/**
 * 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 modules{

    /**
     * <p></p>
     * @date  :2020-04-09 21:28:19
     * @EasyGame.org Tools
     */ 
    export class index2  extends easy.Group{
        public resourceRoot:string = "";
        public resSpriteSheet:string = "index2";//合并材质资源名称
        public resTexture:Array<string> = ["2","page02-12","red","yellow"];//单材质资源名称
        public resGroup:Array<string> = ["courseware_index2"];//配置文件的Group
        public resFiles:Array<string> = ["courseware/index2_loader_200409212819.json"];//需要下载的资源group
        public spriteSheet:egret.SpriteSheet = null;//ui对应的材质集,已经分割好,方便外部读取方便

        public group:easy.Group = null;
        public imgas:easy.Image = null;
        public groupAll:easy.Group = null;
        public img1:easy.Image = null;
        public imgWord:easy.Image = null;
        public img2:easy.Image = null;
        public img3:easy.Image = null;
        public groupCont:easy.Group = null;
        public imgCont:easy.Image = null;
        public imgClick:easy.Image = null;
        public imgPorinter:easy.Image = null;
        public groupClick:easy.Group = null;
        public imgShow:easy.Image = null;
        public btnDele:easy.Button = null;
        public btnAgain:easy.Button = null;
        public btnPage:easy.Button = null;
        public temp:tempTemplate = null;

        public constructor() {
            super(true);
        }
        /**
         * 初始化主场景的组件,加入场景时,主动调用一次
         * 子类覆写该方法,添加UI逻辑
         */  
        public createChildren():void {
            super.createChildren();
            this.showBg = false;
            this.border = false;
            this.width = 640;
            this.height = 960;
            //group 
            this.group = new easy.Group(true);
            this.group.name = "group";
            this.addChild(this.group);
            this.group.bgColor = 0xffffff;
            this.group.border = false;
            this.group.width = 640;
            this.group.height = 960;
            //imgas 
            this.imgas = new easy.Image(true);
            this.imgas.name = "imgas";
            this.addChild(this.imgas);
            this.imgas.y = 26.5;
            this.imgas.width = 620;
            this.imgas.height = 907;
            this.imgas.leftEnabled = true;
            this.imgas.visible = false;
            //groupAll 
            this.groupAll = new easy.Group(true);
            this.groupAll.name = "groupAll";
            this.addChild(this.groupAll);
            this.groupAll.showBg = false;
            this.groupAll.border = false;
            this.groupAll.width = 640;
            this.groupAll.height = 960;
            this.groupAll.verticalEnabled = true;
            //img1 
            this.img1 = new easy.Image(true);
            this.img1.name = "img1";
            this.groupAll.addChild(this.img1);
            this.img1.y = 26;
            this.img1.width = 102;
            this.img1.height = 51;
            //imgWord 
            this.imgWord = new easy.Image(true);
            this.imgWord.name = "imgWord";
            this.groupAll.addChild(this.imgWord);
            this.imgWord.x = 113;
            this.imgWord.y = 27;
            this.imgWord.width = 309;
            this.imgWord.height = 50;
            //img2 
            this.img2 = new easy.Image(true);
            this.img2.name = "img2";
            this.groupAll.addChild(this.img2);
            this.img2.y = 165;
            this.img2.width = 21;
            this.img2.height = 155;
            //img3 
            this.img3 = new easy.Image(true);
            this.img3.name = "img3";
            this.groupAll.addChild(this.img3);
            this.img3.y = 320;
            this.img3.width = 21;
            this.img3.height = 487;
            //groupCont 
            this.groupCont = new easy.Group(true);
            this.groupCont.name = "groupCont";
            this.groupAll.addChild(this.groupCont);
            this.groupCont.showBg = false;
            this.groupCont.border = false;
            this.groupCont.x = 46;
            this.groupCont.y = 167;
            this.groupCont.width = 574;
            this.groupCont.height = 626;
            //imgCont 
            this.imgCont = new easy.Image(true);
            this.imgCont.name = "imgCont";
            this.groupCont.addChild(this.imgCont);
            this.imgCont.width = 574;
            this.imgCont.height = 626;
            //imgClick 
            this.imgClick = new easy.Image(true);
            this.imgClick.name = "imgClick";
            this.groupCont.addChild(this.imgClick);
            this.imgClick.x = 307;
            this.imgClick.y = 92;
            this.imgClick.width = 212;
            this.imgClick.height = 68;
            //imgPorinter 
            this.imgPorinter = new easy.Image(true);
            this.imgPorinter.name = "imgPorinter";
            this.groupCont.addChild(this.imgPorinter);
            this.imgPorinter.x = 484;
            this.imgPorinter.y = 112;
            this.imgPorinter.width = 22;
            this.imgPorinter.height = 36;
            //groupClick 
            this.groupClick = new easy.Group(true);
            this.groupClick.name = "groupClick";
            this.groupAll.addChild(this.groupClick);
            this.groupClick.showBg = false;
            this.groupClick.border = false;
            this.groupClick.x = 114;
            this.groupClick.y = 300;
            this.groupClick.width = 412;
            this.groupClick.height = 480;
            this.groupClick.visible = false;
            //imgShow 
            this.imgShow = new easy.Image(true);
            this.imgShow.name = "imgShow";
            this.groupClick.addChild(this.imgShow);
            this.imgShow.width = 412;
            this.imgShow.height = 480;
            //btnDele 
            this.btnDele = new easy.Button(true);
            this.btnDele.name = "btnDele";
            this.groupClick.addChild(this.btnDele);
            this.btnDele.width = 33;
            this.btnDele.height = 25;
            this.btnDele.x = 345;
            this.btnDele.y = 20;
            //btnAgain 
            this.btnAgain = new easy.Button(true);
            this.btnAgain.name = "btnAgain";
            this.groupAll.addChild(this.btnAgain);
            this.btnAgain.width = 133;
            this.btnAgain.height = 47;
            this.btnAgain.x = 467;
            this.btnAgain.y = 887;
            //btnPage 
            this.btnPage = new easy.Button(true);
            this.btnPage.name = "btnPage";
            this.groupAll.addChild(this.btnPage);
            this.btnPage.width = 133;
            this.btnPage.height = 47;
            this.btnPage.x = 27;
            this.btnPage.y = 887;
            //temp 
            this.temp = new modules.tempTemplate();
            this.temp.name = "temp";
            this.addChild(this.temp);
            if (this.temp.ui["resFiles"]) this.resFiles = this.resFiles.concat(this.temp.ui.resFiles);
            if (this.temp.ui["resGroup"]) this.resGroup = this.resGroup.concat(this.temp.ui.resGroup);
            this.temp.x = 540;
            this.temp.rightEnabled = true;
            this.temp.ui.rightEnabled = true;

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

        }

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

        }
        /**
         * 刷新UI皮肤显示
         */
        public validateNow():void{
            this.drawDelay = false;
            var jsonData:any = RES.getRes("index2_json");
            if (jsonData != null) {
                this.spriteSheet = new egret.SpriteSheet(RES.getRes("index2_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.imgas.texture = RES.getRes("2");
            this.imgas.drawDelay = false;
            this.groupAll.drawDelay = false;
            if (this.spriteSheet) this.img1.texture = this.spriteSheet.getTexture("page02-01");
            this.img1.drawDelay = false;
            if (this.spriteSheet) this.imgWord.texture = this.spriteSheet.getTexture("page02-02");
            this.imgWord.drawDelay = false;
            if (this.spriteSheet) this.img2.texture = this.spriteSheet.getTexture("page_2_4");
            this.img2.drawDelay = false;
            if (this.spriteSheet) this.img3.texture = this.spriteSheet.getTexture("page_2_5");
            this.img3.drawDelay = false;
            this.groupCont.drawDelay = false;
            if (this.spriteSheet) this.imgCont.texture = this.spriteSheet.getTexture("page02-13");
            this.imgCont.drawDelay = false;
            if (this.spriteSheet) this.imgClick.texture = this.spriteSheet.getTexture("page02-15");
            this.imgClick.drawDelay = false;
            if (this.spriteSheet) this.imgPorinter.texture = this.spriteSheet.getTexture("page02-14");
            this.imgPorinter.drawDelay = false;
            this.groupClick.drawDelay = false;
            if (this.spriteSheet) this.imgShow.texture = this.spriteSheet.getTexture("page02-16");
            this.imgShow.drawDelay = false;
            if (this.spriteSheet) this.btnDele.texture = this.spriteSheet.getTexture("page02-17");
            this.btnDele.drawDelay = false;
            this.btnAgain.texture = RES.getRes("page02-12");
            this.btnAgain.drawDelay = false;
            if (this.spriteSheet) this.btnPage.texture = this.spriteSheet.getTexture("page02-11");
            this.btnPage.drawDelay = false;
            //模板temp
            this.temp.validateNow();

        }
    }
}