refactor(map): add dynamic height adjustment for mission list boxes

add resizeListBox utility method to auto-calculate container height based on item count
adjust shop and equip list heights automatically when populating data
This commit is contained in:
panFD
2026-07-22 22:58:58 +08:00
parent 516b937531
commit f3d97e5163
2 changed files with 5450 additions and 11614 deletions

View File

@@ -35,7 +35,7 @@
* - smc.vmdata.mission_data —— 局内数据coin / hero_num / hero_max_num
*/
import { mLogger } from "../common/Logger";
import { _decorator, instantiate, Label, Node, NodeEventType, Prefab, Tween, tween, Vec3 } from "cc";
import { _decorator, instantiate, Label, Node, NodeEventType, Prefab, Tween, tween, Vec3, 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 { GameEvent } from "../common/config/GameEvent";
@@ -591,6 +591,9 @@ export class MissionCardComp extends CCComp {
}
}
// 根据物品数量设置列表面板高度
this.resizeListBox(this.shopBoxNode, ItemCardList.length);
// 默认显示商店面板
if (this.shopPanNode) {
this.shopPanNode.active = true;
@@ -1006,6 +1009,20 @@ export class MissionCardComp extends CCComp {
this.hideAllPanels();
}
/**
* 根据子项数量设置容器高度。
* 单项高度 100间隔 5上下各加 25 冗余(共 50
*/
private resizeListBox(boxNode: Node, count: number) {
if (!boxNode || !boxNode.isValid) return;
const itemHeight = 100;
const spacing = 5;
const padding = 50;
const height = Math.max(0, count) * (itemHeight + spacing) - spacing + padding;
const uiTransform = boxNode.getComponent(UITransform) || boxNode.addComponent(UITransform);
uiTransform.setContentSize(uiTransform.width, height);
}
/**
* 填充装备列表:
* 从 CardPoolList 获取所有装备卡trigger_type=Field
@@ -1033,6 +1050,9 @@ export class MissionCardComp extends CCComp {
}
}
// 根据物品数量设置列表面板高度
this.resizeListBox(this.equipsBoxNode, EquipPoolList.length);
// 默认显示装备面板
if (this.equipsPanNode) {
this.equipsPanNode.active = true;