
import Panel from "../views/Panel";
import PanelCtrl from "../ctrls/panelCtrl";
import { DataManager } from "../../libs/tw/manager/DataManager";
import SceneCtrl from "../ctrls/sceneCtrl";
import { ModuleTypes } from "../types/sceneTypes";
import { Buried } from "../../libs/tw/util/Buried";
import { NetManager } from "../../libs/tw/manager/NetManager";
import Loading from "../loading/Loading";

export default class HintPanel extends Panel {

    public cancelLabBtn:eui.Button;//取消按钮
    public okLabBtn:eui.Button;//确定按钮
    public titileLab:eui.Label;//标题
    public contentLab:eui.Label;//内容

    private mData:any;
    public get skinKey() { return 'HintPanel' }
    
    constructor(data?){
        super(data);
        this.mData = data;
    }

    onSkinComplete():void{
        super.onSkinComplete();
        this.once(egret.Event.ADDED_TO_STAGE,this.onLoad,this);
		if(this.stage){
			this.onLoad();
        }
        this.showAct();
    }

    start():void{
        this.percentHeight = 100;
        
    }
    private onLoad():void{
        this.init();
    }   
    private init(){
        console.log('hint弹窗',this.mData);
        if(this.mData && this.mData.title){
            this.titileLab.text = this.mData.title;
        }
        if(this.mData && this.mData.content){
            this.contentLab.text = this.mData.content;
        }
    }
    initEvents():void{
        super.initEvents();
        this.cancelLabBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_cancel, this);
        this.okLabBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_ok, this);
    }

    removeEvents():void{
        super.removeEvents();
        this.cancelLabBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_cancel, this);
        this.okLabBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_ok, this);
    }


    onTap_ok(e:egret.TouchEvent){
        if(this.mData && this.mData.callBackeOk){
            this.mData.callBackeOk();
        }
        this.hidePanel();
    }
    onTap_cancel(e:egret.TouchEvent){
        if(this.mData && this.mData.callBackeCancel){
            this.mData.callBackeCancel();
        }
        this.hidePanel();
    }
}