This commit is contained in:
CortexCore
2024-07-07 14:27:34 +08:00
parent e6bb3dc5fa
commit c0ded1f99b
4 changed files with 40 additions and 12 deletions

View File

@@ -33,7 +33,8 @@ namespace BITKit.UX
}
private static EntryGroup<IUXPanel> EntryGroup = new();
internal static EntryGroup<IUXPanel> EntryGroup = new();
internal static EntryGroup<IUXPanel> WindowEntryGruop = new();
/// <summary>
/// 内部注册面板队列
/// </summary>
@@ -77,6 +78,11 @@ namespace BITKit.UX
public static void Return()
{
if(WindowEntryGruop.TryGetEntried(out var window))
{
WindowEntryGruop.Entry(-1);
return;
}
if (History.TryPop(out var returnPanel))
{
ReturnBuffer.Release(returnPanel);
@@ -138,6 +144,12 @@ namespace BITKit.UX
if (EntryQueue.TryPop(out var nextPanel))
{
if (nextPanel.IsWindow)
{
WindowEntryGruop.Entry(nextPanel);
return;
}
WindowEntryGruop.Entry(-1);
History.Push(CurrentPanel);
EntryGroup.Entry(x=>x.Index==nextPanel.Index);
BITAppForUnity.AllowCursor.SetElements(this, nextPanel.AllowCursor);
@@ -148,6 +160,10 @@ namespace BITKit.UX
{
currentPanel.OnUpdate(Time.deltaTime);
};
if(WindowEntryGruop.TryGetEntried(out var windowPanel))
{
windowPanel.OnUpdate(Time.deltaTime);
}
}
void IUXService.Register(IUXPanel panel) => Register(panel);
@@ -164,32 +180,36 @@ namespace BITKit.UX
}
#if UNITY_EDITOR
[CustomEditor(typeof(UXService))]
public class UXServiceInspector:BITInspector<UXService>
public class UXServiceInspector : BITInspector<UXService>
{
private Label currentPanelLabel;
private Label currentWindow;
private Label panelsLabel;
private Label historyLabel;
public override VisualElement CreateInspectorGUI()
{
FillDefaultInspector();
CreateSubTitle("States");
currentPanelLabel = root.Create<Label>();
currentWindow = root.Create<Label>();
CreateSubTitle("Panels");
panelsLabel = root.Create<Label>();
CreateSubTitle("History");
historyLabel = root.Create<Label>();
return root;
}
protected override void OnUpdate()
{
if (panelsLabel is null || currentPanelLabel is null || historyLabel is null) return;
panelsLabel.text=string.Join("\n",UXService.Panels);
currentPanelLabel.text = string.Join("\n",UXService.CurrentPanel?.Index);
historyLabel.text = string.Join("\n",UXService.History.Select(x=>x is null ? "Null" : x.Index));
panelsLabel.text = string.Join("\n", UXService.Panels);
currentPanelLabel.text = string.Join("\n", UXService.CurrentPanel?.Index);
historyLabel.text = string.Join("\n", UXService.History.Select(x => x is null ? "Null" : x.Index));
currentWindow.text = UXService.WindowEntryGruop.TryGetEntried(out var window) ? window.Index : "None";
}
}
#endif
#endif
}