DiscoverSettingViewPresenter.ts
2.69 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { AudioSettings } from "simba-cc-audio-manager";
import { SDK } from "simba-sdk";
import { PageIndex } from "../../../../avg/EditorEnums";
import { Presenter } from "../../../../common/classbase/PresenterBase";
import { GameTextData } from "../../../../common/gameplay/gamedata/GameTextData";
import { UIManager } from "../../../../common/gameplay/managers/UIManager";
import GameDotMgr from "../../../GameDotMgr";
import { GameModelManager } from "../../../model/GameModelManager";
import { RegPresenter } from "../../PresenterCCViewFactory";
import { DiscoverSettingView, DiscoverSettingViewType } from "../../view/type/discover/DiscoverSettingView";
import { SourceView } from "../../view/type/notice/NewNoticeView";
import ExchangeCodeViewPresenter from "../ExchangeCodeViewPresenter";
import NewNoticeViewPresenter from "../notice/NewNoticeViewPresenter";
@RegPresenter(DiscoverSettingViewType)
export class DiscoverSettingViewPresenter extends Presenter<undefined, DiscoverSettingView> {
static uuid = "DiscoverSettingViewPresenter";
onOpen() {
super.onOpen(undefined);
this.view.setProps({
soundEnabled: AudioSettings.soundVolume > 0,
musicEnabled: AudioSettings.musicVolume > 0,
onToggleSound: this.toggleSound,
onToggleMusic: this.toggleMusic,
onToggleNotice: this.toggleNotice,
onToggleExchangeCode: this.toggleExchangeCode
});
this._disposable.add(GameModelManager.CloseSettingView.on(this.onCloseSettingView));
}
toggleSound = () => {
AudioSettings.soundVolume = AudioSettings.soundVolume > 0 ? 0 : 1;
this.view.updateProps({
soundEnabled: AudioSettings.soundVolume > 0
});
}
toggleMusic = () => {
AudioSettings.musicVolume = AudioSettings.musicVolume > 0 ? 0 : 1;
this.view.updateProps({
musicEnabled: AudioSettings.musicVolume > 0
});
}
toggleNotice = () => {//公告
UIManager.pushPresenter(NewNoticeViewPresenter, SourceView.SettingView);
}
toggleExchangeCode = () => {//兑换码
//点击兑换码打点
GameDotMgr.getInstance().dotClickUI("exchange_code");
let title = GameModelManager.getLanguageTxt(GameTextData.TEXT_EXCHANGETITLE_VALUE);
let content = "";
UIManager.pushPresenter(ExchangeCodeViewPresenter, {
titletxt: title,
contenttxt: content
});
}
onClose() {
super.onClose();
UIManager.popToPresenter(this);
SDK.showGameClubButton();
}
onCloseSettingView = (index: PageIndex) => {
this.view.close(true);
GameModelManager.JumpToViewInGame.emit(index);
}
}