import { LayOUT} from "../utils/LayOUT";
import { ViewManager } from "../View/ViewManager";
import {WarnPanel} from "../View/WarnPanel";
import {RoleData} from "../Data/RoleData";
import Sprite = Laya.Sprite;
export class AlertUtils 
{
    static  YES:string = "YES";

    static  NO:string = "NO";

    static  CLOSE:string = "CLOSE";

    static  closeAlert():void
    {
        ViewManager.Instance.close( WarnPanel );
    }


     /**
     * 确认框
     * @param titleStr 标题
     * @param descstr 说明
     * @param callobj 作用域
     * @param callback 回调函数
     * @param calldata 回调参数
     * @param okstr 确认按钮文字
     * @param cancelStr 取消按钮文字
     * @param layer 添加层级
     */
    static  confirm(titleStr: string,descstr:string,callobj:any=null,
        callback:Function=null,calldata:any=null):void
    {
        ViewManager.Instance.close( WarnPanel );
        var d: any = {};
        d.titleStr = titleStr;
        d.descStr = descstr;
        d.callobj = callobj;
        d.callback = callback;
        d.calldata=calldata;
        d.cancelStr = "";
        d.okstr = "";
        d.type = 0;
        ViewManager.Instance.add(WarnPanel, d, LayOUT.TIP);
    }


    /****************************** */
    private sp1: Sprite;
        private sp2: Sprite;
    private createApes(): void {
        var gap: number = 300;

        this.sp1 = new Sprite();


        this.sp1.pos((Laya.stage.width - gap) / 2, Laya.stage.height / 2);
        //设置轴心点为中心
        this.sp1.pivot(55, 72);
        Laya.stage.addChild(this.sp1);

        //不设置轴心点默认为左上角
        this.sp2 = new Sprite();
        this.sp2.pos((Laya.stage.width + gap) / 2, Laya.stage.height / 2);
        Laya.stage.addChild(this.sp2);

        Laya.timer.frameLoop(1, this, this.animate);
    }

    private animate(e: Event): void {
        this.sp1.rotation += 2;
        this.sp2.rotation += 2;
    }
    /****************************** */

    /**
     * 提示框（只有确认按钮）
     * @param titleStr 标题
     * @param descstr 说明
     * @param callobj 作用域
     * @param callback 回调函数
     * @param calldata 回调参数
     * @param okstr 确认按钮文字
     * @param layer 添加层级
     */
    static  alert(titleStr:string,descstr:string,callobj:any=null,
                            callback:Function=null,calldata:any=null ):void
    {
        ViewManager.Instance.close( WarnPanel );
        var d: any = {};
        d.titleStr = titleStr;
        d.descStr = descstr;
        d.callobj = callobj;
        d.callback = callback;
        d.calldata=calldata;
        d.cancelStr = "";
        d.okstr = "";
        d.type = 1;
        ViewManager.Instance.add(WarnPanel, d, LayOUT.TIP);
    }

   
}