116 lines
2.8 KiB
C#
116 lines
2.8 KiB
C#
using Godot;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace BITKit;
|
|
/// <summary>
|
|
/// 基本UX面板接口,定义了基本的UX面板功能
|
|
/// </summary>
|
|
/// <para>⭐同步打开与关闭</para>
|
|
/// <para>⭐异步打开与关闭</para>
|
|
/// <para>⭐当前可见状态</para>
|
|
/// <para>⭐基本UI导航回调</para>
|
|
public interface IUXPanel
|
|
{
|
|
/// <summary>
|
|
/// 该面板是否具有动画
|
|
/// </summary>
|
|
bool IsAnimate { get; }
|
|
/// <summary>
|
|
/// 该面板的索引(入口,Key)
|
|
/// </summary>
|
|
string Index { get; }
|
|
/// <summary>
|
|
/// 该面板是否启用指针
|
|
/// </summary>
|
|
bool AllowCursor { get; }
|
|
/// <summary>
|
|
/// 该面板是否启用玩家输入
|
|
/// </summary>
|
|
bool AllowInput { get; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 基本UX服务(GUI管理器),主要通过加载叠加面板实现
|
|
/// </summary>
|
|
/// <para>使用方式:</para>
|
|
///
|
|
///
|
|
public partial class UXService : Control
|
|
{
|
|
private static UXService Singleton;
|
|
/// <summary>
|
|
/// 在构造函数中注入依赖
|
|
/// </summary>
|
|
public UXService()
|
|
{
|
|
BITApp.ServiceCollection.AddSingleton(this);
|
|
Singleton = this;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 注册面板,加入注册队列
|
|
/// </summary>
|
|
/// <param name="panel">UX面板</param>
|
|
public static void Register(IUXPanel panel)
|
|
{
|
|
RegistryQueue.Enqueue(panel);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 注销面板
|
|
/// </summary>
|
|
/// <param name="panel">UX面板</param>
|
|
public static void UnRegister(IUXPanel panel)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// 内部注册面板队列
|
|
/// </summary>
|
|
private static readonly Queue<IUXPanel> RegistryQueue = new();
|
|
/// <summary>
|
|
/// 已注册面板字典
|
|
/// </summary>
|
|
private static readonly Dictionary<string, IUXPanel> Panels = new();
|
|
|
|
/// <summary>
|
|
/// 等待启用的面板队列
|
|
/// </summary>
|
|
private static readonly Stack<IUXPanel> WaitingActivePanels = new();
|
|
|
|
/// <summary>
|
|
/// 已启用面板
|
|
/// </summary>
|
|
private static readonly Stack<IUXPanel> ActivatedPanels = new();
|
|
|
|
/// <summary>
|
|
/// 等待隐藏的面板
|
|
/// </summary>
|
|
private static readonly Stack<IUXPanel> WActivatedPanels = new();
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 正在播放过渡动画的面板
|
|
/// </summary>
|
|
private static readonly Stack<IUXPanel> TransitionPanles = new();
|
|
public override void _Ready()
|
|
{
|
|
if (RegistryQueue.TryDequeue(out var panel))
|
|
{
|
|
Panels.Add(panel.Index,panel);
|
|
}
|
|
}
|
|
private void Entry(IUXPanel panel)
|
|
{
|
|
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
if(TransitionPanles.Count is not 0)return;
|
|
}
|
|
}
|