This commit is contained in:
2025-09-21 10:35:27 +08:00
parent 9559e436e6
commit 8e82ebf724
8 changed files with 569 additions and 309 deletions
+5 -10
View File
@@ -194,13 +194,6 @@ export class ChatController {
TipsPanel.show(LanguageUtils.getText("chat_error_code_1004"));
}
// 添加用户消息到模型
this.chatModel.addDialog(true, message);
// 更新对话显示 - 用户消息
this.dialogManager?.updateDialog(true, message, true);
this.callback?.onDialogUpdated(true);
// 通知界面消息发送开始
this.callback?.onMessageSent(message);
@@ -215,12 +208,14 @@ export class ChatController {
);
if (response) {
// 移除加载中的对话
//this.dialogManager?.removeLoadingDialog();
// 添加用户消息到模型
this.chatModel.addDialog(true, message);
// 更新对话显示 - 用户消息
this.dialogManager?.updateDialog(true, message, true);
this.callback?.onDialogUpdated(true);
// 添加AI回复到模型 (保持完整消息)
this.chatModel.addDialog(false, response);
// 更新对话显示 - AI回复 (使用分段显示)
this.dialogManager?.updateDialogWithSegments(false, response);
this.callback?.onDialogUpdated(false);
@@ -30,7 +30,7 @@ export class ChatContentsLayout extends Component {
// 缓存池
private cachedBubbles: DialogBubble[] = [];
// 等待回复气泡的引用
private waitingBubble: DialogBubble = null;
//private waitingBubble: DialogBubble = null;
// 延时任务ID数组
private delayedTasks: number[] = [];
// ScrollView组件引用
@@ -52,13 +52,22 @@ export class ChatContentsLayout extends Component {
this.fixMaxWidth = 730;
// 获取或添加UIOpacity组件到content节点
this.contentOpacity = this.node.getComponent(UIOpacity) || this.node.addComponent(UIOpacity);
this.contentOpacity =
this.node.getComponent(UIOpacity) || this.node.addComponent(UIOpacity);
// 注册触摸事件
if (this.scrollView && this.scrollView.node) {
this.scrollView.node.on(NodeEventType.TOUCH_START, this.onTouchStart, this);
this.scrollView.node.on(
NodeEventType.TOUCH_START,
this.onTouchStart,
this
);
this.scrollView.node.on(NodeEventType.TOUCH_END, this.onTouchEnd, this);
this.scrollView.node.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this);
this.scrollView.node.on(
NodeEventType.TOUCH_CANCEL,
this.onTouchEnd,
this
);
}
}
@@ -85,11 +94,11 @@ export class ChatContentsLayout extends Component {
this.bubbles.push(playerBubble);
// 创建等待回复气泡(插入到首位,显示在玩家消息上面)
this.waitingBubble = this.createOrGetBubble(false);
this.waitingBubble.node.active = true;
this.waitingBubble.updateBubbleContent("...", false, undefined, true);
this.waitingBubble.node.setSiblingIndex(0);
this.bubbles.push(this.waitingBubble);
// this.waitingBubble = this.createOrGetBubble(false);
// this.waitingBubble.node.active = true;
// this.waitingBubble.updateBubbleContent("...", false, undefined, true);
// this.waitingBubble.node.setSiblingIndex(0);
// this.bubbles.push(this.waitingBubble);
this.node.position = Vec3.ZERO;
// 滚动到底部(等待下一帧Layout更新完成)
this.scheduleOnce(() => {
@@ -102,9 +111,9 @@ export class ChatContentsLayout extends Component {
*/
updateAIDialogs(dialogs: Dialog[]): void {
// 清除等待回复气泡
if (this.waitingBubble) {
this.removeWaitingBubble();
}
// if (this.waitingBubble) {
// this.removeWaitingBubble();
// }
// 清理之前的延时任务
this.clearDelayedTasks();
@@ -124,7 +133,7 @@ export class ChatContentsLayout extends Component {
}
}
this.bubbles = [];
this.waitingBubble = null;
//this.waitingBubble = null;
// 清理多余的缓存气泡
this.cleanupExcessCachedBubbles();
@@ -164,19 +173,19 @@ export class ChatContentsLayout extends Component {
/**
* 移除等待回复气泡
*/
private removeWaitingBubble(): void {
if (this.waitingBubble && this.waitingBubble.node) {
this.waitingBubble.node.active = false;
this.cachedBubbles.push(this.waitingBubble);
// private removeWaitingBubble(): void {
// if (this.waitingBubble && this.waitingBubble.node) {
// this.waitingBubble.node.active = false;
// this.cachedBubbles.push(this.waitingBubble);
// 从当前气泡列表中移除
const index = this.bubbles.indexOf(this.waitingBubble);
if (index > -1) {
this.bubbles.splice(index, 1);
}
}
this.waitingBubble = null;
}
// // 从当前气泡列表中移除
// const index = this.bubbles.indexOf(this.waitingBubble);
// if (index > -1) {
// this.bubbles.splice(index, 1);
// }
// }
// this.waitingBubble = null;
// }
/**
* 带延时地添加AI对话
@@ -316,9 +325,17 @@ export class ChatContentsLayout extends Component {
protected onDestroy(): void {
// 清理事件监听
if (this.scrollView && this.scrollView.node) {
this.scrollView.node.off(NodeEventType.TOUCH_START, this.onTouchStart, this);
this.scrollView.node.off(
NodeEventType.TOUCH_START,
this.onTouchStart,
this
);
this.scrollView.node.off(NodeEventType.TOUCH_END, this.onTouchEnd, this);
this.scrollView.node.off(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this);
this.scrollView.node.off(
NodeEventType.TOUCH_CANCEL,
this.onTouchEnd,
this
);
}
// 清理计时器
@@ -3,13 +3,10 @@ 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 { GirlListItem } from "../../uiitems/GirlListItem";
import { ConfigManager } from "../../manager/ConfigManager";
import { GirlService } from "db://assets/Scripts/chat18x/network/services/GirlService";
import { DataManager, DataId } from "../../data/DataManager";
import { GirlData } from "../../data/GirlData";
import proto from "db://assets/Scripts/proto/proto.pb.js";
import GameRootUI from "../../../Main/Common/GameRootUI";
import { UITransitionHelper } from "../../utils/UITransitionHelper";
import { NavigationManager, PanelType } from "../../manager/NavigationManager";
const { ccclass, property } = _decorator;
@@ -28,7 +25,6 @@ export class GirlListPanel extends li_BaseView {
private maxPoolSize: number = 20;
category: number;
private parentPanelName: string = null;
onLoadCT() {
Utils.parseNode(this.node, this._nodeTab);
@@ -319,11 +319,18 @@ export class ThemePanel extends li_BaseView {
NavigationManager.Instance.switchToPanel(PanelType.GIRL_DETAIL);
} else {
//未解锁
ViewManager.I.openBundlesPopupView("GirlListPopupPanel", {
NavigationManager.Instance.openSubPanel("GirlListPopupPanel", this.node, {
base: this,
category: girlData.getGrilCategoryById(this.recId),
id: this.recId,
});
// ViewManager.I.openBundlesPopupView("GirlListPopupPanel", {
// base: this,
// category: girlData.getGrilCategoryById(this.recId),
// id: this.recId,
// });
}
}
@@ -19,6 +19,7 @@ import { DataManager, DataId } from "../data/DataManager";
import { GirlData } from "../data/GirlData";
import { EnvData } from "../data/EnvData";
import { TipsPanel } from "../ui/panels/TipsPanel";
import { NavigationManager } from "../manager/NavigationManager";
const { ccclass, property } = _decorator;
@@ -72,13 +73,25 @@ export class DetailImageItem extends Component {
this.base.setVideEnable(false);
}
} else {
ViewManager.I.openBundlesView("PopupGirlDetailPanel", {
category: this.category,
resId: this.resId,
girlId: this.girlId,
base: this,
type: this.type,
});
NavigationManager.Instance.openSubPanel(
"PopupGirlDetailPanel",
this.base.node,
{
category: this.category,
resId: this.resId,
girlId: this.girlId,
base: this,
type: this.type,
}
);
// ViewManager.I.openBundlesView("PopupGirlDetailPanel", {
// category: this.category,
// resId: this.resId,
// girlId: this.girlId,
// base: this,
// type: this.type,
// });
}
// if (!this.isImage) {
// //判断是否已经解锁此资源
@@ -238,13 +251,13 @@ export class DetailImageItem extends Component {
this.resId = 0;
this.type = null;
this.isVisible = false;
this.question.active = true;
this.video.enabled = false;
this.priceFrame.active = false;
this.loading.active = false;
this.videoPrice.string = "";
if (this.img && this.img.spriteFrame) {
this.img.spriteFrame = null;
}
@@ -216,11 +216,16 @@ export class GirlListItem extends Component {
NavigationManager.Instance.switchToPanel(PanelType.GIRL_DETAIL);
} else {
//未解锁
ViewManager.I.openBundlesPopupView("GirlListPopupPanel", {
NavigationManager.Instance.openSubPanel("GirlListPopupPanel", this.baseNode, {
base: this,
category: this.category,
id: this.id,
});
// ViewManager.I.openBundlesPopupView("GirlListPopupPanel", {
// base: this,
// category: this.category,
// id: this.id,
// });
}
}
}
File diff suppressed because it is too large Load Diff
@@ -1624,7 +1624,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 200.56799999999996,
"x": 212.63599999999997,
"y": 109.65699999999993,
"z": 0
},
@@ -1707,7 +1707,7 @@
"_actualFontSize": 51,
"_fontSize": 50,
"_fontFamily": "Arial",
"_lineHeight": 40,
"_lineHeight": 51.7,
"_overflow": 2,
"_enableWrapText": true,
"_font": {
@@ -1765,7 +1765,7 @@
"_alignFlags": 33,
"_target": null,
"_left": 553.9668125000001,
"_right": 37.06381250000004,
"_right": 24.9958125,
"_top": 25.737000000000087,
"_bottom": 0,
"_horizontalCenter": 0,