引入luban配表 需要命令行 npm install buffer
This commit is contained in:
@@ -1,18 +1,29 @@
|
||||
import { _decorator, Component, EditBox, Node,Label,Sprite,UITransform } from "cc";
|
||||
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 { 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 { 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";
|
||||
import { VideoRoleType } from "db://assets/Scripts/Main/Common/GlobalValue";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("ChatPanel")
|
||||
@@ -34,44 +45,56 @@ export class ChatPanel extends li_BaseView {
|
||||
@property(ImagePopup)
|
||||
popUpImage: ImagePopup = null;
|
||||
|
||||
id:number
|
||||
id: number;
|
||||
private _nodeTab: any = {};
|
||||
|
||||
openUIDataCT(data)
|
||||
{
|
||||
openUIDataCT(data) {
|
||||
this.id = data;
|
||||
// 设置当前聊天的角色ID
|
||||
ChatAIService.Instance.setCurrentRole(this.id);
|
||||
}
|
||||
|
||||
onLoadCT()
|
||||
{
|
||||
Utils.parseNode(this.node,this._nodeTab);
|
||||
onLoadCT() {
|
||||
Utils.parseNode(this.node, this._nodeTab);
|
||||
|
||||
this.register();
|
||||
this.refresh(this.id);
|
||||
}
|
||||
register()
|
||||
{
|
||||
Utils.addInnerEL(InnerMsgCode.Chat_DialogRefresh,this,this.onDialogUpdate);
|
||||
register() {
|
||||
Utils.addInnerEL(
|
||||
InnerMsgCode.Chat_DialogRefresh,
|
||||
this,
|
||||
this.onDialogUpdate
|
||||
);
|
||||
}
|
||||
refresh(id:number) {
|
||||
refresh(id: number) {
|
||||
this.id = id;
|
||||
const data = girlDetailInfo.filter(value=>value.baseInfo.id == id)[0];
|
||||
if(!data) return;
|
||||
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);
|
||||
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,
|
||||
});
|
||||
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())
|
||||
onDialogUpdate() {
|
||||
this.layout.UpdateDialog(DialogManager.getInstance().getDialogs());
|
||||
}
|
||||
protected onEnable(): void {
|
||||
if (!this.manager) this.manager = DialogManager.getInstance();
|
||||
@@ -86,15 +109,11 @@ export class ChatPanel extends li_BaseView {
|
||||
|
||||
this.editBox.string = "";
|
||||
|
||||
DialogManager.getInstance().updateDialog(true, str,true);
|
||||
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);
|
||||
}
|
||||
@@ -104,11 +123,7 @@ export class ChatPanel extends li_BaseView {
|
||||
//this.popUpImage.refresh("Image/1/blur_naked_1");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
returnBtn()
|
||||
{
|
||||
returnBtn() {
|
||||
this.onClose();
|
||||
GameRootUI.I.showDefaultView();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user