1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import { _decorator, Button, Component, Node } from 'cc';
- import { Layout_Settings } from './Layout_Settings';
- import { ani_ui } from '../UI_Main/UI_Main';
- import { UI_Hall } from '../UI_Hall/UI_Hall';
- import { ch } from '../../../ch/ch';
- import { GameUILayers, gui } from '../../../core/ui/ui';
- import ui_base from '../../../core/ui/ui_base';
- import { ResUtil } from '../../../core/util/ResUtil';
- import { ModuleDef } from '../../../Scripts/ModuleDef';
- import { SceneDef } from '../../../Scripts/SceneDef';
- 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<Layout_Settings>();
- 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);
- }
- }
|