Files
18xchat/assets/Scripts/Sub/UI/Setting_UI.ts
T
2025-07-17 17:18:21 +08:00

73 lines
2.0 KiB
TypeScript

import { _decorator, Node, Toggle } from 'cc';
import { GButton } from '../../Main/Common/GButton';
import Utils from '../../Main/Common/Utils';
import { ViewManager } from '../../Main/Manager/ViewManager';
import li_BaseView from '../../Main/Common/li_BaseView';
import PlayerDataManager from '../../Main/Manager/PlayerDataManager';
const { ccclass, property } = _decorator;
//设置界面
@ccclass('Setting_UI')
export class Setting extends li_BaseView {
private _nodeTab: any = {};
private _data;
private _musicOn: boolean = true; //音乐开关
private _soundOn: boolean = true; //音效开关
private tgMusic: Toggle = null;
private tgSound: Toggle = null;
//----重写父类接口---------------------------------------
onLoadCT() {
this.registerListenner();
}
openUIDataCT(data: any): void {
this._data = data
}
registerListenner() {
// Utils.addInnerEL(InnerMsgCode.GM_UI_Close, this, this.resiveGMClose)
}
start() {
Utils.parseNode(this.node, this._nodeTab)
GButton.BandClick(this._nodeTab.bgmask, ()=>{
this.onClose()
}, this);
GButton.BandClick(this._nodeTab.btnClose, ()=>{
this.onClose()
}, this);
// GButton.BandClick(this._nodeTab.tgMusic, ()=>{
// this.onClose()
// }, this);
// GButton.BandClick(this._nodeTab.tgSound, ()=>{
// this.onClose()
// }, this);
this.tgMusic = this._nodeTab.tgMusic.getComponent(Toggle);
this.tgSound = this._nodeTab.tgSound.getComponent(Toggle);
this.tgMusic.isChecked = PlayerDataManager.I.IsMusicOn;
this.tgSound.isChecked = PlayerDataManager.I.IsSoundOn;
}
update(deltaTime: number) {
}
//背景乐开关,在UI里设置
onTgMusicClick(tg:any, ev:any) {
PlayerDataManager.I.SetMusicOn(this.tgMusic.isChecked)
}
//音效开关,在UI里设置
onTgSoundClick(tg:any, ev:any) {
PlayerDataManager.I.SetSoundOn(this.tgSound.isChecked)
}
}