refactor(ui): 统一技能图标图集缓存逻辑
将技能图标加载从通用uiconsAtlas拆分到专属skillIconsAtlas, 在SinfoComp、SSkillBoxComp、TalentItemComp中替换图集引用, 并添加对应注释明确图集使用范围。
This commit is contained in:
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 2.0 MiB |
@@ -89,6 +89,9 @@ export class SingletonModuleComp extends ecs.Comp {
|
|||||||
/** 全局缓存的通用图集 */
|
/** 全局缓存的通用图集 */
|
||||||
uiconsAtlas: SpriteAtlas | null = null;
|
uiconsAtlas: SpriteAtlas | null = null;
|
||||||
|
|
||||||
|
/** 全局缓存的技能图标图集(gui/ui7,SinfoComp/TalentItemComp/SSkillBoxComp 专用) */
|
||||||
|
skillIconsAtlas: SpriteAtlas | null = null;
|
||||||
|
|
||||||
mission: any = {
|
mission: any = {
|
||||||
status: 0, //0:未开始 1:进行中 2:胜利 3:失败
|
status: 0, //0:未开始 1:进行中 2:胜利 3:失败
|
||||||
play: false,
|
play: false,
|
||||||
|
|||||||
@@ -253,8 +253,9 @@ export class SSkillBoxComp extends CCComp {
|
|||||||
}
|
}
|
||||||
if (this.icon_node && this.icon_node.isValid) {
|
if (this.icon_node && this.icon_node.isValid) {
|
||||||
let sprite = this.icon_node.getComponent(Sprite) || this.icon_node.addComponent(Sprite);
|
let sprite = this.icon_node.getComponent(Sprite) || this.icon_node.addComponent(Sprite);
|
||||||
if (smc.uiconsAtlas && iconId) {
|
// 技能图标统一走 gui/ui7 图集缓存
|
||||||
const frame = smc.uiconsAtlas.getSpriteFrame(iconId);
|
if (smc.skillIconsAtlas && iconId) {
|
||||||
|
const frame = smc.skillIconsAtlas.getSpriteFrame(iconId);
|
||||||
sprite.spriteFrame = frame || null; // 取不到时清空,避免残留
|
sprite.spriteFrame = frame || null; // 取不到时清空,避免残留
|
||||||
} else {
|
} else {
|
||||||
sprite.spriteFrame = null;
|
sprite.spriteFrame = null;
|
||||||
|
|||||||
@@ -361,8 +361,9 @@ export class SinfoComp extends CCComp {
|
|||||||
if (!this.icon_node || !this.icon_node.isValid) return;
|
if (!this.icon_node || !this.icon_node.isValid) return;
|
||||||
const iconId = p.card_icon ?? this.resolveIconId(p);
|
const iconId = p.card_icon ?? this.resolveIconId(p);
|
||||||
let sprite = this.icon_node.getComponent(Sprite) || this.icon_node.addComponent(Sprite);
|
let sprite = this.icon_node.getComponent(Sprite) || this.icon_node.addComponent(Sprite);
|
||||||
if (smc.uiconsAtlas && iconId) {
|
// 技能图标统一走 gui/ui7 图集缓存
|
||||||
const frame = smc.uiconsAtlas.getSpriteFrame(iconId);
|
if (smc.skillIconsAtlas && iconId) {
|
||||||
|
const frame = smc.skillIconsAtlas.getSpriteFrame(iconId);
|
||||||
sprite.spriteFrame = frame || null;
|
sprite.spriteFrame = frame || null;
|
||||||
} else {
|
} else {
|
||||||
sprite.spriteFrame = null;
|
sprite.spriteFrame = null;
|
||||||
|
|||||||
@@ -91,11 +91,11 @@ export class TalentItemComp extends CCComp {
|
|||||||
// 阶位背景:激活对应颜色子节点(Ⅰ蓝 / Ⅱ红 / Ⅲ金)
|
// 阶位背景:激活对应颜色子节点(Ⅰ蓝 / Ⅱ红 / Ⅲ金)
|
||||||
if (this.bg) this.applyTierBg(cfg.tier, inactive);
|
if (this.bg) this.applyTierBg(cfg.tier, inactive);
|
||||||
|
|
||||||
// 图标:uiconsAtlas 优先,资源目录回退(与 TalentItemComp 旧版/SCardComp 口径一致)
|
// 图标:技能图标图集(gui/ui7)优先,资源目录回退(与 SCardComp 口径一致)
|
||||||
if (this.icon && cfg.icon) {
|
if (this.icon && cfg.icon) {
|
||||||
let frame: SpriteFrame | null = null;
|
let frame: SpriteFrame | null = null;
|
||||||
if (smc.uiconsAtlas) {
|
if (smc.skillIconsAtlas) {
|
||||||
frame = smc.uiconsAtlas.getSpriteFrame(cfg.icon);
|
frame = smc.skillIconsAtlas.getSpriteFrame(cfg.icon);
|
||||||
}
|
}
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
frame = oops.res.get("game/heros/cards/" + cfg.icon, SpriteFrame) as SpriteFrame;
|
frame = oops.res.get("game/heros/cards/" + cfg.icon, SpriteFrame) as SpriteFrame;
|
||||||
|
|||||||
Reference in New Issue
Block a user