fix: 调整英雄列表组件调试模式与布局
1. 将CardLiteComp的debugMode默认值改为false 2. 修复heros预制体的Widget对齐参数与位置 3. 优化HerosListComp的日志调试开关,新增卡片列表内容高度自适应逻辑
This commit is contained in:
@@ -102,7 +102,7 @@
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"y": 366,
|
||||
"z": 0
|
||||
},
|
||||
"_lrot": {
|
||||
@@ -212,16 +212,16 @@
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": false,
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 8
|
||||
},
|
||||
"_alignFlags": 45,
|
||||
"_alignFlags": 4,
|
||||
"_target": null,
|
||||
"_left": 144,
|
||||
"_right": 144,
|
||||
"_top": 117,
|
||||
"_bottom": 227,
|
||||
"_left": -5,
|
||||
"_right": -5,
|
||||
"_top": -5,
|
||||
"_bottom": 0,
|
||||
"_horizontalCenter": 0,
|
||||
"_verticalCenter": 0,
|
||||
"_isAbsLeft": true,
|
||||
|
||||
@@ -39,7 +39,7 @@ const { ccclass, property } = _decorator;
|
||||
@ccclass('CardLiteComp')
|
||||
@ecs.register('CardLiteComp', false)
|
||||
export class CardLiteComp extends CCComp {
|
||||
private debugMode: boolean = true;
|
||||
private debugMode: boolean = false;
|
||||
|
||||
// ======================== 编辑器绑定节点 ========================
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* - CardLiteComp —— 轻量卡片组件
|
||||
* - buildSkillDesc(HeroSkillDesc)—— 技能描述生成器
|
||||
*/
|
||||
import { _decorator, Animation, AnimationClip, Label, Node, Prefab, Sprite, Widget, instantiate, resources } from "cc";
|
||||
import { _decorator, Animation, AnimationClip, Label, Node, Prefab, Sprite, UITransform, Widget, instantiate, resources } 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";
|
||||
@@ -89,7 +89,7 @@ export class HerosListComp extends CCComp {
|
||||
// ======================== 卡片列表 ========================
|
||||
|
||||
private initCardList() {
|
||||
mLogger.log(true, "HerosListComp", "initCardList start", {
|
||||
mLogger.log(this.debugMode, "HerosListComp", "initCardList start", {
|
||||
hasCardsNode: !!this.cards_node,
|
||||
hasPrefab: !!this.card_lite_prefab,
|
||||
heroListLen: HeroList.length,
|
||||
@@ -97,7 +97,7 @@ export class HerosListComp extends CCComp {
|
||||
|
||||
if (!this.cards_node || !this.card_lite_prefab) return
|
||||
|
||||
mLogger.log(true, "HerosListComp", "cards_node info", {
|
||||
mLogger.log(this.debugMode, "HerosListComp", "cards_node info", {
|
||||
name: this.cards_node.name,
|
||||
active: this.cards_node.active,
|
||||
childrenCount: this.cards_node.children.length,
|
||||
@@ -115,7 +115,7 @@ export class HerosListComp extends CCComp {
|
||||
const cardNode = instantiate(this.card_lite_prefab)
|
||||
cardNode.name = `card_${uuid}`
|
||||
|
||||
mLogger.log(true, "HerosListComp", `card instantiated ${uuid}`, {
|
||||
mLogger.log(this.debugMode, "HerosListComp", `card instantiated ${uuid}`, {
|
||||
cardActive: cardNode.active,
|
||||
cardPos: cardNode.position.toString(),
|
||||
cardScale: cardNode.scale.toString(),
|
||||
@@ -134,9 +134,31 @@ export class HerosListComp extends CCComp {
|
||||
this.cards_node.addChild(cardNode)
|
||||
}
|
||||
|
||||
mLogger.log(true, "HerosListComp", "initCardList done", {
|
||||
mLogger.log(this.debugMode, "HerosListComp", "initCardList done", {
|
||||
totalChildren: this.cards_node.children.length,
|
||||
})
|
||||
|
||||
this.updateContentSize()
|
||||
}
|
||||
|
||||
private updateContentSize() {
|
||||
const total = this.cards_node.children.length
|
||||
if (total === 0) return
|
||||
|
||||
const cols = 4
|
||||
const rows = Math.ceil(total / cols)
|
||||
const cardH = 200
|
||||
const spacingY = 10
|
||||
const contentH = Math.max(1000, rows * (cardH + spacingY) + 50)
|
||||
|
||||
const uiTrans = this.cards_node.getComponent(UITransform)
|
||||
if (uiTrans) {
|
||||
uiTrans.setContentSize(uiTrans.width, contentH)
|
||||
}
|
||||
|
||||
mLogger.log(this.debugMode, "HerosListComp", "updateContentSize", {
|
||||
total, cols, rows, contentH,
|
||||
})
|
||||
}
|
||||
|
||||
private highlightCard(cardNode: Node) {
|
||||
|
||||
Reference in New Issue
Block a user