添加了教育平台
This commit is contained in:
24
BITKit/Scripts/UX/UXDrag.cs
Normal file
24
BITKit/Scripts/UX/UXDrag.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace BITKit;
|
||||
public partial class UXDrag : Control
|
||||
{
|
||||
public override Variant _GetDragData(Vector2 atPosition)
|
||||
{
|
||||
var label = new Label();
|
||||
label.Text = "Drag";
|
||||
return base._GetDragData(atPosition);
|
||||
}
|
||||
|
||||
public override bool _CanDropData(Vector2 atPosition, Variant data)
|
||||
{
|
||||
return base._CanDropData(atPosition, data);
|
||||
}
|
||||
|
||||
public override void _DropData(Vector2 atPosition, Variant data)
|
||||
{
|
||||
base._DropData(atPosition, data);
|
||||
}
|
||||
}
|
@@ -10,11 +10,12 @@ public partial class UXPanel : Control, IUXPanel
|
||||
[Export] private bool allowInput;
|
||||
[Export] private bool isStartPanel;
|
||||
public bool IsAnimate => isAnimate;
|
||||
public string Index => GetType().FullName == typeof(UXPanel).FullName ? Name : GetType().FullName;
|
||||
|
||||
public string Index => _index;
|
||||
public bool AllowCursor => allowCursor;
|
||||
|
||||
public bool AllowInput => allowInput;
|
||||
|
||||
private string _index;
|
||||
public virtual void OnEntry(){}
|
||||
public virtual void Entry()
|
||||
{
|
||||
@@ -32,6 +33,7 @@ public partial class UXPanel : Control, IUXPanel
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_index = GetType().FullName == typeof(UXPanel).FullName ? Name : GetType().FullName;
|
||||
UXService.Register(this);
|
||||
|
||||
if (isStartPanel)
|
||||
@@ -43,8 +45,13 @@ public partial class UXPanel : Control, IUXPanel
|
||||
{
|
||||
UXService.Open(this as IUXPanel);
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
UXService.UnRegister(this);
|
||||
}
|
||||
// protected override void Dispose(bool disposing)
|
||||
// {
|
||||
// UXService.UnRegister(this);
|
||||
// }
|
||||
}
|
||||
|
@@ -67,19 +67,27 @@ public partial class UXService : Control
|
||||
/// <param name="panel">UX面板</param>
|
||||
public static void UnRegister(IUXPanel panel)
|
||||
{
|
||||
UnRegistryQueue.Enqueue(panel);
|
||||
}
|
||||
|
||||
public static void Open<T>() where T : IUXPanel
|
||||
{
|
||||
}
|
||||
|
||||
public static void Open(IUXPanel panel) => EnableQueue.Push(panel);
|
||||
|
||||
public static void Open(Control control)
|
||||
public static void Return()
|
||||
{
|
||||
|
||||
if (History.TryPop(out _))
|
||||
{
|
||||
if(History.TryPop(out var returnPanel))
|
||||
{
|
||||
Open(returnPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Open(IUXPanel panel) => EnableQueue.Push(panel);
|
||||
|
||||
public static void Open(Control control)=>Open(control as IUXPanel);
|
||||
public static void Open(string name)
|
||||
{
|
||||
|
||||
@@ -89,6 +97,11 @@ public partial class UXService : Control
|
||||
/// 内部注册面板队列
|
||||
/// </summary>
|
||||
private static readonly Queue<IUXPanel> RegistryQueue = new();
|
||||
|
||||
/// <summary>
|
||||
/// 内部注销面板队列
|
||||
/// </summary>
|
||||
private static readonly Queue<IUXPanel> UnRegistryQueue = new();
|
||||
|
||||
/// <summary>
|
||||
/// 已注册面板字典
|
||||
@@ -106,11 +119,9 @@ public partial class UXService : Control
|
||||
private static readonly Stack<IUXPanel> EnabledPanels = new();
|
||||
|
||||
/// <summary>
|
||||
/// 等待隐藏的面板
|
||||
/// 历史面板
|
||||
/// </summary>
|
||||
private static readonly Stack<IUXPanel> WActivatedPanels = new();
|
||||
|
||||
|
||||
private static readonly Stack<IUXPanel> History = new();
|
||||
|
||||
/// <summary>
|
||||
/// 正在播放过渡动画的面板
|
||||
@@ -125,6 +136,10 @@ public partial class UXService : Control
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (TransitionPanles.Count is not 0) return;
|
||||
while (UnRegistryQueue.TryDequeue(out var result))
|
||||
{
|
||||
Panels.Remove(result.Index);
|
||||
}
|
||||
while (RegistryQueue.TryDequeue(out var result))
|
||||
{
|
||||
Panels.Add(result.Index, result);
|
||||
@@ -138,6 +153,7 @@ public partial class UXService : Control
|
||||
}
|
||||
next.Entry();
|
||||
EnabledPanels.Push(next);
|
||||
History.Push(next);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
13
BITKit/Scripts/UX/UXServiceProxy.cs
Normal file
13
BITKit/Scripts/UX/UXServiceProxy.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
namespace BITKit;
|
||||
|
||||
public partial class UXServiceProxy : Node
|
||||
{
|
||||
//public static void Return() => UXService.Return();
|
||||
public void Return()
|
||||
{
|
||||
UXService.Return();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user