Files
18xchat/assets/Scripts/test/girlListPanel/GirlListPanel.ts
T

68 lines
1.8 KiB
TypeScript
Raw Normal View History

2025-07-25 18:27:30 +08:00
import { _decorator, Component, Node,instantiate } from 'cc';
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
import Utils from "db://assets/Scripts/Main/Common/Utils";
import {GirlListItem} from "db://assets/Scripts/test/girlListPanel/GirlListItem";
2025-08-01 18:28:36 +08:00
import { GirlsData} from "db://assets/Scripts/Main/Config/cfg/characters";
2025-07-30 21:52:26 +08:00
import {GButton} from "db://assets/Scripts/Main/Common/GButton";
2025-07-25 15:20:02 +08:00
const { ccclass, property } = _decorator;
@ccclass('GirlListPanel')
2025-07-25 18:27:30 +08:00
export class GirlListPanel extends li_BaseView {
private _nodeTab: any = {};
2025-07-25 15:20:02 +08:00
2025-07-25 18:27:30 +08:00
itemInst:GirlListItem;
content:Node;
cache:GirlListItem[] = [];
2025-07-30 21:52:26 +08:00
id:number;
openUIDataCT(data)
{
this.id = data;
}
2025-07-25 18:27:30 +08:00
onLoadCT() {
Utils.parseNode(this.node,this._nodeTab);
this.registerListener();
this.itemInst = this._nodeTab.BubbleItem.getComponent(GirlListItem);
this.itemInst.node.active = false;
this.content = this._nodeTab.content;
2025-07-30 21:52:26 +08:00
this.refresh(this.id);
2025-07-25 18:27:30 +08:00
}
2025-07-30 21:52:26 +08:00
refresh(index:number)
2025-07-25 18:27:30 +08:00
{
if(this.cache)
{
for(let i = this.cache.length-1; i >=0; i--)
{
this.cache[i].node.destroy();
}
}
2025-07-30 21:52:26 +08:00
const config = GirlsData.filter(value=>value.category == index);
2025-07-25 18:27:30 +08:00
for (let i = 0; i < config.length; i++) {
const cfg = config[i];
let newNode = instantiate(this.itemInst.node)
let item = newNode.getComponent(GirlListItem);
item.refreshData(cfg,this.node);
newNode.active = true;
this.cache.push(item);
this.content.addChild(newNode);
2025-07-25 15:20:02 +08:00
}
}
2025-07-25 18:27:30 +08:00
2025-07-30 21:52:26 +08:00
private registerListener() {
GButton.BandClick(this._nodeTab.ReturnBtn,this.Return,this);
}
Return()
{
this.onClose();
}
2025-07-25 15:20:02 +08:00
}