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

@@ -0,0 +1,6 @@
---
alwaysApply: true
scene: git_message
---
在此处编写规则,自定义 AI 生成提交信息的风格。

View File

@@ -6392,9 +6392,9 @@
"__prefab": {
"__id__": 283
},
"_alignFlags": 33,
"_alignFlags": 9,
"_target": null,
"_left": -4.281999999999989,
"_left": -0.7980000000000018,
"_right": 130.798,
"_top": 67.42699999999999,
"_bottom": -6.274000000000001,
@@ -6406,7 +6406,7 @@
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalWidth": 40,
"_originalHeight": 40,
"_alignMode": 2,
"_lockFlags": 0,
@@ -9318,6 +9318,8 @@
"__id__": 0
},
"fileId": "4d8lwMrctFq4mRNVU1cDrV",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{

File diff suppressed because it is too large Load Diff

View File

@@ -1938,7 +1938,7 @@
"__id__": 92
}
],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 100

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);
});
}