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
@@ -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,
// });
}
}