添加了部分界面
This commit is contained in:
35
BITKit/Scripts/UX/UXWindowService.cs
Normal file
35
BITKit/Scripts/UX/UXWindowService.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace BITKit;
|
||||
[Tool]
|
||||
public partial class UXWindowService : Control
|
||||
{
|
||||
[Export] private Array<Button> tabs;
|
||||
[Export] private Array<Control> windows;
|
||||
public override void _Ready()
|
||||
{
|
||||
if (Engine.IsEditorHint()) return;
|
||||
if(tabs.Count != windows.Count) throw new Exception("tabs.Count != windows.Count");
|
||||
ButtonGroup buttonGroup = new();
|
||||
for (var i = 0; i < tabs.Count; i++)
|
||||
{
|
||||
var tab = tabs[i];
|
||||
var window = windows[i];
|
||||
tab.Pressed += () =>
|
||||
{
|
||||
ShowWindow(window);
|
||||
};
|
||||
}
|
||||
}
|
||||
private void ShowWindow(CanvasItem window)
|
||||
{
|
||||
foreach (var x in windows)
|
||||
{
|
||||
//if(window.Visible is true && window != x)
|
||||
x.Hide();
|
||||
}
|
||||
window.Show();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user