mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2025-07-13 15:52:44 +08:00
2 lines
2.7 KiB
JavaScript
2 lines
2.7 KiB
JavaScript
var u=s=>{throw TypeError(s)};var p=(s,l,e)=>l.has(s)||u("Cannot "+e);var i=(s,l,e)=>(p(s,l,"read from private field"),e?e.call(s):l.get(s)),f=(s,l,e)=>l.has(s)?u("Cannot add the same private member more than once"):l instanceof WeakSet?l.add(s):l.set(s,e);var t;class N extends ui.view.CyberTheme.CyberTalentUI{constructor(){super();f(this,t,new Set);this.btnDrawCard.on(Laya.Event.CLICK,this,this.onClickDrawCard),this.btnNext.on(Laya.Event.CLICK,this,this.onClickNext),this.listTalents.renderHandler=Laya.Handler.create(this,this.renderTalent,null,!1),this.listTalents.scrollBar.elasticDistance=150,this.on(Laya.Event.RESIZE,this,()=>{var a,c,h;const e=(h=(c=(a=this.listTalents)==null?void 0:a._itemRender)==null?void 0:c.props)==null?void 0:h.width;if(e){const n=Math.max(Math.floor((this.width-40)/e),1);this.listTalents.width=n*e+(n-1)*(this.listTalents.spaceY||0)}})}static load(){return["images/background/background_2@3x.png"]}init(){this.pageDrawCard.visible=!0,this.pageResult.visible=!1,this.btnNext.label="UI_Talent_Select_Uncomplete",i(this,t).clear()}close(){}onClickDrawCard(){this.pageDrawCard.visible=!1,this.pageResult.visible=!0,this.listTalents.array=core.talentRandom()}onClickNext(){if(i(this,t).size<core.talentSelectLimit)return $$event("message",["F_TalentSelectNotComplect",core.talentSelectLimit]);const e=[...i(this,t)].map(a=>this.listTalents.array[a]);$ui.switchView(UI.pages.PROPERTY,{talents:e,enableExtend:!0})}renderTalent(e,a){const c=e.dataSource,h=e.getChildByName("hboxTitle"),n=h.getChildByName("labTitle"),r=h.getChildByName("grades"),d=r.getChildByName("grade1"),o=r.getChildByName("grade2"),b=r.getChildByName("grade3"),T=e.getChildByName("labDescription"),C=e.getChildByName("unselected"),g=e.getChildByName("selected");switch(c.grade){case 1:r.x=0,n.x=1,d.visible=!0,o.visible=!1,b.visible=!1;break;case 2:r.x=0,n.x=1,d.visible=!1,o.visible=!0,b.visible=!1;break;case 3:r.x=0,n.x=1,d.visible=!1,o.visible=!1,b.visible=!0;break;default:r.x=1,n.x=0,d.visible=!1,o.visible=!1,b.visible=!1;break}n.text=c.name,n.event(Laya.Event.RESIZE),T.text=c.description,C.visible=!(g.visible=i(this,t).has(a)),e.offAll(Laya.Event.CLICK),e.on(Laya.Event.CLICK,this,()=>{if(i(this,t).has(a))i(this,t).delete(a);else{if(i(this,t).size>=core.talentSelectLimit)return $$event("message",["F_TalentSelectLimit",core.talentSelectLimit]);const m=core.exclude([...i(this,t)].map(v=>this.listTalents.array[v].id),this.listTalents.array[a].id);if(m!=null){for(const{name:v,id:y}of this.listTalents.array)if(m==y)return $$event("message",["F_TalentConflict",v]);return}i(this,t).add(a)}this.btnNext.label=i(this,t).size===core.talentSelectLimit?"UI_Next":"UI_Talent_Select_Uncomplete",C.visible=!(g.visible=i(this,t).has(a))})}}t=new WeakMap;export{N as default};
|