import doStart from "../../new_tw/ctrls/doStart";
import { DataManager } from "../../tw/manager/DataManager";
import { NetManager } from "../../tw/manager/NetManager";
import SceneCtrl from "../ctrls/sceneCtrl";
import { ModuleTypes } from "../types/sceneTypes";
import Loading from "./Loading";
import Panel from "./Panel";
export default class NoPrizePanel extends Panel {
    start(data) {
        super.start();
        this.data.score = `本局分数 ${DataManager.ins.gameGetSubmitResultData.score}`;
        NetManager.ins.getInfo();
    }

    initEvents() {
        super.initEvents();
        this['onceAgainBtn'].once(egret.TouchEvent.TOUCH_TAP, this.onTouchTap, this);
    }

    onTouchTap() {
        this.closeBtns.forEach(
            btn => { if (btn) btn.touchEnabled = false }
        );
        Loading.instace.show();
        doStart((success) => {
            Loading.instace.hide();
            if (success) {
                this.hidePanel();
                SceneCtrl.instance.change(ModuleTypes.PLAY_SCENE);
            }
        });
    }

    onTouchTap_closeBtn(): any {
        super.onTouchTap_closeBtn();
        SceneCtrl.instance.change(ModuleTypes.START_SCENE);
    }
    get skinKey() { return 'NoPrize' }

    protected get closeBtns(): eui.Button[] {
        return [this['closeBtn']]
    }
}