mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
95 lines
2.4 KiB
C#
95 lines
2.4 KiB
C#
|
using System.Collections.Generic;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using Common;
|
|||
|
using Cysharp.Threading.Tasks;
|
|||
|
using FairyGUI;
|
|||
|
using HotScripts.GameLauncher;
|
|||
|
using MainUI;
|
|||
|
using Plugins.JNGame.System;
|
|||
|
using SHFrame;
|
|||
|
|
|||
|
namespace HotScripts.GameScripts.FGui
|
|||
|
{
|
|||
|
|
|||
|
public enum UILayerEnum
|
|||
|
{
|
|||
|
View,
|
|||
|
}
|
|||
|
|
|||
|
public enum UIID
|
|||
|
{
|
|||
|
Component1
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* UI 配置结构体
|
|||
|
*/
|
|||
|
public struct UIConfigStruct
|
|||
|
{
|
|||
|
public readonly string PkgName;
|
|||
|
public readonly string ResName;
|
|||
|
public readonly UILayerEnum Layer;
|
|||
|
|
|||
|
public UIConfigStruct(string pkgName, string resName, UILayerEnum layer)
|
|||
|
{
|
|||
|
PkgName = pkgName;
|
|||
|
ResName = resName;
|
|||
|
Layer = layer;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public class FGuiManager : SystemBase
|
|||
|
{
|
|||
|
|
|||
|
private UI_MainUI _mainUI;
|
|||
|
|
|||
|
public static Dictionary<UIID, UIConfigStruct> UIConfigMap = new();
|
|||
|
public static Dictionary<UILayerEnum, GComponent> LayerMap = new();
|
|||
|
|
|||
|
public override async Task OnInit()
|
|||
|
{
|
|||
|
await UniTask.DelayFrame(1);
|
|||
|
Log.Debug($"UI 初始化中");
|
|||
|
App.EventLauncher.DispatchEvent(HotLauncherEvent.InitSystem,$"UI 初始化中");
|
|||
|
|
|||
|
BindAll();
|
|||
|
BindUI();
|
|||
|
|
|||
|
await SHFrameModule.UI.AddPackageASync("MainUI");
|
|||
|
|
|||
|
_mainUI = UI_MainUI.CreateInstance();
|
|||
|
_mainUI.MakeFullScreen();
|
|||
|
GRoot.inst.AddChildAt(_mainUI,0);
|
|||
|
_mainUI.Center();
|
|||
|
|
|||
|
LayerMap.Add(UILayerEnum.View,_mainUI.m_View);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 绑定UI包
|
|||
|
/// </summary>
|
|||
|
private void BindAll()
|
|||
|
{
|
|||
|
MainUIBinder.BindAll();
|
|||
|
CommonBinder.BindAll();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 绑定UI配置
|
|||
|
/// </summary>
|
|||
|
private void BindUI()
|
|||
|
{
|
|||
|
UIConfigMap.Add(UIID.Component1,new UIConfigStruct("Common", "Component1", UILayerEnum.View));
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public async UniTask Open<TClassType>(UIID id, params object[] param)
|
|||
|
where TClassType : UIBase, new()
|
|||
|
{
|
|||
|
if (!UIConfigMap.ContainsKey(id)) return;
|
|||
|
var config = UIConfigMap[id];
|
|||
|
await SHFrameModule.UI.Open<TClassType>(config.PkgName, config.ResName, LayerMap[config.Layer], param);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|