第一批重构,主要是物理迁移脚本和部分命名空间的调整

- 结构上迁移文件,将脚本分成 Base/Runtime/Presentation/Procedure/Editor 五大文件夹
- 调整 DataTable 和 Definition 下脚本的命名空间
- 依据 UI-5层架构设计规范 拆分原先的 UI 到 Runtime 和 Presentation 下
This commit is contained in:
SepComet
2026-06-02 19:12:34 +08:00
parent 56f74eee9a
commit 34c0784190
655 changed files with 1272 additions and 516 deletions
@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using SepCore.Definition;
using UnityGameFramework.Runtime;
using UI;
namespace CustomComponent
{
public class UIRouterComponent : GameFrameworkComponent
{
private readonly Dictionary<UIFormType, IUIFormController> _routeControllers = new();
public void BindUIUseCase(UIFormType uiFormType, IUIUseCase useCase)
{
IUIFormController controller = GetOrCreateController(uiFormType);
controller.BindUseCase(useCase);
}
public int? OpenUI(UIFormType uiFormType, object userData = null)
{
IUIFormController controller = GetOrCreateController(uiFormType);
return controller.OpenUI(userData);
}
public void CloseUI(UIFormType uiFormType)
{
IUIFormController controller = GetOrCreateController(uiFormType);
controller.CloseUI();
}
private IUIFormController GetOrCreateController(UIFormType uiFormType)
{
if (_routeControllers.TryGetValue(uiFormType, out IUIFormController controller))
{
return controller;
}
string typename = $"UI.{uiFormType}Controller";
Type controllerType = Type.GetType(typename);
if (controllerType == null)
{
controller = new DefaultUIFormController(uiFormType);
}
else
{
controller = (IUIFormController)Activator.CreateInstance(controllerType);
}
_routeControllers.Add(uiFormType, controller);
return controller;
}
private void OnDestroy()
{
foreach (KeyValuePair<UIFormType, IUIFormController> pair in _routeControllers)
{
pair.Value.CloseUI();
}
_routeControllers.Clear();
}
private class DefaultUIFormController : IUIFormController
{
private readonly UIFormType _uiFormType;
private int? _lastSerialId;
public DefaultUIFormController(UIFormType uiFormType)
{
_uiFormType = uiFormType;
}
public int? OpenUI(object userData = null)
{
_lastSerialId = GameEntry.UI.OpenUIForm(_uiFormType, userData);
return _lastSerialId;
}
public void CloseUI()
{
if (_lastSerialId.HasValue)
{
GameEntry.UI.CloseUIForm(_lastSerialId.Value);
_lastSerialId = null;
return;
}
UGuiForm uiForm = GameEntry.UI.GetUIForm(_uiFormType);
if (uiForm != null)
{
GameEntry.UI.CloseUIForm(uiForm);
}
}
public void BindUseCase(IUIUseCase useCase)
{
}
}
}
}