import Panel from "../views/Panel";
import SoundMgr from "../Mgr/SoundMgr";

export default class SoundPanel extends Panel {
    get skinKey() { return "SoundPanel" }
    get groupName() { return "sound_panel" }
    public toggleBack: eui.ToggleSwitch;
    public toggleEffect: eui.ToggleSwitch;


    onSkinComplete() {
        super.onSkinComplete();
        SoundMgr.instance.firstSeted = true;

        this.toggleBack.selected = SoundMgr.instance.musicEnabled;
        this.toggleEffect.selected = SoundMgr.instance.effectEnabled;

        this.toggleBack.addEventListener(egret.Event.CHANGE, (e: eui.UIEvent) => {
            SoundMgr.instance.musicEnabled = (e.target as eui.ToggleSwitch).selected;
        }, this);

        this.toggleEffect.addEventListener(egret.Event.CHANGE, (e: eui.UIEvent) => {
            SoundMgr.instance.effectEnabled = (e.target as eui.ToggleSwitch).selected;
        }, this);
    }
}