fix(heroBox): 修复英雄面板属性显示错位与展开收起高度异常

1.  修正了暴击率/击晕率的文本和节点名称混淆问题
2.  添加属性栏容器节点,实现展开收起时动态调整高度
3.  修复预制体中属性行的绑定关系错乱问题
This commit is contained in:
pan
2026-07-28 16:07:03 +08:00
parent 16cc50cfdf
commit 371178fce3
2 changed files with 76 additions and 62 deletions

View File

@@ -12,7 +12,7 @@
* - HeroInfoheroSet—— 英雄静态配置
*/
import { mLogger } from "../common/Logger";
import { _decorator, Node, Sprite, Label, resources, AnimationClip, SpriteFrame, NodeEventType } from "cc";
import { _decorator, Node, Sprite, Label, resources, AnimationClip, SpriteFrame, NodeEventType, UITransform } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { oops } from "db://oops-framework/core/Oops";
@@ -112,6 +112,9 @@ export class HeroBoxComp extends CCComp {
// ======================== 更多属性折叠栏 ========================
/** 属性栏容器(展开/收起时动态调整高度) */
@property(Node)
private attr_box: Node = null;
/** 更多按钮(点击展开/收起次级属性栏) */
@property(Node)
private more_btn: Node = null;
@@ -133,6 +136,10 @@ export class HeroBoxComp extends CCComp {
/** 次级属性栏是否展开 */
private moreExpanded: boolean = false;
/** 属性栏收起高度 */
private static readonly ATTR_BOX_HEIGHT_COLLAPSED = 125;
/** 属性栏展开高度 */
private static readonly ATTR_BOX_HEIGHT_EXPANDED = 210;
// ======================== 运行时状态 ========================
@@ -166,7 +173,7 @@ export class HeroBoxComp extends CCComp {
this.setMoreRowsVisible(this.moreExpanded);
}
/** 设置 5 个次级属性栏(击晕/冰冻/击退/穿透/风怒)的可见性 */
/** 设置 5 个次级属性栏(击晕/冰冻/击退/穿透/风怒)的可见性,并同步调整属性栏高度 */
private setMoreRowsVisible(visible: boolean) {
const rows = [this.stun_row, this.freeze_row, this.knockback_row, this.puncture_row, this.wfuny_row];
for (const row of rows) {
@@ -174,6 +181,12 @@ export class HeroBoxComp extends CCComp {
row.active = visible;
}
}
// 展开/收起时切换属性栏高度125 ↔ 210
if (this.attr_box && this.attr_box.isValid) {
const transform = this.attr_box.getComponent(UITransform) || this.attr_box.addComponent(UITransform);
const height = visible ? HeroBoxComp.ATTR_BOX_HEIGHT_EXPANDED : HeroBoxComp.ATTR_BOX_HEIGHT_COLLAPSED;
transform.setContentSize(transform.width, height);
}
}
/** ECS 组件移除时销毁节点 */