/**
 * Copyright (c) 2014,www.easygame.org
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the easygame.org nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY EASYEGRET.COM AND CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL EGRET-LABS.ORG AND CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
module virus{

    /**
     * <p></p>
     * @date  :2020-02-12 14:47:47
     * @EasyGame.org Tools
     */ 
    export class LoadMian  extends easy.Group{
        public resSpriteSheet:string = "LoadMian";//合并材质资源名称
        public resTexture:Array<string> = ["loadbg"];//单材质资源名称
        public resGroup:Array<string> = ["loading_main"];//配置文件的Group
        public resFiles:Array<string> = ["loading_main.json"];//需要下载的资源group
        public spriteSheet:egret.SpriteSheet = null;//ui对应的材质集,已经分割好,方便外部读取方便

        public group:easy.Group = null;
        public imgbg:easy.Image = null;
        public imgtu1:easy.Image = null;
        public imgtu2:easy.Image = null;
        public imgtu3:easy.Image = null;
        public imgtu4:easy.Image = null;

        public constructor() {
            super(true);
        }
        /**
         * 初始化主场景的组件,加入场景时,主动调用一次
         * 子类覆写该方法,添加UI逻辑
         */  
        public createChildren():void {
            super.createChildren();
            this.showBg = false;
            this.border = false;
            this.width = 750;
            this.height = 1334;
            this.topEnabled = true;
            this.bottomEnabled = true;
            this.leftEnabled = true;
            this.rightEnabled = true;
            //group 
            this.group = new easy.Group(true);
            this.group.name = "group";
            this.addChild(this.group);
            this.group.showBg = false;
            this.group.border = false;
            this.group.width = 750;
            this.group.height = 1334;
            this.group.horizontalEnabled = true;
            this.group.verticalEnabled = true;
            //imgbg 
            this.imgbg = new easy.Image(true);
            this.imgbg.name = "imgbg";
            this.group.addChild(this.imgbg);
            this.imgbg.width = 750;
            this.imgbg.height = 1334;
            //imgtu1 
            this.imgtu1 = new easy.Image(true);
            this.imgtu1.name = "imgtu1";
            this.group.addChild(this.imgtu1);
            this.imgtu1.x = 276;
            this.imgtu1.y = 423;
            this.imgtu1.width = 198;
            this.imgtu1.height = 176;
            //imgtu2 
            this.imgtu2 = new easy.Image(true);
            this.imgtu2.name = "imgtu2";
            this.group.addChild(this.imgtu2);
            this.imgtu2.x = 128;
            this.imgtu2.y = 554;
            this.imgtu2.width = 494;
            this.imgtu2.height = 82;
            //imgtu3 
            this.imgtu3 = new easy.Image(true);
            this.imgtu3.name = "imgtu3";
            this.group.addChild(this.imgtu3);
            this.imgtu3.x = 156;
            this.imgtu3.y = 572;
            this.imgtu3.width = 438;
            this.imgtu3.height = 20;
            //imgtu4 
            this.imgtu4 = new easy.Image(true);
            this.imgtu4.name = "imgtu4";
            this.group.addChild(this.imgtu4);
            this.imgtu4.x = 156;
            this.imgtu4.y = 572;
            this.imgtu4.width = 438;
            this.imgtu4.height = 20;

        }
        /**
         * 获取初始化逻辑,加入场景时,主动调用一次
         * 子类覆写该方法,添加业务逻辑
         */
         public initData():void {
           super.initData();
        }
        /**
         * 进入的逻辑
         * 可以再次根据外部数据情况做一些逻辑处理
         */
        public enter():void {

        }

        /**
         * 退出的逻辑
         * 做一些数据的销毁或者初始化,保证下次进入的时候,不会残留
         */
        public outer():void {

        }
        /**
         * 刷新UI皮肤显示
         */
        public validateNow():void{
            this.drawDelay = false;
            var jsonData:any = RES.getRes("LoadMian_json");
            if (jsonData != null) {
                this.spriteSheet = new egret.SpriteSheet(RES.getRes("LoadMian_img"));
                for (var key in jsonData.texture){
                    this.spriteSheet.createTexture(key, jsonData.texture[key].x, jsonData.texture[key].y, jsonData.texture[key].w, jsonData.texture[key].h);
                }
            }
            this.group.drawDelay = false;
            this.imgbg.texture = RES.getRes("loadbg");
            this.imgbg.drawDelay = false;
            this.imgtu1.texture = this.spriteSheet.getTexture("load1");
            this.imgtu1.drawDelay = false;
            this.imgtu2.texture = this.spriteSheet.getTexture("load2");
            this.imgtu2.drawDelay = false;
            this.imgtu3.texture = this.spriteSheet.getTexture("load3");
            this.imgtu3.drawDelay = false;
            this.imgtu4.texture = this.spriteSheet.getTexture("load3");
            this.imgtu4.drawDelay = false;

        }
    }
}