refactor(ui): 重构装备和英雄的词条展示逻辑

1. 替换单个Label词条为RichText多行展示
2. 统一使用buildEquipRich和buildSkillDescRich生成带高亮的词条文本
3. 调整prefab的UI元素尺寸适配新的富文本展示
4. 新增showName参数适配不同场景的技能名显示需求
This commit is contained in:
pan
2026-07-31 17:12:47 +08:00
parent b4a42baee5
commit e026ee0e35
8 changed files with 1981 additions and 1616 deletions

View File

@@ -197,13 +197,16 @@ function buildEffectLine(head: string, skill: SkillConfig): ISkillLine {
*
* Why: FieldSkillConfig.info 是手写文案,改 value 易漂移。这里以 FieldSkillType
* 为 key 查标准动词,数值按 fmt比例/整数/减免)从 value 实时渲染。
*
* @param showName 是否在行中包含「技能名」片段(英雄面板需要,装备商店不需要)
*/
function buildFieldLine(head: string, uuid: number): ISkillLine | null {
function buildFieldLine(head: string, uuid: number, showName: boolean = true): ISkillLine | null {
const fs = FieldSkillSet[uuid];
if (!fs) return null;
const desc = FieldDescSet[fs.type];
const nameSeg = showName ? `${fs.name}` : "";
// 未入表类型回退基础备注 info整行不高亮
if (!desc) return { prefix: `${head}${fs.name}${fs.info}`, value: "", suffix: "" };
if (!desc) return { prefix: `${head}${nameSeg}${fs.info}`, value: "", suffix: "" };
// 数值按格式渲染为高亮片段
let valueText: string;
@@ -219,7 +222,7 @@ function buildFieldLine(head: string, uuid: number): ISkillLine | null {
valueText = `+${fs.value}`;
break;
}
return { prefix: `${head}${fs.name}${desc.verb}`, value: valueText, suffix: "" };
return { prefix: `${head}${nameSeg}${desc.verb}`, value: valueText, suffix: "" };
}
/**
@@ -291,7 +294,7 @@ function buildSkillLines(source: ISkillDescSource): ISkillLine[] {
if (fieldUuids?.length) {
const tpl = SkillTriggerName[SkillTriggerType.Field] ?? "光环";
for (const uuid of fieldUuids) {
const line = buildFieldLine(`${tpl}:`, uuid);
const line = buildFieldLine(`${tpl}:`, uuid, true);
if (line) lines.push(line);
}
}
@@ -362,15 +365,16 @@ export function buildSingleSkillRich(skillUuid: number, overrides?: SkillOverrid
}
/**
* 装备详情富文本IBox 弹窗用):展示装备包含的全部驻场光环词条
* 装备/驻场光环详情富文本:展示全部词条,数值绿色高亮
* @param fieldUuids FieldSkillSet 驻场光环 UUID 数组
* @param showName 是否包含「技能名」片段(英雄面板 true装备商店 false
* @returns 多行富文本串,每行一个词条
*/
export function buildEquipRich(fieldUuids: number[]): string {
export function buildEquipRich(fieldUuids: number[], showName: boolean = false): string {
if (!fieldUuids?.length) return "无词条";
const lines: string[] = [];
for (const uuid of fieldUuids) {
const line = buildFieldLine("", uuid);
const line = buildFieldLine("", uuid, showName);
if (!line) continue;
const prefix = line.prefix.replace(SKILL_NAME_PATTERN, `「<color=${RICH_NAME_COLOR}>$1</color>」`);
const text = line.value