This commit is contained in:
2025-09-17 16:12:54 +08:00
parent 586ea3848d
commit be1389df98
16 changed files with 621 additions and 178 deletions
@@ -56,6 +56,7 @@ export class SettingPanel extends li_BaseView {
onEnable() {
this.currentSelectedLang = LanguageUtils.CurrentLanguage;
this.updateSelection();
this.updateAudioButtonStates();
this.playEnterAnimation();
}
@@ -89,12 +90,7 @@ export class SettingPanel extends li_BaseView {
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;
this.updateAudioButtonStates();
}
private initLanguageButton(
@@ -143,6 +139,17 @@ export class SettingPanel extends li_BaseView {
language,
});
}
private updateAudioButtonStates() {
const soundState = PlayerDataManager.I.IsSoundOn;
this.sound_on.active = soundState;
this.sound_off.active = !soundState;
const musicState = PlayerDataManager.I.IsMusicOn;
this.music_on.active = musicState;
this.music_off.active = !musicState;
}
registerListener() {
GButton.BandClick(this._nodeTab.MusicBtn, this.switchMusic, this);
GButton.BandClick(this._nodeTab.SoundBtn, this.switchSound, this);
@@ -171,16 +178,14 @@ 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);
this.updateAudioButtonStates();
}
switchMusic() {
const currentState = PlayerDataManager.I.IsMusicOn;
this.music_on.active = currentState;
this.music_off.active = !currentState;
PlayerDataManager.I.SetMusicOn(!currentState);
this.updateAudioButtonStates();
}
isShow: boolean = false;