代码结构整理

This commit is contained in:
2025-08-11 16:08:59 +08:00
parent ab4d0093d9
commit dad0f47974
81 changed files with 2408 additions and 1179 deletions
@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "2658c05e-6d94-4fdb-aba8-3e2ae8bb989b",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,60 @@
import { _decorator, Component, instantiate, Node, Vec3 } from "cc";
import { DialogManager } from "../../manager/DialogManager";
import { DialogBubble } from "./DialogBubble";
import { Dialog } from "../../utils/DemoData";
const { ccclass, property } = _decorator;
const BUTTOM_Y = -955.571;
@ccclass("ChatContentsLayout")
export class ChatContentsLayout extends Component {
manager: DialogManager = null;
@property(DialogBubble)
lBubble: DialogBubble = null;
@property(DialogBubble)
rBubble: DialogBubble = null;
bubbles: DialogBubble[] = [];
protected start(): void {
this.lBubble.node.active = false;
this.rBubble.node.active = false;
}
protected onEnable(): void {
if (!this.manager) this.manager = DialogManager.getInstance();
this.manager.layoutout = this;
}
UpdateDialog(dialogs: Dialog[]) {
//if (!this.bubbles) this.bubbles = [];
for (let i = this.bubbles.length - 1; i >= 0; i--) {
if (this.bubbles[i].node) {
this.bubbles[i].node.destroy();
}
}
this.bubbles = [];
let initPosY: number = BUTTOM_Y;
for (let i = dialogs.length - 1; i >= 0; i--) {
const dialog = dialogs[i]; //倒序
let newBubbleNode = dialog.isPlayer
? instantiate(this.rBubble.node)
: instantiate(this.lBubble.node);
let newBubble = newBubbleNode.getComponent(DialogBubble);
newBubbleNode.setParent(this.node);
newBubble.node.active = true;
let offset = newBubble.updateBubbleContent(dialog.content);
let pos = newBubble.node.position;
newBubble.node.position = new Vec3(pos.x, initPosY, pos.z);
initPosY += offset + 20;
this.bubbles.push(newBubble);
}
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "8abe19dc-5ef2-4ff2-bc27-6c92e7b9f311",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,57 @@
import { _decorator, Component, Label, Node, Size, UITransform } from "cc";
import Tools from "../../utils/tools";
const { ccclass, property } = _decorator;
@ccclass("DialogBubble")
export class DialogBubble extends Component {
@property(UITransform)
bg: UITransform = null;
@property(Label)
content: Label = null;
@property(UITransform)
contentT: UITransform = null;
updateBubbleContent(str: string) {
const lines = str.split("\n");
let len = 0;
let index = 0;
for (let i = 0; i < lines.length; i++) {
const element = lines[i];
if (element.length > len) {
len = element.length;
index = i;
}
}
let finalLen = 0;
// for (let i = 0; i < lines[index].length; i++) {
// const element = lines[index][i];
// if ("\u4e00" <= element[i] && element[i] <= "\u9fff") {
// finalLen += 35;
// } else {
// finalLen += 18;
// }
// }
if (Tools.IsChinese(lines[index])) {
finalLen = 35 * lines[index].length;
} else {
finalLen = 21 * lines[index].length;
}
this.content.string = str;
this.contentT.setContentSize(
new Size(Math.min(finalLen, 950), this.contentT.contentSize.y)
);
this.content.updateRenderData();
this.bg.setContentSize(
new Size(
this.contentT.contentSize.x + 30,
this.contentT.contentSize.y + 20
)
);
return this.bg.contentSize.y;
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "f5819f30-6fb8-435b-883e-1483a8bf9a92",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,52 @@
import { _decorator, Component, Node,Sprite,Vec3 ,tween, UITransform} from 'cc';
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
import Utils from "db://assets/Scripts/Main/Common/Utils";
import {ViewManager} from "db://assets/Scripts/Main/Manager/ViewManager";
const { ccclass, property } = _decorator;
@ccclass('ImagePopup')
export class ImagePopup extends Component {
@property(Sprite)
image:Sprite;
start()
{
this.node.setPosition(new Vec3(-1500,493,0));
this.image.node.on(Node.EventType.TOUCH_START,this.openImage);
}
onDestroy()
{
//this.image.node.off(Node.EventType.TOUCH_START,this.openImage);
}
refresh(path:string)
{
ResManager.I.changeBundleSpriteFrame(this.image,path,"Chat18x",()=>{
let sizeTran = this.image.node.parent.getComponent(UITransform);
Utils.adjustBgPixelRatioToSize(sizeTran.contentSize,this.image.node,2);
this.popUp();
});
}
openImage()
{
let data = {url:"Image/Girls/10001/DetailImg/10001_3"};
ViewManager.I.openBundlesView('ShowPanel',data);
}
popUp()
{
tween(this.node).to(0.5,{position:new Vec3(-559.374,493,0)},{easing:"backOut"}).start();
this.scheduleOnce(()=>{
this.popDown();
},5);
}
popDown()
{
tween(this.node).to(0.5,{position:new Vec3(-1500,493,0)},{easing:"backIn"}).start();
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "fdde853b-08ee-4506-8e7f-dc9148d53056",
"files": [],
"subMetas": {},
"userData": {}
}
+9
View File
@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "fbb76b35-35bf-4407-8d3b-69b39369f6bc",
"files": [],
"subMetas": {},
"userData": {}
}
+9
View File
@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "cefc0f42-f528-4cd7-ba0a-24c1372b4599",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,117 @@
import { _decorator, Component, EditBox, Node,Label,Sprite,UITransform } from "cc";
// 首先加载 polyfills 以确保兼容性
import "../../utils/polyfills";
import { DialogManager } from "../../manager/DialogManager";
import { ChatAIService } from "../../core/ChatAIService";
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
import Utils from "db://assets/Scripts/Main/Common/Utils";
import {InnerMsgCode} from "db://assets/Scripts/Main/Config/InnerMsgCode";
import {ChatContentsLayout} from "../components/ChatContentsLayout";
import {ViewManager} from "db://assets/Scripts/Main/Manager/ViewManager";
import GameRootUI from "db://assets/Scripts/Main/Common/GameRootUI";
import {ImagePopup} from "../components/ImagePopup";
import {girlDetailInfo, GirlsData} from "db://assets/Scripts/Main/Config/cfg/characters";
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
import {VideoRoleType} from "db://assets/Scripts/Main/Common/GlobalValue";
const { ccclass, property } = _decorator;
@ccclass("ChatPanel")
export class ChatPanel extends li_BaseView {
manager: DialogManager = null;
@property(EditBox)
editBox: EditBox = null;
@property(Label)
girlName: Label = null;
@property(Sprite)
girlImg: Sprite = null;
@property(ChatContentsLayout)
layout: ChatContentsLayout = null;
@property(ImagePopup)
popUpImage: ImagePopup = null;
id:number
private _nodeTab: any = {};
openUIDataCT(data)
{
this.id = data;
// 设置当前聊天的角色ID
ChatAIService.Instance.setCurrentRole(this.id);
}
onLoadCT()
{
Utils.parseNode(this.node,this._nodeTab);
this.register();
this.refresh(this.id);
}
register()
{
Utils.addInnerEL(InnerMsgCode.Chat_DialogRefresh,this,this.onDialogUpdate);
}
refresh(id:number) {
this.id = id;
const data = girlDetailInfo.filter(value=>value.baseInfo.id == id)[0];
if(!data) return;
this.girlName.string = data.baseInfo.name;
ResManager.I.changeBundleSpriteFrame(this.girlImg,data.baseInfo.pic.url,"Chat18x",()=>{
let sizeTran = this.girlImg.node.parent.getComponent(UITransform);
Utils.adjustBgPixelRatioToSize(sizeTran.contentSize,this.girlImg.node,2);
});
let uiTransform:UITransform = this._nodeTab.BgFrame.getComponent(UITransform);
Utils.sendInnerMsg(InnerMsgCode.SimplePlayVide,{path:data.pics[0].url,size:uiTransform.contentSize} )
}
onDialogUpdate()
{
this.layout.UpdateDialog(DialogManager.getInstance().getDialogs())
}
protected onEnable(): void {
if (!this.manager) this.manager = DialogManager.getInstance();
GameRootUI.I.hideDefaultView();
}
public async OnClickSend() {
const str = this.editBox.string;
if (!str || str == "") return;
console.log("post:" + str);
this.editBox.string = "";
DialogManager.getInstance().updateDialog(true, str,true);
// 使用新的sendMessage方法,传入角色ID
const ret = await ChatAIService.Instance.sendMessage(this.id, str);
console.log(ret);
if (ret == null) {
console.warn("rep null");
}
if (this.manager) {
this.manager.updateDialog(false, ret);
}
console.log("ret:" + ret);
//测试
//this.popUpImage.refresh("Image/1/blur_naked_1");
}
returnBtn()
{
this.onClose();
GameRootUI.I.showDefaultView();
//ViewManager.I.openBundlesView("GirlListPanel");
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "dec595e5-5faf-4bea-a040-c4784be2f43c",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,67 @@
import {_decorator, Component, math, Node, Sprite} from 'cc';
import {Config18x, PicInfo} from "db://assets/Scripts/Main/Config/Config18x";
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
import PicType = Config18x.PicType;
import ImageState = Config18x.ImageState;
import {ViewManager} from "db://assets/Scripts/Main/Manager/ViewManager";
import {GButton} from "db://assets/Scripts/Main/Common/GButton";
import {GirlDetailPanel} from "./GirlDetailPanel";
const {ccclass, property} = _decorator;
@ccclass('DetailImageItem')
export class DetailImageItem extends Component {
@property(Sprite)
img: Sprite;
@property(Node)
lock: Node;
@property(Node)
question: Node;
base:GirlDetailPanel;
url:string;
onLoad()
{
GButton.BandClick(this.node,this.onClickThis,this);
}
onClickThis()
{
let data = {url:this.url,closeFunc:()=>{
this.base.setVideEnable(true);
}
}
if(this.url){
ViewManager.I.openBundlesView('ShowPanel',data);
this.base.setVideEnable(false);
}
}
refresh(info: PicInfo,base:GirlDetailPanel) {
this.base = base;
this.lock.active = info.imageState === ImageState.Lock;
this.question.active = info.imageState === ImageState.UnKnown
if (info.picType == PicType.LocalImage) {
this.url = info.url;
if (info.imageState !== ImageState.Release) {
this.url += '_blured';
if (info.imageState === ImageState.Lock)
this.img.color = new math.Color(127, 127, 127, 255);
else
this.img.color = new math.Color(50, 50, 50, 255);
} else {
this.img.color = new math.Color(255, 255, 255, 255);
}
ResManager.I.changeBundleSpriteFrame(this.img, this.url, "Chat18x");
}
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "da3f4fde-7c2a-41b5-b59f-2b539cc41eec",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,118 @@
import {_decorator, Label, Node, Sprite, VideoPlayer,instantiate} from "cc";
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
import {girlDetailInfo} from "db://assets/Scripts/Main/Config/cfg/characters";
import {Config18x} from "db://assets/Scripts/Main/Config/Config18x";
import PicType = Config18x.PicType;
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
import Utils from "db://assets/Scripts/Main/Common/Utils";
import { DetailImageItem } from "./DetailImageItem";
import { NavigationManager } from "../../manager/NavigationManager";
const { ccclass, property } = _decorator;
@ccclass("GirlDetailPanel")
export class GirlDetailPanel extends li_BaseView {
@property(Sprite)
avatar: Sprite;
@property(VideoPlayer)
avatarVideo: VideoPlayer;
@property(Label)
girlName: Label;
@property(Node)
starParent: Node;
@property(Label)
tags: Label;
@property(Label)
descName: Label;
@property(Label)
descAge: Label;
@property(Label)
desc: Label;
@property(Node)
chatBtn: Node;
id = 0;
@property(DetailImageItem)
imgItemInst:DetailImageItem;
@property(Node)
imgsLayout:Node;
openUIDataCT(data)
{
this.id = data;
}
onLoadCT() {
super.onLoadCT();
this.imgItemInst.node.active =false;
this.refresh(this.id);
}
setVideEnable(enable:boolean) {
this.avatarVideo.enabled = enable;
if(enable)
{
this.avatarVideo.play();
}
}
refresh(index:number)
{
console.log(index);
const data = girlDetailInfo.find(v=>v.baseInfo.id === index);
this.girlName.string=this.descName.string = data.baseInfo.name;
if(data.pics[0].picType == PicType.LocalGif)
{
ResManager.I.changeBundleVideo(this.avatarVideo,data.pics[0].url,"Chat18x");
}
if(data.pics.length>1)
{
for (let i = this.imgsLayout.children.length-1; i >=0 ; i--) {
this.imgsLayout.children[i].destroy();
}
for (let i = 1; i < data.pics.length; i++) {
const cfg = data.pics[i];
let newNode = instantiate(this.imgItemInst.node)
let item = newNode.getComponent(DetailImageItem);
item.refresh(cfg,this);
newNode.active = true;
this.imgsLayout.addChild(newNode);
}
}
this.desc.string = data.detailDesc;
let desc = '';
for (let i = 0; i < data.baseInfo.tag.length; i++) {
if(i!=0) desc += "\n"
desc += data.baseInfo.tag[i];
}
this.tags.string = desc;
for (let i = 0; i <5; i++) {
this.starParent.children[i].active =(i<data.baseInfo.starCount);
}
this.descAge.string = data.baseInfo.age.toString();
this.desc.string = data.detailDesc;
this.id = data.baseInfo.id;
}
OnClickChatBtn() {
NavigationManager.Instance.navigateToChat(this.id);
this.onClose();
}
returnBtn()
{
this.onClose();
NavigationManager.Instance.navigateToGirlList(1001);
//ViewManager.I.openBundlesView("GirlListPanel");
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "9dd3472e-2fa0-4f2d-886e-deb7ebfe278b",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,72 @@
import { _decorator, Component, Label, Node, Sprite, UITransform } from "cc";
import { Config18x, GirlInfo } from "db://assets/Scripts/Main/Config/Config18x";
import PriceType = Config18x.PriceType;
import { ViewManager } from "db://assets/Scripts/Main/Manager/ViewManager";
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
import Utils from "db://assets/Scripts/Main/Common/Utils";
import { NavigationManager } from "../../manager/NavigationManager";
const { ccclass, property } = _decorator;
@ccclass("GirlListItem")
export class GirlListItem extends Component {
@property(Sprite)
avatar: Sprite;
@property(Label)
girlName: Label;
@property(Label)
tags: Label;
@property(Label)
price: Label;
@property(Node)
freeNode: Node;
@property(Node)
tryNode: Node;
@property(Node)
chatBtn: Node;
@property(Node)
starParent: Node;
id: number = -1;
baseNode: Node;
refreshData(data: GirlInfo, baseNode: Node) {
this.baseNode = baseNode;
this.id = data.id;
this.girlName.string = data.name;
let desc = "";
for (let i = 0; i < data.tag.length; i++) {
if (i != 0) desc += "&";
desc += data.tag[i];
}
this.tags.string = desc;
this.price.node.active = data.priceType == PriceType.Coin;
this.freeNode.active = data.priceType == PriceType.Free;
this.tryNode.active = data.priceType == PriceType.Try;
ResManager.I.changeBundleSpriteFrame(
this.avatar,
data.pic.url,
"Chat18x",
() => {
let sizeTran = this.avatar.node.parent.getComponent(UITransform);
Utils.adjustBgPixelRatioToSize(
sizeTran.contentSize,
this.avatar.node,
2
);
}
);
for (let i = 0; i < 5; i++) {
this.starParent.children[i].active = i < data.starCount;
}
}
onClickDetail() {
NavigationManager.Instance.navigateToGirlDetail(this.id);
ViewManager.I.closeView(this.baseNode);
}
update(deltaTime: number) {}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "c9c66d7b-1a74-4d16-8410-324541cfc05e",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,55 @@
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 { GirlsData } from "db://assets/Scripts/Main/Config/cfg/characters";
import { GButton } from "db://assets/Scripts/Main/Common/GButton";
import { GirlListItem } from "./GirlListItem";
const { ccclass, property } = _decorator;
@ccclass("GirlListPanel")
export class GirlListPanel extends li_BaseView {
private _nodeTab: any = {};
itemInst: GirlListItem;
content: Node;
cache: GirlListItem[] = [];
id: number;
openUIDataCT(data) {
this.id = data;
}
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;
this.refresh(this.id);
}
refresh(index: number) {
if (this.cache) {
for (let i = this.cache.length - 1; i >= 0; i--) {
this.cache[i].node.destroy();
}
}
const config = GirlsData.filter((value) => value.category == index);
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);
}
}
private registerListener() {
GButton.BandClick(this._nodeTab.ReturnBtn, this.Return, this);
}
Return() {
this.onClose();
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "ecf27ef5-ef11-4e22-8f05-d2e96d62a26a",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,58 @@
import { _decorator, Component, Node,Sprite ,UITransform} from 'cc';
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
import Utils from "db://assets/Scripts/Main/Common/Utils";
import {ViewManager} from "db://assets/Scripts/Main/Manager/ViewManager";
import {GButton} from "db://assets/Scripts/Main/Common/GButton";
const { ccclass, property } = _decorator;
interface ShowPanelData
{
url: string;
closeFunc:Function;
}
@ccclass('ShowPanel')
export class ShowPanel extends li_BaseView {
@property(Sprite)
image:Sprite;
@property(Sprite)
splash:Sprite;
url:string;
func:Function;
openUIDataCT(data:ShowPanelData) {
super.openUIDataCT(data);
this.url = data.url;
this.func = data.closeFunc;
}
onLoadCT() {
this.show(this.url);
}
start()
{
//this.splash.node.on(Node.EventType.TOUCH_START,this.onclickback);
GButton.BandClick(this.splash.node,this.onClose,this);
}
protected onClose() {
if(this.func)
{
this.func();
}
super.onClose();
}
show(path:string)
{
ResManager.I.changeBundleSpriteFrame(this.image,path,"Chat18x",()=>{
Utils.adjustBgPixelRatio(this.image.node,3);
});
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "46300dfd-b10c-4258-9553-52db74ec2799",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,46 @@
import { _decorator, Component, Label, Node, Sprite, UITransform } from "cc";
import { Theme } from "db://assets/Scripts/Main/Config/Config18x";
import { GButton } from "db://assets/Scripts/Main/Common/GButton";
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
import Utils from "db://assets/Scripts/Main/Common/Utils";
import { NavigationManager } from "../../manager/NavigationManager";
const { ccclass, property } = _decorator;
@ccclass("ThemeItem")
export class ThemeItem extends Component {
@property(Sprite)
lockImg: Sprite;
@property(Label)
titleName: Label;
@property(Sprite)
img: Sprite;
private id: number;
private isLocked: boolean;
start() {}
refresh(themeData: Theme) {
this.lockImg.node.active = !themeData.isRelease;
this.isLocked = !themeData.isRelease;
this.titleName.string = themeData.name;
this.id = themeData.themeId;
ResManager.I.changeBundleSpriteFrame(
this.img,
themeData.pic.url,
"Chat18x",
() => {
let sizeTran = this.img.node.parent.getComponent(UITransform);
Utils.adjustBgPixelRatioToSize(sizeTran.contentSize, this.img.node, 2);
}
);
GButton.RemoveAndBandClick(this.node, this.OnClickThis, this);
}
OnClickThis() {
if (this.isLocked) {
return;
}
NavigationManager.Instance.navigateToGirlList(this.id);
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "c715a0ca-612c-4b4b-9cb3-ba48081a2f55",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,109 @@
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 {
GirlsData,
themes,
} from "db://assets/Scripts/Main/Config/cfg/characters";
import { GButton } from "db://assets/Scripts/Main/Common/GButton";
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
import { ThemeItem } from "./ThemeItem";
import { NavigationManager } from "../../manager/NavigationManager";
import { GirlListItem } from "./GirlListItem";
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;
this.content = this._nodeTab.AllThemesLayout;
this.Show();
}
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();
}
}
const config = themes;
for (let i = 0; i < config.length; i++) {
const cfg = config[i];
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);
}
const rectInfo = GirlsData[0];
this.recId = rectInfo.id;
this.recName.string = rectInfo.name;
ResManager.I.changeBundleSpriteFrame(
this.recSprite,
rectInfo.pic.url,
"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);
}
chatWithRec() {
NavigationManager.Instance.navigateToChat(this.recId);
}
openSetting() {
console.log("Setting");
}
openMsgBox() {
console.log("打开信箱");
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "f7d973c4-ec31-49bc-852a-bda8efa76710",
"files": [],
"subMetas": {},
"userData": {}
}