mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 19:34:47 +00:00
117 lines
3.1 KiB
C#
117 lines
3.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using Common;
|
|
using Cysharp.Threading.Tasks;
|
|
using FairyGUI;
|
|
using Hall;
|
|
using HotScripts.GameScripts.FGui.Scripts.Common;
|
|
// using HotScripts.GameLauncher;
|
|
using JNGame.Runtime.System;
|
|
using MainUI;
|
|
using SHFrame;
|
|
|
|
namespace HotScripts.GameScripts.FGui
|
|
{
|
|
|
|
public enum UILayerEnum
|
|
{
|
|
View, //页面
|
|
Tip, //提示
|
|
}
|
|
|
|
public enum UIID
|
|
{
|
|
Tip,
|
|
Hall
|
|
}
|
|
|
|
/**
|
|
* UI 配置结构体
|
|
*/
|
|
public struct UIConfigStruct
|
|
{
|
|
public readonly string PkgName;
|
|
public readonly string ResName;
|
|
public readonly UILayerEnum Layer;
|
|
public readonly bool IsOnce;
|
|
|
|
public UIConfigStruct(string pkgName, string resName, UILayerEnum layer, bool isOnce)
|
|
{
|
|
PkgName = pkgName;
|
|
ResName = resName;
|
|
Layer = layer;
|
|
IsOnce = isOnce;
|
|
}
|
|
}
|
|
|
|
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);
|
|
LayerMap.Add(UILayerEnum.Tip,_mainUI.m_Tip);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定UI包
|
|
/// </summary>
|
|
private async void BindAll()
|
|
{
|
|
//加载依赖包
|
|
await SHFrameModule.UI.AddPackageASync("Common");
|
|
|
|
CommonBinder.BindAll();
|
|
MainUIBinder.BindAll();
|
|
HallBinder.BindAll();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定UI配置
|
|
/// </summary>
|
|
private void BindUI()
|
|
{
|
|
UIConfigMap.Add(UIID.Tip,new UIConfigStruct("Common", "TipTitleUI", UILayerEnum.Tip,false));
|
|
UIConfigMap.Add(UIID.Hall,new UIConfigStruct("Hall", "HallUI", UILayerEnum.View,true));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 打开页面
|
|
/// </summary>
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 打开提示
|
|
/// </summary>
|
|
public void Tip(string title)
|
|
{
|
|
Open<TipTitleUI>(UIID.Tip,title).Forget();
|
|
}
|
|
|
|
}
|
|
} |