日志控制

This commit is contained in:
chen wei bo
2025-09-21 20:18:30 +08:00
parent 23c038fd14
commit 8f90c1d7cf
23 changed files with 207 additions and 178 deletions
+32 -30
View File
@@ -34,6 +34,8 @@ import { NavigationManager, PanelType } from "../../manager/NavigationManager";
import { GirlService } from "../../network/services/GirlService";
import proto from "db://assets/Scripts/proto/proto.pb.js";
import { TipsPanel } from "./TipsPanel";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
const { ccclass, property } = _decorator;
@ccclass("ChatPanel")
@@ -110,9 +112,9 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
// 检查 SceneBgVideoLayer 是否可用
if (!this.videoLayer) {
console.error("ChatPanel: SceneBgVideoLayer.handle 未初始化");
logger.error("ChatPanel: SceneBgVideoLayer.handle 未初始化");
} else {
console.log("ChatPanel: 成功获取 SceneBgVideoLayer 实例");
logger.log("ChatPanel: 成功获取 SceneBgVideoLayer 实例");
}
this.popUpImage.node.active = false;
}
@@ -199,7 +201,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
this.chatController.hasRoleData(this.categoryId, this.id)
) {
// 如果是角色切换且有缓存数据,使用switchRole
console.log(
logger.log(
`ChatPanel: Switching from role ${this.chatController.getCurrentRoleId()} to role ${
this.id
}`
@@ -207,7 +209,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
this.chatController.switchRole(this.categoryId, this.id);
} else {
// 首次初始化或没有缓存数据,使用initialize
console.log(`ChatPanel: Initializing role ${this.id}`);
logger.log(`ChatPanel: Initializing role ${this.id}`);
this.chatController.initialize(this.categoryId, this.id);
}
}
@@ -234,7 +236,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
if (this.videoLayer) {
// Get current emotion from ChatController
const currentEmotion = this.chatController.getCurrentEmotion();
console.log(
logger.log(
`Current emotion for role ${this.id}: ${VideoEmotion[currentEmotion]}`
);
@@ -244,7 +246,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
chatModel.getDefaultVideo();
if (initialVideo) {
console.log(
logger.log(
`Loading initial video: ${initialVideo} (emotion: ${VideoEmotion[initialVideo]})`
);
@@ -263,7 +265,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
}
} else {
this.currentEmotion = null; // Reset current emotion when no videos available
console.log("No SceneBgVideoLayer available for role", this.id);
logger.log("No SceneBgVideoLayer available for role", this.id);
}
}
@@ -272,35 +274,35 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
* 保留此方法仅为了兼容性,但不再主动调用
*/
adjustVideoScale() {
console.log(
logger.log(
"ChatPanel: adjustVideoScale() 方法已废弃,缩放和位置由 playVideo() 自动处理"
);
// 如果确实需要手动调整,可以重新调用 playVideo
// this.videoLayer.playVideo(currentVideo, { size, position });
}
onChatCountChange() {
console.log("Trigger On ChatCount Change");
logger.log("Trigger On ChatCount Change");
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
let triggerId = girlData.getTriggerGrilPhotoId(this.categoryId, this.id);
if (triggerId == 0) return;
console.log("Trigger pop up Image id:" + this.id + "--" + triggerId);
logger.log("Trigger pop up Image id:" + this.id + "--" + triggerId);
this.popUpImage.refresh(this.categoryId, this.id, triggerId);
}
setVideoEnable(enable: boolean) {
if (!this.videoLayer) {
console.error("ChatPanel: SceneBgVideoLayer 不可用");
logger.error("ChatPanel: SceneBgVideoLayer 不可用");
return;
}
if (enable) {
this.videoLayer.resume();
console.log("ChatPanel: 恢复视频播放");
logger.log("ChatPanel: 恢复视频播放");
} else {
this.videoLayer.pause();
console.log("ChatPanel: 暂停视频播放");
logger.log("ChatPanel: 暂停视频播放");
}
}
@@ -314,7 +316,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
// Check if emotion has changed
if (this.currentEmotion === emotion) {
console.log(
logger.log(
`Emotion ${VideoEmotion[emotion]} unchanged, skipping video switch`
);
return;
@@ -324,7 +326,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
const matchingVideo = chatModel.getVideoByEmotion(emotion);
if (matchingVideo) {
console.log(
logger.log(
`Switching to video for emotion ${
VideoEmotion[emotion]
}: ${matchingVideo} (from ${
@@ -346,14 +348,14 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
// 注意:移除了 adjustVideoScale() 调用,因为 playVideo 现在会自动处理缩放和位置
this.setVideoEnable(true);
} else {
console.warn(
logger.warn(
`No video found for emotion ${VideoEmotion[emotion]}, falling back to default video`
);
// Fallback to default video from ChatModel
const fallbackVideo = chatModel.getDefaultVideo();
if (fallbackVideo) {
console.log(
logger.log(
`Loading fallback video: ${fallbackVideo} (emotion: ${VideoEmotion[fallbackVideo]})`
);
@@ -378,7 +380,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
}): void {
// 检查是否是当前角色
if (data.roleId === this.id) {
console.log(
logger.log(
`Emotion initialized for current role ${this.id}: ${
VideoEmotion[data.emotion]
}`
@@ -387,7 +389,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
// 切换到对应的视频
this.switchVideoByEmotion(data.emotion);
} else {
console.log(
logger.log(
`Emotion initialized for role ${data.roleId} (not current role ${this.id}), ignoring`
);
}
@@ -444,7 +446,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
* @param message 用户发送的消息
*/
public onMessageSent(message: string): void {
console.log("Message sent:", message);
logger.log("Message sent:", message);
// 消息发送后开始显示加载动画,由DialogManager处理
}
@@ -453,7 +455,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
* @param response AI的回复内容
*/
public onMessageReceived(response: string): void {
//console.log("Message received:", response);
//logger.log("Message received:", response);
// AI回复收到后加载动画会被自动移除,可以在这里添加其他UI效果
}
@@ -483,7 +485,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
* @param emotion 当前情绪状态
*/
public onEmotionUpdated(emotion: VideoEmotion): void {
console.log(
logger.log(
`ChatPanel: Emotion updated to ${VideoEmotion[emotion]} (${emotion})`
);
@@ -495,23 +497,23 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
switch (emotion) {
case VideoEmotion.calm_down:
// 平静状态的UI更新
console.log("UI state: Calm");
logger.log("UI state: Calm");
break;
case VideoEmotion.arousal:
// 兴奋状态的UI更新
console.log("UI state: Arousal");
logger.log("UI state: Arousal");
break;
case VideoEmotion.desire:
// 渴望状态的UI更新
console.log("UI state: Desire");
logger.log("UI state: Desire");
break;
case VideoEmotion.passion:
// 激情状态的UI更新
console.log("UI state: Passion");
logger.log("UI state: Passion");
break;
case VideoEmotion.orgasm:
// 高潮状态的UI更新
console.log("UI state: Orgasm");
logger.log("UI state: Orgasm");
break;
}
}
@@ -529,17 +531,17 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
*/
public clearRoleDataDebug(roleId?: number): void {
if (!this.chatController) {
console.warn("ChatController not initialized");
logger.warn("ChatController not initialized");
return;
}
const targetRoleId = roleId || this.id;
if (!targetRoleId) {
console.warn("No role ID specified");
logger.warn("No role ID specified");
return;
}
this.chatController.clearRoleData(targetRoleId);
console.log(`Cleared data for role ${targetRoleId}`);
logger.log(`Cleared data for role ${targetRoleId}`);
}
}