继续重构调整(UI)

- 引入 UniTask 和异步版本的 UIModule
- 调整 Runtime/UIBase 和 Presentation 下的脚本命名空间到 SepCore.UI
- 将原来的 5 层 UI 迁移到异步实现
- 规范各层的 UI 脚本命名
This commit is contained in:
SepComet
2026-06-03 09:58:37 +08:00
parent 6b8a6a8789
commit 7bba8bbb80
552 changed files with 83648 additions and 2726 deletions
@@ -0,0 +1,6 @@
namespace SepCore.UI
{
public class MenuContext : UIContext
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 77a32872255d9f84b9332418d1352514
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,128 @@
using Cysharp.Threading.Tasks;
using SepCore.Event;
using SepCore.Definition;
using GameFramework.Event;
using UnityGameFramework.Runtime;
namespace SepCore.UI
{
public class MenuController : UIControllerBase<MenuContext, MenuForm>
{
protected override UIFormType UIFormType => UIFormType.MenuForm;
protected override void RefreshUI(MenuForm form, MenuContext context)
{
form.RefreshUI(context);
}
protected override void SubscribeCustomEvents()
{
GameEntry.Event.Subscribe(MenuStartGameEventArgs.EventId, OnMenuStartGameButtonClick);
GameEntry.Event.Subscribe(MenuFileButtonClickEventArgs.EventId, OnMenuFileButtonClick);
GameEntry.Event.Subscribe(MenuGuideButtonClickEventArgs.EventId, OnMenuGuideButtonClick);
GameEntry.Event.Subscribe(MenuSettingButtonClickEventArgs.EventId, OnMenuSettingButtonClick);
GameEntry.Event.Subscribe(MenuQuitButtonClickEventArgs.EventId, OnMenuQuitButtonClick);
GameEntry.Event.Subscribe(MenuAboutButtonClickEventArgs.EventId, OnMenuAboutButtonClick);
}
protected override void UnsubscribeCustomEvents()
{
GameEntry.Event.Unsubscribe(MenuStartGameEventArgs.EventId, OnMenuStartGameButtonClick);
GameEntry.Event.Unsubscribe(MenuFileButtonClickEventArgs.EventId, OnMenuFileButtonClick);
GameEntry.Event.Unsubscribe(MenuGuideButtonClickEventArgs.EventId, OnMenuGuideButtonClick);
GameEntry.Event.Unsubscribe(MenuSettingButtonClickEventArgs.EventId, OnMenuSettingButtonClick);
GameEntry.Event.Unsubscribe(MenuQuitButtonClickEventArgs.EventId, OnMenuQuitButtonClick);
GameEntry.Event.Unsubscribe(MenuAboutButtonClickEventArgs.EventId, OnMenuAboutButtonClick);
}
private static MenuContext BuildMenuContext()
{
return new MenuContext();
}
public override async UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f)
{
if (userData != null)
{
Log.Warning("MenuController.OpenUIAsync() userData type is invalid.");
return null;
}
return await OpenFormAsync(BuildMenuContext(), timeout);
}
public override void BindUseCase(IUIUseCase useCase)
{
Log.Info("StartMenuForm doesn't need UseCase");
}
private void OnMenuStartGameButtonClick(object sender, GameEventArgs e)
{
if (sender is not MenuForm || e is not MenuStartGameEventArgs)
{
return;
}
GameEntry.UIRouter.OpenUIAsync(UIFormType.SelectRoleForm).Forget();
}
private void OnMenuFileButtonClick(object sender, GameEventArgs e)
{
if (sender is not MenuForm || e is not MenuFileButtonClickEventArgs)
{
return;
}
Log.Warning("Menu file button click is not implemented.");
}
private void OnMenuGuideButtonClick(object sender, GameEventArgs e)
{
if (sender is not MenuForm || e is not MenuGuideButtonClickEventArgs)
{
return;
}
Log.Warning("Menu guide button click is not implemented.");
}
private void OnMenuSettingButtonClick(object sender, GameEventArgs e)
{
if (sender is not MenuForm || e is not MenuSettingButtonClickEventArgs)
{
return;
}
GameEntry.UIRouter.OpenUIAsync(UIFormType.SettingForm).Forget();
}
private void OnMenuQuitButtonClick(object sender, GameEventArgs e)
{
if (sender is not MenuForm || e is not MenuQuitButtonClickEventArgs)
{
return;
}
GameEntry.UIRouter.OpenUIAsync(UIFormType.DialogForm, new DialogRawData
{
Mode = 2,
Title = GameEntry.Localization.GetString("AskQuitGame.Title"),
Message = GameEntry.Localization.GetString("AskQuitGame.Message"),
OnClickConfirm = delegate(object userData)
{
UnityGameFramework.Runtime.GameEntry.Shutdown(ShutdownType.Quit);
}
}).Forget();
}
private void OnMenuAboutButtonClick(object sender, GameEventArgs e)
{
if (sender is not MenuForm || e is not MenuAboutButtonClickEventArgs)
{
return;
}
Log.Warning("Menu about button click is not implemented.");
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3feee66cf220f6f47b147bca4f7967f4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,64 @@
using SepCore.Event;
using UnityGameFramework.Runtime;
namespace SepCore.UI
{
public class MenuForm : UGuiForm
{
public void RefreshUI(MenuContext context)
{
}
#region Lifecycle
protected override void OnOpen(object userData)
{
base.OnOpen(userData);
if (userData is MenuContext context)
{
RefreshUI(context);
return;
}
Log.Warning("StartMenuForm requires StartMenuFormContext as userData.");
}
protected override void OnClose(bool isShutdown, object userData)
{
base.OnClose(isShutdown, userData);
}
#endregion
public void OnStartButtonClick()
{
GameEntry.Event.Fire(this, MenuStartGameEventArgs.Create());
}
public void OnFileButtonClick()
{
GameEntry.Event.Fire(this, MenuFileButtonClickEventArgs.Create());
}
public void OnGuideButtonClick()
{
GameEntry.Event.Fire(this, MenuGuideButtonClickEventArgs.Create());
}
public void OnSettingButtonClick()
{
GameEntry.Event.Fire(this, MenuSettingButtonClickEventArgs.Create());
}
public void OnQuitButtonClick()
{
GameEntry.Event.Fire(this, MenuQuitButtonClickEventArgs.Create());
}
public void OnAboutButtonClick()
{
GameEntry.Event.Fire(this, MenuAboutButtonClickEventArgs.Create());
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d448bbb919fe8454da81331191044ead
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: