refactor(HeroBox): 重构技能描述系统,支持富文本高亮与缓存优化
1. 将技能描述拆分为纯文本/富文本双输出接口,数值部分使用金色高亮 2. 新增技能描述缓存,避免重复解析排版降低性能 3. 重构技能文案生成逻辑,统一结构化行处理流程,保证纯/富文本内容一致 4. 修复目标描述文本中的措辞问题
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
* - HeroInfo(heroSet)—— 英雄静态配置
|
||||
*/
|
||||
import { mLogger } from "../common/Logger";
|
||||
import { _decorator, Node, Sprite, Label, resources, AnimationClip, SpriteFrame, NodeEventType, UITransform, Tween, tween, Vec3 } from "cc";
|
||||
import { _decorator, Node, Sprite, Label, RichText, resources, AnimationClip, SpriteFrame, NodeEventType, UITransform, Tween, tween, Vec3 } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
@@ -20,7 +20,7 @@ import { GameEvent } from "../common/config/GameEvent";
|
||||
import { HeroInfo } from "../common/config/heroSet";
|
||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
import { getLvColor } from "../common/config/GameSet";
|
||||
import { buildSkillDesc } from "../common/config/HeroSkillDesc";
|
||||
import { buildSkillDescRich } from "../common/config/HeroSkillDesc";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -53,9 +53,11 @@ export class HeroBoxComp extends CCComp {
|
||||
@property(Node)
|
||||
private noHero: Node = null;
|
||||
|
||||
/** 技能描述标签(多行,展示当前等级触发技能) */
|
||||
@property(Label)
|
||||
private skill_label: Label = null;
|
||||
/** 技能描述富文本(多行,展示当前等级触发技能,数值高亮) */
|
||||
@property(RichText)
|
||||
private skill_label: RichText = null;
|
||||
/** 技能描述富文本内容缓存(避免 refresh 降频内重复重解析排版) */
|
||||
private skillDescCache: string = "";
|
||||
|
||||
// ======================== 战斗信息标签(总值 + 附加值) ========================
|
||||
|
||||
@@ -329,6 +331,7 @@ export class HeroBoxComp extends CCComp {
|
||||
if (this.skill_label && this.skill_label.isValid) {
|
||||
this.skill_label.string = "";
|
||||
}
|
||||
this.skillDescCache = "";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -396,9 +399,14 @@ export class HeroBoxComp extends CCComp {
|
||||
const finalCritDmg = this.model.getFinalCritDamage();
|
||||
this.setStatRow(this.crit_dmg_all_label, this.crit_dmg_plus_label, finalCritDmg, finalCritDmg - (this.model.crit_damage ?? 0), "%");
|
||||
|
||||
// ---- 技能描述(当前等级触发技能,读运行时 model 最终配置) ----
|
||||
// ---- 技能描述(当前等级触发技能,读运行时 model 最终配置;数值富文本高亮) ----
|
||||
if (this.skill_label && this.skill_label.isValid) {
|
||||
this.skill_label.string = buildSkillDesc(this.model);
|
||||
// 缓存未变则跳过重设,避免 refresh 降频内 RichText 重复重解析排版
|
||||
const desc = buildSkillDescRich(this.model);
|
||||
if (desc !== this.skillDescCache) {
|
||||
this.skillDescCache = desc;
|
||||
this.skill_label.string = desc;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 图标(UUID 变化时重新加载首帧动画) ----
|
||||
|
||||
Reference in New Issue
Block a user