2025-08-11 16:08:59 +08:00
|
|
|
import {
|
|
|
|
|
_decorator,
|
|
|
|
|
Component,
|
|
|
|
|
Node,
|
|
|
|
|
instantiate,
|
|
|
|
|
Label,
|
|
|
|
|
Sprite,
|
|
|
|
|
UITransform,
|
|
|
|
|
} 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 ResManager from "db://assets/Scripts/Main/Manager/ResManager";
|
2025-08-13 11:31:21 +08:00
|
|
|
import { ThemeItem } from "../../uiitems/ThemeItem";
|
2025-08-11 16:08:59 +08:00
|
|
|
import { NavigationManager } from "../../manager/NavigationManager";
|
2025-08-13 11:31:21 +08:00
|
|
|
import { GirlListItem } from "../../uiitems/GirlListItem";
|
2025-08-12 16:58:02 +08:00
|
|
|
import ConfigManager from "../../manager/ConfigManager";
|
2025-08-12 19:49:50 +08:00
|
|
|
import LanguageUtils from "../../../Main/Common/LanguageUtils";
|
2025-08-12 20:22:54 +08:00
|
|
|
import { ViewManager } from "../../../Main/Manager/ViewManager";
|
|
|
|
|
import { InnerMsgCode } from "../../../Main/Config/InnerMsgCode";
|
2025-08-11 16:08:59 +08:00
|
|
|
|
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
|
|
|
|
@ccclass("ThemePanel")
|
|
|
|
|
export class ThemePanel extends li_BaseView {
|
|
|
|
|
private _nodeTab: any = {};
|
|
|
|
|
|
|
|
|
|
coinNum: Label;
|
|
|
|
|
itemInst: GirlListItem;
|
|
|
|
|
content: Node;
|
|
|
|
|
|
|
|
|
|
recId: number;
|
|
|
|
|
recName: Label;
|
|
|
|
|
recSprite: Sprite;
|
|
|
|
|
|
|
|
|
|
cache: ThemeItem[] = [];
|
|
|
|
|
|
|
|
|
|
onLoadCT() {
|
|
|
|
|
Utils.parseNode(this.node, this._nodeTab);
|
|
|
|
|
|
|
|
|
|
this.coinNum = this._nodeTab.coinNum.getComponent(Label);
|
|
|
|
|
this.recName = this._nodeTab.characterNameText.getComponent(Label);
|
|
|
|
|
this.recSprite = this._nodeTab.recPicSlot.getComponent(Sprite);
|
|
|
|
|
|
|
|
|
|
this.registerListener();
|
|
|
|
|
this.itemInst = this._nodeTab.ThemeItem.getComponent(ThemeItem);
|
|
|
|
|
this.itemInst.node.active = false;
|
2025-08-13 15:37:15 +08:00
|
|
|
this.content = this._nodeTab.allThemecontent;
|
2025-08-12 19:49:50 +08:00
|
|
|
|
2025-08-11 16:08:59 +08:00
|
|
|
this.Show();
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-12 20:22:54 +08:00
|
|
|
rectNameKey: string;
|
2025-08-11 16:08:59 +08:00
|
|
|
Show() {
|
|
|
|
|
//some temp data
|
|
|
|
|
this.coinNum.string = (50.0).toString();
|
|
|
|
|
this.recId = 1;
|
|
|
|
|
if (this.cache) {
|
|
|
|
|
for (let i = this.cache.length - 1; i >= 0; i--) {
|
|
|
|
|
this.cache[i].node.destroy();
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-12 16:58:02 +08:00
|
|
|
const cfgs = ConfigManager.tables.TbThemes.getDataList();
|
|
|
|
|
for (let i = 0; i < cfgs.length; i++) {
|
|
|
|
|
const cfg = cfgs[i];
|
|
|
|
|
if (!cfg) return;
|
2025-08-11 16:08:59 +08:00
|
|
|
let newNode = instantiate(this.itemInst.node);
|
|
|
|
|
let item = newNode.getComponent(ThemeItem);
|
|
|
|
|
item.refresh(cfg);
|
|
|
|
|
newNode.active = true;
|
|
|
|
|
this.cache.push(item);
|
|
|
|
|
this.content.addChild(newNode);
|
|
|
|
|
}
|
2025-08-12 16:58:02 +08:00
|
|
|
const rectInfo = cfgs[0];
|
2025-08-11 16:08:59 +08:00
|
|
|
this.recId = rectInfo.id;
|
2025-08-12 20:22:54 +08:00
|
|
|
this.rectNameKey = rectInfo.key;
|
|
|
|
|
|
|
|
|
|
//this.recName.string = LanguageUtils.getText(this.rectNameKey);
|
2025-08-11 16:08:59 +08:00
|
|
|
ResManager.I.changeBundleSpriteFrame(
|
|
|
|
|
this.recSprite,
|
2025-08-12 16:58:02 +08:00
|
|
|
rectInfo.path,
|
2025-08-11 16:08:59 +08:00
|
|
|
"Chat18x",
|
|
|
|
|
() => {
|
|
|
|
|
let sizeTran = this.recSprite.node.parent.getComponent(UITransform);
|
|
|
|
|
Utils.adjustBgPixelRatioToSize(
|
|
|
|
|
sizeTran.contentSize,
|
|
|
|
|
this.recSprite.node,
|
|
|
|
|
2
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private registerListener() {
|
|
|
|
|
GButton.BandClick(this._nodeTab.settingBtn, this.openSetting, this);
|
|
|
|
|
GButton.BandClick(this._nodeTab.msgBoxBtn, this.openMsgBox, this);
|
|
|
|
|
|
|
|
|
|
GButton.BandClick(this._nodeTab.ChatWithRecBtn, this.chatWithRec, this);
|
2025-08-12 20:22:54 +08:00
|
|
|
|
|
|
|
|
Utils.addInnerEL(InnerMsgCode.LanguageChange, this, () => {
|
|
|
|
|
this.recName.string = LanguageUtils.getText(this.rectNameKey);
|
|
|
|
|
});
|
2025-08-11 16:08:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
chatWithRec() {
|
|
|
|
|
NavigationManager.Instance.navigateToChat(this.recId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openSetting() {
|
2025-08-12 20:22:54 +08:00
|
|
|
ViewManager.I.openBundlesView("LanguagePanel");
|
2025-08-11 16:08:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openMsgBox() {
|
|
|
|
|
console.log("打开信箱");
|
|
|
|
|
}
|
2025-08-12 20:22:54 +08:00
|
|
|
|
|
|
|
|
onDestroy(): void {
|
|
|
|
|
Utils.removeInnerEL(InnerMsgCode.LanguageChange, this, () => {
|
|
|
|
|
this.recName.string = LanguageUtils.getText(this.rectNameKey);
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-08-11 16:08:59 +08:00
|
|
|
}
|