This commit is contained in:
CortexCore
2024-06-14 16:16:13 +08:00
parent ca93bd2c56
commit dfa249677f
7 changed files with 40 additions and 41 deletions

View File

@@ -107,6 +107,8 @@ namespace BITKit.UX
private Button _cancelButton;
private void Start()
{
destroyCancellationToken.Register(Dispose);
DI.Register<IUXDialogue,UnityDialogue>();
UXUtils.Inject(this);
@@ -114,8 +116,14 @@ namespace BITKit.UX
Close();
}
private void Dispose()
{
}
internal void PrintAlertMessage(AlertMessage message)
{
if(destroyCancellationToken.IsCancellationRequested)return;
document.rootVisualElement.SetActive(true);
_titleLabel.text = message.title;
_contextLabel.text = message.message;

View File

@@ -54,6 +54,11 @@ namespace BITKit.UX
/// </summary>
private static readonly Stack<IUXPanel> EntryQueue = new();
/// <summary>
/// 返回面板缓冲区
/// </summary>
private static readonly DoubleBuffer<IUXPanel> ReturnBuffer = new();
/// <summary>
/// 已启用面板
/// </summary>
@@ -74,12 +79,11 @@ namespace BITKit.UX
{
if (History.TryPop(out var returnPanel))
{
Entry(returnPanel);
ReturnBuffer.Release(returnPanel);
}
}
public static void Entry(IUXPanel panel) => EntryQueue.Push(panel);
public static void Entry(string panelName) => EntryQueue.Push(Panels[panelName]);
[SerializeReference, SubclassSelector] private IUXPanel initialPanel;
@@ -103,7 +107,7 @@ namespace BITKit.UX
}
private static void OnExit(IUXPanel obj)
{
History.Push(obj);
//History.Push(obj);
}
private static void OnEntry(IUXPanel obj)
{
@@ -125,8 +129,16 @@ namespace BITKit.UX
Panels.Remove(result.Index);
}
if (ReturnBuffer.TryGetRelease(out var returnPanel))
{
EntryGroup.Entry(x=>x.Index==returnPanel.Index);
BITAppForUnity.AllowCursor.SetElements(this, returnPanel.AllowCursor);
BITInputSystem.AllowInput.SetElements(this, returnPanel.AllowInput);
}
if (EntryQueue.TryPop(out var nextPanel))
{
History.Push(CurrentPanel);
EntryGroup.Entry(x=>x.Index==nextPanel.Index);
BITAppForUnity.AllowCursor.SetElements(this, nextPanel.AllowCursor);
BITInputSystem.AllowInput.SetElements(this, nextPanel.AllowInput);
@@ -136,38 +148,6 @@ namespace BITKit.UX
{
currentPanel.OnUpdate(Time.deltaTime);
};
// if (initialized is false && initialPanel is not null)
// {
// initialized = true;
// Entry(initialPanel);
// }
//
// if (!EntryQueue.TryPop(out var next) || next is null) return;
//
// if (Panels.ContainsKey(next.Index) is false) return;
//
// while (EntryCompletedPanels.TryPop(out var entryCompletedPanel))
// {
// entryCompletedPanel?.Exit();
// }
//
// try
// {
// next.Entry();
// }
// catch (Exception e)
// {
// Debug.LogWarning(next.Index);
// Debug.LogException(e);
// }
//
// BITAppForUnity.AllowCursor.SetElements(this, next.AllowCursor);
// BITInputSystem.AllowInput.SetElements(this, next.AllowInput);
//
// EntryCompletedPanels.Push(next);
// History.Push(next);
}
void IUXService.Register(IUXPanel panel) => Register(panel);

View File

@@ -8,6 +8,7 @@ using UnityEngine.UIElements;
namespace BITKit.UX
{
[AttributeUsage(AttributeTargets.Field|AttributeTargets.Property)]
public class UXBindPathAttribute : Attribute
{
public string Path;