refactor(ui): 优化卡牌等级显示逻辑和布局更新

- 移除HInfoComp中品质边框切换逻辑,专注卡牌等级显示
- 简化CardComp中等级节点的布局更新逻辑,仅使用Widget组件
- 调整card.prefab的布局参数和原始宽度
- 禁用role_controller.prefab的_active属性
This commit is contained in:
walkpan
2026-04-21 21:05:21 +08:00
parent 9363f8f1d7
commit e24d169161
6 changed files with 2279 additions and 2001 deletions

View File

@@ -729,19 +729,12 @@ export class CardComp extends CCComp {
}
if (this.lv_node) {
const lvTrans = this.lv_node.getComponent(UITransform);
if (lvTrans) {
lvTrans.setContentSize(this.isEnlarged ? 230 : 170, this.isEnlarged ? 300 : 230);
const widget = this.lv_node.getComponent(Widget);
if (widget) widget.updateAlignment();
}
const widget = this.lv_node.getComponent(Widget);
if (widget) widget.updateAlignment();
this.lv_node.children.forEach(child => {
const childTrans = child.getComponent(UITransform);
if (childTrans) {
childTrans.setContentSize(this.isEnlarged ? 230 : 170, this.isEnlarged ? 300 : 230);
const widget = child.getComponent(Widget);
if (widget) widget.updateAlignment();
}
const childWidget = child.getComponent(Widget);
if (childWidget) childWidget.updateAlignment();
});
}
@@ -981,19 +974,12 @@ export class CardComp extends CCComp {
});
}
if (this.lv_node) {
const lvTrans = this.lv_node.getComponent(UITransform);
if (lvTrans) {
lvTrans.setContentSize(170, 230);
const widget = this.lv_node.getComponent(Widget);
if (widget) widget.updateAlignment();
}
const widget = this.lv_node.getComponent(Widget);
if (widget) widget.updateAlignment();
this.lv_node.children.forEach(child => {
const childTrans = child.getComponent(UITransform);
if (childTrans) {
childTrans.setContentSize(170, 230);
const widget = child.getComponent(Widget);
if (widget) widget.updateAlignment();
}
const childWidget = child.getComponent(Widget);
if (childWidget) childWidget.updateAlignment();
});
}
if (this.HF_node) {

View File

@@ -53,6 +53,9 @@ export class HInfoComp extends CCComp {
@property(Node)
HF_node=null!
@property(Node)
lv_node=null!
/** 绑定的英雄 ECS 实体 ID */
private eid: number = 0;
/** 绑定的英雄属性数据模型引用 */
@@ -96,16 +99,10 @@ export class HInfoComp extends CCComp {
refresh() {
if (!this.model) return;
// ---- 品质边框切换 ----
const isHighLevel = (this.model.lv ?? 0) > 1;
if (this.HF_node) this.HF_node.active = isHighLevel;
if (this.NF_node) this.NF_node.active = !isHighLevel;
// 按卡池等级显示对应子节点
const activeFrameNode = isHighLevel ? this.HF_node : this.NF_node;
if (activeFrameNode) {
// ---- 卡牌等级显示 ----
if (this.lv_node) {
const cardLvStr = `lv${this.model.pool_lv ?? 1}`;
activeFrameNode.children.forEach(child => {
this.lv_node.children.forEach(child => {
child.active = (child.name === cardLvStr);
});
}