代码整理,ai相关配置转luban,聊天气泡缓存
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
import { find } from "cc";
|
||||
import { ChatContentsLayout } from "../ui/components/ChatContentsLayout";
|
||||
import { DemoData } from "../utils/DemoData";
|
||||
import { DemoData } from "../data/DialogData";
|
||||
import { NavigationManager } from "./NavigationManager";
|
||||
import Utils from "db://assets/Scripts/Main/Common/Utils";
|
||||
import {InnerMsgCode} from "db://assets/Scripts/Main/Config/InnerMsgCode";
|
||||
import { InnerMsgCode } from "db://assets/Scripts/Main/Config/InnerMsgCode";
|
||||
|
||||
/**
|
||||
* 对话管理器
|
||||
*
|
||||
*
|
||||
* 专注于管理对话数据和对话流程,导航功能已迁移至NavigationManager
|
||||
*
|
||||
*
|
||||
* @author AI Chat System
|
||||
* @version 2.0.0
|
||||
*/
|
||||
export class DialogManager {
|
||||
private static _instance: DialogManager;
|
||||
|
||||
|
||||
/**
|
||||
* 获取DialogManager的单例实例
|
||||
*
|
||||
*
|
||||
* @returns {DialogManager} 对话管理器实例
|
||||
* @static
|
||||
*/
|
||||
@@ -35,10 +35,10 @@ export class DialogManager {
|
||||
|
||||
/** 对话数据实例 */
|
||||
private demoData: DemoData;
|
||||
|
||||
|
||||
/** 当前主题ID */
|
||||
private themeId = -1;
|
||||
|
||||
|
||||
/** 聊天内容布局组件引用 */
|
||||
public layoutout: ChatContentsLayout;
|
||||
|
||||
@@ -47,19 +47,25 @@ export class DialogManager {
|
||||
* @deprecated 请直接使用 NavigationManager.Instance.navigateToGirlList()
|
||||
*/
|
||||
public EnterGirlList(id: number = null): void {
|
||||
console.warn("DemoManager.EnterGirlList is deprecated, use NavigationManager instead");
|
||||
if(id != null) { this.themeId = id; }
|
||||
if(this.themeId !== -1) {
|
||||
console.warn(
|
||||
"DemoManager.EnterGirlList is deprecated, use NavigationManager instead"
|
||||
);
|
||||
if (id != null) {
|
||||
this.themeId = id;
|
||||
}
|
||||
if (this.themeId !== -1) {
|
||||
NavigationManager.Instance.navigateToGirlList(this.themeId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 进入聊天页面(委托给NavigationManager)
|
||||
* @deprecated 请直接使用 NavigationManager.Instance.navigateToChat()
|
||||
*/
|
||||
public EnterChat(id: number): void {
|
||||
console.warn("DemoManager.EnterChat is deprecated, use NavigationManager instead");
|
||||
console.warn(
|
||||
"DemoManager.EnterChat is deprecated, use NavigationManager instead"
|
||||
);
|
||||
NavigationManager.Instance.navigateToChat(id);
|
||||
}
|
||||
|
||||
@@ -68,35 +74,44 @@ export class DialogManager {
|
||||
* @deprecated 请直接使用 NavigationManager.Instance.navigateToGirlDetail()
|
||||
*/
|
||||
public EnterDetail(id: number): void {
|
||||
console.warn("DemoManager.EnterDetail is deprecated, use NavigationManager instead");
|
||||
console.warn(
|
||||
"DemoManager.EnterDetail is deprecated, use NavigationManager instead"
|
||||
);
|
||||
NavigationManager.Instance.navigateToGirlDetail(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新对话内容
|
||||
*
|
||||
*
|
||||
* @param {boolean} isPlayer - 是否为玩家消息
|
||||
* @param {string} str - 消息内容
|
||||
* @param {boolean} fromPlayer - 是否来自玩家输入(用于清理对话)
|
||||
*/
|
||||
public updateDialog(isPlayer: boolean, str: string, fromPlayer: boolean = false): void {
|
||||
if(fromPlayer) {
|
||||
public updateDialog(
|
||||
isPlayer: boolean,
|
||||
str: string,
|
||||
fromPlayer: boolean = false
|
||||
): void {
|
||||
if (fromPlayer) {
|
||||
this.demoData.cleanDialog();
|
||||
}
|
||||
this.demoData.pushDialog(isPlayer, str);
|
||||
console.log("Dialog updated:", { isPlayer, content: str.substring(0, 50) + "..." });
|
||||
console.log("Dialog updated:", {
|
||||
isPlayer,
|
||||
content: str.substring(0, 50) + "...",
|
||||
});
|
||||
Utils.sendInnerMsg(InnerMsgCode.Chat_DialogRefresh);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有对话记录
|
||||
*
|
||||
*
|
||||
* @returns {Dialog[]} 对话记录数组
|
||||
*/
|
||||
public getDialogs() {
|
||||
return this.demoData.GetDialogs();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 清空当前对话记录
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user