import { _decorator, Button, Component, Node } from 'cc'; import ui_base from 'db://assets/core/ui/ui_base'; import { Layout_Settings } from './Layout_Settings'; import { ModuleDef } from 'db://assets/Scripts/ModuleDef'; import { GameUILayers, gui } from 'db://assets/core/ui/ui'; import { ani_ui } from '../UI_Main/UI_Main'; import { ch } from 'db://assets/ch/ch'; import { SceneDef } from 'db://assets/Scripts/SceneDef'; import { ResUtil } from 'db://assets/core/util/ResUtil'; import { UI_Hall } from '../UI_Hall/UI_Hall'; const { ccclass, property } = _decorator; @ccclass('UI_Settings') export class UI_Settings extends ui_base { constructor() { super(ModuleDef.GAME, 'ui/UI_Settings/Settings', GameUILayers.HUD, Layout_Settings); } protected async onCreated() { const layout = this.getLayout(); ani_ui(layout.Close_Btn.node.parent); this.onButtonEvent(layout.Close_Btn, async (button: any) => { //关闭设置界面 gui.close(UI_Settings); }, this); layout.Toggle_Music.isChecked = ch.audio.volumeMusic != 0; layout.Toggle_Sound.isChecked = ch.audio.switchEffect; this.onToggleEvent(layout.Toggle_Music, async (toggle: any) => { ch.audio.volumeMusic = toggle.isChecked; ch.audio.save(); // button_sound(); }, this); this.onToggleEvent(layout.Toggle_Sound, async (toggle: any) => { ch.audio.switchEffect = toggle.isChecked; ch.audio.save(); // button_sound(); }, this); this.onButtonEvent(layout.Defeat_Btn, async (button: any) => { await gui.closeAll(); gui.show(UI_Hall); ResUtil.loadScene(SceneDef.Hall, ModuleDef.GAME, true); }, this); } }