按 UI 五层规范重构 SelectRoleForm 并整理事件目录
- SelectRoleForm 五层归位:UseCase 改为构造注入 IProcedureMenu(新增 Runtime/ProcedureInterface),RawData 暴露原始 StatModifier[] 而非展示串,Controller 复用 ItemDescUtility 拼装属性文本,并修复 OpenUIAsync(object) 合法 RawData 分支缺少 return 的误报路径 - StatModifier 去展示职责:删除 _statTypeNames / ToString,富文本格式化下沉到 Presentation 层的 ItemDescUtility.Describe(StatModifier),CreatePropDescription 改用统一入口 - 事件目录按 UIForm 归档:Base/Event/UI/Menu/* 拆解到 SelectRoleForm/ MenuForm/ DialogForm/ DisplayItemInfoForm/ Combat/ 等各自子目录,MenuSelectRoleReturnEventArgs 改名 SelectRoleReturnEventArgs,语义归属本 UI 模块 - IUIFormController → IUIController 改名,联动 UIControllerBase / UIRouterComponent / Editor - 同步更新 docs/UI-5层架构设计规范.md 中相关示例与 MenuForm.prefab、ProcedureMenu 引用
This commit is contained in:
@@ -23,8 +23,8 @@ namespace SepCore.UIRouter
|
||||
|
||||
[SerializeField] private List<ControllerBinding> _controllerBindings = new();
|
||||
|
||||
private readonly Dictionary<UIFormType, IUIFormController> _routeControllers = new();
|
||||
private readonly Dictionary<UIFormType, Func<IUIFormController>> _controllerFactories = new();
|
||||
private readonly Dictionary<UIFormType, IUIController> _routeControllers = new();
|
||||
private readonly Dictionary<UIFormType, Func<IUIController>> _controllerFactories = new();
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
@@ -32,7 +32,7 @@ namespace SepCore.UIRouter
|
||||
RegisterSerializedBindings();
|
||||
}
|
||||
|
||||
public void RegisterController(UIFormType uiFormType, Func<IUIFormController> controllerFactory)
|
||||
public void RegisterController(UIFormType uiFormType, Func<IUIController> controllerFactory)
|
||||
{
|
||||
if (controllerFactory == null)
|
||||
{
|
||||
@@ -40,7 +40,7 @@ namespace SepCore.UIRouter
|
||||
return;
|
||||
}
|
||||
|
||||
if (_routeControllers.TryGetValue(uiFormType, out IUIFormController controller))
|
||||
if (_routeControllers.TryGetValue(uiFormType, out IUIController controller))
|
||||
{
|
||||
controller.CloseUIAsync().Forget();
|
||||
_routeControllers.Remove(uiFormType);
|
||||
@@ -50,14 +50,14 @@ namespace SepCore.UIRouter
|
||||
}
|
||||
|
||||
public void RegisterController<TController>(UIFormType uiFormType)
|
||||
where TController : IUIFormController, new()
|
||||
where TController : IUIController, new()
|
||||
{
|
||||
RegisterController(uiFormType, () => new TController());
|
||||
}
|
||||
|
||||
public void BindUIUseCase(UIFormType uiFormType, IUIUseCase useCase)
|
||||
{
|
||||
IUIFormController controller = GetOrCreateController(uiFormType);
|
||||
IUIController controller = GetOrCreateController(uiFormType);
|
||||
if (controller == null)
|
||||
{
|
||||
return;
|
||||
@@ -68,7 +68,7 @@ namespace SepCore.UIRouter
|
||||
|
||||
public UniTask OpenUIAsync(UIFormType uiFormType, object userData = null, float timeout = 30f)
|
||||
{
|
||||
IUIFormController controller = GetOrCreateController(uiFormType);
|
||||
IUIController controller = GetOrCreateController(uiFormType);
|
||||
if (controller == null)
|
||||
{
|
||||
return default;
|
||||
@@ -79,7 +79,7 @@ namespace SepCore.UIRouter
|
||||
|
||||
public UniTask CloseUIAsync(UIFormType uiFormType, object userData = null, float timeout = 30f)
|
||||
{
|
||||
IUIFormController controller = GetOrCreateController(uiFormType);
|
||||
IUIController controller = GetOrCreateController(uiFormType);
|
||||
if (controller == null)
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
@@ -88,14 +88,14 @@ namespace SepCore.UIRouter
|
||||
return controller.CloseUIAsync(userData, timeout);
|
||||
}
|
||||
|
||||
private IUIFormController GetOrCreateController(UIFormType uiFormType)
|
||||
private IUIController GetOrCreateController(UIFormType uiFormType)
|
||||
{
|
||||
if (_routeControllers.TryGetValue(uiFormType, out IUIFormController controller))
|
||||
if (_routeControllers.TryGetValue(uiFormType, out IUIController controller))
|
||||
{
|
||||
return controller;
|
||||
}
|
||||
|
||||
if (!_controllerFactories.TryGetValue(uiFormType, out Func<IUIFormController> controllerFactory))
|
||||
if (!_controllerFactories.TryGetValue(uiFormType, out Func<IUIController> controllerFactory))
|
||||
{
|
||||
Log.Error("UIRouterComponent requires a controller binding for '{0}'.", uiFormType.ToString());
|
||||
return null;
|
||||
@@ -141,7 +141,7 @@ namespace SepCore.UIRouter
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!typeof(IUIFormController).IsAssignableFrom(controllerType))
|
||||
if (!typeof(IUIController).IsAssignableFrom(controllerType))
|
||||
{
|
||||
Log.Warning("UIRouter binding type '{0}' does not implement IUIFormController.",
|
||||
binding.ControllerTypeName);
|
||||
@@ -152,10 +152,10 @@ namespace SepCore.UIRouter
|
||||
}
|
||||
}
|
||||
|
||||
private static IUIFormController CreateController(Type controllerType)
|
||||
private static IUIController CreateController(Type controllerType)
|
||||
{
|
||||
object instance = Activator.CreateInstance(controllerType);
|
||||
if (instance is IUIFormController controller)
|
||||
if (instance is IUIController controller)
|
||||
{
|
||||
return controller;
|
||||
}
|
||||
@@ -165,7 +165,7 @@ namespace SepCore.UIRouter
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
foreach (KeyValuePair<UIFormType, IUIFormController> pair in _routeControllers)
|
||||
foreach (KeyValuePair<UIFormType, IUIController> pair in _routeControllers)
|
||||
{
|
||||
pair.Value.CloseUIAsync().Forget();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user