update 历史聊天妹子页
This commit is contained in:
@@ -0,0 +1,148 @@
|
||||
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 { GButton } from "db://assets/Scripts/Main/Common/GButton";
|
||||
import { PastGirlListItem } from "../../uiitems/PastGirlListItem";
|
||||
import { DataManager, DataId } from "../../data/DataManager";
|
||||
import { GirlData } from "../../data/GirlData";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("PastGirlListPanel")
|
||||
export class PastGirlListPanel extends li_BaseView {
|
||||
private _nodeTab: any = {};
|
||||
|
||||
itemInst: PastGirlListItem;
|
||||
content: Node;
|
||||
|
||||
cache: PastGirlListItem[] = [];
|
||||
|
||||
// 缓存池相关属性
|
||||
private itemPool: PastGirlListItem[] = [];
|
||||
private maxPoolSize: number = 20;
|
||||
|
||||
onLoadCT() {
|
||||
Utils.parseNode(this.node, this._nodeTab);
|
||||
this.registerListener();
|
||||
this.itemInst = this._nodeTab.BubbleItem.getComponent(PastGirlListItem);
|
||||
this.itemInst.node.active = false;
|
||||
this.content = this._nodeTab.content;
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
// 从缓存池获取节点
|
||||
private getItemFromPool(): PastGirlListItem {
|
||||
if (this.itemPool.length > 0) {
|
||||
return this.itemPool.pop();
|
||||
} else {
|
||||
// 缓存池为空,检查是否有隐藏的节点可以复用
|
||||
for (let i = 0; i < this.content.children.length; i++) {
|
||||
let childNode = this.content.children[i];
|
||||
if (!childNode.active && childNode !== this.itemInst.node) {
|
||||
let item = childNode.getComponent(PastGirlListItem);
|
||||
if (item) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 没有可复用的节点,创建新节点
|
||||
let newNode = instantiate(this.itemInst.node);
|
||||
let item = newNode.getComponent(PastGirlListItem);
|
||||
this.content.addChild(newNode);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
// 将节点回收到缓存池
|
||||
private returnItemToPool(item: PastGirlListItem) {
|
||||
if (this.itemPool.length < this.maxPoolSize) {
|
||||
item.reset();
|
||||
this.itemPool.push(item);
|
||||
} else {
|
||||
// 缓存池已满,隐藏节点但不销毁
|
||||
item.reset();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: 实现获取已解锁女孩列表的逻辑
|
||||
// 这个方法需要遍历所有分类,找出 isRelease === true 的女孩
|
||||
private getUnlockedGirls(): number[] {
|
||||
// TODO: 实现获取已解锁女孩列表逻辑
|
||||
// 需要实现的逻辑:
|
||||
// 1. 遍历 GirlData 中的所有分类
|
||||
// 2. 对每个分类中的每个女孩检查 getIsRelease 状态
|
||||
// 3. 返回所有已解锁女孩的 {category, id} 列表
|
||||
console.log("TODO: 实现获取已解锁女孩列表逻辑");
|
||||
return [10001, 10002];
|
||||
}
|
||||
|
||||
refresh() {
|
||||
// 回收当前显示的节点到缓存池
|
||||
if (this.cache) {
|
||||
for (let i = this.cache.length - 1; i >= 0; i--) {
|
||||
let item = this.cache[i];
|
||||
this.returnItemToPool(item);
|
||||
}
|
||||
this.cache = [];
|
||||
}
|
||||
|
||||
// 获取已解锁女孩列表
|
||||
const ids = this.getUnlockedGirls();
|
||||
|
||||
// 根据数据,刷新界面
|
||||
for (let id of ids) {
|
||||
let item = this.getItemFromPool();
|
||||
item.refreshData(id, this.node);
|
||||
item.node.active = true;
|
||||
this.cache.push(item);
|
||||
|
||||
// 确保节点在 content 中(可能已经在了)
|
||||
if (item.node.parent !== this.content) {
|
||||
this.content.addChild(item.node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hide() {
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
private registerListener() {
|
||||
GButton.BandClick(this._nodeTab.ReturnBtn, this.Return, this);
|
||||
}
|
||||
|
||||
Return() {
|
||||
// 直接关闭,不需要动画
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
// 清理缓存池,销毁所有缓存的节点
|
||||
for (let item of this.itemPool) {
|
||||
if (item && item.node) {
|
||||
item.node.destroy();
|
||||
}
|
||||
}
|
||||
this.itemPool = [];
|
||||
|
||||
// 清理当前显示的节点
|
||||
for (let item of this.cache) {
|
||||
if (item && item.node) {
|
||||
item.node.destroy();
|
||||
}
|
||||
}
|
||||
this.cache = [];
|
||||
|
||||
// 清理 content 中所有的 GirlListItem 节点
|
||||
for (let i = this.content.children.length - 1; i >= 0; i--) {
|
||||
let child = this.content.children[i];
|
||||
if (child !== this.itemInst.node) {
|
||||
let item = child.getComponent(PastGirlListItem);
|
||||
if (item) {
|
||||
child.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "311c4e83-620c-41e2-9c37-623f4971f005",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -235,9 +235,15 @@ export class Web3PopPanel extends li_BaseView {
|
||||
const secs = seconds % 60;
|
||||
|
||||
if (hours > 0) {
|
||||
return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
|
||||
return `${Utils.padStart(hours.toString(), 2)}:${Utils.padStart(
|
||||
minutes.toString(),
|
||||
2
|
||||
)}:${Utils.padStart(secs.toString(), 2)}`;
|
||||
} else {
|
||||
return `${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
|
||||
return `${Utils.padStart(minutes.toString(), 2)}:${Utils.padStart(
|
||||
secs.toString(),
|
||||
2
|
||||
)}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,7 +292,7 @@ export class Web3PopPanel extends li_BaseView {
|
||||
private resetButtonStates(): void {
|
||||
const copyBtn = this._nodeTab.CopyBtn;
|
||||
if (copyBtn) {
|
||||
const btnComponent = copyBtn.getComponent('Button');
|
||||
const btnComponent = copyBtn.getComponent("Button");
|
||||
if (btnComponent) {
|
||||
btnComponent.interactable = true;
|
||||
}
|
||||
@@ -294,7 +300,7 @@ export class Web3PopPanel extends li_BaseView {
|
||||
|
||||
const coinTypeSelectBtn = this._nodeTab.CoinTypeSelectBtn;
|
||||
if (coinTypeSelectBtn) {
|
||||
const btnComponent = coinTypeSelectBtn.getComponent('Button');
|
||||
const btnComponent = coinTypeSelectBtn.getComponent("Button");
|
||||
if (btnComponent) {
|
||||
btnComponent.interactable = true;
|
||||
}
|
||||
@@ -304,7 +310,7 @@ export class Web3PopPanel extends li_BaseView {
|
||||
private disableButtons(): void {
|
||||
const copyBtn = this._nodeTab.CopyBtn;
|
||||
if (copyBtn) {
|
||||
const btnComponent = copyBtn.getComponent('Button');
|
||||
const btnComponent = copyBtn.getComponent("Button");
|
||||
if (btnComponent) {
|
||||
btnComponent.interactable = false;
|
||||
}
|
||||
@@ -312,7 +318,7 @@ export class Web3PopPanel extends li_BaseView {
|
||||
|
||||
const coinTypeSelectBtn = this._nodeTab.CoinTypeSelectBtn;
|
||||
if (coinTypeSelectBtn) {
|
||||
const btnComponent = coinTypeSelectBtn.getComponent('Button');
|
||||
const btnComponent = coinTypeSelectBtn.getComponent("Button");
|
||||
if (btnComponent) {
|
||||
btnComponent.interactable = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user