From 3bdeb53859c4f64ea3a3c23d71033d175b48b78c Mon Sep 17 00:00:00 2001 From: xlj <543978819@qq.com> Date: Wed, 10 Sep 2025 21:02:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Scripts/chat18x/core/ChatAIService.ts | 6 +- assets/Scripts/chat18x/ui/panels/ChatPanel.ts | 2 + .../Scripts/chat18x/ui/panels/SettingPanel.ts | 93 +++++++++++++------ assets/bundles/Chat18x/SettingPanel.prefab | 42 ++++----- 4 files changed, 91 insertions(+), 52 deletions(-) diff --git a/assets/Scripts/chat18x/core/ChatAIService.ts b/assets/Scripts/chat18x/core/ChatAIService.ts index aa7e6537..9376eba0 100644 --- a/assets/Scripts/chat18x/core/ChatAIService.ts +++ b/assets/Scripts/chat18x/core/ChatAIService.ts @@ -86,8 +86,10 @@ export class ChatAIService { const config = ApiConfig.Instance.getAIConfig(); // 使用 ChatHistoryManager 的统一加载方法(优先本地,无则获取服务端) - const savedHistory = await ChatHistoryManager.Instance.loadChatHistory(roleId); - + const savedHistory = await ChatHistoryManager.Instance.loadChatHistory( + roleId + ); + let chat; if (savedHistory && savedHistory.length > 0) { chat = this.ai.chats.create({ diff --git a/assets/Scripts/chat18x/ui/panels/ChatPanel.ts b/assets/Scripts/chat18x/ui/panels/ChatPanel.ts index 0a8066b2..177acd0c 100644 --- a/assets/Scripts/chat18x/ui/panels/ChatPanel.ts +++ b/assets/Scripts/chat18x/ui/panels/ChatPanel.ts @@ -193,6 +193,8 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback { //const dataDetail = roleData.detail; const girlData = DataManager.I.getDataById(DataId.Girl); + + this.nameKey = girlData.getGrilName(this.categoryId, this.id); this.girlName.string = LanguageUtils.getText(this.nameKey); // ResManager.I.changeBundleSpriteFrame( diff --git a/assets/Scripts/chat18x/ui/panels/SettingPanel.ts b/assets/Scripts/chat18x/ui/panels/SettingPanel.ts index b7f9df7d..3630a4c8 100644 --- a/assets/Scripts/chat18x/ui/panels/SettingPanel.ts +++ b/assets/Scripts/chat18x/ui/panels/SettingPanel.ts @@ -37,7 +37,8 @@ export class SettingPanel extends li_BaseView { @property(Node) private panelBg: Node = null; - private languageDrawdown; + private languageDrawdown: Node; + private curLanguage: Label; private languageButtons: LanguageButton[] = []; private currentSelectedLang: LanguageType = null; protected start(): void { @@ -45,25 +46,55 @@ export class SettingPanel extends li_BaseView { this.initUI(); this.registerListener(); + + if (this.languageDrawdown) { + this.languageDrawdown.active = false; + this.languageDrawdown.setScale(new Vec3(1, 0, 1)); + } } onEnable() { this.currentSelectedLang = LanguageUtils.CurrentLanguage; this.updateSelection(); - if (this.languageDrawdown) { - this.languageDrawdown.active = false; - } + this.playEnterAnimation(); } + private music_on: Node; + private music_off: Node; + private sound_on: Node; + private sound_off: Node; private initUI() { this.languageDrawdown = this._nodeTab.languageSelection; + this.curLanguage = this._nodeTab.curLanguage.getComponent(Label); this.initLanguageButton( - this._nodeTab.Language1, + this._nodeTab.Language1.getComponent(Button), LanguageType.EN, "English" ); - this.initLanguageButton(this._nodeTab.Language2, LanguageType.HI, "हिंदी"); + this.initLanguageButton( + this._nodeTab.Language2.getComponent(Button), + LanguageType.HI, + "हिंदी" + ); + + this.languageButtons.forEach((b) => { + if (b.language == LanguageUtils.CurrentLanguage) { + this.curLanguage.string = b.label.string; + } + }); + + this.music_on = this._nodeTab.MusicBtn.getChildByName("On"); + this.music_off = this._nodeTab.MusicBtn.getChildByName("Off"); + this.sound_on = this._nodeTab.SoundBtn.getChildByName("On"); + this.sound_off = this._nodeTab.SoundBtn.getChildByName("Off"); + + let currentState = PlayerDataManager.I.IsSoundOn; + this.sound_on.active = currentState; + this.sound_off.active = !currentState; + currentState = PlayerDataManager.I.IsMusicOn; + this.music_on.active = currentState; + this.music_off.active = !currentState; } private initLanguageButton( @@ -121,8 +152,8 @@ export class SettingPanel extends li_BaseView { this ); - GButton.BandClick(this._nodeTab.Language1, this.switchToEn, this); - GButton.BandClick(this._nodeTab.Language2, this.swithcToHi, this); + // GButton.BandClick(this._nodeTab.Language1, this.switchToEn, this); + // GButton.BandClick(this._nodeTab.Language2, this.swithcToHi, this); GButton.BandClick(this._nodeTab.closeBtn, this.close, this); @@ -140,20 +171,33 @@ export class SettingPanel extends li_BaseView { } switchSound() { const currentState = PlayerDataManager.I.IsSoundOn; + this.sound_on.active = currentState; + this.sound_off.active = !currentState; PlayerDataManager.I.SetSoundOn(!currentState); - AudioManager.I.PlayEffect("click"); } switchMusic() { const currentState = PlayerDataManager.I.IsMusicOn; + this.music_on.active = currentState; + this.music_off.active = !currentState; PlayerDataManager.I.SetMusicOn(!currentState); - AudioManager.I.PlayEffect("click"); } + isShow: boolean = false; openLanguageSelection() { - if (this.languageDrawdown) { - this.languageDrawdown.active = true; + if (!this.isShow) { + if (this.languageDrawdown) { + this.languageDrawdown.active = true; + tween(this.languageDrawdown) + .to(0.2, { scale: new Vec3(1, 1, 1) }) + .start(); + } + } else { + tween(this.languageDrawdown) + .to(0.2, { scale: new Vec3(1, 0, 1) }) + .start(); } + this.isShow = !this.isShow; } switchToEn() { @@ -172,8 +216,7 @@ export class SettingPanel extends li_BaseView { if (this.currentSelectedLang === language) { return; } - - AudioManager.I.PlayEffect("click"); + //AudioManager.I.PlayEffect("click"); this.currentSelectedLang = language; LanguageUtils.setLanguage(language); @@ -185,12 +228,14 @@ export class SettingPanel extends li_BaseView { if (selectedBtn && selectedBtn.button) { this.playSelectAnimation(selectedBtn.button.node); } + this.curLanguage.string = selectedBtn.label.string; - this.scheduleOnce(() => { - this.playExitAnimation(() => { - this.close(); - }); - }, 0.5); + if (this.languageDrawdown) { + tween(this.languageDrawdown) + .to(0.2, { scale: new Vec3(1, 0, 1) }) + .start(); + } + this.isShow = false; } private updateSelection() { @@ -241,14 +286,4 @@ export class SettingPanel extends li_BaseView { callback(); } } - - onDestroy() { - this.languageButtons.forEach((langBtn) => { - if (langBtn.button) { - langBtn.button.node.targetOff(this); - } - }); - - super.onDestroy(); - } } diff --git a/assets/bundles/Chat18x/SettingPanel.prefab b/assets/bundles/Chat18x/SettingPanel.prefab index 251036f0..deba2efc 100644 --- a/assets/bundles/Chat18x/SettingPanel.prefab +++ b/assets/bundles/Chat18x/SettingPanel.prefab @@ -46,7 +46,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": 0, - "y": 0, + "y": 251.15699999999993, "z": 0 }, "_lrot": { @@ -227,7 +227,7 @@ "r": 255, "g": 255, "b": 255, - "a": 164 + "a": 255 }, "_spriteFrame": { "__uuid__": "135b84c5-52d8-4565-812e-c212a5f1a366@f9941", @@ -261,8 +261,6 @@ "__id__": 0 }, "fileId": "c9vrQdTkJOhbCKY8SH8Zch", - "instance": null, - "targetOverrides": null, "nestedPrefabInstanceRoots": null }, { @@ -5071,7 +5069,7 @@ "node": { "__id__": 187 }, - "_enabled": true, + "_enabled": false, "__prefab": { "__id__": 197 }, @@ -5080,12 +5078,15 @@ "_dstBlendFactor": 4, "_color": { "__type__": "cc.Color", - "r": 255, - "g": 255, - "b": 255, + "r": 214, + "g": 214, + "b": 214, "a": 255 }, - "_spriteFrame": null, + "_spriteFrame": { + "__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@f9941", + "__expectedType__": "cc.SpriteFrame" + }, "_type": 1, "_fillType": 0, "_sizeMode": 0, @@ -5119,7 +5120,7 @@ }, "clickEvents": [], "_interactable": true, - "_transition": 2, + "_transition": 1, "_normalColor": { "__type__": "cc.Color", "r": 214, @@ -5184,8 +5185,6 @@ "__id__": 0 }, "fileId": "c7elOiU6lL742K74e1NJ3v", - "instance": null, - "targetOverrides": null, "nestedPrefabInstanceRoots": null }, { @@ -5576,7 +5575,7 @@ "node": { "__id__": 207 }, - "_enabled": true, + "_enabled": false, "__prefab": { "__id__": 217 }, @@ -5585,12 +5584,15 @@ "_dstBlendFactor": 4, "_color": { "__type__": "cc.Color", - "r": 255, - "g": 255, - "b": 255, + "r": 214, + "g": 214, + "b": 214, "a": 255 }, - "_spriteFrame": null, + "_spriteFrame": { + "__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@f9941", + "__expectedType__": "cc.SpriteFrame" + }, "_type": 1, "_fillType": 0, "_sizeMode": 0, @@ -5624,7 +5626,7 @@ }, "clickEvents": [], "_interactable": true, - "_transition": 2, + "_transition": 0, "_normalColor": { "__type__": "cc.Color", "r": 214, @@ -5689,8 +5691,6 @@ "__id__": 0 }, "fileId": "ad+JOqXVVBgJzQOCZa3yWE", - "instance": null, - "targetOverrides": null, "nestedPrefabInstanceRoots": null }, { @@ -6201,6 +6201,6 @@ "__id__": 0 }, "fileId": "38Fm50GEVAG5PwFkR1o9QJ", - "targetOverrides": null + "instance": null } ] \ No newline at end of file