refactor(ui, talent): 重构图标加载逻辑并简化天赋文案

统一使用全局smc.uiconsAtlas缓存图标图集,移除各组件本地的缓存逻辑与变量
简化CardComp、SkillBoxComp的图标更新代码,删除冗余的异步加载步骤
将两处天赋名称简化,去掉多余的“额外”描述
This commit is contained in:
walkpan
2026-05-11 19:40:39 +08:00
parent 2413e4d1cc
commit 750e86e858
4 changed files with 12 additions and 35 deletions

View File

@@ -29,6 +29,7 @@ import { SkillSet } from "../common/config/SkillSet";
import { GameEvent } from "../common/config/GameEvent";
import { oops } from "db://oops-framework/core/Oops";
import { smc } from "../common/SingletonModuleComp";
import { UIID } from "../common/config/GameUIConfig";
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { TalentType } from "../common/config/TalentSet";
@@ -102,8 +103,6 @@ export class CardComp extends CCComp {
card_uuid:number=0
/** 是否处于锁定状态(锁定且有卡时,抽卡分发会被跳过) */
private isLocked: boolean = false;
/** 图标图集缓存(首次加载后复用,避免重复 IO */
private uiconsAtlas: SpriteAtlas | null = null;
/** 当前槽位承载的卡牌数据null 表示空槽 */
private cardData: CardConfig | null = null;
/** 上划使用阈值(像素):拖拽距离 >= 此值视为"使用卡牌" */
@@ -194,7 +193,7 @@ export class CardComp extends CCComp {
}
/**
* 更新卡牌图标:先尝试从缓存图集获取,未缓存则异步加载图集获取
* 更新卡牌图标:从全局缓存图集获取对应帧
* @param node 图标所在节点
* @param iconId 图标在 SpriteAtlas 中的帧名称
*/
@@ -202,30 +201,11 @@ export class CardComp extends CCComp {
if (!node || !iconId) return;
const sprite = node.getComponent(Sprite) || node.getComponentInChildren(Sprite);
if (!sprite) return;
// 已缓存图集 → 直接获取帧
if (this.uiconsAtlas) {
const frame = this.uiconsAtlas.getSpriteFrame(iconId);
if (frame) {
sprite.spriteFrame = frame;
} else {
sprite.spriteFrame = null;
}
return;
// 已全局缓存图集 → 直接获取帧
if (smc.uiconsAtlas) {
const frame = smc.uiconsAtlas.getSpriteFrame(iconId);
sprite.spriteFrame = frame || null;
}
// 首次加载图集
resources.load("gui/uicons", SpriteAtlas, (err, atlas) => {
if (err || !atlas) {
mLogger.log(this.debugMode, "CardComp", "load uicons atlas failed", err);
return;
}
this.uiconsAtlas = atlas;
const frame = atlas.getSpriteFrame(iconId);
if (frame) {
sprite.spriteFrame = frame;
} else {
sprite.spriteFrame = null;
}
});
}
/**