refactor: 新增富文本描边工具并优化深色面板文案可读性
1. 新增RichOutline工具类,封装cc.RichText的outline标签包裹逻辑 2. 为所有道具/技能/英雄描述富文本添加黑色2px描边,提升深色背景下的可读性 3. 优化技能描述渲染逻辑: - 调整数值高亮色为更鲜亮的绿色 - 使用罗马数字作为技能等级徽章 - 移除升级预览弹窗的重复描述,改为当前/升级后双版本对比 - 简化升级确认弹窗的格式排版 4. 调整道具/技能预制体的文字颜色为白色,适配深色面板
This commit is contained in:
@@ -22,7 +22,7 @@ import { HeroInfo } from "../common/config/heroSet";
|
||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
import { Hero } from "../hero/Hero";
|
||||
import { FacSet, FightSet, getLvColor, NumberFormatter } from "../common/config/GameSet";
|
||||
import { buildSkillDesc, ISkillDescSource } from "../common/config/HeroSkillDesc";
|
||||
import { buildSkillDescMoreRich, ISkillDescSource } from "../common/config/HeroSkillDesc";
|
||||
import { MissionEconomy } from "./MissionEconomy";
|
||||
import { UIID } from "../common/config/GameUIConfig";
|
||||
import { HeroMoreCom } from "./HeroMoreCom";
|
||||
@@ -180,12 +180,12 @@ export class HeroBoxComp extends CCComp {
|
||||
oops.message.dispatchEvent(GameEvent.ShowSmallTip, { type: "buy_coin", text: "金币不足" });
|
||||
return;
|
||||
}
|
||||
const preview = this.buildUpgradePreview(nextLv);
|
||||
const preview = this.buildUpgradePreview(heroLv, nextLv);
|
||||
|
||||
// oops.gui 公共确认窗口(自定义 CommonPrompt:内容支持富文本高亮)
|
||||
oops.gui.open(UIID.Window, {
|
||||
title: `升级英雄`,
|
||||
content: `<color=#C0392B>${heroName}</color> Lv.${heroLv} → <color=#1E8449>Lv.${nextLv}</color>\n消耗 <color=#E67E22>${cost}</color> 金币\n\n<b>升级后获得:</b>\n${preview}`,
|
||||
content: `<color=#C0392B>${heroName}</color> Lv.${heroLv} → <color=#1E8449>Lv.${nextLv}</color>\n消耗 <color=#E67E22>${cost}</color> 金币\n\n${preview}`,
|
||||
okWord: "升级",
|
||||
cancelWord: "取消",
|
||||
needCancel: true,
|
||||
@@ -205,28 +205,20 @@ export class HeroBoxComp extends CCComp {
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建升级后新能力预览富文本。
|
||||
* 数据源取 HeroInfo 静态配置(lv 置为目标等级),由描述标准层统一渲染,
|
||||
* 与面板技能描述同一套文案规则,杜绝数值漂移。
|
||||
* 构建升级前后对比富文本(当前能力 vs 升级后能力)。
|
||||
* 数据源取 HeroInfo 静态配置,分别按当前 lv 与 nextLv 渲染同一份技能描述,
|
||||
* 与英雄信息弹窗(buildSkillDescMoreRich)同一套文案规则,杜绝数值漂移。
|
||||
*
|
||||
* @param heroLv 当前英雄等级
|
||||
* @param nextLv 目标等级
|
||||
* @returns 多行富文本:属性成长 + 下一档触发技能/光环/复活/加成
|
||||
* @returns 多行富文本:当前属性→升级后属性 + 当前技能 vs 升级后技能
|
||||
*/
|
||||
private buildUpgradePreview(nextLv: number): string {
|
||||
private buildUpgradePreview(heroLv: number, nextLv: number): string {
|
||||
const hero = HeroInfo[this.model?.hero_uuid ?? 0];
|
||||
if (!hero) return "";
|
||||
|
||||
// ---- 属性成长(按 HERO_LV_MULTIPLIER 幂成长 + 等级额外加成) ----
|
||||
const mult = Math.pow(FightSet.HERO_LV_MULTIPLIER, nextLv - 1);
|
||||
const nextAp = Math.floor(hero.ap * mult + HeroBoxComp.sumBonus(hero.ap_bonus, nextLv));
|
||||
const nextHp = Math.floor(hero.hp * mult + HeroBoxComp.sumBonus(hero.hp_bonus, nextLv));
|
||||
const lines: string[] = [
|
||||
`攻击 <color=#27AE60>${nextAp}</color> 生命 <color=#27AE60>${nextHp}</color>`
|
||||
];
|
||||
|
||||
// ---- 新能力(触发技能 / 驻场光环 / 复活 / 额外加成,取目标等级生效档) ----
|
||||
const source: ISkillDescSource = {
|
||||
lv: nextLv,
|
||||
const buildSource = (lv: number): ISkillDescSource => ({
|
||||
lv: lv,
|
||||
call: hero.call,
|
||||
dead: hero.dead,
|
||||
fstart: hero.fstart,
|
||||
@@ -235,11 +227,29 @@ export class HeroBoxComp extends CCComp {
|
||||
atked: hero.atked,
|
||||
field: hero.field,
|
||||
revive: hero.revive,
|
||||
// 预览仅展示增量,额外加成由上方属性成长体现,避免重复
|
||||
});
|
||||
|
||||
// ---- 属性成长(按 HERO_LV_MULTIPLIER 幂成长 + 等级额外加成) ----
|
||||
const attrLine = (lv: number): string => {
|
||||
const mult = Math.pow(FightSet.HERO_LV_MULTIPLIER, lv - 1);
|
||||
const ap = Math.floor(hero.ap * mult + HeroBoxComp.sumBonus(hero.ap_bonus, lv));
|
||||
const hp = Math.floor(hero.hp * mult + HeroBoxComp.sumBonus(hero.hp_bonus, lv));
|
||||
return `攻击 <color=#27AE60>${ap}</color> 生命 <color=#27AE60>${hp}</color>`;
|
||||
};
|
||||
const skillDesc = buildSkillDesc(source);
|
||||
if (skillDesc) lines.push(skillDesc);
|
||||
return lines.join("\n");
|
||||
|
||||
// ---- 升级前后能力对比(当前 vs 升级后,同一份文案规则按 lv 渲染) ----
|
||||
const curDesc = buildSkillDescMoreRich(buildSource(heroLv));
|
||||
const nextDesc = buildSkillDescMoreRich(buildSource(nextLv));
|
||||
|
||||
return [
|
||||
`<b>当前 Lv.${heroLv}:</b>`,
|
||||
attrLine(heroLv),
|
||||
curDesc,
|
||||
``,
|
||||
`<b>升级后 Lv.${nextLv}:</b>`,
|
||||
attrLine(nextLv),
|
||||
nextDesc,
|
||||
].filter(s => s !== undefined).join("\n");
|
||||
}
|
||||
|
||||
/** 累加等级额外加成(≤目标等级的所有档位) */
|
||||
|
||||
Reference in New Issue
Block a user