update
This commit is contained in:
@@ -2,10 +2,17 @@ import { _decorator, Component, EditBox, Node,Label } from "cc";
|
||||
import { DemoManager } from "./DemoManager";
|
||||
import { ChatGPTService } from "./ChatGPTService";
|
||||
import {characters} from "db://assets/Scripts/test/cfg/characters";
|
||||
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 "db://assets/Scripts/test/ChatContentsLayout";
|
||||
import {ViewManager} from "db://assets/Scripts/Main/Manager/ViewManager";
|
||||
import GameRootUI from "db://assets/Scripts/Main/Common/GameRootUI";
|
||||
import {ImagePopup} from "db://assets/Scripts/test/ImagePopup";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("ChatPanel")
|
||||
export class ChatPanel extends Component {
|
||||
export class ChatPanel extends li_BaseView {
|
||||
manager: DemoManager = null;
|
||||
|
||||
@property(EditBox)
|
||||
@@ -14,15 +21,35 @@ export class ChatPanel extends Component {
|
||||
@property(Label)
|
||||
girlName: Label = null;
|
||||
|
||||
@property(ChatContentsLayout)
|
||||
layout: ChatContentsLayout = null;
|
||||
|
||||
@property(ImagePopup)
|
||||
popUpImage: ImagePopup = null;
|
||||
|
||||
id:number
|
||||
|
||||
onLoadCT()
|
||||
{
|
||||
this.register();
|
||||
}
|
||||
register()
|
||||
{
|
||||
Utils.addInnerEL(InnerMsgCode.Chat_DialogRefresh,this,this.onDialogUpdate);
|
||||
}
|
||||
refresh(id:number) {
|
||||
this.id = id;
|
||||
const data = characters[id-1];
|
||||
this.girlName.string = data.name;
|
||||
}
|
||||
|
||||
onDialogUpdate()
|
||||
{
|
||||
this.layout.UpdateDialog(DemoManager.getInstance().getDialogs())
|
||||
}
|
||||
protected onEnable(): void {
|
||||
if (!this.manager) this.manager = DemoManager.getInstance();
|
||||
|
||||
GameRootUI.I.hideDefaultView();
|
||||
}
|
||||
|
||||
public async OnClickSend() {
|
||||
@@ -31,7 +58,8 @@ export class ChatPanel extends Component {
|
||||
console.log("post:" + str);
|
||||
|
||||
this.editBox.string = "";
|
||||
DemoManager.getInstance().updateDialog(true, str);
|
||||
|
||||
DemoManager.getInstance().updateDialog(true, str,true);
|
||||
|
||||
let ret = await ChatGPTService.getInstance().Post({
|
||||
model: "Deepseek-reasoner",
|
||||
@@ -49,5 +77,19 @@ export class ChatPanel extends Component {
|
||||
this.manager.updateDialog(false, rep);
|
||||
}
|
||||
console.log("ret:" + rep);
|
||||
|
||||
//测试
|
||||
this.popUpImage.refresh("Image/1/blur_naked_1");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
returnBtn()
|
||||
{
|
||||
this.onClose();
|
||||
GameRootUI.I.showDefaultView();
|
||||
|
||||
//ViewManager.I.openBundlesView("GirlListPanel");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@ import { DemoData } from "./DemoData";
|
||||
import {GirlDetailPanel} from "db://assets/Scripts/test/GirlDetailPanel";
|
||||
import {ChatPanel} from "db://assets/Scripts/test/ChatPanel";
|
||||
import {GirlListPanel} from "db://assets/Scripts/test/girlListPanel/GirlListPanel";
|
||||
import {ViewManager} from "db://assets/Scripts/Main/Manager/ViewManager";
|
||||
import Utils from "db://assets/Scripts/Main/Common/Utils";
|
||||
import {InnerMsgCode} from "db://assets/Scripts/Main/Config/InnerMsgCode";
|
||||
|
||||
export class DemoManager {
|
||||
private static _instance: DemoManager;
|
||||
@@ -20,38 +23,26 @@ export class DemoManager {
|
||||
|
||||
demoData: DemoData;
|
||||
|
||||
public layoutout: ChatContentsLayout;
|
||||
public detailPanel:GirlDetailPanel;
|
||||
public chatPanel:ChatPanel;
|
||||
public girlListPanel:GirlListPanel;
|
||||
|
||||
hideMainView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
EnterChat(id: number) {
|
||||
if(this.chatPanel==null)
|
||||
{
|
||||
this.chatPanel = find("Canvas/ChatPanel").getComponent(ChatPanel);
|
||||
}
|
||||
this.chatPanel.node.active = true;
|
||||
this.detailPanel.node.active = false;
|
||||
ViewManager.I.openBundlesView("ChatPanel",id);
|
||||
|
||||
}
|
||||
|
||||
EnterDetail(id: number) {
|
||||
if(this.girlListPanel==null)
|
||||
{
|
||||
this.girlListPanel =find("Canvas/GirlListPanel").getComponent(GirlListPanel);
|
||||
}
|
||||
this.girlListPanel.node.active = false;
|
||||
if(this.detailPanel==null)
|
||||
{
|
||||
this.detailPanel = find("Canvas/GirlDetailPanel").getComponent(GirlDetailPanel);
|
||||
}
|
||||
this.detailPanel.refresh(id);
|
||||
this.detailPanel.node.active = true;
|
||||
ViewManager.I.openBundlesView("GirlDetailPanel",id);
|
||||
}
|
||||
|
||||
public updateDialog(isPlayer: boolean, str: string) {
|
||||
public updateDialog(isPlayer: boolean, str: string,fromPlayer:boolean = false) {
|
||||
if(fromPlayer){this.demoData.cleanDialog()}
|
||||
this.demoData.pushDialog(isPlayer, str);
|
||||
console.log("update dialog");
|
||||
this.layoutout.UpdateDialog(this.getDialogs());
|
||||
Utils.sendInnerMsg(InnerMsgCode.Chat_DialogRefresh);
|
||||
}
|
||||
|
||||
public getDialogs() {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { _decorator, Component, Label, Node, Sprite } from "cc";
|
||||
import { DemoManager } from "./DemoManager";
|
||||
import {Character, characters} from "db://assets/Scripts/test/cfg/characters";
|
||||
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
|
||||
import {ViewManager} from "db://assets/Scripts/Main/Manager/ViewManager";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("GirlDetailPanel")
|
||||
export class GirlDetailPanel extends Component {
|
||||
export class GirlDetailPanel extends li_BaseView {
|
||||
@property(Sprite)
|
||||
avatar: Sprite;
|
||||
@property(Label)
|
||||
@@ -16,6 +18,12 @@ export class GirlDetailPanel extends Component {
|
||||
chatBtn: Node;
|
||||
id = 0;
|
||||
|
||||
openUIDataCT(data)
|
||||
{
|
||||
this.id = data;
|
||||
this.refresh(this.id);
|
||||
}
|
||||
|
||||
refresh(index:number)
|
||||
{
|
||||
const data = characters[index-1];
|
||||
@@ -25,5 +33,12 @@ export class GirlDetailPanel extends Component {
|
||||
}
|
||||
OnClickChatBtn() {
|
||||
DemoManager.getInstance().EnterChat(this.id);
|
||||
this.onClose();
|
||||
}
|
||||
|
||||
returnBtn()
|
||||
{
|
||||
this.onClose();
|
||||
//ViewManager.I.openBundlesView("GirlListPanel");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
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(-1000,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()
|
||||
{
|
||||
ViewManager.I.openBundlesView('ShowPanel');
|
||||
}
|
||||
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(-1000,493,0)},{easing:"backIn"}).start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "c0cd7ea3-c521-468b-b49c-6c04142e385d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
} from "cc";
|
||||
import { DemoManager } from "../DemoManager";
|
||||
import { Character, characters } from "db://assets/Scripts/test/cfg/characters";
|
||||
import {ViewManager} from "db://assets/Scripts/Main/Manager/ViewManager";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("GirlListItem")
|
||||
@@ -26,19 +27,17 @@ export class GirlListItem extends Component {
|
||||
|
||||
id: number = -1;
|
||||
|
||||
protected onEnable(): void {
|
||||
this.refreshData(1);
|
||||
}
|
||||
|
||||
refreshData(index: number) {
|
||||
const data = characters[index - 1];
|
||||
baseNode: Node;
|
||||
refreshData(data: Character,base:Node) {
|
||||
this.id = data.id;
|
||||
this.girlName.string = data.name;
|
||||
//this.avatar.spriteFrame =
|
||||
this.baseNode = base;
|
||||
}
|
||||
|
||||
onClickDetail() {
|
||||
DemoManager.getInstance().EnterDetail(this.id);
|
||||
//ViewManager.I.closeView(this.baseNode);
|
||||
}
|
||||
|
||||
update(deltaTime: number) {}
|
||||
|
||||
@@ -1,17 +1,52 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import { _decorator, Component, Node,instantiate } from 'cc';
|
||||
import {characters} from "db://assets/Scripts/test/cfg/characters";
|
||||
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";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('GirlListPanel')
|
||||
export class GirlListPanel extends Component {
|
||||
onEnable()
|
||||
{
|
||||
const cfg = characters;
|
||||
for (let i = 0; i < cfg.length; i++) {
|
||||
const c = cfg[i];
|
||||
export class GirlListPanel extends li_BaseView {
|
||||
private _nodeTab: any = {};
|
||||
|
||||
itemInst:GirlListItem;
|
||||
content:Node;
|
||||
|
||||
cache:GirlListItem[] = [];
|
||||
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.show();
|
||||
}
|
||||
|
||||
|
||||
show()
|
||||
{
|
||||
if(this.cache)
|
||||
{
|
||||
for(let i = this.cache.length-1; i >=0; i--)
|
||||
{
|
||||
this.cache[i].node.destroy();
|
||||
}
|
||||
}
|
||||
const config = characters;
|
||||
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() {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
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;
|
||||
|
||||
@ccclass('ShowPanel')
|
||||
export class ShowPanel extends li_BaseView {
|
||||
@property(Sprite)
|
||||
image:Sprite;
|
||||
@property(Sprite)
|
||||
splash:Sprite;
|
||||
|
||||
onLoadCT() {
|
||||
this.show("Image/1/naked_1");
|
||||
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
//this.splash.node.on(Node.EventType.TOUCH_START,this.onclickback);
|
||||
GButton.BandClick(this.splash.node,()=>{this.close()},this);
|
||||
}
|
||||
|
||||
|
||||
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": "b7645da0-3b81-454b-8956-068491ce4706",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user