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