UISetting.ts
1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { SaveDataManager } from "../../component/SaveDataManager";
import { WindowName } from "../../Global";
import { UIBase } from "../UIBase";
import { UIManager } from "../UIManager";
const { ccclass, property } = cc._decorator;
@ccclass
export default class UISetting extends UIBase {
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start() {
}
protected onEnable(): void {
this.refresh();
}
// update (dt) {}
onBtnMuteClick() {
SaveDataManager.ins.setMusicMute(!SaveDataManager.ins.runtimeData.musicMute);
this.refresh();
}
onBtnVibrationClick() {
SaveDataManager.ins.setSoundEffectMute(!SaveDataManager.ins.runtimeData.SEMute);
this.refresh();
}
onCloseClick() {
UIManager.ins.closeWindow(WindowName.SETTING);
}
private refresh() {
this.node.getChildByName('btnSE').getChildByName('disable').active = (SaveDataManager.ins.runtimeData.SEMute);
this.node.getChildByName('btnMusic').getChildByName('disable').active = (SaveDataManager.ins.runtimeData.musicMute);
}
onBtnPrivacy() {
UIManager.ins.openWindow(WindowName.PRIVACY, 2);
}
}