按 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:
@@ -1,6 +1,7 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.Event;
|
||||
using SepCore.Definition;
|
||||
using SepCore.CustomUtility;
|
||||
using GameFramework.Event;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
@@ -61,7 +62,8 @@ namespace SepCore.UI
|
||||
propertyContext = new RolePropertyAreaContext
|
||||
{
|
||||
RoleName = rawData.SelectedRoleName,
|
||||
InitialPropertyText = rawData.SelectedRoleInitialPropertyText
|
||||
InitialPropertyText = ItemDescUtility.CreatePropDescription(rawData.SelectedRoleInitialProperties)
|
||||
?? string.Empty
|
||||
};
|
||||
}
|
||||
|
||||
@@ -78,6 +80,7 @@ namespace SepCore.UI
|
||||
if (userData is SelectRoleRawData rawData)
|
||||
{
|
||||
await OpenUIAsync(rawData, timeout);
|
||||
return;
|
||||
}
|
||||
|
||||
if (userData != null)
|
||||
|
||||
@@ -25,7 +25,35 @@ namespace SepCore.CustomUtility
|
||||
{"attackDuration", "突刺时长"},
|
||||
{"returnDuration", "收枪时长"}
|
||||
};
|
||||
|
||||
|
||||
private static readonly string[] _statTypeNames =
|
||||
{
|
||||
"无效",
|
||||
"最大生命",
|
||||
"移动速度",
|
||||
"伤害",
|
||||
"防御",
|
||||
"冷却",
|
||||
"暴击率",
|
||||
"暴击伤害",
|
||||
"闪避",
|
||||
"金币/经验吸收范围"
|
||||
};
|
||||
|
||||
public static string Describe(StatModifier modifier)
|
||||
{
|
||||
if (modifier == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
string name = _statTypeNames[(int)modifier.StatType];
|
||||
string colorTag = modifier.Value > 0 ? "green" : "red";
|
||||
string suffix = modifier.IsPercent ? "%" : string.Empty;
|
||||
float displayValue = modifier.IsPercent ? modifier.Value * 100 : modifier.Value;
|
||||
return $"{name}: <color={colorTag}>+{displayValue}{suffix}</color>";
|
||||
}
|
||||
|
||||
public static string CreatePropDescription(StatModifier[] modifiers)
|
||||
{
|
||||
if (modifiers == null || modifiers.Length == 0)
|
||||
@@ -36,7 +64,7 @@ namespace SepCore.CustomUtility
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (StatModifier modifier in modifiers)
|
||||
{
|
||||
sb.Append(modifier);
|
||||
sb.Append(Describe(modifier));
|
||||
sb.Append('\n');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user