-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.min.js
executable file
·2 lines (2 loc) · 32.2 KB
/
main.min.js
1
2
function zeroize(e,t,i){void 0===t&&(t=2),void 0===i&&(i=!0);for(var n=""+e,r="",o=0,a=t-n.length;a>o;o++)i?r="0"+r:r+="0";return r+n}function loadScript(e,t,i){for(var n=[],r=3;r<arguments.length;r++)n[r-3]=arguments[r];var o=document.createElement("script");o.type="text/javascript",o.readyState?o.onreadystatechange=function(){("loaded"===o.readyState||"complete"===o.readyState)&&(o.onreadystatechange=null,t.apply(i,n))}:o.onload=function(){t.apply(i,n)},o.src=e,document.documentElement.appendChild(o)}function is(e,t){return egret.is(e,egret.getQualifiedClassName(t))}function remove(e){e&&e.parent&&e.parent.removeChild(e)}function add(e,t,i,n){void 0===i&&(e.x=t.width-e.width>>1),void 0===n&&(e.y=t.height-e.height>>1),t.addChild(e)}function dispatch(e,t){facade.dispatch(e,!1,t)}function on(e,t,i,n){facade.on(e,t,i,!1,n)}function off(e,t,i){facade.off(e,t,i,!1)}function drawRect(e,t,i,n,r){void 0===r&&(r=4095);var o=new egret.Sprite,a=o.graphics;return a.beginFill(r,1),a.drawRect(e,t,i,n),a.endFill(),o}function getFormatTime(e,t){var i=new Date;return i.setTime(e),i.format(t,!0)}function getDate(e,t,i){var n=new Date(e);n.setDate(n.getDate()+t);var r=n.getTime();return getFormatTime(r,i)}function createBitmapByName(e){var t=new egret.Bitmap,i=RES.getRes(e);return t.texture=i,t}var __reflect=this&&this.__reflect||function(e,t,i){e.__class__=t,i?i.push(t):i=[t],e.__types__=e.__types__?i.concat(e.__types__):i},__extends=this&&this.__extends||function(e,t){function i(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)},GenesListItemRenderer=function(e){function t(){var t,i=e.call(this)||this;i.bm=t=new egret.Bitmap,i.addChild(t),t.x=-50,t.y=5;var n;i.nameLb=n=new eui.Label,i.addChild(n),n.size=22,n.width=100,n.y=10;var r;i.comboBox=r=new ComboBox(180),i.addChild(r),r.editable=!1,r.x=n.x+n.width,r.on(-1,i.change,i);var o;i.checkBox=o=new eui.CheckBox,i.addChild(o),o.x=r.x+r.width+70,o.y=12,o.on(egret.TouchEvent.TOUCH_TAP,i.lock,i);var a=new eui.Button;return i.colorBtn=a=new eui.Button,a.label="调色",i.addChild(a),a.x=o.x+o.width+40,a.on(egret.TouchEvent.TOUCH_TAP,i.color,i),i.width=a.x+a.width,i}return __extends(t,e),t.prototype.dataChanged=function(){var e=this.data,t=e.img;t&&(this.bm.bitmapData=RES.getRes(t),this.bm.width=40,this.bm.height=40),this.nameLb.text=e.name;var i=(this.itemIndex+1,e.num);void 0!=i?this.num=i:this.num=Math.pow(2,e.d0len);var n=e.value;this.comboBox.selectedIndex=void 0!=n?n:0,e.iscolor?this.colorBtn.visible=!0:this.colorBtn.visible=!1,this.num?this.enabled=!0:this.enabled=!1},t.prototype.lock=function(){this.comboBox.enabled=!this.checkBox.selected},t.prototype.change=function(){dispatch(-1)},t.prototype.color=function(){dispatch(-3)},t}(eui.ItemRenderer);__reflect(GenesListItemRenderer.prototype,"GenesListItemRenderer");var AssetAdapter=function(){function e(){}return e.prototype.getAsset=function(e,t,i){function n(n){t.call(i,n,e)}if(RES.hasRes(e)){var r=RES.getRes(e);r?n(r):RES.getResAsync(e,n,this)}else RES.getResByUrl(e,n,this,RES.ResourceItem.TYPE_IMAGE)},e}();__reflect(AssetAdapter.prototype,"AssetAdapter",["eui.IAssetAdapter"]);var ColorsListItemRenderer=function(e){function t(){var t,i=e.call(this)||this;i.typeLb=t=new eui.Label,i.addChild(t),t.textColor=16711680,t.size=24,t.width=30;var n;i.attrLb1=n=new eui.Label,i.addChild(n),n.textColor=4896509,n.size=24,n.width=40,n.x=t.width+20,n.text="hl1";var r;i.hl1=r=new TextInput,i.addChild(r),r.size=24,r.width=100,r.x=n.x+n.width+5,r.textColor=0;var o;i.attrLb2=o=new eui.Label,i.addChild(o),o.textColor=4896509,o.size=24,o.width=40,o.x=r.x+r.width+10,o.text="cl1";var a;i.cl1=a=new TextInput,i.addChild(a),a.size=24,a.width=100,a.x=o.x+o.width,a.textColor=0;var s;i.attrLb3=s=new eui.Label,i.addChild(s),s.textColor=4896509,s.size=24,s.width=40,s.x=a.x+a.width+10,s.text="cl2";var l;i.cl2=l=new TextInput,i.addChild(l),l.size=24,l.width=100,l.x=s.x+s.width,l.textColor=0;var d;i.attrLb4=d=new eui.Label,i.addChild(d),d.textColor=4896509,d.size=24,d.width=40,d.x=l.x+l.width+10,d.text="sd1";var h;i.sd1=h=new TextInput,i.addChild(h),h.size=24,h.width=100,h.x=d.x+d.width,h.textColor=0;var c;i.attrLb5=c=new eui.Label,i.addChild(c),c.textColor=4896509,c.size=24,c.width=40,c.x=h.x+h.width+10,c.text="sd2";var u;i.sd2=u=new TextInput,i.addChild(u),u.size=24,u.width=100,u.x=c.x+c.width,u.textColor=0;var p;i.attrLb6=p=new eui.Label,i.addChild(p),p.textColor=4896509,p.size=24,p.width=40,p.x=u.x+u.width+10,p.text="li1";var g;return i.li1=g=new TextInput,i.addChild(g),g.size=24,g.width=100,g.x=p.x+p.width,g.textColor=0,i.width=g.x+120,i}return __extends(t,e),t.prototype.dataChanged=function(){var e=this.data,t=+e.type;if(e&&t){this.typeLb.text=e.type?e.type:"";var i=e.attrObj;for(var n in i)this[n]&&(this[n].text=i[n]);this.visible=!0}else this.visible=!1},t}(eui.ItemRenderer);__reflect(ColorsListItemRenderer.prototype,"ColorsListItemRenderer");var ComboBox=function(e){function t(t,i){void 0===t&&(t=100);var n=e.call(this)||this;n.isShow=!1,n._srollHeight=500,n.onWheel=n.wheelHander.bind(n),n.width=t,i||(i='<e:Skin class="skins.ItemRendererSkin" states="up,down,disabled" maxHeight="40" minWidth="140" xmlns:e="http://ns.egret.com/eui">\n <e:Image width="100%" height="40" scale9Grid="1,3,8,8" alpha.disabled="0.5"\n source="button_up_png"\n source.down="button_down_png"/>\n <e:Label id="labelDisplay" top="8" bottom="8" left="8" right="8"\n size="24" fontFamily="Tahoma"\n textColor="0xFFFFFF" text="{data.value + data.name}" verticalAlign="middle" textAlign="center"/>\n </e:Skin>');var r=new eui.List;r.width=t,r.itemRendererSkinName=i,r.on(eui.ItemTapEvent.ITEM_TAP,n.listChange,n);var o=new eui.Scroller;o.width=t,o.height=n._srollHeight,o.viewport=r;var a=new TextInput;n.addChild(a),a.borderColor=65280,a.width=t,a.y=10;var s=new eui.Button;return s.label="选择",n.addChild(s),s.x=a.width,s.y=5,s.width=60,s.height=40,o.y=s.y+s.height+10,n.list=r,n.ti=a,n.btn=s,n.scroller=o,s.addEventListener(egret.TouchEvent.TOUCH_TAP,n.btnClick,n),n}return __extends(t,e),Object.defineProperty(t.prototype,"editable",{get:function(){return this._editable},set:function(e){this._editable=e,e?this.ti.type=egret.TextFieldType.INPUT:this.ti.type=egret.TextFieldType.DYNAMIC},enumerable:!0,configurable:!0}),t.prototype.findUserByName=function(e,t){if(e&&this.arr)for(var i=this.arr,n=i.length,r=0;n>r;r++){var o=i[r];if(void 0!=o){var a=o.name+"";void 0!=a&&-1!=a.indexOf(e)&&t.pushOnce(o)}}},t.prototype.listChange=function(e){var t=this._selectedItem=this.list.selectedItem;this.setTIText(t),this.isShow=!1,this._scrollV=this.list.scrollV,remove(this.scroller),this.dispatch(-1)},Object.defineProperty(t.prototype,"selectedItem",{get:function(){return this._selectedItem},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectedIndex",{set:function(e){this.list.selectedIndex=e;var t=this._selectedItem=this.list.selectedItem;this.setTIText(t)},enumerable:!0,configurable:!0}),t.prototype.setTIText=function(e){e?this.ti.text=e.value+e.name:this.ti.text=""},t.prototype.tiClick=function(){this.isShow||(this.addChild(this.scroller),this.isShow=!0,this.dataProvider=this.arr,this.setScrollV(this._scrollV))},t.prototype.btnClick=function(e){var t=this.scroller;if(this.isShow)window.removeEventListener("wheel",this.onWheel),this._scrollV=this.list.scrollV,this.isShow=!1,remove(t);else{window.addEventListener("wheel",this.onWheel),stage.addChild(t),t.width=this.measuredWidth;var i=this.localToGlobal(this.x,this.y);t.x=i.x-100,t.y=i.y+50,this.isShow=!0,this.dataProvider=this.arr,e.stopImmediatePropagation(),this.setScrollV(this._scrollV),stage.on(egret.TouchEvent.TOUCH_TAP,this.stageClick,this)}},t.prototype.wheelHander=function(e){var t=e.deltaY;if(0!=t){var i=this._scrollV||0;0>t?i-=50:i+=50;var n=this._srollHeight,r=this.list.contentHeight-n;i>r?i=r:0>i&&(i=0),this._scrollV=i,this.setScrollV(i)}},t.prototype.setScrollV=function(e){var t=this.scroller.viewport;t.validateNow(),t.scrollV=e},t.prototype.stageClick=function(e){is(e.target,eui.Scroller)||(stage.off(egret.TouchEvent.TOUCH_TAP,this.stageClick,this),this.isShow=!1,remove(this.scroller))},Object.defineProperty(t.prototype,"dataProvider",{set:function(e){this.arr=e,this.list.dataProvider=new eui.ArrayCollection(e)},enumerable:!0,configurable:!0}),t}(eui.Component);__reflect(ComboBox.prototype,"ComboBox");var Combo_Count=function(){function e(){}return e}();Combo_Count.type13=[{name:"不可繁殖",value:0},{name:"可繁殖",value:1}],Combo_Count.type14=[{name:"女性",value:0},{name:"男性",value:1}],Combo_Count.type15=[{name:"人类",value:0},{name:"异形",value:2}],Combo_Count.GeneTypes=[{id:1,name:"轮廓",len:20,d0len:5,r1len:5,r2len:5,r3len:5,cids:[1,27,39,41,35,37,19,12],img:"1_png"},{id:2,name:"轮廓颜色",len:20,d0len:5,r1len:5,r2len:5,r3len:5,cids:[2,28,40,42,20,36,38,13],iscolor:1,img:"2_png"},{id:3,name:"特征",len:20,d0len:5,r1len:5,r2len:5,r3len:5,cids:[21,33,31,23,25,29,16,18,17],img:"3_png"},{id:4,name:"特征颜色",len:20,d0len:5,r1len:5,r2len:5,r3len:5,cids:[30,22,24,32,34,26],iscolor:1,img:"4_png"},{id:5,name:"头发",len:20,d0len:5,r1len:5,r2len:5,r3len:5,cids:[3,5],img:"5_png"},{id:6,name:"头发颜色",len:20,d0len:5,r1len:5,r2len:5,r3len:5,cids:[4,6],iscolor:1,img:"6_png"},{id:7,name:"眼睛",len:20,d0len:5,r1len:5,r2len:5,r3len:5,cids:[7],img:"7_png"},{id:8,name:"眼睛颜色",len:20,d0len:5,r1len:5,r2len:5,r3len:5,cids:[8],iscolor:1,img:"8_png"},{id:9,name:"表情",len:20,d0len:5,r1len:5,r2len:5,r3len:5,cids:[10,14,9,15,11],img:"9_png"},{id:10,name:"背景",len:20,d0len:5,r1len:5,r2len:5,r3len:5,cids:[],img:"10_png"},{id:11,name:"秘密",len:20,d0len:5,r1len:5,r2len:5,r3len:5,cids:[],img:"11_png",num:0},{id:12,name:"限时属性",len:20,d0len:5,r1len:5,r2len:5,r3len:5,cids:[],img:"12_png",num:0},{id:13,name:"繁殖能力",len:1,d0len:1,cids:[43],img:"13_png"},{id:14,name:"性别",len:1,d0len:1,cids:[46],img:"14_png"},{id:15,name:"种族",len:2,d0len:2,cids:[45],img:"15_png",num:2}],Combo_Count.Genes=[{name:"头",id:1,z:20,en:"face",len:2,cid:2},{name:"头肤色",id:2,len:6,en:"face"},{name:"头发",id:3,z:40,en:"hair",len:6,cid:4},{name:"头发颜色",id:4,len:6,en:"hair"},{name:"眉毛",id:5,z:26,en:"eyebrow",len:6,cid:6},{name:"眉毛颜色",id:6,len:6,en:"eyebrow"},{name:"眼睛",id:7,z:25,en:"eye",len:6,cid:8},{name:"眼睛颜色",id:8,len:6,en:"eye"},{name:"鼻子",id:9,z:27,en:"nose",len:5},{name:"嘴巴",id:10,z:28,en:"mouth",len:6,cid:11},{name:"嘴巴颜色",id:11,len:6,en:"mouth"},{name:"耳朵",id:12,z:22,en:"ears",len:5,cid:13},{name:"耳朵颜色",id:13,len:6,en:"ears"},{name:"胡子",id:14,z:32,en:"beard",len:6,cid:15},{name:"胡子颜色",id:15,len:4,en:"beard"},{name:"痣",id:16,z:29,en:"mole",len:4},{name:"雀斑",id:17,z:31,en:"freckle",len:4},{name:"红晕",id:18,z:30,en:"blush",len:4},{name:"尖角",id:19,z:41,en:"horn",len:5,cid:20},{name:"尖角颜色",id:20,len:5,en:"horn"},{name:"纹身脸",id:21,z:23,en:"tattooface",len:7,cid:22},{name:"纹身脸颜色",id:22,len:6,en:"tattooface"},{name:"伤疤",id:23,z:24,en:"scarface",len:6,cid:24},{name:"伤疤颜色",id:24,len:6,en:"scarface"},{name:"特征毛发脸",id:25,z:21,en:"facehair",len:5,cid:26},{name:"特征毛发颜色",id:26,len:6,en:"facehair"},{name:"身体",id:27,z:3,en:"body",len:2,cid:28},{name:"身体肤色",id:28,len:6,en:"body"},{name:"特征毛发身体",id:29,z:4,en:"bodyhair",len:5,cid:30},{name:"特征毛发颜色",id:30,len:6,en:"bodyhair"},{name:"伤疤",id:31,z:6,en:"scarbody",len:6,cid:32},{name:"伤疤颜色",id:32,len:6,en:"scarbody"},{name:"纹身身体",id:33,z:5,en:"tattoobody",len:7,cid:34},{name:"纹身身体颜色",id:34,len:6,en:"tattoobody"},{name:"尾巴",id:35,z:2,en:"tail",len:6,cid:36},{name:"尾巴颜色",id:36,len:6,en:"tail"},{name:"翅膀",id:37,z:1,en:"wing",len:6,cid:38},{name:"翅膀颜色",id:38,len:5,en:"wing"},{name:"内衣上",id:39,z:7,en:"bra",len:5,cid:40},{name:"内衣上颜色",id:40,len:7,en:"bra"},{name:"内衣下",id:41,z:8,en:"briefs",len:5,cid:42},{name:"内衣下颜色",id:42,len:7,en:"briefs"},{name:"繁殖能力",id:43,len:1},{name:"保留和扩展",id:44,len:1},{name:"种族",id:45,len:2},{name:"性别",id:46,len:1},{name:"背景",id:47,z:0,en:"bg",len:5}],Combo_Count.colorAttrObj={cl:"fill",sd:"fill",hl:"fill",li:"stroke"},__reflect(Combo_Count.prototype,"Combo_Count"),Object.defineProperties(Object.prototype,{clone:{value:function(){var e={};for(var t in this)e[t]=this[t];return e},writable:!0},getPropertyDescriptor:{value:function(e){var t=Object.getOwnPropertyDescriptor(this,e);if(t)return t;var i=Object.getPrototypeOf(this);return i?i.getPropertyDescriptor(e):void 0},writable:!0},copyto:{value:function(e){for(var t in this)if(t in e){var i=e.getPropertyDescriptor(t);i&&i.set&&(e[t]=this[t])}else e[t]=this[t]},writable:!0}}),Object.defineProperties(Function.prototype,{isSubClass:{value:function(e){if("function"!=typeof e)return!1;for(var t=this.prototype,i=!1;null!==t&&t!==Object;){if(t===e){i=!0;break}t=t.prototype}return!0},writable:!0}}),Math.DEG_TO_RAD=Math.PI/180,Math.RAD_TO_DEG=180/Math.PI,Math.PI2=2*Math.PI,Math.PI_1_2=.5*Math.PI,Math.clamp=function(e,t,i){return t>e&&(e=t),e>i&&(e=i),e},Math.random2=function(e,t){return e+Math.random()*(t-e)},Number.isSafeInteger||(Number.isSafeInteger=function(e){return 9007199254740991>e&&e>=-9007199254740991}),Object.defineProperties(Number.prototype,{zeroize:{value:function(e){return zeroize(this,e)},writable:!0}}),Object.defineProperties(String.prototype,{zeroize:{value:function(e){return zeroize(this,e)},writable:!0},substitute:{value:function(){var e=arguments.length;if(e>0){var t;if(1==e?(t=arguments[0],"object"!=typeof t&&(t=arguments)):t=arguments,t instanceof Object&&!(t instanceof RegExp))return this.replace(/\{(?:%([^{}]+)%)?([^{}]+)\}/g,function(e,i,n){var r=t[n];if(i){var o=String.subHandler[i];o&&(r=o(r))}return void 0!==r?""+r:e})}return this},writable:!0},hash:{value:function(){for(var e=this.length,t=5381,i=0;e>i;i++)t+=(t<<5)+this.charCodeAt(i);return 2147483647&t},writable:!0},trueLength:{value:function(){var e=this.match(/[\u2E80-\u9FBF]/gi);return this.length+(e?e.length:0)},writable:!0}}),String.zeroize=zeroize,Object.defineProperties(Date.prototype,{format:{value:function(e,t){function i(){return t?l.getDate():l.getUTCDate()}function n(){return t?l.getMonth():l.getUTCMonth()}function r(){return t?l.getFullYear():l.getUTCFullYear()}function o(){return t?l.getHours():l.getUTCHours()}function a(){return t?l.getMinutes():l.getUTCMinutes()}function s(){return t?l.getSeconds():l.getUTCSeconds()}var l=this;return e.replace(/"[^"]*"|'[^']*'|(?:d{1,2}|m{1,2}|yy(?:yy)?|([hHMs])\1?)/g,function(e){switch(e){case"d":return i();case"dd":return zeroize(i());case"M":return n()+1;case"MM":return zeroize(n()+1);case"yy":return(r()+"").substr(2);case"yyyy":return r();case"h":return o()%12||12;case"hh":return zeroize(o()%12||12);case"H":return o();case"HH":return zeroize(o());case"m":return a();case"mm":return zeroize(a());case"s":return s();case"ss":return zeroize(s());default:return e.substr(1,e.length-2)}})},writable:!0}});var DefaultForSort={number:0,string:"","boolean":!1};if(Object.defineProperties(Array.prototype,{cloneTo:{value:function(e){e.length=this.length;var t=this.length;e.length=t;for(var i=0;t>i;i++)e[i]=this[i]},writable:!0},appendTo:{value:function(e){for(var t=this.length,i=0;t>i;i++)e.push(this[i])},writable:!0},pushOnce:{value:function(e){~this.indexOf(e)||this.push(e)},writable:!0},remove:{value:function(e){var t=this.indexOf(e);return~t?(this.splice(t,1),!0):!1},writable:!0},doSort:{value:function(){for(var e,t,i=0,n=arguments.length;n>i;i++){var r=arguments[i],o=typeof r;"boolean"===o?t=r:"string"===o&&(e=r)}return e?this.sort(function(i,n){return t?n[e]-i[e]:i[e]-n[e]}):this.sort(function(e,i){return t?i-e:e-i})},writable:!0},multiSort:{value:function(e,t){var i=Array.isArray(t);return this.sort(function(n,r){for(var o=0,a=e.length;a>o;o++){var s=e[o],l=i?!!t[o]:!!t,d=n[s],h=r[s],c=typeof d,u=typeof h;if("object"==c||"object"==u)return 0;if(c!=u)if("undefined"==c)h=DefaultForSort[u];else{if("undefined"!=u)return 0;d=DefaultForSort[c]}if(h>d)return l?1:-1;if(d>h)return l?-1:1}return 0})},writable:!0}}),"undefined"==typeof window.Map||!window.Map){var PolyfillMap=function(){function e(){this._keys=[],this._values=[],this._size=0}return e.prototype.set=function(e,t){var i=this._keys,n=i.indexOf(e);if(~n)this._values[n]=t;else{var r=this._size;i[r]=e,this._values[r]=t,this._size++}return this},e.prototype.get=function(e){var t=this._keys.indexOf(e);return~t?this._values[t]:void 0},e.prototype.has=function(e){return!~this._keys.indexOf(e)},e.prototype["delete"]=function(e){var t=this._keys,i=t.indexOf(e);return~i?(t.splice(i,1),this._values.splice(i,1),this._size--,!0):!1},e.prototype.forEach=function(e,t){for(var i=this._keys,n=this._values,r=0,o=this._size;o>r;r++)e(n[r],i[r],t)},e.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._size=0},Object.defineProperty(e.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),e}();window.Map=PolyfillMap}var egret;!function(e){!function(){var t=new e.HtmlTextParser;e.TextField.prototype.setHtmlText=function(e){"number"==typeof e&&(e+=""),this.textFlow=e?t.parser(e):[]};var i=e.EventDispatcher.prototype;i.removeAllListeners=function(){var e=this.$EventDispatcher;e[1]={},e[2]={}},i.removeListeners=function(e,t){var i=this.$getEventMap(t),n=i[e];n&&(n.length=0)},i.on=i.addEventListener,i.off=i.removeEventListener,i.hasListen=i.hasEventListener,i.dispatch=i.dispatchEventWith}()}(egret||(egret={}));var Facade=function(e){function t(){var t=e.call(this)||this;return facade=t,t}return __extends(t,e),t}(egret.EventDispatcher);__reflect(Facade.prototype,"Facade");var facade,stage,ColorPanel=function(e){function t(){var t=e.call(this)||this;return t.ATTR_ARR=["hl1","cl1","cl2","sd1","sd2","li1"],t.initComponent(),t.on(egret.Event.ADDED_TO_STAGE,t.addToStage,t),t}return __extends(t,e),t.prototype.onCloseButtonClick=function(t){e.prototype.close.call(this);var i=document.getElementById("colorDiv");i.innerHTML=""},t.prototype.addToStage=function(){this.width=stage.width,this.height=stage.height,this.closeButton&&(this.closeButton.y=stage.height-50),this.x=stage.width-this.width>>1,this.y=stage.height-this.height>>1},t.prototype.initComponent=function(){var e=this.list=new eui.List;e.itemRenderer=ColorsListItemRenderer,this.addChild(e);var t=this._tLayout=new eui.TileLayout;e.layout=t,t.verticalGap=10,t.paddingTop=50;var i=new eui.Scroller;i.width=stage.width,i.viewport=e,this.addChild(i),i.height=stage.height-100;var n=new eui.Button;n.label="预览",n.horizontalCenter=-200,n.y=stage.height-150,this.addChild(n),n.on(egret.TouchEvent.TOUCH_TAP,this.prep,this);var r=new eui.Button;r.label="保存",r.horizontalCenter=200,r.y=n.y,this.addChild(r),r.on(egret.TouchEvent.TOUCH_TAP,this.save,this)},t.prototype.prep=function(){for(var e=this.ATTR_ARR,t=Combo_Count.colorAttrObj,i=this.list,n=0;n<i.numChildren;n++){for(var r=i.getChildAt(n),o=r.typeLb.text,a={},s=0;s<e.length;s++){var l=e[s];a[l]=r[l].text}for(var l in a){var d=document.getElementById(o+"_"+l);if(d){var h=l.substr(0,2);d.setAttribute(t[h],a[l])}}}},t.prototype.save=function(){for(var e=this.ATTR_ARR,t=this.list,i={cmd:0,type:this.bigType,rs:this.rs,value:this.value},n={},r=0;r<t.numChildren;r++){var o=t.getChildAt(r),a=+o.typeLb.text;if(a){for(var s={},l=0;l<e.length;l++){var d=e[l],h=o[d].text;h&&""!=h&&(s[d]=h)}n[a]=s}}i.colorObj=n;var c=JSON.stringify(i),u=new XMLHttpRequest;u.open("POST",this.ip,!0),u.onreadystatechange=function(){4==u.readyState&&200==u.status&&(dispatch(-5),alert("颜色修改成功"))},u.send(c)},t}(eui.Panel);__reflect(ColorPanel.prototype,"ColorPanel");var GenesListItemRenderer1=function(e){function t(){var t,i=e.call(this)||this;i.bm=t=new egret.Bitmap,i.addChild(t);var n;i.nameLb=n=new eui.Label,i.addChild(n),n.size=22,n.y=40,n.textColor=0;var r=i.list=new eui.List;r.itemRenderer=GeneValueListItemRenderer,i.addChild(r);var o=new eui.VerticalLayout;r.layout=o,o.gap=28,o.paddingTop=70,r.on(eui.ItemTapEvent.ITEM_TAP,i.itemTap,i);var a;i.checkBox=a=new eui.CheckBox,i.addChild(a),a.x=42;var s=new eui.Button;return i.colorBtn=s=new eui.Button,i.addChild(s),s.label="C",s.width=25,s.height=30,s.x=66,s.on(egret.TouchEvent.TOUCH_TAP,i.color,i),i}return __extends(t,e),t.prototype.dataChanged=function(){var e=this.data,t=e.img;t&&(this.bm.bitmapData=RES.getRes(t),this.bm.width=40,this.bm.height=40),this.nameLb.text=e.name;var i=e.num;void 0!=i?this.num=i:this.num=Math.pow(2,e.d0len);var n=e.value;this.list.selectedIndex=void 0!=n?n:0,e.iscolor?this.colorBtn.visible=!0:this.colorBtn.visible=!1,this.num?this.enabled=!0:this.enabled=!1},t.prototype.itemTap=function(){dispatch(-1,this.itemIndex)},t.prototype.lock=function(){this.list.touchEnabled=!this.checkBox.selected},t.prototype.color=function(){dispatch(-3)},t}(eui.ItemRenderer);__reflect(GenesListItemRenderer1.prototype,"GenesListItemRenderer1");var GeneValueListItemRenderer=function(e){function t(){var t,i=e.call(this)||this;return i.nameLb=t=new eui.Label,i.addChild(t),t.size=16,t.textColor=0,i.width=90,i}return __extends(t,e),t.prototype.dataChanged=function(){var e=this.data;e&&(this.nameLb.text=e.value+e.name)},t}(eui.ItemRenderer);__reflect(GeneValueListItemRenderer.prototype,"GeneValueListItemRenderer");var LoadingUI=function(e){function t(){var t=e.call(this)||this;return t.createView(),t}return __extends(t,e),t.prototype.createView=function(){this.textField=new egret.TextField,this.addChild(this.textField),this.textField.y=300,this.textField.width=480,this.textField.height=100,this.textField.textAlign="center"},t.prototype.setProgress=function(e,t){this.textField.text="Loading..."+e+"/"+t},t}(egret.Sprite);__reflect(LoadingUI.prototype,"LoadingUI");var Main=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.isThemeLoadEnd=!1,t.isResourceLoadEnd=!1,t.startPos=0,t.isLock=!1,t._rs="00",t._currentIdx=0,t}return __extends(t,e),t.prototype.createChildren=function(){e.prototype.createChildren.call(this),egret.ImageLoader.crossOrigin="anonymous";var t=new AssetAdapter;egret.registerImplementation("eui.IAssetAdapter",t),egret.registerImplementation("eui.IThemeAdapter",new ThemeAdapter),this.loadingView=new LoadingUI,this.stage.addChild(this.loadingView),RES.addEventListener(RES.ResourceEvent.CONFIG_COMPLETE,this.onConfigComplete,this),RES.loadConfig("resource/default.res.json","resource/")},t.prototype.onConfigComplete=function(e){RES.removeEventListener(RES.ResourceEvent.CONFIG_COMPLETE,this.onConfigComplete,this);var t=new eui.Theme("resource/default.thm.json",this.stage);t.addEventListener(eui.UIEvent.COMPLETE,this.onThemeLoadComplete,this),RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE,this.onResourceLoadComplete,this),RES.addEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR,this.onResourceLoadError,this),RES.addEventListener(RES.ResourceEvent.GROUP_PROGRESS,this.onResourceProgress,this),RES.addEventListener(RES.ResourceEvent.ITEM_LOAD_ERROR,this.onItemLoadError,this),RES.loadGroup("preload")},t.prototype.onThemeLoadComplete=function(){this.isThemeLoadEnd=!0,this.createScene()},t.prototype.onResourceLoadComplete=function(e){"preload"==e.groupName&&(this.stage.removeChild(this.loadingView),RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE,this.onResourceLoadComplete,this),RES.removeEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR,this.onResourceLoadError,this),RES.removeEventListener(RES.ResourceEvent.GROUP_PROGRESS,this.onResourceProgress,this),RES.removeEventListener(RES.ResourceEvent.ITEM_LOAD_ERROR,this.onItemLoadError,this),this.isResourceLoadEnd=!0,this.createScene())},t.prototype.createScene=function(){this.isThemeLoadEnd&&this.isResourceLoadEnd&&this.startCreateScene()},t.prototype.onItemLoadError=function(e){console.warn("Url:"+e.resItem.url+" has failed to load")},t.prototype.onResourceLoadError=function(e){console.warn("Group:"+e.groupName+" has failed to load"),this.onResourceLoadComplete(e)},t.prototype.onResourceProgress=function(e){"preload"==e.groupName&&this.loadingView.setProgress(e.itemsLoaded,e.itemsTotal)},t.prototype.startCreateScene=function(){var e=egret.baseParams;if(e&&(this._ip=e.ip,this._port=e.port),this._sip="http://"+this._ip+"/",this._port){var t=this._sip;this._sip=t.substr(0,t.length-1)+":"+this._port+"/"}stage=this.stage;var i=new egret.Shape;i.graphics.beginFill(16777215,.9),i.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight),i.graphics.endFill(),this.addChild(i);var n=this.list=new eui.List;n.itemRenderer=GenesListItemRenderer1,this.addChild(n);var r=new eui.TileLayout;n.layout=r,r.horizontalGap=2;var o=new eui.Scroller;o.width=stage.width,o.viewport=n,this.addChild(o),o.height=stage.height;for(var a=Combo_Count.GeneTypes,s=this.gArr=[],l=0,d=a;l<d.length;l++){var h=d[l],c={};h.copyto(c),s.push(c)}n.dataProvider=new eui.ArrayCollection(s),n.validateNow();var u=new eui.Button;u.label="生成",u.x=stage.width-110,u.y=stage.height-60,this.addChild(u),u.on(egret.TouchEvent.TOUCH_TAP,this.create,this);var p=new eui.Button;p.label="导入",p.x=u.x,p.y=u.y-50,this.addChild(p),p.on(egret.TouchEvent.TOUCH_TAP,this["import"],this);var g=new eui.Button;g.label="全锁",g.x=u.x,g.y=p.y-50,this.addChild(g),g.on(egret.TouchEvent.TOUCH_TAP,this.lock,this);var v=new eui.Button;v.label="随机",v.x=u.x,v.y=g.y-50,this.addChild(v),v.on(egret.TouchEvent.TOUCH_TAP,this.random,this),new Facade,on(-1,this.geneChange,this),on(-3,this.color,this),on(-5,this.save,this),stage.on(egret.TouchEvent.TOUCH_TAP,this.stageClick,this);var m=document.getElementById("fileSelector");m.addEventListener("change",this.fileHandler.bind(this),!1),this.updateAngelImage(),this.getGeneNameCfg()},t.prototype.stageClick=function(e){console.log("")},t.prototype.getIP=function(){return this._sip},t.prototype.getExt=function(e){return e.substr(e.lastIndexOf(".")).toLowerCase()},t.prototype.create=function(){var e=this.getUrl(),t=new XMLHttpRequest;t.open("GET",e,!0),t.onreadystatechange=this.xhrHandler.bind(this),t.send()},t.prototype.xhrHandler=function(e){var t=e.target;if(4==t.readyState&&200==t.status){this.writeFile(t.responseText);var i={genes:this.ids};this.gArr.unshift(i);var n=JSON.stringify(this.gArr);this.writeFile(n,".json")}},t.prototype.writeFile=function(e,t){void 0===t&&(t=".svg");var i=new Blob([e],{type:"text/plain;charset=utf-8"});if(navigator.appVersion.toString().indexOf(".NET")>0)window.navigator.msSaveBlob(i,this.ids+t);else{var n=document.createElement("a");n.href=window.URL.createObjectURL(i),n.download=this.ids+t,n.click(),document.body.appendChild(n)}},t.prototype["import"]=function(){var e=document.getElementById("fileSelector");e.click()},t.prototype.fileHandler=function(){var e=this,t=document.getElementById("fileSelector").files[0];if(t){var i=this.getExt(t.name);if(".json"!=i)alert("导入文件格式不正确,请导入json文件");else{var n=new FileReader;n.onload=function(){var t=JSON.parse(n.result),i=t.shift().genes;e.ids=i;var r=document.getElementById("angelImage");r.src=e.getIP()+i+".svge",document.getElementById("colorDiv").innerHTML="",e.getList_RaceSex_IdxArr(e,t),e.getGeneNameCfg()},n.readAsText(t)}}},t.prototype.random=function(){var e=this.list,t=e.numChildren,i=0,n=0,r=this._idxArr;r||(r=this._idxArr=[]);for(var o=0;t>o;o++){var a=e.getChildAt(o),s=a.checkBox.selected;if(!s){var l=a.data,d=a.num-1;0>d&&(d=0);var h=Math.round(Math.random()*d);r[o]=h,15==l.id?i=Combo_Count.type15[h].value:14==l.id&&(n=h)}}this._idxArr=r;var c=i+""+n;c!=this._rs?(this._rs=c,this.getGeneNameCfg()):(this.setComboData(),this.updateAngelImage())},t.prototype.lock=function(e){var t=this.isLock=!this.isLock,i=e.target;i.label=t?"全解":"全锁";for(var n=this.list,r=n.numChildren,o=0;r>o;o++){var a=n.getChildAt(o);a.enabled&&(a.checkBox.selected=t)}},t.prototype.getGeneNameCfg=function(){var e=this,t=new XMLHttpRequest;t.open("GET",this.getIP()+"n"+this._rs+".svge",!0),t.onreadystatechange=function(){if(4==t.readyState&&200==t.status){var i=decodeURIComponent(t.responseText),n=JSON.parse(i),r={};for(var o in n){var a=n[o];void 0==r[o]&&(r[o]=[]);for(var s in a)a[s].value=s,r[o].push(a[s])}e._geneNameObj=r,e.setComboData(),e.updateAngelImage()}},t.send()},t.prototype.geneChange=function(e){var t=this._currentIdx=e.data,i=this.list,n=i.getChildAt(t).data.id;if(this.checkRaceSex(n)){this.getList_RaceSex_IdxArr(this);var r=i.getChildAt(t).list.selectedItem.value;this._idxArr[n-1]=r,15==n&&2==r&&(this._idxArr[n-1]=r-1),this.getGeneNameCfg()}else{for(var o=this.getKeyTypes(i),a=o.length,s="",l=0;a>l;l++){var d=o[l],r=d-1,h=i.getChildAt(r),c=h.list.selectedItem,u=c.value;s+=15==d||14==d?u+"-":d+"-"+u+"-"}if(""==s)return;s=s.substr(0,s.length-1),this.getSingleSVGByHttp(s),this.updateAngelImage()}},t.prototype.getKeyTypes=function(e){var t=this._currentIdx,i=e.getChildAt(t),n=i.data,r=n.id,o=[15,14,r];return n.iscolor&&(i=e.getChildAt(t-1),n=i.data,o.push(n.id)),o},t.prototype.color=function(e){void 0==this._colorPanel&&(this._colorPanel=new ColorPanel),this.addChild(this._colorPanel),this.getSVGByHttp(),this.getColorCfg()},t.prototype.getSingleSVGByHttp=function(e){var t=new XMLHttpRequest;t.open("GET",this.getIP()+e+".svge",!0),t.onreadystatechange=function(){4==t.readyState&&200==t.status&&(document.getElementById("colorDiv").innerHTML=t.responseText)},t.send()},t.prototype.getSVGByHttp=function(){var e=new XMLHttpRequest;e.open("GET",this.getUrl(),!0),e.onreadystatechange=function(){4==e.readyState&&200==e.status&&(document.getElementById("colorDiv").innerHTML=e.responseText)},e.send()},t.prototype.getColorCfg=function(){var e=this,t=new XMLHttpRequest;t.open("GET",this.getIP()+"c"+this.getColorIds()+".svge",!0),t.onreadystatechange=function(){if(4==t.readyState&&200==t.status){var i=[],n=t.responseText,r=JSON.parse(n);for(var o in r)i.push({type:o,attrObj:r[o]});e._colorPanel.list.dataProvider=new eui.ArrayCollection(i);var a=e.list.selectedItem.id;e._colorPanel.bigType=a,e._colorPanel.rs=e.getList_RaceSex_IdxArr(e);var s=e.list,l=s.selectedIndex;e._colorPanel.value=s.getChildAt(l).list.selectedItem.value,e._colorPanel.ip=e.getIP()}},t.send()},t.prototype.getList_RaceSex_IdxArr=function(e,t){for(var i=e.list,n=0,r=0,o=[],a=i.numChildren,s=0;a>s;s++){var l=i.getChildAt(s),d=t?t[s]:l.data,h=l.list,c=t?d.value:h.selectedItem?h.selectedItem.value:-1;o[s]=c,15==d.id?(n=c,2==n&&(o[s]=c-1)):14==d.id&&(r=c)}return e._idxArr=o,e._rs=""+n+r,e._rs},t.prototype.getColorIds=function(){var e=this.list,t=e.selectedIndex,i=e.getChildAt(t),n=i.data,r=n.id;if(this.checkZGeneType(r)){for(var o=[15,14,r],a=o.length,s="",l=0;a>l;l++){var d=o[l];i=e.getChildAt(d-1);var h=i.list.selectedItem.value;""==s?s=h+"":s+=this.checkZGeneType(d)?"-"+d+"-"+h:"-"+h}return s}},t.prototype.checkRaceSex=function(e){return 15==e||14==e?!0:!1},t.prototype.checkZGeneType=function(e){return 15==e||14==e||13==e?!1:!0},t.prototype.setComboData=function(){for(var e=this.list,t=e.numChildren,i=0;t>i;i++){var n=e.getChildAt(i),r=n.list,o=n.data.id;this.checkZGeneType(o)?r.dataProvider=new eui.ArrayCollection(this._geneNameObj[o]):r.dataProvider=new eui.ArrayCollection(Combo_Count["type"+o]),this._idxArr?r.selectedIndex=this._idxArr[i]:r.selectedIndex=0}},t.prototype.updateAngelImage=function(){var e=document.getElementById("angelImage");e.src=this.getUrl()},t.prototype.getUrl=function(){document.getElementById("angelImage");return this.getIP()+this.getIds()+".svge"},t.prototype.getIds=function(){for(var e=this.list,t=this.gArr,i=e.numChildren,n="",r=0;i>r;r++){var o=e.getChildAt(r),a=o.list.selectedItem,s=void 0;a&&(s=a.value),t[r].value=s;var l=o.data.len;n=zeroize(bigInt(s).toString(2),l)+n}var d=this.ids=bigInt(n,2).toString(10);return d},t.prototype.save=function(){this.updateAngelImage()},t}(eui.UILayer);__reflect(Main.prototype,"Main");var TextInput=function(e){function t(t){void 0===t&&(t=egret.TextFieldType.INPUT);var i=e.call(this)||this;return i.type=t,i.border=!0,i.width=280,i.size=24,i}return __extends(t,e),t}(egret.TextField);__reflect(TextInput.prototype,"TextInput");
var ThemeAdapter=function(){function e(){}return e.prototype.getTheme=function(e,t,i,n){function r(e){t.call(n,e)}function o(t){t.resItem.url==e&&(RES.removeEventListener(RES.ResourceEvent.ITEM_LOAD_ERROR,o,null),i.call(n))}RES.addEventListener(RES.ResourceEvent.ITEM_LOAD_ERROR,o,null),RES.getResByUrl(e,r,this,RES.ResourceItem.TYPE_TEXT)},e}();__reflect(ThemeAdapter.prototype,"ThemeAdapter",["eui.IThemeAdapter"]);