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:
File diff suppressed because it is too large
Load Diff
@@ -35,7 +35,7 @@
|
|||||||
* - smc.vmdata.mission_data —— 局内数据(coin / hero_num / hero_max_num)
|
* - smc.vmdata.mission_data —— 局内数据(coin / hero_num / hero_max_num)
|
||||||
*/
|
*/
|
||||||
import { mLogger } from "../common/Logger";
|
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 { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||||
import { GameEvent } from "../common/config/GameEvent";
|
import { GameEvent } from "../common/config/GameEvent";
|
||||||
@@ -591,6 +591,9 @@ export class MissionCardComp extends CCComp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据物品数量设置列表面板高度
|
||||||
|
this.resizeListBox(this.shopBoxNode, ItemCardList.length);
|
||||||
|
|
||||||
// 默认显示商店面板
|
// 默认显示商店面板
|
||||||
if (this.shopPanNode) {
|
if (this.shopPanNode) {
|
||||||
this.shopPanNode.active = true;
|
this.shopPanNode.active = true;
|
||||||
@@ -1006,6 +1009,20 @@ export class MissionCardComp extends CCComp {
|
|||||||
this.hideAllPanels();
|
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),
|
* 从 CardPoolList 获取所有装备卡(trigger_type=Field),
|
||||||
@@ -1033,6 +1050,9 @@ export class MissionCardComp extends CCComp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据物品数量设置列表面板高度
|
||||||
|
this.resizeListBox(this.equipsBoxNode, EquipPoolList.length);
|
||||||
|
|
||||||
// 默认显示装备面板
|
// 默认显示装备面板
|
||||||
if (this.equipsPanNode) {
|
if (this.equipsPanNode) {
|
||||||
this.equipsPanNode.active = true;
|
this.equipsPanNode.active = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user