fairygui.js 457 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181
  1. (function(window,document,Laya){
  2. var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec;
  3. var Browser=laya.utils.Browser,Byte=laya.utils.Byte,ColorFilter=laya.filters.ColorFilter,Event=laya.events.Event;
  4. var EventDispatcher=laya.events.EventDispatcher,Graphics=laya.display.Graphics,HTMLDivElement=laya.html.dom.HTMLDivElement;
  5. var Handler=laya.utils.Handler,HitArea=laya.utils.HitArea,Input=laya.display.Input,Loader=laya.net.Loader;
  6. var Log=laya.utils.Log,Node=laya.display.Node,Point=laya.maths.Point,Rectangle=laya.maths.Rectangle,Render=laya.renders.Render;
  7. var SoundManager=laya.media.SoundManager,Sprite=laya.display.Sprite,Stage=laya.display.Stage,Text=laya.display.Text;
  8. var Texture=laya.resource.Texture,Utils=laya.utils.Utils,WeakObject=laya.utils.WeakObject;
  9. Laya.interface('fairygui.IUISource');
  10. Laya.interface('fairygui.gears.IColorGear');
  11. Laya.interface('fairygui.gears.IAnimationGear');
  12. //class fairygui.action.ControllerAction
  13. var ControllerAction=(function(){
  14. function ControllerAction(){
  15. this.fromPage=null;
  16. this.toPage=null;
  17. }
  18. __class(ControllerAction,'fairygui.action.ControllerAction');
  19. var __proto=ControllerAction.prototype;
  20. __proto.run=function(controller,prevPage,curPage){
  21. if((this.fromPage==null || this.fromPage.length==0 || this.fromPage.indexOf(prevPage)!=-1)
  22. && (this.toPage==null || this.toPage.length==0 || this.toPage.indexOf(curPage)!=-1))
  23. this.enter(controller);
  24. else
  25. this.leave(controller);
  26. }
  27. __proto.enter=function(controller){}
  28. __proto.leave=function(controller){}
  29. __proto.setup=function(buffer){
  30. var cnt=0;
  31. var i=0;
  32. cnt=buffer.getInt16();
  33. this.fromPage=[];
  34. for (i=0;i < cnt;i++)
  35. this.fromPage[i]=buffer.readS();
  36. cnt=buffer.getInt16();
  37. this.toPage=[];
  38. for (i=0;i < cnt;i++)
  39. this.toPage[i]=buffer.readS();
  40. }
  41. ControllerAction.createAction=function(type){
  42. switch(type){
  43. case 0:
  44. return new PlayTransitionAction();
  45. case 1:
  46. return new ChangePageAction();
  47. }
  48. return null;
  49. }
  50. return ControllerAction;
  51. })()
  52. //class fairygui.AssetProxy
  53. var AssetProxy=(function(){
  54. function AssetProxy(){
  55. this._asset=null;
  56. this._asset=Laya.loader;
  57. }
  58. __class(AssetProxy,'fairygui.AssetProxy');
  59. var __proto=AssetProxy.prototype;
  60. __proto.getRes=function(url){
  61. if(url.indexOf("wxlocal")==-1){
  62. return this._asset.getRes(url+UIConfig$1.versions);
  63. }
  64. return this._asset.getRes(url);
  65. }
  66. __proto.load=function(url,complete,progress,type,priority,cache){
  67. (priority===void 0)&& (priority=1);
  68. (cache===void 0)&& (cache=true);
  69. this._asset.load(url,complete,progress,type,priority,cache);
  70. }
  71. __proto.setAsset=function(asset){
  72. this._asset=asset;
  73. }
  74. __getset(1,AssetProxy,'inst',function(){
  75. if(fairygui.AssetProxy._inst==null)
  76. AssetProxy._inst=new AssetProxy();
  77. return fairygui.AssetProxy._inst;
  78. });
  79. AssetProxy._inst=null;
  80. return AssetProxy;
  81. })()
  82. //class fairygui.AsyncOperation
  83. var AsyncOperation=(function(){
  84. var DisplayListItem;
  85. function AsyncOperation(){
  86. /**
  87. *callback(obj:GObject)
  88. */
  89. this.callback=null;
  90. this._itemList=null;
  91. this._objectPool=null;
  92. this._index=0;
  93. this._itemList=[];
  94. this._objectPool=[];
  95. }
  96. __class(AsyncOperation,'fairygui.AsyncOperation');
  97. var __proto=AsyncOperation.prototype;
  98. __proto.createObject=function(pkgName,resName){
  99. var pkg=UIPackage.getByName(pkgName);
  100. if(pkg){
  101. var pi=pkg.getItemByName(resName);
  102. if(!pi)
  103. throw new Error("resource not found: "+resName);
  104. this.internalCreateObject(pi);
  105. }
  106. else
  107. throw new Error("package not found: "+pkgName);
  108. }
  109. __proto.createObjectFromURL=function(url){
  110. var pi=UIPackage.getItemByURL(url);
  111. if(pi)
  112. this.internalCreateObject(pi);
  113. else
  114. throw new Error("resource not found: "+url);
  115. }
  116. __proto.cancel=function(){
  117. Laya.timer.clear(this,this.run);
  118. this._itemList.length=0;
  119. if(this._objectPool.length>0){
  120. var cnt=this._objectPool.length;
  121. for(var i=0;i<cnt;i++){
  122. this._objectPool[i].dispose();
  123. }
  124. this._objectPool.length=0;
  125. }
  126. }
  127. __proto.internalCreateObject=function(item){
  128. this._itemList.length=0;
  129. this._objectPool.length=0;
  130. var di=new DisplayListItem(item,9);
  131. di.childCount=this.collectComponentChildren(item);
  132. this._itemList.push(di);
  133. this._index=0;
  134. Laya.timer.frameLoop(1,this,this.run);
  135. }
  136. __proto.collectComponentChildren=function(item){
  137. var buffer=item.rawData;
  138. buffer.seek(0,2);
  139. var di;
  140. var pi;
  141. var i=0;
  142. var dataLen=0;
  143. var curPos=0;
  144. var pkg;
  145. var dcnt=buffer.getInt16();
  146. for (i=0;i < dcnt;i++){
  147. dataLen=buffer.getInt16();
  148. curPos=buffer.pos;
  149. buffer.seek(curPos,0);
  150. var type=buffer.readByte();
  151. var src=buffer.readS();
  152. var pkgId=buffer.readS();
  153. buffer.pos=curPos;
  154. if (src !=null){
  155. if (pkgId !=null)
  156. pkg=UIPackage.getById(pkgId);
  157. else
  158. pkg=item.owner;
  159. pi=pkg !=null ? pkg.getItemById(src):null;
  160. di=new DisplayListItem(pi,type);
  161. if (pi !=null && pi.type==3)
  162. di.childCount=this.collectComponentChildren(pi);
  163. }
  164. else{
  165. di=new DisplayListItem(null,type);
  166. if (type==10)
  167. di.listItemCount=this.collectListChildren(buffer);
  168. }
  169. this._itemList.push(di);
  170. buffer.pos=curPos+dataLen;
  171. }
  172. return dcnt;
  173. }
  174. __proto.collectListChildren=function(buffer){
  175. buffer.seek(buffer.pos,8);
  176. var listItemCount=0;
  177. var i=0;
  178. var nextPos=0;
  179. var url;
  180. var pi;
  181. var di;
  182. var defaultItem=buffer.readS();
  183. var itemCount=buffer.getInt16();
  184. for (i=0;i < itemCount;i++){
  185. nextPos=buffer.getInt16();
  186. nextPos+=buffer.pos;
  187. url=buffer.readS();
  188. if (url==null)
  189. url=defaultItem;
  190. if (url){
  191. pi=UIPackage.getItemByURL(url);
  192. if (pi !=null){
  193. di=new DisplayListItem(pi,pi.objectType);
  194. if (pi.type==3)
  195. di.childCount=this.collectComponentChildren(pi);
  196. this._itemList.push(di);
  197. listItemCount++;
  198. }
  199. }
  200. buffer.pos=nextPos;
  201. }
  202. return listItemCount;
  203. }
  204. __proto.run=function(){
  205. var obj;
  206. var di;
  207. var poolStart=0;
  208. var k=0;
  209. var t=Browser.now();
  210. var frameTime=UIConfig$1.frameTimeForAsyncUIConstruction;
  211. var totalItems=this._itemList.length;
  212. while(this._index<totalItems){
  213. di=this._itemList[this._index];
  214. if (di.packageItem !=null){
  215. obj=UIObjectFactory.newObject(di.packageItem);
  216. obj.packageItem=di.packageItem;
  217. this._objectPool.push(obj);
  218. UIPackage._constructing++;
  219. if (di.packageItem.type==3){
  220. poolStart=this._objectPool.length-di.childCount-1;
  221. (obj).constructFromResource2(this._objectPool,poolStart);
  222. this._objectPool.splice(poolStart,di.childCount);
  223. }
  224. else{
  225. obj.constructFromResource();
  226. }
  227. UIPackage._constructing--;
  228. }
  229. else{
  230. obj=UIObjectFactory.newObject2(di.type);
  231. this._objectPool.push(obj);
  232. if (di.type==10 && di.listItemCount > 0){
  233. poolStart=this._objectPool.length-di.listItemCount-1;
  234. for (k=0;k < di.listItemCount;k++)
  235. (obj).itemPool.returnObject(this._objectPool[k+poolStart]);
  236. this._objectPool.splice(poolStart,di.listItemCount);
  237. }
  238. }
  239. this._index++;
  240. if ((this._index % 5==0)&& Browser.now()-t >=frameTime)
  241. return;
  242. }
  243. Laya.timer.clear(this,this.run);
  244. var result=this._objectPool[0];
  245. this._itemList.length=0;
  246. this._objectPool.length=0;
  247. if(this.callback!=null)
  248. this.callback.runWith(result);
  249. }
  250. AsyncOperation.__init$=function(){
  251. //class DisplayListItem
  252. DisplayListItem=(function(){
  253. function DisplayListItem(packageItem,type){
  254. this.packageItem=null;
  255. this.type=0;
  256. this.childCount=0;
  257. this.listItemCount=0;
  258. this.packageItem=packageItem;
  259. this.type=type;
  260. }
  261. __class(DisplayListItem,'');
  262. return DisplayListItem;
  263. })()
  264. }
  265. return AsyncOperation;
  266. })()
  267. /**
  268. *Use for GTextField.autoSize
  269. */
  270. //class fairygui.AutoSizeType
  271. var AutoSizeType=(function(){
  272. function AutoSizeType(){}
  273. __class(AutoSizeType,'fairygui.AutoSizeType');
  274. AutoSizeType.None=0;
  275. AutoSizeType.Both=1;
  276. AutoSizeType.Height=2;
  277. AutoSizeType.Shrink=3;
  278. return AutoSizeType;
  279. })()
  280. /**
  281. *Use for GButton.mode
  282. */
  283. //class fairygui.ButtonMode
  284. var ButtonMode=(function(){
  285. function ButtonMode(){}
  286. __class(ButtonMode,'fairygui.ButtonMode');
  287. ButtonMode.Common=0;
  288. ButtonMode.Check=1;
  289. ButtonMode.Radio=2;
  290. return ButtonMode;
  291. })()
  292. /**
  293. *Use for GComponent.childrenRenderOrder
  294. */
  295. //class fairygui.ChildrenRenderOrder
  296. var ChildrenRenderOrder=(function(){
  297. function ChildrenRenderOrder(){}
  298. __class(ChildrenRenderOrder,'fairygui.ChildrenRenderOrder');
  299. ChildrenRenderOrder.Ascent=0;
  300. ChildrenRenderOrder.Descent=1;
  301. ChildrenRenderOrder.Arch=2;
  302. return ChildrenRenderOrder;
  303. })()
  304. //class fairygui.display.BitmapFont
  305. var BitmapFont$1=(function(){
  306. function BitmapFont(){
  307. this.id=null;
  308. this.size=0;
  309. this.ttf=false;
  310. this.glyphs=null;
  311. this.resizable=false;
  312. this.glyphs={};
  313. }
  314. __class(BitmapFont,'fairygui.display.BitmapFont',null,'BitmapFont$1');
  315. return BitmapFont;
  316. })()
  317. //class fairygui.display.BMGlyph
  318. var BMGlyph=(function(){
  319. function BMGlyph(){
  320. this.offsetX=0;
  321. this.offsetY=0;
  322. this.width=0;
  323. this.height=0;
  324. this.advance=0;
  325. this.lineHeight=0;
  326. this.channel=0;
  327. this.texture=null;
  328. }
  329. __class(BMGlyph,'fairygui.display.BMGlyph');
  330. return BMGlyph;
  331. })()
  332. //class fairygui.display.FillUtils
  333. var FillUtils=(function(){
  334. function FillUtils(){}
  335. __class(FillUtils,'fairygui.display.FillUtils');
  336. FillUtils.fill=function(w,h,method,origin,clockwise,amount){
  337. if(amount<=0)
  338. return null;
  339. else if(amount>=0.9999)
  340. return [0,0,w,0,w,h,0,h];
  341. var points;
  342. switch(method){
  343. case 1:
  344. points=fairygui.display.FillUtils.fillHorizontal(w,h,origin,amount);
  345. break ;
  346. case 2:
  347. points=fairygui.display.FillUtils.fillVertical(w,h,origin,amount);
  348. break ;
  349. case 3:
  350. points=fairygui.display.FillUtils.fillRadial90(w,h,origin,clockwise,amount);
  351. break ;
  352. case 4:
  353. points=fairygui.display.FillUtils.fillRadial180(w,h,origin,clockwise,amount);
  354. break ;
  355. case 5:
  356. points=fairygui.display.FillUtils.fillRadial360(w,h,origin,clockwise,amount);
  357. break ;
  358. }
  359. return points;
  360. }
  361. FillUtils.fillHorizontal=function(w,h,origin,amount){
  362. var w2=w*amount;
  363. if(origin==2 || origin==0)
  364. return [0,0,w2,0,w2,h,0,h];
  365. else
  366. return [w,0,w,h,w-w2,h,w-w2,0];
  367. }
  368. FillUtils.fillVertical=function(w,h,origin,amount){
  369. var h2=h*amount;
  370. if(origin==2 || origin==0)
  371. return [0,0,0,h2,w,h2,w,0];
  372. else
  373. return [0,h,w,h,w,h-h2,0,h-h2];
  374. }
  375. FillUtils.fillRadial90=function(w,h,origin,clockwise,amount){
  376. if(clockwise && (origin==1 || origin==2)
  377. || !clockwise && (origin==0 || origin==3)){
  378. amount=1-amount;
  379. };
  380. var v=NaN,v2=NaN,h2=NaN;
  381. v=Math.tan(Math.PI / 2 *amount);
  382. h2=w *v;
  383. v2=(h2-h)/ h2;
  384. var points;
  385. switch(origin){
  386. case 0:
  387. if(clockwise){
  388. if(h2<=h)
  389. points=[0,0,w,h2,w,0];
  390. else
  391. points=[0,0,w*(1-v2),h,w,h,w,0];
  392. }
  393. else{
  394. if(h2<=h)
  395. points=[0,0,w,h2,w,h,0,h];
  396. else
  397. points=[0,0,w*(1-v2),h,0,h];
  398. }
  399. break ;
  400. case 1:
  401. if(clockwise){
  402. if(h2<=h)
  403. points=[w,0,0,h2,0,h,w,h];
  404. else
  405. points=[w,0,w*v2,h,w,h];
  406. }
  407. else{
  408. if(h2<=h)
  409. points=[w,0,0,h2,0,0];
  410. else
  411. points=[w,0,w*v2,h,0,h,0,0];
  412. }
  413. break ;
  414. case 2:
  415. if(clockwise){
  416. if(h2<=h)
  417. points=[0,h,w,h-h2,w,0,0,0];
  418. else
  419. points=[0,h,w*(1-v2),0,0,0];
  420. }
  421. else{
  422. if(h2<=h)
  423. points=[0,h,w,h-h2,w,h];
  424. else
  425. points=[0,h,w*(1-v2),0,w,0,w,h];
  426. }
  427. break ;
  428. case 3:
  429. if(clockwise){
  430. if(h2<=h)
  431. points=[w,h,0,h-h2,0,h];
  432. else
  433. points=[w,h,w*v2,0,0,0,0,h];
  434. }
  435. else{
  436. if(h2<=h)
  437. points=[w,h,0,h-h2,0,0,w,0];
  438. else
  439. points=[w,h,w*v2,0,w,0];
  440. }
  441. break ;
  442. }
  443. return points;
  444. }
  445. FillUtils.movePoints=function(points,offsetX,offsetY){
  446. var cnt=points.length;
  447. for(var i=0;i<cnt;i+=2){
  448. points[i]+=offsetX;
  449. points[i+1]+=offsetY;
  450. }
  451. }
  452. FillUtils.fillRadial180=function(w,h,origin,clockwise,amount){
  453. var points;
  454. switch(origin){
  455. case 0:
  456. if(amount<=0.5){
  457. amount=amount / 0.5;
  458. points=FillUtils.fillRadial90(w/2,h,
  459. clockwise?0:1,
  460. clockwise,
  461. amount);
  462. if(clockwise)
  463. FillUtils.movePoints(points,w/2,0);
  464. }
  465. else{
  466. amount=(amount-0.5)/ 0.5;
  467. points=FillUtils.fillRadial90(w/2,h,
  468. clockwise?1:0,
  469. clockwise,
  470. amount);
  471. if(clockwise)
  472. points.push(w,h,w,0);
  473. else{
  474. FillUtils.movePoints(points,w/2,0);
  475. points.push(0,h,0,0);
  476. }
  477. }
  478. break ;
  479. case 1:
  480. if(amount<=0.5){
  481. amount=amount / 0.5;
  482. points=FillUtils.fillRadial90(w/2,h,
  483. clockwise?3:2,
  484. clockwise,
  485. amount);
  486. if(!clockwise)
  487. FillUtils.movePoints(points,w/2,0);
  488. }
  489. else{
  490. amount=(amount-0.5)/ 0.5;
  491. points=FillUtils.fillRadial90(w/2,h,
  492. clockwise?2:3,
  493. clockwise,
  494. amount);
  495. if(clockwise){
  496. FillUtils.movePoints(points,w/2,0);
  497. points.push(0,0,0,h);
  498. }
  499. else
  500. points.push(w,0,w,h);
  501. }
  502. break ;
  503. case 2:
  504. if(amount<=0.5){
  505. amount=amount / 0.5;
  506. points=FillUtils.fillRadial90(w,h/2,
  507. clockwise?2:0,
  508. clockwise,
  509. amount);
  510. if(!clockwise)
  511. FillUtils.movePoints(points,0,h/2);
  512. }
  513. else{
  514. amount=(amount-0.5)/ 0.5;
  515. points=FillUtils.fillRadial90(w,h/2,
  516. clockwise?0:2,
  517. clockwise,
  518. amount);
  519. if(clockwise){
  520. FillUtils.movePoints(points,0,h/2);
  521. points.push(w,0,0,0);
  522. }
  523. else
  524. points.push(w,h,0,h);
  525. }
  526. break ;
  527. case 3:
  528. if(amount<=0.5){
  529. amount=amount / 0.5;
  530. points=FillUtils.fillRadial90(w,h/2,
  531. clockwise?1:3,
  532. clockwise,
  533. amount);
  534. if(clockwise)
  535. FillUtils.movePoints(points,0,h/2);
  536. }
  537. else{
  538. amount=(amount-0.5)/ 0.5;
  539. points=FillUtils.fillRadial90(w,h/2,
  540. clockwise?3:1,
  541. clockwise,
  542. amount);
  543. if(clockwise)
  544. points.push(0,h,w,h);
  545. else{
  546. FillUtils.movePoints(points,0,h/2);
  547. points.push(0,0,w,0);
  548. }
  549. }
  550. break ;
  551. }
  552. return points;
  553. }
  554. FillUtils.fillRadial360=function(w,h,origin,clockwise,amount){
  555. var points;
  556. switch(origin){
  557. case 0:
  558. if(amount<=0.5){
  559. amount=amount / 0.5;
  560. points=FillUtils.fillRadial180(w/2,h,
  561. clockwise?2:3,
  562. clockwise,
  563. amount);
  564. if(clockwise)
  565. FillUtils.movePoints(points,w/2,0);
  566. }
  567. else{
  568. amount=(amount-0.5)/ 0.5;
  569. points=FillUtils.fillRadial180(w/2,h,
  570. clockwise?3:2,
  571. clockwise,
  572. amount);
  573. if(clockwise)
  574. points.push(w,h,w,0,w/2,0);
  575. else{
  576. FillUtils.movePoints(points,w/2,0);
  577. points.push(0,h,0,0,w/2,0);
  578. }
  579. }
  580. break ;
  581. case 1:
  582. if(amount<=0.5){
  583. amount=amount / 0.5;
  584. points=FillUtils.fillRadial180(w/2,h,
  585. clockwise?3:2,
  586. clockwise,
  587. amount);
  588. if(!clockwise)
  589. FillUtils.movePoints(points,w/2,0);
  590. }
  591. else{
  592. amount=(amount-0.5)/ 0.5;
  593. points=FillUtils.fillRadial180(w/2,h,
  594. clockwise?2:3,
  595. clockwise,
  596. amount);
  597. if(clockwise){
  598. FillUtils.movePoints(points,w/2,0);
  599. points.push(0,0,0,h,w/2,h);
  600. }
  601. else
  602. points.push(w,0,w,h,w/2,h);
  603. }
  604. break ;
  605. case 2:
  606. if(amount<=0.5){
  607. amount=amount / 0.5;
  608. points=FillUtils.fillRadial180(w,h/2,
  609. clockwise?1:0,
  610. clockwise,
  611. amount);
  612. if(!clockwise)
  613. FillUtils.movePoints(points,0,h/2);
  614. }
  615. else{
  616. amount=(amount-0.5)/ 0.5;
  617. points=FillUtils.fillRadial180(w,h/2,
  618. clockwise?0:1,
  619. clockwise,
  620. amount);
  621. if(clockwise){
  622. FillUtils.movePoints(points,0,h/2);
  623. points.push(w,0,0,0,0,h/2);
  624. }
  625. else
  626. points.push(w,h,0,h,0,h/2);
  627. }
  628. break ;
  629. case 3:
  630. if(amount<=0.5){
  631. amount=amount / 0.5;
  632. points=FillUtils.fillRadial180(w,h/2,
  633. clockwise?0:1,
  634. clockwise,
  635. amount);
  636. if(clockwise)
  637. FillUtils.movePoints(points,0,h/2);
  638. }
  639. else{
  640. amount=(amount-0.5)/ 0.5;
  641. points=FillUtils.fillRadial180(w,h/2,
  642. clockwise?1:0,
  643. clockwise,
  644. amount);
  645. if(clockwise)
  646. points.push(0,h,w,h,w,h/2);
  647. else{
  648. FillUtils.movePoints(points,0,h/2);
  649. points.push(0,0,w,0,w,h/2);
  650. }
  651. }
  652. break ;
  653. }
  654. return points;
  655. }
  656. return FillUtils;
  657. })()
  658. //class fairygui.display.Frame
  659. var Frame=(function(){
  660. function Frame(){
  661. this.rect=null;
  662. this.addDelay=0;
  663. this.texture=null;
  664. this.rect=new Rectangle();
  665. }
  666. __class(Frame,'fairygui.display.Frame');
  667. return Frame;
  668. })()
  669. //class fairygui.DragDropManager
  670. var DragDropManager=(function(){
  671. function DragDropManager(){
  672. this._agent=null;
  673. this._sourceData=null;
  674. this._agent=new GLoader();
  675. this._agent.draggable=true;
  676. this._agent.touchable=false;
  677. this._agent.setSize(100,100);
  678. this._agent.setPivot(0.5,0.5,true);
  679. this._agent.align="center";
  680. this._agent.verticalAlign="middle";
  681. this._agent.sortingOrder=1000000;
  682. this._agent.on("fui_drag_end",this,this.__dragEnd);
  683. }
  684. __class(DragDropManager,'fairygui.DragDropManager');
  685. var __proto=DragDropManager.prototype;
  686. __proto.startDrag=function(source,icon,sourceData,touchPointID){
  687. (touchPointID===void 0)&& (touchPointID=-1);
  688. if(this._agent.parent !=null)
  689. return;
  690. this._sourceData=sourceData;
  691. this._agent.url=icon;
  692. GRoot.inst.addChild(this._agent);
  693. var pt=GRoot.inst.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY);
  694. this._agent.setXY(pt.x,pt.y);
  695. this._agent.startDrag(touchPointID);
  696. }
  697. __proto.cancel=function(){
  698. if(this._agent.parent !=null){
  699. this._agent.stopDrag();
  700. GRoot.inst.removeChild(this._agent);
  701. this._sourceData=null;
  702. }
  703. }
  704. __proto.__dragEnd=function(evt){
  705. if(this._agent.parent==null)
  706. return;
  707. GRoot.inst.removeChild(this._agent);
  708. var sourceData=this._sourceData;
  709. this._sourceData=null;
  710. var obj=GObject.cast(evt.target);
  711. while(obj !=null){
  712. if(obj.displayObject.hasListener("fui_drop")){
  713. obj.requestFocus();
  714. obj.displayObject.event("fui_drop",[sourceData,Events.createEvent("fui_drop",obj.displayObject,evt)]);
  715. return;
  716. }
  717. obj=obj.parent;
  718. }
  719. }
  720. __getset(0,__proto,'dragAgent',function(){
  721. return this._agent;
  722. });
  723. __getset(0,__proto,'dragging',function(){
  724. return this._agent.parent !=null;
  725. });
  726. __getset(1,DragDropManager,'inst',function(){
  727. if(fairygui.DragDropManager._inst==null)
  728. fairygui.DragDropManager._inst=new DragDropManager();
  729. return fairygui.DragDropManager._inst;
  730. });
  731. DragDropManager._inst=null;
  732. return DragDropManager;
  733. })()
  734. //class fairygui.Events
  735. var Events=(function(){
  736. function Events(){}
  737. __class(Events,'fairygui.Events');
  738. Events.createEvent=function(type,target,source){
  739. fairygui.Events.$event.setTo(type,target,source?source.target:target);
  740. if(source){
  741. fairygui.Events.$event.touchId=source.touchId;
  742. fairygui.Events.$event.nativeEvent=source.nativeEvent;
  743. }
  744. else{
  745. fairygui.Events.$event.nativeEvent=null;
  746. }
  747. fairygui.Events.$event._stoped=false;
  748. return fairygui.Events.$event;
  749. }
  750. Events.dispatch=function(type,target,source){
  751. target.event(type,fairygui.Events.createEvent(type,target,source));
  752. }
  753. Events.STATE_CHANGED="fui_state_changed";
  754. Events.XY_CHANGED="fui_xy_changed";
  755. Events.SIZE_CHANGED="fui_size_changed";
  756. Events.SIZE_DELAY_CHANGE="fui_size_delay_change";
  757. Events.CLICK_ITEM="fui_click_item";
  758. Events.SCROLL="fui_scroll";
  759. Events.SCROLL_END="fui_scroll_end";
  760. Events.DROP="fui_drop";
  761. Events.FOCUS_CHANGED="fui_focus_changed";
  762. Events.DRAG_START="fui_drag_start";
  763. Events.DRAG_MOVE="fui_drag_move";
  764. Events.DRAG_END="fui_drag_end";
  765. Events.PULL_DOWN_RELEASE="fui_pull_down_release";
  766. Events.PULL_UP_RELEASE="fui_pull_up_release";
  767. Events.GEAR_STOP="fui_gear_stop";
  768. __static(Events,
  769. ['$event',function(){return this.$event=new Event();}
  770. ]);
  771. return Events;
  772. })()
  773. //class fairygui.FillMethod
  774. var FillMethod=(function(){
  775. function FillMethod(){}
  776. __class(FillMethod,'fairygui.FillMethod');
  777. FillMethod.None=0;
  778. FillMethod.Horizontal=1;
  779. FillMethod.Vertical=2;
  780. FillMethod.Radial90=3;
  781. FillMethod.Radial180=4;
  782. FillMethod.Radial360=5;
  783. return FillMethod;
  784. })()
  785. //class fairygui.FillOrigin
  786. var FillOrigin=(function(){
  787. function FillOrigin(){}
  788. __class(FillOrigin,'fairygui.FillOrigin');
  789. FillOrigin.Top=0;
  790. FillOrigin.Bottom=1;
  791. FillOrigin.Left=2;
  792. FillOrigin.Right=3;
  793. FillOrigin.TopLeft=0;
  794. FillOrigin.TopRight=1;
  795. FillOrigin.BottomLeft=2;
  796. FillOrigin.BottomRight=3;
  797. return FillOrigin;
  798. })()
  799. /**
  800. *Use for GImage.flip
  801. */
  802. //class fairygui.FlipType
  803. var FlipType=(function(){
  804. function FlipType(){}
  805. __class(FlipType,'fairygui.FlipType');
  806. FlipType.None=0;
  807. FlipType.Horizontal=1;
  808. FlipType.Vertical=2;
  809. FlipType.Both=3;
  810. return FlipType;
  811. })()
  812. //class fairygui.GObject
  813. var GObject=(function(){
  814. function GObject(){
  815. this.data=null;
  816. this.packageItem=null;
  817. this._x=0;
  818. this._y=0;
  819. this._alpha=1;
  820. this._rotation=0;
  821. this._visible=true;
  822. this._touchable=true;
  823. this._grayed=false;
  824. this._draggable=false;
  825. this._scaleX=1;
  826. this._scaleY=1;
  827. this._skewX=0;
  828. this._skewY=0;
  829. this._pivotX=0;
  830. this._pivotY=0;
  831. this._pivotAsAnchor=false;
  832. this._pivotOffsetX=0;
  833. this._pivotOffsetY=0;
  834. this._sortingOrder=0;
  835. this._internalVisible=true;
  836. this._handlingController=false;
  837. this._focusable=false;
  838. this._tooltips=null;
  839. this._pixelSnapping=false;
  840. this._relations=null;
  841. this._group=null;
  842. this._gears=null;
  843. this._dragBounds=null;
  844. this._displayObject=null;
  845. this._yOffset=0;
  846. //Size的实现方式,有两种,0-GObject的w/h等于DisplayObject的w/h。1-GObject的sourceWidth/sourceHeight等于DisplayObject的w/h,剩余部分由scale实现
  847. this._sizeImplType=0;
  848. this.minWidth=0;
  849. this.minHeight=0;
  850. this.maxWidth=0;
  851. this.maxHeight=0;
  852. this.sourceWidth=0;
  853. this.sourceHeight=0;
  854. this.initWidth=0;
  855. this.initHeight=0;
  856. this._parent=null;
  857. this._width=0;
  858. this._height=0;
  859. this._rawWidth=0;
  860. this._rawHeight=0;
  861. this._id=null;
  862. this._name=null;
  863. this._underConstruct=false;
  864. this._gearLocked=false;
  865. this._sizePercentInGroup=0;
  866. this._touchDownPoint=null;
  867. ;
  868. this._id=""+fairygui.GObject._gInstanceCounter++;
  869. this._name="";
  870. this.createDisplayObject();
  871. this._relations=new Relations(this);
  872. this._gears=__newvec(8,null);
  873. }
  874. __class(GObject,'fairygui.GObject');
  875. var __proto=GObject.prototype;
  876. __proto.setXY=function(xv,yv){
  877. if(this._x !=xv || this._y !=yv){
  878. var dx=xv-this._x;
  879. var dy=yv-this._y;
  880. this._x=xv;
  881. this._y=yv;
  882. this.handleXYChanged();
  883. if((this instanceof fairygui.GGroup ))
  884. (this).moveChildren(dx,dy);
  885. this.updateGear(1);
  886. if(this._parent && !((this._parent instanceof fairygui.GList ))){
  887. this._parent.setBoundsChangedFlag();
  888. if (this._group !=null)
  889. this._group.setBoundsChangedFlag();
  890. this.displayObject.event("fui_xy_changed");
  891. }
  892. if (GObject.draggingObject==this && !GObject.sUpdateInDragging)
  893. this.localToGlobalRect(0,0,this.width,this.height,GObject.sGlobalRect);
  894. }
  895. }
  896. __proto.center=function(restraint){
  897. (restraint===void 0)&& (restraint=false);
  898. var r;
  899. if(this._parent !=null)
  900. r=this.parent;
  901. else
  902. r=this.root;
  903. this.setXY((r.width-this.width)/ 2,(r.height-this.height)/ 2);
  904. if(restraint){
  905. this.addRelation(r,3);
  906. this.addRelation(r,10);
  907. }
  908. }
  909. __proto.setSize=function(wv,hv,ignorePivot){
  910. (ignorePivot===void 0)&& (ignorePivot=false);
  911. if(this._rawWidth !=wv || this._rawHeight !=hv){
  912. this._rawWidth=wv;
  913. this._rawHeight=hv;
  914. if(wv<this.minWidth)
  915. wv=this.minWidth;
  916. if(hv<this.minHeight)
  917. hv=this.minHeight;
  918. if(this.maxWidth>0 && wv>this.maxWidth)
  919. wv=this.maxWidth;
  920. if(this.maxHeight>0 && hv>this.maxHeight)
  921. hv=this.maxHeight;
  922. var dWidth=wv-this._width;
  923. var dHeight=hv-this._height;
  924. this._width=wv;
  925. this._height=hv;
  926. this.handleSizeChanged();
  927. if(this._pivotX !=0 || this._pivotY !=0){
  928. if(!this._pivotAsAnchor){
  929. if(!ignorePivot)
  930. this.setXY(this.x-this._pivotX *dWidth,this.y-this._pivotY *dHeight);
  931. this.updatePivotOffset();
  932. }
  933. else
  934. this.applyPivot();
  935. }
  936. if ((this instanceof fairygui.GGroup ))
  937. (this).resizeChildren(dWidth,dHeight);
  938. this.updateGear(2);
  939. if(this._parent){
  940. this._relations.onOwnerSizeChanged(dWidth,dHeight,this._pivotAsAnchor || !ignorePivot);
  941. this._parent.setBoundsChangedFlag();
  942. if (this._group !=null)
  943. this._group.setBoundsChangedFlag(true);
  944. }
  945. this.displayObject.event("fui_size_changed");
  946. }
  947. }
  948. __proto.ensureSizeCorrect=function(){}
  949. __proto.setScale=function(sx,sy){
  950. if(this._scaleX !=sx || this._scaleY !=sy){
  951. this._scaleX=sx;
  952. this._scaleY=sy;
  953. this.handleScaleChanged();
  954. this.applyPivot();
  955. this.updateGear(2);
  956. }
  957. }
  958. __proto.setSkew=function(sx,sy){
  959. if(this._skewX !=sx || this._skewY !=sy){
  960. this._skewX=sx;
  961. this._skewY=sy;
  962. if(this._displayObject!=null){
  963. this._displayObject.skew(-sx,sy);
  964. this.applyPivot();
  965. }
  966. }
  967. }
  968. __proto.setPivot=function(xv,yv,asAnchor){
  969. (yv===void 0)&& (yv=0);
  970. (asAnchor===void 0)&& (asAnchor=false);
  971. if(this._pivotX !=xv || this._pivotY !=yv || this._pivotAsAnchor!=asAnchor){
  972. this._pivotX=xv;
  973. this._pivotY=yv;
  974. this._pivotAsAnchor=asAnchor;
  975. this.updatePivotOffset();
  976. this.handleXYChanged();
  977. }
  978. }
  979. __proto.internalSetPivot=function(xv,yv,asAnchor){
  980. this._pivotX=xv;
  981. this._pivotY=yv;
  982. this._pivotAsAnchor=asAnchor;
  983. if(this._pivotAsAnchor)
  984. this.handleXYChanged();
  985. }
  986. __proto.updatePivotOffset=function(){
  987. if(this._displayObject!=null){
  988. if(this._displayObject.transform && (this._pivotX!=0 || this._pivotY!=0)){
  989. if(this._sizeImplType==0){
  990. fairygui.GObject.sHelperPoint.x=this._pivotX*this._width;
  991. fairygui.GObject.sHelperPoint.y=this._pivotY*this._height;
  992. }
  993. else {
  994. fairygui.GObject.sHelperPoint.x=this._pivotX*this.sourceWidth;
  995. fairygui.GObject.sHelperPoint.y=this._pivotY*this.sourceHeight;
  996. };
  997. var pt=this._displayObject.transform.transformPoint(fairygui.GObject.sHelperPoint);
  998. this._pivotOffsetX=this._pivotX*this._width-pt.x;
  999. this._pivotOffsetY=this._pivotY*this._height-pt.y;
  1000. }
  1001. else{
  1002. this._pivotOffsetX=0;
  1003. this._pivotOffsetY=0;
  1004. }
  1005. }
  1006. }
  1007. __proto.applyPivot=function(){
  1008. if(this._pivotX !=0 || this._pivotY !=0){
  1009. this.updatePivotOffset();
  1010. this.handleXYChanged();
  1011. }
  1012. }
  1013. __proto.requestFocus=function(){
  1014. var p=this;
  1015. while (p && !p._focusable)
  1016. p=p.parent;
  1017. if (p !=null)
  1018. this.root.focus=p;
  1019. }
  1020. __proto.__rollOver=function(evt){
  1021. Laya.timer.once(100,this,this.__doShowTooltips);
  1022. }
  1023. __proto.__doShowTooltips=function(){
  1024. var r=this.root;
  1025. if(r)
  1026. this.root.showTooltips(this._tooltips);
  1027. }
  1028. __proto.__rollOut=function(evt){
  1029. Laya.timer.clear(this,this.__doShowTooltips);
  1030. this.root.hideTooltips();
  1031. }
  1032. __proto.getGear=function(index){
  1033. var gear=this._gears[index];
  1034. if (gear==null){
  1035. switch (index){
  1036. case 0:
  1037. gear=new GearDisplay(this);
  1038. break ;
  1039. case 1:
  1040. gear=new GearXY(this);
  1041. break ;
  1042. case 2:
  1043. gear=new GearSize(this);
  1044. break ;
  1045. case 3:
  1046. gear=new GearLook(this);
  1047. break ;
  1048. case 4:
  1049. gear=new GearColor(this);
  1050. break ;
  1051. case 5:
  1052. gear=new GearAnimation(this);
  1053. break ;
  1054. case 6:
  1055. gear=new GearText(this);
  1056. break ;
  1057. case 7:
  1058. gear=new GearIcon(this);
  1059. break ;
  1060. default :
  1061. throw new Error("FairyGUI: invalid gear index!");
  1062. }
  1063. this._gears[index]=gear;
  1064. }
  1065. return gear;
  1066. }
  1067. __proto.updateGear=function(index){
  1068. if(this._underConstruct || this._gearLocked)
  1069. return;
  1070. var gear=this._gears[index];
  1071. if (gear!=null && gear.controller!=null)
  1072. gear.updateState();
  1073. }
  1074. __proto.checkGearController=function(index,c){
  1075. return this._gears[index] !=null && this._gears[index].controller==c;
  1076. }
  1077. __proto.updateGearFromRelations=function(index,dx,dy){
  1078. if (this._gears[index] !=null)
  1079. this._gears[index].updateFromRelations(dx,dy);
  1080. }
  1081. __proto.addDisplayLock=function(){
  1082. var gearDisplay=(this._gears[0]);
  1083. if(gearDisplay && gearDisplay.controller){
  1084. var ret=gearDisplay.addLock();
  1085. this.checkGearDisplay();
  1086. return ret;
  1087. }
  1088. else
  1089. return 0;
  1090. }
  1091. __proto.releaseDisplayLock=function(token){
  1092. var gearDisplay=(this._gears[0]);
  1093. if(gearDisplay && gearDisplay.controller){
  1094. gearDisplay.releaseLock(token);
  1095. this.checkGearDisplay();
  1096. }
  1097. }
  1098. __proto.checkGearDisplay=function(){
  1099. if(this._handlingController)
  1100. return;
  1101. var connected=this._gears[0]==null || (this._gears[0]).connected;
  1102. if(connected!=this._internalVisible){
  1103. this._internalVisible=connected;
  1104. if(this._parent)
  1105. this._parent.childStateChanged(this);
  1106. }
  1107. }
  1108. __proto.addRelation=function(target,relationType,usePercent){
  1109. (usePercent===void 0)&& (usePercent=false);
  1110. this._relations.add(target,relationType,usePercent);
  1111. }
  1112. __proto.removeRelation=function(target,relationType){
  1113. (relationType===void 0)&& (relationType=0);
  1114. this._relations.remove(target,relationType);
  1115. }
  1116. __proto.removeFromParent=function(){
  1117. if (this._parent)
  1118. this._parent.removeChild(this);
  1119. }
  1120. __proto.dispose=function(){
  1121. this.removeFromParent();
  1122. this._relations.dispose();
  1123. this._displayObject.destroy();
  1124. this._displayObject=null;
  1125. }
  1126. __proto.onClick=function(thisObj,listener,args){
  1127. this.on("click",thisObj,listener,args);
  1128. }
  1129. __proto.offClick=function(thisObj,listener){
  1130. this.off("click",thisObj,listener);
  1131. }
  1132. __proto.hasClickListener=function(){
  1133. return this._displayObject.hasListener("click");
  1134. }
  1135. __proto.on=function(type,thisObject,listener,args){
  1136. this._displayObject.on(type,thisObject,listener,args);
  1137. }
  1138. __proto.off=function(type,thisObject,listener){
  1139. this._displayObject.off(type,thisObject,listener);
  1140. }
  1141. __proto.startDrag=function(touchPointID){
  1142. (touchPointID===void 0)&& (touchPointID=-1);
  1143. if (this._displayObject.stage==null)
  1144. return;
  1145. this.dragBegin();
  1146. }
  1147. __proto.stopDrag=function(){
  1148. this.dragEnd();
  1149. }
  1150. __proto.localToGlobal=function(ax,ay,resultPoint){
  1151. (ax===void 0)&& (ax=0);
  1152. (ay===void 0)&& (ay=0);
  1153. if(this._pivotAsAnchor){
  1154. ax+=this._pivotX*this._width;
  1155. ay+=this._pivotY*this._height;
  1156. }
  1157. if(!resultPoint){
  1158. resultPoint=fairygui.GObject.sHelperPoint;
  1159. resultPoint.x=ax;
  1160. resultPoint.y=ay;
  1161. return this._displayObject.localToGlobal(resultPoint,true);
  1162. }
  1163. else{
  1164. resultPoint.x=ax;
  1165. resultPoint.y=ay;
  1166. return this._displayObject.localToGlobal(resultPoint,false);
  1167. }
  1168. }
  1169. __proto.globalToLocal=function(ax,ay,resultPoint){
  1170. (ax===void 0)&& (ax=0);
  1171. (ay===void 0)&& (ay=0);
  1172. if(!resultPoint){
  1173. resultPoint=fairygui.GObject.sHelperPoint;
  1174. resultPoint.x=ax;
  1175. resultPoint.y=ay;
  1176. resultPoint=this._displayObject.globalToLocal(resultPoint,true);
  1177. }
  1178. else{
  1179. resultPoint.x=ax;
  1180. resultPoint.y=ay;
  1181. this._displayObject.globalToLocal(resultPoint,false);
  1182. }
  1183. if(this._pivotAsAnchor){
  1184. resultPoint.x-=this._pivotX*this._width;
  1185. resultPoint.y-=this._pivotY*this._height;
  1186. }
  1187. return resultPoint;
  1188. }
  1189. __proto.localToGlobalRect=function(ax,ay,aWidth,aHeight,resultRect){
  1190. (ax===void 0)&& (ax=0);
  1191. (ay===void 0)&& (ay=0);
  1192. (aWidth===void 0)&& (aWidth=0);
  1193. (aHeight===void 0)&& (aHeight=0);
  1194. if(resultRect==null)
  1195. resultRect=new Rectangle();
  1196. var pt=this.localToGlobal(ax,ay);
  1197. resultRect.x=pt.x;
  1198. resultRect.y=pt.y;
  1199. pt=this.localToGlobal(ax+aWidth,ay+aHeight);
  1200. resultRect.width=pt.x-resultRect.x;
  1201. resultRect.height=pt.y-resultRect.y;
  1202. return resultRect;
  1203. }
  1204. __proto.globalToLocalRect=function(ax,ay,aWidth,aHeight,resultRect){
  1205. (ax===void 0)&& (ax=0);
  1206. (ay===void 0)&& (ay=0);
  1207. (aWidth===void 0)&& (aWidth=0);
  1208. (aHeight===void 0)&& (aHeight=0);
  1209. if(resultRect==null)
  1210. resultRect=new Rectangle();
  1211. var pt=this.globalToLocal(ax,ay);
  1212. resultRect.x=pt.x;
  1213. resultRect.y=pt.y;
  1214. pt=this.globalToLocal(ax+aWidth,ay+aHeight);
  1215. resultRect.width=pt.x-resultRect.x;
  1216. resultRect.height=pt.y-resultRect.y;
  1217. return resultRect;
  1218. }
  1219. __proto.handleControllerChanged=function(c){
  1220. this._handlingController=true;
  1221. for (var i=0;i < 8;i++){
  1222. var gear=this._gears[i];
  1223. if (gear !=null && gear.controller==c)
  1224. gear.apply();
  1225. }
  1226. this._handlingController=false;
  1227. this.checkGearDisplay();
  1228. }
  1229. __proto.createDisplayObject=function(){
  1230. this._displayObject=new Sprite();
  1231. this._displayObject["$owner"]=this;
  1232. }
  1233. __proto.handleXYChanged=function(){
  1234. var xv=this._x;
  1235. var yv=this._y+this._yOffset;
  1236. if(this._pivotAsAnchor){
  1237. xv-=this._pivotX*this._width;
  1238. yv-=this._pivotY*this._height;
  1239. }
  1240. if(this._pixelSnapping){
  1241. xv=Math.round(xv);
  1242. yv=Math.round(yv);
  1243. }
  1244. this._displayObject.pos(xv+this._pivotOffsetX,yv+this._pivotOffsetY);
  1245. }
  1246. __proto.handleSizeChanged=function(){
  1247. if(this._displayObject!=null){
  1248. if(this._sizeImplType==0 || this.sourceWidth==0 || this.sourceHeight==0)
  1249. this._displayObject.size(this._width,this._height);
  1250. else
  1251. this._displayObject.scale(this._width/this.sourceWidth*this._scaleX,
  1252. this._height/this.sourceHeight*this._scaleY);
  1253. }
  1254. }
  1255. __proto.handleScaleChanged=function(){
  1256. if(this._displayObject!=null){
  1257. if(this._sizeImplType==0 || this.sourceWidth==0 || this.sourceHeight==0)
  1258. this._displayObject.scale(this._scaleX,this._scaleY);
  1259. else
  1260. this._displayObject.scale(this._width/this.sourceWidth*this._scaleX,
  1261. this._height/this.sourceHeight*this._scaleY);
  1262. }
  1263. }
  1264. __proto.handleGrayedChanged=function(){
  1265. if(this._displayObject){
  1266. if(this._grayed){
  1267. if(GObject.grayFilter==null)
  1268. GObject.grayFilter=new ColorFilter([0.3086,0.6094,0.082,0,0,0.3086,0.6094,0.082,0,0,0.3086,0.6094,0.082,0,0,0,0,0,1,0]);
  1269. this._displayObject.filters=[GObject.grayFilter];
  1270. }
  1271. else
  1272. this._displayObject.filters=null;
  1273. }
  1274. }
  1275. __proto.handleAlphaChanged=function(){
  1276. if(this._displayObject)
  1277. this._displayObject.alpha=this._alpha;
  1278. }
  1279. __proto.handleVisibleChanged=function(){
  1280. if(this._displayObject)
  1281. this._displayObject.visible=this.internalVisible2;
  1282. }
  1283. __proto.constructFromResource=function(){}
  1284. __proto.setup_beforeAdd=function(buffer,beginPos){
  1285. buffer.seek(beginPos,0);
  1286. buffer.skip(5);
  1287. var f1=NaN;
  1288. var f2=NaN;
  1289. this._id=buffer.readS();
  1290. this._name=buffer.readS();
  1291. f1=buffer.getInt32();
  1292. f2=buffer.getInt32();
  1293. this.setXY(f1,f2);
  1294. if (buffer.readBool()){
  1295. this.initWidth=buffer.getInt32();
  1296. this.initHeight=buffer.getInt32();
  1297. this.setSize(this.initWidth,this.initHeight,true);
  1298. }
  1299. if (buffer.readBool()){
  1300. this.minWidth=buffer.getInt32();
  1301. this.maxWidth=buffer.getInt32();
  1302. this.minHeight=buffer.getInt32();
  1303. this.maxHeight=buffer.getInt32();
  1304. }
  1305. if (buffer.readBool()){
  1306. f1=buffer.getFloat32();
  1307. f2=buffer.getFloat32();
  1308. this.setScale(f1,f2);
  1309. }
  1310. if (buffer.readBool()){
  1311. f1=buffer.getFloat32();
  1312. f2=buffer.getFloat32();
  1313. this.setSkew(f1,f2);
  1314. }
  1315. if (buffer.readBool()){
  1316. f1=buffer.getFloat32();
  1317. f2=buffer.getFloat32();
  1318. this.setPivot(f1,f2,buffer.readBool());
  1319. }
  1320. f1=buffer.getFloat32();
  1321. if (f1 !=1)
  1322. this.alpha=f1;
  1323. f1=buffer.getFloat32();
  1324. if (f1 !=0)
  1325. this.rotation=f1;
  1326. if (!buffer.readBool())
  1327. this.visible=false;
  1328. if (!buffer.readBool())
  1329. this.touchable=false;
  1330. if (buffer.readBool())
  1331. this.grayed=true;
  1332. var bm=buffer.readByte();
  1333. if(bm==2)
  1334. this.blendMode="lighter";
  1335. var filter=buffer.readByte();
  1336. if (filter==1){
  1337. var cm=new ColorMatrix();
  1338. cm.adjustBrightness(buffer.getFloat32());
  1339. cm.adjustContrast(buffer.getFloat32());
  1340. cm.adjustSaturation(buffer.getFloat32());
  1341. cm.adjustHue(buffer.getFloat32());
  1342. var cf=new ColorFilter(cm);
  1343. this.filters=[cf];
  1344. };
  1345. var str=buffer.readS();
  1346. if (str !=null)
  1347. this.data=str;
  1348. }
  1349. __proto.setup_afterAdd=function(buffer,beginPos){
  1350. buffer.seek(beginPos,1);
  1351. var str=buffer.readS();
  1352. if (str !=null)
  1353. this.tooltips=str;
  1354. var groupId=buffer.getInt16();
  1355. if (groupId >=0)
  1356. this.group=this.parent.getChildAt(groupId);
  1357. buffer.seek(beginPos,2);
  1358. var cnt=buffer.getInt16();
  1359. for (var i=0;i < cnt;i++){
  1360. var nextPos=buffer.getInt16();
  1361. nextPos+=buffer.pos;
  1362. var gear=this.getGear(buffer.readByte());
  1363. gear.setup(buffer);
  1364. buffer.pos=nextPos;
  1365. }
  1366. }
  1367. __proto.initDrag=function(){
  1368. if (this._draggable)
  1369. this.on("mousedown",this,this.__begin);
  1370. else
  1371. this.off("mousedown",this,this.__begin);
  1372. }
  1373. __proto.dragBegin=function(){
  1374. if (fairygui.GObject.draggingObject !=null)
  1375. fairygui.GObject.draggingObject.stopDrag();
  1376. fairygui.GObject.sGlobalDragStart.x=Laya.stage.mouseX;
  1377. fairygui.GObject.sGlobalDragStart.y=Laya.stage.mouseY;
  1378. this.localToGlobalRect(0,0,this.width,this.height,fairygui.GObject.sGlobalRect);
  1379. fairygui.GObject.draggingObject=this;
  1380. Laya.stage.on("mousemove",this,this.__moving2);
  1381. Laya.stage.on("mouseup",this,this.__end2);
  1382. }
  1383. __proto.dragEnd=function(){
  1384. if (fairygui.GObject.draggingObject==this){
  1385. Laya.stage.off("mousemove",this,this.__moving2);
  1386. Laya.stage.off("mouseup",this,this.__end2);
  1387. fairygui.GObject.draggingObject=null;
  1388. }
  1389. fairygui.GObject.sDraggingQuery=false;
  1390. }
  1391. __proto.reset=function(){
  1392. Laya.stage.off("mousemove",this,this.__moving);
  1393. Laya.stage.off("mouseup",this,this.__end);
  1394. }
  1395. __proto.__begin=function(){
  1396. if(this._touchDownPoint==null)
  1397. this._touchDownPoint=new Point();
  1398. this._touchDownPoint.x=Laya.stage.mouseX;
  1399. this._touchDownPoint.y=Laya.stage.mouseY;
  1400. Laya.stage.on("mousemove",this,this.__moving);
  1401. Laya.stage.on("mouseup",this,this.__end);
  1402. }
  1403. __proto.__end=function(){
  1404. this.reset();
  1405. }
  1406. __proto.__moving=function(evt){
  1407. var sensitivity=UIConfig$1.touchDragSensitivity;
  1408. if(this._touchDownPoint !=null
  1409. && Math.abs(this._touchDownPoint.x-Laya.stage.mouseX)< sensitivity
  1410. && Math.abs(this._touchDownPoint.y-Laya.stage.mouseY)< sensitivity)
  1411. return;
  1412. this.reset();
  1413. fairygui.GObject.sDraggingQuery=true;
  1414. Events.dispatch("fui_drag_start",this._displayObject,evt);
  1415. if (fairygui.GObject.sDraggingQuery)
  1416. this.dragBegin();
  1417. }
  1418. __proto.__moving2=function(evt){
  1419. var xx=Laya.stage.mouseX-fairygui.GObject.sGlobalDragStart.x+fairygui.GObject.sGlobalRect.x;
  1420. var yy=Laya.stage.mouseY-fairygui.GObject.sGlobalDragStart.y+fairygui.GObject.sGlobalRect.y;
  1421. if(this._dragBounds !=null){
  1422. var rect=GRoot.inst.localToGlobalRect(this._dragBounds.x,this._dragBounds.y,
  1423. this._dragBounds.width,this._dragBounds.height,fairygui.GObject.sDragHelperRect);
  1424. if(xx < rect.x)
  1425. xx=rect.x;
  1426. else if(xx+fairygui.GObject.sGlobalRect.width > rect.right){
  1427. xx=rect.right-fairygui.GObject.sGlobalRect.width;
  1428. if(xx < rect.x)
  1429. xx=rect.x;
  1430. }
  1431. if(yy < rect.y)
  1432. yy=rect.y;
  1433. else if(yy+fairygui.GObject.sGlobalRect.height > rect.bottom){
  1434. yy=rect.bottom-fairygui.GObject.sGlobalRect.height;
  1435. if(yy < rect.y)
  1436. yy=rect.y;
  1437. }
  1438. }
  1439. GObject.sUpdateInDragging=true;
  1440. var pt=this.parent.globalToLocal(xx,yy,fairygui.GObject.sHelperPoint);
  1441. this.setXY(Math.round(pt.x),Math.round(pt.y));
  1442. GObject.sUpdateInDragging=false;
  1443. Events.dispatch("fui_drag_move",this._displayObject,evt);
  1444. }
  1445. __proto.__end2=function(evt){
  1446. if (fairygui.GObject.draggingObject==this){
  1447. this.stopDrag();
  1448. Events.dispatch("fui_drag_end",this._displayObject,evt);
  1449. }
  1450. }
  1451. __getset(0,__proto,'yMin',function(){
  1452. return this._pivotAsAnchor ? (this._y-this._height *this._pivotY):this._y;
  1453. },function(value){
  1454. if (this._pivotAsAnchor)
  1455. this.setXY(this._x,value+this._height *this._pivotY);
  1456. else
  1457. this.setXY(this._x,value);
  1458. });
  1459. __getset(0,__proto,'id',function(){
  1460. return this._id;
  1461. });
  1462. __getset(0,__proto,'name',function(){
  1463. return this._name;
  1464. },function(value){
  1465. this._name=value;
  1466. });
  1467. __getset(0,__proto,'rotation',function(){
  1468. return this._rotation;
  1469. },function(value){
  1470. if(this._rotation !=value){
  1471. this._rotation=value;
  1472. if(this._displayObject!=null){
  1473. this._displayObject.rotation=this.normalizeRotation;
  1474. this.applyPivot();
  1475. }
  1476. this.updateGear(3);
  1477. }
  1478. });
  1479. __getset(0,__proto,'width',function(){
  1480. this.ensureSizeCorrect();
  1481. if(this._relations.sizeDirty)
  1482. this._relations.ensureRelationsSizeCorrect();
  1483. return this._width;
  1484. },function(value){
  1485. this.setSize(value,this._rawHeight);
  1486. });
  1487. __getset(0,__proto,'x',function(){
  1488. return this._x;
  1489. },function(value){
  1490. this.setXY(value,this._y);
  1491. });
  1492. __getset(0,__proto,'draggable',function(){
  1493. return this._draggable;
  1494. },function(value){
  1495. if (this._draggable !=value){
  1496. this._draggable=value;
  1497. this.initDrag();
  1498. }
  1499. });
  1500. __getset(0,__proto,'y',function(){
  1501. return this._y;
  1502. },function(value){
  1503. this.setXY(this._x,value);
  1504. });
  1505. __getset(0,__proto,'gearXY',function(){
  1506. return (this.getGear(1));
  1507. });
  1508. __getset(0,__proto,'xMin',function(){
  1509. return this._pivotAsAnchor ? (this._x-this._width *this._pivotX):this._x;
  1510. },function(value){
  1511. if (this._pivotAsAnchor)
  1512. this.setXY(value+this._width *this._pivotX,this._y);
  1513. else
  1514. this.setXY(value,this._y);
  1515. });
  1516. __getset(0,__proto,'pixelSnapping',function(){
  1517. return this._pixelSnapping;
  1518. },function(value){
  1519. if(this._pixelSnapping!=value){
  1520. this._pixelSnapping=value;
  1521. this.handleXYChanged();
  1522. }
  1523. });
  1524. __getset(0,__proto,'height',function(){
  1525. this.ensureSizeCorrect();
  1526. if(this._relations.sizeDirty)
  1527. this._relations.ensureRelationsSizeCorrect();
  1528. return this._height;
  1529. },function(value){
  1530. this.setSize(this._rawWidth,value);
  1531. });
  1532. __getset(0,__proto,'asButton',function(){
  1533. return this;
  1534. });
  1535. __getset(0,__proto,'actualWidth',function(){
  1536. return this.width *Math.abs(this._scaleX);
  1537. });
  1538. __getset(0,__proto,'actualHeight',function(){
  1539. return this.height *Math.abs(this._scaleY);
  1540. });
  1541. __getset(0,__proto,'blendMode',function(){
  1542. return this._displayObject.blendMode;
  1543. },function(value){
  1544. this._displayObject.blendMode=value;
  1545. });
  1546. __getset(0,__proto,'scaleX',function(){
  1547. return this._scaleX;
  1548. },function(value){
  1549. this.setScale(value,this._scaleY);
  1550. });
  1551. __getset(0,__proto,'scaleY',function(){
  1552. return this._scaleY;
  1553. },function(value){
  1554. this.setScale(this._scaleX,value);
  1555. });
  1556. __getset(0,__proto,'skewX',function(){
  1557. return this._skewX;
  1558. },function(value){
  1559. this.setSkew(value,this._skewY);
  1560. });
  1561. __getset(0,__proto,'pivotAsAnchor',function(){
  1562. return this._pivotAsAnchor;
  1563. });
  1564. __getset(0,__proto,'skewY',function(){
  1565. return this._skewY;
  1566. },function(value){
  1567. this.setSkew(this._skewX,value);
  1568. });
  1569. __getset(0,__proto,'pivotX',function(){
  1570. return this._pivotX;
  1571. },function(value){
  1572. this.setPivot(value,this._pivotY);
  1573. });
  1574. __getset(0,__proto,'asLoader',function(){
  1575. return this;
  1576. });
  1577. __getset(0,__proto,'asTextInput',function(){
  1578. return this;
  1579. });
  1580. __getset(0,__proto,'displayObject',function(){
  1581. return this._displayObject;
  1582. });
  1583. __getset(0,__proto,'normalizeRotation',function(){
  1584. var rot=this._rotation % 360;
  1585. if(rot > 180)
  1586. rot=rot-360;
  1587. else if(rot <-180)
  1588. rot=360+rot;
  1589. return rot;
  1590. });
  1591. __getset(0,__proto,'pivotY',function(){
  1592. return this._pivotY;
  1593. },function(value){
  1594. this.setPivot(this._pivotX,value);
  1595. });
  1596. __getset(0,__proto,'touchable',function(){
  1597. return this._touchable;
  1598. },function(value){
  1599. if(this._touchable!=value){
  1600. this._touchable=value;
  1601. this.updateGear(3);
  1602. if(((this instanceof fairygui.GImage ))|| ((this instanceof fairygui.GMovieClip ))
  1603. || ((this instanceof fairygui.GTextField ))&& !((this instanceof fairygui.GTextInput ))&& !((this instanceof fairygui.GRichTextField )))
  1604. return;
  1605. if(this._displayObject !=null)
  1606. this._displayObject.mouseEnabled=this._touchable;
  1607. }
  1608. });
  1609. __getset(0,__proto,'alpha',function(){
  1610. return this._alpha;
  1611. },function(value){
  1612. if(this._alpha!=value){
  1613. this._alpha=value;
  1614. this.handleAlphaChanged();
  1615. this.updateGear(3);
  1616. }
  1617. });
  1618. __getset(0,__proto,'grayed',function(){
  1619. return this._grayed;
  1620. },function(value){
  1621. if(this._grayed !=value){
  1622. this._grayed=value;
  1623. this.handleGrayedChanged();
  1624. this.updateGear(3);
  1625. }
  1626. });
  1627. __getset(0,__proto,'dragBounds',function(){
  1628. return this._dragBounds;
  1629. },function(value){
  1630. this._dragBounds=value;
  1631. });
  1632. __getset(0,__proto,'asProgress',function(){
  1633. return this;
  1634. });
  1635. __getset(0,__proto,'enabled',function(){
  1636. return !this._grayed && this._touchable;
  1637. },function(value){
  1638. this.grayed=!value;
  1639. this.touchable=value;
  1640. });
  1641. __getset(0,__proto,'sortingOrder',function(){
  1642. return this._sortingOrder;
  1643. },function(value){
  1644. if (value < 0)
  1645. value=0;
  1646. if (this._sortingOrder !=value){
  1647. var old=this._sortingOrder;
  1648. this._sortingOrder=value;
  1649. if (this._parent !=null)
  1650. this._parent.childSortingOrderChanged(this,old,this._sortingOrder);
  1651. }
  1652. });
  1653. __getset(0,__proto,'visible',function(){
  1654. return this._visible;
  1655. },function(value){
  1656. if (this._visible !=value){
  1657. this._visible=value;
  1658. this.handleVisibleChanged();
  1659. if (this._parent)
  1660. this._parent.setBoundsChangedFlag();
  1661. }
  1662. });
  1663. __getset(0,__proto,'internalVisible',function(){
  1664. return this._internalVisible && (!this._group || this._group.internalVisible)
  1665. && !this._displayObject._cacheStyle.maskParent;
  1666. });
  1667. __getset(0,__proto,'icon',function(){
  1668. return null;
  1669. },function(value){
  1670. });
  1671. __getset(0,__proto,'internalVisible2',function(){
  1672. return this._visible && (!this._group || this._group.internalVisible2);
  1673. });
  1674. __getset(0,__proto,'asGraph',function(){
  1675. return this;
  1676. });
  1677. __getset(0,__proto,'gearSize',function(){
  1678. return (this.getGear(2));
  1679. });
  1680. __getset(0,__proto,'focusable',function(){
  1681. return this._focusable;
  1682. },function(value){
  1683. this._focusable=value;
  1684. });
  1685. __getset(0,__proto,'focused',function(){
  1686. return this.root.focus==this;
  1687. });
  1688. __getset(0,__proto,'tooltips',function(){
  1689. return this._tooltips;
  1690. },function(value){
  1691. if(this._tooltips){
  1692. this.off("mouseover",this,this.__rollOver);
  1693. this.off("mouseout",this,this.__rollOut);
  1694. }
  1695. this._tooltips=value;
  1696. if(this._tooltips){
  1697. this.on("mouseover",this,this.__rollOver);
  1698. this.on("mouseout",this,this.__rollOut);
  1699. }
  1700. });
  1701. __getset(0,__proto,'dragging',function(){
  1702. return fairygui.GObject.draggingObject==this;
  1703. });
  1704. __getset(0,__proto,'group',function(){
  1705. return this._group;
  1706. },function(value){
  1707. if (this._group !=value){
  1708. if (this._group !=null)
  1709. this._group.setBoundsChangedFlag(true);
  1710. this._group=value;
  1711. if (this._group !=null)
  1712. this._group.setBoundsChangedFlag(true);
  1713. }
  1714. });
  1715. __getset(0,__proto,'filters',function(){
  1716. return this._displayObject.filters;
  1717. },function(value){
  1718. this._displayObject.filters=value;
  1719. });
  1720. __getset(0,__proto,'inContainer',function(){
  1721. return this._displayObject !=null && this._displayObject.parent !=null;
  1722. });
  1723. __getset(0,__proto,'resourceURL',function(){
  1724. if (this.packageItem !=null)
  1725. return "ui://"+this.packageItem.owner.id+this.packageItem.id;
  1726. else
  1727. return null;
  1728. });
  1729. __getset(0,__proto,'onStage',function(){
  1730. return this._displayObject !=null && this._displayObject.stage !=null;
  1731. });
  1732. __getset(0,__proto,'root',function(){
  1733. if((this instanceof fairygui.GRoot ))
  1734. return (this);
  1735. var p=this._parent;
  1736. while (p){
  1737. if ((p instanceof fairygui.GRoot ))
  1738. return (p);
  1739. p=p.parent;
  1740. }
  1741. return GRoot.inst;
  1742. });
  1743. __getset(0,__proto,'gearLook',function(){
  1744. return (this.getGear(3));
  1745. });
  1746. __getset(0,__proto,'asCom',function(){
  1747. return this;
  1748. });
  1749. __getset(0,__proto,'relations',function(){
  1750. return this._relations;
  1751. });
  1752. __getset(0,__proto,'parent',function(){
  1753. return this._parent;
  1754. },function(val){
  1755. this._parent=val;
  1756. });
  1757. __getset(0,__proto,'asLabel',function(){
  1758. return this;
  1759. });
  1760. __getset(0,__proto,'asImage',function(){
  1761. return this;
  1762. });
  1763. __getset(0,__proto,'asTextField',function(){
  1764. return this;
  1765. });
  1766. __getset(0,__proto,'asGroup',function(){
  1767. return this;
  1768. });
  1769. __getset(0,__proto,'asRichTextField',function(){
  1770. return this;
  1771. });
  1772. __getset(0,__proto,'asList',function(){
  1773. return this;
  1774. });
  1775. __getset(0,__proto,'asSlider',function(){
  1776. return this;
  1777. });
  1778. __getset(0,__proto,'asComboBox',function(){
  1779. return this;
  1780. });
  1781. __getset(0,__proto,'asMovieClip',function(){
  1782. return this;
  1783. });
  1784. __getset(0,__proto,'text',function(){
  1785. return null;
  1786. },function(value){
  1787. });
  1788. GObject.cast=function(sprite){
  1789. return (sprite["$owner"]);
  1790. }
  1791. GObject.draggingObject=null;
  1792. GObject._gInstanceCounter=0;
  1793. GObject.grayFilter=null;
  1794. GObject.sDraggingQuery=false;
  1795. GObject.sUpdateInDragging=false;
  1796. __static(GObject,
  1797. ['sGlobalDragStart',function(){return this.sGlobalDragStart=new Point();},'sGlobalRect',function(){return this.sGlobalRect=new Rectangle();},'sHelperPoint',function(){return this.sHelperPoint=new Point();},'sDragHelperRect',function(){return this.sDragHelperRect=new Rectangle();}
  1798. ]);
  1799. return GObject;
  1800. })()
  1801. //class fairygui.gears.GearBase
  1802. var GearBase=(function(){
  1803. function GearBase(owner){
  1804. this._owner=null;
  1805. this._controller=null;
  1806. this._tweenConfig=null;
  1807. this._owner=owner;
  1808. }
  1809. __class(GearBase,'fairygui.gears.GearBase');
  1810. var __proto=GearBase.prototype;
  1811. __proto.setup=function(buffer){
  1812. this._controller=this._owner.parent.getControllerAt(buffer.getInt16());
  1813. this.init();
  1814. var cnt=0;
  1815. var i=0;
  1816. var page;
  1817. if ((this instanceof fairygui.gears.GearDisplay )){
  1818. cnt=buffer.getInt16();
  1819. var pages=[];
  1820. for (i=0;i < cnt;i++)
  1821. pages[i]=buffer.readS();
  1822. (this).pages=pages;
  1823. }
  1824. else{
  1825. cnt=buffer.getInt16();
  1826. for (i=0;i < cnt;i++){
  1827. page=buffer.readS();
  1828. if (page==null)
  1829. continue ;
  1830. this.addStatus(page,buffer);
  1831. }
  1832. if (buffer.readBool())
  1833. this.addStatus(null,buffer);
  1834. }
  1835. if (buffer.readBool()){
  1836. this._tweenConfig=new GearTweenConfig();
  1837. this._tweenConfig.easeType=buffer.readByte();
  1838. this._tweenConfig.duration=buffer.getFloat32();
  1839. this._tweenConfig.delay=buffer.getFloat32();
  1840. }
  1841. }
  1842. __proto.updateFromRelations=function(dx,dy){}
  1843. __proto.addStatus=function(pageId,buffer){}
  1844. __proto.init=function(){}
  1845. __proto.apply=function(){}
  1846. __proto.updateState=function(){}
  1847. __getset(0,__proto,'controller',function(){
  1848. return this._controller;
  1849. },function(val){
  1850. if (val !=this._controller){
  1851. this._controller=val;
  1852. if(this._controller)
  1853. this.init();
  1854. }
  1855. });
  1856. __getset(0,__proto,'tweenConfig',function(){
  1857. if(this._tweenConfig==null)
  1858. this._tweenConfig=new GearTweenConfig();
  1859. return this._tweenConfig;
  1860. });
  1861. GearBase.disableAllTweenEffect=false;
  1862. return GearBase;
  1863. })()
  1864. //class fairygui.gears.GearTweenConfig
  1865. var GearTweenConfig=(function(){
  1866. function GearTweenConfig(){
  1867. this.tween=false;
  1868. this.easeType=0;
  1869. this.duration=NaN;
  1870. this.delay=NaN;
  1871. this._displayLockToken=NaN;
  1872. this._tweener=null;
  1873. this.tween=true;
  1874. this.easeType=5;
  1875. this.duration=0.3;
  1876. this.delay=0;
  1877. }
  1878. __class(GearTweenConfig,'fairygui.gears.GearTweenConfig');
  1879. return GearTweenConfig;
  1880. })()
  1881. //class fairygui.GObjectPool
  1882. var GObjectPool=(function(){
  1883. function GObjectPool(){
  1884. this._pool=null;
  1885. this._count=0;
  1886. this._pool={};
  1887. }
  1888. __class(GObjectPool,'fairygui.GObjectPool');
  1889. var __proto=GObjectPool.prototype;
  1890. __proto.clear=function(){
  1891. for (var i1 in this._pool){
  1892. var arr=this._pool[i1];
  1893. var cnt=arr.length;
  1894. for (var i=0;i < cnt;i++)
  1895. arr[i].dispose();
  1896. }
  1897. this._pool={};
  1898. this._count=0;
  1899. }
  1900. __proto.getObject=function(url){
  1901. url=UIPackage.normalizeURL(url);
  1902. if(url==null)
  1903. return null;
  1904. var arr=this._pool[url];
  1905. if (arr !=null && arr.length>0){
  1906. this._count--;
  1907. return arr.shift();
  1908. };
  1909. var child=UIPackage.createObjectFromURL(url);
  1910. return child;
  1911. }
  1912. __proto.returnObject=function(obj){
  1913. var url=obj.resourceURL;
  1914. if (!url)
  1915. return;
  1916. var arr=this._pool[url];
  1917. if (arr==null){
  1918. arr=[];
  1919. this._pool[url]=arr;
  1920. }
  1921. this._count++;
  1922. arr.push(obj);
  1923. }
  1924. __getset(0,__proto,'count',function(){
  1925. return this._count;
  1926. });
  1927. return GObjectPool;
  1928. })()
  1929. /**
  1930. *Use for GGroup.layout
  1931. */
  1932. //class fairygui.GroupLayoutType
  1933. var GroupLayoutType=(function(){
  1934. function GroupLayoutType(){}
  1935. __class(GroupLayoutType,'fairygui.GroupLayoutType');
  1936. GroupLayoutType.None=0;
  1937. GroupLayoutType.Horizontal=1;
  1938. GroupLayoutType.Vertical=2;
  1939. return GroupLayoutType;
  1940. })()
  1941. /**
  1942. *Use for GList.layout
  1943. */
  1944. //class fairygui.ListLayoutType
  1945. var ListLayoutType=(function(){
  1946. function ListLayoutType(){}
  1947. __class(ListLayoutType,'fairygui.ListLayoutType');
  1948. ListLayoutType.SingleColumn=0;
  1949. ListLayoutType.SingleRow=1;
  1950. ListLayoutType.FlowHorizontal=2;
  1951. ListLayoutType.FlowVertical=3;
  1952. ListLayoutType.Pagination=4;
  1953. return ListLayoutType;
  1954. })()
  1955. /**
  1956. *Use for GList.selectionMode
  1957. */
  1958. //class fairygui.ListSelectionMode
  1959. var ListSelectionMode=(function(){
  1960. function ListSelectionMode(){}
  1961. __class(ListSelectionMode,'fairygui.ListSelectionMode');
  1962. ListSelectionMode.Single=0;
  1963. ListSelectionMode.Multiple=1;
  1964. ListSelectionMode.Multiple_SingleClick=2;
  1965. ListSelectionMode.None=3;
  1966. return ListSelectionMode;
  1967. })()
  1968. /**
  1969. *Use for GLoader.fill
  1970. */
  1971. //class fairygui.LoaderFillType
  1972. var LoaderFillType=(function(){
  1973. function LoaderFillType(){}
  1974. __class(LoaderFillType,'fairygui.LoaderFillType');
  1975. LoaderFillType.None=0;
  1976. LoaderFillType.Scale=1;
  1977. LoaderFillType.ScaleMatchHeight=2;
  1978. LoaderFillType.ScaleMatchWidth=3;
  1979. LoaderFillType.ScaleFree=4;
  1980. LoaderFillType.ScaleNoBorder=5;
  1981. return LoaderFillType;
  1982. })()
  1983. //class fairygui.Margin
  1984. var Margin=(function(){
  1985. function Margin(){
  1986. this.left=0;
  1987. this.right=0;
  1988. this.top=0;
  1989. this.bottom=0;
  1990. }
  1991. __class(Margin,'fairygui.Margin');
  1992. var __proto=Margin.prototype;
  1993. __proto.copy=function(source){
  1994. this.top=source.top;
  1995. this.bottom=source.bottom;
  1996. this.left=source.left;
  1997. this.right=source.right;
  1998. }
  1999. return Margin;
  2000. })()
  2001. /**
  2002. *Use for UIObjectFactory.newObject
  2003. */
  2004. //class fairygui.ObjectType
  2005. var ObjectType=(function(){
  2006. function ObjectType(){}
  2007. __class(ObjectType,'fairygui.ObjectType');
  2008. ObjectType.Image=0;
  2009. ObjectType.MovieClip=1;
  2010. ObjectType.Swf=2;
  2011. ObjectType.Graph=3;
  2012. ObjectType.Loader=4;
  2013. ObjectType.Group=5;
  2014. ObjectType.Text=6;
  2015. ObjectType.RichText=7;
  2016. ObjectType.InputText=8;
  2017. ObjectType.Component=9;
  2018. ObjectType.List=10;
  2019. ObjectType.Label=11;
  2020. ObjectType.Button=12;
  2021. ObjectType.ComboBox=13;
  2022. ObjectType.ProgressBar=14;
  2023. ObjectType.Slider=15;
  2024. ObjectType.ScrollBar=16;
  2025. return ObjectType;
  2026. })()
  2027. /**
  2028. *Use for GComponent.overflow
  2029. */
  2030. //class fairygui.OverflowType
  2031. var OverflowType=(function(){
  2032. function OverflowType(){}
  2033. __class(OverflowType,'fairygui.OverflowType');
  2034. OverflowType.Visible=0;
  2035. OverflowType.Hidden=1;
  2036. OverflowType.Scroll=2;
  2037. return OverflowType;
  2038. })()
  2039. //class fairygui.PackageItem
  2040. var PackageItem=(function(){
  2041. function PackageItem(){
  2042. this.owner=null;
  2043. this.type=0;
  2044. this.objectType=0;
  2045. this.id=null;
  2046. this.name=null;
  2047. this.width=0;
  2048. this.height=0;
  2049. this.file=null;
  2050. this.decoded=false;
  2051. this.rawData=null;
  2052. //image
  2053. this.scale9Grid=null;
  2054. this.scaleByTile=false;
  2055. this.tileGridIndice=0;
  2056. this.smoothing=false;
  2057. this.texture=null;
  2058. this.pixelHitTestData=null;
  2059. //movieclip
  2060. this.interval=0;
  2061. this.repeatDelay=0;
  2062. this.swing=false;
  2063. this.frames=null;
  2064. //componenet
  2065. this.extensionType=null;
  2066. //font
  2067. this.bitmapFont=null;
  2068. }
  2069. __class(PackageItem,'fairygui.PackageItem');
  2070. var __proto=PackageItem.prototype;
  2071. __proto.load=function(){
  2072. return this.owner.getItemAsset(this);
  2073. }
  2074. __proto.toString=function(){
  2075. return this.name;
  2076. }
  2077. return PackageItem;
  2078. })()
  2079. //class fairygui.PackageItemType
  2080. var PackageItemType=(function(){
  2081. function PackageItemType(){}
  2082. __class(PackageItemType,'fairygui.PackageItemType');
  2083. PackageItemType.Image=0;
  2084. PackageItemType.MovieClip=1;
  2085. PackageItemType.Sound=2;
  2086. PackageItemType.Component=3;
  2087. PackageItemType.Atlas=4;
  2088. PackageItemType.Font=5;
  2089. PackageItemType.Swf=6;
  2090. PackageItemType.Misc=7;
  2091. PackageItemType.Unknown=8;
  2092. return PackageItemType;
  2093. })()
  2094. //class fairygui.PageOption
  2095. var PageOption=(function(){
  2096. function PageOption(){
  2097. this._controller=null;
  2098. this._id=null;
  2099. }
  2100. __class(PageOption,'fairygui.PageOption');
  2101. var __proto=PageOption.prototype;
  2102. __proto.clear=function(){
  2103. this._id=null;
  2104. }
  2105. __getset(0,__proto,'controller',null,function(val){
  2106. this._controller=val;
  2107. });
  2108. __getset(0,__proto,'index',function(){
  2109. if (this._id)
  2110. return this._controller.getPageIndexById(this._id);
  2111. else
  2112. return-1;
  2113. },function(pageIndex){
  2114. this._id=this._controller.getPageId(pageIndex);
  2115. });
  2116. __getset(0,__proto,'name',function(){
  2117. if (this._id)
  2118. return this._controller.getPageNameById(this._id);
  2119. else
  2120. return null;
  2121. },function(pageName){
  2122. this._id=this._controller.getPageIdByName(pageName);
  2123. });
  2124. __getset(0,__proto,'id',function(){
  2125. return this._id;
  2126. },function(id){
  2127. this._id=id;
  2128. });
  2129. return PageOption;
  2130. })()
  2131. /**
  2132. *Use for GComboBox.popupDirection
  2133. */
  2134. //class fairygui.PopupDirection
  2135. var PopupDirection=(function(){
  2136. function PopupDirection(){}
  2137. __class(PopupDirection,'fairygui.PopupDirection');
  2138. PopupDirection.Auto=0;
  2139. PopupDirection.Up=1;
  2140. PopupDirection.Down=2;
  2141. return PopupDirection;
  2142. })()
  2143. //class fairygui.PopupMenu
  2144. var PopupMenu=(function(){
  2145. function PopupMenu(resourceURL){
  2146. this._contentPane=null;
  2147. this._list=null;
  2148. if(!resourceURL){
  2149. resourceURL=UIConfig$1.popupMenu;
  2150. if(!resourceURL)
  2151. throw "UIConfig.popupMenu not defined";
  2152. }
  2153. this._contentPane=UIPackage.createObjectFromURL(resourceURL).asCom;
  2154. this._contentPane.on("display",this,this.__addedToStage);
  2155. this._list=(this._contentPane.getChild("list"));
  2156. this._list.removeChildrenToPool();
  2157. this._list.addRelation(this._contentPane,14);
  2158. this._list.removeRelation(this._contentPane,15);
  2159. this._contentPane.addRelation(this._list,15);
  2160. this._list.on("fui_click_item",this,this.__clickItem);
  2161. }
  2162. __class(PopupMenu,'fairygui.PopupMenu');
  2163. var __proto=PopupMenu.prototype;
  2164. __proto.dispose=function(){
  2165. this._contentPane.dispose();
  2166. }
  2167. __proto.addItem=function(caption,handler){
  2168. var item=this._list.addItemFromPool().asButton;
  2169. item.title=caption;
  2170. item.data=handler;
  2171. item.grayed=false;
  2172. var c=item.getController("checked");
  2173. if(c !=null)
  2174. c.selectedIndex=0;
  2175. return item;
  2176. }
  2177. __proto.addItemAt=function(caption,index,handler){
  2178. var item=this._list.getFromPool().asButton;
  2179. this._list.addChildAt(item,index);
  2180. item.title=caption;
  2181. item.data=handler;
  2182. item.grayed=false;
  2183. var c=item.getController("checked");
  2184. if(c !=null)
  2185. c.selectedIndex=0;
  2186. return item;
  2187. }
  2188. __proto.addSeperator=function(){
  2189. if(UIConfig$1.popupMenu_seperator==null)
  2190. throw "UIConfig.popupMenu_seperator not defined";
  2191. this.list.addItemFromPool(UIConfig$1.popupMenu_seperator);
  2192. }
  2193. __proto.getItemName=function(index){
  2194. var item=this._list.getChildAt(index);
  2195. return item.name;
  2196. }
  2197. __proto.setItemText=function(name,caption){
  2198. var item=this._list.getChild(name).asButton;
  2199. item.title=caption;
  2200. }
  2201. __proto.setItemVisible=function(name,visible){
  2202. var item=this._list.getChild(name).asButton;
  2203. if(item.visible !=visible){
  2204. item.visible=visible;
  2205. this._list.setBoundsChangedFlag();
  2206. }
  2207. }
  2208. __proto.setItemGrayed=function(name,grayed){
  2209. var item=this._list.getChild(name).asButton;
  2210. item.grayed=grayed;
  2211. }
  2212. __proto.setItemCheckable=function(name,checkable){
  2213. var item=this._list.getChild(name).asButton;
  2214. var c=item.getController("checked");
  2215. if(c !=null){
  2216. if(checkable){
  2217. if(c.selectedIndex==0)
  2218. c.selectedIndex=1;
  2219. }
  2220. else
  2221. c.selectedIndex=0;
  2222. }
  2223. }
  2224. __proto.setItemChecked=function(name,checked){
  2225. var item=this._list.getChild(name).asButton;
  2226. var c=item.getController("checked");
  2227. if(c !=null)
  2228. c.selectedIndex=checked?2:1;
  2229. }
  2230. __proto.isItemChecked=function(name){
  2231. var item=this._list.getChild(name).asButton;
  2232. var c=item.getController("checked");
  2233. if(c !=null)
  2234. return c.selectedIndex==2;
  2235. else
  2236. return false;
  2237. }
  2238. __proto.removeItem=function(name){
  2239. var item=this._list.getChild(name);
  2240. if(item !=null){
  2241. var index=this._list.getChildIndex(item);
  2242. this._list.removeChildToPoolAt(index);
  2243. return true;
  2244. }
  2245. else
  2246. return false;
  2247. }
  2248. __proto.clearItems=function(){
  2249. this._list.removeChildrenToPool();
  2250. }
  2251. __proto.show=function(target,downward){
  2252. var r=target !=null?target.root:GRoot.inst;
  2253. r.showPopup(this.contentPane,((target instanceof fairygui.GRoot ))?null:target,downward);
  2254. }
  2255. __proto.__clickItem=function(itemObject){
  2256. Laya.timer.once(100,this,this.__clickItem2,[itemObject]);
  2257. }
  2258. __proto.__clickItem2=function(itemObject){
  2259. if(!((itemObject instanceof fairygui.GButton )))
  2260. return;
  2261. if(itemObject.grayed){
  2262. this._list.selectedIndex=-1;
  2263. return;
  2264. };
  2265. var c=itemObject.asCom.getController("checked");
  2266. if(c !=null && c.selectedIndex !=0){
  2267. if(c.selectedIndex==1)
  2268. c.selectedIndex=2;
  2269. else
  2270. c.selectedIndex=1;
  2271. };
  2272. var r=(this._contentPane.parent);
  2273. r.hidePopup(this.contentPane);
  2274. if(itemObject.data !=null){
  2275. (itemObject.data).run();
  2276. }
  2277. }
  2278. __proto.__addedToStage=function(){
  2279. this._list.selectedIndex=-1;
  2280. this._list.resizeToFit(100000,10);
  2281. }
  2282. __getset(0,__proto,'itemCount',function(){
  2283. return this._list.numChildren;
  2284. });
  2285. __getset(0,__proto,'contentPane',function(){
  2286. return this._contentPane;
  2287. });
  2288. __getset(0,__proto,'list',function(){
  2289. return this._list;
  2290. });
  2291. return PopupMenu;
  2292. })()
  2293. /**
  2294. *Use for GProgressBar.titleType and GSlider.titleType
  2295. */
  2296. //class fairygui.ProgressTitleType
  2297. var ProgressTitleType=(function(){
  2298. function ProgressTitleType(){}
  2299. __class(ProgressTitleType,'fairygui.ProgressTitleType');
  2300. ProgressTitleType.Percent=0;
  2301. ProgressTitleType.ValueAndMax=1;
  2302. ProgressTitleType.Value=2;
  2303. ProgressTitleType.Max=3;
  2304. return ProgressTitleType;
  2305. })()
  2306. //class fairygui.RelationItem
  2307. var RelationItem=(function(){
  2308. var RelationDef;
  2309. function RelationItem(owner){
  2310. this._owner=null;
  2311. this._target=null;
  2312. this._defs=null;
  2313. this._targetX=NaN;
  2314. this._targetY=NaN;
  2315. this._targetWidth=NaN;
  2316. this._targetHeight=NaN;
  2317. this._owner=owner;
  2318. this._defs=[];
  2319. }
  2320. __class(RelationItem,'fairygui.RelationItem');
  2321. var __proto=RelationItem.prototype;
  2322. __proto.add=function(relationType,usePercent){
  2323. if (relationType==24){
  2324. this.add(14,usePercent);
  2325. this.add(15,usePercent);
  2326. return;
  2327. };
  2328. var cnt=this._defs.length;
  2329. for(var i=0;i<cnt;i++){
  2330. if (this._defs[i].type==relationType)
  2331. return;
  2332. }
  2333. this.internalAdd(relationType,usePercent);
  2334. }
  2335. __proto.internalAdd=function(relationType,usePercent){
  2336. if (relationType==24){
  2337. this.internalAdd(14,usePercent);
  2338. this.internalAdd(15,usePercent);
  2339. return;
  2340. };
  2341. var info=new RelationDef();
  2342. info.percent=usePercent;
  2343. info.type=relationType;
  2344. info.axis=(relationType <=6 || relationType==14 || relationType >=16 && relationType <=19)? 0 :1;
  2345. this._defs.push(info);
  2346. if (usePercent || relationType==1 || relationType==3 || relationType==5
  2347. || relationType==8 || relationType==10 || relationType==12)
  2348. this._owner.pixelSnapping=true;
  2349. }
  2350. __proto.remove=function(relationType){
  2351. if (relationType==24){
  2352. this.remove(14);
  2353. this.remove(15);
  2354. return;
  2355. };
  2356. var dc=this._defs.length;
  2357. for (var k=0;k < dc;k++){
  2358. if (this._defs[k].type==relationType){
  2359. this._defs.splice(k,1);
  2360. break ;
  2361. }
  2362. }
  2363. }
  2364. __proto.copyFrom=function(source){
  2365. this.target=source.target;
  2366. this._defs.length=0;
  2367. var cnt=source._defs.length;
  2368. for(var i=0;i<cnt;i++){
  2369. var info=source._defs[i];
  2370. var info2=new RelationDef();
  2371. info2.copyFrom(info);
  2372. this._defs.push(info2);
  2373. }
  2374. }
  2375. __proto.dispose=function(){
  2376. if (this._target !=null){
  2377. this.releaseRefTarget(this._target);
  2378. this._target=null;
  2379. }
  2380. }
  2381. __proto.applyOnSelfResized=function(dWidth,dHeight,applyPivot){
  2382. var cnt=this._defs.length;
  2383. if(cnt==0)
  2384. return;
  2385. var ox=this._owner.x;
  2386. var oy=this._owner.y;
  2387. for (var i=0;i < cnt;i++){
  2388. var info=this._defs[i];
  2389. switch (info.type){
  2390. case 3:
  2391. this._owner.x-=(0.5-(applyPivot ? this._owner.pivotX :0))*dWidth;
  2392. break ;
  2393. case 5:
  2394. case 4:
  2395. case 6:
  2396. this._owner.x-=(1-(applyPivot ? this._owner.pivotX :0))*dWidth;
  2397. break ;
  2398. case 10:
  2399. this._owner.y-=(0.5-(applyPivot ? this._owner.pivotY :0))*dHeight;
  2400. break ;
  2401. case 12:
  2402. case 11:
  2403. case 13:
  2404. this._owner.y-=(1-(applyPivot ? this._owner.pivotY :0))*dHeight;
  2405. break ;
  2406. }
  2407. }
  2408. if (ox!=this._owner.x || oy!=this._owner.y){
  2409. ox=this._owner.x-ox;
  2410. oy=this._owner.y-oy;
  2411. this._owner.updateGearFromRelations(1,ox,oy);
  2412. if (this._owner.parent !=null && this._owner.parent._transitions.length > 0){
  2413. cnt=this._owner.parent._transitions.length;
  2414. for(var j=0;j<cnt;j++){
  2415. var trans=this._owner.parent._transitions[j];
  2416. trans.updateFromRelations(this._owner.id,ox,oy);
  2417. }
  2418. }
  2419. }
  2420. }
  2421. __proto.applyOnXYChanged=function(info,dx,dy){
  2422. var tmp=NaN;
  2423. switch (info.type){
  2424. case 0:
  2425. case 1:
  2426. case 2:
  2427. case 3:
  2428. case 4:
  2429. case 5:
  2430. case 6:
  2431. this._owner.x+=dx;
  2432. break ;
  2433. case 7:
  2434. case 8:
  2435. case 9:
  2436. case 10:
  2437. case 11:
  2438. case 12:
  2439. case 13:
  2440. this._owner.y+=dy;
  2441. break ;
  2442. case 14:
  2443. case 15:
  2444. break ;
  2445. case 16:
  2446. case 17:
  2447. tmp=this._owner.xMin;
  2448. this._owner.width=this._owner._rawWidth-dx;
  2449. this._owner.xMin=tmp+dx;
  2450. break ;
  2451. case 18:
  2452. case 19:
  2453. tmp=this._owner.xMin;
  2454. this._owner.width=this._owner._rawWidth+dx;
  2455. this._owner.xMin=tmp;
  2456. break ;
  2457. case 20:
  2458. case 21:
  2459. tmp=this._owner.yMin;
  2460. this._owner.height=this._owner._rawHeight-dy;
  2461. this._owner.yMin=tmp+dy;
  2462. break ;
  2463. case 22:
  2464. case 23:
  2465. tmp=this._owner.yMin;
  2466. this._owner.height=this._owner._rawHeight+dy;
  2467. this._owner.yMin=tmp;
  2468. break ;
  2469. }
  2470. }
  2471. __proto.applyOnSizeChanged=function(info){
  2472. var pos=0,pivot=0,delta=0;
  2473. var v=NaN,tmp=NaN;
  2474. if (info.axis==0){
  2475. if (this._target !=this._owner.parent){
  2476. pos=this._target.x;
  2477. if (this._target.pivotAsAnchor)
  2478. pivot=this._target.pivotX;
  2479. }
  2480. if (info.percent){
  2481. if (this._targetWidth !=0)
  2482. delta=this._target._width / this._targetWidth;
  2483. }
  2484. else
  2485. delta=this._target._width-this._targetWidth;
  2486. }
  2487. else{
  2488. if (this._target !=this._owner.parent){
  2489. pos=this._target.y;
  2490. if (this._target.pivotAsAnchor)
  2491. pivot=this._target.pivotY;
  2492. }
  2493. if (info.percent){
  2494. if (this._targetHeight !=0)
  2495. delta=this._target._height / this._targetHeight;
  2496. }
  2497. else
  2498. delta=this._target._height-this._targetHeight;
  2499. }
  2500. switch (info.type){
  2501. case 0:
  2502. if (info.percent)
  2503. this._owner.xMin=pos+(this._owner.xMin-pos)*delta;
  2504. else if (pivot !=0)
  2505. this._owner.x+=delta *(-pivot);
  2506. break ;
  2507. case 1:
  2508. if (info.percent)
  2509. this._owner.xMin=pos+(this._owner.xMin-pos)*delta;
  2510. else
  2511. this._owner.x+=delta *(0.5-pivot);
  2512. break ;
  2513. case 2:
  2514. if (info.percent)
  2515. this._owner.xMin=pos+(this._owner.xMin-pos)*delta;
  2516. else
  2517. this._owner.x+=delta *(1-pivot);
  2518. break ;
  2519. case 3:
  2520. if (info.percent)
  2521. this._owner.xMin=pos+(this._owner.xMin+this._owner._rawWidth *0.5-pos)*delta-this._owner._rawWidth *0.5;
  2522. else
  2523. this._owner.x+=delta *(0.5-pivot);
  2524. break ;
  2525. case 4:
  2526. if (info.percent)
  2527. this._owner.xMin=pos+(this._owner.xMin+this._owner._rawWidth-pos)*delta-this._owner._rawWidth;
  2528. else if (pivot !=0)
  2529. this._owner.x+=delta *(-pivot);
  2530. break ;
  2531. case 5:
  2532. if (info.percent)
  2533. this._owner.xMin=pos+(this._owner.xMin+this._owner._rawWidth-pos)*delta-this._owner._rawWidth;
  2534. else
  2535. this._owner.x+=delta *(0.5-pivot);
  2536. break ;
  2537. case 6:
  2538. if (info.percent)
  2539. this._owner.xMin=pos+(this._owner.xMin+this._owner._rawWidth-pos)*delta-this._owner._rawWidth;
  2540. else
  2541. this._owner.x+=delta *(1-pivot);
  2542. break ;
  2543. case 7:
  2544. if (info.percent)
  2545. this._owner.yMin=pos+(this._owner.yMin-pos)*delta;
  2546. else if (pivot !=0)
  2547. this._owner.y+=delta *(-pivot);
  2548. break ;
  2549. case 8:
  2550. if (info.percent)
  2551. this._owner.yMin=pos+(this._owner.yMin-pos)*delta;
  2552. else
  2553. this._owner.y+=delta *(0.5-pivot);
  2554. break ;
  2555. case 9:
  2556. if (info.percent)
  2557. this._owner.yMin=pos+(this._owner.yMin-pos)*delta;
  2558. else
  2559. this._owner.y+=delta *(1-pivot);
  2560. break ;
  2561. case 10:
  2562. if (info.percent)
  2563. this._owner.yMin=pos+(this._owner.yMin+this._owner._rawHeight *0.5-pos)*delta-this._owner._rawHeight *0.5;
  2564. else
  2565. this._owner.y+=delta *(0.5-pivot);
  2566. break ;
  2567. case 11:
  2568. if (info.percent)
  2569. this._owner.yMin=pos+(this._owner.yMin+this._owner._rawHeight-pos)*delta-this._owner._rawHeight;
  2570. else if (pivot !=0)
  2571. this._owner.y+=delta *(-pivot);
  2572. break ;
  2573. case 12:
  2574. if (info.percent)
  2575. this._owner.yMin=pos+(this._owner.yMin+this._owner._rawHeight-pos)*delta-this._owner._rawHeight;
  2576. else
  2577. this._owner.y+=delta *(0.5-pivot);
  2578. break ;
  2579. case 13:
  2580. if (info.percent)
  2581. this._owner.yMin=pos+(this._owner.yMin+this._owner._rawHeight-pos)*delta-this._owner._rawHeight;
  2582. else
  2583. this._owner.y+=delta *(1-pivot);
  2584. break ;
  2585. case 14:
  2586. if (this._owner._underConstruct && this._owner==this._target.parent)
  2587. v=this._owner.sourceWidth-this._target.initWidth;
  2588. else
  2589. v=this._owner._rawWidth-this._targetWidth;
  2590. if (info.percent)
  2591. v=v *delta;
  2592. if (this._target==this._owner.parent){
  2593. if (this._owner.pivotAsAnchor){
  2594. tmp=this._owner.xMin;
  2595. this._owner.setSize(this._target._width+v,this._owner._rawHeight,true);
  2596. this._owner.xMin=tmp;
  2597. }
  2598. else
  2599. this._owner.setSize(this._target._width+v,this._owner._rawHeight,true);
  2600. }
  2601. else
  2602. this._owner.width=this._target._width+v;
  2603. break ;
  2604. case 15:
  2605. if (this._owner._underConstruct && this._owner==this._target.parent)
  2606. v=this._owner.sourceHeight-this._target.initHeight;
  2607. else
  2608. v=this._owner._rawHeight-this._targetHeight;
  2609. if (info.percent)
  2610. v=v *delta;
  2611. if (this._target==this._owner.parent){
  2612. if (this._owner.pivotAsAnchor){
  2613. tmp=this._owner.yMin;
  2614. this._owner.setSize(this._owner._rawWidth,this._target._height+v,true);
  2615. this._owner.yMin=tmp;
  2616. }
  2617. else
  2618. this._owner.setSize(this._owner._rawWidth,this._target._height+v,true);
  2619. }
  2620. else
  2621. this._owner.height=this._target._height+v;
  2622. break ;
  2623. case 16:
  2624. tmp=this._owner.xMin;
  2625. if (info.percent)
  2626. v=pos+(tmp-pos)*delta-tmp;
  2627. else
  2628. v=delta *(-pivot);
  2629. this._owner.width=this._owner._rawWidth-v;
  2630. this._owner.xMin=tmp+v;
  2631. break ;
  2632. case 17:
  2633. tmp=this._owner.xMin;
  2634. if (info.percent)
  2635. v=pos+(tmp-pos)*delta-tmp;
  2636. else
  2637. v=delta *(1-pivot);
  2638. this._owner.width=this._owner._rawWidth-v;
  2639. this._owner.xMin=tmp+v;
  2640. break ;
  2641. case 18:
  2642. tmp=this._owner.xMin;
  2643. if (info.percent)
  2644. v=pos+(tmp+this._owner._rawWidth-pos)*delta-(tmp+this._owner._rawWidth);
  2645. else
  2646. v=delta *(-pivot);
  2647. this._owner.width=this._owner._rawWidth+v;
  2648. this._owner.xMin=tmp;
  2649. break ;
  2650. case 19:
  2651. tmp=this._owner.xMin;
  2652. if (info.percent){
  2653. if (this._owner==this._target.parent){
  2654. if (this._owner._underConstruct)
  2655. this._owner.width=pos+this._target._width-this._target._width *pivot+
  2656. (this._owner.sourceWidth-pos-this._target.initWidth+this._target.initWidth *pivot)*delta;
  2657. else
  2658. this._owner.width=pos+(this._owner._rawWidth-pos)*delta;
  2659. }
  2660. else{
  2661. v=pos+(tmp+this._owner._rawWidth-pos)*delta-(tmp+this._owner._rawWidth);
  2662. this._owner.width=this._owner._rawWidth+v;
  2663. this._owner.xMin=tmp;
  2664. }
  2665. }
  2666. else{
  2667. if (this._owner==this._target.parent){
  2668. if (this._owner._underConstruct)
  2669. this._owner.width=this._owner.sourceWidth+(this._target._width-this._target.initWidth)*(1-pivot);
  2670. else
  2671. this._owner.width=this._owner._rawWidth+delta *(1-pivot);
  2672. }
  2673. else{
  2674. v=delta *(1-pivot);
  2675. this._owner.width=this._owner._rawWidth+v;
  2676. this._owner.xMin=tmp;
  2677. }
  2678. }
  2679. break ;
  2680. case 20:
  2681. tmp=this._owner.yMin;
  2682. if (info.percent)
  2683. v=pos+(tmp-pos)*delta-tmp;
  2684. else
  2685. v=delta *(-pivot);
  2686. this._owner.height=this._owner._rawHeight-v;
  2687. this._owner.yMin=tmp+v;
  2688. break ;
  2689. case 21:
  2690. tmp=this._owner.yMin;
  2691. if (info.percent)
  2692. v=pos+(tmp-pos)*delta-tmp;
  2693. else
  2694. v=delta *(1-pivot);
  2695. this._owner.height=this._owner._rawHeight-v;
  2696. this._owner.yMin=tmp+v;
  2697. break ;
  2698. case 22:
  2699. tmp=this._owner.yMin;
  2700. if (info.percent)
  2701. v=pos+(tmp+this._owner._rawHeight-pos)*delta-(tmp+this._owner._rawHeight);
  2702. else
  2703. v=delta *(-pivot);
  2704. this._owner.height=this._owner._rawHeight+v;
  2705. this._owner.yMin=tmp;
  2706. break ;
  2707. case 23:
  2708. tmp=this._owner.yMin;
  2709. if (info.percent){
  2710. if (this._owner==this._target.parent){
  2711. if (this._owner._underConstruct)
  2712. this._owner.height=pos+this._target._height-this._target._height *pivot+
  2713. (this._owner.sourceHeight-pos-this._target.initHeight+this._target.initHeight *pivot)*delta;
  2714. else
  2715. this._owner.height=pos+(this._owner._rawHeight-pos)*delta;
  2716. }
  2717. else{
  2718. v=pos+(tmp+this._owner._rawHeight-pos)*delta-(tmp+this._owner._rawHeight);
  2719. this._owner.height=this._owner._rawHeight+v;
  2720. this._owner.yMin=tmp;
  2721. }
  2722. }
  2723. else{
  2724. if (this._owner==this._target.parent){
  2725. if (this._owner._underConstruct)
  2726. this._owner.height=this._owner.sourceHeight+(this._target._height-this._target.initHeight)*(1-pivot);
  2727. else
  2728. this._owner.height=this._owner._rawHeight+delta *(1-pivot);
  2729. }
  2730. else{
  2731. v=delta *(1-pivot);
  2732. this._owner.height=this._owner._rawHeight+v;
  2733. this._owner.yMin=tmp;
  2734. }
  2735. }
  2736. break ;
  2737. }
  2738. }
  2739. __proto.addRefTarget=function(target){
  2740. if (target !=this._owner.parent)
  2741. target.on("fui_xy_changed",this,this.__targetXYChanged);
  2742. target.on("fui_size_changed",this,this.__targetSizeChanged);
  2743. target.on("fui_size_delay_change",this,this.__targetSizeWillChange);
  2744. this._targetX=this._target.x;
  2745. this._targetY=this._target.y;
  2746. this._targetWidth=this._target._width;
  2747. this._targetHeight=this._target._height;
  2748. }
  2749. __proto.releaseRefTarget=function(target){
  2750. if(target.displayObject==null)
  2751. return;
  2752. target.off("fui_xy_changed",this,this.__targetXYChanged);
  2753. target.off("fui_size_changed",this,this.__targetSizeChanged);
  2754. target.off("fui_size_delay_change",this,this.__targetSizeWillChange);
  2755. }
  2756. __proto.__targetXYChanged=function(target){
  2757. if (this._owner.relations.handling!=null || this._owner.group!=null && this._owner.group._updating){
  2758. this._targetX=this._target.x;
  2759. this._targetY=this._target.y;
  2760. return;
  2761. }
  2762. this._owner.relations.handling=target;
  2763. var ox=this._owner.x;
  2764. var oy=this._owner.y;
  2765. var dx=this._target.x-this._targetX;
  2766. var dy=this._target.y-this._targetY;
  2767. var cnt=this._defs.length;
  2768. for(var i=0;i<cnt;i++){
  2769. this.applyOnXYChanged(this._defs[i],dx,dy);
  2770. }
  2771. this._targetX=this._target.x;
  2772. this._targetY=this._target.y;
  2773. if (ox!=this._owner.x || oy!=this._owner.y){
  2774. ox=this._owner.x-ox;
  2775. oy=this._owner.y-oy;
  2776. this._owner.updateGearFromRelations(1,ox,oy);
  2777. if (this._owner.parent !=null && this._owner.parent._transitions.length > 0){
  2778. cnt=this._owner.parent._transitions.length;
  2779. for(var j=0;j<cnt;j++){
  2780. var trans=this._owner.parent._transitions[j];
  2781. trans.updateFromRelations(this._owner.id,ox,oy);
  2782. }
  2783. }
  2784. }
  2785. this._owner.relations.handling=null;
  2786. }
  2787. __proto.__targetSizeChanged=function(target){
  2788. if (this._owner.relations.handling!=null){
  2789. this._targetWidth=this._target._width;
  2790. this._targetHeight=this._target._height;
  2791. return;
  2792. }
  2793. this._owner.relations.handling=target;
  2794. var ox=this._owner.x;
  2795. var oy=this._owner.y;
  2796. var ow=this._owner._rawWidth;
  2797. var oh=this._owner._rawHeight;
  2798. var cnt=this._defs.length;
  2799. for(var i=0;i<cnt;i++){
  2800. this.applyOnSizeChanged(this._defs[i]);
  2801. }
  2802. this._targetWidth=this._target._width;
  2803. this._targetHeight=this._target._height;
  2804. if (ox!=this._owner.x || oy!=this._owner.y){
  2805. ox=this._owner.x-ox;
  2806. oy=this._owner.y-oy;
  2807. this._owner.updateGearFromRelations(1,ox,oy);
  2808. if (this._owner.parent !=null && this._owner.parent._transitions.length > 0){
  2809. cnt=this._owner.parent._transitions.length;
  2810. for(var j=0;j<cnt;j++){
  2811. var trans=this._owner.parent._transitions[j];
  2812. trans.updateFromRelations(this._owner.id,ox,oy);
  2813. }
  2814. }
  2815. }
  2816. if (ow!=this._owner._rawWidth || oh!=this._owner._rawHeight){
  2817. ow=this._owner._rawWidth-ow;
  2818. oh=this._owner._rawHeight-oh;
  2819. this._owner.updateGearFromRelations(2,ow,oh);
  2820. }
  2821. this._owner.relations.handling=null;
  2822. }
  2823. __proto.__targetSizeWillChange=function(target){
  2824. this._owner.relations.sizeDirty=true;
  2825. }
  2826. __getset(0,__proto,'owner',function(){
  2827. return this._owner;
  2828. });
  2829. __getset(0,__proto,'target',function(){
  2830. return this._target;
  2831. },function(value){
  2832. if(this._target!=value){
  2833. if(this._target)
  2834. this.releaseRefTarget(this._target);
  2835. this._target=value;
  2836. if(this._target)
  2837. this.addRefTarget(this._target);
  2838. }
  2839. });
  2840. __getset(0,__proto,'isEmpty',function(){
  2841. return this._defs.length==0;
  2842. });
  2843. RelationItem.__init$=function(){
  2844. //class RelationDef
  2845. RelationDef=(function(){
  2846. function RelationDef(){
  2847. this.percent=false;
  2848. this.type=0;
  2849. this.axis=0;
  2850. }
  2851. __class(RelationDef,'');
  2852. var __proto=RelationDef.prototype;
  2853. __proto.copyFrom=function(source){
  2854. this.percent=source.percent;
  2855. this.type=source.type;
  2856. this.axis=source.axis;
  2857. }
  2858. return RelationDef;
  2859. })()
  2860. }
  2861. return RelationItem;
  2862. })()
  2863. //class fairygui.Relations
  2864. var Relations=(function(){
  2865. function Relations(owner){
  2866. this._owner=null;
  2867. this._items=null;
  2868. this.handling=null;
  2869. this.sizeDirty=false;
  2870. this._owner=owner;
  2871. this._items=[];
  2872. }
  2873. __class(Relations,'fairygui.Relations');
  2874. var __proto=Relations.prototype;
  2875. __proto.add=function(target,relationType,usePercent){
  2876. (usePercent===void 0)&& (usePercent=false);
  2877. var length=this._items.length;
  2878. for (var i=0;i < length;i++){
  2879. var item=this._items[i];
  2880. if (item.target==target){
  2881. item.add(relationType,usePercent);
  2882. return;
  2883. }
  2884. };
  2885. var newItem=new RelationItem(this._owner);
  2886. newItem.target=target;
  2887. newItem.add(relationType,usePercent);
  2888. this._items.push(newItem);
  2889. }
  2890. __proto.remove=function(target,relationType){
  2891. (relationType===void 0)&& (relationType=0);
  2892. var cnt=this._items.length;
  2893. var i=0;
  2894. while (i < cnt){
  2895. var item=this._items[i];
  2896. if (item.target==target){
  2897. item.remove(relationType);
  2898. if (item.isEmpty){
  2899. item.dispose();
  2900. this._items.splice(i,1);
  2901. cnt--;
  2902. }
  2903. else
  2904. i++;
  2905. }
  2906. else
  2907. i++;
  2908. }
  2909. }
  2910. __proto.contains=function(target){
  2911. var length=this._items.length;
  2912. for (var i=0;i < length;i++){
  2913. var item=this._items[i];
  2914. if (item.target==target)
  2915. return true;
  2916. }
  2917. return false;
  2918. }
  2919. __proto.clearFor=function(target){
  2920. var cnt=this._items.length;
  2921. var i=0;
  2922. while (i < cnt){
  2923. var item=this._items[i];
  2924. if (item.target==target){
  2925. item.dispose();
  2926. this._items.splice(i,1);
  2927. cnt--;
  2928. }
  2929. else
  2930. i++;
  2931. }
  2932. }
  2933. __proto.clearAll=function(){
  2934. var length=this._items.length;
  2935. for (var i=0;i < length;i++){
  2936. var item=this._items[i];
  2937. item.dispose();
  2938. }
  2939. this._items.length=0;
  2940. }
  2941. __proto.copyFrom=function(source){
  2942. this.clearAll();
  2943. var arr=source._items;
  2944. var length=arr.length;
  2945. for (var i=0;i < length;i++){
  2946. var ri=arr[i];
  2947. var item=new RelationItem(this._owner);
  2948. item.copyFrom(ri);
  2949. this._items.push(item);
  2950. }
  2951. }
  2952. __proto.dispose=function(){
  2953. this.clearAll();
  2954. }
  2955. __proto.onOwnerSizeChanged=function(dWidth,dHeight,applyPivot){
  2956. if (this._items.length==0)
  2957. return;
  2958. var length=this._items.length;
  2959. for (var i=0;i < length;i++){
  2960. var item=this._items[i];
  2961. item.applyOnSelfResized(dWidth,dHeight,applyPivot);
  2962. }
  2963. }
  2964. __proto.ensureRelationsSizeCorrect=function(){
  2965. if (this._items.length==0)
  2966. return;
  2967. this.sizeDirty=false;
  2968. var length=this._items.length;
  2969. for (var i=0;i < length;i++){
  2970. var item=this._items[i];
  2971. item.target.ensureSizeCorrect();
  2972. }
  2973. }
  2974. __proto.setup=function(buffer,parentToChild){
  2975. var cnt=buffer.readByte();
  2976. var target;
  2977. for (var i=0;i < cnt;i++){
  2978. var targetIndex=buffer.getInt16();
  2979. if (targetIndex==-1)
  2980. target=this._owner.parent;
  2981. else if (parentToChild)
  2982. target=(this._owner).getChildAt(targetIndex);
  2983. else
  2984. target=this._owner.parent.getChildAt(targetIndex);
  2985. var newItem=new RelationItem(this._owner);
  2986. newItem.target=target;
  2987. this._items.push(newItem);
  2988. var cnt2=buffer.readByte();
  2989. for (var j=0;j < cnt2;j++){
  2990. var rt=buffer.readByte();
  2991. var usePercent=buffer.readBool();
  2992. newItem.internalAdd(rt,usePercent);
  2993. }
  2994. }
  2995. }
  2996. __getset(0,__proto,'empty',function(){
  2997. return this._items.length==0;
  2998. });
  2999. return Relations;
  3000. })()
  3001. //class fairygui.RelationType
  3002. var RelationType=(function(){
  3003. function RelationType(){}
  3004. __class(RelationType,'fairygui.RelationType');
  3005. RelationType.Left_Left=0;
  3006. RelationType.Left_Center=1;
  3007. RelationType.Left_Right=2;
  3008. RelationType.Center_Center=3;
  3009. RelationType.Right_Left=4;
  3010. RelationType.Right_Center=5;
  3011. RelationType.Right_Right=6;
  3012. RelationType.Top_Top=7;
  3013. RelationType.Top_Middle=8;
  3014. RelationType.Top_Bottom=9;
  3015. RelationType.Middle_Middle=10;
  3016. RelationType.Bottom_Top=11;
  3017. RelationType.Bottom_Middle=12;
  3018. RelationType.Bottom_Bottom=13;
  3019. RelationType.Width=14;
  3020. RelationType.Height=15;
  3021. RelationType.LeftExt_Left=16;
  3022. RelationType.LeftExt_Right=17;
  3023. RelationType.RightExt_Left=18;
  3024. RelationType.RightExt_Right=19;
  3025. RelationType.TopExt_Top=20;
  3026. RelationType.TopExt_Bottom=21;
  3027. RelationType.BottomExt_Top=22;
  3028. RelationType.BottomExt_Bottom=23;
  3029. RelationType.Size=24;
  3030. return RelationType;
  3031. })()
  3032. //class fairygui.ScrollBarDisplayType
  3033. var ScrollBarDisplayType=(function(){
  3034. function ScrollBarDisplayType(){}
  3035. __class(ScrollBarDisplayType,'fairygui.ScrollBarDisplayType');
  3036. ScrollBarDisplayType.Default=0;
  3037. ScrollBarDisplayType.Visible=1;
  3038. ScrollBarDisplayType.Auto=2;
  3039. ScrollBarDisplayType.Hidden=3;
  3040. return ScrollBarDisplayType;
  3041. })()
  3042. //class fairygui.ScrollPane
  3043. var ScrollPane=(function(){
  3044. function ScrollPane(owner){
  3045. this._owner=null;
  3046. this._container=null;
  3047. this._maskContainer=null;
  3048. this._alignContainer=null;
  3049. this._scrollType=0;
  3050. this._scrollStep=0;
  3051. this._mouseWheelStep=0;
  3052. this._decelerationRate=NaN;
  3053. this._scrollBarMargin=null;
  3054. this._bouncebackEffect=false;
  3055. this._touchEffect=false;
  3056. this._scrollBarDisplayAuto=false;
  3057. this._vScrollNone=false;
  3058. this._hScrollNone=false;
  3059. this._needRefresh=false;
  3060. this._refreshBarAxis=null;
  3061. this._displayOnLeft=false;
  3062. this._snapToItem=false;
  3063. this._displayInDemand=false;
  3064. this._mouseWheelEnabled=false;
  3065. this._pageMode=false;
  3066. this._inertiaDisabled=false;
  3067. this._xPos=NaN;
  3068. this._yPos=NaN;
  3069. this._viewSize=null;
  3070. this._contentSize=null;
  3071. this._overlapSize=null;
  3072. this._pageSize=null;
  3073. this._containerPos=null;
  3074. this._beginTouchPos=null;
  3075. this._lastTouchPos=null;
  3076. this._lastTouchGlobalPos=null;
  3077. this._velocity=null;
  3078. this._velocityScale=NaN;
  3079. this._lastMoveTime=NaN;
  3080. this._isHoldAreaDone=false;
  3081. this._aniFlag=0;
  3082. this._scrollBarVisible=false;
  3083. this._loop=0;
  3084. this._headerLockedSize=0;
  3085. this._footerLockedSize=0;
  3086. this._refreshEventDispatching=false;
  3087. this._tweening=0;
  3088. this._tweenTime=null;
  3089. this._tweenDuration=null;
  3090. this._tweenStart=null;
  3091. this._tweenChange=null;
  3092. this._pageController=null;
  3093. this._hzScrollBar=null;
  3094. this._vtScrollBar=null;
  3095. this._header=null;
  3096. this._footer=null;
  3097. this.isDragged=false;
  3098. ;
  3099. this._owner=owner;
  3100. this._maskContainer=new Sprite();
  3101. this._owner.displayObject.addChild(this._maskContainer);
  3102. this._container=this._owner._container;
  3103. this._container.pos(0,0);
  3104. this._maskContainer.addChild(this._container);
  3105. this._scrollBarVisible=true;
  3106. this._mouseWheelEnabled=true;
  3107. this._xPos=0;
  3108. this._yPos=0;
  3109. this._aniFlag=0;
  3110. this._footerLockedSize=0;
  3111. this._headerLockedSize=0;
  3112. this._scrollBarMargin=new Margin();
  3113. this._viewSize=new Point();
  3114. this._contentSize=new Point();
  3115. this._pageSize=new Point(1,1);
  3116. this._overlapSize=new Point();
  3117. this._tweenTime=new Point();
  3118. this._tweenStart=new Point();
  3119. this._tweenDuration=new Point();
  3120. this._tweenChange=new Point();
  3121. this._velocity=new Point();
  3122. this._containerPos=new Point();
  3123. this._beginTouchPos=new Point();
  3124. this._lastTouchPos=new Point();
  3125. this._lastTouchGlobalPos=new Point();
  3126. this._scrollStep=UIConfig$1.defaultScrollStep;
  3127. this._mouseWheelStep=this._scrollStep*2;
  3128. this._decelerationRate=UIConfig$1.defaultScrollDecelerationRate;
  3129. this._owner.on("mousedown",this,this.__mouseDown);
  3130. this._owner.on("mousewheel",this,this.__mouseWheel);
  3131. }
  3132. __class(ScrollPane,'fairygui.ScrollPane');
  3133. var __proto=ScrollPane.prototype;
  3134. __proto.setup=function(buffer){
  3135. this._scrollType=buffer.readByte();
  3136. var scrollBarDisplay=buffer.readByte();
  3137. var flags=buffer.getInt32();
  3138. if (buffer.readBool()){
  3139. this._scrollBarMargin.top=buffer.getInt32();
  3140. this._scrollBarMargin.bottom=buffer.getInt32();
  3141. this._scrollBarMargin.left=buffer.getInt32();
  3142. this._scrollBarMargin.right=buffer.getInt32();
  3143. };
  3144. var vtScrollBarRes=buffer.readS();
  3145. var hzScrollBarRes=buffer.readS();
  3146. var headerRes=buffer.readS();
  3147. var footerRes=buffer.readS();
  3148. this._displayOnLeft=(flags & 1)!=0;
  3149. this._snapToItem=(flags & 2)!=0;
  3150. this._displayInDemand=(flags & 4)!=0;
  3151. this._pageMode=(flags & 8)!=0;
  3152. if(flags & 16)
  3153. this._touchEffect=true;
  3154. else if(flags & 32)
  3155. this._touchEffect=false;
  3156. else
  3157. this._touchEffect=UIConfig$1.defaultScrollTouchEffect;
  3158. if(flags & 64)
  3159. this._bouncebackEffect=true;
  3160. else if(flags & 128)
  3161. this._bouncebackEffect=false;
  3162. else
  3163. this._bouncebackEffect=UIConfig$1.defaultScrollBounceEffect;
  3164. this._inertiaDisabled=(flags & 256)!=0;
  3165. if((flags & 512)==0)
  3166. this._maskContainer.scrollRect=new Rectangle();
  3167. if(scrollBarDisplay==0)
  3168. scrollBarDisplay=UIConfig$1.defaultScrollBarDisplay;
  3169. if(scrollBarDisplay !=3){
  3170. if(this._scrollType==2 || this._scrollType==1){
  3171. var res=vtScrollBarRes ? vtScrollBarRes :UIConfig$1.verticalScrollBar;
  3172. if(res){
  3173. this._vtScrollBar=(UIPackage.createObjectFromURL(res));
  3174. if(!this._vtScrollBar)
  3175. throw "cannot create scrollbar from "+res;
  3176. this._vtScrollBar.setScrollPane(this,true);
  3177. this._owner.displayObject.addChild(this._vtScrollBar.displayObject);
  3178. }
  3179. }
  3180. if(this._scrollType==2 || this._scrollType==0){
  3181. res=hzScrollBarRes ? hzScrollBarRes :UIConfig$1.horizontalScrollBar;
  3182. if(res){
  3183. this._hzScrollBar=(UIPackage.createObjectFromURL(res));
  3184. if(!this._hzScrollBar)
  3185. throw "cannot create scrollbar from "+res;
  3186. this._hzScrollBar.setScrollPane(this,false);
  3187. this._owner.displayObject.addChild(this._hzScrollBar.displayObject);
  3188. }
  3189. }
  3190. this._scrollBarDisplayAuto=scrollBarDisplay==2;
  3191. if(this._scrollBarDisplayAuto){
  3192. this._scrollBarVisible=false;
  3193. if(this._vtScrollBar)
  3194. this._vtScrollBar.displayObject.visible=false;
  3195. if(this._hzScrollBar)
  3196. this._hzScrollBar.displayObject.visible=false;
  3197. }
  3198. }
  3199. else
  3200. this._mouseWheelEnabled=false;
  3201. if (headerRes){
  3202. this._header=UIPackage.createObjectFromURL(headerRes);
  3203. if (this._header==null)
  3204. throw new Error("FairyGUI: cannot create scrollPane header from "+headerRes);
  3205. }
  3206. if (footerRes){
  3207. this._footer=UIPackage.createObjectFromURL(footerRes);
  3208. if (this._footer==null)
  3209. throw new Error("FairyGUI: cannot create scrollPane footer from "+footerRes);
  3210. }
  3211. if (this._header !=null || this._footer !=null)
  3212. this._refreshBarAxis=(this._scrollType==2 || this._scrollType==1)? "y" :"x";
  3213. this.setSize(this.owner.width,this.owner.height);
  3214. }
  3215. __proto.dispose=function(){
  3216. if (this._tweening !=0)
  3217. Laya.timer.clear(this,this.tweenUpdate);
  3218. this._pageController=null;
  3219. if (this._hzScrollBar !=null)
  3220. this._hzScrollBar.dispose();
  3221. if (this._vtScrollBar !=null)
  3222. this._vtScrollBar.dispose();
  3223. if (this._header !=null)
  3224. this._header.dispose();
  3225. if (this._footer !=null)
  3226. this._footer.dispose();
  3227. }
  3228. __proto.setPercX=function(value,ani){
  3229. (ani===void 0)&& (ani=false);
  3230. this._owner.ensureBoundsCorrect();
  3231. this.setPosX(this._overlapSize.x *ToolSet.clamp01(value),ani);
  3232. }
  3233. __proto.setPercY=function(value,ani){
  3234. (ani===void 0)&& (ani=false);
  3235. this._owner.ensureBoundsCorrect();
  3236. this.setPosY(this._overlapSize.y *ToolSet.clamp01(value),ani);
  3237. }
  3238. __proto.setPosX=function(value,ani){
  3239. (ani===void 0)&& (ani=false);
  3240. this._owner.ensureBoundsCorrect();
  3241. if (this._loop==1)
  3242. value=this.loopCheckingNewPos(value,"x");
  3243. value=ToolSet.clamp(value,0,this._overlapSize.x);
  3244. if (value !=this._xPos){
  3245. this._xPos=value;
  3246. this.posChanged(ani);
  3247. }
  3248. }
  3249. __proto.setPosY=function(value,ani){
  3250. (ani===void 0)&& (ani=false);
  3251. this._owner.ensureBoundsCorrect();
  3252. if (this._loop==1)
  3253. value=this.loopCheckingNewPos(value,"y");
  3254. value=ToolSet.clamp(value,0,this._overlapSize.y);
  3255. if (value !=this._yPos){
  3256. this._yPos=value;
  3257. this.posChanged(ani);
  3258. }
  3259. }
  3260. __proto.setCurrentPageX=function(value,ani){
  3261. if (this._pageMode && this._overlapSize.x>0)
  3262. this.setPosX(value *this._pageSize.x,ani);
  3263. }
  3264. __proto.setCurrentPageY=function(value,ani){
  3265. if (this._pageMode && this._overlapSize.y>0)
  3266. this.setPosY(value *this._pageSize.y,ani);
  3267. }
  3268. __proto.scrollTop=function(ani){
  3269. (ani===void 0)&& (ani=false);
  3270. this.setPercY(0,ani);
  3271. }
  3272. __proto.scrollBottom=function(ani){
  3273. (ani===void 0)&& (ani=false);
  3274. this.setPercY(1,ani);
  3275. }
  3276. __proto.scrollUp=function(ratio,ani){
  3277. (ratio===void 0)&& (ratio=1);
  3278. (ani===void 0)&& (ani=false);
  3279. if (this._pageMode)
  3280. this.setPosY(this._yPos-this._pageSize.y *ratio,ani);
  3281. else
  3282. this.setPosY(this._yPos-this._scrollStep *ratio,ani);;
  3283. }
  3284. __proto.scrollDown=function(ratio,ani){
  3285. (ratio===void 0)&& (ratio=1);
  3286. (ani===void 0)&& (ani=false);
  3287. if (this._pageMode)
  3288. this.setPosY(this._yPos+this._pageSize.y *ratio,ani);
  3289. else
  3290. this.setPosY(this._yPos+this._scrollStep *ratio,ani);
  3291. }
  3292. __proto.scrollLeft=function(ratio,ani){
  3293. (ratio===void 0)&& (ratio=1);
  3294. (ani===void 0)&& (ani=false);
  3295. if (this._pageMode)
  3296. this.setPosX(this._xPos-this._pageSize.x *ratio,ani);
  3297. else
  3298. this.setPosX(this._xPos-this._scrollStep *ratio,ani);
  3299. }
  3300. __proto.scrollRight=function(ratio,ani){
  3301. (ratio===void 0)&& (ratio=1);
  3302. (ani===void 0)&& (ani=false);
  3303. if (this._pageMode)
  3304. this.setPosX(this._xPos+this._pageSize.x *ratio,ani);
  3305. else
  3306. this.setPosX(this._xPos+this._scrollStep *ratio,ani);
  3307. }
  3308. __proto.scrollToView=function(target,ani,setFirst){
  3309. (ani===void 0)&& (ani=false);
  3310. (setFirst===void 0)&& (setFirst=false);
  3311. this._owner.ensureBoundsCorrect();
  3312. if(this._needRefresh)
  3313. this.refresh();
  3314. var rect;
  3315. if((target instanceof fairygui.GObject )){
  3316. if(target.parent !=this._owner){
  3317. target.parent.localToGlobalRect(target.x,target.y,
  3318. target.width,target.height,fairygui.ScrollPane.sHelperRect);
  3319. rect=this._owner.globalToLocalRect(fairygui.ScrollPane.sHelperRect.x,fairygui.ScrollPane.sHelperRect.y,
  3320. fairygui.ScrollPane.sHelperRect.width,fairygui.ScrollPane.sHelperRect.height,fairygui.ScrollPane.sHelperRect);
  3321. }
  3322. else {
  3323. rect=fairygui.ScrollPane.sHelperRect;
  3324. rect.setTo(target.x,target.y,target.width,target.height);
  3325. }
  3326. }
  3327. else
  3328. rect=(target);
  3329. if(this._overlapSize.y>0){
  3330. var bottom=this._yPos+this._viewSize.y;
  3331. if(setFirst || rect.y<=this._yPos || rect.height>=this._viewSize.y){
  3332. if(this._pageMode)
  3333. this.setPosY(Math.floor(rect.y/this._pageSize.y)*this._pageSize.y,ani);
  3334. else
  3335. this.setPosY(rect.y,ani);
  3336. }
  3337. else if(rect.y+rect.height>bottom){
  3338. if(this._pageMode)
  3339. this.setPosY(Math.floor(rect.y/this._pageSize.y)*this._pageSize.y,ani);
  3340. else if (rect.height <=this._viewSize.y/2)
  3341. this.setPosY(rect.y+rect.height*2-this._viewSize.y,ani);
  3342. else
  3343. this.setPosY(rect.y+rect.height-this._viewSize.y,ani);
  3344. }
  3345. }
  3346. if(this._overlapSize.x>0){
  3347. var right=this._xPos+this._viewSize.x;
  3348. if(setFirst || rect.x<=this._xPos || rect.width>=this._viewSize.x){
  3349. if(this._pageMode)
  3350. this.setPosX(Math.floor(rect.x/this._pageSize.x)*this._pageSize.x,ani);
  3351. else
  3352. this.setPosX(rect.x,ani);
  3353. }
  3354. else if(rect.x+rect.width>right){
  3355. if(this._pageMode)
  3356. this.setPosX(Math.floor(rect.x/this._pageSize.x)*this._pageSize.x,ani);
  3357. else if (rect.width <=this._viewSize.x/2)
  3358. this.setPosX(rect.x+rect.width*2-this._viewSize.x,ani);
  3359. else
  3360. this.setPosX(rect.x+rect.width-this._viewSize.x,ani);
  3361. }
  3362. }
  3363. if(!ani && this._needRefresh)
  3364. this.refresh();
  3365. }
  3366. __proto.isChildInView=function(obj){
  3367. if(this._overlapSize.y>0){
  3368. var dist=obj.y+this._container.y;
  3369. if(dist<-obj.height || dist>this._viewSize.y)
  3370. return false;
  3371. }
  3372. if(this._overlapSize.x>0){
  3373. dist=obj.x+this._container.x;
  3374. if(dist<-obj.width || dist>this._viewSize.x)
  3375. return false;
  3376. }
  3377. return true;
  3378. }
  3379. __proto.cancelDragging=function(){
  3380. this._owner.displayObject.stage.off("mousemove",this,this.__mouseMove);
  3381. this._owner.displayObject.stage.off("mouseup",this,this.__mouseUp);
  3382. this._owner.displayObject.stage.off("click",this,this.__click);
  3383. if (ScrollPane.draggingPane==this)
  3384. ScrollPane.draggingPane=null;
  3385. ScrollPane._gestureFlag=0;
  3386. this.isDragged=false;
  3387. this._maskContainer.mouseEnabled=true;
  3388. }
  3389. __proto.lockHeader=function(size){
  3390. if (this._headerLockedSize==size)
  3391. return;
  3392. this._headerLockedSize=size;
  3393. if (!this._refreshEventDispatching && this._container[this._refreshBarAxis] >=0){
  3394. this._tweenStart.setTo(this._container.x,this._container.y);
  3395. this._tweenChange.setTo(0,0);
  3396. this._tweenChange[this._refreshBarAxis]=this._headerLockedSize-this._tweenStart[this._refreshBarAxis];
  3397. this._tweenDuration.setTo(0.3,0.3);
  3398. this._tweenTime.setTo(0,0);
  3399. this._tweening=2;
  3400. Laya.timer.frameLoop(1,this,this.tweenUpdate);
  3401. }
  3402. }
  3403. __proto.lockFooter=function(size){
  3404. if (this._footerLockedSize==size)
  3405. return;
  3406. this._footerLockedSize=size;
  3407. if (!this._refreshEventDispatching && this._container[this._refreshBarAxis] <=-this._overlapSize[this._refreshBarAxis]){
  3408. this._tweenStart.setTo(this._container.x,this._container.y);
  3409. this._tweenChange.setTo(0,0);
  3410. var max=this._overlapSize[this._refreshBarAxis];
  3411. if (max==0)
  3412. max=Math.max(this._contentSize[this._refreshBarAxis]+this._footerLockedSize-this._viewSize[this._refreshBarAxis],0);
  3413. else
  3414. max+=this._footerLockedSize;
  3415. this._tweenChange[this._refreshBarAxis]=-max-this._tweenStart[this._refreshBarAxis];
  3416. this._tweenDuration.setTo(0.3,0.3);
  3417. this._tweenTime.setTo(0,0);
  3418. this._tweening=2;
  3419. Laya.timer.frameLoop(1,this,this.tweenUpdate);
  3420. }
  3421. }
  3422. __proto.onOwnerSizeChanged=function(){
  3423. this.setSize(this._owner.width,this._owner.height);
  3424. this.posChanged(false);
  3425. }
  3426. __proto.handleControllerChanged=function(c){
  3427. if (this._pageController==c){
  3428. if (this._scrollType==0)
  3429. this.setCurrentPageX(c.selectedIndex,true);
  3430. else
  3431. this.setCurrentPageY(c.selectedIndex,true);
  3432. }
  3433. }
  3434. __proto.updatePageController=function(){
  3435. if (this._pageController !=null && !this._pageController.changing){
  3436. var index=0;
  3437. if (this._scrollType==0)
  3438. index=this.currentPageX;
  3439. else
  3440. index=this.currentPageY;
  3441. if (index < this._pageController.pageCount){
  3442. var c=this._pageController;
  3443. this._pageController=null;
  3444. c.selectedIndex=index;
  3445. this._pageController=c;
  3446. }
  3447. }
  3448. }
  3449. __proto.adjustMaskContainer=function(){
  3450. var mx=NaN,my=NaN;
  3451. if (this._displayOnLeft && this._vtScrollBar !=null)
  3452. mx=Math.floor(this._owner.margin.left+this._vtScrollBar.width);
  3453. else
  3454. mx=Math.floor(this._owner.margin.left);
  3455. my=Math.floor(this._owner.margin.top);
  3456. this._maskContainer.pos(mx,my);
  3457. if(this._owner._alignOffset.x!=0 || this._owner._alignOffset.y!=0){
  3458. if(this._alignContainer==null){
  3459. this._alignContainer=new Sprite();
  3460. this._maskContainer.addChild(this._alignContainer);
  3461. this._alignContainer.addChild(this._container);
  3462. }
  3463. this._alignContainer.pos(this._owner._alignOffset.x,this._owner._alignOffset.y);
  3464. }
  3465. else if(this._alignContainer){
  3466. this._alignContainer.pos(0,0);
  3467. }
  3468. }
  3469. __proto.setSize=function(aWidth,aHeight){
  3470. this.adjustMaskContainer();
  3471. if (this._hzScrollBar){
  3472. this._hzScrollBar.y=aHeight-this._hzScrollBar.height;
  3473. if(this._vtScrollBar && !this._vScrollNone){
  3474. this._hzScrollBar.width=aWidth-this._vtScrollBar.width-this._scrollBarMargin.left-this._scrollBarMargin.right;
  3475. if(this._displayOnLeft)
  3476. this._hzScrollBar.x=this._scrollBarMargin.left+this._vtScrollBar.width;
  3477. else
  3478. this._hzScrollBar.x=this._scrollBarMargin.left;
  3479. }
  3480. else {
  3481. this._hzScrollBar.width=aWidth-this._scrollBarMargin.left-this._scrollBarMargin.right;
  3482. this._hzScrollBar.x=this._scrollBarMargin.left;
  3483. }
  3484. }
  3485. if (this._vtScrollBar){
  3486. if (!this._displayOnLeft)
  3487. this._vtScrollBar.x=aWidth-this._vtScrollBar.width;
  3488. if(this._hzScrollBar)
  3489. this._vtScrollBar.height=aHeight-this._hzScrollBar.height-this._scrollBarMargin.top-this._scrollBarMargin.bottom;
  3490. else
  3491. this._vtScrollBar.height=aHeight-this._scrollBarMargin.top-this._scrollBarMargin.bottom;
  3492. this._vtScrollBar.y=this._scrollBarMargin.top;
  3493. }
  3494. this._viewSize.x=aWidth;
  3495. this._viewSize.y=aHeight;
  3496. if(this._hzScrollBar && !this._hScrollNone)
  3497. this._viewSize.y-=this._hzScrollBar.height;
  3498. if(this._vtScrollBar && !this._vScrollNone)
  3499. this._viewSize.x-=this._vtScrollBar.width;
  3500. this._viewSize.x-=(this._owner.margin.left+this._owner.margin.right);
  3501. this._viewSize.y-=(this._owner.margin.top+this._owner.margin.bottom);
  3502. this._viewSize.x=Math.max(1,this._viewSize.x);
  3503. this._viewSize.y=Math.max(1,this._viewSize.y);
  3504. this._pageSize.x=this._viewSize.x;
  3505. this._pageSize.y=this._viewSize.y;
  3506. this.handleSizeChanged();
  3507. }
  3508. __proto.setContentSize=function(aWidth,aHeight){
  3509. if(this._contentSize.x==aWidth && this._contentSize.y==aHeight)
  3510. return;
  3511. this._contentSize.x=aWidth;
  3512. this._contentSize.y=aHeight;
  3513. this.handleSizeChanged();
  3514. }
  3515. __proto.changeContentSizeOnScrolling=function(deltaWidth,deltaHeight,deltaPosX,deltaPosY){
  3516. var isRightmost=this._xPos==this._overlapSize.x;
  3517. var isBottom=this._yPos==this._overlapSize.y;
  3518. this._contentSize.x+=deltaWidth;
  3519. this._contentSize.y+=deltaHeight;
  3520. this.handleSizeChanged();
  3521. if (this._tweening==1){
  3522. if (deltaWidth !=0 && isRightmost && this._tweenChange.x < 0){
  3523. this._xPos=this._overlapSize.x;
  3524. this._tweenChange.x=-this._xPos-this._tweenStart.x;
  3525. }
  3526. if (deltaHeight !=0 && isBottom && this._tweenChange.y < 0){
  3527. this._yPos=this._overlapSize.y;
  3528. this._tweenChange.y=-this._yPos-this._tweenStart.y;
  3529. }
  3530. }
  3531. else if (this._tweening==2){
  3532. if (deltaPosX !=0){
  3533. this._container.x-=deltaPosX;
  3534. this._tweenStart.x-=deltaPosX;
  3535. this._xPos=-this._container.x;
  3536. }
  3537. if (deltaPosY !=0){
  3538. this._container.y-=deltaPosY;
  3539. this._tweenStart.y-=deltaPosY;
  3540. this._yPos=-this._container.y;
  3541. }
  3542. }
  3543. else if (this.isDragged){
  3544. if (deltaPosX !=0){
  3545. this._container.x-=deltaPosX;
  3546. this._containerPos.x-=deltaPosX;
  3547. this._xPos=-this._container.x;
  3548. }
  3549. if (deltaPosY !=0){
  3550. this._container.y-=deltaPosY;
  3551. this._containerPos.y-=deltaPosY;
  3552. this._yPos=-this._container.y;
  3553. }
  3554. }
  3555. else{
  3556. if (deltaWidth !=0 && isRightmost){
  3557. this._xPos=this._overlapSize.x;
  3558. this._container.x=-this._xPos;
  3559. }
  3560. if (deltaHeight !=0 && isBottom){
  3561. this._yPos=this._overlapSize.y;
  3562. this._container.y=-this._yPos;
  3563. }
  3564. }
  3565. if (this._pageMode)
  3566. this.updatePageController();
  3567. }
  3568. __proto.handleSizeChanged=function(onScrolling){
  3569. (onScrolling===void 0)&& (onScrolling=false);
  3570. if(this._displayInDemand){
  3571. if(this._vtScrollBar){
  3572. if(this._contentSize.y<=this._viewSize.y){
  3573. if(!this._vScrollNone){
  3574. this._vScrollNone=true;
  3575. this._viewSize.x+=this._vtScrollBar.width;
  3576. }
  3577. }
  3578. else{
  3579. if(this._vScrollNone){
  3580. this._vScrollNone=false;
  3581. this._viewSize.x-=this._vtScrollBar.width;
  3582. }
  3583. }
  3584. }
  3585. if(this._hzScrollBar){
  3586. if(this._contentSize.x<=this._viewSize.x){
  3587. if(!this._hScrollNone){
  3588. this._hScrollNone=true;
  3589. this._viewSize.y+=this._hzScrollBar.height;
  3590. }
  3591. }
  3592. else{
  3593. if(this._hScrollNone){
  3594. this._hScrollNone=false;
  3595. this._viewSize.y-=this._hzScrollBar.height;
  3596. }
  3597. }
  3598. }
  3599. }
  3600. if(this._vtScrollBar){
  3601. if(this._viewSize.y<this._vtScrollBar.minSize)
  3602. this._vtScrollBar.displayObject.visible=false;
  3603. else{
  3604. this._vtScrollBar.displayObject.visible=this._scrollBarVisible && !this._vScrollNone;
  3605. if(this._contentSize.y==0)
  3606. this._vtScrollBar.displayPerc=0;
  3607. else
  3608. this._vtScrollBar.displayPerc=Math.min(1,this._viewSize.y/this._contentSize.y);
  3609. }
  3610. }
  3611. if(this._hzScrollBar){
  3612. if(this._viewSize.x<this._hzScrollBar.minSize)
  3613. this._hzScrollBar.displayObject.visible=false;
  3614. else{
  3615. this._hzScrollBar.displayObject.visible=this._scrollBarVisible && !this._hScrollNone;
  3616. if(this._contentSize.x==0)
  3617. this._hzScrollBar.displayPerc=0;
  3618. else
  3619. this._hzScrollBar.displayPerc=Math.min(1,this._viewSize.x/this._contentSize.x);
  3620. }
  3621. };
  3622. var rect=this._maskContainer.scrollRect;
  3623. if (rect){
  3624. rect.width=this._viewSize.x;
  3625. rect.height=this._viewSize.y;
  3626. this._maskContainer.scrollRect=rect;
  3627. }
  3628. if (this._scrollType==0 || this._scrollType==2)
  3629. this._overlapSize.x=Math.ceil(Math.max(0,this._contentSize.x-this._viewSize.x));
  3630. else
  3631. this._overlapSize.x=0;
  3632. if (this._scrollType==1 || this._scrollType==2)
  3633. this._overlapSize.y=Math.ceil(Math.max(0,this._contentSize.y-this._viewSize.y));
  3634. else
  3635. this._overlapSize.y=0;
  3636. this._xPos=ToolSet.clamp(this._xPos,0,this._overlapSize.x);
  3637. this._yPos=ToolSet.clamp(this._yPos,0,this._overlapSize.y);
  3638. if(this._refreshBarAxis!=null){
  3639. var max=this._overlapSize[this._refreshBarAxis];
  3640. if (max==0)
  3641. max=Math.max(this._contentSize[this._refreshBarAxis]+this._footerLockedSize-this._viewSize[this._refreshBarAxis],0);
  3642. else
  3643. max+=this._footerLockedSize;
  3644. if (this._refreshBarAxis=="x"){
  3645. this._container.pos(ToolSet.clamp(this._container.x,-max,this._headerLockedSize),
  3646. ToolSet.clamp(this._container.y,-this._overlapSize.y,0));
  3647. }
  3648. else{
  3649. this._container.pos(ToolSet.clamp(this._container.x,-this._overlapSize.x,0),
  3650. ToolSet.clamp(this._container.y,-max,this._headerLockedSize));
  3651. }
  3652. if (this._header !=null){
  3653. if (this._refreshBarAxis=="x")
  3654. this._header.height=this._viewSize.y;
  3655. else
  3656. this._header.width=this._viewSize.x;
  3657. }
  3658. if (this._footer !=null){
  3659. if (this._refreshBarAxis=="y")
  3660. this._footer.height=this._viewSize.y;
  3661. else
  3662. this._footer.width=this._viewSize.x;
  3663. }
  3664. }
  3665. else{
  3666. this._container.pos(ToolSet.clamp(this._container.x,-this._overlapSize.x,0),
  3667. ToolSet.clamp(this._container.y,-this._overlapSize.y,0));
  3668. }
  3669. this.syncScrollBar(true);
  3670. this.checkRefreshBar();
  3671. if (this._pageMode)
  3672. this.updatePageController();
  3673. }
  3674. __proto.posChanged=function(ani){
  3675. if (this._aniFlag==0)
  3676. this._aniFlag=ani ? 1 :-1;
  3677. else if (this._aniFlag==1 && !ani)
  3678. this._aniFlag=-1;
  3679. this._needRefresh=true;
  3680. Laya.timer.callLater(this,this.refresh);
  3681. }
  3682. __proto.refresh=function(){
  3683. this._needRefresh=false;
  3684. Laya.timer.clear(this,this.refresh);
  3685. if (this._pageMode || this._snapToItem){
  3686. ScrollPane.sEndPos.setTo(-this._xPos,-this._yPos);
  3687. this.alignPosition(ScrollPane.sEndPos,false);
  3688. this._xPos=-ScrollPane.sEndPos.x;
  3689. this._yPos=-ScrollPane.sEndPos.y;
  3690. }
  3691. this.refresh2();
  3692. if(this._owner&&this._owner.displayObject){
  3693. Events.dispatch("fui_scroll",this._owner.displayObject);
  3694. }
  3695. if (this._needRefresh){
  3696. this._needRefresh=false;
  3697. Laya.timer.clear(this,this.refresh);
  3698. this.refresh2();
  3699. }
  3700. this.syncScrollBar();
  3701. this._aniFlag=0;
  3702. }
  3703. __proto.refresh2=function(){
  3704. if (this._aniFlag==1 && !this.isDragged){
  3705. var posX=NaN;
  3706. var posY=NaN;
  3707. if (this._overlapSize.x > 0)
  3708. posX=-Math.floor(this._xPos);
  3709. else{
  3710. if (this._container.x !=0)
  3711. this._container.x=0;
  3712. posX=0;
  3713. }
  3714. if (this._overlapSize.y > 0)
  3715. posY=-Math.floor(this._yPos);
  3716. else{
  3717. if (this._container.y !=0)
  3718. this._container.y=0;
  3719. posY=0;
  3720. }
  3721. if (posX !=this._container.x || posY !=this._container.y){
  3722. this._tweening=1;
  3723. this._tweenTime.setTo(0,0);
  3724. this._tweenDuration.setTo(0.5,0.5);
  3725. this._tweenStart.setTo(this._container.x,this._container.y);
  3726. this._tweenChange.setTo(posX-this._tweenStart.x,posY-this._tweenStart.y);
  3727. Laya.timer.frameLoop(1,this,this.tweenUpdate);
  3728. }
  3729. else if (this._tweening !=0)
  3730. this.killTween();
  3731. }
  3732. else{
  3733. if (this._tweening !=0)
  3734. this.killTween();
  3735. this._container.pos(Math.floor(-this._xPos),Math.floor(-this._yPos));
  3736. this.loopCheckingCurrent();
  3737. }
  3738. if (this._pageMode)
  3739. this.updatePageController();
  3740. }
  3741. __proto.syncScrollBar=function(end){
  3742. (end===void 0)&& (end=false);
  3743. if (this._vtScrollBar !=null){
  3744. this._vtScrollBar.scrollPerc=this._overlapSize.y==0 ? 0 :ToolSet.clamp(-this._container.y,0,this._overlapSize.y)/ this._overlapSize.y;
  3745. if (this._scrollBarDisplayAuto)
  3746. this.showScrollBar(!end);
  3747. }
  3748. if (this._hzScrollBar !=null){
  3749. this._hzScrollBar.scrollPerc=this._overlapSize.x==0 ? 0 :ToolSet.clamp(-this._container.x,0,this._overlapSize.x)/ this._overlapSize.x;
  3750. if (this._scrollBarDisplayAuto)
  3751. this.showScrollBar(!end);
  3752. }
  3753. if(end)
  3754. this._maskContainer.mouseEnabled=true;
  3755. }
  3756. __proto.__mouseDown=function(){
  3757. if(!this._touchEffect)
  3758. return;
  3759. if(this._tweening!=0){
  3760. this.killTween();
  3761. this.isDragged=true;
  3762. }
  3763. else
  3764. this.isDragged=false;
  3765. var pt=this._owner.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY,fairygui.ScrollPane.sHelperPoint);
  3766. this._containerPos.setTo(this._container.x,this._container.y);
  3767. this._beginTouchPos.setTo(pt.x,pt.y);
  3768. this._lastTouchPos.setTo(pt.x,pt.y);
  3769. this._lastTouchGlobalPos.setTo(Laya.stage.mouseX,Laya.stage.mouseY);
  3770. this._isHoldAreaDone=false;
  3771. this._velocity.setTo(0,0);
  3772. this._velocityScale=1;
  3773. this._lastMoveTime=Laya.timer.currTimer/1000;
  3774. this._owner.displayObject.stage.on("mousemove",this,this.__mouseMove);
  3775. this._owner.displayObject.stage.on("mouseup",this,this.__mouseUp);
  3776. this._owner.displayObject.stage.on("click",this,this.__click);
  3777. }
  3778. __proto.__mouseMove=function(){
  3779. if(!this._touchEffect)
  3780. return;
  3781. if (ScrollPane.draggingPane !=null && ScrollPane.draggingPane !=this || GObject.draggingObject !=null)
  3782. return;
  3783. var sensitivity=UIConfig$1.touchScrollSensitivity;
  3784. var pt=this._owner.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY,fairygui.ScrollPane.sHelperPoint);
  3785. var diff=NaN,diff2=NaN;
  3786. var sv=false,sh=false,st=false;
  3787. if (this._scrollType==1){
  3788. if (!this._isHoldAreaDone){
  3789. ScrollPane._gestureFlag |=1;
  3790. diff=Math.abs(this._beginTouchPos.y-pt.y);
  3791. if (diff < sensitivity)
  3792. return;
  3793. if ((ScrollPane._gestureFlag & 2)!=0){
  3794. diff2=Math.abs(this._beginTouchPos.x-pt.x);
  3795. if (diff < diff2)
  3796. return;
  3797. }
  3798. }
  3799. sv=true;
  3800. }
  3801. else if (this._scrollType==0){
  3802. if (!this._isHoldAreaDone){
  3803. ScrollPane._gestureFlag |=2;
  3804. diff=Math.abs(this._beginTouchPos.x-pt.x);
  3805. if (diff < sensitivity)
  3806. return;
  3807. if ((ScrollPane._gestureFlag & 1)!=0){
  3808. diff2=Math.abs(this._beginTouchPos.y-pt.y);
  3809. if (diff < diff2)
  3810. return;
  3811. }
  3812. }
  3813. sh=true;
  3814. }
  3815. else{
  3816. ScrollPane._gestureFlag=3;
  3817. if (!this._isHoldAreaDone){
  3818. diff=Math.abs(this._beginTouchPos.y-pt.y);
  3819. if (diff < sensitivity){
  3820. diff=Math.abs(this._beginTouchPos.x-pt.x);
  3821. if (diff < sensitivity)
  3822. return;
  3823. }
  3824. }
  3825. sv=sh=true;
  3826. };
  3827. var newPosX=Math.floor(this._containerPos.x+pt.x-this._beginTouchPos.x);
  3828. var newPosY=Math.floor(this._containerPos.y+pt.y-this._beginTouchPos.y);
  3829. if (sv){
  3830. if (newPosY > 0){
  3831. if (!this._bouncebackEffect)
  3832. this._container.y=0;
  3833. else if (this._header !=null && this._header.maxHeight !=0)
  3834. this._container.y=Math.floor(Math.min(newPosY *0.5,this._header.maxHeight));
  3835. else
  3836. this._container.y=Math.floor(Math.min(newPosY *0.5,this._viewSize.y *0.5));
  3837. }
  3838. else if (newPosY <-this._overlapSize.y){
  3839. if (!this._bouncebackEffect)
  3840. this._container.y=-this._overlapSize.y;
  3841. else if (this._footer !=null && this._footer.maxHeight > 0)
  3842. this._container.y=Math.floor(Math.max((newPosY+this._overlapSize.y)*0.5,-this._footer.maxHeight)-this._overlapSize.y);
  3843. else
  3844. this._container.y=Math.floor(Math.max((newPosY+this._overlapSize.y)*0.5,-this._viewSize.y *0.5)-this._overlapSize.y);
  3845. }
  3846. else
  3847. this._container.y=newPosY;
  3848. }
  3849. if (sh){
  3850. if (newPosX > 0){
  3851. if (!this._bouncebackEffect)
  3852. this._container.x=0;
  3853. else if (this._header !=null && this._header.maxWidth !=0)
  3854. this._container.x=Math.floor(Math.min(newPosX *0.5,this._header.maxWidth));
  3855. else
  3856. this._container.x=Math.floor(Math.min(newPosX *0.5,this._viewSize.x *0.5));
  3857. }
  3858. else if (newPosX < 0-this._overlapSize.x){
  3859. if (!this._bouncebackEffect)
  3860. this._container.x=-this._overlapSize.x;
  3861. else if (this._footer !=null && this._footer.maxWidth > 0)
  3862. this._container.x=Math.floor(Math.max((newPosX+this._overlapSize.x)*0.5,-this._footer.maxWidth)-this._overlapSize.x);
  3863. else
  3864. this._container.x=Math.floor(Math.max((newPosX+this._overlapSize.x)*0.5,-this._viewSize.x *0.5)-this._overlapSize.x);
  3865. }
  3866. else
  3867. this._container.x=newPosX;
  3868. };
  3869. var frameRate=Laya.stage.frameRate=="slow"?30:60;
  3870. var now=Laya.timer.currTimer/1000;
  3871. var deltaTime=Math.max(now-this._lastMoveTime,1/frameRate);
  3872. var deltaPositionX=pt.x-this._lastTouchPos.x;
  3873. var deltaPositionY=pt.y-this._lastTouchPos.y;
  3874. if (!sh)
  3875. deltaPositionX=0;
  3876. if (!sv)
  3877. deltaPositionY=0;
  3878. if(deltaTime!=0){
  3879. var elapsed=deltaTime *frameRate-1;
  3880. if (elapsed > 1){
  3881. var factor=Math.pow(0.833,elapsed);
  3882. this._velocity.x=this._velocity.x *factor;
  3883. this._velocity.y=this._velocity.y *factor;
  3884. }
  3885. this._velocity.x=ToolSet.lerp(this._velocity.x,deltaPositionX *60 / frameRate / deltaTime,deltaTime *10);
  3886. this._velocity.y=ToolSet.lerp(this._velocity.y,deltaPositionY *60 / frameRate / deltaTime,deltaTime *10);
  3887. };
  3888. var deltaGlobalPositionX=this._lastTouchGlobalPos.x-Laya.stage.mouseX;
  3889. var deltaGlobalPositionY=this._lastTouchGlobalPos.y-Laya.stage.mouseY;
  3890. if (deltaPositionX !=0)
  3891. this._velocityScale=Math.abs(deltaGlobalPositionX / deltaPositionX);
  3892. else if (deltaPositionY !=0)
  3893. this._velocityScale=Math.abs(deltaGlobalPositionY / deltaPositionY);
  3894. this._lastTouchPos.setTo(pt.x,pt.y);
  3895. this._lastTouchGlobalPos.setTo(Laya.stage.mouseX,Laya.stage.mouseY);
  3896. this._lastMoveTime=now;
  3897. if (this._overlapSize.x > 0)
  3898. this._xPos=ToolSet.clamp(-this._container.x,0,this._overlapSize.x);
  3899. if (this._overlapSize.y > 0)
  3900. this._yPos=ToolSet.clamp(-this._container.y,0,this._overlapSize.y);
  3901. if (this._loop !=0){
  3902. newPosX=this._container.x;
  3903. newPosY=this._container.y;
  3904. if (this.loopCheckingCurrent()){
  3905. this._containerPos.x+=this._container.x-newPosX;
  3906. this._containerPos.y+=this._container.y-newPosY;
  3907. }
  3908. }
  3909. ScrollPane.draggingPane=this;
  3910. this._isHoldAreaDone=true;
  3911. this.isDragged=true;
  3912. this._maskContainer.mouseEnabled=false;
  3913. this.syncScrollBar();
  3914. this.checkRefreshBar();
  3915. if (this._pageMode)
  3916. this.updatePageController();
  3917. Events.dispatch("fui_scroll",this._owner.displayObject);
  3918. }
  3919. __proto.__mouseUp=function(){
  3920. this._owner.displayObject.stage.off("mousemove",this,this.__mouseMove);
  3921. this._owner.displayObject.stage.off("mouseup",this,this.__mouseUp);
  3922. this._owner.displayObject.stage.off("click",this,this.__click);
  3923. if (ScrollPane.draggingPane==this)
  3924. ScrollPane.draggingPane=null;
  3925. ScrollPane._gestureFlag=0;
  3926. if (!this.isDragged || !this._touchEffect){
  3927. this.isDragged=false;
  3928. this._maskContainer.mouseEnabled=true;
  3929. return;
  3930. }
  3931. this.isDragged=false;
  3932. this._maskContainer.mouseEnabled=true;
  3933. this._tweenStart.setTo(this._container.x,this._container.y);
  3934. ScrollPane.sEndPos.setTo(this._tweenStart.x,this._tweenStart.y);
  3935. var flag=false;
  3936. if (this._container.x > 0){
  3937. ScrollPane.sEndPos.x=0;
  3938. flag=true;
  3939. }
  3940. else if (this._container.x <-this._overlapSize.x){
  3941. ScrollPane.sEndPos.x=-this._overlapSize.x;
  3942. flag=true;
  3943. }
  3944. if (this._container.y > 0){
  3945. ScrollPane.sEndPos.y=0;
  3946. flag=true;
  3947. }
  3948. else if (this._container.y <-this._overlapSize.y){
  3949. ScrollPane.sEndPos.y=-this._overlapSize.y;
  3950. flag=true;
  3951. }
  3952. if (flag){
  3953. this._tweenChange.setTo(ScrollPane.sEndPos.x-this._tweenStart.x,ScrollPane.sEndPos.y-this._tweenStart.y);
  3954. if (this._tweenChange.x <-UIConfig$1.touchDragSensitivity || this._tweenChange.y <-UIConfig$1.touchDragSensitivity){
  3955. this._refreshEventDispatching=true;
  3956. Events.dispatch("fui_pull_down_release",this._owner.displayObject);
  3957. this._refreshEventDispatching=false;
  3958. }
  3959. else if (this._tweenChange.x > UIConfig$1.touchDragSensitivity || this._tweenChange.y > UIConfig$1.touchDragSensitivity){
  3960. this._refreshEventDispatching=true;
  3961. Events.dispatch("fui_pull_up_release",this._owner.displayObject);
  3962. this._refreshEventDispatching=false;
  3963. }
  3964. if (this._headerLockedSize > 0 && ScrollPane.sEndPos[this._refreshBarAxis]==0){
  3965. ScrollPane.sEndPos[this._refreshBarAxis]=this._headerLockedSize;
  3966. this._tweenChange.x=ScrollPane.sEndPos.x-this._tweenStart.x;
  3967. this._tweenChange.y=ScrollPane.sEndPos.y-this._tweenStart.y;
  3968. }
  3969. else if (this._footerLockedSize > 0 && ScrollPane.sEndPos[this._refreshBarAxis]==-this._overlapSize[this._refreshBarAxis]){
  3970. var max=this._overlapSize[this._refreshBarAxis];
  3971. if (max==0)
  3972. max=Math.max(this._contentSize[this._refreshBarAxis]+this._footerLockedSize-this._viewSize[this._refreshBarAxis],0);
  3973. else
  3974. max+=this._footerLockedSize;
  3975. ScrollPane.sEndPos[this._refreshBarAxis]=-max;
  3976. this._tweenChange.x=ScrollPane.sEndPos.x-this._tweenStart.x;
  3977. this._tweenChange.y=ScrollPane.sEndPos.y-this._tweenStart.y;
  3978. }
  3979. this._tweenDuration.setTo(0.3,0.3);
  3980. }
  3981. else{
  3982. if (!this._inertiaDisabled){
  3983. var frameRate=Laya.stage.frameRate=="slow"?30:60;
  3984. var elapsed=(Laya.timer.currTimer/1000-this._lastMoveTime)*frameRate-1;
  3985. if (elapsed > 1){
  3986. var factor=Math.pow(0.833,elapsed);
  3987. this._velocity.x=this._velocity.x *factor;
  3988. this._velocity.y=this._velocity.y *factor;
  3989. }
  3990. this.updateTargetAndDuration(this._tweenStart,ScrollPane.sEndPos);
  3991. }
  3992. else
  3993. this._tweenDuration.setTo(0.3,0.3);
  3994. ScrollPane.sOldChange.setTo(ScrollPane.sEndPos.x-this._tweenStart.x,ScrollPane.sEndPos.y-this._tweenStart.y);
  3995. this.loopCheckingTarget(ScrollPane.sEndPos);
  3996. if (this._pageMode || this._snapToItem)
  3997. this.alignPosition(ScrollPane.sEndPos,true);
  3998. this._tweenChange.x=ScrollPane.sEndPos.x-this._tweenStart.x;
  3999. this._tweenChange.y=ScrollPane.sEndPos.y-this._tweenStart.y;
  4000. if (this._tweenChange.x==0 && this._tweenChange.y==0){
  4001. if (this._scrollBarDisplayAuto)
  4002. this.showScrollBar(false);
  4003. return;
  4004. }
  4005. if (this._pageMode || this._snapToItem){
  4006. this.fixDuration("x",ScrollPane.sOldChange.x);
  4007. this.fixDuration("y",ScrollPane.sOldChange.y);
  4008. }
  4009. }
  4010. this._tweening=2;
  4011. this._tweenTime.setTo(0,0);
  4012. Laya.timer.frameLoop(1,this,this.tweenUpdate);
  4013. }
  4014. __proto.__click=function(){
  4015. this.isDragged=false;
  4016. }
  4017. __proto.__mouseWheel=function(evt){
  4018. if(!this._mouseWheelEnabled)
  4019. return;
  4020. var pt=this._owner.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY,fairygui.ScrollPane.sHelperPoint);
  4021. var delta=evt["delta"];
  4022. delta=delta>0?-1:(delta<0?1:0);
  4023. if (this._overlapSize.x > 0 && this._overlapSize.y==0){
  4024. if (this._pageMode)
  4025. this.setPosX(this._xPos+this._pageSize.x *delta,false);
  4026. else
  4027. this.setPosX(this._xPos+this._mouseWheelStep *delta,false);
  4028. }
  4029. else {
  4030. if (this._pageMode)
  4031. this.setPosY(this._yPos+this._pageSize.y *delta,false);
  4032. else
  4033. this.setPosY(this._yPos+this._mouseWheelStep *delta,false);
  4034. }
  4035. }
  4036. __proto.__rollOver=function(){
  4037. this.showScrollBar(true);
  4038. }
  4039. __proto.__rollOut=function(){
  4040. this.showScrollBar(false);
  4041. }
  4042. __proto.showScrollBar=function(val){
  4043. if (val){
  4044. this.__showScrollBar(true);
  4045. Laya.timer.clear(this,this.__showScrollBar);
  4046. }
  4047. else
  4048. Laya.timer.once(500,this,this.__showScrollBar,[val]);
  4049. }
  4050. __proto.__showScrollBar=function(val){
  4051. this._scrollBarVisible=val && this._viewSize.x>0 && this._viewSize.y>0;
  4052. if (this._vtScrollBar)
  4053. this._vtScrollBar.displayObject.visible=this._scrollBarVisible && !this._vScrollNone;
  4054. if (this._hzScrollBar)
  4055. this._hzScrollBar.displayObject.visible=this._scrollBarVisible && !this._hScrollNone;
  4056. }
  4057. __proto.getLoopPartSize=function(division,axis){
  4058. return (this._contentSize[axis]+(axis=="x" ? (this._owner).columnGap :(this._owner).lineGap))/ division;
  4059. }
  4060. __proto.loopCheckingCurrent=function(){
  4061. var changed=false;
  4062. if (this._loop==1 && this._overlapSize.x > 0){
  4063. if (this._xPos < 0.001){
  4064. this._xPos+=this.getLoopPartSize(2,"x");
  4065. changed=true;
  4066. }
  4067. else if (this._xPos >=this._overlapSize.x){
  4068. this._xPos-=this.getLoopPartSize(2,"x");
  4069. changed=true;
  4070. }
  4071. }
  4072. else if (this._loop==2 && this._overlapSize.y > 0){
  4073. if (this._yPos < 0.001){
  4074. this._yPos+=this.getLoopPartSize(2,"y");
  4075. changed=true;
  4076. }
  4077. else if (this._yPos >=this._overlapSize.y){
  4078. this._yPos-=this.getLoopPartSize(2,"y");
  4079. changed=true;
  4080. }
  4081. }
  4082. if (changed)
  4083. this._container.pos(Math.floor(-this._xPos),Math.floor(-this._yPos));
  4084. return changed;
  4085. }
  4086. __proto.loopCheckingTarget=function(endPos){
  4087. if (this._loop==1)
  4088. this.loopCheckingTarget2(endPos,"x");
  4089. if (this._loop==2)
  4090. this.loopCheckingTarget2(endPos,"y");
  4091. }
  4092. __proto.loopCheckingTarget2=function(endPos,axis){
  4093. var halfSize=NaN;
  4094. var tmp=NaN;
  4095. if (endPos[axis] > 0){
  4096. halfSize=this.getLoopPartSize(2,axis);
  4097. tmp=this._tweenStart[axis]-halfSize;
  4098. if (tmp <=0 && tmp >=-this._overlapSize[axis]){
  4099. endPos[axis]-=halfSize;
  4100. this._tweenStart[axis]=tmp;
  4101. }
  4102. }
  4103. else if (endPos[axis] <-this._overlapSize[axis]){
  4104. halfSize=this.getLoopPartSize(2,axis);
  4105. tmp=this._tweenStart[axis]+halfSize;
  4106. if (tmp <=0 && tmp >=-this._overlapSize[axis]){
  4107. endPos[axis]+=halfSize;
  4108. this._tweenStart[axis]=tmp;
  4109. }
  4110. }
  4111. }
  4112. __proto.loopCheckingNewPos=function(value,axis){
  4113. if (this._overlapSize[axis]==0)
  4114. return value;
  4115. var pos=axis=="x" ? this._xPos :this._yPos;
  4116. var changed=false;
  4117. var v=NaN;
  4118. if (value < 0.001){
  4119. value+=this.getLoopPartSize(2,axis);
  4120. if (value > pos){
  4121. v=this.getLoopPartSize(6,axis);
  4122. v=Math.ceil((value-pos)/ v)*v;
  4123. pos=ToolSet.clamp(pos+v,0,this._overlapSize[axis]);
  4124. changed=true;
  4125. }
  4126. }
  4127. else if (value >=this._overlapSize[axis]){
  4128. value-=this.getLoopPartSize(2,axis);
  4129. if (value < pos){
  4130. v=this.getLoopPartSize(6,axis);
  4131. v=Math.ceil((pos-value)/ v)*v;
  4132. pos=ToolSet.clamp(pos-v,0,this._overlapSize[axis]);
  4133. changed=true;
  4134. }
  4135. }
  4136. if (changed){
  4137. if (axis=="x")
  4138. this._container.x=-Math.floor(pos);
  4139. else
  4140. this._container.y=-Math.floor(pos);
  4141. }
  4142. return value;
  4143. }
  4144. __proto.alignPosition=function(pos,inertialScrolling){
  4145. if (this._pageMode){
  4146. pos.x=this.alignByPage(pos.x,"x",inertialScrolling);
  4147. pos.y=this.alignByPage(pos.y,"y",inertialScrolling);
  4148. }
  4149. else if (this._snapToItem){
  4150. var pt=this._owner.getSnappingPosition(-pos.x,-pos.y,ScrollPane.sHelperPoint);
  4151. if (pos.x < 0 && pos.x >-this._overlapSize.x)
  4152. pos.x=-pt.x;
  4153. if (pos.y < 0 && pos.y >-this._overlapSize.y)
  4154. pos.y=-pt.y;
  4155. }
  4156. }
  4157. __proto.alignByPage=function(pos,axis,inertialScrolling){
  4158. var page=0;
  4159. if (pos > 0)
  4160. page=0;
  4161. else if (pos <-this._overlapSize[axis])
  4162. page=Math.ceil(this._contentSize[axis] / this._pageSize[axis])-1;
  4163. else{
  4164. page=Math.floor(-pos / this._pageSize[axis]);
  4165. var change=inertialScrolling ? (pos-this._containerPos[axis]):(pos-this._container[axis]);
  4166. var testPageSize=Math.min(this._pageSize[axis],this._contentSize[axis]-(page+1)*this._pageSize[axis]);
  4167. var delta=-pos-page *this._pageSize[axis];
  4168. if (Math.abs(change)> this._pageSize[axis]){
  4169. if (delta > testPageSize *0.5)
  4170. page++;
  4171. }
  4172. else{
  4173. if (delta > testPageSize *(change < 0 ? 0.3 :0.7))
  4174. page++;
  4175. }
  4176. pos=-page *this._pageSize[axis];
  4177. if (pos <-this._overlapSize[axis])
  4178. pos=-this._overlapSize[axis];
  4179. }
  4180. if (inertialScrolling){
  4181. var oldPos=this._tweenStart[axis];
  4182. var oldPage=0;
  4183. if (oldPos > 0)
  4184. oldPage=0;
  4185. else if (oldPos <-this._overlapSize[axis])
  4186. oldPage=Math.ceil(this._contentSize[axis] / this._pageSize[axis])-1;
  4187. else
  4188. oldPage=Math.floor(-oldPos / this._pageSize[axis]);
  4189. var startPage=Math.floor(-this._containerPos[axis] / this._pageSize[axis]);
  4190. if (Math.abs(page-startPage)> 1 && Math.abs(oldPage-startPage)<=1){
  4191. if (page > startPage)
  4192. page=startPage+1;
  4193. else
  4194. page=startPage-1;
  4195. pos=-page *this._pageSize[axis];
  4196. }
  4197. }
  4198. return pos;
  4199. }
  4200. __proto.updateTargetAndDuration=function(orignPos,resultPos){
  4201. resultPos.x=this.updateTargetAndDuration2(orignPos.x,"x");
  4202. resultPos.y=this.updateTargetAndDuration2(orignPos.y,"y");
  4203. }
  4204. __proto.updateTargetAndDuration2=function(pos,axis){
  4205. var v=this._velocity[axis];
  4206. var duration=0;
  4207. if (pos > 0)
  4208. pos=0;
  4209. else if (pos <-this._overlapSize[axis])
  4210. pos=-this._overlapSize[axis];
  4211. else{
  4212. var v2=Math.abs(v)*this._velocityScale;
  4213. if(Browser.onMobile)
  4214. v2 *=1136 / Math.max(Laya.stage.width,Laya.stage.height);
  4215. var ratio=0;
  4216. if (this._pageMode || !Browser.onMobile){
  4217. if (v2 > 500)
  4218. ratio=Math.pow((v2-500)/ 500,2);
  4219. }
  4220. else{
  4221. if (v2 > 1000)
  4222. ratio=Math.pow((v2-1000)/ 1000,2);
  4223. }
  4224. if (ratio !=0){
  4225. if (ratio > 1)
  4226. ratio=1;
  4227. v2 *=ratio;
  4228. v *=ratio;
  4229. this._velocity[axis]=v;
  4230. duration=Math.log(60 / v2)/Math.log(this._decelerationRate)/ 60;
  4231. var change=Math.floor(v *duration *0.4);
  4232. pos+=change;
  4233. }
  4234. }
  4235. if (duration < 0.3)
  4236. duration=0.3;
  4237. this._tweenDuration[axis]=duration;
  4238. return pos;
  4239. }
  4240. __proto.fixDuration=function(axis,oldChange){
  4241. if (this._tweenChange[axis]==0 || Math.abs(this._tweenChange[axis])>=Math.abs(oldChange))
  4242. return;
  4243. var newDuration=Math.abs(this._tweenChange[axis] / oldChange)*this._tweenDuration[axis];
  4244. if (newDuration < 0.3)
  4245. newDuration=0.3;
  4246. this._tweenDuration[axis]=newDuration;
  4247. }
  4248. __proto.killTween=function(){
  4249. if (this._tweening==1){
  4250. this._container.pos(this._tweenStart.x+this._tweenChange.x,this._tweenStart.y+this._tweenChange.y);
  4251. Events.dispatch("fui_scroll",this._owner.displayObject);
  4252. }
  4253. this._tweening=0;
  4254. Laya.timer.clear(this,this.tweenUpdate);
  4255. Events.dispatch("fui_scroll_end",this._owner.displayObject);
  4256. }
  4257. __proto.checkRefreshBar=function(){
  4258. if (this._header==null && this._footer==null)
  4259. return;
  4260. var pos=this._container[this._refreshBarAxis];
  4261. if (this._header !=null){
  4262. if (pos > 0){
  4263. if (this._header.displayObject.parent==null)
  4264. this._maskContainer.addChildAt(this._header.displayObject,0);
  4265. var pt=ScrollPane.sHelperPoint;
  4266. pt.setTo(this._header.width,this._header.height);
  4267. pt[this._refreshBarAxis]=pos;
  4268. this._header.setSize(pt.x,pt.y);
  4269. }
  4270. else{
  4271. if (this._header.displayObject.parent !=null)
  4272. this._maskContainer.removeChild(this._header.displayObject);
  4273. }
  4274. }
  4275. if (this._footer !=null){
  4276. var max=this._overlapSize[this._refreshBarAxis];
  4277. if (pos <-max || max==0 && this._footerLockedSize > 0){
  4278. if (this._footer.displayObject.parent==null)
  4279. this._maskContainer.addChildAt(this._footer.displayObject,0);
  4280. pt=ScrollPane.sHelperPoint;
  4281. pt.setTo(this._footer.x,this._footer.y);
  4282. if (max > 0)
  4283. pt[this._refreshBarAxis]=pos+this._contentSize[this._refreshBarAxis];
  4284. else
  4285. pt[this._refreshBarAxis]=Math.max(Math.min(pos+this._viewSize[this._refreshBarAxis],this._viewSize[this._refreshBarAxis]-this._footerLockedSize),
  4286. this._viewSize[this._refreshBarAxis]-this._contentSize[this._refreshBarAxis]);
  4287. this._footer.setXY(pt.x,pt.y);
  4288. pt.setTo(this._footer.width,this._footer.height);
  4289. if (max > 0)
  4290. pt[this._refreshBarAxis]=-max-pos;
  4291. else
  4292. pt[this._refreshBarAxis]=this._viewSize[this._refreshBarAxis]-this._footer[this._refreshBarAxis];
  4293. this._footer.setSize(pt.x,pt.y);
  4294. }
  4295. else{
  4296. if (this._footer.displayObject.parent !=null)
  4297. this._maskContainer.removeChild(this._footer.displayObject);
  4298. }
  4299. }
  4300. }
  4301. __proto.tweenUpdate=function(){
  4302. var nx=this.runTween("x");
  4303. var ny=this.runTween("y");
  4304. this._container.pos(nx,ny);
  4305. if (this._tweening==2){
  4306. if (this._overlapSize.x > 0)
  4307. this._xPos=ToolSet.clamp(-nx,0,this._overlapSize.x);
  4308. if (this._overlapSize.y > 0)
  4309. this._yPos=ToolSet.clamp(-ny,0,this._overlapSize.y);
  4310. if (this._pageMode)
  4311. this.updatePageController();
  4312. }
  4313. if (this._tweenChange.x==0 && this._tweenChange.y==0){
  4314. this._tweening=0;
  4315. Laya.timer.clear(this,this.tweenUpdate);
  4316. this.loopCheckingCurrent();
  4317. this.syncScrollBar(true);
  4318. this.checkRefreshBar();
  4319. Events.dispatch("fui_scroll",this._owner.displayObject);
  4320. Events.dispatch("fui_scroll_end",this._owner.displayObject);
  4321. }
  4322. else{
  4323. this.syncScrollBar(false);
  4324. this.checkRefreshBar();
  4325. Events.dispatch("fui_scroll",this._owner.displayObject);
  4326. }
  4327. }
  4328. __proto.runTween=function(axis){
  4329. var newValue=NaN;
  4330. if (this._tweenChange[axis] !=0){
  4331. this._tweenTime[axis]+=Laya.timer.delta/1000;
  4332. if (this._tweenTime[axis] >=this._tweenDuration[axis]){
  4333. newValue=this._tweenStart[axis]+this._tweenChange[axis];
  4334. this._tweenChange[axis]=0;
  4335. }
  4336. else{
  4337. var ratio=ScrollPane.easeFunc(this._tweenTime[axis],this._tweenDuration[axis]);
  4338. newValue=this._tweenStart[axis]+Math.floor(this._tweenChange[axis] *ratio);
  4339. };
  4340. var threshold1=0;
  4341. var threshold2=-this._overlapSize[axis];
  4342. if (this._headerLockedSize > 0 && this._refreshBarAxis==axis)
  4343. threshold1=this._headerLockedSize;
  4344. if (this._footerLockedSize > 0 && this._refreshBarAxis==axis){
  4345. var max=this._overlapSize[this._refreshBarAxis];
  4346. if (max==0)
  4347. max=Math.max(this._contentSize[this._refreshBarAxis]+this._footerLockedSize-this._viewSize[this._refreshBarAxis],0);
  4348. else
  4349. max+=this._footerLockedSize;
  4350. threshold2=-max;
  4351. }
  4352. if (this._tweening==2 && this._bouncebackEffect){
  4353. if (newValue > 20+threshold1 && this._tweenChange[axis] > 0
  4354. || newValue > threshold1 && this._tweenChange[axis]==0){
  4355. this._tweenTime[axis]=0;
  4356. this._tweenDuration[axis]=0.3;
  4357. this._tweenChange[axis]=-newValue+threshold1;
  4358. this._tweenStart[axis]=newValue;
  4359. }
  4360. else if (newValue < threshold2-20 && this._tweenChange[axis] < 0
  4361. || newValue < threshold2 && this._tweenChange[axis]==0){
  4362. this._tweenTime[axis]=0;
  4363. this._tweenDuration[axis]=0.3;
  4364. this._tweenChange[axis]=threshold2-newValue;
  4365. this._tweenStart[axis]=newValue;
  4366. }
  4367. }
  4368. else{
  4369. if (newValue > threshold1){
  4370. newValue=threshold1;
  4371. this._tweenChange[axis]=0;
  4372. }
  4373. else if (newValue < threshold2){
  4374. newValue=threshold2;
  4375. this._tweenChange[axis]=0;
  4376. }
  4377. }
  4378. }
  4379. else
  4380. newValue=this._container[axis];
  4381. return newValue;
  4382. }
  4383. __getset(0,__proto,'viewWidth',function(){
  4384. return this._viewSize.x;
  4385. },function(value){
  4386. value=value+this._owner.margin.left+this._owner.margin.right;
  4387. if (this._vtScrollBar !=null)
  4388. value+=this._vtScrollBar.width;
  4389. this._owner.width=value;
  4390. });
  4391. __getset(0,__proto,'percY',function(){
  4392. return this._overlapSize.y==0 ? 0 :this._yPos / this._overlapSize.y;
  4393. },function(value){
  4394. this.setPercY(value,false);
  4395. });
  4396. __getset(0,__proto,'owner',function(){
  4397. return this._owner;
  4398. });
  4399. __getset(0,__proto,'bouncebackEffect',function(){
  4400. return this._bouncebackEffect;
  4401. },function(sc){
  4402. this._bouncebackEffect=sc;
  4403. });
  4404. __getset(0,__proto,'vtScrollBar',function(){
  4405. return this._vtScrollBar;
  4406. });
  4407. __getset(0,__proto,'hzScrollBar',function(){
  4408. return this._hzScrollBar;
  4409. });
  4410. __getset(0,__proto,'header',function(){
  4411. return this._header;
  4412. });
  4413. __getset(0,__proto,'footer',function(){
  4414. return this._footer;
  4415. });
  4416. __getset(0,__proto,'isBottomMost',function(){
  4417. return this._yPos==this._overlapSize.y || this._overlapSize.y==0;
  4418. });
  4419. __getset(0,__proto,'touchEffect',function(){
  4420. return this._touchEffect;
  4421. },function(sc){
  4422. this._touchEffect=sc;
  4423. });
  4424. __getset(0,__proto,'contentWidth',function(){
  4425. return this._contentSize.x;
  4426. });
  4427. __getset(0,__proto,'scrollStep',function(){
  4428. return this._scrollStep;
  4429. },function(val){
  4430. this._scrollStep=val;
  4431. if(this._scrollStep==0)
  4432. this._scrollStep=UIConfig$1.defaultScrollStep;
  4433. this._mouseWheelStep=this._scrollStep*2;
  4434. });
  4435. __getset(0,__proto,'viewHeight',function(){
  4436. return this._viewSize.y;
  4437. },function(value){
  4438. value=value+this._owner.margin.top+this._owner.margin.bottom;
  4439. if (this._hzScrollBar !=null)
  4440. value+=this._hzScrollBar.height;
  4441. this._owner.height=value;
  4442. });
  4443. __getset(0,__proto,'posX',function(){
  4444. return this._xPos;
  4445. },function(value){
  4446. this.setPosX(value,false);
  4447. });
  4448. __getset(0,__proto,'snapToItem',function(){
  4449. return this._snapToItem;
  4450. },function(value){
  4451. this._snapToItem=value;
  4452. });
  4453. __getset(0,__proto,'mouseWheelEnabled',function(){
  4454. return this._mouseWheelEnabled;
  4455. },function(value){
  4456. this._mouseWheelEnabled=value;
  4457. });
  4458. __getset(0,__proto,'decelerationRate',function(){
  4459. return this._decelerationRate;
  4460. },function(value){
  4461. this._decelerationRate=value;
  4462. });
  4463. __getset(0,__proto,'percX',function(){
  4464. return this._overlapSize.x==0 ? 0 :this._xPos / this._overlapSize.x;
  4465. },function(value){
  4466. this.setPercX(value,false);
  4467. });
  4468. __getset(0,__proto,'posY',function(){
  4469. return this._yPos;
  4470. },function(value){
  4471. this.setPosY(value,false);
  4472. });
  4473. __getset(0,__proto,'contentHeight',function(){
  4474. return this._contentSize.y;
  4475. });
  4476. __getset(0,__proto,'currentPageX',function(){
  4477. if (!this._pageMode)
  4478. return 0;
  4479. var page=Math.floor(this._xPos / this._pageSize.x);
  4480. if (this._xPos-page *this._pageSize.x > this._pageSize.x *0.5)
  4481. page++;
  4482. return page;
  4483. },function(value){
  4484. this.setCurrentPageX(value,false);
  4485. });
  4486. __getset(0,__proto,'currentPageY',function(){
  4487. if (!this._pageMode)
  4488. return 0;
  4489. var page=Math.floor(this._yPos / this._pageSize.y);
  4490. if (this._yPos-page *this._pageSize.y > this._pageSize.y *0.5)
  4491. page++;
  4492. return page;
  4493. },function(value){
  4494. this.setCurrentPageY(value,false);
  4495. });
  4496. __getset(0,__proto,'isRightMost',function(){
  4497. return this._xPos==this._overlapSize.x || this._overlapSize.x==0;
  4498. });
  4499. __getset(0,__proto,'pageController',function(){
  4500. return this._pageController;
  4501. },function(value){
  4502. this._pageController=value;
  4503. });
  4504. __getset(0,__proto,'scrollingPosX',function(){
  4505. return ToolSet.clamp(-this._container.x,0,this._overlapSize.x);
  4506. });
  4507. __getset(0,__proto,'scrollingPosY',function(){
  4508. return ToolSet.clamp(-this._container.y,0,this._overlapSize.y);
  4509. });
  4510. ScrollPane.easeFunc=function(t,d){
  4511. return (t=t / d-1)*t *t+1;
  4512. }
  4513. ScrollPane.draggingPane=null;
  4514. ScrollPane._gestureFlag=0;
  4515. ScrollPane.TWEEN_TIME_GO=0.5;
  4516. ScrollPane.TWEEN_TIME_DEFAULT=0.3;
  4517. ScrollPane.PULL_RATIO=0.5;
  4518. __static(ScrollPane,
  4519. ['sHelperPoint',function(){return this.sHelperPoint=new Point();},'sHelperRect',function(){return this.sHelperRect=new Rectangle();},'sEndPos',function(){return this.sEndPos=new Point();},'sOldChange',function(){return this.sOldChange=new Point();}
  4520. ]);
  4521. return ScrollPane;
  4522. })()
  4523. //class fairygui.ScrollType
  4524. var ScrollType=(function(){
  4525. function ScrollType(){}
  4526. __class(ScrollType,'fairygui.ScrollType');
  4527. ScrollType.Horizontal=0;
  4528. ScrollType.Vertical=1;
  4529. ScrollType.Both=2;
  4530. return ScrollType;
  4531. })()
  4532. //class fairygui.Transition
  4533. var Transition=(function(){
  4534. var TransitionActionType,TransitionItem,TweenConfig,TValue_Visible,TValue_Animation,TValue_Sound,TValue_Transition,TValue_Shake,TValue_Text,TValue;
  4535. function Transition(owner){
  4536. this.name=null;
  4537. this._owner=null;
  4538. this._ownerBaseX=NaN;
  4539. this._ownerBaseY=NaN;
  4540. this._items=null;
  4541. this._totalTimes=0;
  4542. this._totalTasks=0;
  4543. this._playing=false;
  4544. this._paused=false;
  4545. this._onComplete=null;
  4546. this._options=0;
  4547. this._reversed=false;
  4548. this._totalDuration=NaN;
  4549. this._autoPlay=false;
  4550. this._autoPlayTimes=0;
  4551. this._autoPlayDelay=NaN;
  4552. this._timeScale=NaN;
  4553. this._startTime=NaN;
  4554. this._endTime=NaN;
  4555. this.OPTION_IGNORE_DISPLAY_CONTROLLER=1;
  4556. this.OPTION_AUTO_STOP_DISABLED=2;
  4557. this.OPTION_AUTO_STOP_AT_END=4;
  4558. this._owner=owner;
  4559. this._items=[];
  4560. this._totalDuration=0;
  4561. this._autoPlayTimes=1;
  4562. this._autoPlayDelay=0;
  4563. this._timeScale=1;
  4564. this._startTime=0;
  4565. this._endTime=0;
  4566. }
  4567. __class(Transition,'fairygui.Transition');
  4568. var __proto=Transition.prototype;
  4569. __proto.play=function(onComplete,times,delay,startTime,endTime){
  4570. (times===void 0)&& (times=1);
  4571. (delay===void 0)&& (delay=0);
  4572. (startTime===void 0)&& (startTime=0);
  4573. (endTime===void 0)&& (endTime=-1);
  4574. this._play(onComplete,times,delay,startTime,endTime,false);
  4575. }
  4576. __proto.playReverse=function(onComplete,times,delay,startTime,endTime){
  4577. (times===void 0)&& (times=1);
  4578. (delay===void 0)&& (delay=0);
  4579. (startTime===void 0)&& (startTime=0);
  4580. (endTime===void 0)&& (endTime=-1);
  4581. this._play(onComplete,1,delay,startTime,endTime,true);
  4582. }
  4583. __proto.changePlayTimes=function(value){
  4584. this._totalTimes=value;
  4585. }
  4586. __proto.setAutoPlay=function(value,times,delay){
  4587. (times===void 0)&& (times=1);
  4588. (delay===void 0)&& (delay=0);
  4589. if (this._autoPlay !=value){
  4590. this._autoPlay=value;
  4591. this._autoPlayTimes=times;
  4592. this._autoPlayDelay=delay;
  4593. if (this._autoPlay){
  4594. if (this._owner.onStage)
  4595. this.play(null,null,this._autoPlayTimes,this._autoPlayDelay);
  4596. }
  4597. else{
  4598. if (!this._owner.onStage)
  4599. this.stop(false,true);
  4600. }
  4601. }
  4602. }
  4603. __proto._play=function(onComplete,times,delay,startTime,endTime,reversed){
  4604. (times===void 0)&& (times=1);
  4605. (delay===void 0)&& (delay=0);
  4606. (startTime===void 0)&& (startTime=0);
  4607. (endTime===void 0)&& (endTime=-1);
  4608. (reversed===void 0)&& (reversed=false);
  4609. this.stop(true,true);
  4610. this._totalTimes=times;
  4611. this._reversed=reversed;
  4612. this._startTime=startTime;
  4613. this._endTime=endTime;
  4614. this._playing=true;
  4615. this._paused=false;
  4616. this._onComplete=onComplete;
  4617. var cnt=this._items.length;
  4618. for (var i=0;i < cnt;i++){
  4619. var item=this._items[i];
  4620. if(item.target==null){
  4621. if (item.targetId)
  4622. item.target=this._owner.getChildById(item.targetId);
  4623. else
  4624. item.target=this._owner;
  4625. }
  4626. else if (item.target !=this._owner && item.target.parent !=this._owner)
  4627. item.target=null;
  4628. if (item.target !=null && item.type==10){
  4629. var trans=(item.target).getTransition(item.value.transName);
  4630. if(trans==this)
  4631. trans=null;
  4632. if (trans !=null){
  4633. if (item.value.playTimes==0){
  4634. var j=0;
  4635. for (j=i-1;j >=0;j--){
  4636. var item2=this._items[j];
  4637. if (item2.type==10){
  4638. if (item2.value.trans==trans){
  4639. item2.value.stopTime=item.time-item2.time;
  4640. break ;
  4641. }
  4642. }
  4643. }
  4644. if(j<0)
  4645. item.value.stopTime=0;
  4646. else
  4647. trans=null;
  4648. }
  4649. else
  4650. item.value.stopTime=-1;
  4651. }
  4652. item.value.trans=trans;
  4653. }
  4654. }
  4655. if(delay==0)
  4656. this.onDelayedPlay();
  4657. else
  4658. GTween.delayedCall(delay).onComplete(this.onDelayedPlay,this);
  4659. }
  4660. __proto.stop=function(setToComplete,processCallback){
  4661. (setToComplete===void 0)&& (setToComplete=true);
  4662. (processCallback===void 0)&& (processCallback=false);
  4663. if (!this._playing)
  4664. return;
  4665. this._playing=false;
  4666. this._totalTasks=0;
  4667. this._totalTimes=0;
  4668. var handler=this._onComplete;
  4669. this._onComplete=null;
  4670. GTween.kill(this);
  4671. var cnt=this._items.length;
  4672. if(this._reversed){
  4673. for (var i=cnt-1;i >=0;i--){
  4674. var item=this._items[i];
  4675. if(item.target==null)
  4676. continue ;
  4677. this.stopItem(item,setToComplete);
  4678. }
  4679. }
  4680. else{
  4681. for (i=0;i < cnt;i++){
  4682. item=this._items[i];
  4683. if(item.target==null)
  4684. continue ;
  4685. this.stopItem(item,setToComplete);
  4686. }
  4687. }
  4688. if (processCallback && handler !=null){
  4689. handler.run();
  4690. }
  4691. }
  4692. __proto.stopItem=function(item,setToComplete){
  4693. if (item.displayLockToken!=0){
  4694. item.target.releaseDisplayLock(item.displayLockToken);
  4695. item.displayLockToken=0;
  4696. }
  4697. if (item.tweener !=null){
  4698. item.tweener.kill(setToComplete);
  4699. item.tweener=null;
  4700. if (item.type==11 && !setToComplete){
  4701. item.target._gearLocked=true;
  4702. item.target.setXY(item.target.x-item.value.lastOffsetX,item.target.y-item.value.lastOffsetY);
  4703. item.target._gearLocked=false;
  4704. }
  4705. }
  4706. if (item.type==10){
  4707. var trans=item.value.trans;
  4708. if (trans !=null)
  4709. trans.stop(setToComplete,false);
  4710. }
  4711. }
  4712. __proto.setPaused=function(paused){
  4713. if (!this._playing || this._paused==paused)
  4714. return;
  4715. this._paused=paused;
  4716. var tweener=GTween.getTween(this);
  4717. if (tweener !=null)
  4718. tweener.setPaused(paused);
  4719. var cnt=this._items.length;
  4720. for (var i=0;i < cnt;i++){
  4721. var item=this._items[i];
  4722. if (item.target==null)
  4723. continue ;
  4724. if (item.type==10){
  4725. if (item.value.trans !=null)
  4726. item.value.trans.setPaused(paused);
  4727. }
  4728. else if (item.type==7){
  4729. if (paused){
  4730. item.value.flag=(item.target).playing;
  4731. (item.target).playing=false;
  4732. }
  4733. else
  4734. (item.target).playing=item.value.flag;
  4735. }
  4736. if (item.tweener !=null)
  4737. item.tweener.setPaused(paused);
  4738. }
  4739. }
  4740. __proto.dispose=function(){
  4741. if(this._playing)
  4742. GTween.kill(this);
  4743. var cnt=this._items.length;
  4744. for (var i=0;i < cnt;i++){
  4745. var item=this._items[i];
  4746. if (item.tweener !=null){
  4747. item.tweener.kill();
  4748. item.tweener=null;
  4749. }
  4750. item.target=null;
  4751. item.hook=null;
  4752. if (item.tweenConfig !=null)
  4753. item.tweenConfig.endHook=null;
  4754. }
  4755. this._items.length=0;
  4756. this._playing=false;
  4757. this._onComplete=null;
  4758. }
  4759. __proto.setValue=function(label,__args){
  4760. var args=[];for(var i=1,sz=arguments.length;i<sz;i++)args.push(arguments[i]);
  4761. var cnt=this._items.length;
  4762. var value;
  4763. for (var i=0;i < cnt;i++){
  4764. var item=this._items[i];
  4765. if (item.label==label){
  4766. if (item.tweenConfig !=null)
  4767. value=item.tweenConfig.startValue;
  4768. else
  4769. value=item.value;
  4770. }
  4771. else if (item.tweenConfig !=null && item.tweenConfig.endLabel==label){
  4772. value=item.tweenConfig.endValue;
  4773. }
  4774. else
  4775. continue ;
  4776. switch (item.type){
  4777. case 0:
  4778. case 1:
  4779. case 3:
  4780. case 2:
  4781. case 13:
  4782. value.b1=true;
  4783. value.b2=true;
  4784. value.f1=parseFloat(args[0]);
  4785. value.f2=parseFloat(args[1]);
  4786. break ;
  4787. case 4:
  4788. value.f1=parseFloat(args[0]);
  4789. break ;
  4790. case 5:
  4791. value.f1=parseFloat(args[0]);
  4792. break ;
  4793. case 6:
  4794. value.f1=parseFloat(args[0]);
  4795. break ;
  4796. case 7:
  4797. value.frame=parseInt(args[0]);
  4798. if (args.length > 1)
  4799. value.playing=args[1];
  4800. break ;
  4801. case 8:
  4802. value.visible=args[0];
  4803. break ;
  4804. case 9:
  4805. value.sound=args[0];
  4806. if(args.length > 1)
  4807. value.volume=parseFloat(args[1]);
  4808. break ;
  4809. case 10:
  4810. value.transName=args[0];
  4811. if (args.length > 1)
  4812. value.playTimes=parseInt(args[1]);
  4813. break ;
  4814. case 11:
  4815. value.amplitude=parseFloat(args[0]);
  4816. if (args.length > 1)
  4817. value.duration=parseFloat(args[1]);
  4818. break ;
  4819. case 12:
  4820. value.f1=parseFloat(args[0]);
  4821. value.f2=parseFloat(args[1]);
  4822. value.f3=parseFloat(args[2]);
  4823. value.f4=parseFloat(args[3]);
  4824. break ;
  4825. case 14:
  4826. case 15:
  4827. value.text=args[0];
  4828. break ;
  4829. }
  4830. }
  4831. }
  4832. __proto.setHook=function(label,callback){
  4833. var cnt=this._items.length;
  4834. for (var i=0;i < cnt;i++){
  4835. var item=this._items[i];
  4836. if (item.label==label){
  4837. item.hook=callback;
  4838. break ;
  4839. }
  4840. else if (item.tweenConfig !=null && item.tweenConfig.endLabel==label){
  4841. item.tweenConfig.endHook=callback;
  4842. break ;
  4843. }
  4844. }
  4845. }
  4846. __proto.clearHooks=function(){
  4847. var cnt=this._items.length;
  4848. for (var i=0;i < cnt;i++){
  4849. var item=this._items[i];
  4850. item.hook=null;
  4851. if (item.tweenConfig !=null)
  4852. item.tweenConfig.endHook=null;
  4853. }
  4854. }
  4855. __proto.setTarget=function(label,newTarget){
  4856. var cnt=this._items.length;
  4857. for (var i=0;i < cnt;i++){
  4858. var item=this._items[i];
  4859. if (item.label==label){
  4860. item.targetId=newTarget.id;
  4861. item.target=null;
  4862. }
  4863. }
  4864. }
  4865. __proto.setDuration=function(label,value){
  4866. var cnt=this._items.length;
  4867. for (var i=0;i < cnt;i++){
  4868. var item=this._items[i];
  4869. if (item.tweenConfig !=null && item.label==label)
  4870. item.tweenConfig.duration=value;
  4871. }
  4872. }
  4873. __proto.getLabelTime=function(label){
  4874. var cnt=this._items.length;
  4875. for (var i=0;i < cnt;i++){
  4876. var item=this._items[i];
  4877. if (item.label==label)
  4878. return item.time;
  4879. else if (item.tweenConfig !=null && item.tweenConfig.endLabel==label)
  4880. return item.time+item.tweenConfig.duration;
  4881. }
  4882. return Number.NaN;
  4883. }
  4884. __proto.updateFromRelations=function(targetId,dx,dy){
  4885. var cnt=this._items.length;
  4886. if (cnt==0)
  4887. return;
  4888. for (var i=0;i < cnt;i++){
  4889. var item=this._items[i];
  4890. if (item.type==0 && item.targetId==targetId){
  4891. if (item.tweenConfig!=null){
  4892. item.tweenConfig.startValue.f1+=dx;
  4893. item.tweenConfig.startValue.f2+=dy;
  4894. item.tweenConfig.endValue.f1+=dx;
  4895. item.tweenConfig.endValue.f2+=dy;
  4896. }
  4897. else{
  4898. item.value.f1+=dx;
  4899. item.value.f2+=dy;
  4900. }
  4901. }
  4902. }
  4903. }
  4904. __proto.onOwnerAddedToStage=function(){
  4905. if (this._autoPlay && !this._playing)
  4906. this.play(null,this._autoPlayTimes,this._autoPlayDelay);
  4907. }
  4908. __proto.onOwnerRemovedFromStage=function(){
  4909. if ((this._options & this.OPTION_AUTO_STOP_DISABLED)==0)
  4910. this.stop((this._options & this.OPTION_AUTO_STOP_AT_END)!=0 ? true :false,false);
  4911. }
  4912. __proto.onDelayedPlay=function(){
  4913. this.internalPlay();
  4914. this._playing=this._totalTasks>0;
  4915. if (this._playing){
  4916. if ((this._options & this.OPTION_IGNORE_DISPLAY_CONTROLLER)!=0){
  4917. var cnt=this._items.length;
  4918. for (var i=0;i < cnt;i++){
  4919. var item=this._items[i];
  4920. if (item.target !=null && item.target!=this._owner)
  4921. item.displayLockToken=item.target.addDisplayLock();
  4922. }
  4923. }
  4924. }
  4925. else if (this._onComplete !=null){
  4926. var handler=this._onComplete;
  4927. this._onComplete=null;
  4928. handler.run();
  4929. }
  4930. }
  4931. __proto.internalPlay=function(){
  4932. this._ownerBaseX=this._owner.x;
  4933. this._ownerBaseY=this._owner.y;
  4934. this._totalTasks=0;
  4935. var cnt=this._items.length;
  4936. var item;
  4937. var needSkipAnimations=false;
  4938. if (!this._reversed){
  4939. for (var i=0;i < cnt;i++){
  4940. item=this._items[i];
  4941. if (item.target==null)
  4942. continue ;
  4943. if (item.type==7 && this._startTime !=0 && item.time <=this._startTime){
  4944. needSkipAnimations=true;
  4945. item.value.flag=false;
  4946. }
  4947. else
  4948. this.playItem(item);
  4949. }
  4950. }
  4951. else{
  4952. for (i=cnt-1;i >=0;i--){
  4953. item=this._items[i];
  4954. if (item.target==null)
  4955. continue ;
  4956. this.playItem(item);
  4957. }
  4958. }
  4959. if (needSkipAnimations)
  4960. this.skipAnimations();
  4961. }
  4962. __proto.playItem=function(item){
  4963. var time=NaN;
  4964. if (item.tweenConfig !=null){
  4965. if (this._reversed)
  4966. time=(this._totalDuration-item.time-item.tweenConfig.duration);
  4967. else
  4968. time=item.time;
  4969. if (this._endTime==-1 || time <=this._endTime){
  4970. var startValue;
  4971. var endValue;
  4972. if(this._reversed){
  4973. startValue=item.tweenConfig.endValue;
  4974. endValue=item.tweenConfig.startValue;
  4975. }
  4976. else{
  4977. startValue=item.tweenConfig.startValue;
  4978. endValue=item.tweenConfig.endValue;
  4979. }
  4980. item.value.b1=startValue.b1 || endValue.b1;
  4981. item.value.b2=startValue.b2 || endValue.b2;
  4982. switch(item.type){
  4983. case 0:
  4984. case 1:
  4985. case 2:
  4986. case 13:
  4987. item.tweener=GTween.to2(startValue.f1,startValue.f2,endValue.f1,endValue.f2,item.tweenConfig.duration);
  4988. break ;
  4989. case 4:
  4990. case 5:
  4991. item.tweener=GTween.to(startValue.f1,endValue.f1,item.tweenConfig.duration);
  4992. break ;
  4993. case 6:
  4994. item.tweener=GTween.toColor(startValue.f1,endValue.f1,item.tweenConfig.duration);
  4995. break ;
  4996. case 12:
  4997. item.tweener=GTween.to4(startValue.f1,startValue.f2,startValue.f3,startValue.f4,
  4998. endValue.f1,endValue.f2,endValue.f3,endValue.f4,item.tweenConfig.duration);
  4999. break ;
  5000. }
  5001. item.tweener.setDelay(time)
  5002. .setEase(item.tweenConfig.easeType)
  5003. .setRepeat(item.tweenConfig.repeat,item.tweenConfig.yoyo)
  5004. .setTimeScale(this._timeScale)
  5005. .setTarget(item)
  5006. .onStart(this.onTweenStart,this)
  5007. .onUpdate(this.onTweenUpdate,this)
  5008. .onComplete(this.onTweenComplete,this);
  5009. if (this._endTime >=0)
  5010. item.tweener.setBreakpoint(this._endTime-time);
  5011. this._totalTasks++;
  5012. }
  5013. }
  5014. else if(item.type==11){
  5015. if (this._reversed)
  5016. time=(this._totalDuration-item.time-item.value.duration);
  5017. else
  5018. time=item.time;
  5019. item.value.offsetX=item.value.offsetY=0;
  5020. item.value.lastOffsetX=item.value.lastOffsetY=0;
  5021. item.tweener=GTween.shake(0,0,item.value.amplitude,item.value.duration)
  5022. .setDelay(time)
  5023. .setTimeScale(this._timeScale)
  5024. .setTarget(item)
  5025. .onUpdate(this.onTweenUpdate,this)
  5026. .onComplete(this.onTweenComplete,this);
  5027. if (this._endTime >=0)
  5028. item.tweener.setBreakpoint(this._endTime-item.time);
  5029. this._totalTasks++;
  5030. }
  5031. else{
  5032. if (this._reversed)
  5033. time=(this._totalDuration-item.time);
  5034. else
  5035. time=item.time;
  5036. if (time <=this._startTime){
  5037. this.applyValue(item);
  5038. this.callHook(item,false);
  5039. }
  5040. else if (this._endTime==-1 || time <=this._endTime){
  5041. this._totalTasks++;
  5042. item.tweener=GTween.delayedCall(time)
  5043. .setTimeScale(this._timeScale)
  5044. .setTarget(item)
  5045. .onComplete(this.onDelayedPlayItem,this);
  5046. }
  5047. }
  5048. if (item.tweener !=null)
  5049. item.tweener.seek(this._startTime);
  5050. }
  5051. __proto.skipAnimations=function(){
  5052. var frame=0;
  5053. var playStartTime=NaN;
  5054. var playTotalTime=NaN;
  5055. var value;
  5056. var target;
  5057. var item;
  5058. var cnt=this._items.length;
  5059. for (var i=0;i < cnt;i++){
  5060. item=this._items[i];
  5061. if (item.type !=7 || item.time > this._startTime)
  5062. continue ;
  5063. value=item.value;
  5064. if (value.flag)
  5065. continue ;
  5066. target=(item.target);
  5067. frame=target.frame;
  5068. playStartTime=target.playing ? 0 :-1;
  5069. playTotalTime=0;
  5070. for (var j=i;j < cnt;j++){
  5071. item=this._items[j];
  5072. if (item.type !=7 || item.target !=target || item.time > this._startTime)
  5073. continue ;
  5074. value=item.value;
  5075. value.flag=true;
  5076. if (value.frame !=-1){
  5077. frame=value.frame;
  5078. if (value.playing)
  5079. playStartTime=item.time;
  5080. else
  5081. playStartTime=-1;
  5082. playTotalTime=0;
  5083. }
  5084. else{
  5085. if (value.playing){
  5086. if (playStartTime < 0)
  5087. playStartTime=item.time;
  5088. }
  5089. else{
  5090. if (playStartTime >=0)
  5091. playTotalTime+=(item.time-playStartTime);
  5092. playStartTime=-1;
  5093. }
  5094. }
  5095. this.callHook(item,false);
  5096. }
  5097. if (playStartTime >=0)
  5098. playTotalTime+=(this._startTime-playStartTime);
  5099. target.playing=playStartTime>=0;
  5100. target.frame=frame;
  5101. if (playTotalTime > 0)
  5102. target.advance(playTotalTime*1000);
  5103. }
  5104. }
  5105. __proto.onDelayedPlayItem=function(tweener){
  5106. var item=tweener.target;
  5107. item.tweener=null;
  5108. this._totalTasks--;
  5109. this.applyValue(item);
  5110. this.callHook(item,false);
  5111. this.checkAllComplete();
  5112. }
  5113. __proto.onTweenStart=function(tweener){
  5114. var item=tweener.target;
  5115. if (item.type==0 || item.type==1){
  5116. var startValue;
  5117. var endValue;
  5118. if (this._reversed){
  5119. startValue=item.tweenConfig.endValue;
  5120. endValue=item.tweenConfig.startValue;
  5121. }
  5122. else{
  5123. startValue=item.tweenConfig.startValue;
  5124. endValue=item.tweenConfig.endValue;
  5125. }
  5126. if (item.type==0){
  5127. if (item.target !=this._owner){
  5128. if (!startValue.b1)
  5129. startValue.f1=item.target.x;
  5130. if (!startValue.b2)
  5131. startValue.f2=item.target.y;
  5132. }
  5133. else{
  5134. if (!startValue.b1)
  5135. startValue.f1=item.target.x-this._ownerBaseX;
  5136. if (!startValue.b2)
  5137. startValue.f2=item.target.y-this._ownerBaseY;
  5138. }
  5139. }
  5140. else{
  5141. if (!startValue.b1)
  5142. startValue.f1=item.target.width;
  5143. if (!startValue.b2)
  5144. startValue.f2=item.target.height;
  5145. }
  5146. if (!endValue.b1)
  5147. endValue.f1=startValue.f1;
  5148. if (!endValue.b2)
  5149. endValue.f2=startValue.f2;
  5150. tweener.startValue.x=startValue.f1;
  5151. tweener.startValue.y=startValue.f2;
  5152. tweener.endValue.x=endValue.f1;
  5153. tweener.endValue.y=endValue.f2;
  5154. }
  5155. this.callHook(item,false);
  5156. }
  5157. __proto.onTweenUpdate=function(tweener){
  5158. var item=tweener.target;
  5159. switch (item.type){
  5160. case 0:
  5161. case 1:
  5162. case 2:
  5163. case 13:
  5164. item.value.f1=tweener.value.x;
  5165. item.value.f2=tweener.value.y;
  5166. break ;
  5167. case 4:
  5168. case 5:
  5169. item.value.f1=tweener.value.x;
  5170. break ;
  5171. case 6:
  5172. item.value.f1=tweener.value.color;
  5173. break ;
  5174. case 12:
  5175. item.value.f1=tweener.value.x;
  5176. item.value.f2=tweener.value.y;
  5177. item.value.f3=tweener.value.z;
  5178. item.value.f4=tweener.value.w;
  5179. break ;
  5180. case 11:
  5181. item.value.offsetX=tweener.deltaValue.x;
  5182. item.value.offsetY=tweener.deltaValue.y;
  5183. break ;
  5184. }
  5185. this.applyValue(item);
  5186. }
  5187. __proto.onTweenComplete=function(tweener){
  5188. var item=tweener.target;
  5189. item.tweener=null;
  5190. this._totalTasks--;
  5191. if (tweener.allCompleted)
  5192. this.callHook(item,true);
  5193. this.checkAllComplete();
  5194. }
  5195. __proto.onPlayTransCompleted=function(item){
  5196. this._totalTasks--;
  5197. this.checkAllComplete();
  5198. }
  5199. __proto.callHook=function(item,tweenEnd){
  5200. if (tweenEnd){
  5201. if (item.tweenConfig!=null && item.tweenConfig.endHook !=null)
  5202. item.tweenConfig.endHook.run();
  5203. }
  5204. else{
  5205. if (item.time >=this._startTime && item.hook !=null)
  5206. item.hook.run();
  5207. }
  5208. }
  5209. __proto.checkAllComplete=function(){
  5210. if (this._playing && this._totalTasks==0){
  5211. if (this._totalTimes < 0){
  5212. this.internalPlay();
  5213. }
  5214. else{
  5215. this._totalTimes--;
  5216. if (this._totalTimes > 0)
  5217. this.internalPlay();
  5218. else{
  5219. this._playing=false;
  5220. var cnt=this._items.length;
  5221. for (var i=0;i < cnt;i++){
  5222. var item=this._items[i];
  5223. if (item.target !=null && item.displayLockToken!=0){
  5224. item.target.releaseDisplayLock(item.displayLockToken);
  5225. item.displayLockToken=0;
  5226. }
  5227. }
  5228. if (this._onComplete !=null){
  5229. var handler=this._onComplete;
  5230. this._onComplete=null;
  5231. handler.run();
  5232. }
  5233. }
  5234. }
  5235. }
  5236. }
  5237. __proto.applyValue=function(item){
  5238. item.target._gearLocked=true;
  5239. switch (item.type){
  5240. case 0:
  5241. if(item.target==this._owner){
  5242. var f1=NaN,f2=NaN;
  5243. if (!item.value.b1)
  5244. f1=item.target.x;
  5245. else
  5246. f1=item.value.f1+this._ownerBaseX;
  5247. if (!item.value.b2)
  5248. f2=item.target.y;
  5249. else
  5250. f2=item.value.f2+this._ownerBaseY;
  5251. item.target.setXY(f1,f2);
  5252. }
  5253. else{
  5254. if (!item.value.b1)
  5255. item.value.f1=item.target.x;
  5256. if (!item.value.b2)
  5257. item.value.f2=item.target.y;
  5258. item.target.setXY(item.value.f1,item.value.f2);
  5259. }
  5260. break ;
  5261. case 1:
  5262. if (!item.value.b1)
  5263. item.value.f1=item.target.width;
  5264. if (!item.value.b2)
  5265. item.value.f2=item.target.height;
  5266. item.target.setSize(item.value.f1,item.value.f2);
  5267. break ;
  5268. case 3:
  5269. item.target.setPivot(item.value.f1,item.value.f2,item.target.pivotAsAnchor);
  5270. break ;
  5271. case 4:
  5272. item.target.alpha=item.value.f1;
  5273. break ;
  5274. case 5:
  5275. item.target.rotation=item.value.f1;
  5276. break ;
  5277. case 2:
  5278. item.target.setScale(item.value.f1,item.value.f2);
  5279. break ;
  5280. case 13:
  5281. item.target.setSkew(item.value.f1,item.value.f2);
  5282. break ;
  5283. case 6:
  5284. (item.target).color=ToolSet.convertToHtmlColor(item.value.f1,false);
  5285. break ;
  5286. case 7:
  5287. if (item.value.frame>=0)
  5288. (item.target).frame=item.value.frame;
  5289. (item.target).playing=item.value.playing;
  5290. (item.target).timeScale=this._timeScale;
  5291. break ;
  5292. case 8:
  5293. item.target.visible=item.value.visible;
  5294. break ;
  5295. case 10:
  5296. if (this._playing){
  5297. var trans=item.value.trans;
  5298. if (trans !=null){
  5299. this._totalTasks++;
  5300. var startTime=this._startTime > item.time ? (this._startTime-item.time):0;
  5301. var endTime=this._endTime >=0 ? (this._endTime-item.time):-1;
  5302. if (item.value.stopTime >=0 && (endTime < 0 || endTime > item.value.stopTime))
  5303. endTime=item.value.stopTime;
  5304. trans.timeScale=this._timeScale;
  5305. trans._play(Handler.create(this,this.onPlayTransCompleted,[item]),item.value.playTimes,0,startTime,endTime,this._reversed);
  5306. }
  5307. }
  5308. break ;
  5309. case 9:
  5310. if (this._playing && item.time >=this._startTime){
  5311. if(item.value.audioClip==null){
  5312. var pi=UIPackage.getItemByURL(item.value.sound);
  5313. if(pi)
  5314. item.value.audioClip=pi.file;
  5315. else
  5316. item.value.audioClip=item.value.sound;
  5317. }
  5318. if(item.value.audioClip)
  5319. GRoot.inst.playOneShotSound(item.value.audioClip,item.value.volume);
  5320. }
  5321. break ;
  5322. case 11:
  5323. item.target.setXY(item.target.x-item.value.lastOffsetX+item.value.offsetX,item.target.y-item.value.lastOffsetY+item.value.offsetY);
  5324. item.value.lastOffsetX=item.value.offsetX;
  5325. item.value.lastOffsetY=item.value.offsetY;
  5326. break ;
  5327. case 12:{
  5328. var arr=item.target.filters;
  5329. var cm=new ColorMatrix();
  5330. cm.adjustBrightness(item.value.f1);
  5331. cm.adjustContrast(item.value.f2);
  5332. cm.adjustSaturation(item.value.f3);
  5333. cm.adjustHue(item.value.f4);
  5334. arr=[new ColorFilter(cm)];
  5335. item.target.filters=arr;
  5336. break ;
  5337. }
  5338. case 14:
  5339. item.target.text=item.value.text;
  5340. break ;
  5341. case 15:
  5342. item.target.icon=item.value.text;
  5343. break ;
  5344. }
  5345. item.target._gearLocked=false;
  5346. }
  5347. __proto.setup=function(buffer){
  5348. this.name=buffer.readS();
  5349. this._options=buffer.getInt32();
  5350. this._autoPlay=buffer.readBool();
  5351. this._autoPlayTimes=buffer.getInt32();
  5352. this._autoPlayDelay=buffer.getFloat32();
  5353. var cnt=buffer.getInt16();
  5354. for (var i=0;i < cnt;i++){
  5355. var dataLen=buffer.getInt16();
  5356. var curPos=buffer.pos;
  5357. buffer.seek(curPos,0);
  5358. var item=new TransitionItem(buffer.readByte());
  5359. this._items[i]=item;
  5360. item.time=buffer.getFloat32();
  5361. var targetId=buffer.getInt16();
  5362. if (targetId < 0)
  5363. item.targetId="";
  5364. else
  5365. item.targetId=this._owner.getChildAt(targetId).id;
  5366. item.label=buffer.readS();
  5367. if (buffer.readBool()){
  5368. buffer.seek(curPos,1);
  5369. item.tweenConfig=new TweenConfig();
  5370. item.tweenConfig.duration=buffer.getFloat32();
  5371. if (item.time+item.tweenConfig.duration > this._totalDuration)
  5372. this._totalDuration=item.time+item.tweenConfig.duration;
  5373. item.tweenConfig.easeType=buffer.readByte();
  5374. item.tweenConfig.repeat=buffer.getInt32();
  5375. item.tweenConfig.yoyo=buffer.readBool();
  5376. item.tweenConfig.endLabel=buffer.readS();
  5377. buffer.seek(curPos,2);
  5378. this.decodeValue(item,buffer,item.tweenConfig.startValue);
  5379. buffer.seek(curPos,3);
  5380. this.decodeValue(item,buffer,item.tweenConfig.endValue);
  5381. }
  5382. else{
  5383. if (item.time > this._totalDuration)
  5384. this._totalDuration=item.time;
  5385. buffer.seek(curPos,2);
  5386. this.decodeValue(item,buffer,item.value);
  5387. }
  5388. buffer.pos=curPos+dataLen;
  5389. }
  5390. }
  5391. __proto.decodeValue=function(item,buffer,value){
  5392. switch(item.type){
  5393. case 0:
  5394. case 1:
  5395. case 3:
  5396. case 13:
  5397. value.b1=buffer.readBool();
  5398. value.b2=buffer.readBool();
  5399. value.f1=buffer.getFloat32();
  5400. value.f2=buffer.getFloat32();
  5401. break ;
  5402. case 4:
  5403. case 5:
  5404. value.f1=buffer.getFloat32();
  5405. break ;
  5406. case 2:
  5407. value.f1=buffer.getFloat32();
  5408. value.f2=buffer.getFloat32();
  5409. break ;
  5410. case 6:
  5411. value.f1=buffer.readColor();
  5412. break ;
  5413. case 7:
  5414. value.playing=buffer.readBool();
  5415. value.frame=buffer.getInt32();
  5416. break ;
  5417. case 8:
  5418. value.visible=buffer.readBool();
  5419. break ;
  5420. case 9:
  5421. value.sound=buffer.readS();
  5422. value.volume=buffer.getFloat32();
  5423. break ;
  5424. case 10:
  5425. value.transName=buffer.readS();
  5426. value.playTimes=buffer.getInt32();
  5427. break ;
  5428. case 11:
  5429. value.amplitude=buffer.getFloat32();
  5430. value.duration=buffer.getFloat32();
  5431. break ;
  5432. case 12:
  5433. value.f1=buffer.getFloat32();
  5434. value.f2=buffer.getFloat32();
  5435. value.f3=buffer.getFloat32();
  5436. value.f4=buffer.getFloat32();
  5437. break ;
  5438. case 14:
  5439. case 15:
  5440. value.text=buffer.readS();
  5441. break ;
  5442. }
  5443. }
  5444. __getset(0,__proto,'playing',function(){
  5445. return this._playing;
  5446. },function(value){
  5447. this._playing=value;
  5448. }
  5449. );
  5450. __getset(0,__proto,'timeScale',function(){
  5451. return this._timeScale;
  5452. },function(value){
  5453. if(this._timeScale !=value){
  5454. this._timeScale=value;
  5455. if (this._playing){
  5456. var cnt=this._items.length;
  5457. for (var i=0;i < cnt;i++){
  5458. var item=this._items[i];
  5459. if (item.tweener !=null)
  5460. item.tweener.setTimeScale(value);
  5461. else if (item.type==10){
  5462. if(item.value.trans !=null)
  5463. item.value.trans.timeScale=value;
  5464. }
  5465. else if(item.type==7){
  5466. if(item.target !=null)
  5467. (item.target).timeScale=value;
  5468. }
  5469. }
  5470. }
  5471. }
  5472. });
  5473. Transition.__init$=function(){
  5474. //class TransitionActionType
  5475. TransitionActionType=(function(){
  5476. function TransitionActionType(){}
  5477. __class(TransitionActionType,'');
  5478. TransitionActionType.XY=0;
  5479. TransitionActionType.Size=1;
  5480. TransitionActionType.Scale=2;
  5481. TransitionActionType.Pivot=3;
  5482. TransitionActionType.Alpha=4;
  5483. TransitionActionType.Rotation=5;
  5484. TransitionActionType.Color=6;
  5485. TransitionActionType.Animation=7;
  5486. TransitionActionType.Visible=8;
  5487. TransitionActionType.Sound=9;
  5488. TransitionActionType.Transition=10;
  5489. TransitionActionType.Shake=11;
  5490. TransitionActionType.ColorFilter=12;
  5491. TransitionActionType.Skew=13;
  5492. TransitionActionType.Text=14;
  5493. TransitionActionType.Icon=15;
  5494. TransitionActionType.Unknown=16;
  5495. return TransitionActionType;
  5496. })()
  5497. //class TransitionItem
  5498. TransitionItem=(function(){
  5499. function TransitionItem(type){
  5500. this.time=NaN;
  5501. this.targetId=null;
  5502. this.type=0;
  5503. this.tweenConfig=null;
  5504. this.label=null;
  5505. this.value=null;
  5506. this.hook=null;
  5507. this.tweener=null;
  5508. this.target=null;
  5509. this.displayLockToken=0;
  5510. this.type=type;
  5511. switch (type){
  5512. case 0:
  5513. case 1:
  5514. case 2:
  5515. case 3:
  5516. case 13:
  5517. case 4:
  5518. case 5:
  5519. case 6:
  5520. case 12:
  5521. this.value=new TValue();
  5522. break ;
  5523. case 7:
  5524. this.value=new TValue_Animation();
  5525. break ;
  5526. case 11:
  5527. this.value=new TValue_Shake();
  5528. break ;
  5529. case 9:
  5530. this.value=new TValue_Sound();
  5531. break ;
  5532. case 10:
  5533. this.value=new TValue_Transition();
  5534. break ;
  5535. case 8:
  5536. this.value=new TValue_Visible();
  5537. break ;
  5538. case 14:
  5539. case 15:
  5540. this.value=new TValue_Text();
  5541. break ;
  5542. }
  5543. }
  5544. __class(TransitionItem,'');
  5545. return TransitionItem;
  5546. })()
  5547. //class TweenConfig
  5548. TweenConfig=(function(){
  5549. function TweenConfig(){
  5550. this.duration=NaN;
  5551. this.easeType=0;
  5552. this.repeat=0;
  5553. this.yoyo=false;
  5554. this.startValue=null;
  5555. this.endValue=null;
  5556. this.endLabel=null;
  5557. this.endHook=null;
  5558. this.easeType=5;
  5559. this.startValue=new TValue();
  5560. this.endValue=new TValue();
  5561. }
  5562. __class(TweenConfig,'');
  5563. return TweenConfig;
  5564. })()
  5565. //class TValue_Visible
  5566. TValue_Visible=(function(){
  5567. function TValue_Visible(){
  5568. this.visible=false;
  5569. }
  5570. __class(TValue_Visible,'');
  5571. return TValue_Visible;
  5572. })()
  5573. //class TValue_Animation
  5574. TValue_Animation=(function(){
  5575. function TValue_Animation(){
  5576. this.frame=0;
  5577. this.playing=false;
  5578. this.flag=false;
  5579. }
  5580. __class(TValue_Animation,'');
  5581. return TValue_Animation;
  5582. })()
  5583. //class TValue_Sound
  5584. TValue_Sound=(function(){
  5585. function TValue_Sound(){
  5586. this.sound=null;
  5587. this.volume=NaN;
  5588. this.audioClip=null;
  5589. }
  5590. __class(TValue_Sound,'');
  5591. return TValue_Sound;
  5592. })()
  5593. //class TValue_Transition
  5594. TValue_Transition=(function(){
  5595. function TValue_Transition(){
  5596. this.transName=null;
  5597. this.playTimes=0;
  5598. this.trans=null;
  5599. this.stopTime=NaN;
  5600. }
  5601. __class(TValue_Transition,'');
  5602. return TValue_Transition;
  5603. })()
  5604. //class TValue_Shake
  5605. TValue_Shake=(function(){
  5606. function TValue_Shake(){
  5607. this.amplitude=NaN;
  5608. this.duration=NaN;
  5609. this.offsetX=NaN;
  5610. this.offsetY=NaN;
  5611. this.lastOffsetX=NaN;
  5612. this.lastOffsetY=NaN;
  5613. }
  5614. __class(TValue_Shake,'');
  5615. return TValue_Shake;
  5616. })()
  5617. //class TValue_Text
  5618. TValue_Text=(function(){
  5619. function TValue_Text(){
  5620. this.text=null;
  5621. }
  5622. __class(TValue_Text,'');
  5623. return TValue_Text;
  5624. })()
  5625. //class TValue
  5626. TValue=(function(){
  5627. function TValue(){
  5628. this.f1=NaN;
  5629. this.f2=NaN;
  5630. this.f3=NaN;
  5631. this.f4=NaN;
  5632. this.b1=false;
  5633. this.b2=false;
  5634. this.b1=this.b2=true;
  5635. }
  5636. __class(TValue,'');
  5637. return TValue;
  5638. })()
  5639. }
  5640. return Transition;
  5641. })()
  5642. //class fairygui.TranslationHelper
  5643. var TranslationHelper=(function(){
  5644. function TranslationHelper(){}
  5645. __class(TranslationHelper,'fairygui.TranslationHelper');
  5646. TranslationHelper.loadFromXML=function(source){
  5647. TranslationHelper.strings={};
  5648. var xml=Utils.parseXMLFromString(source);
  5649. var resNode=TranslationHelper.findChildNode(xml,"resources");
  5650. var nodes=resNode.childNodes;
  5651. var length1=nodes.length;
  5652. for (var i1=0;i1 < length1;i1++){
  5653. var cxml=nodes[i1];
  5654. if (cxml.nodeName=="string"){
  5655. var key=cxml.getAttribute("name");
  5656. var text=cxml.textContent;
  5657. var i=key.indexOf("-");
  5658. if(i==-1)
  5659. continue ;
  5660. var key2=key.substr(0,i);
  5661. var key3=key.substr(i+1);
  5662. var col=TranslationHelper.strings[key2];
  5663. if(!col){
  5664. col={};
  5665. TranslationHelper.strings[key2]=col;
  5666. }
  5667. col[key3]=text;
  5668. }
  5669. }
  5670. }
  5671. TranslationHelper.translateComponent=function(item){
  5672. if(TranslationHelper.strings==null)
  5673. return;
  5674. var compStrings=TranslationHelper.strings[item.owner.id+item.id];
  5675. if(compStrings==null)
  5676. return;
  5677. var elementId,value;
  5678. var buffer=item.rawData;
  5679. var nextPos=0;
  5680. var itemCount=0;
  5681. var i=0,j=0,k=0;
  5682. var dataLen=0;
  5683. var curPos=0;
  5684. var valueCnt=0;
  5685. var page;
  5686. buffer.seek(0,2);
  5687. var childCount=buffer.getInt16();
  5688. for (i=0;i < childCount;i++){
  5689. dataLen=buffer.getInt16();
  5690. curPos=buffer.pos;
  5691. buffer.seek(curPos,0);
  5692. var type=buffer.readByte();
  5693. buffer.skip(4);
  5694. elementId=buffer.readS();
  5695. if (type==9){
  5696. if (buffer.seek(curPos,6))
  5697. type=buffer.readByte();
  5698. }
  5699. buffer.seek(curPos,1);
  5700. if((value=compStrings[elementId+"-tips"])!=null)
  5701. buffer.writeS(value);
  5702. buffer.seek(curPos,2);
  5703. var gearCnt=buffer.getInt16();
  5704. for (j=0;j < gearCnt;j++){
  5705. nextPos=buffer.getInt16();
  5706. nextPos+=buffer.pos;
  5707. if (buffer.readByte()==6){
  5708. buffer.skip(2);
  5709. valueCnt=buffer.getInt16();
  5710. for (k=0;k < valueCnt;k++){
  5711. page=buffer.readS();
  5712. if (page !=null){
  5713. if((value=compStrings[elementId+"-texts_"+k])!=null)
  5714. buffer.writeS(value);
  5715. else
  5716. buffer.skip(2);
  5717. }
  5718. }
  5719. if (buffer.readBool()&& (value=compStrings[elementId+"-texts_def"])!=null)
  5720. buffer.writeS(value);
  5721. }
  5722. buffer.pos=nextPos;
  5723. }
  5724. switch (type){
  5725. case 6:
  5726. case 7:
  5727. case 8:{
  5728. if ((value=compStrings[elementId])!=null){
  5729. buffer.seek(curPos,6);
  5730. buffer.writeS(value);
  5731. }
  5732. if ((value=compStrings[elementId+"-prompt"])!=null){
  5733. buffer.seek(curPos,4);
  5734. buffer.writeS(value);
  5735. }
  5736. break ;
  5737. }
  5738. case 10:{
  5739. buffer.seek(curPos,8);
  5740. buffer.skip(2);
  5741. itemCount=buffer.getInt16();
  5742. for (j=0;j<itemCount;j++){
  5743. nextPos=buffer.getInt16();
  5744. nextPos+=buffer.pos;
  5745. buffer.skip(2);
  5746. if ((value=compStrings[elementId+"-"+j])!=null)
  5747. buffer.writeS(value);
  5748. else
  5749. buffer.skip(2);
  5750. if ((value=compStrings[elementId+"-"+j+"-0"])!=null)
  5751. buffer.writeS(value);
  5752. buffer.pos=nextPos;
  5753. }
  5754. break ;
  5755. }
  5756. case 11:{
  5757. if (buffer.seek(curPos,6)&& buffer.readByte()==type){
  5758. if ((value=compStrings[elementId])!=null)
  5759. buffer.writeS(value);
  5760. else
  5761. buffer.skip(2);
  5762. buffer.skip(2);
  5763. if (buffer.readBool())
  5764. buffer.skip(4);
  5765. buffer.skip(4);
  5766. if (buffer.readBool()&& (value=compStrings[elementId+"-prompt"])!=null)
  5767. buffer.writeS(value);
  5768. }
  5769. break ;
  5770. }
  5771. case 12:{
  5772. if (buffer.seek(curPos,6)&& buffer.readByte()==type){
  5773. if ((value=compStrings[elementId])!=null)
  5774. buffer.writeS(value);
  5775. else
  5776. buffer.skip(2);
  5777. if ((value=compStrings[elementId+"-0"])!=null)
  5778. buffer.writeS(value);
  5779. }
  5780. break ;
  5781. }
  5782. case 13:{
  5783. if (buffer.seek(curPos,6)&& buffer.readByte()==type){
  5784. itemCount=buffer.getInt16();
  5785. for (j=0;j < itemCount;j++){
  5786. nextPos=buffer.getInt16();
  5787. nextPos+=buffer.pos;
  5788. if ((value=compStrings[elementId+"-"+j])!=null)
  5789. buffer.writeS(value);
  5790. buffer.pos=nextPos;
  5791. }
  5792. if ((value=compStrings[elementId])!=null)
  5793. buffer.writeS(value);
  5794. }
  5795. break ;
  5796. }
  5797. }
  5798. buffer.pos=curPos+dataLen;
  5799. }
  5800. }
  5801. TranslationHelper.findChildNode=function(xml,name){
  5802. var col=xml.childNodes;
  5803. var length1=col.length;
  5804. if (length1>0){
  5805. for (var i1=0;i1 < length1;i1++){
  5806. var cxml=col[i1];
  5807. if (cxml.nodeName==name){
  5808. return cxml;
  5809. }
  5810. }
  5811. }
  5812. return null;
  5813. }
  5814. TranslationHelper.strings=null;
  5815. return TranslationHelper;
  5816. })()
  5817. //class fairygui.tree.TreeNode
  5818. var TreeNode=(function(){
  5819. function TreeNode(hasChild){
  5820. this._data=null;
  5821. this._parent=null;
  5822. this._children=null;
  5823. this._expanded=false;
  5824. this._tree=null;
  5825. this._cell=null;
  5826. this._level=0;
  5827. if(hasChild)
  5828. this._children=[];
  5829. }
  5830. __class(TreeNode,'fairygui.tree.TreeNode');
  5831. var __proto=TreeNode.prototype;
  5832. __proto.setCell=function(value){
  5833. this._cell=value;
  5834. }
  5835. __proto.setLevel=function(value){
  5836. this._level=value;
  5837. }
  5838. __proto.addChild=function(child){
  5839. this.addChildAt(child,this._children.length);
  5840. return child;
  5841. }
  5842. __proto.addChildAt=function(child,index){
  5843. if(!child)
  5844. throw new Error("child is null");
  5845. var numChildren=this._children.length;
  5846. if (index >=0 && index <=numChildren){
  5847. if (child._parent==this){
  5848. this.setChildIndex(child,index);
  5849. }
  5850. else{
  5851. if(child._parent)
  5852. child._parent.removeChild(child);
  5853. var cnt=this._children.length;
  5854. if (index==cnt)
  5855. this._children.push(child);
  5856. else
  5857. this._children.splice(index,0,child);
  5858. child._parent=this;
  5859. child._level=this._level+1;
  5860. child.setTree(this._tree);
  5861. if(this._cell!=null && this._cell.parent!=null && this._expanded)
  5862. this._tree.afterInserted(child);
  5863. }
  5864. return child;
  5865. }
  5866. else{
  5867. throw new Error("Invalid child index");
  5868. }
  5869. }
  5870. __proto.removeChild=function(child){
  5871. var childIndex=this._children.indexOf(child);
  5872. if (childIndex !=-1){
  5873. this.removeChildAt(childIndex);
  5874. }
  5875. return child;
  5876. }
  5877. __proto.removeChildAt=function(index){
  5878. if (index >=0 && index < this.numChildren){
  5879. var child=this._children[index];
  5880. this._children.splice(index,1);
  5881. child._parent=null;
  5882. if(this._tree!=null){
  5883. child.setTree(null);
  5884. this._tree.afterRemoved(child);
  5885. }
  5886. return child;
  5887. }
  5888. else{
  5889. throw new Error("Invalid child index");
  5890. }
  5891. }
  5892. __proto.removeChildren=function(beginIndex,endIndex){
  5893. (beginIndex===void 0)&& (beginIndex=0);
  5894. (endIndex===void 0)&& (endIndex=-1);
  5895. if (endIndex < 0 || endIndex >=this.numChildren)
  5896. endIndex=this.numChildren-1;
  5897. for (var i=beginIndex;i<=endIndex;++i)
  5898. this.removeChildAt(beginIndex);
  5899. }
  5900. __proto.getChildAt=function(index){
  5901. if (index >=0 && index < this.numChildren)
  5902. return this._children[index];
  5903. else
  5904. throw new Error("Invalid child index");
  5905. }
  5906. __proto.getChildIndex=function(child){
  5907. return this._children.indexOf(child);
  5908. }
  5909. __proto.getPrevSibling=function(){
  5910. if(this._parent==null)
  5911. return null;
  5912. var i=this._parent._children.indexOf(this);
  5913. if(i<=0)
  5914. return null;
  5915. return this._parent._children[i-1];
  5916. }
  5917. __proto.getNextSibling=function(){
  5918. if(this._parent==null)
  5919. return null;
  5920. var i=this._parent._children.indexOf(this);
  5921. if(i<0 || i>=this._parent._children.length-1)
  5922. return null;
  5923. return this._parent._children[i+1];
  5924. }
  5925. __proto.setChildIndex=function(child,index){
  5926. var oldIndex=this._children.indexOf(child);
  5927. if (oldIndex==-1)
  5928. throw new Error("Not a child of this container");
  5929. var cnt=this._children.length;
  5930. if(index<0)
  5931. index=0;
  5932. else if(index>cnt)
  5933. index=cnt;
  5934. if(oldIndex==index)
  5935. return;
  5936. this._children.splice(oldIndex,1);
  5937. this._children.splice(index,0,child);
  5938. if(this._cell!=null && this._cell.parent!=null && this._expanded)
  5939. this._tree.afterMoved(child);
  5940. }
  5941. __proto.swapChildren=function(child1,child2){
  5942. var index1=this._children.indexOf(child1);
  5943. var index2=this._children.indexOf(child2);
  5944. if (index1==-1 || index2==-1)
  5945. throw new Error("Not a child of this container");
  5946. this.swapChildrenAt(index1,index2);
  5947. }
  5948. __proto.swapChildrenAt=function(index1,index2){
  5949. var child1=this._children[index1];
  5950. var child2=this._children[index2];
  5951. this.setChildIndex(child1,index2);
  5952. this.setChildIndex(child2,index1);
  5953. }
  5954. __proto.setTree=function(value){
  5955. this._tree=value;
  5956. if(this._tree!=null && this._tree.treeNodeWillExpand && this._expanded)
  5957. this._tree.treeNodeWillExpand.runWith(this);
  5958. if(this._children!=null){
  5959. var cnt=this._children.length;
  5960. for(var i=0;i<cnt;i++){
  5961. var node=this._children[i];
  5962. node._level=this._level+1;
  5963. node.setTree(value);
  5964. }
  5965. }
  5966. }
  5967. __getset(0,__proto,'expanded',function(){
  5968. return this._expanded;
  5969. },function(value){
  5970. if(this._children==null)
  5971. return;
  5972. if(this._expanded!=value){
  5973. this._expanded=value;
  5974. if(this._tree!=null){
  5975. if(this._expanded)
  5976. this._tree.afterExpanded(this);
  5977. else
  5978. this._tree.afterCollapsed(this);
  5979. }
  5980. }
  5981. });
  5982. __getset(0,__proto,'tree',function(){
  5983. return this._tree;
  5984. });
  5985. __getset(0,__proto,'level',function(){
  5986. return this._level;
  5987. });
  5988. __getset(0,__proto,'cell',function(){
  5989. return this._cell;
  5990. });
  5991. __getset(0,__proto,'data',function(){
  5992. return this._data;
  5993. },function(value){
  5994. this._data=value;
  5995. });
  5996. __getset(0,__proto,'parent',function(){
  5997. return this._parent;
  5998. });
  5999. __getset(0,__proto,'isFolder',function(){
  6000. return this._children!=null;
  6001. });
  6002. __getset(0,__proto,'text',function(){
  6003. if(this._cell!=null)
  6004. return this._cell.text;
  6005. else
  6006. return null;
  6007. });
  6008. __getset(0,__proto,'numChildren',function(){
  6009. return this._children.length;
  6010. });
  6011. return TreeNode;
  6012. })()
  6013. //class fairygui.tree.TreeView
  6014. var TreeView=(function(){
  6015. function TreeView(list){
  6016. this._list=null;
  6017. this._root=null;
  6018. this._indent=0;
  6019. /**
  6020. *当需要为节点创建一个显示对象时调用这个Handler。参数为节点对象(TreeNode)。应该返回一个GObject。
  6021. */
  6022. this.treeNodeCreateCell=null;
  6023. /**
  6024. *当节点需要渲染时调用这个Handler。参数为节点对象(TreeNode)。
  6025. */
  6026. this.treeNodeRender=null;
  6027. /**
  6028. *当目录节点展开或者收缩时调用这个Handler。参数为节点对象(TreeNode)。可以用节点的expanded属性判断目标状态。
  6029. */
  6030. this.treeNodeWillExpand=null;
  6031. /**
  6032. *当节点被点击时调用这个Handler。参数有两个,第一个为节点对象(TreeNode),第二个为事件对象(Event)。
  6033. */
  6034. this.treeNodeClick=null;
  6035. this._list=list;
  6036. this._list.removeChildrenToPool();
  6037. this._list.on("fui_click_item",this,this.__clickItem);
  6038. this._root=new TreeNode(true);
  6039. this._root.setTree(this);
  6040. this._root.setCell(this._list);
  6041. this._root.expanded=true;
  6042. this._indent=15;
  6043. }
  6044. __class(TreeView,'fairygui.tree.TreeView');
  6045. var __proto=TreeView.prototype;
  6046. __proto.getSelectedNode=function(){
  6047. if(this._list.selectedIndex!=-1)
  6048. return (this._list.getChildAt(this._list.selectedIndex).data);
  6049. else
  6050. return null;
  6051. }
  6052. __proto.getSelection=function(){
  6053. var sels=this._list.getSelection();
  6054. var cnt=sels.length;
  6055. var ret=[];
  6056. for(var i=0;i<cnt;i++){
  6057. var node=(this._list.getChildAt(sels[i]).data);
  6058. ret.push(node);
  6059. }
  6060. return ret;
  6061. }
  6062. __proto.addSelection=function(node,scrollItToView){
  6063. (scrollItToView===void 0)&& (scrollItToView=false);
  6064. var parentNode=node.parent;
  6065. while(parentNode!=null && parentNode!=this._root){
  6066. parentNode.expanded=true;
  6067. parentNode=parentNode.parent;
  6068. }
  6069. if(!node.cell)
  6070. return;
  6071. this._list.addSelection(this._list.getChildIndex(node.cell),scrollItToView);
  6072. }
  6073. __proto.removeSelection=function(node){
  6074. if(!node.cell)
  6075. return;
  6076. this._list.removeSelection(this._list.getChildIndex(node.cell));
  6077. }
  6078. __proto.clearSelection=function(){
  6079. this._list.clearSelection();
  6080. }
  6081. __proto.getNodeIndex=function(node){
  6082. return this._list.getChildIndex(node.cell);
  6083. }
  6084. __proto.updateNode=function(node){
  6085. if(node.cell==null)
  6086. return;
  6087. if(this.treeNodeRender)
  6088. this.treeNodeRender.runWith(node);
  6089. }
  6090. __proto.updateNodes=function(nodes){
  6091. var cnt=nodes.length;
  6092. for(var i=0;i<cnt;i++){
  6093. var node=nodes[i];
  6094. if(node.cell==null)
  6095. return;
  6096. if(this.treeNodeRender)
  6097. this.treeNodeRender.runWith(node);
  6098. }
  6099. }
  6100. __proto.expandAll=function(folderNode){
  6101. folderNode.expanded=true;
  6102. var cnt=folderNode.numChildren;
  6103. for(var i=0;i<cnt;i++){
  6104. var node=folderNode.getChildAt(i);
  6105. if(node.isFolder)
  6106. this.expandAll(node);
  6107. }
  6108. }
  6109. __proto.collapseAll=function(folderNode){
  6110. if(folderNode!=this._root)
  6111. folderNode.expanded=false;
  6112. var cnt=folderNode.numChildren;
  6113. for(var i=0;i<cnt;i++){
  6114. var node=folderNode.getChildAt(i);
  6115. if(node.isFolder)
  6116. this.collapseAll(node);
  6117. }
  6118. }
  6119. __proto.createCell=function(node){
  6120. if(this.treeNodeCreateCell)
  6121. node.setCell(this.treeNodeCreateCell.runWith(node));
  6122. else
  6123. node.setCell((this._list.itemPool.getObject(this._list.defaultItem)));
  6124. node.cell.data=node;
  6125. var indentObj=node.cell.getChild("indent");
  6126. if(indentObj!=null)
  6127. indentObj.width=(node.level-1)*this._indent;
  6128. var expandButton=(node.cell.getChild("expandButton"));
  6129. if(expandButton){
  6130. if(node.isFolder){
  6131. expandButton.visible=true;
  6132. expandButton.onClick(this,this.__clickExpandButton);
  6133. expandButton.data=node;
  6134. expandButton.selected=node.expanded;
  6135. }
  6136. else
  6137. expandButton.visible=false;
  6138. }
  6139. if(this.treeNodeRender)
  6140. this.treeNodeRender.runWith(node);
  6141. }
  6142. __proto.afterInserted=function(node){
  6143. this.createCell(node);
  6144. var index=this.getInsertIndexForNode(node);
  6145. this._list.addChildAt(node.cell,index);
  6146. if(this.treeNodeRender)
  6147. this.treeNodeRender.runWith(node);
  6148. if(node.isFolder && node.expanded)
  6149. this.checkChildren(node,index);
  6150. }
  6151. __proto.getInsertIndexForNode=function(node){
  6152. var prevNode=node.getPrevSibling();
  6153. if(prevNode==null)
  6154. prevNode=node.parent;
  6155. var insertIndex=this._list.getChildIndex(prevNode.cell)+1;
  6156. var myLevel=node.level;
  6157. var cnt=this._list.numChildren;
  6158. for(var i=insertIndex;i<cnt;i++){
  6159. var testNode=(this._list.getChildAt(i).data);
  6160. if(testNode.level<=myLevel)
  6161. break ;
  6162. insertIndex++;
  6163. }
  6164. return insertIndex;
  6165. }
  6166. __proto.afterRemoved=function(node){
  6167. this.removeNode(node);
  6168. }
  6169. __proto.afterExpanded=function(node){
  6170. if(node!=this._root && this.treeNodeWillExpand)
  6171. this.treeNodeWillExpand(node);
  6172. if(node.cell==null)
  6173. return;
  6174. if(node!=this._root){
  6175. if(this.treeNodeRender)
  6176. this.treeNodeRender.runWith(node);
  6177. var expandButton=(node.cell.getChild("expandButton"));
  6178. if(expandButton)
  6179. expandButton.selected=true;
  6180. }
  6181. if(node.cell.parent!=null)
  6182. this.checkChildren(node,this._list.getChildIndex(node.cell));
  6183. }
  6184. __proto.afterCollapsed=function(node){
  6185. if(node!=this._root && this.treeNodeWillExpand)
  6186. this.treeNodeWillExpand(node);
  6187. if(node.cell==null)
  6188. return;
  6189. if(node!=this._root){
  6190. if(this.treeNodeRender)
  6191. this.treeNodeRender.runWith(node);
  6192. var expandButton=(node.cell.getChild("expandButton"));
  6193. if(expandButton)
  6194. expandButton.selected=false;
  6195. }
  6196. if(node.cell.parent!=null)
  6197. this.hideFolderNode(node);
  6198. }
  6199. __proto.afterMoved=function(node){
  6200. if(!node.isFolder)
  6201. this._list.removeChild(node.cell);
  6202. else
  6203. this.hideFolderNode(node);
  6204. var index=this.getInsertIndexForNode(node);
  6205. this._list.addChildAt(node.cell,index);
  6206. if(node.isFolder && node.expanded)
  6207. this.checkChildren(node,index);
  6208. }
  6209. __proto.checkChildren=function(folderNode,index){
  6210. var cnt=folderNode.numChildren;
  6211. for(var i=0;i<cnt;i++){
  6212. index++;
  6213. var node=folderNode.getChildAt(i);
  6214. if(node.cell==null)
  6215. this.createCell(node);
  6216. if(!node.cell.parent)
  6217. this._list.addChildAt(node.cell,index);
  6218. if(node.isFolder && node.expanded)
  6219. index=this.checkChildren(node,index);
  6220. }
  6221. return index;
  6222. }
  6223. __proto.hideFolderNode=function(folderNode){
  6224. var cnt=folderNode.numChildren;
  6225. for(var i=0;i<cnt;i++){
  6226. var node=folderNode.getChildAt(i);
  6227. if(node.cell && node.cell.parent!=null)
  6228. this._list.removeChild(node.cell);
  6229. if(node.isFolder && node.expanded)
  6230. this.hideFolderNode(node);
  6231. }
  6232. }
  6233. __proto.removeNode=function(node){
  6234. if(node.cell!=null){
  6235. if(node.cell.parent!=null)
  6236. this._list.removeChild(node.cell);
  6237. this._list.returnToPool(node.cell);
  6238. node.cell.data=null;
  6239. node.setCell(null);
  6240. }
  6241. if(node.isFolder){
  6242. var cnt=node.numChildren;
  6243. for(var i=0;i<cnt;i++){
  6244. var node2=node.getChildAt(i);
  6245. this.removeNode(node2);
  6246. }
  6247. }
  6248. }
  6249. __proto.__clickExpandButton=function(evt){
  6250. evt.stopPropagation();
  6251. var expandButton=(GObject.cast(evt.currentTarget));
  6252. var node=(expandButton.parent.data);
  6253. if(this._list.scrollPane!=null){
  6254. var posY=this._list.scrollPane.posY;
  6255. if(expandButton.selected)
  6256. node.expanded=true;
  6257. else
  6258. node.expanded=false;
  6259. this._list.scrollPane.posY=posY;
  6260. this._list.scrollPane.scrollToView(node.cell);
  6261. }
  6262. else{
  6263. if(expandButton.selected)
  6264. node.expanded=true;
  6265. else
  6266. node.expanded=false;
  6267. }
  6268. }
  6269. __proto.__clickItem=function(item,evt){
  6270. if(this._list.scrollPane!=null)
  6271. var posY=this._list.scrollPane.posY;
  6272. var node=(item.data);
  6273. if(this.treeNodeClick)
  6274. this.treeNodeClick.runWith([node,evt]);
  6275. if(this._list.scrollPane!=null){
  6276. this._list.scrollPane.posY=posY;
  6277. if(node.cell)
  6278. this._list.scrollPane.scrollToView(node.cell);
  6279. }
  6280. }
  6281. __getset(0,__proto,'list',function(){
  6282. return this._list;
  6283. });
  6284. __getset(0,__proto,'root',function(){
  6285. return this._root;
  6286. });
  6287. __getset(0,__proto,'indent',function(){
  6288. return this._indent;
  6289. },function(value){
  6290. this._indent=value;
  6291. });
  6292. return TreeView;
  6293. })()
  6294. //class fairygui.tween.EaseManager
  6295. var EaseManager=(function(){
  6296. var Bounce;
  6297. function EaseManager(){}
  6298. __class(EaseManager,'fairygui.tween.EaseManager');
  6299. EaseManager.evaluate=function(easeType,time,duration,overshootOrAmplitude,period){
  6300. switch (easeType){
  6301. case 0:
  6302. return time / duration;
  6303. case 1:
  6304. return-Math.cos(time / duration *EaseManager._PiOver2)+1;
  6305. case 2:
  6306. return Math.sin(time / duration *EaseManager._PiOver2);
  6307. case 3:
  6308. return-0.5 *(Math.cos(Math.PI *time / duration)-1);
  6309. case 4:
  6310. return (time /=duration)*time;
  6311. case 5:
  6312. return-(time /=duration)*(time-2);
  6313. case 6:
  6314. if ((time /=duration *0.5)< 1)return 0.5 *time *time;
  6315. return-0.5 *((--time)*(time-2)-1);
  6316. case 7:
  6317. return (time /=duration)*time *time;
  6318. case 8:
  6319. return ((time=time / duration-1)*time *time+1);
  6320. case 9:
  6321. if ((time /=duration *0.5)< 1)return 0.5 *time *time *time;
  6322. return 0.5 *((time-=2)*time *time+2);
  6323. case 10:
  6324. return (time /=duration)*time *time *time;
  6325. case 11:
  6326. return-((time=time / duration-1)*time *time *time-1);
  6327. case 12:
  6328. if ((time /=duration *0.5)< 1)return 0.5 *time *time *time *time;
  6329. return-0.5 *((time-=2)*time *time *time-2);
  6330. case 13:
  6331. return (time /=duration)*time *time *time *time;
  6332. case 14:
  6333. return ((time=time / duration-1)*time *time *time *time+1);
  6334. case 15:
  6335. if ((time /=duration *0.5)< 1)return 0.5 *time *time *time *time *time;
  6336. return 0.5 *((time-=2)*time *time *time *time+2);
  6337. case 16:
  6338. return (time==0)? 0 :Math.pow(2,10 *(time / duration-1));
  6339. case 17:
  6340. if (time==duration)return 1;
  6341. return (-Math.pow(2,-10 *time / duration)+1);
  6342. case 18:
  6343. if (time==0)return 0;
  6344. if (time==duration)return 1;
  6345. if ((time /=duration *0.5)< 1)return 0.5 *Math.pow(2,10 *(time-1));
  6346. return 0.5 *(-Math.pow(2,-10 *--time)+2);
  6347. case 19:
  6348. return-(Math.sqrt(1-(time /=duration)*time)-1);
  6349. case 20:
  6350. return Math.sqrt(1-(time=time / duration-1)*time);
  6351. case 21:
  6352. if ((time /=duration *0.5)< 1)return-0.5 *(Math.sqrt(1-time *time)-1);
  6353. return 0.5 *(Math.sqrt(1-(time-=2)*time)+1);
  6354. case 22:;
  6355. var s0=NaN;
  6356. if (time==0)return 0;
  6357. if ((time /=duration)==1)return 1;
  6358. if (period==0)period=duration *0.3;
  6359. if (overshootOrAmplitude < 1){
  6360. overshootOrAmplitude=1;
  6361. s0=period / 4;
  6362. }
  6363. else s0=period / EaseManager._TwoPi *Math.asin(1 / overshootOrAmplitude);
  6364. return-(overshootOrAmplitude *Math.pow(2,10 *(time-=1))*Math.sin((time *duration-s0)*EaseManager._TwoPi / period));
  6365. case 23:;
  6366. var s1=NaN;
  6367. if (time==0)return 0;
  6368. if ((time /=duration)==1)return 1;
  6369. if (period==0)period=duration *0.3;
  6370. if (overshootOrAmplitude < 1){
  6371. overshootOrAmplitude=1;
  6372. s1=period / 4;
  6373. }
  6374. else s1=period / EaseManager._TwoPi *Math.asin(1 / overshootOrAmplitude);
  6375. return (overshootOrAmplitude *Math.pow(2,-10 *time)*Math.sin((time *duration-s1)*EaseManager._TwoPi / period)+1);
  6376. case 24:;
  6377. var s=NaN;
  6378. if (time==0)return 0;
  6379. if ((time /=duration *0.5)==2)return 1;
  6380. if (period==0)period=duration *(0.3 *1.5);
  6381. if (overshootOrAmplitude < 1){
  6382. overshootOrAmplitude=1;
  6383. s=period / 4;
  6384. }
  6385. else s=period / EaseManager._TwoPi *Math.asin(1 / overshootOrAmplitude);
  6386. if (time < 1)return-0.5 *(overshootOrAmplitude *Math.pow(2,10 *(time-=1))*Math.sin((time *duration-s)*EaseManager._TwoPi / period));
  6387. return overshootOrAmplitude *Math.pow(2,-10 *(time-=1))*Math.sin((time *duration-s)*EaseManager._TwoPi / period)*0.5+1;
  6388. case 25:
  6389. return (time /=duration)*time *((overshootOrAmplitude+1)*time-overshootOrAmplitude);
  6390. case 26:
  6391. return ((time=time / duration-1)*time *((overshootOrAmplitude+1)*time+overshootOrAmplitude)+1);
  6392. case 27:
  6393. if ((time /=duration *0.5)< 1)return 0.5 *(time *time *(((overshootOrAmplitude *=(1.525))+1)*time-overshootOrAmplitude));
  6394. return 0.5 *((time-=2)*time *(((overshootOrAmplitude *=(1.525))+1)*time+overshootOrAmplitude)+2);
  6395. case 28:
  6396. return Bounce.easeIn(time,duration);
  6397. case 29:
  6398. return Bounce.easeOut(time,duration);
  6399. case 30:
  6400. return Bounce.easeInOut(time,duration);
  6401. default :
  6402. return-(time /=duration)*(time-2);
  6403. }
  6404. }
  6405. __static(EaseManager,
  6406. ['_PiOver2',function(){return this._PiOver2=Math.PI *0.5;},'_TwoPi',function(){return this._TwoPi=Math.PI *2;}
  6407. ]);
  6408. EaseManager.__init$=function(){
  6409. /// This class contains a C# port of the easing equations created by Robert Penner (http://robertpenner.com/easing).
  6410. //class Bounce
  6411. Bounce=(function(){
  6412. function Bounce(){}
  6413. __class(Bounce,'');
  6414. Bounce.easeIn=function(time,duration){
  6415. return 1-Bounce.easeOut(duration-time,duration);
  6416. }
  6417. Bounce.easeOut=function(time,duration){
  6418. if ((time /=duration)< (1 / 2.75)){
  6419. return (7.5625 *time *time);
  6420. }
  6421. if (time < (2 / 2.75)){
  6422. return (7.5625 *(time-=(1.5 / 2.75))*time+0.75);
  6423. }
  6424. if (time < (2.5 / 2.75)){
  6425. return (7.5625 *(time-=(2.25 / 2.75))*time+0.9375);
  6426. }
  6427. return (7.5625 *(time-=(2.625 / 2.75))*time+0.984375);
  6428. }
  6429. Bounce.easeInOut=function(time,duration){
  6430. if (time < duration *0.5){
  6431. return Bounce.easeIn(time *2,duration)*0.5;
  6432. }
  6433. return Bounce.easeOut(time *2-duration,duration)*0.5+0.5;
  6434. }
  6435. return Bounce;
  6436. })()
  6437. }
  6438. return EaseManager;
  6439. })()
  6440. //class fairygui.tween.EaseType
  6441. var EaseType=(function(){
  6442. function EaseType(){}
  6443. __class(EaseType,'fairygui.tween.EaseType');
  6444. EaseType.Linear=0;
  6445. EaseType.SineIn=1;
  6446. EaseType.SineOut=2;
  6447. EaseType.SineInOut=3;
  6448. EaseType.QuadIn=4;
  6449. EaseType.QuadOut=5;
  6450. EaseType.QuadInOut=6;
  6451. EaseType.CubicIn=7;
  6452. EaseType.CubicOut=8;
  6453. EaseType.CubicInOut=9;
  6454. EaseType.QuartIn=10;
  6455. EaseType.QuartOut=11;
  6456. EaseType.QuartInOut=12;
  6457. EaseType.QuintIn=13;
  6458. EaseType.QuintOut=14;
  6459. EaseType.QuintInOut=15;
  6460. EaseType.ExpoIn=16;
  6461. EaseType.ExpoOut=17;
  6462. EaseType.ExpoInOut=18;
  6463. EaseType.CircIn=19;
  6464. EaseType.CircOut=20;
  6465. EaseType.CircInOut=21;
  6466. EaseType.ElasticIn=22;
  6467. EaseType.ElasticOut=23;
  6468. EaseType.ElasticInOut=24;
  6469. EaseType.BackIn=25;
  6470. EaseType.BackOut=26;
  6471. EaseType.BackInOut=27;
  6472. EaseType.BounceIn=28;
  6473. EaseType.BounceOut=29;
  6474. EaseType.BounceInOut=30;
  6475. EaseType.Custom=31;
  6476. return EaseType;
  6477. })()
  6478. //class fairygui.tween.GTween
  6479. var GTween=(function(){
  6480. function GTween(){}
  6481. __class(GTween,'fairygui.tween.GTween');
  6482. GTween.to=function(start,end,duration){
  6483. return TweenManager.createTween()._to(start,end,duration);
  6484. }
  6485. GTween.to2=function(start,start2,end,end2,duration){
  6486. return TweenManager.createTween()._to2(start,start2,end,end2,duration);
  6487. }
  6488. GTween.to3=function(start,start2,start3,end,end2,end3,duration){
  6489. return TweenManager.createTween()._to3(start,start2,start3,end,end2,end3,duration);
  6490. }
  6491. GTween.to4=function(start,start2,start3,start4,end,end2,end3,end4,duration){
  6492. return TweenManager.createTween()._to4(start,start2,start3,start4,end,end2,end3,end4,duration);
  6493. }
  6494. GTween.toColor=function(start,end,duration){
  6495. return TweenManager.createTween()._toColor(start,end,duration);
  6496. }
  6497. GTween.delayedCall=function(delay){
  6498. return TweenManager.createTween().setDelay(delay);
  6499. }
  6500. GTween.shake=function(startX,startY,amplitude,duration){
  6501. return TweenManager.createTween()._shake(startX,startY,amplitude,duration);
  6502. }
  6503. GTween.isTweening=function(target,propType){
  6504. return TweenManager.isTweening(target,propType);
  6505. }
  6506. GTween.kill=function(target,complete,propType){
  6507. (complete===void 0)&& (complete=false);
  6508. TweenManager.killTweens(target,false,null);
  6509. }
  6510. GTween.getTween=function(target,propType){
  6511. return TweenManager.getTween(target,propType);
  6512. }
  6513. GTween.catchCallbackExceptions=true;
  6514. return GTween;
  6515. })()
  6516. //class fairygui.tween.GTweener
  6517. var GTweener=(function(){
  6518. function GTweener(){
  6519. this._target=null;
  6520. this._propType=null;
  6521. this._killed=false;
  6522. this._paused=false;
  6523. this._delay=NaN;
  6524. this._duration=NaN;
  6525. this._breakpoint=NaN;
  6526. this._easeType=0;
  6527. this._easeOvershootOrAmplitude=NaN;
  6528. this._easePeriod=NaN;
  6529. this._repeat=0;
  6530. this._yoyo=false;
  6531. this._timeScale=NaN;
  6532. this._snapping=false;
  6533. this._userData=null;
  6534. this._onUpdate=null;
  6535. this._onUpdateCaller=null;
  6536. this._onStart=null;
  6537. this._onStartCaller=null;
  6538. this._onComplete=null;
  6539. this._onCompleteCaller=null;
  6540. this._startValue=null;
  6541. this._endValue=null;
  6542. this._value=null;
  6543. this._deltaValue=null;
  6544. this._valueSize=0;
  6545. this._started=false;
  6546. this._ended=0;
  6547. this._elapsedTime=NaN;
  6548. this._normalizedTime=NaN;
  6549. this._startValue=new TweenValue();
  6550. this._endValue=new TweenValue();
  6551. this._value=new TweenValue();
  6552. this._deltaValue=new TweenValue();
  6553. this._reset();
  6554. }
  6555. __class(GTweener,'fairygui.tween.GTweener');
  6556. var __proto=GTweener.prototype;
  6557. __proto.setDelay=function(value){
  6558. this._delay=value;
  6559. return this;
  6560. }
  6561. __proto.setDuration=function(value){
  6562. this._duration=value;
  6563. return this;
  6564. }
  6565. __proto.setBreakpoint=function(value){
  6566. this._breakpoint=value;
  6567. return this;
  6568. }
  6569. __proto.setEase=function(value){
  6570. this._easeType=value;
  6571. return this;
  6572. }
  6573. __proto.setEasePeriod=function(value){
  6574. this._easePeriod=value;
  6575. return this;
  6576. }
  6577. __proto.setEaseOvershootOrAmplitude=function(value){
  6578. this._easeOvershootOrAmplitude=value;
  6579. return this;
  6580. }
  6581. __proto.setRepeat=function(repeat,yoyo){
  6582. (yoyo===void 0)&& (yoyo=false);
  6583. this._repeat=repeat;
  6584. this._yoyo=yoyo;
  6585. return this;
  6586. }
  6587. __proto.setTimeScale=function(value){
  6588. this._timeScale=value;
  6589. return this;
  6590. }
  6591. __proto.setSnapping=function(value){
  6592. this._snapping=value;
  6593. return this;
  6594. }
  6595. __proto.setTarget=function(value,propType){
  6596. this._target=value;
  6597. this._propType=propType;
  6598. return this;
  6599. }
  6600. __proto.setUserData=function(value){
  6601. this._userData=value;
  6602. return this;
  6603. }
  6604. __proto.onUpdate=function(callback,caller){
  6605. this._onUpdate=callback;
  6606. this._onUpdateCaller=caller;
  6607. return this;
  6608. }
  6609. __proto.onStart=function(callback,caller){
  6610. this._onStart=callback;
  6611. this._onStartCaller=caller;
  6612. return this;
  6613. }
  6614. __proto.onComplete=function(callback,caller){
  6615. this._onComplete=callback;
  6616. this._onCompleteCaller=caller;
  6617. return this;
  6618. }
  6619. __proto.setPaused=function(paused){
  6620. this._paused=paused;
  6621. return this;
  6622. }
  6623. /**
  6624. *seek position of the tween,in seconds.
  6625. */
  6626. __proto.seek=function(time){
  6627. if (this._killed)
  6628. return;
  6629. this._elapsedTime=time;
  6630. if (this._elapsedTime < this._delay){
  6631. if (this._started)
  6632. this._elapsedTime=this._delay;
  6633. else
  6634. return;
  6635. }
  6636. this.update();
  6637. }
  6638. __proto.kill=function(complete){
  6639. (complete===void 0)&& (complete=false);
  6640. if (this._killed)
  6641. return;
  6642. if (complete){
  6643. if (this._ended==0){
  6644. if (this._breakpoint >=0)
  6645. this._elapsedTime=this._delay+this._breakpoint;
  6646. else if (this._repeat >=0)
  6647. this._elapsedTime=this._delay+this._duration *(this._repeat+1);
  6648. else
  6649. this._elapsedTime=this._delay+this._duration *2;
  6650. this.update();
  6651. }
  6652. this.callCompleteCallback();
  6653. }
  6654. this._killed=true;
  6655. }
  6656. __proto._to=function(start,end,duration){
  6657. this._valueSize=1;
  6658. this._startValue.x=start;
  6659. this._endValue.x=end;
  6660. this._duration=duration;
  6661. return this;
  6662. }
  6663. __proto._to2=function(start,start2,end,end2,duration){
  6664. this._valueSize=2;
  6665. this._startValue.x=start;
  6666. this._endValue.x=end;
  6667. this._startValue.y=start2;
  6668. this._endValue.y=end2;
  6669. this._duration=duration;
  6670. return this;
  6671. }
  6672. __proto._to3=function(start,start2,start3,end,end2,end3,duration){
  6673. this._valueSize=3;
  6674. this._startValue.x=start;
  6675. this._endValue.x=end;
  6676. this._startValue.y=start2;
  6677. this._endValue.y=end2;
  6678. this._startValue.z=start3;
  6679. this._endValue.z=end3;
  6680. this._duration=duration;
  6681. return this;
  6682. }
  6683. __proto._to4=function(start,start2,start3,start4,end,end2,end3,end4,duration){
  6684. this._valueSize=4;
  6685. this._startValue.x=start;
  6686. this._endValue.x=end;
  6687. this._startValue.y=start2;
  6688. this._endValue.y=end2;
  6689. this._startValue.z=start3;
  6690. this._endValue.z=end3;
  6691. this._startValue.w=start4;
  6692. this._endValue.w=end4;
  6693. this._duration=duration;
  6694. return this;
  6695. }
  6696. __proto._toColor=function(start,end,duration){
  6697. this._valueSize=4;
  6698. this._startValue.color=start;
  6699. this._endValue.color=end;
  6700. this._duration=duration;
  6701. return this;
  6702. }
  6703. __proto._shake=function(startX,startY,amplitude,duration){
  6704. this._valueSize=5;
  6705. this._startValue.x=startX;
  6706. this._startValue.y=startY;
  6707. this._startValue.w=amplitude;
  6708. this._duration=duration;
  6709. this._easeType=0;
  6710. return this;
  6711. }
  6712. __proto._init=function(){
  6713. this._delay=0;
  6714. this._duration=0;
  6715. this._breakpoint=-1;
  6716. this._easeType=5;
  6717. this._timeScale=1;
  6718. this._easePeriod=0;
  6719. this._easeOvershootOrAmplitude=1.70158;
  6720. this._snapping=false;
  6721. this._repeat=0;
  6722. this._yoyo=false;
  6723. this._valueSize=0;
  6724. this._started=false;
  6725. this._paused=false;
  6726. this._killed=false;
  6727. this._elapsedTime=0;
  6728. this._normalizedTime=0;
  6729. this._ended=0;
  6730. }
  6731. __proto._reset=function(){
  6732. this._target=null;
  6733. this._userData=null;
  6734. this._onStart=this._onUpdate=this._onComplete=null;
  6735. this._onStartCaller=this._onUpdateCaller=this._onCompleteCaller=null;
  6736. }
  6737. __proto._update=function(dt){
  6738. if (this._timeScale !=1)
  6739. dt *=this._timeScale;
  6740. if (dt==0)
  6741. return;
  6742. if (this._ended !=0){
  6743. this.callCompleteCallback();
  6744. this._killed=true;
  6745. return;
  6746. }
  6747. this._elapsedTime+=dt;
  6748. this.update();
  6749. if (this._ended !=0){
  6750. if (!this._killed){
  6751. this.callCompleteCallback();
  6752. this._killed=true;
  6753. }
  6754. }
  6755. }
  6756. __proto.update=function(){
  6757. this._ended=0;
  6758. if (this._valueSize==0){
  6759. if (this._elapsedTime >=this._delay+this._duration)
  6760. this._ended=1;
  6761. return;
  6762. }
  6763. if (!this._started){
  6764. if (this._elapsedTime < this._delay)
  6765. return;
  6766. this._started=true;
  6767. this.callStartCallback();
  6768. if (this._killed)
  6769. return;
  6770. };
  6771. var reversed=false;
  6772. var tt=this._elapsedTime-this._delay;
  6773. if (this._breakpoint >=0 && tt >=this._breakpoint){
  6774. tt=this._breakpoint;
  6775. this._ended=2;
  6776. }
  6777. if (this._repeat !=0){
  6778. var round=Math.floor(tt / this._duration);
  6779. tt-=this._duration *round;
  6780. if (this._yoyo)
  6781. reversed=round % 2==1;
  6782. if (this._repeat > 0 && this._repeat-round < 0){
  6783. if (this._yoyo)
  6784. reversed=this._repeat % 2==1;
  6785. tt=this._duration;
  6786. this._ended=1;
  6787. }
  6788. }
  6789. else if (tt >=this._duration){
  6790. tt=this._duration;
  6791. this._ended=1;
  6792. }
  6793. this._normalizedTime=EaseManager.evaluate(this._easeType,reversed ? (this._duration-tt):tt,this._duration,
  6794. this._easeOvershootOrAmplitude,this._easePeriod);
  6795. this._value.setZero();
  6796. this._deltaValue.setZero();
  6797. if (this._valueSize==5){
  6798. if (this._ended==0){
  6799. var r=this._startValue.w*(1-this._normalizedTime);
  6800. var rx=(Math.random()*2-1)*r;
  6801. var ry=(Math.random()*2-1)*r;
  6802. rx=rx > 0 ? Math.ceil(rx):Math.floor(rx);
  6803. ry=ry > 0 ? Math.ceil(ry):Math.floor(ry);
  6804. this._deltaValue.x=rx;
  6805. this._deltaValue.y=ry;
  6806. this._value.x=this._startValue.x+rx;
  6807. this._value.y=this._startValue.y+ry;
  6808. }
  6809. else{
  6810. this._value.x=this._startValue.x;
  6811. this._value.y=this._startValue.y;
  6812. }
  6813. }
  6814. else{
  6815. for (var i=0;i < this._valueSize;i++){
  6816. var n1=this._startValue.getField(i);
  6817. var n2=this._endValue.getField(i);
  6818. var f=n1+(n2-n1)*this._normalizedTime;
  6819. if (this._snapping)
  6820. f=Math.round(f);
  6821. this._deltaValue.setField(i,f-this._value.getField(i));
  6822. this._value.setField(i,f);
  6823. }
  6824. }
  6825. if (this._target !=null && this._propType !=null){
  6826. if((typeof this._propType=='function')){
  6827. switch(this._valueSize){
  6828. case 1:
  6829. this._propType.call(this._target,this._value.x);
  6830. break ;
  6831. case 2:
  6832. this._propType.call(this._target,this._value.x,this._value.y);
  6833. break ;
  6834. case 3:
  6835. this._propType.call(this._target,this._value.x,this._value.y,this._value.z);
  6836. break ;
  6837. case 4:
  6838. this._propType.call(this._target,this._value.x,this._value.y,this._value.z,this._value.w);
  6839. break ;
  6840. case 5:
  6841. this._propType.call(this._target,this._value.color);
  6842. break ;
  6843. case 6:
  6844. this._propType.call(this._target,this._value.x,this._value.y);
  6845. break ;
  6846. }
  6847. }
  6848. else{
  6849. if(this._valueSize==5)
  6850. this._target[this._propType]=this._value.color;
  6851. else
  6852. this._target[this._propType]=this._value.x;
  6853. }
  6854. }
  6855. this.callUpdateCallback();
  6856. }
  6857. __proto.callStartCallback=function(){
  6858. if (this._onStart !=null){
  6859. if(GTween.catchCallbackExceptions){
  6860. try{
  6861. this._onStart.call(this._onStartCaller,this);
  6862. }
  6863. catch(err){
  6864. console.log("FairyGUI: error in start callback > "+err.message);
  6865. }
  6866. }
  6867. else
  6868. this._onStart.call(this._onStartCaller,this);
  6869. }
  6870. }
  6871. __proto.callUpdateCallback=function(){
  6872. if (this._onUpdate !=null){
  6873. if(GTween.catchCallbackExceptions){
  6874. try{
  6875. this._onUpdate.call(this._onUpdateCaller,this);
  6876. }
  6877. catch(err){
  6878. console.log("FairyGUI: error in update callback > "+err.message);
  6879. }
  6880. }
  6881. else
  6882. this._onUpdate.call(this._onUpdateCaller,this);
  6883. }
  6884. }
  6885. __proto.callCompleteCallback=function(){
  6886. if (this._onComplete !=null){
  6887. if(GTween.catchCallbackExceptions){
  6888. try{
  6889. this._onComplete.call(this._onCompleteCaller,this);
  6890. }
  6891. catch(err){
  6892. console.log("FairyGUI: error in complete callback > "+err.message);
  6893. }
  6894. }
  6895. else
  6896. this._onComplete.call(this._onCompleteCaller,this);
  6897. }
  6898. }
  6899. __getset(0,__proto,'target',function(){
  6900. return this._target;
  6901. });
  6902. __getset(0,__proto,'delay',function(){
  6903. return this._delay;
  6904. });
  6905. __getset(0,__proto,'duration',function(){
  6906. return this._duration;
  6907. });
  6908. __getset(0,__proto,'value',function(){
  6909. return this._value;
  6910. });
  6911. __getset(0,__proto,'userData',function(){
  6912. return this._userData;
  6913. });
  6914. __getset(0,__proto,'repeat',function(){
  6915. return this._repeat;
  6916. });
  6917. __getset(0,__proto,'startValue',function(){
  6918. return this._startValue;
  6919. });
  6920. __getset(0,__proto,'endValue',function(){
  6921. return this._endValue;
  6922. });
  6923. __getset(0,__proto,'deltaValue',function(){
  6924. return this._deltaValue;
  6925. });
  6926. __getset(0,__proto,'normalizedTime',function(){
  6927. return this._normalizedTime;
  6928. });
  6929. __getset(0,__proto,'completed',function(){
  6930. return this._ended !=0;
  6931. });
  6932. __getset(0,__proto,'allCompleted',function(){
  6933. return this._ended==1;
  6934. });
  6935. return GTweener;
  6936. })()
  6937. //class fairygui.tween.TweenManager
  6938. var TweenManager=(function(){
  6939. function TweenManager(){}
  6940. __class(TweenManager,'fairygui.tween.TweenManager');
  6941. TweenManager.createTween=function(){
  6942. if (!TweenManager._inited){
  6943. Laya.timer.frameLoop(1,null,TweenManager.update);
  6944. TweenManager._inited=true;
  6945. };
  6946. var tweener;
  6947. var cnt=TweenManager._tweenerPool.length;
  6948. if (cnt > 0){
  6949. tweener=TweenManager._tweenerPool.pop();
  6950. }
  6951. else
  6952. tweener=new GTweener();
  6953. tweener._init();
  6954. TweenManager._activeTweens[TweenManager._totalActiveTweens++]=tweener;
  6955. if (TweenManager._totalActiveTweens==TweenManager._activeTweens.length)
  6956. TweenManager._activeTweens.length=TweenManager._activeTweens.length+Math.ceil(TweenManager._activeTweens.length *0.5);
  6957. return tweener;
  6958. }
  6959. TweenManager.isTweening=function(target,propType){
  6960. if (target==null)
  6961. return false;
  6962. var anyType=propType==null;
  6963. for (var i=0;i < TweenManager._totalActiveTweens;i++){
  6964. var tweener=TweenManager._activeTweens[i];
  6965. if (tweener !=null && tweener.target==target && !tweener._killed
  6966. && (anyType || tweener._propType==propType))
  6967. return true;
  6968. }
  6969. return false;
  6970. }
  6971. TweenManager.killTweens=function(target,completed,propType){
  6972. if (target==null)
  6973. return false;
  6974. var flag=false;
  6975. var cnt=TweenManager._totalActiveTweens;
  6976. var anyType=propType==null;
  6977. for (var i=0;i < cnt;i++){
  6978. var tweener=TweenManager._activeTweens[i];
  6979. if (tweener !=null && tweener.target==target && !tweener._killed
  6980. && (anyType || tweener._propType==propType)){
  6981. tweener.kill(completed);
  6982. flag=true;
  6983. }
  6984. }
  6985. return flag;
  6986. }
  6987. TweenManager.getTween=function(target,propType){
  6988. if (target==null)
  6989. return null;
  6990. var cnt=TweenManager._totalActiveTweens;
  6991. var anyType=propType==null;
  6992. for (var i=0;i < cnt;i++){
  6993. var tweener=TweenManager._activeTweens[i];
  6994. if (tweener !=null && tweener.target==target && !tweener._killed
  6995. && (anyType || tweener._propType==propType)){
  6996. return tweener;
  6997. }
  6998. }
  6999. return null;
  7000. }
  7001. TweenManager.update=function(){
  7002. var dt=Laya.timer.delta/1000;
  7003. var cnt=TweenManager._totalActiveTweens;
  7004. var freePosStart=-1;
  7005. var freePosCount=0;
  7006. for (var i=0;i < cnt;i++){
  7007. var tweener=TweenManager._activeTweens[i];
  7008. if (tweener==null){
  7009. if (freePosStart==-1)
  7010. freePosStart=i;
  7011. freePosCount++;
  7012. }
  7013. else if (tweener._killed){
  7014. tweener._reset();
  7015. TweenManager._tweenerPool.push(tweener);
  7016. TweenManager._activeTweens[i]=null;
  7017. if (freePosStart==-1)
  7018. freePosStart=i;
  7019. freePosCount++;
  7020. }
  7021. else{
  7022. if(!tweener._paused)
  7023. tweener._update(dt);
  7024. if (freePosStart !=-1){
  7025. TweenManager._activeTweens[freePosStart]=tweener;
  7026. TweenManager._activeTweens[i]=null;
  7027. freePosStart++;
  7028. }
  7029. }
  7030. }
  7031. if (freePosStart >=0){
  7032. if (TweenManager._totalActiveTweens !=cnt){
  7033. var j=cnt;
  7034. cnt=TweenManager._totalActiveTweens-cnt;
  7035. for (i=0;i < cnt;i++)
  7036. TweenManager._activeTweens[freePosStart++]=TweenManager._activeTweens[j++];
  7037. }
  7038. TweenManager._totalActiveTweens=freePosStart;
  7039. }
  7040. }
  7041. TweenManager._tweenerPool=[];
  7042. TweenManager._totalActiveTweens=0;
  7043. TweenManager._inited=false;
  7044. __static(TweenManager,
  7045. ['_activeTweens',function(){return this._activeTweens=new Array(30);}
  7046. ]);
  7047. return TweenManager;
  7048. })()
  7049. //class fairygui.tween.TweenValue
  7050. var TweenValue=(function(){
  7051. function TweenValue(){
  7052. this.x=NaN;
  7053. this.y=NaN;
  7054. this.z=NaN;
  7055. this.w=NaN;
  7056. this.x=this.y=this.z=this.w=0;
  7057. }
  7058. __class(TweenValue,'fairygui.tween.TweenValue');
  7059. var __proto=TweenValue.prototype;
  7060. __proto.getField=function(index){
  7061. switch (index){
  7062. case 0:
  7063. return this.x;
  7064. case 1:
  7065. return this.y;
  7066. case 2:
  7067. return this.z;
  7068. case 3:
  7069. return this.w;
  7070. default :
  7071. throw new Error("Index out of bounds: "+index);
  7072. }
  7073. }
  7074. __proto.setField=function(index,value){
  7075. switch (index){
  7076. case 0:
  7077. this.x=value;
  7078. break ;
  7079. case 1:
  7080. this.y=value;
  7081. break ;
  7082. case 2:
  7083. this.z=value;
  7084. break ;
  7085. case 3:
  7086. this.w=value;
  7087. break ;
  7088. default :
  7089. throw new Error("Index out of bounds: "+index);
  7090. }
  7091. }
  7092. __proto.setZero=function(){
  7093. this.x=this.y=this.z=this.w=0;
  7094. }
  7095. __getset(0,__proto,'color',function(){
  7096. return (this.w<<24)+(this.x<<16)+(this.y<<8)+this.z;
  7097. },function(value){
  7098. this.x=(value & 0xFF0000)>>16;
  7099. this.y=(value & 0x00FF00)>>8;
  7100. this.z=(value & 0x0000FF);
  7101. this.w=(value & 0xFF000000)>>24;
  7102. });
  7103. return TweenValue;
  7104. })()
  7105. //class fairygui.UIConfig
  7106. var UIConfig$1=(function(){
  7107. function UIConfig(){}
  7108. __class(UIConfig,'fairygui.UIConfig',null,'UIConfig$1');
  7109. UIConfig.defaultFont="SimSun";
  7110. UIConfig.windowModalWaiting=null;
  7111. UIConfig.globalModalWaiting=null;
  7112. UIConfig.modalLayerColor="rgba(33,33,33,0.2)";
  7113. UIConfig.buttonSound=null;
  7114. UIConfig.buttonSoundVolumeScale=1;
  7115. UIConfig.horizontalScrollBar=null;
  7116. UIConfig.verticalScrollBar=null;
  7117. UIConfig.defaultScrollStep=25;
  7118. UIConfig.defaultScrollDecelerationRate=0.967;
  7119. UIConfig.defaultScrollBarDisplay=1;
  7120. UIConfig.defaultScrollTouchEffect=true;
  7121. UIConfig.defaultScrollBounceEffect=true;
  7122. UIConfig.popupMenu=null;
  7123. UIConfig.popupMenu_seperator=null;
  7124. UIConfig.loaderErrorSign=null;
  7125. UIConfig.tooltipsWin=null;
  7126. UIConfig.defaultComboBoxVisibleItemCount=10;
  7127. UIConfig.touchScrollSensitivity=20;
  7128. UIConfig.touchDragSensitivity=10;
  7129. UIConfig.clickDragSensitivity=2;
  7130. UIConfig.bringWindowToFrontOnClick=true;
  7131. UIConfig.frameTimeForAsyncUIConstruction=2;
  7132. UIConfig.textureLinearSampling=true;
  7133. UIConfig.packageFileExtension="fui";
  7134. UIConfig.versions="";
  7135. UIConfig.resourceurl="";
  7136. UIConfig.equipPlatform="";
  7137. UIConfig.gameWidth=0;
  7138. UIConfig.gameHeight=0;
  7139. UIConfig.disTips=3000;
  7140. UIConfig.gameBgResousedict=null;
  7141. UIConfig.maskLayer=null;
  7142. UIConfig.gameEffectDict=null;
  7143. UIConfig.gameLoaderManager=null;
  7144. return UIConfig;
  7145. })()
  7146. //class fairygui.UIObjectFactory
  7147. var UIObjectFactory=(function(){
  7148. function UIObjectFactory(){}
  7149. __class(UIObjectFactory,'fairygui.UIObjectFactory');
  7150. UIObjectFactory.setPackageItemExtension=function(url,type){
  7151. if (url==null)
  7152. throw new Error("Invaild url: "+url);
  7153. var pi=UIPackage.getItemByURL(url);
  7154. if (pi !=null)
  7155. pi.extensionType=type;
  7156. UIObjectFactory.packageItemExtensions[url]=type;
  7157. }
  7158. UIObjectFactory.setLoaderExtension=function(type){
  7159. fairygui.UIObjectFactory.loaderType=type;
  7160. }
  7161. UIObjectFactory.resolvePackageItemExtension=function(pi){
  7162. pi.extensionType=UIObjectFactory.packageItemExtensions["ui://"+pi.owner.id+pi.id];
  7163. if(!pi.extensionType)
  7164. pi.extensionType=UIObjectFactory.packageItemExtensions["ui://"+pi.owner.name+"/"+pi.name];
  7165. }
  7166. UIObjectFactory.newObject=function(pi){
  7167. if(pi.extensionType!=null)
  7168. return new pi.extensionType();
  7169. else
  7170. return UIObjectFactory.newObject2(pi.objectType);
  7171. }
  7172. UIObjectFactory.newObject2=function(type){
  7173. switch (type){
  7174. case 0:
  7175. return new GImage();
  7176. case 1:
  7177. return new GMovieClip();
  7178. case 9:
  7179. return new GComponent();
  7180. case 6:
  7181. return new GBasicTextField();
  7182. case 7:
  7183. return new GRichTextField();
  7184. case 8:
  7185. return new GTextInput();
  7186. case 5:
  7187. return new GGroup();
  7188. case 10:
  7189. return new GList();
  7190. case 3:
  7191. return new GGraph();
  7192. case 4:
  7193. if (fairygui.UIObjectFactory.loaderType !=null)
  7194. return new fairygui.UIObjectFactory.loaderType();
  7195. else
  7196. return new GLoader();
  7197. case 12:
  7198. return new GButton();
  7199. case 11:
  7200. return new GLabel();
  7201. case 14:
  7202. return new GProgressBar();
  7203. case 15:
  7204. return new GSlider();
  7205. case 16:
  7206. return new GScrollBar();
  7207. case 13:
  7208. return new GComboBox();
  7209. default :
  7210. return null;
  7211. }
  7212. }
  7213. UIObjectFactory.packageItemExtensions={};
  7214. UIObjectFactory.loaderType=null;
  7215. return UIObjectFactory;
  7216. })()
  7217. //class fairygui.UIPackage
  7218. var UIPackage=(function(){
  7219. var AtlasSprite;
  7220. function UIPackage(){
  7221. this._id=null;
  7222. this._name=null;
  7223. this._items=null;
  7224. this._itemsById=null;
  7225. this._itemsByName=null;
  7226. this._customId=null;
  7227. this._sprites=null;
  7228. this._items=[];
  7229. this._itemsById={};
  7230. this._itemsByName={};
  7231. this._sprites={};
  7232. }
  7233. __class(UIPackage,'fairygui.UIPackage');
  7234. var __proto=UIPackage.prototype;
  7235. __proto.loadPackage=function(buffer,resKey){
  7236. if (buffer.getUint32()!=0x46475549)
  7237. throw new Error("FairyGUI: old package format found in '"+resKey+"'");
  7238. buffer.version=buffer.getInt32();
  7239. var compressed=buffer.readBool();
  7240. this._id=buffer.readUTFString();
  7241. this._name=buffer.readUTFString();
  7242. buffer.skip(20);
  7243. if(compressed){
  7244. var buf=new Uint8Array(buffer.buffer,buffer.pos,buffer.length-buffer.pos);
  7245. var inflater=new Zlib.RawInflate(buf);buf=inflater.decompress();;
  7246. buffer=new ByteBuffer(buf);
  7247. };
  7248. var indexTablePos=buffer.pos;
  7249. var cnt=0;
  7250. var i=0;
  7251. var nextPos=0;
  7252. buffer.seek(indexTablePos,4);
  7253. cnt=buffer.getInt32();
  7254. var stringTable=__newvec(cnt);
  7255. for (i=0;i < cnt;i++)
  7256. stringTable[i]=buffer.readUTFString();
  7257. buffer.stringTable=stringTable;
  7258. buffer.seek(indexTablePos,1);
  7259. var pi;
  7260. resKey=resKey+"_";
  7261. cnt=buffer.getUint16();
  7262. for (i=0;i < cnt;i++){
  7263. nextPos=buffer.getInt32();
  7264. nextPos+=buffer.pos;
  7265. pi=new PackageItem();
  7266. pi.owner=this;
  7267. pi.type=buffer.readByte();
  7268. pi.id=buffer.readS();
  7269. pi.name=buffer.readS();
  7270. buffer.readS();
  7271. pi.file=buffer.readS();
  7272. buffer.readBool();
  7273. pi.width=buffer.getInt32();
  7274. pi.height=buffer.getInt32();
  7275. switch (pi.type){
  7276. case 0:{
  7277. pi.objectType=0;
  7278. var scaleOption=buffer.readByte();
  7279. if (scaleOption==1){
  7280. pi.scale9Grid=new laya.maths.Rectangle();
  7281. pi.scale9Grid.x=buffer.getInt32();
  7282. pi.scale9Grid.y=buffer.getInt32();
  7283. pi.scale9Grid.width=buffer.getInt32();
  7284. pi.scale9Grid.height=buffer.getInt32();
  7285. pi.tileGridIndice=buffer.getInt32();
  7286. }
  7287. else if (scaleOption==2)
  7288. pi.scaleByTile=true;
  7289. pi.smoothing=buffer.readBool();
  7290. break ;
  7291. }
  7292. case 1:{
  7293. pi.smoothing=buffer.readBool();
  7294. pi.objectType=1;
  7295. pi.rawData=buffer.readBuffer();
  7296. break ;
  7297. }
  7298. case 5:{
  7299. pi.rawData=buffer.readBuffer();
  7300. break ;
  7301. }
  7302. case 3:{
  7303. var extension=buffer.readByte();
  7304. if (extension > 0)
  7305. pi.objectType=extension;
  7306. else
  7307. pi.objectType=9;
  7308. pi.rawData=buffer.readBuffer();
  7309. UIObjectFactory.resolvePackageItemExtension(pi);
  7310. break ;
  7311. }
  7312. case 4:
  7313. case 2:
  7314. case 7:{
  7315. pi.file=resKey+pi.file;
  7316. break ;
  7317. }
  7318. }
  7319. this._items.push(pi);
  7320. this._itemsById[pi.id]=pi;
  7321. if (pi.name !=null)
  7322. this._itemsByName[pi.name]=pi;
  7323. buffer.pos=nextPos;
  7324. }
  7325. buffer.seek(indexTablePos,2);
  7326. cnt=buffer.getUint16();
  7327. for (i=0;i < cnt;i++){
  7328. nextPos=buffer.getUint16();
  7329. nextPos+=buffer.pos;
  7330. var itemId=buffer.readS();
  7331. pi=this._itemsById[buffer.readS()];
  7332. var sprite=new AtlasSprite();
  7333. sprite.atlas=pi;
  7334. sprite.rect.x=buffer.getInt32();
  7335. sprite.rect.y=buffer.getInt32();
  7336. sprite.rect.width=buffer.getInt32();
  7337. sprite.rect.height=buffer.getInt32();
  7338. sprite.rotated=buffer.readBool();
  7339. this._sprites[itemId]=sprite;
  7340. buffer.pos=nextPos;
  7341. }
  7342. if (buffer.seek(indexTablePos,3)){
  7343. cnt=buffer.getUint16();
  7344. for (i=0;i < cnt;i++){
  7345. nextPos=buffer.getInt32();
  7346. nextPos+=buffer.pos;
  7347. pi=this._itemsById[buffer.readS()];
  7348. if (pi && pi.type==0){
  7349. pi.pixelHitTestData=new PixelHitTestData();
  7350. pi.pixelHitTestData.load(buffer);
  7351. }
  7352. buffer.pos=nextPos;
  7353. }
  7354. }
  7355. }
  7356. __proto.loadAllAssets=function(){
  7357. var cnt=this._items.length;
  7358. for(var i=0;i < cnt;i++){
  7359. var pi=this._items[i];
  7360. this.getItemAsset(pi);
  7361. }
  7362. }
  7363. __proto.unloadAssets=function(){
  7364. var cnt=this._items.length;
  7365. for(var i=0;i < cnt;i++){
  7366. var pi=this._items[i];
  7367. if(pi.type==4){
  7368. if(pi.texture!=null)
  7369. Laya.loader.clearTextureRes(pi.texture.url);
  7370. }
  7371. }
  7372. }
  7373. __proto.dispose=function(){
  7374. var cnt=this._items.length;
  7375. for(var i=0;i < cnt;i++){
  7376. var pi=this._items[i];
  7377. if(pi.type==4){
  7378. if(pi.texture!=null){
  7379. pi.texture.destroy();
  7380. pi.texture=null;
  7381. }
  7382. }
  7383. else if(pi.type==2){
  7384. SoundManager.destroySound(pi.file);
  7385. }
  7386. }
  7387. }
  7388. __proto.createObject=function(resName,userClass){
  7389. var pi=this._itemsByName[resName];
  7390. if (pi)
  7391. return this.internalCreateObject(pi,userClass);
  7392. else
  7393. return null;
  7394. }
  7395. __proto.internalCreateObject=function(item,userClass){
  7396. var g;
  7397. if (item.type==3){
  7398. if (userClass !=null)
  7399. g=new userClass();
  7400. else
  7401. g=UIObjectFactory.newObject(item);
  7402. }
  7403. else
  7404. g=UIObjectFactory.newObject(item);
  7405. if (g==null)
  7406. return null;
  7407. fairygui.UIPackage._constructing++;
  7408. g.packageItem=item;
  7409. g.constructFromResource();
  7410. fairygui.UIPackage._constructing--;
  7411. return g;
  7412. }
  7413. __proto.getItemById=function(itemId){
  7414. return this._itemsById[itemId];
  7415. }
  7416. __proto.getItemByName=function(resName){
  7417. return this._itemsByName[resName];
  7418. }
  7419. __proto.getItemAssetByName=function(resName){
  7420. var pi=this._itemsByName[resName];
  7421. if (pi==null){
  7422. throw "Resource not found -"+resName;
  7423. }
  7424. return this.getItemAsset(pi);
  7425. }
  7426. __proto.getItemAsset=function(item){
  7427. switch (item.type){
  7428. case 0:
  7429. if (!item.decoded){
  7430. item.decoded=true;
  7431. var sprite=this._sprites[item.id];
  7432. if (sprite !=null)
  7433. item.texture=this.createSpriteTexture(sprite);
  7434. else
  7435. item.texture=null;
  7436. }
  7437. return item.texture;
  7438. case 4:
  7439. if (!item.decoded){
  7440. item.decoded=true;
  7441. item.texture=AssetProxy.inst.getRes(item.file);
  7442. if(!UIConfig$1.textureLinearSampling)
  7443. item.texture.isLinearSampling=false;
  7444. }
  7445. return item.texture;
  7446. case 5:
  7447. if (!item.decoded){
  7448. item.decoded=true;
  7449. this.loadFont(item);
  7450. }
  7451. return item.bitmapFont;
  7452. case 1:
  7453. if (!item.decoded){
  7454. item.decoded=true;
  7455. this.loadMovieClip(item);
  7456. }
  7457. return item.frames;
  7458. case 3:
  7459. return item.rawData;
  7460. case 7:
  7461. if(item.file)
  7462. return AssetProxy.inst.getRes(item.file);
  7463. else
  7464. return null;
  7465. default :
  7466. return null;
  7467. }
  7468. }
  7469. __proto.createSpriteTexture=function(sprite){
  7470. var atlasTexture=(this.getItemAsset(sprite.atlas));
  7471. return Texture.createFromTexture(atlasTexture,
  7472. sprite.rect.x,sprite.rect.y,sprite.rect.width,sprite.rect.height);
  7473. }
  7474. __proto.loadMovieClip=function(item){
  7475. var buffer=item.rawData;
  7476. buffer.seek(0,0);
  7477. item.interval=buffer.getInt32();
  7478. item.swing=buffer.readBool();
  7479. item.repeatDelay=buffer.getInt32();
  7480. buffer.seek(0,1);
  7481. var frameCount=buffer.getInt16();
  7482. item.frames=__newvec(frameCount);
  7483. var spriteId;
  7484. var frame;
  7485. var sprite;
  7486. for (var i=0;i < frameCount;i++){
  7487. var nextPos=buffer.getInt16();
  7488. nextPos+=buffer.pos;
  7489. frame=new Frame();
  7490. frame.rect.x=buffer.getInt32();
  7491. frame.rect.y=buffer.getInt32();
  7492. frame.rect.width=buffer.getInt32();
  7493. frame.rect.height=buffer.getInt32();
  7494. frame.addDelay=buffer.getInt32();
  7495. spriteId=buffer.readS();
  7496. if (spriteId !=null && (sprite=this._sprites[spriteId])!=null)
  7497. frame.texture=this.createSpriteTexture(sprite);
  7498. item.frames[i]=frame;
  7499. buffer.pos=nextPos;
  7500. }
  7501. }
  7502. __proto.loadFont=function(item){
  7503. var font=new BitmapFont$1();
  7504. item.bitmapFont=font;
  7505. var buffer=item.rawData;
  7506. buffer.seek(0,0);
  7507. font.ttf=buffer.readBool();
  7508. buffer.readBool();
  7509. font.resizable=buffer.readBool();
  7510. buffer.readBool();
  7511. font.size=buffer.getInt32();
  7512. var xadvance=buffer.getInt32();
  7513. var lineHeight=buffer.getInt32();
  7514. var mainTexture=null;
  7515. var mainSprite=this._sprites[item.id];
  7516. if (mainSprite!=null)
  7517. mainTexture=(this.getItemAsset(mainSprite.atlas));
  7518. buffer.seek(0,1);
  7519. var bg=null;
  7520. var cnt=buffer.getInt32();
  7521. for (var i=0;i < cnt;i++){
  7522. var nextPos=buffer.getInt16();
  7523. nextPos+=buffer.pos;
  7524. bg=new BMGlyph();
  7525. var ch=buffer.readChar();
  7526. font.glyphs[ch]=bg;
  7527. var img=buffer.readS();
  7528. var bx=buffer.getInt32();
  7529. var by=buffer.getInt32();
  7530. bg.offsetX=buffer.getInt32();
  7531. bg.offsetY=buffer.getInt32();
  7532. bg.width=buffer.getInt32();
  7533. bg.height=buffer.getInt32();
  7534. bg.advance=buffer.getInt32();
  7535. bg.channel=buffer.readByte();
  7536. if (bg.channel==1)
  7537. bg.channel=3;
  7538. else if (bg.channel==2)
  7539. bg.channel=2;
  7540. else if (bg.channel==3)
  7541. bg.channel=1;
  7542. if (!font.ttf){
  7543. var charImg=this._itemsById[img];
  7544. if (charImg){
  7545. this.getItemAsset(charImg);
  7546. bg.width=charImg.width;
  7547. bg.height=charImg.height;
  7548. bg.texture=charImg.texture;
  7549. }
  7550. }
  7551. else{
  7552. bg.texture=Texture.createFromTexture(mainTexture,
  7553. bx+mainSprite.rect.x,by+mainSprite.rect.y,bg.width,bg.height);
  7554. }
  7555. if (font.ttf)
  7556. bg.lineHeight=lineHeight;
  7557. else{
  7558. if (bg.advance==0){
  7559. if (xadvance==0)
  7560. bg.advance=bg.offsetX+bg.width;
  7561. else
  7562. bg.advance=xadvance;
  7563. }
  7564. bg.lineHeight=bg.offsetY < 0 ? bg.height :(bg.offsetY+bg.height);
  7565. if (bg.lineHeight < font.size)
  7566. bg.lineHeight=font.size;
  7567. }
  7568. buffer.pos=nextPos;
  7569. }
  7570. }
  7571. __getset(0,__proto,'id',function(){
  7572. return this._id;
  7573. });
  7574. __getset(0,__proto,'name',function(){
  7575. return this._name;
  7576. });
  7577. __getset(0,__proto,'customId',function(){
  7578. return this._customId;
  7579. },function(value){
  7580. if (this._customId !=null)
  7581. delete fairygui.UIPackage._packageInstById[this._customId];
  7582. this._customId=value;
  7583. if (this._customId !=null)
  7584. fairygui.UIPackage._packageInstById[this._customId]=this;
  7585. });
  7586. UIPackage.getById=function(id){
  7587. return fairygui.UIPackage._packageInstById[id];
  7588. }
  7589. UIPackage.getByName=function(name){
  7590. return fairygui.UIPackage._packageInstByName[name];
  7591. }
  7592. UIPackage.addPackage=function(resKey,pkgName,descData){
  7593. var pkg = fairygui.UIPackage._packageInstByName[pkgName];
  7594. if(!pkg){
  7595. if(!descData){
  7596. descData=AssetProxy.inst.getRes(resKey+"."+UIConfig$1.packageFileExtension);
  7597. if(!descData || descData.length==0)
  7598. throw new Error("package resource not ready: "+resKey);
  7599. };
  7600. var buffer=new ByteBuffer(descData);
  7601. var pkg=new UIPackage();
  7602. pkg.loadPackage(buffer,resKey);
  7603. fairygui.UIPackage._packageInstById[pkg.id]=pkg;
  7604. fairygui.UIPackage._packageInstByName[pkg.name]=pkg;
  7605. pkg.customId=resKey;
  7606. }
  7607. return pkg;
  7608. }
  7609. UIPackage.removePackage=function(packageIdOrName){
  7610. var pkg=fairygui.UIPackage._packageInstById[packageIdOrName];
  7611. if(!pkg)
  7612. pkg=fairygui.UIPackage._packageInstByName[packageIdOrName];
  7613. if(!pkg)
  7614. return;
  7615. pkg.dispose();
  7616. delete fairygui.UIPackage._packageInstById[pkg.id];
  7617. if(pkg._customId !=null)
  7618. delete fairygui.UIPackage._packageInstById[pkg._customId];
  7619. delete fairygui.UIPackage._packageInstByName[pkg.name];
  7620. }
  7621. UIPackage.createObject=function(pkgName,resName,userClass){
  7622. var pkg=fairygui.UIPackage.getByName(pkgName);
  7623. if(pkg)
  7624. return pkg.createObject(resName,userClass);
  7625. else
  7626. return null;
  7627. }
  7628. UIPackage.createObjectFromURL=function(url,userClass){
  7629. var pi=fairygui.UIPackage.getItemByURL(url);
  7630. if(pi)
  7631. return pi.owner.internalCreateObject(pi,userClass);
  7632. else
  7633. return null;
  7634. }
  7635. UIPackage.getItemURL=function(pkgName,resName){
  7636. var pkg=fairygui.UIPackage.getByName(pkgName);
  7637. if(!pkg)
  7638. return null;
  7639. var pi=pkg._itemsByName[resName];
  7640. if(!pi)
  7641. return null;
  7642. return "ui://"+pkg.id+pi.id;
  7643. }
  7644. UIPackage.getItemByURL=function(url){
  7645. var pos1=url.indexOf("//");
  7646. if (pos1==-1)
  7647. return null;
  7648. var pos2=url.indexOf("/",pos1+2);
  7649. if (pos2==-1){
  7650. if (url.length > 13){
  7651. var pkgId=url.substr(5,8);
  7652. var pkg=UIPackage.getById(pkgId);
  7653. if (pkg !=null){
  7654. var srcId=url.substr(13);
  7655. return pkg.getItemById(srcId);
  7656. }
  7657. }
  7658. }
  7659. else{
  7660. var pkgName=url.substr(pos1+2,pos2-pos1-2);
  7661. pkg=UIPackage.getByName(pkgName);
  7662. if (pkg !=null){
  7663. var srcName=url.substr(pos2+1);
  7664. return pkg.getItemByName(srcName);
  7665. }
  7666. }
  7667. return null;
  7668. }
  7669. UIPackage.getItemAssetByURL=function(url){
  7670. var item=UIPackage.getItemByURL(url);
  7671. if (item==null)
  7672. return null;
  7673. return item.owner.getItemAsset(item);
  7674. }
  7675. UIPackage.normalizeURL=function(url){
  7676. if(url==null)
  7677. return null;
  7678. var pos1=url.indexOf("//");
  7679. if (pos1==-1)
  7680. return null;
  7681. var pos2=url.indexOf("/",pos1+2);
  7682. if (pos2==-1)
  7683. return url;
  7684. var pkgName=url.substr(pos1+2,pos2-pos1-2);
  7685. var srcName=url.substr(pos2+1);
  7686. return UIPackage.getItemURL(pkgName,srcName);
  7687. }
  7688. UIPackage.setStringsSource=function(source){
  7689. TranslationHelper.loadFromXML(source);
  7690. }
  7691. UIPackage._constructing=0;
  7692. UIPackage._packageInstById={};
  7693. UIPackage._packageInstByName={};
  7694. UIPackage.__init$=function(){
  7695. //class AtlasSprite
  7696. AtlasSprite=(function(){
  7697. function AtlasSprite(){
  7698. this.atlas=null;
  7699. this.rect=null;
  7700. this.rotated=false;
  7701. this.rect=new Rectangle();
  7702. }
  7703. __class(AtlasSprite,'');
  7704. return AtlasSprite;
  7705. })()
  7706. }
  7707. return UIPackage;
  7708. })()
  7709. //class fairygui.utils.PixelHitTestData
  7710. var PixelHitTestData=(function(){
  7711. function PixelHitTestData(){
  7712. this.pixelWidth=0;
  7713. this.scale=NaN;
  7714. this.pixels=null;
  7715. }
  7716. __class(PixelHitTestData,'fairygui.utils.PixelHitTestData');
  7717. var __proto=PixelHitTestData.prototype;
  7718. __proto.load=function(ba){
  7719. ba.getInt32();
  7720. this.pixelWidth=ba.getInt32();
  7721. this.scale=1/ba.readByte();
  7722. var len=ba.getInt32();
  7723. this.pixels=__newvec(len);
  7724. for(var i=0;i<len;i++){
  7725. var j=ba.readByte();
  7726. if(j<0)
  7727. j+=256;
  7728. this.pixels[i]=j;
  7729. }
  7730. }
  7731. return PixelHitTestData;
  7732. })()
  7733. //class fairygui.utils.ToolSet
  7734. var ToolSet=(function(){
  7735. function ToolSet(){}
  7736. __class(ToolSet,'fairygui.utils.ToolSet');
  7737. ToolSet.getFileName=function(source){
  7738. var i=source.lastIndexOf("/");
  7739. if (i !=-1)
  7740. source=source.substr(i+1);
  7741. i=source.lastIndexOf("\\");
  7742. if (i !=-1)
  7743. source=source.substr(i+1);
  7744. i=source.lastIndexOf(".");
  7745. if (i !=-1)
  7746. return source.substring(0,i);
  7747. else
  7748. return source;
  7749. }
  7750. ToolSet.startsWith=function(source,str,ignoreCase){
  7751. (ignoreCase===void 0)&& (ignoreCase=false);
  7752. if (!source)
  7753. return false;
  7754. else if (source.length < str.length)
  7755. return false;
  7756. else {
  7757. source=source.substring(0,str.length);
  7758. if (!ignoreCase)
  7759. return source==str;
  7760. else
  7761. return source.toLowerCase()==str.toLowerCase();
  7762. }
  7763. }
  7764. ToolSet.endsWith=function(source,str,ignoreCase){
  7765. (ignoreCase===void 0)&& (ignoreCase=false);
  7766. if (!source)
  7767. return false;
  7768. else if (source.length < str.length)
  7769. return false;
  7770. else {
  7771. source=source.substring(source.length-str.length);
  7772. if (!ignoreCase)
  7773. return source==str;
  7774. else
  7775. return source.toLowerCase()==str.toLowerCase();
  7776. }
  7777. }
  7778. ToolSet.trim=function(targetString){
  7779. return fairygui.utils.ToolSet.trimLeft(fairygui.utils.ToolSet.trimRight(targetString));
  7780. }
  7781. ToolSet.trimLeft=function(targetString){
  7782. var tempChar="";
  7783. for (var i=0;i < targetString.length;i++){
  7784. tempChar=targetString.charAt(i);
  7785. if (tempChar !=" " && tempChar !="\n" && tempChar !="\r"){
  7786. break ;
  7787. }
  7788. }
  7789. return targetString.substr(i);
  7790. }
  7791. ToolSet.trimRight=function(targetString){
  7792. var tempChar="";
  7793. for (var i=targetString.length-1;i >=0;i--){
  7794. tempChar=targetString.charAt(i);
  7795. if (tempChar !=" " && tempChar !="\n" && tempChar !="\r"){
  7796. break ;
  7797. }
  7798. }
  7799. return targetString.substring(0,i+1);
  7800. }
  7801. ToolSet.convertToHtmlColor=function(argb,hasAlpha){
  7802. (hasAlpha===void 0)&& (hasAlpha=false);
  7803. var alpha;
  7804. if (hasAlpha)
  7805. alpha=(argb >> 24 & 0xFF).toString(16);
  7806. else
  7807. alpha="";
  7808. var red=(argb >> 16 & 0xFF).toString(16);
  7809. var green=(argb >> 8 & 0xFF).toString(16);
  7810. var blue=(argb & 0xFF).toString(16);
  7811. if (alpha.length==1)
  7812. alpha="0"+alpha;
  7813. if (red.length==1)
  7814. red="0"+red;
  7815. if (green.length==1)
  7816. green="0"+green;
  7817. if (blue.length==1)
  7818. blue="0"+blue;
  7819. return "#"+alpha+red+green+blue;
  7820. }
  7821. ToolSet.convertFromHtmlColor=function(str,hasAlpha){
  7822. (hasAlpha===void 0)&& (hasAlpha=false);
  7823. if (str.length < 1)
  7824. return 0;
  7825. if (str.charAt(0)=="#")
  7826. str=str.substr(1);
  7827. if (str.length==8)
  7828. return (parseInt(str.substr(0,2),16)<< 24)+parseInt(str.substr(2),16);
  7829. else if (hasAlpha)
  7830. return 0xFF000000+parseInt(str,16);
  7831. else
  7832. return parseInt(str,16);
  7833. }
  7834. ToolSet.displayObjectToGObject=function(obj){
  7835. while (obj !=null && !((obj instanceof laya.display.Stage ))){
  7836. if (obj["$owner"])
  7837. return obj["$owner"];
  7838. obj=obj.parent;
  7839. }
  7840. return null;
  7841. }
  7842. ToolSet.encodeHTML=function(str){
  7843. if (!str)
  7844. return "";
  7845. else
  7846. return str.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;").replace("'","&apos;");
  7847. }
  7848. ToolSet.parseUBB=function(text){
  7849. return fairygui.utils.ToolSet.defaultUBBParser.parse(text);
  7850. }
  7851. ToolSet.removeUBB=function(text){
  7852. return fairygui.utils.ToolSet.defaultUBBParser.parse(text,true);
  7853. }
  7854. ToolSet.clamp=function(value,min,max){
  7855. if(value<min)
  7856. value=min;
  7857. else if(value>max)
  7858. value=max;
  7859. return value;
  7860. }
  7861. ToolSet.clamp01=function(value){
  7862. if(value>1)
  7863. value=1;
  7864. else if(value<0)
  7865. value=0;
  7866. return value;
  7867. }
  7868. ToolSet.lerp=function(start,end,percent){
  7869. return (start+percent*(end-start));
  7870. }
  7871. __static(ToolSet,
  7872. ['defaultUBBParser',function(){return this.defaultUBBParser=new UBBParser();}
  7873. ]);
  7874. return ToolSet;
  7875. })()
  7876. //class fairygui.utils.UBBParser
  7877. var UBBParser=(function(){
  7878. function UBBParser(){
  7879. this._text=null;
  7880. this._readPos=0;
  7881. this._handlers=null;
  7882. this.smallFontSize=12;
  7883. this.normalFontSize=14;
  7884. this.largeFontSize=16;
  7885. this.defaultImgWidth=0;
  7886. this.defaultImgHeight=0;
  7887. this._handlers={};
  7888. this._handlers["url"]=this.onTag_URL;
  7889. this._handlers["img"]=this.onTag_IMG;
  7890. this._handlers["b"]=this.onTag_Simple;
  7891. this._handlers["i"]=this.onTag_Simple;
  7892. this._handlers["u"]=this.onTag_Simple;
  7893. this._handlers["sup"]=this.onTag_Simple;
  7894. this._handlers["sub"]=this.onTag_Simple;
  7895. this._handlers["color"]=this.onTag_COLOR;
  7896. this._handlers["font"]=this.onTag_FONT;
  7897. this._handlers["size"]=this.onTag_SIZE;
  7898. }
  7899. __class(UBBParser,'fairygui.utils.UBBParser');
  7900. var __proto=UBBParser.prototype;
  7901. __proto.onTag_URL=function(tagName,end,attr){
  7902. if (!end){
  7903. if (attr !=null)
  7904. return "<a href=\""+attr+"\" target=\"_blank\">";
  7905. else {
  7906. var href=this.getTagText();
  7907. return "<a href=\""+href+"\" target=\"_blank\">";
  7908. }
  7909. }
  7910. else
  7911. return "</a>";
  7912. }
  7913. __proto.onTag_IMG=function(tagName,end,attr){
  7914. if (!end){
  7915. var src=this.getTagText(true);
  7916. if (!src)
  7917. return null;
  7918. if (this.defaultImgWidth)
  7919. return "<img src=\""+src+"\" width=\""+this.defaultImgWidth+"\" height=\""+this.defaultImgHeight+"\"/>";
  7920. else
  7921. return "<img src=\""+src+"\"/>";
  7922. }
  7923. else
  7924. return null;
  7925. }
  7926. __proto.onTag_Simple=function(tagName,end,attr){
  7927. return end ? ("</"+tagName+">"):("<"+tagName+">");
  7928. }
  7929. __proto.onTag_COLOR=function(tagName,end,attr){
  7930. if (!end)
  7931. return "<font color=\""+attr+"\">";
  7932. else
  7933. return "</font>";
  7934. }
  7935. __proto.onTag_FONT=function(tagName,end,attr){
  7936. if (!end)
  7937. return "<font face=\""+attr+"\">";
  7938. else
  7939. return "</font>";
  7940. }
  7941. __proto.onTag_SIZE=function(tagName,end,attr){
  7942. if (!end){
  7943. if (attr=="normal")
  7944. attr=""+this.normalFontSize;
  7945. else if (attr=="small")
  7946. attr=""+this.smallFontSize;
  7947. else if (attr=="large")
  7948. attr=""+this.largeFontSize;
  7949. else if (attr.length && attr.charAt(0)=="+")
  7950. attr=""+(this.smallFontSize+parseInt(attr.substr(1)));
  7951. else if (attr.length && attr.charAt(0)=="-")
  7952. attr=""+(this.smallFontSize-parseInt(attr.substr(1)));
  7953. return "<font size=\""+attr+"\">";
  7954. }
  7955. else
  7956. return "</font>";
  7957. }
  7958. __proto.getTagText=function(remove){
  7959. (remove===void 0)&& (remove=false);
  7960. var pos1=this._readPos;
  7961. var pos2=0;
  7962. var result="";
  7963. while ((pos2=this._text.indexOf("[",pos1))!=-1){
  7964. if (this._text.charCodeAt(pos2-1)==92){
  7965. result+=this._text.substring(pos1,pos2-1);
  7966. result+="[";
  7967. pos1=pos2+1;
  7968. }
  7969. else{
  7970. result+=this._text.substring(pos1,pos2);
  7971. break ;
  7972. }
  7973. }
  7974. if (pos2==-1)
  7975. return null;
  7976. if (remove)
  7977. this._readPos=pos2;
  7978. return result;
  7979. }
  7980. __proto.parse=function(text,remove){
  7981. (remove===void 0)&& (remove=false);
  7982. this._text=text;
  7983. var pos1=0,pos2=0,pos3=0;
  7984. var end=false;
  7985. var tag,attr;
  7986. var repl;
  7987. var func;
  7988. var result="";
  7989. while((pos2=this._text.indexOf("[",pos1))!=-1){
  7990. if (pos2 > 0 && this._text.charCodeAt(pos2-1)==92){
  7991. result+=this._text.substring(pos1,pos2-1);
  7992. result+="[";
  7993. pos1=pos2+1;
  7994. continue ;
  7995. }
  7996. result+=this._text.substring(pos1,pos2);
  7997. pos1=pos2;
  7998. pos2=this._text.indexOf("]",pos1);
  7999. if(pos2==-1)
  8000. break ;
  8001. end=this._text.charAt(pos1+1)=='/';
  8002. tag=this._text.substring(end?pos1+2:pos1+1,pos2);
  8003. this._readPos=pos2+1;
  8004. attr=null;
  8005. repl=null;
  8006. pos3=tag.indexOf("=");
  8007. if(pos3!=-1){
  8008. attr=tag.substring(pos3+1);
  8009. tag=tag.substring(0,pos3);
  8010. }
  8011. tag=tag.toLowerCase();
  8012. func=this._handlers[tag];
  8013. if(func!=null){
  8014. if(!remove){
  8015. repl=func.call(this,tag,end,attr);
  8016. if(repl!=null)
  8017. result+=repl;
  8018. }
  8019. }
  8020. else
  8021. result+=this._text.substring(pos1,this._readPos);
  8022. pos1=this._readPos;
  8023. }
  8024. if (pos1 < this._text.length)
  8025. result+=this._text.substr(pos1);
  8026. this._text=null;
  8027. return result;
  8028. }
  8029. __static(UBBParser,
  8030. ['inst',function(){return this.inst=new UBBParser();}
  8031. ]);
  8032. return UBBParser;
  8033. })()
  8034. //class fairygui.utils.ColorMatrix extends Array
  8035. var ColorMatrix=(function(_super){
  8036. // initialization:
  8037. function ColorMatrix(){
  8038. ColorMatrix.__super.call(this);
  8039. this.reset();
  8040. }
  8041. __class(ColorMatrix,'fairygui.utils.ColorMatrix',Array);
  8042. var __proto=ColorMatrix.prototype;
  8043. // public methods:
  8044. __proto.reset=function(){
  8045. for (var i=0;i<ColorMatrix.LENGTH;i++){
  8046. this[i]=ColorMatrix.IDENTITY_MATRIX[i];
  8047. }
  8048. }
  8049. __proto.invert=function(){
  8050. this.multiplyMatrix([-1,0,0,0,255,
  8051. 0,-1,0,0,255,
  8052. 0,0,-1,0,255,
  8053. 0,0,0,1,0]);
  8054. }
  8055. __proto.adjustColor=function(p_brightness,p_contrast,p_saturation,p_hue){
  8056. this.adjustHue(p_hue);
  8057. this.adjustContrast(p_contrast);
  8058. this.adjustBrightness(p_brightness);
  8059. this.adjustSaturation(p_saturation);
  8060. }
  8061. __proto.adjustBrightness=function(p_val){
  8062. p_val=this.cleanValue(p_val,1)*255;
  8063. this.multiplyMatrix([
  8064. 1,0,0,0,p_val,
  8065. 0,1,0,0,p_val,
  8066. 0,0,1,0,p_val,
  8067. 0,0,0,1,0]);
  8068. }
  8069. __proto.adjustContrast=function(p_val){
  8070. p_val=this.cleanValue(p_val,1);
  8071. var s=p_val+1;
  8072. var o=128 *(1-s);
  8073. this.multiplyMatrix([
  8074. s,0,0,0,o,
  8075. 0,s,0,0,o,
  8076. 0,0,s,0,o,
  8077. 0,0,0,1,0]);
  8078. }
  8079. __proto.adjustSaturation=function(p_val){
  8080. p_val=this.cleanValue(p_val,1);
  8081. p_val+=1;
  8082. var invSat=1-p_val;
  8083. var invLumR=invSat *0.299;
  8084. var invLumG=invSat *0.587;
  8085. var invLumB=invSat *0.114;
  8086. this.multiplyMatrix([
  8087. (invLumR+p_val),invLumG,invLumB,0,0,
  8088. invLumR,(invLumG+p_val),invLumB,0,0,
  8089. invLumR,invLumG,(invLumB+p_val),0,0,
  8090. 0,0,0,1,0]);
  8091. }
  8092. __proto.adjustHue=function(p_val){
  8093. p_val=this.cleanValue(p_val,1);
  8094. p_val *=Math.PI;
  8095. var cos=Math.cos(p_val);
  8096. var sin=Math.sin(p_val);
  8097. this.multiplyMatrix([
  8098. ((0.299+(cos *(1-0.299)))+(sin *-(0.299))),((0.587+(cos *-(0.587)))+(sin *-(0.587))),((0.114+(cos *-(0.114)))+(sin *(1-0.114))),0,0,
  8099. ((0.299+(cos *-(0.299)))+(sin *0.143)),((0.587+(cos *(1-0.587)))+(sin *0.14)),((0.114+(cos *-(0.114)))+(sin *-0.283)),0,0,
  8100. ((0.299+(cos *-(0.299)))+(sin *-((1-0.299)))),((0.587+(cos *-(0.587)))+(sin *0.587)),((0.114+(cos *(1-0.114)))+(sin *0.114)),0,0,
  8101. 0,0,0,1,0]);
  8102. }
  8103. __proto.concat=function(p_matrix){
  8104. if (p_matrix.length !=ColorMatrix.LENGTH){return;}
  8105. this.multiplyMatrix(p_matrix);
  8106. }
  8107. __proto.clone=function(){
  8108. var result=new ColorMatrix();
  8109. result.copyMatrix(this);
  8110. return result;
  8111. }
  8112. __proto.copyMatrix=function(p_matrix){
  8113. var l=ColorMatrix.LENGTH;
  8114. for (var i=0;i<l;i++){
  8115. this[i]=p_matrix[i];
  8116. }
  8117. }
  8118. __proto.multiplyMatrix=function(p_matrix){
  8119. var col=[];
  8120. var i=0;
  8121. for (var y=0;y<4;++y){
  8122. for (var x=0;x<5;++x){
  8123. col[i+x]=p_matrix[i] *this[x]+
  8124. p_matrix[i+1] *this[x+5]+
  8125. p_matrix[i+2] *this[x+10]+
  8126. p_matrix[i+3] *this[x+15]+
  8127. (x==4 ? p_matrix[i+4] :0);
  8128. }
  8129. i+=5;
  8130. }
  8131. this.copyMatrix(col);
  8132. }
  8133. __proto.cleanValue=function(p_val,p_limit){
  8134. return Math.min(p_limit,Math.max(-p_limit,p_val));
  8135. }
  8136. ColorMatrix.create=function(p_brightness,p_contrast,p_saturation,p_hue){
  8137. var ret=new ColorMatrix();
  8138. ret.adjustColor(p_brightness,p_contrast,p_saturation,p_hue);
  8139. return ret;
  8140. }
  8141. ColorMatrix.LUMA_R=0.299;
  8142. ColorMatrix.LUMA_G=0.587;
  8143. ColorMatrix.LUMA_B=0.114;
  8144. __static(ColorMatrix,
  8145. ['IDENTITY_MATRIX',function(){return this.IDENTITY_MATRIX=[
  8146. 1,0,0,0,0,
  8147. 0,1,0,0,0,
  8148. 0,0,1,0,0,
  8149. 0,0,0,1,0];},'LENGTH',function(){return this.LENGTH=ColorMatrix.IDENTITY_MATRIX.length;}
  8150. ]);
  8151. return ColorMatrix;
  8152. })(Array)
  8153. //class fairygui.Controller extends laya.events.EventDispatcher
  8154. var Controller=(function(_super){
  8155. function Controller(){
  8156. this._selectedIndex=0;
  8157. this._previousIndex=0;
  8158. this._pageIds=null;
  8159. this._pageNames=null;
  8160. this._actions=null;
  8161. this.name=null;
  8162. this.parent=null;
  8163. this.autoRadioGroupDepth=false;
  8164. this.changing=false;
  8165. Controller.__super.call(this);
  8166. this._pageIds=[];
  8167. this._pageNames=[];
  8168. this._selectedIndex=-1;
  8169. this._previousIndex=-1;
  8170. }
  8171. __class(Controller,'fairygui.Controller',_super);
  8172. var __proto=Controller.prototype;
  8173. __proto.dispose=function(){
  8174. this.offAll();
  8175. }
  8176. //功能和设置selectedIndex一样,但不会触发事件
  8177. __proto.setSelectedIndex=function(value){
  8178. (value===void 0)&& (value=0);
  8179. if (this._selectedIndex !=value){
  8180. if(value > this._pageIds.length-1)
  8181. throw "index out of bounds: "+value;
  8182. this.changing=true;
  8183. this._previousIndex=this._selectedIndex;
  8184. this._selectedIndex=value;
  8185. this.parent.applyController(this);
  8186. this.changing=false;
  8187. }
  8188. }
  8189. //功能和设置selectedPage一样,但不会触发事件
  8190. __proto.setSelectedPage=function(value){
  8191. var i=this._pageNames.indexOf(value);
  8192. if (i==-1)
  8193. i=0;
  8194. this.setSelectedIndex(i);
  8195. }
  8196. __proto.getPageName=function(index){
  8197. (index===void 0)&& (index=0);
  8198. return this._pageNames[index];
  8199. }
  8200. __proto.addPage=function(name){
  8201. (name===void 0)&& (name="");
  8202. this.addPageAt(name,this._pageIds.length);
  8203. }
  8204. __proto.addPageAt=function(name,index){
  8205. (index===void 0)&& (index=0);
  8206. var nid=""+(fairygui.Controller._nextPageId++);
  8207. if (index==this._pageIds.length){
  8208. this._pageIds.push(nid);
  8209. this._pageNames.push(name);
  8210. }
  8211. else {
  8212. this._pageIds.splice(index,0,nid);
  8213. this._pageNames.splice(index,0,name);
  8214. }
  8215. }
  8216. __proto.removePage=function(name){
  8217. var i=this._pageNames.indexOf(name);
  8218. if (i !=-1){
  8219. this._pageIds.splice(i,1);
  8220. this._pageNames.splice(i,1);
  8221. if (this._selectedIndex >=this._pageIds.length)
  8222. this.selectedIndex=this._selectedIndex-1;
  8223. else
  8224. this.parent.applyController(this);
  8225. }
  8226. }
  8227. __proto.removePageAt=function(index){
  8228. (index===void 0)&& (index=0);
  8229. this._pageIds.splice(index,1);
  8230. this._pageNames.splice(index,1);
  8231. if (this._selectedIndex >=this._pageIds.length)
  8232. this.selectedIndex=this._selectedIndex-1;
  8233. else
  8234. this.parent.applyController(this);
  8235. }
  8236. __proto.clearPages=function(){
  8237. this._pageIds.length=0;
  8238. this._pageNames.length=0;
  8239. if (this._selectedIndex !=-1)
  8240. this.selectedIndex=-1;
  8241. else
  8242. this.parent.applyController(this);
  8243. }
  8244. __proto.hasPage=function(aName){
  8245. return this._pageNames.indexOf(aName)!=-1;
  8246. }
  8247. __proto.getPageIndexById=function(aId){
  8248. return this._pageIds.indexOf(aId);
  8249. }
  8250. __proto.getPageIdByName=function(aName){
  8251. var i=this._pageNames.indexOf(aName);
  8252. if(i !=-1)
  8253. return this._pageIds[i];
  8254. else
  8255. return null;
  8256. }
  8257. __proto.getPageNameById=function(aId){
  8258. var i=this._pageIds.indexOf(aId);
  8259. if(i !=-1)
  8260. return this._pageNames[i];
  8261. else
  8262. return null;
  8263. }
  8264. __proto.getPageId=function(index){
  8265. (index===void 0)&& (index=0);
  8266. return this._pageIds[index];
  8267. }
  8268. __proto.runActions=function(){
  8269. if(this._actions){
  8270. var cnt=this._actions.length;
  8271. for(var i=0;i<cnt;i++){
  8272. this._actions[i].run(this,this.previousPageId,this.selectedPageId);
  8273. }
  8274. }
  8275. }
  8276. __proto.setup=function(buffer){
  8277. var beginPos=buffer.pos;
  8278. buffer.seek(beginPos,0);
  8279. this.name=buffer.readS();
  8280. this.autoRadioGroupDepth=buffer.readBool();
  8281. buffer.seek(beginPos,1);
  8282. var i=0;
  8283. var nextPos=0;
  8284. var cnt=buffer.getInt16();
  8285. for (i=0;i < cnt;i++){
  8286. this._pageIds.push(buffer.readS());
  8287. this._pageNames.push(buffer.readS());
  8288. }
  8289. buffer.seek(beginPos,2);
  8290. cnt=buffer.getInt16();
  8291. if (cnt > 0){
  8292. if (this._actions==null)
  8293. this._actions=[];
  8294. for (i=0;i < cnt;i++){
  8295. nextPos=buffer.getInt16();
  8296. nextPos+=buffer.pos;
  8297. var action=ControllerAction.createAction(buffer.readByte());
  8298. action.setup(buffer);
  8299. this._actions.push(action);
  8300. buffer.pos=nextPos;
  8301. }
  8302. }
  8303. if (this.parent !=null && this._pageIds.length > 0)
  8304. this._selectedIndex=0;
  8305. else
  8306. this._selectedIndex=-1;
  8307. }
  8308. __getset(0,__proto,'selectedIndex',function(){
  8309. return this._selectedIndex;
  8310. },function(value){
  8311. if(this._selectedIndex !=value){
  8312. if(value > this._pageIds.length-1)
  8313. throw "index out of bounds: "+value;
  8314. this.changing=true;
  8315. this._previousIndex=this._selectedIndex;
  8316. this._selectedIndex=value;
  8317. this.parent.applyController(this);
  8318. this.event("fui_state_changed");
  8319. this.changing=false;
  8320. }
  8321. });
  8322. __getset(0,__proto,'selectedPage',function(){
  8323. if (this._selectedIndex==-1)
  8324. return null;
  8325. else
  8326. return this._pageNames[this._selectedIndex];
  8327. },function(val){
  8328. var i=this._pageNames.indexOf(val);
  8329. if (i==-1)
  8330. i=0;
  8331. this.selectedIndex=i;
  8332. });
  8333. __getset(0,__proto,'previsousIndex',function(){
  8334. return this._previousIndex;
  8335. });
  8336. __getset(0,__proto,'previousPage',function(){
  8337. if (this._previousIndex==-1)
  8338. return null;
  8339. else
  8340. return this._pageNames[this._previousIndex];
  8341. });
  8342. __getset(0,__proto,'pageCount',function(){
  8343. return this._pageIds.length;
  8344. });
  8345. __getset(0,__proto,'selectedPageId',function(){
  8346. if (this._selectedIndex==-1)
  8347. return null;
  8348. else
  8349. return this._pageIds[this._selectedIndex];
  8350. },function(val){
  8351. var i=this._pageIds.indexOf(val);
  8352. this.selectedIndex=i;
  8353. });
  8354. __getset(0,__proto,'previousPageId',function(){
  8355. if(this._previousIndex==-1)
  8356. return null;
  8357. else
  8358. return this._pageIds[this._previousIndex];
  8359. });
  8360. __getset(0,__proto,'oppositePageId',null,function(val){
  8361. var i=this._pageIds.indexOf(val);
  8362. if(i > 0)
  8363. this.selectedIndex=0;
  8364. else if(this._pageIds.length > 1)
  8365. this.selectedIndex=1;
  8366. });
  8367. Controller._nextPageId=0;
  8368. return Controller;
  8369. })(EventDispatcher)
  8370. //class fairygui.utils.ByteBuffer extends laya.utils.Byte
  8371. var ByteBuffer=(function(_super){
  8372. function ByteBuffer(data,offset,length){
  8373. this.stringTable=null;
  8374. this.version=0;
  8375. (offset===void 0)&& (offset=0);
  8376. (length===void 0)&& (length=-1);
  8377. if(length==-1)
  8378. length=data.byteLength-offset;
  8379. if(offset==0 && length==data.byteLength)
  8380. ByteBuffer.__super.call(this,data);
  8381. else{
  8382. this._u8d_=new Uint8Array(data,offset,length);
  8383. this._d_=new DataView(this._u8d_.buffer,offset,length);
  8384. this._length=length;
  8385. }
  8386. this.endian="bigEndian";
  8387. }
  8388. __class(ByteBuffer,'fairygui.utils.ByteBuffer',_super);
  8389. var __proto=ByteBuffer.prototype;
  8390. __proto.skip=function(count){
  8391. this.pos+=count;
  8392. }
  8393. __proto.readBool=function(){
  8394. return this.getUint8()==1;
  8395. }
  8396. __proto.readS=function(){
  8397. var index=this.getUint16();
  8398. if (index==65534)
  8399. return null;
  8400. else if (index==65533)
  8401. return ""
  8402. else
  8403. return this.stringTable[index];
  8404. }
  8405. __proto.writeS=function(value){
  8406. var index=this.getUint16();
  8407. if (index !=65534 && index !=65533)
  8408. this.stringTable[index]=value;
  8409. }
  8410. __proto.readColor=function(hasAlpha){
  8411. (hasAlpha===void 0)&& (hasAlpha=false);
  8412. var r=this.getUint8();
  8413. var g=this.getUint8();
  8414. var b=this.getUint8();
  8415. var a=this.getUint8();
  8416. return (hasAlpha?(a<<24):0)+(r<<16)+(g<<8)+b;
  8417. }
  8418. __proto.readColorS=function(hasAlpha){
  8419. (hasAlpha===void 0)&& (hasAlpha=false);
  8420. var r=this.getUint8();
  8421. var g=this.getUint8();
  8422. var b=this.getUint8();
  8423. var a=this.getUint8();
  8424. if(hasAlpha && a!=255)
  8425. return "rgba("+r+","+g+","+b+","+(a/255)+")";
  8426. else{
  8427. var sr=r.toString(16);
  8428. var sg=g.toString(16);
  8429. var sb=b.toString(16);
  8430. if (sr.length==1)
  8431. sr="0"+sr;
  8432. if (sg.length==1)
  8433. sg="0"+sg;
  8434. if (sb.length==1)
  8435. sb="0"+sb;
  8436. return "#"+sr+sg+sb;
  8437. }
  8438. }
  8439. __proto.readChar=function(){
  8440. var i=this.getUint16();
  8441. return String.fromCharCode(i);
  8442. }
  8443. __proto.readBuffer=function(){
  8444. var count=this.getUint32();
  8445. var ba=new ByteBuffer(this.buffer,this._pos_,count);
  8446. ba.stringTable=this.stringTable;
  8447. ba.version=this.version;
  8448. return ba;
  8449. }
  8450. __proto.seek=function(indexTablePos,blockIndex){
  8451. var tmp=this._pos_;
  8452. this.pos=indexTablePos;
  8453. var segCount=this.getUint8();
  8454. if (blockIndex < segCount){
  8455. var useShort=this.getUint8()==1;
  8456. var newPos=0;
  8457. if (useShort){
  8458. this.pos+=2 *blockIndex;
  8459. newPos=this.getUint16();
  8460. }
  8461. else{
  8462. this.pos+=4 *blockIndex;
  8463. newPos=this.getUint32();
  8464. }
  8465. if (newPos > 0){
  8466. this.pos=indexTablePos+newPos;
  8467. return true;
  8468. }
  8469. else{
  8470. this.pos=tmp;
  8471. return false;
  8472. }
  8473. }
  8474. else{
  8475. this.pos=tmp;
  8476. return false;
  8477. }
  8478. }
  8479. return ByteBuffer;
  8480. })(Byte)
  8481. //class fairygui.utils.ChildHitArea extends laya.utils.HitArea
  8482. var ChildHitArea=(function(_super){
  8483. function ChildHitArea(child,reversed){
  8484. this._child=null;
  8485. this._reversed=false;
  8486. ChildHitArea.__super.call(this);
  8487. this._child=child;
  8488. this._reversed=reversed;
  8489. if(this._reversed)
  8490. this.unHit=child.hitArea.hit;
  8491. else
  8492. this.hit=child.hitArea.hit;
  8493. }
  8494. __class(ChildHitArea,'fairygui.utils.ChildHitArea',_super);
  8495. var __proto=ChildHitArea.prototype;
  8496. __proto.contains=function(x,y){
  8497. var tPos;
  8498. tPos=Point.TEMP;
  8499. tPos.setTo(0,0);
  8500. tPos=this._child.toParentPoint(tPos);
  8501. if (this._reversed)
  8502. return !HitArea._isHitGraphic(x-tPos.x,y-tPos.y,this.unHit);
  8503. else
  8504. return HitArea._isHitGraphic(x-tPos.x,y-tPos.y,this.hit);
  8505. }
  8506. return ChildHitArea;
  8507. })(HitArea)
  8508. //class fairygui.utils.PixelHitTest extends laya.utils.HitArea
  8509. var PixelHitTest=(function(_super){
  8510. function PixelHitTest(data,offsetX,offsetY){
  8511. this._data=null;
  8512. this.offsetX=0;
  8513. this.offsetY=0;
  8514. this.scaleX=NaN;
  8515. this.scaleY=NaN;
  8516. PixelHitTest.__super.call(this);
  8517. (offsetX===void 0)&& (offsetX=0);
  8518. (offsetY===void 0)&& (offsetY=0);
  8519. this._data=data;
  8520. this.offsetX=offsetX;
  8521. this.offsetY=offsetY;
  8522. this.scaleX=1;
  8523. this.scaleY=1;
  8524. }
  8525. __class(PixelHitTest,'fairygui.utils.PixelHitTest',_super);
  8526. var __proto=PixelHitTest.prototype;
  8527. __proto.contains=function(x,y){
  8528. x=Math.floor((x / this.scaleX-this.offsetX)*this._data.scale);
  8529. y=Math.floor((y / this.scaleY-this.offsetY)*this._data.scale);
  8530. if (x < 0 || y < 0 || x >=this._data.pixelWidth)
  8531. return false;
  8532. var pos=y *this._data.pixelWidth+x;
  8533. var pos2=Math.floor(pos / 8);
  8534. var pos3=pos % 8;
  8535. if (pos2 >=0 && pos2 < this._data.pixels.length)
  8536. return ((this._data.pixels[pos2] >> pos3)& 0x1)==1;
  8537. else
  8538. return false;
  8539. }
  8540. return PixelHitTest;
  8541. })(HitArea)
  8542. //class fairygui.action.ChangePageAction extends fairygui.action.ControllerAction
  8543. var ChangePageAction=(function(_super){
  8544. function ChangePageAction(){
  8545. this.objectId=null;
  8546. this.controllerName=null;
  8547. this.targetPage=null;
  8548. ChangePageAction.__super.call(this);
  8549. }
  8550. __class(ChangePageAction,'fairygui.action.ChangePageAction',_super);
  8551. var __proto=ChangePageAction.prototype;
  8552. __proto.enter=function(controller){
  8553. if(!this.controllerName)
  8554. return;
  8555. var gcom;
  8556. if(this.objectId)
  8557. gcom=controller.parent.getChildById(this.objectId);
  8558. else
  8559. gcom=controller.parent;
  8560. if(gcom){
  8561. var cc=gcom.getController(this.controllerName);
  8562. if(cc && cc!=controller && !cc.changing)
  8563. cc.selectedPageId=this.targetPage;
  8564. }
  8565. }
  8566. __proto.setup=function(buffer){
  8567. _super.prototype.setup.call(this,buffer);
  8568. this.objectId=buffer.readS();
  8569. this.controllerName=buffer.readS();
  8570. this.targetPage=buffer.readS();
  8571. }
  8572. return ChangePageAction;
  8573. })(ControllerAction)
  8574. //class fairygui.action.PlayTransitionAction extends fairygui.action.ControllerAction
  8575. var PlayTransitionAction=(function(_super){
  8576. function PlayTransitionAction(){
  8577. this.transitionName=null;
  8578. this.playTimes=1;
  8579. this.delay=0;
  8580. this.stopOnExit=false;
  8581. this._currentTransition=null;
  8582. PlayTransitionAction.__super.call(this);
  8583. }
  8584. __class(PlayTransitionAction,'fairygui.action.PlayTransitionAction',_super);
  8585. var __proto=PlayTransitionAction.prototype;
  8586. __proto.enter=function(controller){
  8587. var trans=controller.parent.getTransition(this.transitionName);
  8588. if(trans){
  8589. if(this._currentTransition && this._currentTransition.playing)
  8590. trans.changePlayTimes(this.playTimes);
  8591. else
  8592. trans.play(null,this.playTimes,this.delay);
  8593. this._currentTransition=trans;
  8594. }
  8595. }
  8596. __proto.leave=function(controller){
  8597. if(this.stopOnExit && this._currentTransition){
  8598. this._currentTransition.stop();
  8599. this._currentTransition=null;
  8600. }
  8601. }
  8602. __proto.setup=function(buffer){
  8603. _super.prototype.setup.call(this,buffer);
  8604. this.transitionName=buffer.readS();
  8605. this.playTimes=buffer.getInt32();
  8606. this.delay=buffer.getFloat32();
  8607. this.stopOnExit=buffer.readBool();
  8608. }
  8609. return PlayTransitionAction;
  8610. })(ControllerAction)
  8611. //class fairygui.GTextField extends fairygui.GObject
  8612. var GTextField=(function(_super){
  8613. function GTextField(){
  8614. this._gearColor=null;
  8615. this._templateVars=null;
  8616. this._text=null;
  8617. GTextField.__super.call(this);
  8618. this._gearColor=new GearColor(this);
  8619. }
  8620. __class(GTextField,'fairygui.GTextField',_super);
  8621. var __proto=GTextField.prototype;
  8622. Laya.imps(__proto,{"fairygui.gears.IColorGear":true})
  8623. __proto.parseTemplate=function(template){
  8624. var pos1=0,pos2=0,pos3=0;
  8625. var tag;
  8626. var value;
  8627. var result="";
  8628. while((pos2=template.indexOf("{",pos1))!=-1){
  8629. if (pos2 > 0 && template.charCodeAt(pos2-1)==92){
  8630. result+=template.substring(pos1,pos2-1);
  8631. result+="{";
  8632. pos1=pos2+1;
  8633. continue ;
  8634. }
  8635. result+=template.substring(pos1,pos2);
  8636. pos1=pos2;
  8637. pos2=template.indexOf("}",pos1);
  8638. if(pos2==-1)
  8639. break ;
  8640. if(pos2==pos1+1){
  8641. result+=template.substr(pos1,2);
  8642. pos1=pos2+1;
  8643. continue ;
  8644. }
  8645. tag=template.substring(pos1+1,pos2);
  8646. pos3=tag.indexOf("=");
  8647. if(pos3!=-1){
  8648. value=this._templateVars[tag.substring(0,pos3)];
  8649. if(value==null)
  8650. result+=tag.substring(pos3+1);
  8651. else
  8652. result+=value;
  8653. }
  8654. else{
  8655. value=this._templateVars[tag];
  8656. if(value!=null)
  8657. result+=value;
  8658. }
  8659. pos1=pos2+1;
  8660. }
  8661. if (pos1 < template.length)
  8662. result+=template.substr(pos1);
  8663. return result;
  8664. }
  8665. __proto.setVar=function(name,value){
  8666. if(!this._templateVars)
  8667. this._templateVars={};
  8668. this._templateVars[name]=value;
  8669. return this;
  8670. }
  8671. __proto.flushVars=function(){
  8672. this.text=this._text;
  8673. }
  8674. __proto.handleControllerChanged=function(c){
  8675. _super.prototype.handleControllerChanged.call(this,c);
  8676. if(this._gearColor.controller==c)
  8677. this._gearColor.apply();
  8678. }
  8679. __proto.setup_beforeAdd=function(buffer,beginPos){
  8680. _super.prototype.setup_beforeAdd.call(this,buffer,beginPos);
  8681. buffer.seek(beginPos,5);
  8682. var iv=0;
  8683. this.font=buffer.readS();
  8684. this.fontSize=buffer.getInt16();
  8685. this.color=buffer.readColorS();
  8686. iv=buffer.readByte();
  8687. this.align=iv==0?"left":(iv==1?"center":"right");
  8688. iv=buffer.readByte();
  8689. this.valign=iv==0?"top":(iv==1?"middle":"bottom");
  8690. this.leading=buffer.getInt16();
  8691. this.letterSpacing=buffer.getInt16();
  8692. this.ubbEnabled=buffer.readBool();
  8693. this.autoSize=buffer.readByte();
  8694. this.underline=buffer.readBool();
  8695. this.italic=buffer.readBool();
  8696. this.bold=buffer.readBool();
  8697. this.singleLine=buffer.readBool();
  8698. if (buffer.readBool()){
  8699. this.strokeColor=buffer.readColorS();
  8700. this.stroke=buffer.getFloat32()+1;
  8701. }
  8702. if (buffer.readBool())
  8703. buffer.skip(12);
  8704. if (buffer.readBool())
  8705. this._templateVars={};
  8706. }
  8707. __proto.setup_afterAdd=function(buffer,beginPos){
  8708. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  8709. buffer.seek(beginPos,6);
  8710. var str=buffer.readS();
  8711. if (str !=null)
  8712. this.text=str;
  8713. }
  8714. __getset(0,__proto,'color',function(){
  8715. return null;
  8716. },function(value){
  8717. });
  8718. __getset(0,__proto,'font',function(){
  8719. return null;
  8720. },function(value){
  8721. });
  8722. __getset(0,__proto,'templateVars',function(){
  8723. return this._templateVars;
  8724. },function(value){
  8725. if(this._templateVars==null && value==null)
  8726. return;
  8727. this._templateVars=value;
  8728. this.flushVars();
  8729. });
  8730. __getset(0,__proto,'leading',function(){
  8731. return 0;
  8732. },function(value){
  8733. });
  8734. __getset(0,__proto,'fontSize',function(){
  8735. return 0;
  8736. },function(value){
  8737. });
  8738. __getset(0,__proto,'bold',function(){
  8739. return false;
  8740. },function(value){
  8741. });
  8742. __getset(0,__proto,'letterSpacing',function(){
  8743. return 0;
  8744. },function(value){
  8745. });
  8746. __getset(0,__proto,'align',function(){
  8747. return null;
  8748. },function(value){
  8749. });
  8750. __getset(0,__proto,'valign',function(){
  8751. return null;
  8752. },function(value){
  8753. });
  8754. __getset(0,__proto,'italic',function(){
  8755. return false;
  8756. },function(value){
  8757. });
  8758. __getset(0,__proto,'underline',function(){
  8759. return false;
  8760. },function(value){
  8761. });
  8762. __getset(0,__proto,'singleLine',function(){
  8763. return false;
  8764. },function(value){
  8765. });
  8766. __getset(0,__proto,'stroke',function(){
  8767. return 0;
  8768. },function(value){
  8769. });
  8770. __getset(0,__proto,'strokeColor',function(){
  8771. return null;
  8772. },function(value){
  8773. });
  8774. __getset(0,__proto,'ubbEnabled',function(){
  8775. return false;
  8776. },function(value){
  8777. });
  8778. /**
  8779. *@see AutoSizeType
  8780. */
  8781. /**
  8782. *@see AutoSizeType
  8783. */
  8784. __getset(0,__proto,'autoSize',function(){
  8785. return 0;
  8786. },function(value){
  8787. });
  8788. __getset(0,__proto,'textWidth',function(){
  8789. return 0;
  8790. });
  8791. return GTextField;
  8792. })(GObject)
  8793. //class fairygui.GComponent extends fairygui.GObject
  8794. var GComponent=(function(_super){
  8795. function GComponent(){
  8796. this._sortingChildCount=0;
  8797. this._opaque=false;
  8798. this._applyingController=null;
  8799. this._mask=null;
  8800. this._margin=null;
  8801. this._trackBounds=false;
  8802. this._boundsChanged=false;
  8803. this._childrenRenderOrder=0;
  8804. this._apexIndex=0;
  8805. this._buildingDisplayList=false;
  8806. this._children=null;
  8807. this._controllers=null;
  8808. this._transitions=null;
  8809. this._container=null;
  8810. this._scrollPane=null;
  8811. this._alignOffset=null;
  8812. GComponent.__super.call(this);
  8813. this._children=[];
  8814. this._controllers=[];
  8815. this._transitions=[];
  8816. this._margin=new Margin();
  8817. this._alignOffset=new Point();
  8818. this._opaque=false;
  8819. }
  8820. __class(GComponent,'fairygui.GComponent',_super);
  8821. var __proto=GComponent.prototype;
  8822. __proto.createDisplayObject=function(){
  8823. _super.prototype.createDisplayObject.call(this);
  8824. this._displayObject.mouseEnabled=true;
  8825. this._displayObject.mouseThrough=true;
  8826. this._container=this._displayObject;
  8827. }
  8828. __proto.dispose=function(){
  8829. var i=0;
  8830. var cnt=0;
  8831. cnt=this._transitions.length;
  8832. for (i=0;i < cnt;++i){
  8833. var trans=this._transitions[i];
  8834. trans.dispose();
  8835. }
  8836. cnt=this._controllers.length;
  8837. for (i=0;i < cnt;++i){
  8838. var cc=this._controllers[i];
  8839. cc.dispose();
  8840. }
  8841. if (this.scrollPane !=null)
  8842. this.scrollPane.dispose();
  8843. cnt=this._children.length;
  8844. for(i=cnt-1;i >=0;--i){
  8845. var obj=this._children[i];
  8846. obj.parent=null;
  8847. obj.dispose();
  8848. }
  8849. this._boundsChanged=false;
  8850. this._mask=null;
  8851. _super.prototype.dispose.call(this);
  8852. }
  8853. __proto.addChild=function(child){
  8854. this.addChildAt(child,this._children.length);
  8855. return child;
  8856. }
  8857. __proto.addChildAt=function(child,index){
  8858. (index===void 0)&& (index=0);
  8859. if(!child)
  8860. throw "child is null";
  8861. var numChildren=this._children.length;
  8862. if(index >=0 && index <=numChildren){
  8863. if(child.parent==this){
  8864. this.setChildIndex(child,index);
  8865. }
  8866. else {
  8867. child.removeFromParent();
  8868. child.parent=this;
  8869. var cnt=this._children.length;
  8870. if(child.sortingOrder !=0){
  8871. this._sortingChildCount++;
  8872. index=this.getInsertPosForSortingChild(child);
  8873. }
  8874. else if(this._sortingChildCount > 0){
  8875. if(index > (cnt-this._sortingChildCount))
  8876. index=cnt-this._sortingChildCount;
  8877. }
  8878. if(index==cnt)
  8879. this._children.push(child);
  8880. else
  8881. this._children.splice(index,0,child);
  8882. this.childStateChanged(child);
  8883. this.setBoundsChangedFlag();
  8884. }
  8885. return child;
  8886. }
  8887. else {
  8888. throw "Invalid child index";
  8889. }
  8890. }
  8891. __proto.getInsertPosForSortingChild=function(target){
  8892. var cnt=this._children.length;
  8893. var i=0;
  8894. for(i=0;i < cnt;i++){
  8895. var child=this._children[i];
  8896. if(child==target)
  8897. continue ;
  8898. if(target.sortingOrder < child.sortingOrder)
  8899. break ;
  8900. }
  8901. return i;
  8902. }
  8903. __proto.removeChild=function(child,dispose){
  8904. (dispose===void 0)&& (dispose=false);
  8905. var childIndex=this._children.indexOf(child);
  8906. if(childIndex !=-1){
  8907. this.removeChildAt(childIndex,dispose);
  8908. }
  8909. return child;
  8910. }
  8911. __proto.removeChildAt=function(index,dispose){
  8912. (dispose===void 0)&& (dispose=false);
  8913. if(index >=0 && index < this.numChildren){
  8914. var child=this._children[index];
  8915. child.parent=null;
  8916. if(child.sortingOrder !=0)
  8917. this._sortingChildCount--;
  8918. this._children.splice(index,1);
  8919. child.group=null;
  8920. if(child.inContainer){
  8921. this._container.removeChild(child.displayObject);
  8922. if (this._childrenRenderOrder==2)
  8923. Laya.timer.callLater(this,this.buildNativeDisplayList);
  8924. }
  8925. if(dispose)
  8926. child.dispose();
  8927. this.setBoundsChangedFlag();
  8928. return child;
  8929. }
  8930. else {
  8931. throw "Invalid child index";
  8932. }
  8933. }
  8934. __proto.removeChildren=function(beginIndex,endIndex,dispose){
  8935. (beginIndex===void 0)&& (beginIndex=0);
  8936. (endIndex===void 0)&& (endIndex=-1);
  8937. (dispose===void 0)&& (dispose=false);
  8938. if(endIndex < 0 || endIndex >=this.numChildren)
  8939. endIndex=this.numChildren-1;
  8940. for(var i=beginIndex;i <=endIndex;++i)
  8941. this.removeChildAt(beginIndex,dispose);
  8942. }
  8943. __proto.getChildAt=function(index){
  8944. (index===void 0)&& (index=0);
  8945. if(index >=0 && index < this.numChildren)
  8946. return this._children[index];
  8947. else
  8948. throw "Invalid child index";
  8949. }
  8950. __proto.getChild=function(name){
  8951. var cnt=this._children.length;
  8952. for(var i=0;i < cnt;++i){
  8953. if(this._children[i].name==name)
  8954. return this._children[i];
  8955. }
  8956. return null;
  8957. }
  8958. __proto.getVisibleChild=function(name){
  8959. var cnt=this._children.length;
  8960. for(var i=0;i < cnt;++i){
  8961. var child=this._children[i];
  8962. if(child.internalVisible && child.internalVisible2 && child.name==name)
  8963. return child;
  8964. }
  8965. return null;
  8966. }
  8967. __proto.getChildInGroup=function(name,group){
  8968. var cnt=this._children.length;
  8969. for(var i=0;i < cnt;++i){
  8970. var child=this._children[i];
  8971. if(child.group==group && child.name==name)
  8972. return child;
  8973. }
  8974. return null;
  8975. }
  8976. __proto.getChildById=function(id){
  8977. var cnt=this._children.length;
  8978. for(var i=0;i < cnt;++i){
  8979. if(this._children[i]._id==id)
  8980. return this._children[i];
  8981. }
  8982. return null;
  8983. }
  8984. __proto.getChildIndex=function(child){
  8985. return this._children.indexOf(child);
  8986. }
  8987. __proto.setChildIndex=function(child,index){
  8988. (index===void 0)&& (index=0);
  8989. var oldIndex=this._children.indexOf(child);
  8990. if(oldIndex==-1)
  8991. throw "Not a child of this container";
  8992. if(child.sortingOrder !=0)
  8993. return;
  8994. var cnt=this._children.length;
  8995. if(this._sortingChildCount > 0){
  8996. if(index > (cnt-this._sortingChildCount-1))
  8997. index=cnt-this._sortingChildCount-1;
  8998. }
  8999. this._setChildIndex(child,oldIndex,index);
  9000. }
  9001. __proto.setChildIndexBefore=function(child,index){
  9002. var oldIndex=this._children.indexOf(child);
  9003. if (oldIndex==-1)
  9004. throw "Not a child of this container";
  9005. if(child.sortingOrder!=0)
  9006. return oldIndex;
  9007. var cnt=this._children.length;
  9008. if(this._sortingChildCount>0){
  9009. if (index > (cnt-this._sortingChildCount-1))
  9010. index=cnt-this._sortingChildCount-1;
  9011. }
  9012. if (oldIndex < index)
  9013. return this._setChildIndex(child,oldIndex,index-1);
  9014. else
  9015. return this._setChildIndex(child,oldIndex,index);
  9016. }
  9017. __proto._setChildIndex=function(child,oldIndex,index){
  9018. var cnt=this._children.length;
  9019. if(index > cnt)
  9020. index=cnt;
  9021. if(oldIndex==index)
  9022. return oldIndex;
  9023. this._children.splice(oldIndex,1);
  9024. this._children.splice(index,0,child);
  9025. if(child.inContainer){
  9026. var displayIndex=0;
  9027. var g;
  9028. var i=0;
  9029. if (this._childrenRenderOrder==0){
  9030. for(i=0;i<index;i++){
  9031. g=this._children[i];
  9032. if(g.inContainer)
  9033. displayIndex++;
  9034. }
  9035. if(displayIndex==this._container.numChildren)
  9036. displayIndex--;
  9037. this._container.setChildIndex(child.displayObject,displayIndex);
  9038. }
  9039. else if (this._childrenRenderOrder==1){
  9040. for (i=cnt-1;i > index;i--){
  9041. g=this._children[i];
  9042. if (g.inContainer)
  9043. displayIndex++;
  9044. }
  9045. if(displayIndex==this._container.numChildren)
  9046. displayIndex--;
  9047. this._container.setChildIndex(child.displayObject,displayIndex);
  9048. }
  9049. else{
  9050. Laya.timer.callLater(this,this.buildNativeDisplayList);
  9051. }
  9052. this.setBoundsChangedFlag();
  9053. }
  9054. return index;
  9055. }
  9056. __proto.swapChildren=function(child1,child2){
  9057. var index1=this._children.indexOf(child1);
  9058. var index2=this._children.indexOf(child2);
  9059. if(index1==-1 || index2==-1)
  9060. throw "Not a child of this container";
  9061. this.swapChildrenAt(index1,index2);
  9062. }
  9063. __proto.swapChildrenAt=function(index1,index2){
  9064. (index2===void 0)&& (index2=0);
  9065. var child1=this._children[index1];
  9066. var child2=this._children[index2];
  9067. this.setChildIndex(child1,index2);
  9068. this.setChildIndex(child2,index1);
  9069. }
  9070. __proto.isAncestorOf=function(child){
  9071. if (child==null)
  9072. return false;
  9073. var p=child.parent;
  9074. while(p){
  9075. if(p==this)
  9076. return true;
  9077. p=p.parent;
  9078. }
  9079. return false;
  9080. }
  9081. __proto.addController=function(controller){
  9082. this._controllers.push(controller);
  9083. controller.parent=this;
  9084. this.applyController(controller);
  9085. }
  9086. __proto.getControllerAt=function(index){
  9087. return this._controllers[index];
  9088. }
  9089. __proto.getController=function(name){
  9090. var cnt=this._controllers.length;
  9091. for(var i=0;i < cnt;++i){
  9092. var c=this._controllers[i];
  9093. if(c.name==name)
  9094. return c;
  9095. }
  9096. return null;
  9097. }
  9098. __proto.removeController=function(c){
  9099. var index=this._controllers.indexOf(c);
  9100. if(index==-1)
  9101. throw new Error("controller not exists");
  9102. c.parent=null;
  9103. this._controllers.splice(index,1);
  9104. var length=this._children.length;
  9105. for(var i=0;i < length;i++){
  9106. var child=this._children[i];
  9107. child.handleControllerChanged(c);
  9108. }
  9109. }
  9110. __proto.childStateChanged=function(child){
  9111. if(this._buildingDisplayList)
  9112. return;
  9113. var cnt=this._children.length;
  9114. if((child instanceof fairygui.GGroup )){
  9115. for(var i=0;i < cnt;i++){
  9116. var g=this._children[i];
  9117. if(g.group==child)
  9118. this.childStateChanged(g);
  9119. }
  9120. return;
  9121. }
  9122. if(!child.displayObject)
  9123. return;
  9124. if(child.internalVisible && child.displayObject!=this._displayObject.mask){
  9125. if(!child.displayObject.parent){
  9126. var index=0
  9127. if (this._childrenRenderOrder==0){
  9128. for (i=0;i < cnt;i++){
  9129. g=this._children[i];
  9130. if (g==child)
  9131. break ;
  9132. if (g.displayObject !=null && g.displayObject.parent !=null)
  9133. index++;
  9134. }
  9135. this._container.addChildAt(child.displayObject,index);
  9136. }
  9137. else if (this._childrenRenderOrder==1){
  9138. for (i=cnt-1;i >=0;i--){
  9139. g=this._children[i];
  9140. if (g==child)
  9141. break ;
  9142. if (g.displayObject !=null && g.displayObject.parent !=null)
  9143. index++;
  9144. }
  9145. this._container.addChildAt(child.displayObject,index);
  9146. }
  9147. else{
  9148. this._container.addChild(child.displayObject);
  9149. Laya.timer.callLater(this,this.buildNativeDisplayList);
  9150. }
  9151. }
  9152. }
  9153. else {
  9154. if(child.displayObject.parent){
  9155. this._container.removeChild(child.displayObject);
  9156. if (this._childrenRenderOrder==2)
  9157. Laya.timer.callLater(this,this.buildNativeDisplayList);
  9158. }
  9159. }
  9160. }
  9161. __proto.buildNativeDisplayList=function(){
  9162. var cnt=this._children.length;
  9163. if (cnt==0)
  9164. return;
  9165. var i=0;
  9166. var child;
  9167. switch (this._childrenRenderOrder){
  9168. case 0:{
  9169. for (i=0;i < cnt;i++){
  9170. child=this._children[i];
  9171. if (child.displayObject !=null && child.internalVisible)
  9172. this._container.addChild(child.displayObject);
  9173. }
  9174. }
  9175. break ;
  9176. case 1:{
  9177. for (i=cnt-1;i >=0;i--){
  9178. child=this._children[i];
  9179. if (child.displayObject !=null && child.internalVisible)
  9180. this._container.addChild(child.displayObject);
  9181. }
  9182. }
  9183. break ;
  9184. case 2:{
  9185. for (i=0;i < this._apexIndex;i++){
  9186. child=this._children[i];
  9187. if (child.displayObject !=null && child.internalVisible)
  9188. this._container.addChild(child.displayObject);
  9189. }
  9190. for (i=cnt-1;i >=this._apexIndex;i--){
  9191. child=this._children[i];
  9192. if (child.displayObject !=null && child.internalVisible)
  9193. this._container.addChild(child.displayObject);
  9194. }
  9195. }
  9196. break ;
  9197. }
  9198. }
  9199. __proto.applyController=function(c){
  9200. this._applyingController=c;
  9201. var child;
  9202. var length=this._children.length;
  9203. for(var i=0;i < length;i++){
  9204. child=this._children[i];
  9205. child.handleControllerChanged(c);
  9206. }
  9207. this._applyingController=null;
  9208. c.runActions();
  9209. }
  9210. __proto.applyAllControllers=function(){
  9211. var cnt=this._controllers.length;
  9212. for(var i=0;i < cnt;++i){
  9213. this.applyController(this._controllers[i]);
  9214. }
  9215. }
  9216. __proto.adjustRadioGroupDepth=function(obj,c){
  9217. var cnt=this._children.length;
  9218. var i=NaN;
  9219. var child;
  9220. var myIndex=-1,maxIndex=-1;
  9221. for(i=0;i < cnt;i++){
  9222. child=this._children[i];
  9223. if(child==obj){
  9224. myIndex=i;
  9225. }
  9226. else if(((child instanceof fairygui.GButton ))
  9227. && (child).relatedController==c){
  9228. if(i > maxIndex)
  9229. maxIndex=i;
  9230. }
  9231. }
  9232. if(myIndex < maxIndex){
  9233. if(this._applyingController!=null)
  9234. this._children[maxIndex].handleControllerChanged(this._applyingController);
  9235. this.swapChildrenAt(myIndex,maxIndex);
  9236. }
  9237. }
  9238. __proto.getTransitionAt=function(index){
  9239. return this._transitions[index];
  9240. }
  9241. __proto.getTransition=function(transName){
  9242. var cnt=this._transitions.length;
  9243. for(var i=0;i < cnt;++i){
  9244. var trans=this._transitions[i];
  9245. if(trans.name==transName)
  9246. return trans;
  9247. }
  9248. return null;
  9249. }
  9250. __proto.isChildInView=function(child){
  9251. if(this._displayObject.scrollRect !=null){
  9252. return child.x+child.width >=0 && child.x <=this.width
  9253. && child.y+child.height >=0 && child.y <=this.height;
  9254. }
  9255. else if(this._scrollPane !=null){
  9256. return this._scrollPane.isChildInView(child);
  9257. }
  9258. else
  9259. return true;
  9260. }
  9261. __proto.getFirstChildInView=function(){
  9262. var cnt=this._children.length;
  9263. for(var i=0;i < cnt;++i){
  9264. var child=this._children[i];
  9265. if(this.isChildInView(child))
  9266. return i;
  9267. }
  9268. return-1;
  9269. }
  9270. __proto.setMask=function(value,reversed){
  9271. if(this._mask && this._mask!=value){
  9272. if(this._mask.blendMode=="destination-out")
  9273. this._mask.blendMode=null;
  9274. }
  9275. this._mask=value;
  9276. if(!this._mask){
  9277. this._displayObject.mask=null;
  9278. if((this._displayObject.hitArea instanceof fairygui.utils.ChildHitArea ))
  9279. this._displayObject.hitArea=null;
  9280. return;
  9281. }
  9282. if(this._mask.hitArea){
  9283. this._displayObject.hitArea=new ChildHitArea(this._mask,reversed);
  9284. this._displayObject.mouseThrough=false;
  9285. this._displayObject.hitTestPrior=true;
  9286. }
  9287. if(reversed){
  9288. this._displayObject.mask=null;
  9289. this._displayObject.cacheAs="bitmap";
  9290. this._mask.blendMode="destination-out";
  9291. }
  9292. else
  9293. this._displayObject.mask=this._mask;
  9294. }
  9295. __proto.updateHitArea=function(){
  9296. if((this._displayObject.hitArea instanceof fairygui.utils.PixelHitTest )){
  9297. var hitTest=(this._displayObject.hitArea);
  9298. if(this.sourceWidth!=0)
  9299. hitTest.scaleX=this.width/this.sourceWidth;
  9300. if(this.sourceHeight!=0)
  9301. hitTest.scaleY=this.height/this.sourceHeight;
  9302. }
  9303. else if((this._displayObject.hitArea instanceof laya.maths.Rectangle )){
  9304. this._displayObject.hitArea.setTo(0,0,this.width,this.height);
  9305. }
  9306. }
  9307. __proto.updateMask=function(){
  9308. var rect=this._displayObject.scrollRect;
  9309. if(rect==null)
  9310. rect=new Rectangle();
  9311. rect.x=this._margin.left;
  9312. rect.y=this._margin.top;
  9313. rect.width=this.width-this._margin.right;
  9314. rect.height=this.height-this._margin.bottom;
  9315. this._displayObject.scrollRect=rect;
  9316. }
  9317. __proto.setupScroll=function(buffer){
  9318. if (this._displayObject==this._container){
  9319. this._container=new Sprite();
  9320. this._displayObject.addChild(this._container);
  9321. }
  9322. this._scrollPane=new ScrollPane(this);
  9323. this._scrollPane.setup(buffer);
  9324. }
  9325. __proto.setupOverflow=function(overflow){
  9326. if(overflow==1){
  9327. if (this._displayObject==this._container){
  9328. this._container=new Sprite();
  9329. this._displayObject.addChild(this._container);
  9330. }
  9331. this.updateMask();
  9332. this._container.pos(this._margin.left,this._margin.top);
  9333. }
  9334. else if(this._margin.left !=0 || this._margin.top !=0){
  9335. if (this._displayObject==this._container){
  9336. this._container=new Sprite();
  9337. this._displayObject.addChild(this._container);
  9338. }
  9339. this._container.pos(this._margin.left,this._margin.top);
  9340. }
  9341. }
  9342. __proto.handleSizeChanged=function(){
  9343. _super.prototype.handleSizeChanged.call(this);
  9344. if(this._scrollPane)
  9345. this._scrollPane.onOwnerSizeChanged();
  9346. else if(this._displayObject.scrollRect !=null)
  9347. this.updateMask();
  9348. if(this._displayObject.hitArea!=null)
  9349. this.updateHitArea();
  9350. }
  9351. __proto.handleGrayedChanged=function(){
  9352. var c=this.getController("grayed");
  9353. if(c !=null){
  9354. c.selectedIndex=this.grayed ? 1 :0;
  9355. return;
  9356. };
  9357. var v=this.grayed;
  9358. var cnt=this._children.length;
  9359. for(var i=0;i < cnt;++i){
  9360. this._children[i].grayed=v;
  9361. }
  9362. }
  9363. __proto.handleControllerChanged=function(c){
  9364. _super.prototype.handleControllerChanged.call(this,c);
  9365. if (this._scrollPane !=null)
  9366. this._scrollPane.handleControllerChanged(c);
  9367. }
  9368. __proto.setBoundsChangedFlag=function(){
  9369. if (!this._scrollPane && !this._trackBounds)
  9370. return;
  9371. if (!this._boundsChanged){
  9372. this._boundsChanged=true;
  9373. Laya.timer.callLater(this,this.__render);
  9374. }
  9375. }
  9376. __proto.__render=function(){
  9377. if (this._boundsChanged){
  9378. var i1=0;
  9379. var len=this._children.length;
  9380. var child
  9381. for(i1=0;i1 < len;i1++){
  9382. child=this._children[i1];
  9383. child.ensureSizeCorrect();
  9384. }
  9385. this.updateBounds();
  9386. }
  9387. }
  9388. __proto.ensureBoundsCorrect=function(){
  9389. var i1=0;
  9390. var len=this._children.length;
  9391. var child
  9392. for(i1=0;i1 < len;i1++){
  9393. child=this._children[i1];
  9394. child.ensureSizeCorrect();
  9395. }
  9396. if (this._boundsChanged)
  9397. this.updateBounds();
  9398. }
  9399. __proto.updateBounds=function(){
  9400. var ax=0,ay=0,aw=0,ah=0;
  9401. var len=this._children.length;
  9402. if(len > 0){
  9403. ax=Number.POSITIVE_INFINITY,ay=Number.POSITIVE_INFINITY;
  9404. var ar=Number.NEGATIVE_INFINITY,ab=Number.NEGATIVE_INFINITY;
  9405. var tmp=0;
  9406. var i1=0;
  9407. for(i1=0;i1 < len;i1++){
  9408. var child=this._children[i1];
  9409. tmp=child.x;
  9410. if(tmp < ax)
  9411. ax=tmp;
  9412. tmp=child.y;
  9413. if(tmp < ay)
  9414. ay=tmp;
  9415. tmp=child.x+child.actualWidth;
  9416. if(tmp > ar)
  9417. ar=tmp;
  9418. tmp=child.y+child.actualHeight;
  9419. if(tmp > ab)
  9420. ab=tmp;
  9421. }
  9422. aw=ar-ax;
  9423. ah=ab-ay;
  9424. }
  9425. this.setBounds(ax,ay,aw,ah);
  9426. }
  9427. __proto.setBounds=function(ax,ay,aw,ah){
  9428. this._boundsChanged=false;
  9429. if (this._scrollPane)
  9430. this._scrollPane.setContentSize(Math.round(ax+aw),Math.round(ay+ah));
  9431. }
  9432. __proto.getSnappingPosition=function(xValue,yValue,resultPoint){
  9433. if(!resultPoint)
  9434. resultPoint=new Point();
  9435. var cnt=this._children.length;
  9436. if(cnt==0){
  9437. resultPoint.x=0;
  9438. resultPoint.y=0;
  9439. return resultPoint;
  9440. }
  9441. this.ensureBoundsCorrect();
  9442. var obj=null;
  9443. var prev=null;
  9444. var i=0;
  9445. if(yValue !=0){
  9446. for(;i < cnt;i++){
  9447. obj=this._children[i];
  9448. if(yValue < obj.y){
  9449. if(i==0){
  9450. yValue=0;
  9451. break ;
  9452. }
  9453. else {
  9454. prev=this._children[i-1];
  9455. if(yValue < prev.y+prev.actualHeight / 2)
  9456. yValue=prev.y;
  9457. else
  9458. yValue=obj.y;
  9459. break ;
  9460. }
  9461. }
  9462. }
  9463. if(i==cnt)
  9464. yValue=obj.y;
  9465. }
  9466. if(xValue !=0){
  9467. if(i > 0)
  9468. i--;
  9469. for(;i < cnt;i++){
  9470. obj=this._children[i];
  9471. if(xValue < obj.x){
  9472. if(i==0){
  9473. xValue=0;
  9474. break ;
  9475. }
  9476. else {
  9477. prev=this._children[i-1];
  9478. if(xValue < prev.x+prev.actualWidth / 2)
  9479. xValue=prev.x;
  9480. else
  9481. xValue=obj.x;
  9482. break ;
  9483. }
  9484. }
  9485. }
  9486. if(i==cnt)
  9487. xValue=obj.x;
  9488. }
  9489. resultPoint.x=xValue;
  9490. resultPoint.y=yValue;
  9491. return resultPoint;
  9492. }
  9493. __proto.childSortingOrderChanged=function(child,oldValue,newValue){
  9494. (newValue===void 0)&& (newValue=0);
  9495. if (newValue==0){
  9496. this._sortingChildCount--;
  9497. this.setChildIndex(child,this._children.length);
  9498. }
  9499. else {
  9500. if (oldValue==0)
  9501. this._sortingChildCount++;
  9502. var oldIndex=this._children.indexOf(child);
  9503. var index=this.getInsertPosForSortingChild(child);
  9504. if (oldIndex < index)
  9505. this._setChildIndex(child,oldIndex,index-1);
  9506. else
  9507. this._setChildIndex(child,oldIndex,index);
  9508. }
  9509. }
  9510. __proto.constructFromResource=function(){
  9511. this.constructFromResource2(null,0);
  9512. }
  9513. __proto.constructFromResource2=function(objectPool,poolIndex){
  9514. if (!this.packageItem.decoded){
  9515. this.packageItem.decoded=true;
  9516. TranslationHelper.translateComponent(this.packageItem);
  9517. };
  9518. var i=0;
  9519. var dataLen=0;
  9520. var curPos=0;
  9521. var nextPos=0;
  9522. var f1=NaN;
  9523. var f2=NaN;
  9524. var i1=0;
  9525. var i2=0;
  9526. var buffer=this.packageItem.rawData;
  9527. buffer.seek(0,0);
  9528. this._underConstruct=true;
  9529. this.sourceWidth=buffer.getInt32();
  9530. this.sourceHeight=buffer.getInt32();
  9531. this.initWidth=this.sourceWidth;
  9532. this.initHeight=this.sourceHeight;
  9533. this.setSize(this.sourceWidth,this.sourceHeight);
  9534. if (buffer.readBool()){
  9535. this.minWidth=buffer.getInt32();
  9536. this.maxWidth=buffer.getInt32();
  9537. this.minHeight=buffer.getInt32();
  9538. this.maxHeight=buffer.getInt32();
  9539. }
  9540. if (buffer.readBool()){
  9541. f1=buffer.getFloat32();
  9542. f2=buffer.getFloat32();
  9543. this.internalSetPivot(f1,f2,buffer.readBool());
  9544. }
  9545. if (buffer.readBool()){
  9546. this._margin.top=buffer.getInt32();
  9547. this._margin.bottom=buffer.getInt32();
  9548. this._margin.left=buffer.getInt32();
  9549. this._margin.right=buffer.getInt32();
  9550. };
  9551. var overflow=buffer.readByte();
  9552. if (overflow==2){
  9553. var savedPos=buffer.pos;
  9554. buffer.seek(0,7);
  9555. this.setupScroll(buffer);
  9556. buffer.pos=savedPos;
  9557. }
  9558. else
  9559. this.setupOverflow(overflow);
  9560. if (buffer.readBool())
  9561. buffer.skip(8);
  9562. this._buildingDisplayList=true;
  9563. buffer.seek(0,1);
  9564. var controllerCount=buffer.getInt16();
  9565. for (i=0;i < controllerCount;i++){
  9566. nextPos=buffer.getInt16();
  9567. nextPos+=buffer.pos;
  9568. var controller=new Controller();
  9569. this._controllers.push(controller);
  9570. controller.parent=this;
  9571. controller.setup(buffer);
  9572. buffer.pos=nextPos;
  9573. }
  9574. buffer.seek(0,2);
  9575. var child;
  9576. var childCount=buffer.getInt16();
  9577. for (i=0;i < childCount;i++){
  9578. dataLen=buffer.getInt16();
  9579. curPos=buffer.pos;
  9580. if (objectPool !=null)
  9581. child=objectPool[poolIndex+i];
  9582. else{
  9583. buffer.seek(curPos,0);
  9584. var type=buffer.readByte();
  9585. var src=buffer.readS();
  9586. var pkgId=buffer.readS();
  9587. var pi=null;
  9588. if (src !=null){
  9589. var pkg;
  9590. if (pkgId !=null)
  9591. pkg=UIPackage.getById(pkgId);
  9592. else
  9593. pkg=this.packageItem.owner;
  9594. pi=pkg !=null ? pkg.getItemById(src):null;
  9595. }
  9596. if (pi !=null){
  9597. child=UIObjectFactory.newObject(pi);
  9598. child.packageItem=pi;
  9599. child.constructFromResource();
  9600. }
  9601. else
  9602. child=UIObjectFactory.newObject2(type);
  9603. }
  9604. child._underConstruct=true;
  9605. child.setup_beforeAdd(buffer,curPos);
  9606. child.parent=this;
  9607. this._children.push(child);
  9608. buffer.pos=curPos+dataLen;
  9609. }
  9610. buffer.seek(0,3);
  9611. this.relations.setup(buffer,true);
  9612. buffer.seek(0,2);
  9613. buffer.skip(2);
  9614. for (i=0;i < childCount;i++){
  9615. nextPos=buffer.getInt16();
  9616. nextPos+=buffer.pos;
  9617. buffer.seek(buffer.pos,3);
  9618. this._children[i].relations.setup(buffer,false);
  9619. buffer.pos=nextPos;
  9620. }
  9621. buffer.seek(0,2);
  9622. buffer.skip(2);
  9623. for (i=0;i < childCount;i++){
  9624. nextPos=buffer.getInt16();
  9625. nextPos+=buffer.pos;
  9626. child=this._children[i];
  9627. child.setup_afterAdd(buffer,buffer.pos);
  9628. child._underConstruct=false;
  9629. buffer.pos=nextPos;
  9630. }
  9631. buffer.seek(0,4);
  9632. buffer.skip(2);
  9633. this.opaque=buffer.readBool();
  9634. var maskId=buffer.getInt16();
  9635. if (maskId !=-1){
  9636. this.setMask(this.getChildAt(maskId).displayObject,buffer.readBool());
  9637. };
  9638. var hitTestId=buffer.readS();
  9639. if (hitTestId !=null){
  9640. pi=this.packageItem.owner.getItemById(hitTestId);
  9641. if (pi !=null && pi.pixelHitTestData !=null){
  9642. i1=buffer.getInt32();
  9643. i2=buffer.getInt32();
  9644. this._displayObject.hitArea=new PixelHitTest(pi.pixelHitTestData,i1,i2);
  9645. this._displayObject.mouseThrough=false;
  9646. this._displayObject.hitTestPrior=true;
  9647. }
  9648. }
  9649. buffer.seek(0,5);
  9650. var transitionCount=buffer.getInt16();
  9651. for (i=0;i < transitionCount;i++){
  9652. nextPos=buffer.getInt16();
  9653. nextPos+=buffer.pos;
  9654. var trans=new Transition(this);
  9655. trans.setup(buffer);
  9656. this._transitions.push(trans);
  9657. buffer.pos=nextPos;
  9658. }
  9659. if (this._transitions.length > 0){
  9660. this.displayObject.on("display",this,this.___added);
  9661. this.displayObject.on("undisplay",this,this.___removed);
  9662. }
  9663. this.applyAllControllers();
  9664. this._buildingDisplayList=false;
  9665. this._underConstruct=false;
  9666. this.buildNativeDisplayList();
  9667. this.setBoundsChangedFlag();
  9668. if (this.packageItem.objectType !=9)
  9669. this.constructExtension(buffer);
  9670. this.constructFromXML(null);
  9671. }
  9672. __proto.constructExtension=function(buffer){}
  9673. __proto.constructFromXML=function(xml){}
  9674. __proto.setup_afterAdd=function(buffer,beginPos){
  9675. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  9676. buffer.seek(beginPos,4);
  9677. var pageController=buffer.getInt16();
  9678. if (pageController !=-1 && this._scrollPane !=null)
  9679. this._scrollPane.pageController=this._parent.getControllerAt(pageController);
  9680. var cnt=buffer.getInt16();
  9681. for (var i=0;i < cnt;i++){
  9682. var cc=this.getController(buffer.readS());
  9683. var pageId=buffer.readS();
  9684. if(cc)
  9685. cc.selectedPageId=pageId;
  9686. }
  9687. }
  9688. __proto.___added=function(){
  9689. var cnt=this._transitions.length;
  9690. for(var i=0;i < cnt;++i){
  9691. this._transitions[i].onOwnerAddedToStage();
  9692. }
  9693. }
  9694. __proto.___removed=function(){
  9695. var cnt=this._transitions.length;
  9696. for(var i=0;i < cnt;++i){
  9697. this._transitions[i].onOwnerRemovedFromStage();
  9698. }
  9699. }
  9700. __getset(0,__proto,'numChildren',function(){
  9701. return this._children.length;
  9702. });
  9703. __getset(0,__proto,'displayListContainer',function(){
  9704. return this._container;
  9705. });
  9706. /**
  9707. *@see ChildrenRenderOrder
  9708. */
  9709. /**
  9710. *@see ChildrenRenderOrder
  9711. */
  9712. __getset(0,__proto,'childrenRenderOrder',function(){
  9713. return this._childrenRenderOrder;
  9714. },function(value){
  9715. if (this._childrenRenderOrder !=value){
  9716. this._childrenRenderOrder=value;
  9717. this.buildNativeDisplayList();
  9718. }
  9719. });
  9720. __getset(0,__proto,'opaque',function(){
  9721. return this._opaque;
  9722. },function(value){
  9723. if(this._opaque!=value){
  9724. this._opaque=value;
  9725. if (this._opaque){
  9726. if(this._displayObject.hitArea==null)
  9727. this._displayObject.hitArea=new Rectangle();
  9728. if((this._displayObject.hitArea instanceof laya.maths.Rectangle ))
  9729. this._displayObject.hitArea.setTo(0,0,this.width,this.height);
  9730. this._displayObject.mouseThrough=false;
  9731. }
  9732. else {
  9733. if((this._displayObject.hitArea instanceof laya.maths.Rectangle ))
  9734. this._displayObject.hitArea=null;
  9735. this._displayObject.mouseThrough=true;
  9736. }
  9737. }
  9738. });
  9739. __getset(0,__proto,'controllers',function(){
  9740. return this._controllers;
  9741. });
  9742. __getset(0,__proto,'scrollPane',function(){
  9743. return this._scrollPane;
  9744. });
  9745. __getset(0,__proto,'margin',function(){
  9746. return this._margin;
  9747. },function(value){
  9748. this._margin.copy(value);
  9749. if(this._displayObject.scrollRect!=null){
  9750. this._container.pos(this._margin.left+this._alignOffset.x,this._margin.top+this._alignOffset.y);
  9751. }
  9752. this.handleSizeChanged();
  9753. });
  9754. __getset(0,__proto,'apexIndex',function(){
  9755. return this._apexIndex;
  9756. },function(value){
  9757. if (this._apexIndex !=value){
  9758. this._apexIndex=value;
  9759. if (this._childrenRenderOrder==2)
  9760. this.buildNativeDisplayList();
  9761. }
  9762. });
  9763. __getset(0,__proto,'mask',function(){
  9764. return this._mask;
  9765. },function(value){
  9766. this.setMask(value,false);
  9767. });
  9768. __getset(0,__proto,'viewHeight',function(){
  9769. if (this._scrollPane !=null)
  9770. return this._scrollPane.viewHeight;
  9771. else
  9772. return this.height-this._margin.top-this._margin.bottom;
  9773. },function(value){
  9774. if (this._scrollPane !=null)
  9775. this._scrollPane.viewHeight=value;
  9776. else
  9777. this.height=value+this._margin.top+this._margin.bottom;
  9778. });
  9779. __getset(0,__proto,'baseUserData',function(){
  9780. var buffer=this.packageItem.rawData;
  9781. buffer.seek(0,4);
  9782. return buffer.readS();
  9783. });
  9784. __getset(0,__proto,'viewWidth',function(){
  9785. if (this._scrollPane !=null)
  9786. return this._scrollPane.viewWidth;
  9787. else
  9788. return this.width-this._margin.left-this._margin.right;
  9789. },function(value){
  9790. if (this._scrollPane !=null)
  9791. this._scrollPane.viewWidth=value;
  9792. else
  9793. this.width=value+this._margin.left+this._margin.right;
  9794. });
  9795. return GComponent;
  9796. })(GObject)
  9797. //class fairygui.gears.GearAnimation extends fairygui.gears.GearBase
  9798. var GearAnimation=(function(_super){
  9799. var GearAnimationValue;
  9800. function GearAnimation(owner){
  9801. this._storage=null;
  9802. this._default=null;
  9803. GearAnimation.__super.call(this,owner);
  9804. }
  9805. __class(GearAnimation,'fairygui.gears.GearAnimation',_super);
  9806. var __proto=GearAnimation.prototype;
  9807. __proto.init=function(){
  9808. this._default=new GearAnimationValue((this._owner).playing,
  9809. (this._owner).frame);
  9810. this._storage={};
  9811. }
  9812. __proto.addStatus=function(pageId,buffer){
  9813. var gv;
  9814. if (pageId==null)
  9815. gv=this._default;
  9816. else {
  9817. gv=new GearAnimationValue();
  9818. this._storage[pageId]=gv;
  9819. }
  9820. gv.playing=buffer.readBool();
  9821. gv.frame=buffer.getInt32();
  9822. }
  9823. __proto.apply=function(){
  9824. this._owner._gearLocked=true;
  9825. var gv=this._storage[this._controller.selectedPageId];
  9826. if (!gv)
  9827. gv=this._default;
  9828. (this._owner).frame=gv.frame;
  9829. (this._owner).playing=gv.playing;
  9830. this._owner._gearLocked=false;
  9831. }
  9832. __proto.updateState=function(){
  9833. var mc=(this._owner);
  9834. var gv=this._storage[this._controller.selectedPageId];
  9835. if(!gv){
  9836. gv=new GearAnimationValue();
  9837. this._storage[this._controller.selectedPageId]=gv;
  9838. }
  9839. gv.frame=mc.frame;
  9840. gv.playing=mc.playing;
  9841. }
  9842. GearAnimation.__init$=function(){
  9843. //class GearAnimationValue
  9844. GearAnimationValue=(function(){
  9845. function GearAnimationValue(playing,frame){
  9846. this.playing=false;
  9847. this.frame=NaN;
  9848. (playing===void 0)&& (playing=true);
  9849. (frame===void 0)&& (frame=0);
  9850. this.playing=playing;
  9851. this.frame=frame;
  9852. }
  9853. __class(GearAnimationValue,'');
  9854. return GearAnimationValue;
  9855. })()
  9856. }
  9857. return GearAnimation;
  9858. })(GearBase)
  9859. //class fairygui.gears.GearColor extends fairygui.gears.GearBase
  9860. var GearColor=(function(_super){
  9861. var GearColorValue;
  9862. function GearColor(owner){
  9863. this._storage=null;
  9864. this._default=null;
  9865. GearColor.__super.call(this,owner);
  9866. }
  9867. __class(GearColor,'fairygui.gears.GearColor',_super);
  9868. var __proto=GearColor.prototype;
  9869. __proto.init=function(){
  9870. if(this._owner["strokeColor"]!=undefined)
  9871. this._default=new GearColorValue(this._owner["color"],this._owner["strokeColor"]);
  9872. else
  9873. this._default=new GearColorValue(this._owner["color"],null);
  9874. this._storage={};
  9875. }
  9876. __proto.addStatus=function(pageId,buffer){
  9877. var gv;
  9878. if (pageId==null)
  9879. gv=this._default;
  9880. else {
  9881. gv=new GearColorValue();
  9882. this._storage[pageId]=gv;
  9883. }
  9884. gv.color=buffer.readColorS();
  9885. gv.strokeColor=buffer.readColorS();
  9886. }
  9887. __proto.apply=function(){
  9888. this._owner._gearLocked=true;
  9889. var gv=this._storage[this._controller.selectedPageId];
  9890. if(!gv)
  9891. gv=this._default;
  9892. (this._owner).color=gv.color;
  9893. if(this._owner["strokeColor"]!=undefined && gv.strokeColor!=null)
  9894. this._owner["strokeColor"]=gv.strokeColor;
  9895. this._owner._gearLocked=false;
  9896. }
  9897. __proto.updateState=function(){
  9898. var gv=this._storage[this._controller.selectedPageId];
  9899. if(!gv){
  9900. gv=new GearColorValue(null,null);
  9901. this._storage[this._controller.selectedPageId]=gv;
  9902. }
  9903. gv.color=(this._owner).color;
  9904. if(this._owner["strokeColor"]!=undefined)
  9905. gv.strokeColor=this._owner["strokeColor"];
  9906. }
  9907. GearColor.__init$=function(){
  9908. //class GearColorValue
  9909. GearColorValue=(function(){
  9910. function GearColorValue(color,strokeColor){
  9911. this.color=null;
  9912. this.strokeColor=null;
  9913. this.color=color;
  9914. this.strokeColor=strokeColor;
  9915. }
  9916. __class(GearColorValue,'');
  9917. return GearColorValue;
  9918. })()
  9919. }
  9920. return GearColor;
  9921. })(GearBase)
  9922. //class fairygui.gears.GearDisplay extends fairygui.gears.GearBase
  9923. var GearDisplay=(function(_super){
  9924. function GearDisplay(owner){
  9925. this.pages=null;
  9926. this._visible=0;
  9927. this._displayLockToken=0;
  9928. GearDisplay.__super.call(this,owner);
  9929. this._displayLockToken=1;
  9930. }
  9931. __class(GearDisplay,'fairygui.gears.GearDisplay',_super);
  9932. var __proto=GearDisplay.prototype;
  9933. __proto.init=function(){
  9934. this.pages=null;
  9935. }
  9936. __proto.addLock=function(){
  9937. this._visible++;
  9938. return this._displayLockToken;
  9939. }
  9940. __proto.releaseLock=function(token){
  9941. if(token==this._displayLockToken)
  9942. this._visible--;
  9943. }
  9944. __proto.apply=function(){
  9945. this._displayLockToken++;
  9946. if(this._displayLockToken<=0)
  9947. this._displayLockToken=1;
  9948. if(this.pages==null || this.pages.length==0
  9949. || this.pages.indexOf(this._controller.selectedPageId)!=-1)
  9950. this._visible=1;
  9951. else
  9952. this._visible=0;
  9953. }
  9954. __getset(0,__proto,'connected',function(){
  9955. return this._controller==null || this._visible>0;
  9956. });
  9957. return GearDisplay;
  9958. })(GearBase)
  9959. //class fairygui.gears.GearIcon extends fairygui.gears.GearBase
  9960. var GearIcon=(function(_super){
  9961. function GearIcon(owner){
  9962. this._storage=null;
  9963. this._default=null;
  9964. GearIcon.__super.call(this,owner);
  9965. }
  9966. __class(GearIcon,'fairygui.gears.GearIcon',_super);
  9967. var __proto=GearIcon.prototype;
  9968. __proto.init=function(){
  9969. this._default=this._owner.icon;
  9970. this._storage={};
  9971. }
  9972. __proto.addStatus=function(pageId,buffer){
  9973. if(pageId==null)
  9974. this._default=buffer.readS();
  9975. else
  9976. this._storage[pageId]=buffer.readS();
  9977. }
  9978. __proto.apply=function(){
  9979. this._owner._gearLocked=true;
  9980. var data=this._storage[this._controller.selectedPageId];
  9981. if(data!==undefined)
  9982. this._owner.icon=data;
  9983. else
  9984. this._owner.icon=this._default;
  9985. this._owner._gearLocked=false;
  9986. }
  9987. __proto.updateState=function(){
  9988. this._storage[this._controller.selectedPageId]=this._owner.icon;
  9989. }
  9990. return GearIcon;
  9991. })(GearBase)
  9992. //class fairygui.gears.GearLook extends fairygui.gears.GearBase
  9993. var GearLook=(function(_super){
  9994. var GearLookValue;
  9995. function GearLook(owner){
  9996. this._storage=null;
  9997. this._default=null;
  9998. GearLook.__super.call(this,owner);
  9999. }
  10000. __class(GearLook,'fairygui.gears.GearLook',_super);
  10001. var __proto=GearLook.prototype;
  10002. __proto.init=function(){
  10003. this._default=new GearLookValue(this._owner.alpha,this._owner.rotation,this._owner.grayed,this._owner.touchable);
  10004. this._storage={};
  10005. }
  10006. __proto.addStatus=function(pageId,buffer){
  10007. var gv;
  10008. if (pageId==null)
  10009. gv=this._default;
  10010. else {
  10011. gv=new GearLookValue();
  10012. this._storage[pageId]=gv;
  10013. }
  10014. gv.alpha=buffer.getFloat32();
  10015. gv.rotation=buffer.getFloat32();
  10016. gv.grayed=buffer.readBool();
  10017. gv.touchable=buffer.readBool();
  10018. }
  10019. __proto.apply=function(){
  10020. var gv=this._storage[this._controller.selectedPageId];
  10021. if(!gv)
  10022. gv=this._default;
  10023. if(this._tweenConfig!=null && this._tweenConfig.tween && !UIPackage._constructing && !GearBase.disableAllTweenEffect){
  10024. this._owner._gearLocked=true;
  10025. this._owner.grayed=gv.grayed;
  10026. this._owner.touchable=gv.touchable;
  10027. this._owner._gearLocked=false;
  10028. if (this._tweenConfig._tweener !=null){
  10029. if (this._tweenConfig._tweener.endValue.x !=gv.alpha || this._tweenConfig._tweener.endValue.y !=gv.rotation){
  10030. this._tweenConfig._tweener.kill(true);
  10031. this._tweenConfig._tweener=null;
  10032. }
  10033. else
  10034. return;
  10035. };
  10036. var a=gv.alpha!=this._owner.alpha;
  10037. var b=gv.rotation!=this._owner.rotation;
  10038. if(a || b){
  10039. if(this._owner.checkGearController(0,this._controller))
  10040. this._tweenConfig._displayLockToken=this._owner.addDisplayLock();
  10041. this._tweenConfig._tweener=GTween.to2(this._owner.alpha,this._owner.rotation,gv.alpha,gv.rotation,this._tweenConfig.duration)
  10042. .setDelay(this._tweenConfig.delay)
  10043. .setEase(this._tweenConfig.easeType)
  10044. .setUserData((a ? 1 :0)+(b ? 2 :0))
  10045. .setTarget(this)
  10046. .onUpdate(this.__tweenUpdate,this)
  10047. .onComplete(this.__tweenComplete,this);
  10048. }
  10049. }
  10050. else {
  10051. this._owner._gearLocked=true;
  10052. this._owner.grayed=gv.grayed;
  10053. this._owner.alpha=gv.alpha;
  10054. this._owner.rotation=gv.rotation;
  10055. this._owner.touchable=gv.touchable;
  10056. this._owner._gearLocked=false;
  10057. }
  10058. }
  10059. __proto.__tweenUpdate=function(tweener){
  10060. var flag=tweener.userData;
  10061. this._owner._gearLocked=true;
  10062. if ((flag & 1)!=0)
  10063. this._owner.alpha=tweener.value.x;
  10064. if ((flag & 2)!=0)
  10065. this._owner.rotation=tweener.value.y;
  10066. this._owner._gearLocked=false;
  10067. }
  10068. __proto.__tweenComplete=function(){
  10069. if(this._tweenConfig._displayLockToken!=0){
  10070. this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken);
  10071. this._tweenConfig._displayLockToken=0;
  10072. }
  10073. this._tweenConfig._tweener=null;
  10074. }
  10075. __proto.updateState=function(){
  10076. var gv=this._storage[this._controller.selectedPageId];
  10077. if(!gv){
  10078. gv=new GearLookValue();
  10079. this._storage[this._controller.selectedPageId]=gv;
  10080. }
  10081. gv.alpha=this._owner.alpha;
  10082. gv.rotation=this._owner.rotation;
  10083. gv.grayed=this._owner.grayed;
  10084. gv.touchable=this._owner.touchable;
  10085. }
  10086. GearLook.__init$=function(){
  10087. //class GearLookValue
  10088. GearLookValue=(function(){
  10089. function GearLookValue(alpha,rotation,grayed,touchable){
  10090. this.alpha=NaN;
  10091. this.rotation=NaN;
  10092. this.grayed=false;
  10093. this.touchable=false;
  10094. (alpha===void 0)&& (alpha=0);
  10095. (rotation===void 0)&& (rotation=0);
  10096. (grayed===void 0)&& (grayed=false);
  10097. (touchable===void 0)&& (touchable=true);
  10098. this.alpha=alpha;
  10099. this.rotation=rotation;
  10100. this.grayed=grayed;
  10101. this.touchable=touchable;
  10102. }
  10103. __class(GearLookValue,'');
  10104. return GearLookValue;
  10105. })()
  10106. }
  10107. return GearLook;
  10108. })(GearBase)
  10109. //class fairygui.gears.GearSize extends fairygui.gears.GearBase
  10110. var GearSize=(function(_super){
  10111. var GearSizeValue;
  10112. function GearSize(owner){
  10113. this._storage=null;
  10114. this._default=null;
  10115. GearSize.__super.call(this,owner);
  10116. }
  10117. __class(GearSize,'fairygui.gears.GearSize',_super);
  10118. var __proto=GearSize.prototype;
  10119. __proto.init=function(){
  10120. this._default=new GearSizeValue(this._owner.width,this._owner.height,
  10121. this._owner.scaleX,this._owner.scaleY);
  10122. this._storage={};
  10123. }
  10124. __proto.addStatus=function(pageId,buffer){
  10125. var gv;
  10126. if (pageId==null)
  10127. gv=this._default;
  10128. else {
  10129. gv=new GearSizeValue();
  10130. this._storage[pageId]=gv;
  10131. }
  10132. gv.width=buffer.getInt32();
  10133. gv.height=buffer.getInt32();
  10134. gv.scaleX=buffer.getFloat32();
  10135. gv.scaleY=buffer.getFloat32();
  10136. }
  10137. __proto.apply=function(){
  10138. var gv=this._storage[this._controller.selectedPageId];
  10139. if (!gv)
  10140. gv=this._default;
  10141. if(this._tweenConfig!=null && this._tweenConfig.tween && !UIPackage._constructing && !GearBase.disableAllTweenEffect){
  10142. if (this._tweenConfig._tweener !=null){
  10143. if (this._tweenConfig._tweener.endValue.x !=gv.width || this._tweenConfig._tweener.endValue.y !=gv.height
  10144. || this._tweenConfig._tweener.endValue.z !=gv.scaleX || this._tweenConfig._tweener.endValue.w !=gv.scaleY){
  10145. this._tweenConfig._tweener.kill(true);
  10146. this._tweenConfig._tweener=null;
  10147. }
  10148. else
  10149. return;
  10150. };
  10151. var a=gv.width !=this._owner.width || gv.height !=this._owner.height;
  10152. var b=gv.scaleX !=this._owner.scaleX || gv.scaleY !=this._owner.scaleY;
  10153. if(a || b){
  10154. if(this._owner.checkGearController(0,this._controller))
  10155. this._tweenConfig._displayLockToken=this._owner.addDisplayLock();
  10156. this._tweenConfig._tweener=GTween.to4(this._owner.width,this._owner.height,this._owner.scaleX,this._owner.scaleY,gv.width,gv.height,gv.scaleX,gv.scaleY,this._tweenConfig.duration)
  10157. .setDelay(this._tweenConfig.delay)
  10158. .setEase(this._tweenConfig.easeType)
  10159. .setUserData((a ? 1 :0)+(b ? 2 :0))
  10160. .setTarget(this)
  10161. .onUpdate(this.__tweenUpdate,this)
  10162. .onComplete(this.__tweenComplete,this);
  10163. }
  10164. }
  10165. else {
  10166. this._owner._gearLocked=true;
  10167. this._owner.setSize(gv.width,gv.height,this._owner.checkGearController(1,this._controller));
  10168. this._owner.setScale(gv.scaleX,gv.scaleY);
  10169. this._owner._gearLocked=false;
  10170. }
  10171. }
  10172. __proto.__tweenUpdate=function(tweener){
  10173. var flag=tweener.userData;
  10174. this._owner._gearLocked=true;
  10175. if ((flag & 1)!=0)
  10176. this._owner.setSize(tweener.value.x,tweener.value.y,this._owner.checkGearController(1,this._controller));
  10177. if ((flag & 2)!=0)
  10178. this._owner.setScale(tweener.value.z,tweener.value.w);
  10179. this._owner._gearLocked=false;
  10180. }
  10181. __proto.__tweenComplete=function(){
  10182. if(this._tweenConfig._displayLockToken!=0){
  10183. this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken);
  10184. this._tweenConfig._displayLockToken=0;
  10185. }
  10186. this._tweenConfig._tweener=null;
  10187. }
  10188. __proto.updateState=function(){
  10189. var gv=this._storage[this._controller.selectedPageId];
  10190. if(!gv){
  10191. gv=new GearSizeValue();
  10192. this._storage[this._controller.selectedPageId]=gv;
  10193. }
  10194. gv.width=this._owner.width;
  10195. gv.height=this._owner.height;
  10196. gv.scaleX=this._owner.scaleX;
  10197. gv.scaleY=this._owner.scaleY;
  10198. }
  10199. __proto.updateFromRelations=function(dx,dy){
  10200. if(this._controller==null || this._storage==null)
  10201. return;
  10202. for(var key in this._storage){
  10203. var gv=this._storage[key];
  10204. gv.width+=dx;
  10205. gv.height+=dy;
  10206. }
  10207. this._default.width+=dx;
  10208. this._default.height+=dy;
  10209. this.updateState();
  10210. }
  10211. GearSize.__init$=function(){
  10212. //class GearSizeValue
  10213. GearSizeValue=(function(){
  10214. function GearSizeValue(width,height,scaleX,scaleY){
  10215. this.width=NaN;
  10216. this.height=NaN;
  10217. this.scaleX=NaN;
  10218. this.scaleY=NaN;
  10219. (width===void 0)&& (width=0);
  10220. (height===void 0)&& (height=0);
  10221. (scaleX===void 0)&& (scaleX=0);
  10222. (scaleY===void 0)&& (scaleY=0);
  10223. this.width=width;
  10224. this.height=height;
  10225. this.scaleX=scaleX;
  10226. this.scaleY=scaleY;
  10227. }
  10228. __class(GearSizeValue,'');
  10229. return GearSizeValue;
  10230. })()
  10231. }
  10232. return GearSize;
  10233. })(GearBase)
  10234. //class fairygui.GGraph extends fairygui.GObject
  10235. var GGraph=(function(_super){
  10236. function GGraph(){
  10237. this._type=0;
  10238. this._lineSize=NaN;
  10239. this._lineColor=null;
  10240. this._fillColor=null;
  10241. this._cornerRadius=null;
  10242. this._hitArea=null;
  10243. GGraph.__super.call(this);
  10244. this._type=0;
  10245. this._lineSize=1;
  10246. this._lineColor="#000000"
  10247. this._fillColor="#FFFFFF";
  10248. this._cornerRadius=null;
  10249. }
  10250. __class(GGraph,'fairygui.GGraph',_super);
  10251. var __proto=GGraph.prototype;
  10252. Laya.imps(__proto,{"fairygui.gears.IColorGear":true})
  10253. __proto.drawRect=function(lineSize,lineColor,fillColor,cornerRadius){
  10254. this._type=1;
  10255. this._lineSize=lineSize;
  10256. this._lineColor=lineColor;
  10257. this._fillColor=fillColor;
  10258. this._cornerRadius=cornerRadius;
  10259. this.drawCommon();
  10260. }
  10261. __proto.drawEllipse=function(lineSize,lineColor,fillColor){
  10262. this._type=2;
  10263. this._lineSize=lineSize;
  10264. this._lineColor=lineColor;
  10265. this._fillColor=fillColor;
  10266. this.drawCommon();
  10267. }
  10268. __proto.drawCommon=function(){
  10269. this._displayObject.mouseEnabled=this.touchable;
  10270. var gr=this._displayObject.graphics;
  10271. gr.clear();
  10272. var w=this.width;
  10273. var h=this.height;
  10274. if(w==0 || h==0)
  10275. return;
  10276. var fillColor=this._fillColor;
  10277. var lineColor=this._lineColor;
  10278. if(Render.isWebGL && ToolSet.startsWith(fillColor,"rgba")){
  10279. var arr=fillColor.substring(5,fillColor.lastIndexOf(")")).split(",");
  10280. var a=parseFloat(arr[3]);
  10281. if(a==0)
  10282. fillColor=null;
  10283. else {
  10284. fillColor=Utils.toHexColor((parseInt(arr[0])<<16)+(parseInt(arr[1])<<8)+parseInt(arr[2]));
  10285. this.alpha=a;
  10286. }
  10287. }
  10288. if (this._type==1){
  10289. if(this._cornerRadius!=null){
  10290. var paths=[
  10291. ["moveTo",this._cornerRadius[0],0],
  10292. ["lineTo",w-this._cornerRadius[1],0],
  10293. ["arcTo",w,0,w,this._cornerRadius[1],this._cornerRadius[1]],
  10294. ["lineTo",w,h-this._cornerRadius[3]],
  10295. ["arcTo",w,h,w-this._cornerRadius[3],h,this._cornerRadius[3]],
  10296. ["lineTo",this._cornerRadius[2],h],
  10297. ["arcTo",0,h,0,h-this._cornerRadius[2],this._cornerRadius[2]],
  10298. ["lineTo",0,this._cornerRadius[0]],
  10299. ["arcTo",0,0,this._cornerRadius[0],0,this._cornerRadius[0]],
  10300. ["closePath"]];
  10301. gr.drawPath(0,0,paths,{fillStyle:fillColor},this._lineSize>0?{strokeStyle:lineColor,lineWidth:this._lineSize}:null);
  10302. }
  10303. else
  10304. gr.drawRect(0,0,w,h,fillColor,this._lineSize>0?lineColor:null,this._lineSize);
  10305. }else{
  10306. gr.drawCircle(w/2,h/2,w/2,fillColor,this._lineSize>0?lineColor:null,this._lineSize);
  10307. }
  10308. this._displayObject.repaint();
  10309. }
  10310. __proto.replaceMe=function(target){
  10311. if (!this._parent)
  10312. throw "parent not set";
  10313. target.name=this.name;
  10314. target.alpha=this.alpha;
  10315. target.rotation=this.rotation;
  10316. target.visible=this.visible;
  10317. target.touchable=this.touchable;
  10318. target.grayed=this.grayed;
  10319. target.setXY(this.x,this.y);
  10320. target.setSize(this.width,this.height);
  10321. var index=this._parent.getChildIndex(this);
  10322. this._parent.addChildAt(target,index);
  10323. target.relations.copyFrom(this.relations);
  10324. this._parent.removeChild(this,true);
  10325. }
  10326. __proto.addBeforeMe=function(target){
  10327. if (this._parent==null)
  10328. throw "parent not set";
  10329. var index=this._parent.getChildIndex(this);
  10330. this._parent.addChildAt(target,index);
  10331. }
  10332. __proto.addAfterMe=function(target){
  10333. if (this._parent==null)
  10334. throw "parent not set";
  10335. var index=this._parent.getChildIndex(this);
  10336. index++;
  10337. this._parent.addChildAt(target,index);
  10338. }
  10339. __proto.setNativeObject=function(obj){
  10340. this._type=0;
  10341. this._displayObject.mouseEnabled=this.touchable;
  10342. this._displayObject.graphics.clear();
  10343. this._displayObject.addChild(obj);
  10344. }
  10345. __proto.createDisplayObject=function(){
  10346. _super.prototype.createDisplayObject.call(this);
  10347. this._displayObject.mouseEnabled=false;
  10348. this._hitArea=new HitArea();
  10349. this._hitArea.hit=this._displayObject.graphics;
  10350. this._displayObject.hitArea=this._hitArea;
  10351. }
  10352. __proto.handleSizeChanged=function(){
  10353. _super.prototype.handleSizeChanged.call(this);
  10354. if(this._type !=0)
  10355. this.drawCommon();
  10356. }
  10357. __proto.setup_beforeAdd=function(buffer,beginPos){
  10358. _super.prototype.setup_beforeAdd.call(this,buffer,beginPos);
  10359. buffer.seek(beginPos,5);
  10360. this._type=buffer.readByte();
  10361. if (this._type!=0){
  10362. this._lineSize=buffer.getInt32();
  10363. this._lineColor=buffer.readColorS(true);
  10364. this._fillColor=buffer.readColorS(true);
  10365. if (buffer.readBool()){
  10366. this._cornerRadius=[];
  10367. for (var i=0;i < 4;i++)
  10368. this._cornerRadius[i]=buffer.getFloat32();
  10369. }
  10370. this.drawCommon();
  10371. }
  10372. }
  10373. __getset(0,__proto,'color',function(){
  10374. return this._fillColor;
  10375. },function(value){
  10376. this._fillColor=value;
  10377. if(this._type!=0)
  10378. this.drawCommon();
  10379. });
  10380. return GGraph;
  10381. })(GObject)
  10382. //class fairygui.gears.GearText extends fairygui.gears.GearBase
  10383. var GearText=(function(_super){
  10384. function GearText(owner){
  10385. this._storage=null;
  10386. this._default=null;
  10387. GearText.__super.call(this,owner);
  10388. }
  10389. __class(GearText,'fairygui.gears.GearText',_super);
  10390. var __proto=GearText.prototype;
  10391. __proto.init=function(){
  10392. this._default=this._owner.text;
  10393. this._storage={};
  10394. }
  10395. __proto.addStatus=function(pageId,buffer){
  10396. if(pageId==null)
  10397. this._default=buffer.readS();
  10398. else
  10399. this._storage[pageId]=buffer.readS();
  10400. }
  10401. __proto.apply=function(){
  10402. this._owner._gearLocked=true;
  10403. var data=this._storage[this._controller.selectedPageId];
  10404. if(data!==undefined)
  10405. this._owner.text=data;
  10406. else
  10407. this._owner.text=this._default;
  10408. this._owner._gearLocked=false;
  10409. }
  10410. __proto.updateState=function(){
  10411. this._storage[this._controller.selectedPageId]=this._owner.text;
  10412. }
  10413. return GearText;
  10414. })(GearBase)
  10415. //class fairygui.GGroup extends fairygui.GObject
  10416. var GGroup=(function(_super){
  10417. function GGroup(){
  10418. this._layout=0;
  10419. this._lineGap=0;
  10420. this._columnGap=0;
  10421. this._percentReady=false;
  10422. this._boundsChanged=false;
  10423. this._updating=0;
  10424. GGroup.__super.call(this);
  10425. }
  10426. __class(GGroup,'fairygui.GGroup',_super);
  10427. var __proto=GGroup.prototype;
  10428. __proto.setBoundsChangedFlag=function(childSizeChanged){
  10429. (childSizeChanged===void 0)&& (childSizeChanged=false);
  10430. if (this._updating==0 && this.parent !=null){
  10431. if (childSizeChanged)
  10432. this._percentReady=false;
  10433. if(!this._boundsChanged){
  10434. this._boundsChanged=true;
  10435. if(this._layout!=0)
  10436. Laya.timer.callLater(this,this.ensureBoundsCorrect);
  10437. }
  10438. }
  10439. }
  10440. __proto.ensureBoundsCorrect=function(){
  10441. if (this._boundsChanged)
  10442. this.updateBounds();
  10443. }
  10444. __proto.updateBounds=function(){
  10445. Laya.timer.clear(this,this.ensureBoundsCorrect);
  10446. this._boundsChanged=false;
  10447. if (this.parent==null)
  10448. return;
  10449. this.handleLayout();
  10450. var cnt=this._parent.numChildren;
  10451. var i=0;
  10452. var child;
  10453. var ax=Number.POSITIVE_INFINITY,ay=Number.POSITIVE_INFINITY;
  10454. var ar=Number.NEGATIVE_INFINITY,ab=Number.NEGATIVE_INFINITY;
  10455. var tmp=0;
  10456. var empty=true;
  10457. for(i=0;i<cnt;i++){
  10458. child=this._parent.getChildAt(i);
  10459. if(child.group==this){
  10460. tmp=child.x;
  10461. if(tmp<ax)
  10462. ax=tmp;
  10463. tmp=child.y;
  10464. if(tmp<ay)
  10465. ay=tmp;
  10466. tmp=child.x+child.width;
  10467. if(tmp>ar)
  10468. ar=tmp;
  10469. tmp=child.y+child.height;
  10470. if(tmp>ab)
  10471. ab=tmp;
  10472. empty=false;
  10473. }
  10474. }
  10475. if (!empty){
  10476. this._updating=1;
  10477. this.setXY(ax,ay);
  10478. this._updating=2;
  10479. this.setSize(ar-ax,ab-ay);
  10480. }
  10481. else{
  10482. this._updating=2;
  10483. this.setSize(0,0);
  10484. }
  10485. this._updating=0;
  10486. }
  10487. __proto.handleLayout=function(){
  10488. this._updating |=1;
  10489. var child;
  10490. var i=0;
  10491. var cnt=0;
  10492. if (this._layout==1){
  10493. var curX=NaN;
  10494. cnt=this.parent.numChildren;
  10495. for (i=0;i < cnt;i++){
  10496. child=this.parent.getChildAt(i);
  10497. if (child.group !=this)
  10498. continue ;
  10499. if (isNaN(curX))
  10500. curX=Math.floor(child.x);
  10501. else
  10502. child.x=curX;
  10503. if (child.width !=0)
  10504. curX+=Math.floor(child.width+this._columnGap);
  10505. }
  10506. if (!this._percentReady)
  10507. this.updatePercent();
  10508. }
  10509. else if (this._layout==2){
  10510. var curY=NaN;
  10511. cnt=this.parent.numChildren;
  10512. for (i=0;i < cnt;i++){
  10513. child=this.parent.getChildAt(i);
  10514. if (child.group !=this)
  10515. continue ;
  10516. if (isNaN(curY))
  10517. curY=Math.floor(child.y);
  10518. else
  10519. child.y=curY;
  10520. if (child.height !=0)
  10521. curY+=Math.floor(child.height+this._lineGap);
  10522. }
  10523. if (!this._percentReady)
  10524. this.updatePercent();
  10525. }
  10526. this._updating &=2;
  10527. }
  10528. __proto.updatePercent=function(){
  10529. this._percentReady=true;
  10530. var cnt=this.parent.numChildren;
  10531. var i=0;
  10532. var child;
  10533. var size=0;
  10534. if (this._layout==1){
  10535. for (i=0;i < cnt;i++){
  10536. child=this.parent.getChildAt(i);
  10537. if (child.group !=this)
  10538. continue ;
  10539. size+=child.width;
  10540. }
  10541. for (i=0;i < cnt;i++){
  10542. child=this.parent.getChildAt(i);
  10543. if (child.group !=this)
  10544. continue ;
  10545. if (size > 0)
  10546. child._sizePercentInGroup=child.width / size;
  10547. else
  10548. child._sizePercentInGroup=0;
  10549. }
  10550. }
  10551. else{
  10552. for (i=0;i < cnt;i++){
  10553. child=this.parent.getChildAt(i);
  10554. if (child.group !=this)
  10555. continue ;
  10556. size+=child.height;
  10557. }
  10558. for (i=0;i < cnt;i++){
  10559. child=this.parent.getChildAt(i);
  10560. if (child.group !=this)
  10561. continue ;
  10562. if (size > 0)
  10563. child._sizePercentInGroup=child.height / size;
  10564. else
  10565. child._sizePercentInGroup=0;
  10566. }
  10567. }
  10568. }
  10569. __proto.moveChildren=function(dx,dy){
  10570. if ((this._updating & 1)!=0 || this.parent==null)
  10571. return;
  10572. this._updating |=1;
  10573. var cnt=this.parent.numChildren;
  10574. var i=0;
  10575. var child;
  10576. for (i=0;i < cnt;i++){
  10577. child=this.parent.getChildAt(i);
  10578. if (child.group==this){
  10579. child.setXY(child.x+dx,child.y+dy);
  10580. }
  10581. }
  10582. this._updating &=2;
  10583. }
  10584. __proto.resizeChildren=function(dw,dh){
  10585. if (this._layout==0 || (this._updating & 2)!=0 || this.parent==null)
  10586. return;
  10587. this._updating |=2;
  10588. if (!this._percentReady)
  10589. this.updatePercent();
  10590. var cnt=this.parent.numChildren;
  10591. var i=0;
  10592. var j=0;
  10593. var child;
  10594. var last=-1;
  10595. var numChildren=0;
  10596. var lineSize=0;
  10597. var remainSize=0;
  10598. var found=false;
  10599. for (i=0;i < cnt;i++){
  10600. child=this.parent.getChildAt(i);
  10601. if (child.group !=this)
  10602. continue ;
  10603. last=i;
  10604. numChildren++;
  10605. }
  10606. if (this._layout==1){
  10607. remainSize=lineSize=this.width-(numChildren-1)*this._columnGap;
  10608. var curX=NaN;
  10609. var nw=NaN;
  10610. for (i=0;i < cnt;i++){
  10611. child=this.parent.getChildAt(i);
  10612. if (child.group !=this)
  10613. continue ;
  10614. if (isNaN(curX))
  10615. curX=Math.floor(child.x);
  10616. else
  10617. child.x=curX;
  10618. if (last==i)
  10619. nw=remainSize;
  10620. else
  10621. nw=Math.round(child._sizePercentInGroup *lineSize);
  10622. child.setSize(nw,child._rawHeight+dh,true);
  10623. remainSize-=child.width;
  10624. if (last==i){
  10625. if (remainSize >=1){
  10626. for (j=0;j <=i;j++){
  10627. child=this.parent.getChildAt(j);
  10628. if (child.group !=this)
  10629. continue ;
  10630. if (!found){
  10631. nw=child.width+remainSize;
  10632. if ((child.maxWidth==0 || nw < child.maxWidth)
  10633. && (child.minWidth==0 || nw > child.minWidth)){
  10634. child.setSize(nw,child.height,true);
  10635. found=true;
  10636. }
  10637. }
  10638. else
  10639. child.x+=remainSize;
  10640. }
  10641. }
  10642. }
  10643. else
  10644. curX+=(child.width+this._columnGap);
  10645. }
  10646. }
  10647. else if (this._layout==2){
  10648. remainSize=lineSize=this.height-(numChildren-1)*this._lineGap;
  10649. var curY=NaN;
  10650. var nh=NaN;
  10651. for (i=0;i < cnt;i++){
  10652. child=this.parent.getChildAt(i);
  10653. if (child.group !=this)
  10654. continue ;
  10655. if (isNaN(curY))
  10656. curY=Math.floor(child.y);
  10657. else
  10658. child.y=curY;
  10659. if (last==i)
  10660. nh=remainSize;
  10661. else
  10662. nh=Math.round(child._sizePercentInGroup *lineSize);
  10663. child.setSize(child._rawWidth+dw,nh,true);
  10664. remainSize-=child.height;
  10665. if (last==i){
  10666. if (remainSize >=1){
  10667. for (j=0;j <=i;j++){
  10668. child=this.parent.getChildAt(j);
  10669. if (child.group !=this)
  10670. continue ;
  10671. if (!found){
  10672. nh=child.height+remainSize;
  10673. if ((child.maxHeight==0 || nh < child.maxHeight)
  10674. && (child.minHeight==0 || nh > child.minHeight)){
  10675. child.setSize(child.width,nh,true);
  10676. found=true;
  10677. }
  10678. }
  10679. else
  10680. child.y+=remainSize;
  10681. }
  10682. }
  10683. }
  10684. else
  10685. curY+=(child.height+this._lineGap);
  10686. }
  10687. }
  10688. this._updating &=1;
  10689. }
  10690. __proto.handleAlphaChanged=function(){
  10691. if(this._underConstruct||this._parent==null)
  10692. return;
  10693. var cnt=this._parent.numChildren;
  10694. for(var i=0;i<cnt;i++){
  10695. var child=this._parent.getChildAt(i);
  10696. if(child.group==this)
  10697. child.alpha=this.alpha;
  10698. }
  10699. }
  10700. __proto.handleVisibleChanged=function(){
  10701. if(!this._parent)
  10702. return;
  10703. var cnt=this._parent.numChildren;
  10704. for(var i=0;i<cnt;i++){
  10705. var child=this._parent.getChildAt(i);
  10706. if(child.group==this)
  10707. child.handleVisibleChanged();
  10708. }
  10709. }
  10710. __proto.setup_beforeAdd=function(buffer,beginPos){
  10711. _super.prototype.setup_beforeAdd.call(this,buffer,beginPos);
  10712. buffer.seek(beginPos,5);
  10713. this._layout=buffer.readByte();
  10714. this._lineGap=buffer.getInt32();
  10715. this._columnGap=buffer.getInt32();
  10716. }
  10717. __proto.setup_afterAdd=function(buffer,beginPos){
  10718. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  10719. if(!this.visible)
  10720. this.handleVisibleChanged();
  10721. }
  10722. /**
  10723. *@see GroupLayout
  10724. */
  10725. /**
  10726. *@see GroupLayout
  10727. */
  10728. __getset(0,__proto,'layout',function(){
  10729. return this._layout;
  10730. },function(value){
  10731. if(this._layout !=value){
  10732. this._layout=value;
  10733. this.setBoundsChangedFlag(true);
  10734. }
  10735. });
  10736. __getset(0,__proto,'columnGap',function(){
  10737. return this._columnGap;
  10738. },function(value){
  10739. if(this._columnGap !=value){
  10740. this._columnGap=value;
  10741. this.setBoundsChangedFlag();
  10742. }
  10743. });
  10744. __getset(0,__proto,'lineGap',function(){
  10745. return this._lineGap;
  10746. },function(value){
  10747. if(this._lineGap !=value){
  10748. this._lineGap=value;
  10749. this.setBoundsChangedFlag();
  10750. }
  10751. });
  10752. return GGroup;
  10753. })(GObject)
  10754. //class fairygui.GImage extends fairygui.GObject
  10755. var GImage=(function(_super){
  10756. function GImage(){
  10757. this.image=null;
  10758. this._color=null;
  10759. this._flip=0;
  10760. GImage.__super.call(this);
  10761. this._color="#FFFFFF";
  10762. }
  10763. __class(GImage,'fairygui.GImage',_super);
  10764. var __proto=GImage.prototype;
  10765. Laya.imps(__proto,{"fairygui.gears.IColorGear":true})
  10766. __proto.applyColor=function(){}
  10767. __proto.createDisplayObject=function(){
  10768. this._displayObject=this.image=new Image$1();
  10769. this.image.mouseEnabled=false;
  10770. this._displayObject["$owner"]=this;
  10771. }
  10772. __proto.constructFromResource=function(){
  10773. this.packageItem.load();
  10774. this.sourceWidth=this.packageItem.width;
  10775. this.sourceHeight=this.packageItem.height;
  10776. this.initWidth=this.sourceWidth;
  10777. this.initHeight=this.sourceHeight;
  10778. this.image.scale9Grid=this.packageItem.scale9Grid;
  10779. this.image.scaleByTile=this.packageItem.scaleByTile;
  10780. this.image.tileGridIndice=this.packageItem.tileGridIndice;
  10781. this.image.tex=this.packageItem.texture;
  10782. this.setSize(this.sourceWidth,this.sourceHeight);
  10783. }
  10784. __proto.handleXYChanged=function(){
  10785. _super.prototype.handleXYChanged.call(this);
  10786. if(this._flip !=0){
  10787. if(this.scaleX==-1)
  10788. this.image.x+=this.width;
  10789. if(this.scaleY==-1)
  10790. this.image.y+=this.height;
  10791. }
  10792. }
  10793. __proto.handleSizeChanged=function(){
  10794. if(this.image.tex!=null){
  10795. this.image.scaleTexture(this.width/this.sourceWidth,this.height/this.sourceHeight);
  10796. }
  10797. }
  10798. __proto.setup_beforeAdd=function(buffer,beginPos){
  10799. _super.prototype.setup_beforeAdd.call(this,buffer,beginPos);
  10800. buffer.seek(beginPos,5);
  10801. if (buffer.readBool())
  10802. this.color=buffer.readColorS();
  10803. this.flip=buffer.readByte();
  10804. this.image.fillMethod=buffer.readByte();
  10805. if (this.image.fillMethod !=0){
  10806. this.image.fillOrigin=buffer.readByte();
  10807. this.image.fillClockwise=buffer.readBool();
  10808. this.image.fillAmount=buffer.getFloat32();
  10809. }
  10810. }
  10811. __getset(0,__proto,'color',function(){
  10812. return this._color;
  10813. },function(value){
  10814. if(this._color !=value){
  10815. this._color=value;
  10816. this.updateGear(4);
  10817. this.applyColor();
  10818. }
  10819. });
  10820. __getset(0,__proto,'fillClockwise',function(){
  10821. return this.image.fillClockwise;
  10822. },function(value){
  10823. this.image.fillClockwise=value;
  10824. });
  10825. /**
  10826. *@see FlipType
  10827. */
  10828. /**
  10829. *@see FlipType
  10830. */
  10831. __getset(0,__proto,'flip',function(){
  10832. return this._flip;
  10833. },function(value){
  10834. if(this._flip!=value){
  10835. this._flip=value;
  10836. var sx=1,sy=1;
  10837. if(this._flip==1 || this._flip==3)
  10838. sx=-1;
  10839. if(this._flip==2 || this._flip==3)
  10840. sy=-1;
  10841. this.setScale(sx,sy);
  10842. this.handleXYChanged();
  10843. }
  10844. });
  10845. __getset(0,__proto,'fillMethod',function(){
  10846. return this.image.fillMethod;
  10847. },function(value){
  10848. this.image.fillMethod=value;
  10849. });
  10850. __getset(0,__proto,'fillOrigin',function(){
  10851. return this.image.fillOrigin;
  10852. },function(value){
  10853. this.image.fillOrigin=value;
  10854. });
  10855. __getset(0,__proto,'fillAmount',function(){
  10856. return this.image.fillAmount;
  10857. },function(value){
  10858. this.image.fillAmount=value;
  10859. });
  10860. return GImage;
  10861. })(GObject)
  10862. //class fairygui.gears.GearXY extends fairygui.gears.GearBase
  10863. var GearXY=(function(_super){
  10864. function GearXY(owner){
  10865. this._storage=null;
  10866. this._default=null;
  10867. GearXY.__super.call(this,owner);
  10868. }
  10869. __class(GearXY,'fairygui.gears.GearXY',_super);
  10870. var __proto=GearXY.prototype;
  10871. __proto.init=function(){
  10872. this._default=new Point(this._owner.x,this._owner.y);
  10873. this._storage={};
  10874. }
  10875. __proto.addStatus=function(pageId,buffer){
  10876. var gv;
  10877. if (pageId==null)
  10878. gv=this._default;
  10879. else {
  10880. gv=new Point();
  10881. this._storage[pageId]=gv;
  10882. }
  10883. gv.x=buffer.getInt32();
  10884. gv.y=buffer.getInt32();
  10885. }
  10886. __proto.apply=function(){
  10887. var pt=this._storage[this._controller.selectedPageId];
  10888. if (!pt)
  10889. pt=this._default;
  10890. if(this._tweenConfig!=null && this._tweenConfig.tween && !UIPackage._constructing && !GearBase.disableAllTweenEffect){
  10891. if (this._tweenConfig._tweener !=null){
  10892. if (this._tweenConfig._tweener.endValue.x !=pt.x || this._tweenConfig._tweener.endValue.y !=pt.y){
  10893. this._tweenConfig._tweener.kill(true);
  10894. this._tweenConfig._tweener=null;
  10895. }
  10896. else
  10897. return;
  10898. }
  10899. if (this._owner.x !=pt.x || this._owner.y !=pt.y){
  10900. if(this._owner.checkGearController(0,this._controller))
  10901. this._tweenConfig._displayLockToken=this._owner.addDisplayLock();
  10902. this._tweenConfig._tweener=GTween.to2(this._owner.x,this._owner.y,pt.x,pt.y,this._tweenConfig.duration)
  10903. .setDelay(this._tweenConfig.delay)
  10904. .setEase(this._tweenConfig.easeType)
  10905. .setTarget(this)
  10906. .onUpdate(this.__tweenUpdate,this)
  10907. .onComplete(this.__tweenComplete,this);
  10908. }
  10909. }
  10910. else {
  10911. this._owner._gearLocked=true;
  10912. this._owner.setXY(pt.x,pt.y);
  10913. this._owner._gearLocked=false;
  10914. }
  10915. }
  10916. __proto.__tweenUpdate=function(tweener){
  10917. this._owner._gearLocked=true;
  10918. this._owner.setXY(tweener.value.x,tweener.value.y);
  10919. this._owner._gearLocked=false;
  10920. }
  10921. __proto.__tweenComplete=function(){
  10922. if(this._tweenConfig._displayLockToken!=0){
  10923. this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken);
  10924. this._tweenConfig._displayLockToken=0;
  10925. }
  10926. this._tweenConfig._tweener=null;
  10927. }
  10928. __proto.updateState=function(){
  10929. var pt=this._storage[this._controller.selectedPageId];
  10930. if(!pt){
  10931. pt=new Point();
  10932. this._storage[this._controller.selectedPageId]=pt;
  10933. }
  10934. pt.x=this._owner.x;
  10935. pt.y=this._owner.y;
  10936. }
  10937. __proto.updateFromRelations=function(dx,dy){
  10938. if(this._controller==null || this._storage==null)
  10939. return;
  10940. for (var key in this._storage){
  10941. var pt=this._storage[key];
  10942. pt.x+=dx;
  10943. pt.y+=dy;
  10944. }
  10945. this._default.x+=dx;
  10946. this._default.y+=dy;
  10947. this.updateState();
  10948. }
  10949. return GearXY;
  10950. })(GearBase)
  10951. //class fairygui.GLoader extends fairygui.GObject
  10952. var GLoader=(function(_super){
  10953. function GLoader(){
  10954. this._url=null;
  10955. this._align=null;
  10956. this._valign=null;
  10957. this._autoSize=false;
  10958. this._fill=0;
  10959. this._shrinkOnly=false;
  10960. this._showErrorSign=false;
  10961. this._playing=false;
  10962. this._frame=0;
  10963. this._color=null;
  10964. this._contentItem=null;
  10965. this._contentSourceWidth=0;
  10966. this._contentSourceHeight=0;
  10967. this._contentWidth=0;
  10968. this._contentHeight=0;
  10969. this._content=null;
  10970. this._errorSign=null;
  10971. this._content2=null;
  10972. this._updatingLayout=false;
  10973. GLoader.__super.call(this);
  10974. this._playing=true;
  10975. this._url="";
  10976. this._fill=0;
  10977. this._align="left";
  10978. this._valign="top";
  10979. this._showErrorSign=true;
  10980. this._color="#FFFFFF";
  10981. this.isdispose=false;
  10982. this.effectpkgdict=null;
  10983. }
  10984. __class(GLoader,'fairygui.GLoader',_super);
  10985. var __proto=GLoader.prototype;
  10986. Laya.imps(__proto,{"fairygui.gears.IAnimationGear":true,"fairygui.gears.IColorGear":true})
  10987. __proto.createDisplayObject=function(){
  10988. _super.prototype.createDisplayObject.call(this);
  10989. this._displayObject.mouseEnabled=true;
  10990. }
  10991. __proto.dispose=function(){
  10992. if(this._contentItem==null && ((this._content instanceof fairygui.display.Image ))){
  10993. var texture=(this._content).tex;
  10994. if(texture !=null)
  10995. this.freeExternal(texture);
  10996. }
  10997. if(this._content2!=null)
  10998. this._content2.dispose();
  10999. this.isdispose=true;
  11000. this.clearEffectDict();
  11001. this.effectpkgdict=null;
  11002. _super.prototype.dispose.call(this);
  11003. }
  11004. __proto.advance=function(timeInMiniseconds){
  11005. if((this._content instanceof fairygui.display.MovieClip ))
  11006. (this._content).advance(timeInMiniseconds);
  11007. }
  11008. __proto.applyColor=function(){}
  11009. __proto.loadContent=function(){
  11010. this.clearContent();
  11011. this.clearEffectDict();
  11012. if (!this._url)
  11013. return;
  11014. if( UIConfig$1.gameEffectDict && UIConfig$1.gameEffectDict[this._url] !=null ){
  11015. if(UIConfig$1.gameEffectDict[this._url]=="1"){
  11016. UIConfig$1.gameLoaderManager.loadEffect( this._url,this,this.effectComplete,this._url );
  11017. }else{
  11018. UIConfig$1.gameLoaderManager.loadEffect( UIConfig$1.gameEffectDict[this._url],this,this.effectComplete,this._url );
  11019. }
  11020. }
  11021. else
  11022. {
  11023. if(ToolSet.startsWith(this._url,"ui://"))
  11024. this.loadFromPackage(this._url);
  11025. else
  11026. this.loadExternal();
  11027. }
  11028. }
  11029. __proto.clearEffectDict=function(){
  11030. if(this.effectpkgdict){
  11031. for(var s in this.effectpkgdict){
  11032. UIConfig$1.gameLoaderManager.removeeffectpackage(this.effectpkgdict[s]);
  11033. delete this.effectpkgdict[s];
  11034. }
  11035. }
  11036. }
  11037. __proto.effectComplete=function(itemurl){
  11038. if(itemurl==this._url&&!this.isdispose){
  11039. var pkgname=UIConfig$1.gameEffectDict[this._url];
  11040. var effecturl;
  11041. if(pkgname=="1"){
  11042. pkgname=itemurl;
  11043. UIConfig$1.gameLoaderManager.addeffectPackage(pkgname);
  11044. effecturl=fairygui.UIPackage.getItemURL(pkgname,pkgname);
  11045. }else{
  11046. UIConfig$1.gameLoaderManager.addeffectPackage(pkgname);
  11047. effecturl=this._url;
  11048. }
  11049. if(!this.effectpkgdict){
  11050. this.effectpkgdict={};
  11051. }
  11052. this.effectpkgdict[itemurl]=pkgname;
  11053. this.loadFromPackage(effecturl);
  11054. }
  11055. }
  11056. __proto.loadFromPackage=function(itemURL){
  11057. this._contentItem=UIPackage.getItemByURL(itemURL);
  11058. if(this._contentItem !=null){
  11059. this._contentItem.load();
  11060. if(this._autoSize)
  11061. this.setSize(this._contentItem.width,this._contentItem.height);
  11062. if(this._contentItem.type==0){
  11063. if(this._contentItem.texture==null){
  11064. if( UIConfig$1.gameBgResousedict && UIConfig$1.gameBgResousedict[this._url]!=null){
  11065. this._url=UIConfig$1.gameBgResousedict[this._url];
  11066. this.loadExternal();
  11067. }else{
  11068. this.setErrorState();
  11069. }
  11070. }
  11071. else {
  11072. if(!((this._content instanceof fairygui.display.Image ))){
  11073. this._content=new Image$1();
  11074. this._displayObject.addChild(this._content);
  11075. }
  11076. else
  11077. this._displayObject.addChild(this._content);
  11078. (this._content).tex=this._contentItem.texture;
  11079. (this._content).scale9Grid=this._contentItem.scale9Grid;
  11080. (this._content).scaleByTile=this._contentItem.scaleByTile;
  11081. (this._content).tileGridIndice=this._contentItem.tileGridIndice;
  11082. this._contentSourceWidth=this._contentItem.width;
  11083. this._contentSourceHeight=this._contentItem.height;
  11084. this.updateLayout();
  11085. }
  11086. }
  11087. else if(this._contentItem.type==1){
  11088. if(!((this._content instanceof fairygui.display.MovieClip ))){
  11089. this._content=new MovieClip$1();
  11090. this._displayObject.addChild(this._content);
  11091. }
  11092. else
  11093. this._displayObject.addChild(this._content);
  11094. this._contentSourceWidth=this._contentItem.width;
  11095. this._contentSourceHeight=this._contentItem.height;
  11096. (this._content).interval=this._contentItem.interval;
  11097. (this._content).swing=this._contentItem.swing;
  11098. (this._content).repeatDelay=this._contentItem.repeatDelay;
  11099. (this._content).frames=this._contentItem.frames;
  11100. (this._content).boundsRect=new Rectangle(0,0,this._contentSourceWidth,this._contentSourceHeight);
  11101. this.updateLayout();
  11102. }
  11103. else if(this._contentItem.type==3){
  11104. var obj=UIPackage.createObjectFromURL(itemURL);
  11105. if(!obj)
  11106. this.setErrorState();
  11107. else if(!((obj instanceof fairygui.GComponent ))){
  11108. obj.dispose();
  11109. this.setErrorState();
  11110. }
  11111. else{
  11112. this._content2=obj.asCom;
  11113. this._displayObject.addChild(this._content2.displayObject);
  11114. this._contentSourceWidth=this._contentItem.width;
  11115. this._contentSourceHeight=this._contentItem.height;
  11116. this.updateLayout();
  11117. }
  11118. }
  11119. else
  11120. this.setErrorState();
  11121. }
  11122. else{
  11123. if( UIConfig$1.gameBgResousedict && UIConfig$1.gameBgResousedict[this._url]!=null){
  11124. this._url=UIConfig$1.gameBgResousedict[this._url];
  11125. this.loadExternal();
  11126. }else{
  11127. this.setErrorState();
  11128. }
  11129. }
  11130. }
  11131. __proto.loadFromContentItem=function(contentItem){
  11132. this._contentItem=null;
  11133. this._contentItem=contentItem;
  11134. if(this._contentItem){
  11135. if(!this._content){
  11136. this._content=new MovieClip$1();
  11137. this._displayObject.addChild(this._content);
  11138. (this._content).playing=false;
  11139. }
  11140. this._contentSourceWidth=this._contentItem.width;
  11141. this._contentSourceHeight=this._contentItem.height;
  11142. (this._content).interval=this._contentItem.interval;
  11143. (this._content).swing=this._contentItem.swing;
  11144. (this._content).repeatDelay=this._contentItem.repeatDelay;
  11145. (this._content).frames=this._contentItem.frames;
  11146. this.updateLayout();
  11147. }
  11148. }
  11149. __proto.loadExternal=function(){
  11150. var texture = AssetProxy.inst.getRes(this._url);
  11151. if(texture){
  11152. this.onExternalLoadSuccess(this._url);
  11153. }else{
  11154. AssetProxy.inst.load([{ url:this._url, type:"image" }],Handler.create(this,this.__getResCompleted,[this._url]));
  11155. }
  11156. }
  11157. __proto.freeExternal=function(texture){}
  11158. __proto.onExternalLoadSuccess=function(urls){
  11159. if(!((this._content instanceof fairygui.display.Image ))){
  11160. this._content=new Image$1();
  11161. this._displayObject.addChild(this._content);
  11162. }
  11163. else
  11164. this._displayObject.addChild(this._content);
  11165. var texture = AssetProxy.inst.getRes(urls);
  11166. (this._content).tex=texture;//texture;
  11167. (this._content).scale9Grid=null;
  11168. (this._content).scaleByTile=false;
  11169. if( !texture ){
  11170. return;
  11171. }
  11172. this._contentSourceWidth=texture.width;
  11173. this._contentSourceHeight=texture.height;
  11174. this.updateLayout();
  11175. }
  11176. __proto.onExternalLoadFailed=function(){
  11177. this.setErrorState();
  11178. }
  11179. __proto.__getResCompleted=function(tex){
  11180. if(tex!=null)
  11181. this.onExternalLoadSuccess(tex);
  11182. else
  11183. this.onExternalLoadFailed();
  11184. }
  11185. __proto.setErrorState=function(){
  11186. if (!this._showErrorSign)
  11187. return;
  11188. if (this._errorSign==null){
  11189. if (UIConfig$1.loaderErrorSign !=null){
  11190. this._errorSign=fairygui.GLoader._errorSignPool.getObject(UIConfig$1.loaderErrorSign);
  11191. }
  11192. }
  11193. if (this._errorSign !=null){
  11194. this._errorSign.setSize(this.width,this.height);
  11195. this._displayObject.addChild(this._errorSign.displayObject);
  11196. }
  11197. }
  11198. __proto.clearErrorState=function(){
  11199. if (this._errorSign !=null){
  11200. this._displayObject.removeChild(this._errorSign.displayObject);
  11201. fairygui.GLoader._errorSignPool.returnObject(this._errorSign);
  11202. this._errorSign=null;
  11203. }
  11204. }
  11205. __proto.updateLayout=function(){
  11206. if (this._content2==null && this._content==null){
  11207. if (this._autoSize){
  11208. this._updatingLayout=true;
  11209. this.setSize(50,30);
  11210. this._updatingLayout=false;
  11211. }
  11212. return;
  11213. }
  11214. this._contentWidth=this._contentSourceWidth;
  11215. this._contentHeight=this._contentSourceHeight;
  11216. if (this._autoSize){
  11217. this._updatingLayout=true;
  11218. if (this._contentWidth==0)
  11219. this._contentWidth=50;
  11220. if (this._contentHeight==0)
  11221. this._contentHeight=30;
  11222. this.setSize(this._contentWidth,this._contentHeight);
  11223. this._updatingLayout=false;
  11224. if(this._contentWidth==this._width && this._contentHeight==this._height){
  11225. if(this._content2!=null){
  11226. this._content2.setXY(0,0);
  11227. this._content2.setScale(1,1);
  11228. }
  11229. else{
  11230. this._content.x=0;
  11231. this._content.y=0;
  11232. this._content.scaleX=1;
  11233. this._content.scaleY=1;
  11234. }
  11235. return;
  11236. }
  11237. };
  11238. var sx=1,sy=1;
  11239. if(this._fill!=0){
  11240. sx=this.width/this._contentSourceWidth;
  11241. sy=this.height/this._contentSourceHeight;
  11242. if(sx!=1 || sy!=1){
  11243. if (this._fill==2)
  11244. sx=sy;
  11245. else if (this._fill==3)
  11246. sy=sx;
  11247. else if (this._fill==1){
  11248. if (sx > sy)
  11249. sx=sy;
  11250. else
  11251. sy=sx;
  11252. }
  11253. else if (this._fill==5){
  11254. if (sx > sy)
  11255. sy=sx;
  11256. else
  11257. sx=sy;
  11258. }
  11259. if(this._shrinkOnly){
  11260. if(sx>1)
  11261. sx=1;
  11262. if(sy>1)
  11263. sy=1;
  11264. }
  11265. this._contentWidth=this._contentSourceWidth *sx;
  11266. this._contentHeight=this._contentSourceHeight *sy;
  11267. }
  11268. }
  11269. if(this._content2!=null)
  11270. this._content2.setScale(sx,sy);
  11271. else if ((this._content instanceof fairygui.display.Image ))
  11272. (this._content).scaleTexture(sx,sy);
  11273. else
  11274. this._content.scale(sx,sy);
  11275. var nx=NaN,ny=NaN;
  11276. if (this._align=="center")
  11277. nx=Math.floor((this.width-this._contentWidth)/ 2);
  11278. else if (this._align=="right")
  11279. nx=this.width-this._contentWidth;
  11280. else
  11281. nx=0;
  11282. if (this._valign=="middle")
  11283. ny=Math.floor((this.height-this._contentHeight)/ 2);
  11284. else if (this._valign=="bottom")
  11285. ny=this.height-this._contentHeight;
  11286. else
  11287. ny=0;
  11288. if(this._content2!=null)
  11289. this._content2.setXY(nx,ny);
  11290. else{
  11291. this._content.x=nx;
  11292. this._content.y=ny;
  11293. }
  11294. }
  11295. __proto.clearContent=function(){
  11296. this.clearErrorState();
  11297. if (this._content !=null && this._content.parent !=null)
  11298. this._displayObject.removeChild(this._content);
  11299. if(this._contentItem==null && ((this._content instanceof fairygui.display.Image ))){
  11300. var texture=(this._content).tex;
  11301. if(texture !=null)
  11302. this.freeExternal(texture);
  11303. }
  11304. if(this._content2!=null){
  11305. this._content2.dispose();
  11306. this._content2=null;
  11307. }
  11308. this._contentItem=null;
  11309. }
  11310. __proto.handleSizeChanged=function(){
  11311. _super.prototype.handleSizeChanged.call(this);
  11312. if(!this._updatingLayout)
  11313. this.updateLayout();
  11314. }
  11315. __proto.setup_beforeAdd=function(buffer,beginPos){
  11316. _super.prototype.setup_beforeAdd.call(this,buffer,beginPos);
  11317. buffer.seek(beginPos,5);
  11318. var iv=0;
  11319. this._url=buffer.readS();
  11320. iv=buffer.readByte();
  11321. this._align=iv==0?"left":(iv==1?"center":"right");
  11322. iv=buffer.readByte();
  11323. this._valign=iv==0?"top":(iv==1?"middle":"bottom");
  11324. this._fill=buffer.readByte();
  11325. this._shrinkOnly=buffer.readBool();
  11326. this._autoSize=buffer.readBool();
  11327. this._showErrorSign=buffer.readBool();
  11328. this._playing=buffer.readBool();
  11329. this._frame=buffer.getInt32();
  11330. if (buffer.readBool())
  11331. this.color=buffer.readColorS();
  11332. var fillMethod=buffer.readByte();
  11333. if (fillMethod !=0)
  11334. buffer.skip(6);
  11335. if (this._url)
  11336. this.loadContent();
  11337. }
  11338. __getset(0,__proto,'frame',function(){
  11339. return this._frame;
  11340. },function(value){
  11341. if (this._frame !=value){
  11342. this._frame=value;
  11343. if ((this._content instanceof fairygui.display.MovieClip ))
  11344. (this._content).frame=value;
  11345. this.updateGear(5);
  11346. }
  11347. });
  11348. __getset(0,__proto,'url',function(){
  11349. return this._url;
  11350. },function(value){
  11351. if (this._url==value)
  11352. return;
  11353. this._url=value;
  11354. this.loadContent();
  11355. this.updateGear(7);
  11356. });
  11357. __getset(0,__proto,'align',function(){
  11358. return this._align;
  11359. },function(value){
  11360. if (this._align !=value){
  11361. this._align=value;
  11362. this.updateLayout();
  11363. }
  11364. });
  11365. /**
  11366. *@see LoaderFillType
  11367. */
  11368. /**
  11369. *@see LoaderFillType
  11370. */
  11371. __getset(0,__proto,'fill',function(){
  11372. return this._fill;
  11373. },function(value){
  11374. if (this._fill !=value){
  11375. this._fill=value;
  11376. this.updateLayout();
  11377. }
  11378. });
  11379. __getset(0,__proto,'verticalAlign',function(){
  11380. return this._valign;
  11381. },function(value){
  11382. if (this._valign !=value){
  11383. this._valign=value;
  11384. this.updateLayout();
  11385. }
  11386. });
  11387. __getset(0,__proto,'icon',function(){
  11388. return this._url;
  11389. },function(value){
  11390. this.url=value;
  11391. });
  11392. __getset(0,__proto,'content',function(){
  11393. return this._content;
  11394. });
  11395. __getset(0,__proto,'shrinkOnly',function(){
  11396. return this._shrinkOnly;
  11397. },function(value){
  11398. if(this._shrinkOnly!=value){
  11399. this._shrinkOnly=value;
  11400. this.updateLayout();
  11401. }
  11402. });
  11403. //todo:
  11404. __getset(0,__proto,'showErrorSign',function(){
  11405. return this._showErrorSign;
  11406. },function(value){
  11407. this._showErrorSign=value;
  11408. });
  11409. __getset(0,__proto,'autoSize',function(){
  11410. return this._autoSize;
  11411. },function(value){
  11412. if (this._autoSize !=value){
  11413. this._autoSize=value;
  11414. this.updateLayout();
  11415. }
  11416. });
  11417. __getset(0,__proto,'playing',function(){
  11418. return this._playing;
  11419. },function(value){
  11420. if (this._playing !=value){
  11421. this._playing=value;
  11422. if ((this._content instanceof fairygui.display.MovieClip ))
  11423. (this._content).playing=value;
  11424. this.updateGear(5);
  11425. }
  11426. });
  11427. //从start帧开始,播放到end帧(-1表示结尾),重复times次(0表示无限循环),循环结束后,停止在endAt帧(-1表示参数end)
  11428. __proto.setPlaySettings=function(start,end,times,endAt,endHandler){
  11429. (start===void 0)&& (start=0);
  11430. (end===void 0)&& (end=-1);
  11431. (times===void 0)&& (times=0);
  11432. (endAt===void 0)&& (endAt=-1);
  11433. if ((this._content instanceof fairygui.display.MovieClip )){
  11434. (this._content).setPlaySettings(start,end,times,endAt,endHandler);
  11435. }
  11436. }
  11437. __getset(0,__proto,'content',function(){
  11438. return this._content;
  11439. });
  11440. __getset(0,__proto,'timeScale',function(){
  11441. if((this._content instanceof fairygui.display.MovieClip ))
  11442. return (this._content).timeScale;
  11443. else
  11444. return 1;
  11445. },function(value){
  11446. if((this._content instanceof fairygui.display.MovieClip ))
  11447. (this._content).timeScale=value;
  11448. });
  11449. __getset(0,__proto,'color',function(){
  11450. return this._color;
  11451. },function(value){
  11452. if(this._color !=value){
  11453. this._color=value;
  11454. this.updateGear(4);
  11455. this.applyColor();
  11456. }
  11457. });
  11458. __getset(0,__proto,'component',function(){
  11459. return this._content2;
  11460. });
  11461. __static(GLoader,
  11462. ['_errorSignPool',function(){return this._errorSignPool=new GObjectPool();}
  11463. ]);
  11464. return GLoader;
  11465. })(GObject)
  11466. //class fairygui.GMovieClip extends fairygui.GObject
  11467. var GMovieClip=(function(_super){
  11468. function GMovieClip(){
  11469. this._movieClip=null;
  11470. GMovieClip.__super.call(this);
  11471. this._sizeImplType=1;
  11472. }
  11473. __class(GMovieClip,'fairygui.GMovieClip',_super);
  11474. var __proto=GMovieClip.prototype;
  11475. Laya.imps(__proto,{"fairygui.gears.IAnimationGear":true,"fairygui.gears.IColorGear":true})
  11476. __proto.createDisplayObject=function(){
  11477. this._displayObject=this._movieClip=new MovieClip$1();
  11478. this._movieClip.mouseEnabled=false;
  11479. this._displayObject["$owner"]=this;
  11480. }
  11481. __proto.rewind=function(){
  11482. this._movieClip.rewind();
  11483. }
  11484. __proto.syncStatus=function(anotherMc){
  11485. this._movieClip.syncStatus(anotherMc._movieClip);
  11486. }
  11487. __proto.advance=function(timeInMiniseconds){
  11488. this._movieClip.advance(timeInMiniseconds);
  11489. }
  11490. //从start帧开始,播放到end帧(-1表示结尾),重复times次(0表示无限循环),循环结束后,停止在endAt帧(-1表示参数end)
  11491. __proto.setPlaySettings=function(start,end,times,endAt,endHandler){
  11492. (start===void 0)&& (start=0);
  11493. (end===void 0)&& (end=-1);
  11494. (times===void 0)&& (times=0);
  11495. (endAt===void 0)&& (endAt=-1);
  11496. this._movieClip.setPlaySettings(start,end,times,endAt,endHandler);
  11497. }
  11498. __proto.constructFromResource=function(){
  11499. this.sourceWidth=this.packageItem.width;
  11500. this.sourceHeight=this.packageItem.height;
  11501. this.initWidth=this.sourceWidth;
  11502. this.initHeight=this.sourceHeight;
  11503. this.setSize(this.sourceWidth,this.sourceHeight);
  11504. this.packageItem.load();
  11505. this._movieClip.interval=this.packageItem.interval;
  11506. this._movieClip.swing=this.packageItem.swing;
  11507. this._movieClip.repeatDelay=this.packageItem.repeatDelay;
  11508. this._movieClip.frames=this.packageItem.frames;
  11509. this._movieClip.boundsRect=new Rectangle(0,0,this.sourceWidth,this.sourceHeight);
  11510. }
  11511. __proto.setinterval=function(value){
  11512. if(this._movieClip){
  11513. this._movieClip.interval=value;
  11514. }
  11515. }
  11516. __proto.setup_beforeAdd=function(buffer,beginPos){
  11517. _super.prototype.setup_beforeAdd.call(this,buffer,beginPos);
  11518. buffer.seek(beginPos,5);
  11519. if (buffer.readBool())
  11520. this.color=buffer.readColorS();
  11521. buffer.readByte();
  11522. this._movieClip.frame=buffer.getInt32();
  11523. this._movieClip.playing=buffer.readBool();
  11524. }
  11525. __getset(0,__proto,'color',function(){
  11526. return "#FFFFFF";
  11527. },function(value){
  11528. });
  11529. __getset(0,__proto,'playing',function(){
  11530. return this._movieClip.playing;
  11531. },function(value){
  11532. if (this._movieClip.playing !=value){
  11533. this._movieClip.playing=value;
  11534. this.updateGear(5);
  11535. }
  11536. });
  11537. __getset(0,__proto,'timeScale',function(){
  11538. return this._movieClip.timeScale;
  11539. },function(value){
  11540. this._movieClip.timeScale=value;
  11541. });
  11542. __getset(0,__proto,'frame',function(){
  11543. return this._movieClip.frame;
  11544. },function(value){
  11545. if (this._movieClip.frame !=value){
  11546. this._movieClip.frame=value;
  11547. this.updateGear(5);
  11548. }
  11549. });
  11550. return GMovieClip;
  11551. })(GObject)
  11552. //class fairygui.GBasicTextField extends fairygui.GTextField
  11553. var GBasicTextField=(function(_super){
  11554. var LineInfo,TextExt;
  11555. function GBasicTextField(){
  11556. this.textField=null;
  11557. this._font=null;
  11558. this._color=null;
  11559. this._ubbEnabled=false;
  11560. this._singleLine=false;
  11561. this._letterSpacing=0;
  11562. this._autoSize=0;
  11563. this._widthAutoSize=false;
  11564. this._heightAutoSize=false;
  11565. this._updatingSize=false;
  11566. this._textWidth=0;
  11567. this._textHeight=0;
  11568. this._bitmapFont=null;
  11569. this._lines=null;
  11570. GBasicTextField.__super.call(this);
  11571. this._text="";
  11572. this._color="#000000";
  11573. this.textField.align="left";
  11574. this.textField.font=UIConfig$1.defaultFont;
  11575. this._autoSize=1;
  11576. this._widthAutoSize=this._heightAutoSize=true;
  11577. this.textField["_sizeDirty"]=false;
  11578. }
  11579. __class(GBasicTextField,'fairygui.GBasicTextField',_super);
  11580. var __proto=GBasicTextField.prototype;
  11581. __proto.createDisplayObject=function(){
  11582. this._displayObject=this.textField=new TextExt(this);
  11583. this._displayObject["$owner"]=this;
  11584. this._displayObject.mouseEnabled=false;
  11585. }
  11586. __proto.setAutoSize=function(value){
  11587. this._autoSize=value;
  11588. this._widthAutoSize=value==1;
  11589. this._heightAutoSize=value==1 || value==2;
  11590. this.textField.wordWrap=!this._widthAutoSize && !this._singleLine;
  11591. if(!this._underConstruct){
  11592. if(!this._heightAutoSize)
  11593. this.textField.size(this.width,this.height);
  11594. else if(!this._widthAutoSize)
  11595. this.textField.width=this.width;
  11596. }
  11597. }
  11598. __proto.ensureSizeCorrect=function(){
  11599. if (!this._underConstruct && this.textField["_isChanged"])
  11600. this.textField.typeset();
  11601. }
  11602. __proto.typeset=function(){
  11603. if(this._bitmapFont!=null)
  11604. this.renderWithBitmapFont();
  11605. else if(this._widthAutoSize || this._heightAutoSize)
  11606. this.updateSize();
  11607. }
  11608. __proto.updateSize=function(){
  11609. this._textWidth=Math.ceil(this.textField.textWidth);
  11610. this._textHeight=Math.ceil(this.textField.textHeight);
  11611. var w=NaN,h=0;
  11612. if(this._widthAutoSize){
  11613. w=this._textWidth;
  11614. if(this.textField.width!=w){
  11615. this.textField.width=w;
  11616. if(this.textField.align!="left")
  11617. this.textField["baseTypeset"]();
  11618. }
  11619. }
  11620. else
  11621. w=this.width;
  11622. if(this._heightAutoSize){
  11623. h=this._textHeight;
  11624. if(!this._widthAutoSize){
  11625. if(this.textField.height!=this._textHeight)
  11626. this.textField.height=this._textHeight;
  11627. }
  11628. }
  11629. else {
  11630. h=this.height;
  11631. if(this._textHeight > h)
  11632. this._textHeight=h;
  11633. if(this.textField.height!=this._textHeight)
  11634. this.textField.height=this._textHeight;
  11635. }
  11636. this._updatingSize=true;
  11637. this.setSize(w,h);
  11638. this._updatingSize=false;
  11639. }
  11640. __proto.renderWithBitmapFont=function(){
  11641. var gr=this._displayObject.graphics;
  11642. gr.clear();
  11643. if (!this._lines)
  11644. this._lines=[];
  11645. else
  11646. LineInfo.returnList(this._lines);
  11647. var letterSpacing=this.letterSpacing;
  11648. var lineSpacing=this.leading-1;
  11649. var rectWidth=this.width-2 *2;
  11650. var lineWidth=0,lineHeight=0,lineTextHeight=0;
  11651. var glyphWidth=0,glyphHeight=0;
  11652. var wordChars=0,wordStart=0,wordEnd=0;
  11653. var lastLineHeight=0;
  11654. var lineBuffer="";
  11655. var lineY=2;
  11656. var line;
  11657. var wordWrap=!this._widthAutoSize && !this._singleLine;
  11658. var fontSize=this.fontSize;
  11659. var fontScale=this._bitmapFont.resizable?fontSize/this._bitmapFont.size:1;
  11660. this._textWidth=0;
  11661. this._textHeight=0;
  11662. var text2=this._text;
  11663. if (this._templateVars !=null)
  11664. text2=this.parseTemplate(text2);
  11665. var textLength=text2.length;
  11666. for (var offset=0;offset < textLength;++offset){
  11667. var ch=text2.charAt(offset);
  11668. var cc=ch.charCodeAt(0);
  11669. if (cc==10){
  11670. lineBuffer+=ch;
  11671. line=LineInfo.borrow();
  11672. line.width=lineWidth;
  11673. if (lineTextHeight==0){
  11674. if (lastLineHeight==0)
  11675. lastLineHeight=fontSize;
  11676. if (lineHeight==0)
  11677. lineHeight=lastLineHeight;
  11678. lineTextHeight=lineHeight;
  11679. }
  11680. line.height=lineHeight;
  11681. lastLineHeight=lineHeight;
  11682. line.textHeight=lineTextHeight;
  11683. line.text=lineBuffer;
  11684. line.y=lineY;
  11685. lineY+=(line.height+lineSpacing);
  11686. if (line.width > this._textWidth)
  11687. this._textWidth=line.width;
  11688. this._lines.push(line);
  11689. lineBuffer="";
  11690. lineWidth=0;
  11691. lineHeight=0;
  11692. lineTextHeight=0;
  11693. wordChars=0;
  11694. wordStart=0;
  11695. wordEnd=0;
  11696. continue ;
  11697. }
  11698. if (cc>=65 && cc<=90 || cc>=97 && cc<=122){
  11699. if (wordChars==0)
  11700. wordStart=lineWidth;
  11701. wordChars++;
  11702. }
  11703. else{
  11704. if (wordChars > 0)
  11705. wordEnd=lineWidth;
  11706. wordChars=0;
  11707. }
  11708. if (cc==32){
  11709. glyphWidth=Math.ceil(fontSize / 2);
  11710. glyphHeight=fontSize;
  11711. }
  11712. else {
  11713. var glyph=this._bitmapFont.glyphs[ch];
  11714. if (glyph){
  11715. glyphWidth=Math.ceil(glyph.advance*fontScale);
  11716. glyphHeight=Math.ceil(glyph.lineHeight*fontScale);
  11717. }
  11718. else {
  11719. glyphWidth=0;
  11720. glyphHeight=0;
  11721. }
  11722. }
  11723. if (glyphHeight > lineTextHeight)
  11724. lineTextHeight=glyphHeight;
  11725. if (glyphHeight > lineHeight)
  11726. lineHeight=glyphHeight;
  11727. if (lineWidth !=0)
  11728. lineWidth+=letterSpacing;
  11729. lineWidth+=glyphWidth;
  11730. if (!wordWrap || lineWidth <=rectWidth){
  11731. lineBuffer+=ch;
  11732. }
  11733. else {
  11734. line=LineInfo.borrow();
  11735. line.height=lineHeight;
  11736. line.textHeight=lineTextHeight;
  11737. if (lineBuffer.length==0){
  11738. line.text=ch;
  11739. }
  11740. else if (wordChars > 0 && wordEnd > 0){
  11741. lineBuffer+=ch;
  11742. var len=lineBuffer.length-wordChars;
  11743. line.text=ToolSet.trimRight(lineBuffer.substr(0,len));
  11744. line.width=wordEnd;
  11745. lineBuffer=lineBuffer.substr(len);
  11746. lineWidth-=wordStart;
  11747. }
  11748. else {
  11749. line.text=lineBuffer;
  11750. line.width=lineWidth-(glyphWidth+letterSpacing);
  11751. lineBuffer=ch;
  11752. lineWidth=glyphWidth;
  11753. lineHeight=glyphHeight;
  11754. lineTextHeight=glyphHeight;
  11755. }
  11756. line.y=lineY;
  11757. lineY+=(line.height+lineSpacing);
  11758. if (line.width > this._textWidth)
  11759. this._textWidth=line.width;
  11760. wordChars=0;
  11761. wordStart=0;
  11762. wordEnd=0;
  11763. this._lines.push(line);
  11764. }
  11765. }
  11766. if (lineBuffer.length > 0){
  11767. line=LineInfo.borrow();
  11768. line.width=lineWidth;
  11769. if (lineHeight==0)
  11770. lineHeight=lastLineHeight;
  11771. if (lineTextHeight==0)
  11772. lineTextHeight=lineHeight;
  11773. line.height=lineHeight;
  11774. line.textHeight=lineTextHeight;
  11775. line.text=lineBuffer;
  11776. line.y=lineY;
  11777. if (line.width > this._textWidth)
  11778. this._textWidth=line.width;
  11779. this._lines.push(line);
  11780. }
  11781. if (this._textWidth > 0)
  11782. this._textWidth+=2 *2;
  11783. var count=this._lines.length;
  11784. if (count==0){
  11785. this._textHeight=0;
  11786. }
  11787. else {
  11788. line=this._lines[this._lines.length-1];
  11789. this._textHeight=line.y+line.height+2;
  11790. };
  11791. var w=NaN,h=0;
  11792. if (this._widthAutoSize){
  11793. if (this._textWidth==0)
  11794. w=0;
  11795. else
  11796. w=this._textWidth;
  11797. }
  11798. else
  11799. w=this.width;
  11800. if (this._heightAutoSize){
  11801. if (this._textHeight==0)
  11802. h=0;
  11803. else
  11804. h=this._textHeight;
  11805. }
  11806. else
  11807. h=this.height;
  11808. this._updatingSize=true;
  11809. this.setSize(w,h);
  11810. this._updatingSize=false;
  11811. this.doAlign();
  11812. if (w==0 || h==0)
  11813. return;
  11814. var charX=2;
  11815. var lineIndent=0;
  11816. var charIndent=0;
  11817. rectWidth=this.width-2 *2;
  11818. var lineCount=this._lines.length;
  11819. for (var i=0;i < lineCount;i++){
  11820. line=this._lines[i];
  11821. charX=2;
  11822. if (this.align=="center")
  11823. lineIndent=(rectWidth-line.width)/ 2;
  11824. else if (this.align=="right")
  11825. lineIndent=rectWidth-line.width;
  11826. else
  11827. lineIndent=0;
  11828. textLength=line.text.length;
  11829. for (var j=0;j < textLength;j++){
  11830. ch=line.text.charAt(j);
  11831. cc=ch.charCodeAt(0);
  11832. if(cc==10)
  11833. continue ;
  11834. if(cc==32){
  11835. charX+=this._letterSpacing+Math.ceil(fontSize/2);
  11836. continue ;
  11837. }
  11838. glyph=this._bitmapFont.glyphs[ch];
  11839. if (glyph !=null){
  11840. charIndent=(line.height+line.textHeight)/ 2-Math.ceil(glyph.lineHeight*fontScale);
  11841. if(glyph.texture){
  11842. gr.drawTexture(glyph.texture,
  11843. charX+lineIndent+Math.ceil(glyph.offsetX*fontScale),
  11844. line.y+charIndent+Math.ceil(glyph.offsetY*fontScale),
  11845. glyph.texture.width *fontScale,
  11846. glyph.texture.height *fontScale);
  11847. }
  11848. charX+=letterSpacing+Math.ceil(glyph.advance*fontScale);
  11849. }
  11850. else {
  11851. charX+=letterSpacing;
  11852. }
  11853. }
  11854. }
  11855. }
  11856. //line loop
  11857. __proto.handleSizeChanged=function(){
  11858. if(this._updatingSize)
  11859. return;
  11860. if(this._underConstruct)
  11861. this.textField.size(this.width,this.height);
  11862. else{
  11863. if(this._bitmapFont!=null){
  11864. if(!this._widthAutoSize)
  11865. this.textField["setChanged"]();
  11866. else
  11867. this.doAlign();
  11868. }
  11869. else {
  11870. if(!this._widthAutoSize){
  11871. if(!this._heightAutoSize)
  11872. this.textField.size(this.width,this.height);
  11873. else
  11874. this.textField.width=this.width;
  11875. }
  11876. }
  11877. }
  11878. }
  11879. __proto.handleGrayedChanged=function(){
  11880. fairygui.GObject.prototype.handleGrayedChanged.call(this);
  11881. if(this.grayed)
  11882. this.textField.color="#AAAAAA";
  11883. else
  11884. this.textField.color=this._color;
  11885. }
  11886. __proto.doAlign=function(){
  11887. if(this.valign=="top" || this._textHeight==0)
  11888. this._yOffset=2;
  11889. else {
  11890. var dh=this.height-this._textHeight;
  11891. if(dh < 0)
  11892. dh=0;
  11893. if(this.valign=="middle")
  11894. this._yOffset=Math.floor(dh / 2);
  11895. else
  11896. this._yOffset=Math.floor(dh);
  11897. }
  11898. this.handleXYChanged();
  11899. }
  11900. __proto.flushVars=function(){
  11901. this.text=this._text;
  11902. }
  11903. __getset(0,__proto,'bold',function(){
  11904. return this.textField.bold;
  11905. },function(value){
  11906. this.textField.bold=value;
  11907. });
  11908. __getset(0,__proto,'letterSpacing',function(){
  11909. return this._letterSpacing;
  11910. },function(value){
  11911. this._letterSpacing=value;
  11912. });
  11913. __getset(0,__proto,'align',function(){
  11914. return this.textField.align;
  11915. },function(value){
  11916. this.textField.align=value;
  11917. });
  11918. __getset(0,__proto,'text',function(){
  11919. return this._text;
  11920. },function(value){
  11921. this._text=value;
  11922. if(this._text==null)
  11923. this._text="";
  11924. if(this._bitmapFont==null){
  11925. if(this._widthAutoSize)
  11926. this.textField.width=10000;
  11927. var text2=this._text;
  11928. if (this._templateVars !=null)
  11929. text2=this.parseTemplate(text2);
  11930. if(this._ubbEnabled)
  11931. this.textField.text=ToolSet.removeUBB(ToolSet.encodeHTML(text2));
  11932. else
  11933. this.textField.text=text2;
  11934. }
  11935. else{
  11936. this.textField.text="";
  11937. this.textField["setChanged"]();
  11938. }
  11939. if(this.parent && this.parent._underConstruct)
  11940. this.textField.typeset();
  11941. });
  11942. __getset(0,__proto,'color',function(){
  11943. return this._color;
  11944. },function(value){
  11945. if (this._color !=value){
  11946. this._color=value;
  11947. if (this._gearColor.controller)
  11948. this._gearColor.updateState();
  11949. if(this.grayed)
  11950. this.textField.color="#AAAAAA";
  11951. else
  11952. this.textField.color=this._color;
  11953. }
  11954. });
  11955. __getset(0,__proto,'font',function(){
  11956. return this.textField.font;
  11957. },function(value){
  11958. this._font=value;
  11959. if(ToolSet.startsWith(this._font,"ui://"))
  11960. this._bitmapFont=UIPackage.getItemAssetByURL(this._font);
  11961. else
  11962. this._bitmapFont=null;
  11963. if(this._bitmapFont!=null){
  11964. this.textField["setChanged"]();
  11965. }
  11966. else {
  11967. if(this._font)
  11968. this.textField.font=this._font;
  11969. else
  11970. this.textField.font=UIConfig$1.defaultFont;
  11971. }
  11972. });
  11973. __getset(0,__proto,'leading',function(){
  11974. return this.textField.leading;
  11975. },function(value){
  11976. this.textField.leading=value;
  11977. });
  11978. __getset(0,__proto,'fontSize',function(){
  11979. return this.textField.fontSize;
  11980. },function(value){
  11981. this.textField.fontSize=value;
  11982. });
  11983. __getset(0,__proto,'valign',function(){
  11984. return this.textField.valign;
  11985. },function(value){
  11986. this.textField.valign=value;
  11987. });
  11988. __getset(0,__proto,'italic',function(){
  11989. return this.textField.italic;
  11990. },function(value){
  11991. this.textField.italic=value;
  11992. });
  11993. __getset(0,__proto,'underline',function(){
  11994. return this.textField.underline;
  11995. },function(value){
  11996. this.textField.underline=value;
  11997. });
  11998. __getset(0,__proto,'singleLine',function(){
  11999. return this._singleLine;
  12000. },function(value){
  12001. this._singleLine=value;
  12002. this.textField.wordWrap=!this._widthAutoSize && !this._singleLine;
  12003. });
  12004. __getset(0,__proto,'stroke',function(){
  12005. return this.textField.stroke;
  12006. },function(value){
  12007. this.textField.stroke=value;
  12008. });
  12009. __getset(0,__proto,'strokeColor',function(){
  12010. return this.textField.strokeColor;
  12011. },function(value){
  12012. this.textField.strokeColor=value;
  12013. this.updateGear(4);
  12014. });
  12015. __getset(0,__proto,'ubbEnabled',function(){
  12016. return this._ubbEnabled;
  12017. },function(value){
  12018. this._ubbEnabled=value;
  12019. });
  12020. __getset(0,__proto,'autoSize',function(){
  12021. return this._autoSize;
  12022. },function(value){
  12023. if (this._autoSize !=value){
  12024. this.setAutoSize(value);
  12025. }
  12026. });
  12027. __getset(0,__proto,'textWidth',function(){
  12028. if (this.textField["_isChanged"])
  12029. this.textField.typeset();
  12030. return this._textWidth;
  12031. });
  12032. __getset(0,__proto,'textHeight',function(){
  12033. if (this.textField["_isChanged"])
  12034. this.textField.typeset();
  12035. return this._textHeight;
  12036. });
  12037. GBasicTextField.GUTTER_X=2;
  12038. GBasicTextField.GUTTER_Y=2;
  12039. GBasicTextField.__init$=function(){
  12040. //class LineInfo
  12041. LineInfo=(function(){
  12042. function LineInfo(){
  12043. this.width=0;
  12044. this.height=0;
  12045. this.textHeight=0;
  12046. this.text=null;
  12047. this.y=0;
  12048. }
  12049. __class(LineInfo,'');
  12050. LineInfo.borrow=function(){
  12051. if (LineInfo.pool.length){
  12052. var ret=LineInfo.pool.pop();
  12053. ret.width=0;
  12054. ret.height=0;
  12055. ret.textHeight=0;
  12056. ret.text=null;
  12057. ret.y=0;
  12058. return ret;
  12059. }
  12060. else
  12061. return new LineInfo();
  12062. }
  12063. LineInfo.returns=function(value){
  12064. LineInfo.pool.push(value);
  12065. }
  12066. LineInfo.returnList=function(value){
  12067. var length=value.length;
  12068. for (var i=0;i < length;i++){
  12069. var li=value[i];
  12070. LineInfo.pool.push(li);
  12071. }
  12072. value.length=0;
  12073. }
  12074. LineInfo.pool=[];
  12075. return LineInfo;
  12076. })()
  12077. //class TextExt extends laya.display.Text
  12078. TextExt=(function(_super){
  12079. function TextExt(owner){
  12080. this._owner=null;
  12081. this._lock=false;
  12082. this._sizeDirty=false;
  12083. TextExt.__super.call(this);
  12084. this._owner=owner;
  12085. }
  12086. __class(TextExt,'',_super);
  12087. var __proto=TextExt.prototype;
  12088. __proto.baseTypeset=function(){
  12089. this._lock=true;
  12090. this.typeset();
  12091. this._lock=false;
  12092. }
  12093. __proto.typeset=function(){
  12094. this._sizeDirty=true;
  12095. _super.prototype.typeset.call(this);
  12096. if(!this._lock)
  12097. this._owner.typeset();
  12098. if(this._isChanged){
  12099. Laya.timer.clear(this,this.typeset);
  12100. this._isChanged=false;
  12101. }
  12102. this._sizeDirty=false;
  12103. }
  12104. __proto.setChanged=function(){
  12105. this.isChanged=true;
  12106. }
  12107. __getset(0,__proto,'isChanged',null,function(value){
  12108. if (value && !this._sizeDirty){
  12109. if(this._owner.autoSize!=0 && this._owner.parent){
  12110. this._sizeDirty=true;
  12111. this.event("fui_size_delay_change");
  12112. }
  12113. }
  12114. Laya.superSet(Text,this,'isChanged',value);
  12115. });
  12116. return TextExt;
  12117. })(Text)
  12118. }
  12119. return GBasicTextField;
  12120. })(GTextField)
  12121. //class fairygui.GButton extends fairygui.GComponent
  12122. var GButton=(function(_super){
  12123. function GButton(){
  12124. this._titleObject=null;
  12125. this._iconObject=null;
  12126. this._relatedController=null;
  12127. this._mode=0;
  12128. this._selected=false;
  12129. this._title=null;
  12130. this._selectedTitle=null;
  12131. this._icon=null;
  12132. this._selectedIcon=null;
  12133. this._sound=null;
  12134. this._soundVolumeScale=0;
  12135. this._pageOption=null;
  12136. this._buttonController=null;
  12137. this._changeStateOnClick=false;
  12138. this._linkedPopup=null;
  12139. this._downEffect=0;
  12140. this._downEffectValue=0;
  12141. this._downScaled=false;
  12142. this._down=false;
  12143. this._over=false;
  12144. GButton.__super.call(this);
  12145. this._mode=0;
  12146. this._title="";
  12147. this._icon="";
  12148. this._sound=UIConfig$1.buttonSound;
  12149. this._soundVolumeScale=UIConfig$1.buttonSoundVolumeScale;
  12150. this._pageOption=new PageOption();
  12151. this._changeStateOnClick=true;
  12152. this._downEffectValue=0.8;
  12153. }
  12154. __class(GButton,'fairygui.GButton',_super);
  12155. var __proto=GButton.prototype;
  12156. __proto.getTextField=function(){
  12157. if ((this._titleObject instanceof fairygui.GTextField ))
  12158. return this._titleObject;
  12159. else if ((this._titleObject instanceof fairygui.GLabel ))
  12160. return (this._titleObject).getTextField();
  12161. else if ((this._titleObject instanceof fairygui.GButton ))
  12162. return (this._titleObject).getTextField();
  12163. else
  12164. return null;
  12165. }
  12166. __proto.fireClick=function(downEffect){
  12167. (downEffect===void 0)&& (downEffect=true);
  12168. if (downEffect && this._mode==0){
  12169. this.setState("over");
  12170. Laya.timer.once(100,this,this.setState,["down"],false);
  12171. Laya.timer.once(200,this,this.setState,["up"],false);
  12172. }
  12173. this.__click(Events.createEvent("click",this.displayObject));
  12174. }
  12175. __proto.setState=function(val){
  12176. if (this._buttonController)
  12177. this._buttonController.selectedPage=val;
  12178. if(this._downEffect==1){
  12179. var cnt=this.numChildren;
  12180. if(val=="down" || val=="selectedOver" || val=="selectedDisabled"){
  12181. var r=this._downEffectValue *255;
  12182. var color=Utils.toHexColor((r << 16)+(r << 8)+r);
  12183. for(var i=0;i < cnt;i++){
  12184. var obj=this.getChildAt(i);
  12185. if(((obj instanceof fairygui.GImage ))|| ((obj instanceof fairygui.GLoader ))
  12186. || ((obj instanceof fairygui.GMovieClip )))
  12187. (obj).color=color;
  12188. }
  12189. }
  12190. else {
  12191. for(i=0;i < cnt;i++){
  12192. obj=this.getChildAt(i);
  12193. if(((obj instanceof fairygui.GImage ))|| ((obj instanceof fairygui.GLoader ))
  12194. || ((obj instanceof fairygui.GMovieClip )))
  12195. (obj).color="#FFFFFF";
  12196. }
  12197. }
  12198. }
  12199. else if(this._downEffect==2){
  12200. if(val=="down" || val=="selectedOver" || val=="selectedDisabled"){
  12201. if(!this._downScaled){
  12202. this.setScale(this.scaleX*this._downEffectValue,this.scaleY*this._downEffectValue);
  12203. this._downScaled=true;
  12204. }
  12205. }
  12206. else{
  12207. if(this._downScaled){
  12208. this.setScale(this.scaleX/this._downEffectValue,this.scaleY/this._downEffectValue);
  12209. this._downScaled=false;
  12210. }
  12211. }
  12212. }
  12213. }
  12214. __proto.handleControllerChanged=function(c){
  12215. _super.prototype.handleControllerChanged.call(this,c);
  12216. if (this._relatedController==c)
  12217. this.selected=this._pageOption.id==c.selectedPageId;
  12218. }
  12219. __proto.handleGrayedChanged=function(){
  12220. if(this._buttonController && this._buttonController.hasPage("disabled")){
  12221. if(this.grayed){
  12222. if(this._selected && this._buttonController.hasPage("selectedDisabled"))
  12223. this.setState("selectedDisabled");
  12224. else
  12225. this.setState("disabled");
  12226. }
  12227. else if(this._selected)
  12228. this.setState("down");
  12229. else
  12230. this.setState("up");
  12231. }
  12232. else
  12233. _super.prototype.handleGrayedChanged.call(this);
  12234. }
  12235. __proto.constructExtension=function(buffer){
  12236. buffer.seek(0,6);
  12237. this._mode=buffer.readByte();
  12238. var str=buffer.readS();
  12239. if(str)
  12240. this._sound=str;
  12241. this._soundVolumeScale=buffer.getFloat32();
  12242. this._downEffect=buffer.readByte();
  12243. this._downEffectValue=buffer.getFloat32();
  12244. if(this._downEffect==2)
  12245. this.setPivot(0.5,0.5,this.pivotAsAnchor);
  12246. this._buttonController=this.getController("button");
  12247. this._titleObject=this.getChild("title");
  12248. this._iconObject=this.getChild("icon");
  12249. if (this._titleObject !=null)
  12250. this._title=this._titleObject.text;
  12251. if (this._iconObject !=null)
  12252. this._icon=this._iconObject.icon;
  12253. if (this._mode==0)
  12254. this.setState("up");
  12255. this.on("mouseover",this,this.__rollover);
  12256. this.on("mouseout",this,this.__rollout);
  12257. this.on("mousedown",this,this.__mousedown);
  12258. this.on("click",this,this.__click);
  12259. }
  12260. __proto.setup_afterAdd=function(buffer,beginPos){
  12261. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  12262. if (!buffer.seek(beginPos,6))
  12263. return;
  12264. if (buffer.readByte()!=this.packageItem.objectType)
  12265. return;
  12266. var str;
  12267. var iv=0;
  12268. str=buffer.readS();
  12269. if (str !=null)
  12270. this.title=str;
  12271. str=buffer.readS();
  12272. if (str !=null)
  12273. this.selectedTitle=str;
  12274. str=buffer.readS();
  12275. if (str !=null)
  12276. this.icon=str;
  12277. str=buffer.readS();
  12278. if (str !=null)
  12279. this.selectedIcon=str;
  12280. if (buffer.readBool())
  12281. this.titleColor=buffer.readColorS();
  12282. iv=buffer.getInt32();
  12283. if (iv !=0)
  12284. this.titleFontSize=iv;
  12285. iv=buffer.getInt16();
  12286. if (iv >=0)
  12287. this._relatedController=this.parent.getControllerAt(iv);
  12288. this.pageOption.id=buffer.readS();
  12289. str=buffer.readS();
  12290. if (str !=null)
  12291. this._sound=str;
  12292. if (buffer.readBool())
  12293. this._soundVolumeScale=buffer.getFloat32();
  12294. this.selected=buffer.readBool();
  12295. }
  12296. __proto.__rollover=function(){
  12297. if(!this._buttonController || !this._buttonController.hasPage("over"))
  12298. return;
  12299. this._over=true;
  12300. if (this._down)
  12301. return;
  12302. if(this.grayed && this._buttonController.hasPage("disabled"))
  12303. return;
  12304. this.setState(this._selected ? "selectedOver" :"over");
  12305. }
  12306. __proto.__rollout=function(){
  12307. if(!this._buttonController || !this._buttonController.hasPage("over"))
  12308. return;
  12309. this._over=false;
  12310. if (this._down)
  12311. return;
  12312. if(this.grayed && this._buttonController.hasPage("disabled"))
  12313. return;
  12314. this.setState(this._selected ? "down" :"up");
  12315. }
  12316. __proto.dispose=function(){
  12317. _super.prototype.dispose.call(this);
  12318. }
  12319. __proto.__mousedown=function(evt){
  12320. this._down=true;
  12321. GRoot.inst.checkPopups(evt.target);
  12322. Laya.stage.on("mouseup",this,this.__mouseup);
  12323. if(this._mode==0){
  12324. if(this.grayed && this._buttonController && this._buttonController.hasPage("disabled"))
  12325. this.setState("selectedDisabled");
  12326. else
  12327. this.setState("down");
  12328. }
  12329. if (this._linkedPopup !=null){
  12330. if ((this._linkedPopup instanceof fairygui.Window ))
  12331. (this._linkedPopup).toggleStatus();
  12332. else
  12333. this.root.togglePopup(this._linkedPopup,this);
  12334. }
  12335. }
  12336. __proto.__mouseup=function(){
  12337. if (this._down){
  12338. Laya.stage.off("mouseup",this,this.__mouseup);
  12339. this._down=false;
  12340. if(this._displayObject==null)
  12341. return;
  12342. if(this._mode==0){
  12343. if(this.grayed && this._buttonController && this._buttonController.hasPage("disabled"))
  12344. this.setState("disabled");
  12345. else if(this._over)
  12346. this.setState("over");
  12347. else
  12348. this.setState("up");
  12349. }
  12350. }
  12351. }
  12352. __proto.__click=function(evt){
  12353. if(this._sound&&UIConfig$1.buttonSoundVolumeScale!=0){
  12354. var pi=UIPackage.getItemByURL(this._sound);
  12355. if (pi)
  12356. GRoot.inst.playOneShotSound(pi.file);
  12357. else
  12358. GRoot.inst.playOneShotSound(this._sound);
  12359. }
  12360. if (this._mode==1){
  12361. if(this._changeStateOnClick){
  12362. this.selected=!this._selected;
  12363. Events.dispatch("fui_state_changed",this.displayObject,evt);
  12364. }
  12365. }
  12366. else if (this._mode==2){
  12367. if (this._changeStateOnClick && !this._selected){
  12368. this.selected=true;
  12369. Events.dispatch("fui_state_changed",this.displayObject,evt);
  12370. }
  12371. }
  12372. else{
  12373. if(this._relatedController)
  12374. this._relatedController.selectedPageId=this._pageOption.id;
  12375. }
  12376. }
  12377. __getset(0,__proto,'relatedController',function(){
  12378. return this._relatedController;
  12379. },function(val){
  12380. if (val !=this._relatedController){
  12381. this._relatedController=val;
  12382. this._pageOption.controller=val;
  12383. this._pageOption.clear();
  12384. }
  12385. });
  12386. __getset(0,__proto,'icon',function(){
  12387. return this._icon;
  12388. },function(value){
  12389. this._icon=value;
  12390. value=(this._selected && this._selectedIcon)? this._selectedIcon :this._icon;
  12391. if(this._iconObject!=null)
  12392. this._iconObject.icon=value;
  12393. this.updateGear(7);
  12394. });
  12395. __getset(0,__proto,'titleFontSize',function(){
  12396. var tf=this.getTextField();
  12397. if(tf!=null)
  12398. return tf.fontSize;
  12399. else
  12400. return 0;
  12401. },function(value){
  12402. var tf=this.getTextField();
  12403. if(tf!=null)
  12404. tf.fontSize=value;
  12405. });
  12406. __getset(0,__proto,'selectedIcon',function(){
  12407. return this._selectedIcon;
  12408. },function(value){
  12409. this._selectedIcon=value;
  12410. value=(this._selected && this._selectedIcon)? this._selectedIcon :this._icon;
  12411. if(this._iconObject!=null)
  12412. this._iconObject.icon=value;
  12413. });
  12414. __getset(0,__proto,'title',function(){
  12415. return this._title;
  12416. },function(value){
  12417. this._title=value;
  12418. if (this._titleObject)
  12419. this._titleObject.text=(this._selected && this._selectedTitle)? this._selectedTitle :this._title;
  12420. this.updateGear(6);
  12421. });
  12422. __getset(0,__proto,'text',function(){
  12423. return this.title;
  12424. },function(value){
  12425. this.title=value;
  12426. });
  12427. __getset(0,__proto,'selectedTitle',function(){
  12428. return this._selectedTitle;
  12429. },function(value){
  12430. this._selectedTitle=value;
  12431. if (this._titleObject)
  12432. this._titleObject.text=(this._selected && this._selectedTitle)? this._selectedTitle :this._title;
  12433. });
  12434. __getset(0,__proto,'soundVolumeScale',function(){
  12435. return this._soundVolumeScale;
  12436. },function(value){
  12437. this._soundVolumeScale=value;
  12438. });
  12439. __getset(0,__proto,'sound',function(){
  12440. return this._sound;
  12441. },function(val){
  12442. this._sound=val;
  12443. });
  12444. __getset(0,__proto,'titleColor',function(){
  12445. var tf=this.getTextField();
  12446. if(tf!=null)
  12447. return tf.color;
  12448. else
  12449. return "#000000";
  12450. },function(value){
  12451. var tf=this.getTextField();
  12452. if(tf!=null)
  12453. tf.color=value;
  12454. this.updateGear(4);
  12455. });
  12456. __getset(0,__proto,'selected',function(){
  12457. return this._selected;
  12458. },function(val){
  12459. if (this._mode==0)
  12460. return;
  12461. if (this._selected !=val){
  12462. this._selected=val;
  12463. if(this.grayed && this._buttonController && this._buttonController.hasPage("disabled")){
  12464. if(this._selected)
  12465. this.setState("selectedDisabled");
  12466. else
  12467. this.setState("disabled");
  12468. }
  12469. else {
  12470. if(this._selected)
  12471. this.setState(this._over ? "selectedOver" :"down");
  12472. else
  12473. this.setState(this._over ? "over" :"up");
  12474. }
  12475. if(this._selectedTitle && this._titleObject)
  12476. this._titleObject.text=this._selected ? this._selectedTitle :this._title;
  12477. if(this._selectedIcon){
  12478. var str=this._selected ? this._selectedIcon :this._icon;
  12479. if(this._iconObject!=null)
  12480. this._iconObject.icon=str;
  12481. }
  12482. if(this._relatedController
  12483. && this._parent
  12484. && !this._parent._buildingDisplayList){
  12485. if(this._selected){
  12486. this._relatedController.selectedPageId=this._pageOption.id;
  12487. if(this._relatedController.autoRadioGroupDepth)
  12488. this._parent.adjustRadioGroupDepth(this,this._relatedController);
  12489. }
  12490. else if(this._mode==1 && this._relatedController.selectedPageId==this._pageOption.id)
  12491. this._relatedController.oppositePageId=this._pageOption.id;
  12492. }
  12493. }
  12494. });
  12495. /**
  12496. *@see ButtonMode
  12497. */
  12498. /**
  12499. *@see ButtonMode
  12500. */
  12501. __getset(0,__proto,'mode',function(){
  12502. return this._mode;
  12503. },function(value){
  12504. if (this._mode !=value){
  12505. if (value==0)
  12506. this.selected=false;
  12507. this._mode=value;
  12508. }
  12509. });
  12510. __getset(0,__proto,'pageOption',function(){
  12511. return this._pageOption;
  12512. });
  12513. __getset(0,__proto,'changeStateOnClick',function(){
  12514. return this._changeStateOnClick;
  12515. },function(value){
  12516. this._changeStateOnClick=value;
  12517. });
  12518. __getset(0,__proto,'linkedPopup',function(){
  12519. return this._linkedPopup;
  12520. },function(value){
  12521. this._linkedPopup=value;
  12522. });
  12523. GButton.UP="up";
  12524. GButton.DOWN="down";
  12525. GButton.OVER="over";
  12526. GButton.SELECTED_OVER="selectedOver";
  12527. GButton.DISABLED="disabled";
  12528. GButton.SELECTED_DISABLED="selectedDisabled";
  12529. return GButton;
  12530. })(GComponent)
  12531. //class fairygui.GComboBox extends fairygui.GComponent
  12532. var GComboBox=(function(_super){
  12533. function GComboBox(){
  12534. this.dropdown=null;
  12535. this._titleObject=null;
  12536. this._iconObject=null;
  12537. this._list=null;
  12538. this._items=null;
  12539. this._icons=null;
  12540. this._values=null;
  12541. this._popupDirection=0;
  12542. this._visibleItemCount=0;
  12543. this._itemsUpdated=false;
  12544. this._selectedIndex=0;
  12545. this._buttonController=null;
  12546. this._selectionController=null;
  12547. this._down=false;
  12548. this._over=false;
  12549. GComboBox.__super.call(this);
  12550. this._visibleItemCount=UIConfig$1.defaultComboBoxVisibleItemCount;
  12551. this._itemsUpdated=true;
  12552. this._selectedIndex=-1;
  12553. this._items=[];
  12554. this._values=[];
  12555. }
  12556. __class(GComboBox,'fairygui.GComboBox',_super);
  12557. var __proto=GComboBox.prototype;
  12558. __proto.getTextField=function(){
  12559. if ((this._titleObject instanceof fairygui.GTextField ))
  12560. return this._titleObject;
  12561. else if ((this._titleObject instanceof fairygui.GLabel ))
  12562. return (this._titleObject).getTextField();
  12563. else if ((this._titleObject instanceof fairygui.GButton ))
  12564. return (this._titleObject).getTextField();
  12565. else
  12566. return null;
  12567. }
  12568. __proto.setState=function(val){
  12569. if (this._buttonController)
  12570. this._buttonController.selectedPage=val;
  12571. }
  12572. __proto.handleControllerChanged=function(c){
  12573. _super.prototype.handleControllerChanged.call(this,c);
  12574. if (this._selectionController==c)
  12575. this.selectedIndex=c.selectedIndex;
  12576. }
  12577. __proto.updateSelectionController=function(){
  12578. if (this._selectionController !=null && !this._selectionController.changing
  12579. && this._selectedIndex < this._selectionController.pageCount){
  12580. var c=this._selectionController;
  12581. this._selectionController=null;
  12582. c.selectedIndex=this._selectedIndex;
  12583. this._selectionController=c;
  12584. }
  12585. }
  12586. __proto.dispose=function(){
  12587. if(this.dropdown){
  12588. this.dropdown.dispose();
  12589. this.dropdown=null;
  12590. }
  12591. this._selectionController=null;
  12592. _super.prototype.dispose.call(this);
  12593. }
  12594. __proto.constructExtension=function(buffer){
  12595. var str;
  12596. this._buttonController=this.getController("button");
  12597. this._titleObject=this.getChild("title");
  12598. this._iconObject=this.getChild("icon");
  12599. str=buffer.readS();
  12600. if (str){
  12601. this.dropdown=(UIPackage.createObjectFromURL(str));
  12602. if (!this.dropdown){
  12603. Log.print("下拉框必须为元件");
  12604. return;
  12605. }
  12606. this.dropdown.name="this._dropdownObject";
  12607. this._list=this.dropdown.getChild("list").asList;
  12608. if (this._list==null){
  12609. Log.print(this.resourceURL+": 下拉框的弹出元件里必须包含名为list的列表");
  12610. return;
  12611. }
  12612. this._list.on("fui_click_item",this,this.__clickItem);
  12613. this._list.addRelation(this.dropdown,14);
  12614. this._list.removeRelation(this.dropdown,15);
  12615. this.dropdown.addRelation(this._list,15);
  12616. this.dropdown.removeRelation(this._list,14);
  12617. this.dropdown.displayObject.on("undisplay",this,this.__popupWinClosed);
  12618. }
  12619. this.on("mouseover",this,this.__rollover);
  12620. this.on("mouseout",this,this.__rollout);
  12621. this.on("mousedown",this,this.__mousedown);
  12622. }
  12623. __proto.setup_afterAdd=function(buffer,beginPos){
  12624. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  12625. if (!buffer.seek(beginPos,6))
  12626. return;
  12627. if (buffer.readByte()!=this.packageItem.objectType)
  12628. return;
  12629. var i=0;
  12630. var iv=0;
  12631. var nextPos=0;
  12632. var str;
  12633. var itemCount=buffer.getInt16();
  12634. for (i=0;i < itemCount;i++){
  12635. nextPos=buffer.getInt16();
  12636. nextPos+=buffer.pos;
  12637. this._items[i]=buffer.readS();
  12638. this._values[i]=buffer.readS();
  12639. str=buffer.readS();
  12640. if (str !=null){
  12641. if (this._icons==null)
  12642. this._icons=[];
  12643. this._icons[i]=str;
  12644. }
  12645. buffer.pos=nextPos;
  12646. }
  12647. str=buffer.readS();
  12648. if (str !=null){
  12649. this.text=str;
  12650. this._selectedIndex=this._items.indexOf(str);
  12651. }
  12652. else if (this._items.length > 0){
  12653. this._selectedIndex=0;
  12654. this.text=this._items[0];
  12655. }
  12656. else
  12657. this._selectedIndex=-1;
  12658. str=buffer.readS();
  12659. if (str !=null)
  12660. this.icon=str;
  12661. if (buffer.readBool())
  12662. this.titleColor=buffer.readColorS();
  12663. iv=buffer.getInt32();
  12664. if (iv > 0)
  12665. this._visibleItemCount=iv;
  12666. this._popupDirection=buffer.readByte();
  12667. iv=buffer.getInt16();
  12668. if (iv >=0)
  12669. this._selectionController=this.parent.getControllerAt(iv);
  12670. }
  12671. __proto.showDropdown=function(){
  12672. if (this._itemsUpdated){
  12673. this._itemsUpdated=false;
  12674. this._list.removeChildrenToPool();
  12675. var cnt=this._items.length;
  12676. for (var i=0;i < cnt;i++){
  12677. var item=this._list.addItemFromPool();
  12678. item.name=i < this._values.length ? this._values[i] :"";
  12679. item.text=this._items[i];
  12680. item.icon=(this._icons !=null && i < this._icons.length)? this._icons[i] :null;
  12681. }
  12682. this._list.resizeToFit(this._visibleItemCount);
  12683. }
  12684. this._list.selectedIndex=this._selectedIndex;
  12685. this.dropdown.width=this.width;
  12686. var downward=null;
  12687. if (this._popupDirection==2)
  12688. downward=true;
  12689. else if (this._popupDirection==1)
  12690. downward=false;
  12691. this.root.togglePopup(this.dropdown,this,downward);
  12692. if (this.dropdown.parent)
  12693. this.setState("down");
  12694. }
  12695. __proto.__popupWinClosed=function(){
  12696. if(this._over)
  12697. this.setState("over");
  12698. else
  12699. this.setState("up");
  12700. }
  12701. __proto.__clickItem=function(itemObject,evt){
  12702. Laya.timer.callLater(this,this.__clickItem2,[this._list.getChildIndex(itemObject),evt])
  12703. }
  12704. __proto.__clickItem2=function(index,evt){
  12705. if ((this.dropdown.parent instanceof fairygui.GRoot ))
  12706. (this.dropdown.parent).hidePopup();
  12707. this._selectedIndex=-1;
  12708. this.selectedIndex=index;
  12709. Events.dispatch("fui_state_changed",this.displayObject,evt);
  12710. }
  12711. __proto.__rollover=function(){
  12712. this._over=true;
  12713. if (this._down || this.dropdown && this.dropdown.parent)
  12714. return;
  12715. this.setState("over");
  12716. }
  12717. __proto.__rollout=function(){
  12718. this._over=false;
  12719. if (this._down || this.dropdown && this.dropdown.parent)
  12720. return;
  12721. this.setState("up");
  12722. }
  12723. __proto.__mousedown=function(evt){
  12724. if((evt.target instanceof laya.display.Input ))
  12725. return;
  12726. this._down=true;
  12727. GRoot.inst.checkPopups(evt.target);
  12728. Laya.stage.on("mouseup",this,this.__mouseup);
  12729. if (this.dropdown)
  12730. this.showDropdown();
  12731. }
  12732. __proto.__mouseup=function(){
  12733. if(this._down){
  12734. this._down=false;
  12735. Laya.stage.off("mouseup",this,this.__mouseup);
  12736. if(this.dropdown && !this.dropdown.parent){
  12737. if(this._over)
  12738. this.setState("over");
  12739. else
  12740. this.setState("up");
  12741. }
  12742. }
  12743. }
  12744. __getset(0,__proto,'text',function(){
  12745. if (this._titleObject)
  12746. return this._titleObject.text;
  12747. else
  12748. return null;
  12749. },function(value){
  12750. if (this._titleObject)
  12751. this._titleObject.text=value;
  12752. this.updateGear(6);
  12753. });
  12754. __getset(0,__proto,'titleColor',function(){
  12755. var tf=this.getTextField();
  12756. if(tf!=null)
  12757. return tf.color;
  12758. else
  12759. return "#000000";
  12760. },function(value){
  12761. var tf=this.getTextField();
  12762. if(tf!=null)
  12763. tf.color=value;
  12764. this.updateGear(4);
  12765. });
  12766. __getset(0,__proto,'titleFontSize',function(){
  12767. var tf=this.getTextField();
  12768. if(tf!=null)
  12769. return tf.fontSize;
  12770. else
  12771. return 0;
  12772. },function(value){
  12773. var tf=this.getTextField();
  12774. if(tf!=null)
  12775. tf.fontSize=value;
  12776. });
  12777. __getset(0,__proto,'icon',function(){
  12778. if(this._iconObject)
  12779. return this._iconObject.icon;
  12780. else
  12781. return null;
  12782. },function(value){
  12783. if(this._iconObject)
  12784. this._iconObject.icon=value;
  12785. this.updateGear(7);
  12786. });
  12787. __getset(0,__proto,'icons',function(){
  12788. return this._icons;
  12789. },function(value){
  12790. this._icons=value;
  12791. if (this._icons !=null && this._selectedIndex !=-1 && this._selectedIndex < this._icons.length)
  12792. this.icon=this._icons[this._selectedIndex];
  12793. });
  12794. __getset(0,__proto,'selectionController',function(){
  12795. return this._selectionController;
  12796. },function(value){
  12797. this._selectionController=value;
  12798. });
  12799. __getset(0,__proto,'visibleItemCount',function(){
  12800. return this._visibleItemCount;
  12801. },function(value){
  12802. this._visibleItemCount=value;
  12803. });
  12804. /**
  12805. *@see PopupDirection
  12806. */
  12807. /**
  12808. *@see PopupDirection
  12809. */
  12810. __getset(0,__proto,'popupDirection',function(){
  12811. return this._popupDirection;
  12812. },function(value){
  12813. this._popupDirection=value;
  12814. });
  12815. __getset(0,__proto,'items',function(){
  12816. return this._items;
  12817. },function(value){
  12818. if(!value)
  12819. this._items.length=0;
  12820. else
  12821. this._items=value.concat();
  12822. if(this._items.length>0){
  12823. if(this._selectedIndex>=this._items.length)
  12824. this._selectedIndex=this._items.length-1;
  12825. else if(this._selectedIndex==-1)
  12826. this._selectedIndex=0;
  12827. this.text=this._items[this._selectedIndex];
  12828. if (this._icons !=null && this._selectedIndex < this._icons.length)
  12829. this.icon=this._icons[this._selectedIndex];
  12830. }
  12831. else{
  12832. this.text="";
  12833. if (this._icons !=null)
  12834. this.icon=null;
  12835. this._selectedIndex=-1;
  12836. }
  12837. this._itemsUpdated=true;
  12838. });
  12839. __getset(0,__proto,'values',function(){
  12840. return this._values;
  12841. },function(value){
  12842. if (!value)
  12843. this._values.length=0;
  12844. else
  12845. this._values=value.concat();
  12846. });
  12847. __getset(0,__proto,'selectedIndex',function(){
  12848. return this._selectedIndex;
  12849. },function(val){
  12850. if(this._selectedIndex==val)
  12851. return;
  12852. this._selectedIndex=val;
  12853. if(this._selectedIndex>=0 && this._selectedIndex<this._items.length){
  12854. this.text=this._items[this._selectedIndex];
  12855. if (this._icons !=null && this._selectedIndex < this._icons.length)
  12856. this.icon=this._icons[this._selectedIndex];
  12857. }
  12858. else{
  12859. this.text="";
  12860. if (this._icons !=null)
  12861. this.icon=null;
  12862. }
  12863. this.updateSelectionController();
  12864. });
  12865. __getset(0,__proto,'value',function(){
  12866. return this._values[this._selectedIndex];
  12867. },function(val){
  12868. this.selectedIndex=this._values.indexOf(val);
  12869. });
  12870. return GComboBox;
  12871. })(GComponent)
  12872. //class fairygui.GLabel extends fairygui.GComponent
  12873. var GLabel=(function(_super){
  12874. function GLabel(){
  12875. this._titleObject=null;
  12876. this._iconObject=null;
  12877. GLabel.__super.call(this);
  12878. }
  12879. __class(GLabel,'fairygui.GLabel',_super);
  12880. var __proto=GLabel.prototype;
  12881. Laya.imps(__proto,{"fairygui.gears.IColorGear":true})
  12882. __proto.getTextField=function(){
  12883. if ((this._titleObject instanceof fairygui.GTextField ))
  12884. return this._titleObject;
  12885. else if ((this._titleObject instanceof fairygui.GLabel ))
  12886. return (this._titleObject).getTextField();
  12887. else if ((this._titleObject instanceof fairygui.GButton ))
  12888. return (this._titleObject).getTextField();
  12889. else
  12890. return null;
  12891. }
  12892. __proto.constructExtension=function(buffer){
  12893. this._titleObject=this.getChild("title");
  12894. this._iconObject=this.getChild("icon");
  12895. }
  12896. __proto.setup_afterAdd=function(buffer,beginPos){
  12897. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  12898. if (!buffer.seek(beginPos,6))
  12899. return;
  12900. if (buffer.readByte()!=this.packageItem.objectType)
  12901. return;
  12902. var str;
  12903. str=buffer.readS();
  12904. if (str !=null)
  12905. this.title=str;
  12906. str=buffer.readS();
  12907. if (str !=null)
  12908. this.icon=str;
  12909. if (buffer.readBool())
  12910. this.titleColor=buffer.readColorS();
  12911. var iv=buffer.getInt32();
  12912. if (iv !=0)
  12913. this.titleFontSize=iv;
  12914. if (buffer.readBool()){
  12915. var input=this.getTextField();
  12916. if (input !=null){
  12917. str=buffer.readS();
  12918. if (str !=null)
  12919. input.promptText=str;
  12920. str=buffer.readS();
  12921. if (str !=null)
  12922. input.restrict=str;
  12923. iv=buffer.getInt32();
  12924. if (iv !=0)
  12925. input.maxLength=iv;
  12926. iv=buffer.getInt32();
  12927. if (iv !=0){
  12928. if(iv==4)
  12929. input.keyboardType="number";
  12930. else if(iv==3)
  12931. input.keyboardType="url";
  12932. }
  12933. if (buffer.readBool())
  12934. input.password=true;
  12935. }
  12936. else
  12937. buffer.skip(13);
  12938. }
  12939. }
  12940. __getset(0,__proto,'color',function(){
  12941. return this.titleColor;
  12942. },function(value){
  12943. this.titleColor=value;
  12944. });
  12945. __getset(0,__proto,'icon',function(){
  12946. if(this._iconObject!=null)
  12947. return this._iconObject.icon;
  12948. else
  12949. return null;
  12950. },function(value){
  12951. if(this._iconObject!=null)
  12952. this._iconObject.icon=value;
  12953. this.updateGear(7);
  12954. });
  12955. __getset(0,__proto,'editable',function(){
  12956. if (this._titleObject && ((this._titleObject instanceof fairygui.GTextInput )))
  12957. return this._titleObject.asTextInput.editable;
  12958. else
  12959. return false;
  12960. },function(val){
  12961. if (this._titleObject)
  12962. this._titleObject.asTextInput.editable=val;
  12963. });
  12964. __getset(0,__proto,'title',function(){
  12965. if (this._titleObject)
  12966. return this._titleObject.text;
  12967. else
  12968. return null;
  12969. },function(value){
  12970. if (this._titleObject)
  12971. this._titleObject.text=value;
  12972. this.updateGear(6);
  12973. });
  12974. __getset(0,__proto,'text',function(){
  12975. return this.title;
  12976. },function(value){
  12977. this.title=value;
  12978. });
  12979. __getset(0,__proto,'titleColor',function(){
  12980. var tf=this.getTextField();
  12981. if(tf!=null)
  12982. return tf.color;
  12983. else
  12984. return "#000000";
  12985. },function(value){
  12986. var tf=this.getTextField();
  12987. if(tf!=null)
  12988. tf.color=value;
  12989. this.updateGear(4);
  12990. });
  12991. __getset(0,__proto,'titleFontSize',function(){
  12992. var tf=this.getTextField();
  12993. if(tf!=null)
  12994. return tf.fontSize;
  12995. else
  12996. return 0;
  12997. },function(value){
  12998. var tf=this.getTextField();
  12999. if(tf!=null)
  13000. tf.fontSize=value;
  13001. });
  13002. return GLabel;
  13003. })(GComponent)
  13004. //class fairygui.GList extends fairygui.GComponent
  13005. var GList=(function(_super){
  13006. var ItemInfo;
  13007. function GList(){
  13008. /**
  13009. *itemRenderer(int index,GObject item);
  13010. */
  13011. this.itemRenderer=null;
  13012. /**
  13013. *itemProvider(index:int):String;
  13014. */
  13015. this.itemProvider=null;
  13016. this.scrollItemToViewOnClick=false;
  13017. this.foldInvisibleItems=false;
  13018. this._layout=0;
  13019. this._lineCount=0;
  13020. this._columnCount=0;
  13021. this._lineGap=0;
  13022. this._columnGap=0;
  13023. this._defaultItem=null;
  13024. this._autoResizeItem=false;
  13025. this._selectionMode=0;
  13026. this._align=null;
  13027. this._verticalAlign=null;
  13028. this._selectionController=null;
  13029. this._lastSelectedIndex=0;
  13030. this._pool=null;
  13031. //Virtual List support
  13032. this._virtual=false;
  13033. this._loop=false;
  13034. this._numItems=0;
  13035. this._realNumItems=0;
  13036. this._firstIndex=0;
  13037. //the top left index
  13038. this._curLineItemCount=0;
  13039. //item count in one line
  13040. this._curLineItemCount2=0;
  13041. //只用在页面模式,表示垂直方向的项目数
  13042. this._itemSize=null;
  13043. this._virtualListChanged=0;
  13044. //1-content changed,2-size changed
  13045. this._virtualItems=null;
  13046. this._eventLocked=false;
  13047. this.itemInfoVer=0;
  13048. GList.__super.call(this);
  13049. this._trackBounds=true;
  13050. this._pool=new GObjectPool();
  13051. this._layout=0;
  13052. this._autoResizeItem=true;
  13053. this._lastSelectedIndex=-1;
  13054. this._selectionMode=0;
  13055. this.opaque=true;
  13056. this.scrollItemToViewOnClick=true;
  13057. this._align="left";
  13058. this._verticalAlign="top";
  13059. this._container=new Sprite();
  13060. this._displayObject.addChild(this._container);
  13061. }
  13062. __class(GList,'fairygui.GList',_super);
  13063. var __proto=GList.prototype;
  13064. __proto.dispose=function(){
  13065. this._pool.clear();
  13066. _super.prototype.dispose.call(this);
  13067. }
  13068. __proto.getFromPool=function(url){
  13069. if (!url)
  13070. url=this._defaultItem;
  13071. var obj=this._pool.getObject(url);
  13072. if(obj!=null)
  13073. obj.visible=true;
  13074. return obj;
  13075. }
  13076. __proto.returnToPool=function(obj){
  13077. obj.displayObject.cacheAs="none";
  13078. this._pool.returnObject(obj);
  13079. }
  13080. __proto.addChildAt=function(child,index){
  13081. (index===void 0)&& (index=0);
  13082. _super.prototype.addChildAt.call(this,child,index);
  13083. if ((child instanceof fairygui.GButton )){
  13084. var button=(child);
  13085. button.selected=false;
  13086. button.changeStateOnClick=false;
  13087. }
  13088. child.on("click",this,this.__clickItem);
  13089. return child;
  13090. }
  13091. __proto.addItem=function(url){
  13092. if (!url)
  13093. url=this._defaultItem;
  13094. return this.addChild(UIPackage.createObjectFromURL(url));
  13095. }
  13096. __proto.addItemFromPool=function(url){
  13097. return this.addChild(this.getFromPool(url));
  13098. }
  13099. __proto.removeChildAt=function(index,dispose){
  13100. (dispose===void 0)&& (dispose=false);
  13101. var child=_super.prototype.removeChildAt.call(this,index,dispose);
  13102. child.off("click",this,this.__clickItem);
  13103. return child;
  13104. }
  13105. __proto.removeChildToPoolAt=function(index){
  13106. (index===void 0)&& (index=0);
  13107. var child=_super.prototype.removeChildAt.call(this,index);
  13108. this.returnToPool(child);
  13109. }
  13110. __proto.removeChildToPool=function(child){
  13111. this.removeChild(child);
  13112. this.returnToPool(child);
  13113. }
  13114. __proto.removeChildrenToPool=function(beginIndex,endIndex){
  13115. (beginIndex===void 0)&& (beginIndex=0);
  13116. (endIndex===void 0)&& (endIndex=-1);
  13117. if (endIndex < 0 || endIndex >=this._children.length)
  13118. endIndex=this._children.length-1;
  13119. for (var i=beginIndex;i <=endIndex;++i)
  13120. this.removeChildToPoolAt(beginIndex);
  13121. }
  13122. __proto.getSelection=function(){
  13123. var ret=[];
  13124. var i=0;
  13125. if (this._virtual){
  13126. for (i=0;i < this._realNumItems;i++){
  13127. var ii=this._virtualItems[i];
  13128. if (((ii.obj instanceof fairygui.GButton ))&& (ii.obj).selected
  13129. || ii.obj==null && ii.selected){
  13130. var j=i;
  13131. if (this._loop){
  13132. j=i % this._numItems;
  13133. if (ret.indexOf(j)!=-1)
  13134. continue ;
  13135. }
  13136. ret.push(j);
  13137. }
  13138. }
  13139. }
  13140. else{
  13141. var cnt=this._children.length;
  13142. for (i=0;i < cnt;i++){
  13143. var obj=this._children[i].asButton;
  13144. if (obj !=null && obj.selected)
  13145. ret.push(i);
  13146. }
  13147. }
  13148. return ret;
  13149. }
  13150. __proto.addSelection=function(index,scrollItToView){
  13151. (scrollItToView===void 0)&& (scrollItToView=false);
  13152. if(this._selectionMode==3)
  13153. return;
  13154. this.checkVirtualList();
  13155. if(this._selectionMode==0)
  13156. this.clearSelection();
  13157. if (scrollItToView)
  13158. this.scrollToView(index);
  13159. this._lastSelectedIndex=index;
  13160. var obj=null;
  13161. if (this._virtual){
  13162. var ii=this._virtualItems[index];
  13163. if (ii.obj !=null)
  13164. obj=ii.obj.asButton;
  13165. ii.selected=true;
  13166. }
  13167. else
  13168. obj=this.getChildAt(index).asButton;
  13169. if (obj !=null && !obj.selected){
  13170. obj.selected=true;
  13171. this.updateSelectionController(index);
  13172. }
  13173. }
  13174. __proto.removeSelection=function(index){
  13175. if(this._selectionMode==3)
  13176. return;
  13177. var obj=null;
  13178. if (this._virtual){
  13179. var ii=this._virtualItems[index];
  13180. if (ii.obj !=null)
  13181. obj=ii.obj.asButton;
  13182. ii.selected=false;
  13183. }
  13184. else
  13185. obj=this.getChildAt(index).asButton;
  13186. if (obj !=null)
  13187. obj.selected=false;
  13188. }
  13189. __proto.clearSelection=function(){
  13190. var i=0;
  13191. if (this._virtual){
  13192. for (i=0;i < this._realNumItems;i++){
  13193. var ii=this._virtualItems[i];
  13194. if ((ii.obj instanceof fairygui.GButton ))
  13195. (ii.obj).selected=false;
  13196. ii.selected=false;
  13197. }
  13198. }
  13199. else{
  13200. var cnt=this._children.length;
  13201. for (i=0;i < cnt;i++){
  13202. var obj=this._children[i].asButton;
  13203. if (obj !=null)
  13204. obj.selected=false;
  13205. }
  13206. }
  13207. }
  13208. __proto.clearSelectionExcept=function(g){
  13209. var i=0;
  13210. if (this._virtual){
  13211. for (i=0;i < this._realNumItems;i++){
  13212. var ii=this._virtualItems[i];
  13213. if (ii.obj !=g){
  13214. if (((ii.obj instanceof fairygui.GButton )))
  13215. (ii.obj).selected=false;
  13216. ii.selected=false;
  13217. }
  13218. }
  13219. }
  13220. else{
  13221. var cnt=this._children.length;
  13222. for (i=0;i < cnt;i++){
  13223. var obj=this._children[i].asButton;
  13224. if (obj !=null && obj !=g)
  13225. obj.selected=false;
  13226. }
  13227. }
  13228. }
  13229. __proto.selectAll=function(){
  13230. this.checkVirtualList();
  13231. var last=-1;
  13232. var i=0;
  13233. if (this._virtual){
  13234. for (i=0;i < this._realNumItems;i++){
  13235. var ii=this._virtualItems[i];
  13236. if (((ii.obj instanceof fairygui.GButton ))&& !(ii.obj).selected){
  13237. (ii.obj).selected=true;
  13238. last=i;
  13239. }
  13240. ii.selected=true;
  13241. }
  13242. }
  13243. else{
  13244. var cnt=this._children.length;
  13245. for (i=0;i < cnt;i++){
  13246. var obj=this._children[i].asButton;
  13247. if (obj !=null && !obj.selected){
  13248. obj.selected=true;
  13249. last=i;
  13250. }
  13251. }
  13252. }
  13253. if(last!=-1)
  13254. this.updateSelectionController(last);
  13255. }
  13256. __proto.selectNone=function(){
  13257. this.clearSelection();
  13258. }
  13259. __proto.selectReverse=function(){
  13260. this.checkVirtualList();
  13261. var last=-1;
  13262. var i=0;
  13263. if (this._virtual){
  13264. for (i=0;i < this._realNumItems;i++){
  13265. var ii=this._virtualItems[i];
  13266. if ((ii.obj instanceof fairygui.GButton )){
  13267. (ii.obj).selected=!(ii.obj).selected;
  13268. if ((ii.obj).selected)
  13269. last=i;
  13270. }
  13271. ii.selected=!ii.selected;
  13272. }
  13273. }
  13274. else{
  13275. var cnt=this._children.length;
  13276. for (i=0;i < cnt;i++){
  13277. var obj=this._children[i].asButton;
  13278. if (obj !=null){
  13279. obj.selected=!obj.selected;
  13280. if (obj.selected)
  13281. last=i;
  13282. }
  13283. }
  13284. }
  13285. if(last!=-1)
  13286. this.updateSelectionController(last);
  13287. }
  13288. __proto.handleArrowKey=function(dir){
  13289. (dir===void 0)&& (dir=0);
  13290. var index=this.selectedIndex;
  13291. if (index==-1)
  13292. return;
  13293. switch (dir){
  13294. case 1:
  13295. if (this._layout==0 || this._layout==3){
  13296. index--;
  13297. if (index >=0){
  13298. this.clearSelection();
  13299. this.addSelection(index,true);
  13300. }
  13301. }
  13302. else if (this._layout==2 || this._layout==4){
  13303. var current=this._children[index];
  13304. var k=0;
  13305. for (var i=index-1;i >=0;i--){
  13306. var obj=this._children[i];
  13307. if (obj.y !=current.y){
  13308. current=obj;
  13309. break ;
  13310. }
  13311. k++;
  13312. }
  13313. for (;i >=0;i--){
  13314. obj=this._children[i];
  13315. if (obj.y !=current.y){
  13316. this.clearSelection();
  13317. this.addSelection(i+k+1,true);
  13318. break ;
  13319. }
  13320. }
  13321. }
  13322. break ;
  13323. case 3:
  13324. if (this._layout==1 || this._layout==2 || this._layout==4){
  13325. index++;
  13326. if (index < this._children.length){
  13327. this.clearSelection();
  13328. this.addSelection(index,true);
  13329. }
  13330. }
  13331. else if (this._layout==3){
  13332. current=this._children[index];
  13333. k=0;
  13334. var cnt=this._children.length;
  13335. for (i=index+1;i < cnt;i++){
  13336. obj=this._children[i];
  13337. if (obj.x !=current.x){
  13338. current=obj;
  13339. break ;
  13340. }
  13341. k++;
  13342. }
  13343. for (;i < cnt;i++){
  13344. obj=this._children[i];
  13345. if (obj.x !=current.x){
  13346. this.clearSelection();
  13347. this.addSelection(i-k-1,true);
  13348. break ;
  13349. }
  13350. }
  13351. }
  13352. break ;
  13353. case 5:
  13354. if (this._layout==0 || this._layout==3){
  13355. index++;
  13356. if (index < this._children.length){
  13357. this.clearSelection();
  13358. this.addSelection(index,true);
  13359. }
  13360. }
  13361. else if (this._layout==2 || this._layout==4){
  13362. current=this._children[index];
  13363. k=0;
  13364. cnt=this._children.length;
  13365. for (i=index+1;i < cnt;i++){
  13366. obj=this._children[i];
  13367. if (obj.y !=current.y){
  13368. current=obj;
  13369. break ;
  13370. }
  13371. k++;
  13372. }
  13373. for (;i < cnt;i++){
  13374. obj=this._children[i];
  13375. if (obj.y !=current.y){
  13376. this.clearSelection();
  13377. this.addSelection(i-k-1,true);
  13378. break ;
  13379. }
  13380. }
  13381. }
  13382. break ;
  13383. case 7:
  13384. if (this._layout==1 || this._layout==2 || this._layout==4){
  13385. index--;
  13386. if (index >=0){
  13387. this.clearSelection();
  13388. this.addSelection(index,true);
  13389. }
  13390. }
  13391. else if (this._layout==3){
  13392. current=this._children[index];
  13393. k=0;
  13394. for (i=index-1;i >=0;i--){
  13395. obj=this._children[i];
  13396. if (obj.x !=current.x){
  13397. current=obj;
  13398. break ;
  13399. }
  13400. k++;
  13401. }
  13402. for (;i >=0;i--){
  13403. obj=this._children[i];
  13404. if (obj.x !=current.x){
  13405. this.clearSelection();
  13406. this.addSelection(i+k+1,true);
  13407. break ;
  13408. }
  13409. }
  13410. }
  13411. break ;
  13412. }
  13413. }
  13414. __proto.__clickItem=function(evt){
  13415. if (this._scrollPane !=null && this._scrollPane.isDragged)
  13416. return;
  13417. var item=GObject.cast(evt.currentTarget);
  13418. this.setSelectionOnEvent(item,evt);
  13419. if(this._scrollPane && this.scrollItemToViewOnClick)
  13420. this._scrollPane.scrollToView(item,true);
  13421. this.displayObject.event("fui_click_item",[item,Events.createEvent("fui_click_item",this.displayObject,evt)]);
  13422. }
  13423. __proto.setSelectionOnEvent=function(item,evt){
  13424. if (!((item instanceof fairygui.GButton ))|| this._selectionMode==3)
  13425. return;
  13426. var dontChangeLastIndex=false;
  13427. var button=(item);
  13428. var index=this.childIndexToItemIndex(this.getChildIndex(item));
  13429. if (this._selectionMode==0){
  13430. if (!button.selected){
  13431. this.clearSelectionExcept(button);
  13432. button.selected=true;
  13433. }
  13434. }
  13435. else {
  13436. if (evt.shiftKey){
  13437. if (!button.selected){
  13438. if (this._lastSelectedIndex !=-1){
  13439. var min=Math.min(this._lastSelectedIndex,index);
  13440. var max=Math.max(this._lastSelectedIndex,index);
  13441. max=Math.min(max,this.numItems-1);
  13442. var i=0;
  13443. if (this._virtual){
  13444. for (i=min;i <=max;i++){
  13445. var ii=this._virtualItems[i];
  13446. if ((ii.obj instanceof fairygui.GButton ))
  13447. (ii.obj).selected=true;
  13448. ii.selected=true;
  13449. }
  13450. }
  13451. else{
  13452. for(i=min;i<=max;i++){
  13453. var obj=this.getChildAt(i).asButton;
  13454. if(obj!=null)
  13455. obj.selected=true;
  13456. }
  13457. }
  13458. dontChangeLastIndex=true;
  13459. }
  13460. else {
  13461. button.selected=true;
  13462. }
  13463. }
  13464. }
  13465. else if (evt.ctrlKey || this._selectionMode==2){
  13466. button.selected=!button.selected;
  13467. }
  13468. else {
  13469. if (!button.selected){
  13470. this.clearSelectionExcept(button);
  13471. button.selected=true;
  13472. }
  13473. else
  13474. this.clearSelectionExcept(button);
  13475. }
  13476. }
  13477. if (!dontChangeLastIndex)
  13478. this._lastSelectedIndex=index;
  13479. if(button.selected)
  13480. this.updateSelectionController(index);
  13481. }
  13482. __proto.resizeToFit=function(itemCount,minSize){
  13483. (itemCount===void 0)&& (itemCount=1000000);
  13484. (minSize===void 0)&& (minSize=0);
  13485. this.ensureBoundsCorrect();
  13486. var curCount=this.numItems;
  13487. if (itemCount > curCount)
  13488. itemCount=curCount;
  13489. if(this._virtual){
  13490. var lineCount=Math.ceil(itemCount / this._curLineItemCount);
  13491. if(this._layout==0 || this._layout==2)
  13492. this.viewHeight=lineCount *this._itemSize.y+Math.max(0,lineCount-1)*this._lineGap;
  13493. else
  13494. this.viewWidth=lineCount *this._itemSize.x+Math.max(0,lineCount-1)*this._columnGap;
  13495. }
  13496. else if(itemCount==0){
  13497. if (this._layout==0 || this._layout==2)
  13498. this.viewHeight=minSize;
  13499. else
  13500. this.viewWidth=minSize;
  13501. }
  13502. else {
  13503. var i=itemCount-1;
  13504. var obj=null;
  13505. while (i >=0){
  13506. obj=this.getChildAt(i);
  13507. if (!this.foldInvisibleItems || obj.visible)
  13508. break ;
  13509. i--;
  13510. }
  13511. if (i < 0){
  13512. if (this._layout==0 || this._layout==2)
  13513. this.viewHeight=minSize;
  13514. else
  13515. this.viewWidth=minSize;
  13516. }
  13517. else {
  13518. var size=0;
  13519. if (this._layout==0 || this._layout==2){
  13520. size=obj.y+obj.height;
  13521. if (size < minSize)
  13522. size=minSize;
  13523. this.viewHeight=size;
  13524. }
  13525. else {
  13526. size=obj.x+obj.width;
  13527. if (size < minSize)
  13528. size=minSize;
  13529. this.viewWidth=size;
  13530. }
  13531. }
  13532. }
  13533. }
  13534. __proto.getMaxItemWidth=function(){
  13535. var cnt=this._children.length;
  13536. var max=0;
  13537. for (var i=0;i < cnt;i++){
  13538. var child=this.getChildAt(i);
  13539. if (child.width > max)
  13540. max=child.width;
  13541. }
  13542. return max;
  13543. }
  13544. __proto.handleSizeChanged=function(){
  13545. _super.prototype.handleSizeChanged.call(this);
  13546. this.setBoundsChangedFlag();
  13547. if (this._virtual)
  13548. this.setVirtualListChangedFlag(true);
  13549. }
  13550. __proto.handleControllerChanged=function(c){
  13551. _super.prototype.handleControllerChanged.call(this,c);
  13552. if (this._selectionController==c)
  13553. this.selectedIndex=c.selectedIndex;
  13554. }
  13555. __proto.updateSelectionController=function(index){
  13556. if (this._selectionController !=null && !this._selectionController.changing
  13557. && index < this._selectionController.pageCount){
  13558. var c=this._selectionController;
  13559. this._selectionController=null;
  13560. c.selectedIndex=index;
  13561. this._selectionController=c;
  13562. }
  13563. }
  13564. __proto.getSnappingPosition=function(xValue,yValue,resultPoint){
  13565. if (this._virtual){
  13566. if(!resultPoint)
  13567. resultPoint=new Point();
  13568. var saved=NaN;
  13569. var index=0;
  13570. if (this._layout==0 || this._layout==2){
  13571. saved=yValue;
  13572. fairygui.GList.pos_param=yValue;
  13573. index=this.getIndexOnPos1(false);
  13574. yValue=fairygui.GList.pos_param;
  13575. if (index < this._virtualItems.length && saved-yValue > this._virtualItems[index].height / 2 && index < this._realNumItems)
  13576. yValue+=this._virtualItems[index].height+this._lineGap;
  13577. }
  13578. else if (this._layout==1 || this._layout==3){
  13579. saved=xValue;
  13580. fairygui.GList.pos_param=xValue;
  13581. index=this.getIndexOnPos2(false);
  13582. xValue=fairygui.GList.pos_param;
  13583. if (index < this._virtualItems.length && saved-xValue > this._virtualItems[index].width / 2 && index < this._realNumItems)
  13584. xValue+=this._virtualItems[index].width+this._columnGap;
  13585. }
  13586. else{
  13587. saved=xValue;
  13588. fairygui.GList.pos_param=xValue;
  13589. index=this.getIndexOnPos3(false);
  13590. xValue=fairygui.GList.pos_param;
  13591. if (index < this._virtualItems.length && saved-xValue > this._virtualItems[index].width / 2 && index < this._realNumItems)
  13592. xValue+=this._virtualItems[index].width+this._columnGap;
  13593. }
  13594. resultPoint.x=xValue;
  13595. resultPoint.y=yValue;
  13596. return resultPoint;
  13597. }
  13598. else
  13599. return _super.prototype.getSnappingPosition.call(this,xValue,yValue,resultPoint);
  13600. }
  13601. __proto.scrollToView=function(index,ani,setFirst){
  13602. (ani===void 0)&& (ani=false);
  13603. (setFirst===void 0)&& (setFirst=false);
  13604. if (this._virtual){
  13605. if(this._numItems==0)
  13606. return;
  13607. this.checkVirtualList();
  13608. if (index >=this._virtualItems.length)
  13609. throw new Error("Invalid child index: "+index+">"+this._virtualItems.length);
  13610. if(this._loop)
  13611. index=Math.floor(this._firstIndex/this._numItems)*this._numItems+index;
  13612. var rect;
  13613. var ii=this._virtualItems[index];
  13614. var pos=0;
  13615. var i=0;
  13616. if (this._layout==0 || this._layout==2){
  13617. for (i=this._curLineItemCount-1;i < index;i+=this._curLineItemCount)
  13618. pos+=this._virtualItems[i].height+this._lineGap;
  13619. rect=new Rectangle(0,pos,this._itemSize.x,ii.height);
  13620. }
  13621. else if (this._layout==1 || this._layout==3){
  13622. for (i=this._curLineItemCount-1;i < index;i+=this._curLineItemCount)
  13623. pos+=this._virtualItems[i].width+this._columnGap;
  13624. rect=new Rectangle(pos,0,ii.width,this._itemSize.y);
  13625. }
  13626. else{
  13627. var page=index / (this._curLineItemCount *this._curLineItemCount2);
  13628. rect=new Rectangle(page *this.viewWidth+(index % this._curLineItemCount)*(ii.width+this._columnGap),
  13629. (index / this._curLineItemCount)% this._curLineItemCount2 *(ii.height+this._lineGap),
  13630. ii.width,ii.height);
  13631. }
  13632. setFirst=true;
  13633. if (this._scrollPane !=null)
  13634. this._scrollPane.scrollToView(rect,ani,setFirst);
  13635. }
  13636. else{
  13637. var obj=this.getChildAt(index);
  13638. if (this._scrollPane !=null)
  13639. this._scrollPane.scrollToView(obj,ani,setFirst);
  13640. else if (this.parent !=null && this.parent.scrollPane !=null)
  13641. this.parent.scrollPane.scrollToView(obj,ani,setFirst);
  13642. }
  13643. }
  13644. __proto.getFirstChildInView=function(){
  13645. return this.childIndexToItemIndex(_super.prototype.getFirstChildInView.call(this));
  13646. }
  13647. __proto.childIndexToItemIndex=function(index){
  13648. if (!this._virtual)
  13649. return index;
  13650. if (this._layout==4){
  13651. for (var i=this._firstIndex;i < this._realNumItems;i++){
  13652. if (this._virtualItems[i].obj !=null){
  13653. index--;
  13654. if (index < 0)
  13655. return i;
  13656. }
  13657. }
  13658. return index;
  13659. }
  13660. else{
  13661. index+=this._firstIndex;
  13662. if (this._loop && this._numItems > 0)
  13663. index=index % this._numItems;
  13664. return index;
  13665. }
  13666. }
  13667. __proto.itemIndexToChildIndex=function(index){
  13668. if (!this._virtual)
  13669. return index;
  13670. if (this._layout==4){
  13671. return this.getChildIndex(this._virtualItems[index].obj);
  13672. }
  13673. else{
  13674. if (this._loop && this._numItems > 0){
  13675. var j=this._firstIndex % this._numItems;
  13676. if (index >=j)
  13677. index=index-j;
  13678. else
  13679. index=this._numItems-j+index;
  13680. }
  13681. else
  13682. index-=this._firstIndex;
  13683. return index;
  13684. }
  13685. }
  13686. __proto.setVirtual=function(){
  13687. this._setVirtual(false);
  13688. }
  13689. /**
  13690. *Set the list to be virtual list,and has loop behavior.
  13691. */
  13692. __proto.setVirtualAndLoop=function(){
  13693. this._setVirtual(true);
  13694. }
  13695. __proto._setVirtual=function(loop){
  13696. if(!this._virtual){
  13697. if(this._scrollPane==null)
  13698. throw new Error("Virtual list must be scrollable!");
  13699. if(loop){
  13700. if(this._layout==2 || this._layout==3)
  13701. throw new Error("Loop list is not supported for FlowHorizontal or FlowVertical layout!");
  13702. this._scrollPane.bouncebackEffect=false;
  13703. }
  13704. this._virtual=true;
  13705. this._loop=loop;
  13706. this._virtualItems=[];
  13707. this.removeChildrenToPool();
  13708. if(this._itemSize==null){
  13709. this._itemSize=new Point();
  13710. var obj=this.getFromPool(null);
  13711. if (obj==null){
  13712. throw new Error("Virtual List must have a default list item resource.");
  13713. }
  13714. else{
  13715. this._itemSize.x=obj.width;
  13716. this._itemSize.y=obj.height;
  13717. }
  13718. this.returnToPool(obj);
  13719. }
  13720. if(this._layout==0 || this._layout==2){
  13721. this._scrollPane.scrollStep=this._itemSize.y;
  13722. if(this._loop)
  13723. this._scrollPane._loop=2;
  13724. }
  13725. else{
  13726. this._scrollPane.scrollStep=this._itemSize.x;
  13727. if(this._loop)
  13728. this._scrollPane._loop=1;
  13729. }
  13730. this.on("fui_scroll",this,this.__scrolled);
  13731. this.setVirtualListChangedFlag(true);
  13732. }
  13733. }
  13734. __proto.refreshVirtualList=function(){
  13735. this.setVirtualListChangedFlag(false);
  13736. }
  13737. __proto.checkVirtualList=function(){
  13738. if(this._virtualListChanged!=0){
  13739. this._refreshVirtualList();
  13740. Laya.timer.clear(this,this._refreshVirtualList);
  13741. }
  13742. }
  13743. __proto.setVirtualListChangedFlag=function(layoutChanged){
  13744. (layoutChanged===void 0)&& (layoutChanged=false);
  13745. if(layoutChanged)
  13746. this._virtualListChanged=2;
  13747. else if(this._virtualListChanged==0)
  13748. this._virtualListChanged=1;
  13749. Laya.timer.callLater(this,this._refreshVirtualList);
  13750. }
  13751. __proto._refreshVirtualList=function(){
  13752. var layoutChanged=this._virtualListChanged==2;
  13753. this._virtualListChanged=0;
  13754. this._eventLocked=true;
  13755. if (layoutChanged){
  13756. if (this._layout==0 || this._layout==1)
  13757. this._curLineItemCount=1;
  13758. else if (this._layout==2){
  13759. if (this._columnCount > 0)
  13760. this._curLineItemCount=this._columnCount;
  13761. else{
  13762. this._curLineItemCount=Math.floor((this._scrollPane.viewWidth+this._columnGap)/ (this._itemSize.x+this._columnGap));
  13763. if (this._curLineItemCount <=0)
  13764. this._curLineItemCount=1;
  13765. }
  13766. }
  13767. else if (this._layout==3){
  13768. if (this._lineCount > 0)
  13769. this._curLineItemCount=this._lineCount;
  13770. else{
  13771. this._curLineItemCount=Math.floor((this._scrollPane.viewHeight+this._lineGap)/ (this._itemSize.y+this._lineGap));
  13772. if (this._curLineItemCount <=0)
  13773. this._curLineItemCount=1;
  13774. }
  13775. }
  13776. else{
  13777. if (this._columnCount > 0)
  13778. this._curLineItemCount=this._columnCount;
  13779. else{
  13780. this._curLineItemCount=Math.floor((this._scrollPane.viewWidth+this._columnGap)/ (this._itemSize.x+this._columnGap));
  13781. if (this._curLineItemCount <=0)
  13782. this._curLineItemCount=1;
  13783. }
  13784. if (this._lineCount > 0)
  13785. this._curLineItemCount2=this._lineCount;
  13786. else{
  13787. this._curLineItemCount2=Math.floor((this._scrollPane.viewHeight+this._lineGap)/ (this._itemSize.y+this._lineGap));
  13788. if (this._curLineItemCount2 <=0)
  13789. this._curLineItemCount2=1;
  13790. }
  13791. }
  13792. };
  13793. var ch=0,cw=0;
  13794. if (this._realNumItems > 0){
  13795. var i=0;
  13796. var len=Math.ceil(this._realNumItems / this._curLineItemCount)*this._curLineItemCount;
  13797. var len2=Math.min(this._curLineItemCount,this._realNumItems);
  13798. if (this._layout==0 || this._layout==2){
  13799. for (i=0;i < len;i+=this._curLineItemCount)
  13800. ch+=this._virtualItems[i].height+this._lineGap;
  13801. if (ch > 0)
  13802. ch-=this._lineGap;
  13803. if (this._autoResizeItem)
  13804. cw=this._scrollPane.viewWidth;
  13805. else{
  13806. for (i=0;i < len2;i++)
  13807. cw+=this._virtualItems[i].width+this._columnGap;
  13808. if (cw > 0)
  13809. cw-=this._columnGap;
  13810. }
  13811. }
  13812. else if (this._layout==1 || this._layout==3){
  13813. for (i=0;i < len;i+=this._curLineItemCount)
  13814. cw+=this._virtualItems[i].width+this._columnGap;
  13815. if (cw > 0)
  13816. cw-=this._columnGap;
  13817. if (this._autoResizeItem)
  13818. ch=this._scrollPane.viewHeight;
  13819. else{
  13820. for (i=0;i < len2;i++)
  13821. ch+=this._virtualItems[i].height+this._lineGap;
  13822. if (ch > 0)
  13823. ch-=this._lineGap;
  13824. }
  13825. }
  13826. else{
  13827. var pageCount=Math.ceil(len / (this._curLineItemCount *this._curLineItemCount2));
  13828. cw=pageCount *this.viewWidth;
  13829. ch=this.viewHeight;
  13830. }
  13831. }
  13832. this.handleAlign(cw,ch);
  13833. this._scrollPane.setContentSize(cw,ch);
  13834. this._eventLocked=false;
  13835. this.handleScroll(true);
  13836. }
  13837. __proto.__scrolled=function(evt){
  13838. this.handleScroll(false);
  13839. }
  13840. __proto.getIndexOnPos1=function(forceUpdate){
  13841. if (this._realNumItems < this._curLineItemCount){
  13842. GList.pos_param=0;
  13843. return 0;
  13844. };
  13845. var i=0;
  13846. var pos2=NaN;
  13847. var pos3=NaN;
  13848. if (this.numChildren > 0 && !forceUpdate){
  13849. pos2=this.getChildAt(0).y;
  13850. if (pos2 > GList.pos_param){
  13851. for (i=this._firstIndex-this._curLineItemCount;i >=0;i-=this._curLineItemCount){
  13852. pos2-=(this._virtualItems[i].height+this._lineGap);
  13853. if (pos2 <=GList.pos_param){
  13854. GList.pos_param=pos2;
  13855. return i;
  13856. }
  13857. }
  13858. GList.pos_param=0;
  13859. return 0;
  13860. }
  13861. else{
  13862. for (i=this._firstIndex;i < this._realNumItems;i+=this._curLineItemCount){
  13863. pos3=pos2+this._virtualItems[i].height+this._lineGap;
  13864. if (pos3 > GList.pos_param){
  13865. GList.pos_param=pos2;
  13866. return i;
  13867. }
  13868. pos2=pos3;
  13869. }
  13870. GList.pos_param=pos2;
  13871. return this._realNumItems-this._curLineItemCount;
  13872. }
  13873. }
  13874. else{
  13875. pos2=0;
  13876. for (i=0;i < this._realNumItems;i+=this._curLineItemCount){
  13877. pos3=pos2+this._virtualItems[i].height+this._lineGap;
  13878. if (pos3 > GList.pos_param){
  13879. GList.pos_param=pos2;
  13880. return i;
  13881. }
  13882. pos2=pos3;
  13883. }
  13884. GList.pos_param=pos2;
  13885. return this._realNumItems-this._curLineItemCount;
  13886. }
  13887. }
  13888. __proto.getIndexOnPos2=function(forceUpdate){
  13889. if (this._realNumItems < this._curLineItemCount){
  13890. GList.pos_param=0;
  13891. return 0;
  13892. };
  13893. var i=0;
  13894. var pos2=NaN;
  13895. var pos3=NaN;
  13896. if (this.numChildren > 0 && !forceUpdate){
  13897. pos2=this.getChildAt(0).x;
  13898. if (pos2 > GList.pos_param){
  13899. for (i=this._firstIndex-this._curLineItemCount;i >=0;i-=this._curLineItemCount){
  13900. pos2-=(this._virtualItems[i].width+this._columnGap);
  13901. if (pos2 <=GList.pos_param){
  13902. GList.pos_param=pos2;
  13903. return i;
  13904. }
  13905. }
  13906. GList.pos_param=0;
  13907. return 0;
  13908. }
  13909. else{
  13910. for (i=this._firstIndex;i < this._realNumItems;i+=this._curLineItemCount){
  13911. pos3=pos2+this._virtualItems[i].width+this._columnGap;
  13912. if (pos3 > GList.pos_param){
  13913. GList.pos_param=pos2;
  13914. return i;
  13915. }
  13916. pos2=pos3;
  13917. }
  13918. GList.pos_param=pos2;
  13919. return this._realNumItems-this._curLineItemCount;
  13920. }
  13921. }
  13922. else{
  13923. pos2=0;
  13924. for (i=0;i < this._realNumItems;i+=this._curLineItemCount){
  13925. pos3=pos2+this._virtualItems[i].width+this._columnGap;
  13926. if (pos3 > GList.pos_param){
  13927. GList.pos_param=pos2;
  13928. return i;
  13929. }
  13930. pos2=pos3;
  13931. }
  13932. GList.pos_param=pos2;
  13933. return this._realNumItems-this._curLineItemCount;
  13934. }
  13935. }
  13936. __proto.getIndexOnPos3=function(forceUpdate){
  13937. if (this._realNumItems < this._curLineItemCount){
  13938. GList.pos_param=0;
  13939. return 0;
  13940. };
  13941. var viewWidth=this.viewWidth;
  13942. var page=Math.floor(GList.pos_param / viewWidth);
  13943. var startIndex=page *(this._curLineItemCount *this._curLineItemCount2);
  13944. var pos2=page *viewWidth;
  13945. var i=0;
  13946. var pos3=NaN;
  13947. for (i=0;i < this._curLineItemCount;i++){
  13948. pos3=pos2+this._virtualItems[startIndex+i].width+this._columnGap;
  13949. if (pos3 > GList.pos_param){
  13950. GList.pos_param=pos2;
  13951. return startIndex+i;
  13952. }
  13953. pos2=pos3;
  13954. }
  13955. GList.pos_param=pos2;
  13956. return startIndex+this._curLineItemCount-1;
  13957. }
  13958. __proto.handleScroll=function(forceUpdate){
  13959. if (this._eventLocked)
  13960. return;
  13961. if (this._layout==0 || this._layout==2){
  13962. var enterCounter=0;
  13963. while(this.handleScroll1(forceUpdate)){
  13964. enterCounter++;
  13965. forceUpdate=false;
  13966. if(enterCounter>20){
  13967. console.log("FairyGUI: list will never be filled as the item renderer function always returns a different size.");
  13968. break ;
  13969. }
  13970. }
  13971. this.handleArchOrder1();
  13972. }
  13973. else if (this._layout==1 || this._layout==3){
  13974. enterCounter=0;
  13975. while(this.handleScroll2(forceUpdate)){
  13976. enterCounter++;
  13977. forceUpdate=false;
  13978. if(enterCounter>20){
  13979. console.log("FairyGUI: list will never be filled as the item renderer function always returns a different size.");
  13980. break ;
  13981. }
  13982. }
  13983. this.handleArchOrder2();
  13984. }
  13985. else{
  13986. this.handleScroll3(forceUpdate);
  13987. }
  13988. this._boundsChanged=false;
  13989. }
  13990. __proto.handleScroll1=function(forceUpdate){
  13991. var pos=this._scrollPane.scrollingPosY;
  13992. var max=pos+this._scrollPane.viewHeight;
  13993. var end=max==this._scrollPane.contentHeight;
  13994. fairygui.GList.pos_param=pos;
  13995. var newFirstIndex=this.getIndexOnPos1(forceUpdate);
  13996. pos=fairygui.GList.pos_param;
  13997. if (newFirstIndex==this._firstIndex && !forceUpdate)
  13998. return false;
  13999. var oldFirstIndex=this._firstIndex;
  14000. this._firstIndex=newFirstIndex;
  14001. var curIndex=newFirstIndex;
  14002. var forward=oldFirstIndex > newFirstIndex;
  14003. var childCount=this.numChildren;
  14004. var lastIndex=oldFirstIndex+childCount-1;
  14005. var reuseIndex=forward ? lastIndex :oldFirstIndex;
  14006. var curX=0,curY=pos;
  14007. var needRender=false;
  14008. var deltaSize=0;
  14009. var firstItemDeltaSize=0;
  14010. var url=this.defaultItem;
  14011. var ii,ii2;
  14012. var i=0,j=0;
  14013. var partSize=(this._scrollPane.viewWidth-this._columnGap *(this._curLineItemCount-1))/ this._curLineItemCount;
  14014. this.itemInfoVer++;
  14015. while (curIndex < this._realNumItems && (end || curY < max)){
  14016. ii=this._virtualItems[curIndex];
  14017. if (ii.obj==null || forceUpdate){
  14018. if (this.itemProvider !=null){
  14019. url=this.itemProvider.runWith(curIndex % this._numItems);
  14020. if (url==null)
  14021. url=this._defaultItem;
  14022. url=UIPackage.normalizeURL(url);
  14023. }
  14024. if (ii.obj !=null && ii.obj.resourceURL !=url){
  14025. if ((ii.obj instanceof fairygui.GButton ))
  14026. ii.selected=(ii.obj).selected;
  14027. this.removeChildToPool(ii.obj);
  14028. ii.obj=null;
  14029. }
  14030. }
  14031. if (ii.obj==null){
  14032. if (forward){
  14033. for (j=reuseIndex;j >=oldFirstIndex;j--){
  14034. ii2=this._virtualItems[j];
  14035. if (ii2.obj !=null && ii2.updateFlag !=this.itemInfoVer && ii2.obj.resourceURL==url){
  14036. if ((ii2.obj instanceof fairygui.GButton ))
  14037. ii2.selected=(ii2.obj).selected;
  14038. ii.obj=ii2.obj;
  14039. ii2.obj=null;
  14040. if (j==reuseIndex)
  14041. reuseIndex--;
  14042. break ;
  14043. }
  14044. }
  14045. }
  14046. else{
  14047. for (j=reuseIndex;j <=lastIndex;j++){
  14048. ii2=this._virtualItems[j];
  14049. if (ii2.obj !=null && ii2.updateFlag !=this.itemInfoVer && ii2.obj.resourceURL==url){
  14050. if ((ii2.obj instanceof fairygui.GButton ))
  14051. ii2.selected=(ii2.obj).selected;
  14052. ii.obj=ii2.obj;
  14053. ii2.obj=null;
  14054. if (j==reuseIndex)
  14055. reuseIndex++;
  14056. break ;
  14057. }
  14058. }
  14059. }
  14060. if (ii.obj !=null){
  14061. this.setChildIndex(ii.obj,forward ? curIndex-newFirstIndex :this.numChildren);
  14062. }
  14063. else{
  14064. ii.obj=this._pool.getObject(url);
  14065. if (forward)
  14066. this.addChildAt(ii.obj,curIndex-newFirstIndex);
  14067. else
  14068. this.addChild(ii.obj);
  14069. }
  14070. if ((ii.obj instanceof fairygui.GButton ))
  14071. (ii.obj).selected=ii.selected;
  14072. needRender=true;
  14073. }
  14074. else
  14075. needRender=forceUpdate;
  14076. if (needRender){
  14077. if (this._autoResizeItem && (this._layout==0 || this._columnCount > 0))
  14078. ii.obj.setSize(partSize,ii.obj.height,true);
  14079. this.itemRenderer.runWith([curIndex % this._numItems,ii.obj]);
  14080. if (curIndex % this._curLineItemCount==0){
  14081. deltaSize+=Math.ceil(ii.obj.height)-ii.height;
  14082. if (curIndex==newFirstIndex && oldFirstIndex > newFirstIndex){
  14083. firstItemDeltaSize=Math.ceil(ii.obj.height)-ii.height;
  14084. }
  14085. }
  14086. ii.width=Math.ceil(ii.obj.width);
  14087. ii.height=Math.ceil(ii.obj.height);
  14088. }
  14089. ii.updateFlag=this.itemInfoVer;
  14090. ii.obj.setXY(curX,curY);
  14091. if (curIndex==newFirstIndex)
  14092. max+=ii.height;
  14093. curX+=ii.width+this._columnGap;
  14094. if (curIndex % this._curLineItemCount==this._curLineItemCount-1){
  14095. curX=0;
  14096. curY+=ii.height+this._lineGap;
  14097. }
  14098. curIndex++;
  14099. }
  14100. for (i=0;i < childCount;i++){
  14101. ii=this._virtualItems[oldFirstIndex+i];
  14102. if (ii.updateFlag !=this.itemInfoVer && ii.obj !=null){
  14103. if ((ii.obj instanceof fairygui.GButton ))
  14104. ii.selected=(ii.obj).selected;
  14105. this.removeChildToPool(ii.obj);
  14106. ii.obj=null;
  14107. }
  14108. }
  14109. childCount=this._children.length;
  14110. for (i=0;i < childCount;i++){
  14111. var obj=this._virtualItems[newFirstIndex+i].obj;
  14112. if (this._children[i] !=obj)
  14113. this.setChildIndex(obj,i);
  14114. }
  14115. if (deltaSize !=0 || firstItemDeltaSize !=0)
  14116. this._scrollPane.changeContentSizeOnScrolling(0,deltaSize,0,firstItemDeltaSize);
  14117. if (curIndex > 0 && this.numChildren > 0 && this._container.y < 0 && this.getChildAt(0).y >-this._container.y)
  14118. return true;
  14119. else
  14120. return false;
  14121. }
  14122. __proto.handleScroll2=function(forceUpdate){
  14123. var pos=this._scrollPane.scrollingPosX;
  14124. var max=pos+this._scrollPane.viewWidth;
  14125. var end=pos==this._scrollPane.contentWidth;
  14126. fairygui.GList.pos_param=pos;
  14127. var newFirstIndex=this.getIndexOnPos2(forceUpdate);
  14128. pos=fairygui.GList.pos_param;
  14129. if (newFirstIndex==this._firstIndex && !forceUpdate)
  14130. return false;
  14131. var oldFirstIndex=this._firstIndex;
  14132. this._firstIndex=newFirstIndex;
  14133. var curIndex=newFirstIndex;
  14134. var forward=oldFirstIndex > newFirstIndex;
  14135. var childCount=this.numChildren;
  14136. var lastIndex=oldFirstIndex+childCount-1;
  14137. var reuseIndex=forward ? lastIndex :oldFirstIndex;
  14138. var curX=pos,curY=0;
  14139. var needRender=false;
  14140. var deltaSize=0;
  14141. var firstItemDeltaSize=0;
  14142. var url=this.defaultItem;
  14143. var ii,ii2;
  14144. var i=0,j=0;
  14145. var partSize=(this._scrollPane.viewHeight-this._lineGap *(this._curLineItemCount-1))/ this._curLineItemCount;
  14146. this.itemInfoVer++;
  14147. while (curIndex < this._realNumItems && (end || curX < max)){
  14148. ii=this._virtualItems[curIndex];
  14149. if (ii.obj==null || forceUpdate){
  14150. if (this.itemProvider !=null){
  14151. url=this.itemProvider.runWith(curIndex % this._numItems);
  14152. if (url==null)
  14153. url=this._defaultItem;
  14154. url=UIPackage.normalizeURL(url);
  14155. }
  14156. if (ii.obj !=null && ii.obj.resourceURL !=url){
  14157. if ((ii.obj instanceof fairygui.GButton ))
  14158. ii.selected=(ii.obj).selected;
  14159. this.removeChildToPool(ii.obj);
  14160. ii.obj=null;
  14161. }
  14162. }
  14163. if (ii.obj==null){
  14164. if (forward){
  14165. for (j=reuseIndex;j >=oldFirstIndex;j--){
  14166. ii2=this._virtualItems[j];
  14167. if (ii2.obj !=null && ii2.updateFlag !=this.itemInfoVer && ii2.obj.resourceURL==url){
  14168. if ((ii2.obj instanceof fairygui.GButton ))
  14169. ii2.selected=(ii2.obj).selected;
  14170. ii.obj=ii2.obj;
  14171. ii2.obj=null;
  14172. if (j==reuseIndex)
  14173. reuseIndex--;
  14174. break ;
  14175. }
  14176. }
  14177. }
  14178. else{
  14179. for (j=reuseIndex;j <=lastIndex;j++){
  14180. ii2=this._virtualItems[j];
  14181. if (ii2.obj !=null && ii2.updateFlag !=this.itemInfoVer && ii2.obj.resourceURL==url){
  14182. if ((ii2.obj instanceof fairygui.GButton ))
  14183. ii2.selected=(ii2.obj).selected;
  14184. ii.obj=ii2.obj;
  14185. ii2.obj=null;
  14186. if (j==reuseIndex)
  14187. reuseIndex++;
  14188. break ;
  14189. }
  14190. }
  14191. }
  14192. if (ii.obj !=null){
  14193. this.setChildIndex(ii.obj,forward ? curIndex-newFirstIndex :this.numChildren);
  14194. }
  14195. else{
  14196. ii.obj=this._pool.getObject(url);
  14197. if (forward)
  14198. this.addChildAt(ii.obj,curIndex-newFirstIndex);
  14199. else
  14200. this.addChild(ii.obj);
  14201. }
  14202. if ((ii.obj instanceof fairygui.GButton ))
  14203. (ii.obj).selected=ii.selected;
  14204. needRender=true;
  14205. }
  14206. else
  14207. needRender=forceUpdate;
  14208. if (needRender){
  14209. if (this._autoResizeItem && (this._layout==1 || this._lineCount > 0))
  14210. ii.obj.setSize(ii.obj.width,partSize,true);
  14211. this.itemRenderer.runWith([curIndex % this._numItems,ii.obj]);
  14212. if (curIndex % this._curLineItemCount==0){
  14213. deltaSize+=Math.ceil(ii.obj.width)-ii.width;
  14214. if (curIndex==newFirstIndex && oldFirstIndex > newFirstIndex){
  14215. firstItemDeltaSize=Math.ceil(ii.obj.width)-ii.width;
  14216. }
  14217. }
  14218. ii.width=Math.ceil(ii.obj.width);
  14219. ii.height=Math.ceil(ii.obj.height);
  14220. }
  14221. ii.updateFlag=this.itemInfoVer;
  14222. ii.obj.setXY(curX,curY);
  14223. if (curIndex==newFirstIndex)
  14224. max+=ii.width;
  14225. curY+=ii.height+this._lineGap;
  14226. if (curIndex % this._curLineItemCount==this._curLineItemCount-1){
  14227. curY=0;
  14228. curX+=ii.width+this._columnGap;
  14229. }
  14230. curIndex++;
  14231. }
  14232. for (i=0;i < childCount;i++){
  14233. ii=this._virtualItems[oldFirstIndex+i];
  14234. if (ii.updateFlag !=this.itemInfoVer && ii.obj !=null){
  14235. if ((ii.obj instanceof fairygui.GButton ))
  14236. ii.selected=(ii.obj).selected;
  14237. this.removeChildToPool(ii.obj);
  14238. ii.obj=null;
  14239. }
  14240. }
  14241. childCount=this._children.length;
  14242. for (i=0;i < childCount;i++){
  14243. var obj=this._virtualItems[newFirstIndex+i].obj;
  14244. if (this._children[i] !=obj)
  14245. this.setChildIndex(obj,i);
  14246. }
  14247. if (deltaSize !=0 || firstItemDeltaSize !=0)
  14248. this._scrollPane.changeContentSizeOnScrolling(deltaSize,0,firstItemDeltaSize,0);
  14249. if (curIndex > 0 && this.numChildren > 0 && this._container.x < 0 && this.getChildAt(0).x >-this._container.x)
  14250. return true;
  14251. else
  14252. return false;
  14253. }
  14254. __proto.handleScroll3=function(forceUpdate){
  14255. var pos=this._scrollPane.scrollingPosX;
  14256. fairygui.GList.pos_param=pos;
  14257. var newFirstIndex=this.getIndexOnPos3(forceUpdate);
  14258. pos=fairygui.GList.pos_param;
  14259. if (newFirstIndex==this._firstIndex && !forceUpdate)
  14260. return;
  14261. var oldFirstIndex=this._firstIndex;
  14262. this._firstIndex=newFirstIndex;
  14263. var reuseIndex=oldFirstIndex;
  14264. var virtualItemCount=this._virtualItems.length;
  14265. var pageSize=this._curLineItemCount *this._curLineItemCount2;
  14266. var startCol=newFirstIndex % this._curLineItemCount;
  14267. var viewWidth=this.viewWidth;
  14268. var page=Math.floor(newFirstIndex / pageSize);
  14269. var startIndex=page *pageSize;
  14270. var lastIndex=startIndex+pageSize *2;
  14271. var needRender=false;
  14272. var i=0;
  14273. var ii,ii2;
  14274. var col=0;
  14275. var url=this._defaultItem;
  14276. var partWidth=(this._scrollPane.viewWidth-this._columnGap *(this._curLineItemCount-1))/ this._curLineItemCount;
  14277. var partHeight=(this._scrollPane.viewHeight-this._lineGap *(this._curLineItemCount2-1))/ this._curLineItemCount2;
  14278. this.itemInfoVer++;
  14279. for (i=startIndex;i < lastIndex;i++){
  14280. if (i >=this._realNumItems)
  14281. continue ;
  14282. col=i % this._curLineItemCount;
  14283. if (i-startIndex < pageSize){
  14284. if (col < startCol)
  14285. continue ;
  14286. }
  14287. else{
  14288. if (col > startCol)
  14289. continue ;
  14290. }
  14291. ii=this._virtualItems[i];
  14292. ii.updateFlag=this.itemInfoVer;
  14293. };
  14294. var lastObj=null;
  14295. var insertIndex=0;
  14296. for (i=startIndex;i < lastIndex;i++){
  14297. if (i >=this._realNumItems)
  14298. continue ;
  14299. ii=this._virtualItems[i];
  14300. if (ii.updateFlag !=this.itemInfoVer)
  14301. continue ;
  14302. if (ii.obj==null){
  14303. while (reuseIndex < virtualItemCount){
  14304. ii2=this._virtualItems[reuseIndex];
  14305. if (ii2.obj !=null && ii2.updateFlag !=this.itemInfoVer){
  14306. if ((ii2.obj instanceof fairygui.GButton ))
  14307. ii2.selected=(ii2.obj).selected;
  14308. ii.obj=ii2.obj;
  14309. ii2.obj=null;
  14310. break ;
  14311. }
  14312. reuseIndex++;
  14313. }
  14314. if (insertIndex==-1)
  14315. insertIndex=this.getChildIndex(lastObj)+1;
  14316. if (ii.obj==null){
  14317. if (this.itemProvider !=null){
  14318. url=this.itemProvider.runWith(i % this._numItems);
  14319. if (url==null)
  14320. url=this._defaultItem;
  14321. url=UIPackage.normalizeURL(url);
  14322. }
  14323. ii.obj=this._pool.getObject(url);
  14324. this.addChildAt(ii.obj,insertIndex);
  14325. }
  14326. else{
  14327. insertIndex=this.setChildIndexBefore(ii.obj,insertIndex);
  14328. }
  14329. insertIndex++;
  14330. if ((ii.obj instanceof fairygui.GButton ))
  14331. (ii.obj).selected=ii.selected;
  14332. needRender=true;
  14333. }
  14334. else{
  14335. needRender=forceUpdate;
  14336. insertIndex=-1;
  14337. lastObj=ii.obj;
  14338. }
  14339. if (needRender){
  14340. if (this._autoResizeItem){
  14341. if (this._curLineItemCount==this._columnCount && this._curLineItemCount2==this._lineCount)
  14342. ii.obj.setSize(partWidth,partHeight,true);
  14343. else if (this._curLineItemCount==this._columnCount)
  14344. ii.obj.setSize(partWidth,ii.obj.height,true);
  14345. else if (this._curLineItemCount2==this._lineCount)
  14346. ii.obj.setSize(ii.obj.width,partHeight,true);
  14347. }
  14348. this.itemRenderer.runWith([i % this._numItems,ii.obj]);
  14349. ii.width=Math.ceil(ii.obj.width);
  14350. ii.height=Math.ceil(ii.obj.height);
  14351. }
  14352. };
  14353. var borderX=(startIndex / pageSize)*viewWidth;
  14354. var xx=borderX;
  14355. var yy=0;
  14356. var lineHeight=0;
  14357. for (i=startIndex;i < lastIndex;i++){
  14358. if (i >=this._realNumItems)
  14359. continue ;
  14360. ii=this._virtualItems[i];
  14361. if (ii.updateFlag==this.itemInfoVer)
  14362. ii.obj.setXY(xx,yy);
  14363. if (ii.height > lineHeight)
  14364. lineHeight=ii.height;
  14365. if (i % this._curLineItemCount==this._curLineItemCount-1){
  14366. xx=borderX;
  14367. yy+=lineHeight+this._lineGap;
  14368. lineHeight=0;
  14369. if (i==startIndex+pageSize-1){
  14370. borderX+=viewWidth;
  14371. xx=borderX;
  14372. yy=0;
  14373. }
  14374. }
  14375. else
  14376. xx+=ii.width+this._columnGap;
  14377. }
  14378. for (i=reuseIndex;i < virtualItemCount;i++){
  14379. ii=this._virtualItems[i];
  14380. if (ii.updateFlag !=this.itemInfoVer && ii.obj !=null){
  14381. if ((ii.obj instanceof fairygui.GButton ))
  14382. ii.selected=(ii.obj).selected;
  14383. this.removeChildToPool(ii.obj);
  14384. ii.obj=null;
  14385. }
  14386. }
  14387. }
  14388. __proto.handleArchOrder1=function(){
  14389. if (this.childrenRenderOrder==2){
  14390. var mid=this._scrollPane.posY+this.viewHeight / 2;
  14391. var minDist=Number.POSITIVE_INFINITY;
  14392. var dist=0;
  14393. var apexIndex=0;
  14394. var cnt=this.numChildren;
  14395. for (var i=0;i < cnt;i++){
  14396. var obj=this.getChildAt(i);
  14397. if (!this.foldInvisibleItems || obj.visible){
  14398. dist=Math.abs(mid-obj.y-obj.height / 2);
  14399. if (dist < minDist){
  14400. minDist=dist;
  14401. apexIndex=i;
  14402. }
  14403. }
  14404. }
  14405. this.apexIndex=apexIndex;
  14406. }
  14407. }
  14408. __proto.handleArchOrder2=function(){
  14409. if (this.childrenRenderOrder==2){
  14410. var mid=this._scrollPane.posX+this.viewWidth / 2;
  14411. var minDist=Number.POSITIVE_INFINITY;
  14412. var dist=0;
  14413. var apexIndex=0;
  14414. var cnt=this.numChildren;
  14415. for (var i=0;i < cnt;i++){
  14416. var obj=this.getChildAt(i);
  14417. if (!this.foldInvisibleItems || obj.visible){
  14418. dist=Math.abs(mid-obj.x-obj.width / 2);
  14419. if (dist < minDist){
  14420. minDist=dist;
  14421. apexIndex=i;
  14422. }
  14423. }
  14424. }
  14425. this.apexIndex=apexIndex;
  14426. }
  14427. }
  14428. __proto.handleAlign=function(contentWidth,contentHeight){
  14429. var newOffsetX=0;
  14430. var newOffsetY=0;
  14431. if (contentHeight < this.viewHeight){
  14432. if (this._verticalAlign=="middle")
  14433. newOffsetY=Math.floor((this.viewHeight-contentHeight)/ 2);
  14434. else if (this._verticalAlign=="bottom")
  14435. newOffsetY=this.viewHeight-contentHeight;
  14436. }
  14437. if (contentWidth < this.viewWidth){
  14438. if (this._align=="center")
  14439. newOffsetX=Math.floor((this.viewWidth-contentWidth)/ 2);
  14440. else if (this._align=="right")
  14441. newOffsetX=this.viewWidth-contentWidth;
  14442. }
  14443. if (newOffsetX!=this._alignOffset.x || newOffsetY!=this._alignOffset.y){
  14444. this._alignOffset.setTo(newOffsetX,newOffsetY);
  14445. if (this._scrollPane !=null)
  14446. this._scrollPane.adjustMaskContainer();
  14447. else
  14448. this._container.pos(this._margin.left+this._alignOffset.x,this._margin.top+this._alignOffset.y);
  14449. }
  14450. }
  14451. __proto.updateBounds=function(){
  14452. if(this._virtual)
  14453. return;
  14454. var i=0;
  14455. var child;
  14456. var curX=0;
  14457. var curY=0;
  14458. var maxWidth=0;
  14459. var maxHeight=0;
  14460. var cw=0,ch=0;
  14461. var j=0;
  14462. var page=0;
  14463. var k=0;
  14464. var cnt=this._children.length;
  14465. var viewWidth=this.viewWidth;
  14466. var viewHeight=this.viewHeight;
  14467. var lineSize=0;
  14468. var lineStart=0;
  14469. var ratio=NaN;
  14470. if(this._layout==0){
  14471. for(i=0;i<cnt;i++){
  14472. child=this.getChildAt(i);
  14473. if (this.foldInvisibleItems && !child.visible)
  14474. continue ;
  14475. if (curY !=0)
  14476. curY+=this._lineGap;
  14477. child.y=curY;
  14478. if (this._autoResizeItem)
  14479. child.setSize(viewWidth,child.height,true);
  14480. curY+=Math.ceil(child.height);
  14481. if(child.width>maxWidth)
  14482. maxWidth=child.width;
  14483. }
  14484. cw=Math.ceil(maxWidth);
  14485. ch=curY;
  14486. }
  14487. else if(this._layout==1){
  14488. for(i=0;i<cnt;i++){
  14489. child=this.getChildAt(i);
  14490. if (this.foldInvisibleItems && !child.visible)
  14491. continue ;
  14492. if(curX!=0)
  14493. curX+=this._columnGap;
  14494. child.x=curX;
  14495. if (this._autoResizeItem)
  14496. child.setSize(child.width,viewHeight,true);
  14497. curX+=Math.ceil(child.width);
  14498. if(child.height>maxHeight)
  14499. maxHeight=child.height;
  14500. }
  14501. cw=curX;
  14502. ch=Math.ceil(maxHeight);
  14503. }
  14504. else if(this._layout==2){
  14505. if (this._autoResizeItem && this._columnCount > 0){
  14506. for (i=0;i < cnt;i++){
  14507. child=this.getChildAt(i);
  14508. if (this.foldInvisibleItems && !child.visible)
  14509. continue ;
  14510. lineSize+=child.sourceWidth;
  14511. j++;
  14512. if (j==this._columnCount || i==cnt-1){
  14513. ratio=(viewWidth-lineSize-(j-1)*this._columnGap)/ lineSize;
  14514. curX=0;
  14515. for (j=lineStart;j <=i;j++){
  14516. child=this.getChildAt(j);
  14517. if (this.foldInvisibleItems && !child.visible)
  14518. continue ;
  14519. child.setXY(curX,curY);
  14520. if (j < i){
  14521. child.setSize(child.sourceWidth+Math.round(child.sourceWidth *ratio),child.height,true);
  14522. curX+=Math.ceil(child.width)+this._columnGap;
  14523. }
  14524. else{
  14525. child.setSize(viewWidth-curX,child.height,true);
  14526. }
  14527. if (child.height > maxHeight)
  14528. maxHeight=child.height;
  14529. }
  14530. curY+=Math.ceil(maxHeight)+this._lineGap;
  14531. maxHeight=0;
  14532. j=0;
  14533. lineStart=i+1;
  14534. lineSize=0;
  14535. }
  14536. }
  14537. ch=curY+Math.ceil(maxHeight);
  14538. cw=viewWidth;
  14539. }
  14540. else{
  14541. for(i=0;i<cnt;i++){
  14542. child=this.getChildAt(i);
  14543. if (this.foldInvisibleItems && !child.visible)
  14544. continue ;
  14545. if(curX!=0)
  14546. curX+=this._columnGap;
  14547. if (this._columnCount !=0 && j >=this._columnCount
  14548. || this._columnCount==0 && curX+child.width > viewWidth && maxHeight !=0){
  14549. curX=0;
  14550. curY+=Math.ceil(maxHeight)+this._lineGap;
  14551. maxHeight=0;
  14552. j=0;
  14553. }
  14554. child.setXY(curX,curY);
  14555. curX+=Math.ceil(child.width);
  14556. if (curX > maxWidth)
  14557. maxWidth=curX;
  14558. if (child.height > maxHeight)
  14559. maxHeight=child.height;
  14560. j++;
  14561. }
  14562. ch=curY+Math.ceil(maxHeight);
  14563. cw=Math.ceil(maxWidth);
  14564. }
  14565. }
  14566. else if (this._layout==3){
  14567. if (this._autoResizeItem && this._lineCount > 0){
  14568. for (i=0;i < cnt;i++){
  14569. child=this.getChildAt(i);
  14570. if (this.foldInvisibleItems && !child.visible)
  14571. continue ;
  14572. lineSize+=child.sourceHeight;
  14573. j++;
  14574. if (j==this._lineCount || i==cnt-1){
  14575. ratio=(viewHeight-lineSize-(j-1)*this._lineGap)/ lineSize;
  14576. curY=0;
  14577. for (j=lineStart;j <=i;j++){
  14578. child=this.getChildAt(j);
  14579. if (this.foldInvisibleItems && !child.visible)
  14580. continue ;
  14581. child.setXY(curX,curY);
  14582. if (j < i){
  14583. child.setSize(child.width,child.sourceHeight+Math.round(child.sourceHeight *ratio),true);
  14584. curY+=Math.ceil(child.height)+this._lineGap;
  14585. }
  14586. else{
  14587. child.setSize(child.width,viewHeight-curY,true);
  14588. }
  14589. if (child.width > maxWidth)
  14590. maxWidth=child.width;
  14591. }
  14592. curX+=Math.ceil(maxWidth)+this._columnGap;
  14593. maxWidth=0;
  14594. j=0;
  14595. lineStart=i+1;
  14596. lineSize=0;
  14597. }
  14598. }
  14599. cw=curX+Math.ceil(maxWidth);
  14600. ch=viewHeight;
  14601. }
  14602. else{
  14603. for(i=0;i<cnt;i++){
  14604. child=this.getChildAt(i);
  14605. if (this.foldInvisibleItems && !child.visible)
  14606. continue ;
  14607. if(curY!=0)
  14608. curY+=this._lineGap;
  14609. if (this._lineCount !=0 && j >=this._lineCount
  14610. || this._lineCount==0 && curY+child.height > viewHeight && maxWidth !=0){
  14611. curY=0;
  14612. curX+=Math.ceil(maxWidth)+this._columnGap;
  14613. maxWidth=0;
  14614. j=0;
  14615. }
  14616. child.setXY(curX,curY);
  14617. curY+=Math.ceil(child.height);
  14618. if (curY > maxHeight)
  14619. maxHeight=curY;
  14620. if (child.width > maxWidth)
  14621. maxWidth=child.width;
  14622. j++;
  14623. }
  14624. cw=curX+Math.ceil(maxWidth);
  14625. ch=Math.ceil(maxHeight);
  14626. }
  14627. }
  14628. else{
  14629. var eachHeight=0;
  14630. if(this._autoResizeItem && this._lineCount>0)
  14631. eachHeight=Math.floor((viewHeight-(this._lineCount-1)*this._lineGap)/this._lineCount);
  14632. if (this._autoResizeItem && this._columnCount > 0){
  14633. for (i=0;i < cnt;i++){
  14634. child=this.getChildAt(i);
  14635. if (this.foldInvisibleItems && !child.visible)
  14636. continue ;
  14637. if (j==0 && (this._lineCount !=0 && k >=this._lineCount
  14638. || this._lineCount==0 && curY+child.height > viewHeight)){
  14639. page++;
  14640. curY=0;
  14641. k=0;
  14642. }
  14643. lineSize+=child.sourceWidth;
  14644. j++;
  14645. if (j==this._columnCount || i==cnt-1){
  14646. ratio=(viewWidth-lineSize-(j-1)*this._columnGap)/ lineSize;
  14647. curX=0;
  14648. for (j=lineStart;j <=i;j++){
  14649. child=this.getChildAt(j);
  14650. if (this.foldInvisibleItems && !child.visible)
  14651. continue ;
  14652. child.setXY(page *viewWidth+curX,curY);
  14653. if (j < i){
  14654. child.setSize(child.sourceWidth+Math.round(child.sourceWidth *ratio),
  14655. this._lineCount>0?eachHeight:child.height,true);
  14656. curX+=Math.ceil(child.width)+this._columnGap;
  14657. }
  14658. else{
  14659. child.setSize(viewWidth-curX,this._lineCount>0?eachHeight:child.height,true);
  14660. }
  14661. if (child.height > maxHeight)
  14662. maxHeight=child.height;
  14663. }
  14664. curY+=Math.ceil(maxHeight)+this._lineGap;
  14665. maxHeight=0;
  14666. j=0;
  14667. lineStart=i+1;
  14668. lineSize=0;
  14669. k++;
  14670. }
  14671. }
  14672. }
  14673. else{
  14674. for (i=0;i < cnt;i++){
  14675. child=this.getChildAt(i);
  14676. if (this.foldInvisibleItems && !child.visible)
  14677. continue ;
  14678. if (curX !=0)
  14679. curX+=this._columnGap;
  14680. if (this._autoResizeItem && this._lineCount > 0)
  14681. child.setSize(child.width,eachHeight,true);
  14682. if (this._columnCount !=0 && j >=this._columnCount
  14683. || this._columnCount==0 && curX+child.width > viewWidth && maxHeight !=0){
  14684. curX=0;
  14685. curY+=Math.ceil(maxHeight)+this._lineGap;
  14686. maxHeight=0;
  14687. j=0;
  14688. k++;
  14689. if (this._lineCount !=0 && k >=this._lineCount
  14690. || this._lineCount==0 && curY+child.height > viewHeight && maxWidth !=0){
  14691. page++;
  14692. curY=0;
  14693. k=0;
  14694. }
  14695. }
  14696. child.setXY(page *viewWidth+curX,curY);
  14697. curX+=Math.ceil(child.width);
  14698. if (curX > maxWidth)
  14699. maxWidth=curX;
  14700. if (child.height > maxHeight)
  14701. maxHeight=child.height;
  14702. j++;
  14703. }
  14704. }
  14705. ch=page > 0 ? viewHeight :curY+Math.ceil(maxHeight);
  14706. cw=(page+1)*viewWidth;
  14707. }
  14708. this.handleAlign(cw,ch);
  14709. this.setBounds(0,0,cw,ch);
  14710. }
  14711. __proto.setup_beforeAdd=function(buffer,beginPos){
  14712. fairygui.GObject.prototype.setup_beforeAdd.call(this,buffer,beginPos);
  14713. buffer.seek(beginPos,5);
  14714. var i=0;
  14715. var j=0;
  14716. var cnt=0;
  14717. var i1=0;
  14718. var i2=0;
  14719. var nextPos=0;
  14720. var str;
  14721. this._layout=buffer.readByte();
  14722. this._selectionMode=buffer.readByte();
  14723. i1=buffer.readByte();
  14724. this._align=i1==0?"left":(i1==1?"center":"right");
  14725. i1=buffer.readByte();
  14726. this._verticalAlign=i1==0?"top":(i1==1?"middle":"bottom");
  14727. this._lineGap=buffer.getInt16();
  14728. this._columnGap=buffer.getInt16();
  14729. this._lineCount=buffer.getInt16();
  14730. this._columnCount=buffer.getInt16();
  14731. this._autoResizeItem=buffer.readBool();
  14732. this._childrenRenderOrder=buffer.readByte();
  14733. this._apexIndex=buffer.getInt16();
  14734. if (buffer.readBool()){
  14735. this._margin.top=buffer.getInt32();
  14736. this._margin.bottom=buffer.getInt32();
  14737. this._margin.left=buffer.getInt32();
  14738. this._margin.right=buffer.getInt32();
  14739. };
  14740. var overflow=buffer.readByte();
  14741. if (overflow==2){
  14742. var savedPos=buffer.pos;
  14743. buffer.seek(beginPos,7);
  14744. this.setupScroll(buffer);
  14745. buffer.pos=savedPos;
  14746. }
  14747. else
  14748. this.setupOverflow(overflow);
  14749. if (buffer.readBool())
  14750. buffer.skip(8);
  14751. buffer.seek(beginPos,8);
  14752. this._defaultItem=buffer.readS();
  14753. var itemCount=buffer.getInt16();
  14754. for (i=0;i < itemCount;i++){
  14755. nextPos=buffer.getInt16();
  14756. nextPos+=buffer.pos;
  14757. str=buffer.readS();
  14758. if (str==null){
  14759. str=this.defaultItem;
  14760. if (!str){
  14761. buffer.pos=nextPos;
  14762. continue ;
  14763. }
  14764. };
  14765. var obj=this.getFromPool(str);
  14766. if (obj !=null){
  14767. this.addChild(obj);
  14768. str=buffer.readS();
  14769. if (str !=null)
  14770. obj.text=str;
  14771. str=buffer.readS();
  14772. if (str !=null && ((obj instanceof fairygui.GButton )))
  14773. (obj).selectedTitle=str;
  14774. str=buffer.readS();
  14775. if (str !=null)
  14776. obj.icon=str;
  14777. str=buffer.readS();
  14778. if (str !=null && ((obj instanceof fairygui.GButton )))
  14779. (obj).selectedIcon=str;
  14780. str=buffer.readS();
  14781. if (str !=null)
  14782. obj.name=str;
  14783. if ((obj instanceof fairygui.GComponent )){
  14784. cnt=buffer.getInt16();
  14785. for (j=0;j < cnt;j++){
  14786. var cc=(obj).getController(buffer.readS());
  14787. str=buffer.readS();
  14788. if (cc !=null)
  14789. cc.selectedPageId=str;
  14790. }
  14791. }
  14792. }
  14793. buffer.pos=nextPos;
  14794. }
  14795. }
  14796. __proto.setup_afterAdd=function(buffer,beginPos){
  14797. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  14798. buffer.seek(beginPos,6);
  14799. var i=buffer.getInt16();
  14800. if (i !=-1)
  14801. this._selectionController=this.parent.getControllerAt(i);
  14802. }
  14803. /**
  14804. *@see ListLayoutType
  14805. */
  14806. /**
  14807. *@see ListLayoutType
  14808. */
  14809. __getset(0,__proto,'layout',function(){
  14810. return this._layout;
  14811. },function(value){
  14812. if (this._layout !=value){
  14813. this._layout=value;
  14814. this.setBoundsChangedFlag();
  14815. if(this._virtual)
  14816. this.setVirtualListChangedFlag(true);
  14817. }
  14818. });
  14819. __getset(0,__proto,'align',function(){
  14820. return this._align;
  14821. },function(value){
  14822. if(this._align!=value){
  14823. this._align=value;
  14824. this.setBoundsChangedFlag();
  14825. if (this._virtual)
  14826. this.setVirtualListChangedFlag(true);
  14827. }
  14828. });
  14829. __getset(0,__proto,'lineCount',function(){
  14830. return this._lineCount;
  14831. },function(value){
  14832. if (this._lineCount !=value){
  14833. this._lineCount=value;
  14834. if (this._layout==3 || this._layout==4){
  14835. this.setBoundsChangedFlag();
  14836. if (this._virtual)
  14837. this.setVirtualListChangedFlag(true);
  14838. }
  14839. }
  14840. });
  14841. __getset(0,__proto,'columnCount',function(){
  14842. return this._columnCount;
  14843. },function(value){
  14844. if (this._columnCount !=value){
  14845. this._columnCount=value;
  14846. if (this._layout==2 || this._layout==4){
  14847. this.setBoundsChangedFlag();
  14848. if (this._virtual)
  14849. this.setVirtualListChangedFlag(true);
  14850. }
  14851. }
  14852. });
  14853. __getset(0,__proto,'lineGap',function(){
  14854. return this._lineGap;
  14855. },function(value){
  14856. if (this._lineGap !=value){
  14857. this._lineGap=value;
  14858. this.setBoundsChangedFlag();
  14859. if(this._virtual)
  14860. this.setVirtualListChangedFlag(true);
  14861. }
  14862. });
  14863. __getset(0,__proto,'columnGap',function(){
  14864. return this._columnGap;
  14865. },function(value){
  14866. if(this._columnGap !=value){
  14867. this._columnGap=value;
  14868. this.setBoundsChangedFlag();
  14869. if (this._virtual)
  14870. this.setVirtualListChangedFlag(true);
  14871. }
  14872. });
  14873. __getset(0,__proto,'verticalAlign',function(){
  14874. return this._verticalAlign;
  14875. },function(value){
  14876. if(this._verticalAlign!=value){
  14877. this._verticalAlign=value;
  14878. this.setBoundsChangedFlag();
  14879. if (this._virtual)
  14880. this.setVirtualListChangedFlag(true);
  14881. }
  14882. });
  14883. __getset(0,__proto,'virtualItemSize',function(){
  14884. return this._itemSize;
  14885. },function(value){
  14886. if(this._virtual){
  14887. if(this._itemSize==null)
  14888. this._itemSize=new Point();
  14889. this._itemSize.setTo(value.x,value.y);
  14890. this.setVirtualListChangedFlag(true);
  14891. }
  14892. });
  14893. __getset(0,__proto,'defaultItem',function(){
  14894. return this._defaultItem;
  14895. },function(val){
  14896. this._defaultItem=val;
  14897. });
  14898. __getset(0,__proto,'autoResizeItem',function(){
  14899. return this._autoResizeItem;
  14900. },function(value){
  14901. if(this._autoResizeItem !=value){
  14902. this._autoResizeItem=value;
  14903. this.setBoundsChangedFlag();
  14904. if (this._virtual)
  14905. this.setVirtualListChangedFlag(true);
  14906. }
  14907. });
  14908. /**
  14909. *@see ListSelectionMode
  14910. */
  14911. /**
  14912. *@see ListSelectionMode
  14913. */
  14914. __getset(0,__proto,'selectionMode',function(){
  14915. return this._selectionMode;
  14916. },function(value){
  14917. this._selectionMode=value;
  14918. });
  14919. __getset(0,__proto,'selectionController',function(){
  14920. return this._selectionController;
  14921. },function(value){
  14922. this._selectionController=value;
  14923. });
  14924. __getset(0,__proto,'itemPool',function(){
  14925. return this._pool;
  14926. });
  14927. __getset(0,__proto,'selectedIndex',function(){
  14928. var i=0;
  14929. if (this._virtual){
  14930. for (i=0;i < this._realNumItems;i++){
  14931. var ii=this._virtualItems[i];
  14932. if (((ii.obj instanceof fairygui.GButton ))&& (ii.obj).selected
  14933. || ii.obj==null && ii.selected){
  14934. if (this._loop)
  14935. return i % this._numItems;
  14936. else
  14937. return i;
  14938. }
  14939. }
  14940. }
  14941. else{
  14942. var cnt=this._children.length;
  14943. for (i=0;i < cnt;i++){
  14944. var obj=this._children[i].asButton;
  14945. if (obj !=null && obj.selected)
  14946. return i;
  14947. }
  14948. }
  14949. return-1;
  14950. },function(value){
  14951. if (value >=0 && value < this.numItems){
  14952. if(this._selectionMode!=0)
  14953. this.clearSelection();
  14954. this.addSelection(value);
  14955. }
  14956. else
  14957. this.clearSelection();
  14958. });
  14959. /**
  14960. *Set the list item count.
  14961. *If the list is not virtual,specified Number of items will be created.
  14962. *If the list is virtual,only items in view will be created.
  14963. */
  14964. __getset(0,__proto,'numItems',function(){
  14965. if(this._virtual)
  14966. return this._numItems;
  14967. else
  14968. return this._children.length;
  14969. },function(value){
  14970. var i=0;
  14971. if (this._virtual){
  14972. if (this.itemRenderer==null)
  14973. throw new Error("Set itemRenderer first!");
  14974. this._numItems=value;
  14975. if (this._loop)
  14976. this._realNumItems=this._numItems *6;
  14977. else
  14978. this._realNumItems=this._numItems;
  14979. var oldCount=this._virtualItems.length;
  14980. if (this._realNumItems > oldCount){
  14981. for (i=oldCount;i < this._realNumItems;i++){
  14982. var ii=new ItemInfo();
  14983. ii.width=this._itemSize.x;
  14984. ii.height=this._itemSize.y;
  14985. this._virtualItems.push(ii);
  14986. }
  14987. }
  14988. else{
  14989. for (i=this._realNumItems;i < oldCount;i++)
  14990. this._virtualItems[i].selected=false;
  14991. }
  14992. if (this._virtualListChanged !=0)
  14993. Laya.timer.clear(this,this._refreshVirtualList);
  14994. this._refreshVirtualList();
  14995. }
  14996. else{
  14997. var cnt=this._children.length;
  14998. if (value > cnt){
  14999. for (i=cnt;i < value;i++){
  15000. if (this.itemProvider==null)
  15001. this.addItemFromPool();
  15002. else
  15003. this.addItemFromPool(this.itemProvider.runWith(i));
  15004. }
  15005. }
  15006. else{
  15007. this.removeChildrenToPool(value,cnt);
  15008. }
  15009. if (this.itemRenderer !=null){
  15010. for (i=0;i < value;i++)
  15011. this.itemRenderer.runWith([i,this.getChildAt(i)]);
  15012. }
  15013. }
  15014. });
  15015. GList.pos_param=NaN;
  15016. GList.__init$=function(){
  15017. //class ItemInfo
  15018. ItemInfo=(function(){
  15019. function ItemInfo(){
  15020. this.width=0;
  15021. this.height=0;
  15022. this.obj=null;
  15023. this.updateFlag=0;
  15024. this.selected=false;
  15025. }
  15026. __class(ItemInfo,'');
  15027. return ItemInfo;
  15028. })()
  15029. }
  15030. return GList;
  15031. })(GComponent)
  15032. //class fairygui.GRichTextField extends fairygui.GTextField
  15033. var GRichTextField=(function(_super){
  15034. function GRichTextField(){
  15035. this.div=null;
  15036. this._ubbEnabled=false;
  15037. this._color=null;
  15038. GRichTextField.__super.call(this);
  15039. this._text="";
  15040. }
  15041. __class(GRichTextField,'fairygui.GRichTextField',_super);
  15042. var __proto=GRichTextField.prototype;
  15043. __proto.createDisplayObject=function(){
  15044. this._displayObject=this.div=new HTMLDivElement();
  15045. this._displayObject.mouseEnabled=true;
  15046. this._displayObject["$owner"]=this;
  15047. this.font = UIConfig$1.defaultFont;
  15048. }
  15049. __proto.handleSizeChanged=function(){
  15050. this.div.size(this.width,this.height);
  15051. }
  15052. __getset(0,__proto,'bold',function(){
  15053. return this.div.style.bold;
  15054. },function(value){
  15055. this.div.style.bold=value;
  15056. });
  15057. __getset(0,__proto,'align',function(){
  15058. return this.div.style.align;
  15059. },function(value){
  15060. this.div.style.align=value;
  15061. });
  15062. __getset(0,__proto,'text',function(){
  15063. return this._text;
  15064. },function(value){
  15065. this._text=value;
  15066. var text2=this._text;
  15067. if (this._templateVars !=null)
  15068. text2=this.parseTemplate(text2);
  15069. if(this._ubbEnabled)
  15070. this.div.innerHTML=ToolSet.parseUBB(text2);
  15071. else
  15072. this.div.innerHTML=text2;
  15073. });
  15074. __getset(0,__proto,'color',function(){
  15075. return this._color;
  15076. },function(value){
  15077. if (this._color !=value){
  15078. this._color=value;
  15079. this.div.style.color=value;
  15080. if (this._gearColor.controller)
  15081. this._gearColor.updateState();
  15082. }
  15083. });
  15084. __getset(0,__proto,'font',function(){
  15085. return this.div.style.font;
  15086. },function(value){
  15087. if(value)
  15088. this.div.style.font=value;
  15089. else
  15090. this.div.style.font=UIConfig$1.defaultFont;
  15091. });
  15092. __getset(0,__proto,'leading',function(){
  15093. return this.div.style.leading;
  15094. },function(value){
  15095. this.div.style.leading=value;
  15096. });
  15097. __getset(0,__proto,'fontSize',function(){
  15098. return this.div.style.fontSize;
  15099. },function(value){
  15100. this.div.style.fontSize=value;
  15101. });
  15102. __getset(0,__proto,'valign',function(){
  15103. return this.div.style.valign;
  15104. },function(value){
  15105. this.div.style.valign=value;
  15106. });
  15107. __getset(0,__proto,'italic',function(){
  15108. return this.div.style.italic;
  15109. },function(value){
  15110. this.div.style.italic=value;
  15111. });
  15112. __getset(0,__proto,'stroke',function(){
  15113. return this.div.style.stroke;
  15114. },function(value){
  15115. this.div.style.stroke=value;
  15116. });
  15117. __getset(0,__proto,'strokeColor',function(){
  15118. return this.div.style.strokeColor;
  15119. },function(value){
  15120. this.div.style.strokeColor=value;
  15121. this.updateGear(4);
  15122. });
  15123. __getset(0,__proto,'ubbEnabled',function(){
  15124. return this._ubbEnabled;
  15125. },function(value){
  15126. this._ubbEnabled=value;
  15127. });
  15128. return GRichTextField;
  15129. })(GTextField)
  15130. //class fairygui.GProgressBar extends fairygui.GComponent
  15131. var GProgressBar=(function(_super){
  15132. function GProgressBar(){
  15133. this._max=0;
  15134. this._value=0;
  15135. this._titleType=0;
  15136. this._reverse=false;
  15137. this._titleObject=null;
  15138. this._aniObject=null;
  15139. this._barObjectH=null;
  15140. this._barObjectV=null;
  15141. this._barMaxWidth=0;
  15142. this._barMaxHeight=0;
  15143. this._barMaxWidthDelta=0;
  15144. this._barMaxHeightDelta=0;
  15145. this._barStartX=0;
  15146. this._barStartY=0;
  15147. this._tweening=false;
  15148. GProgressBar.__super.call(this);
  15149. this._titleType=0;
  15150. this._value=50;
  15151. this._max=100;
  15152. }
  15153. __class(GProgressBar,'fairygui.GProgressBar',_super);
  15154. var __proto=GProgressBar.prototype;
  15155. __proto.tweenValue=function(value,duration){
  15156. var _$this=this;
  15157. if(this._value !=value){
  15158. if(this._tweening){
  15159. GTween.kill(this,false,this.update);
  15160. this._tweening=false;
  15161. };
  15162. var oldValule=this._value;
  15163. this._value=value;
  15164. this._tweening=true;
  15165. return GTween.to(oldValule,this._value,duration).setTarget(this,this.update).setEase(0)
  15166. .onComplete(function(){_$this._tweening=false;},this);
  15167. }
  15168. else
  15169. return null;
  15170. }
  15171. __proto.update=function(newValue){
  15172. var percent=this._max!=0?Math.min(newValue / this._max,1):0;
  15173. if(this._titleObject){
  15174. switch(this._titleType){
  15175. case 0:
  15176. this._titleObject.text=Math.round(percent *100)+"%";
  15177. break ;
  15178. case 1:
  15179. this._titleObject.text=Math.round(newValue)+"/"+Math.round(this._max);
  15180. break ;
  15181. case 2:
  15182. this._titleObject.text=""+Math.round(newValue);
  15183. break ;
  15184. case 3:
  15185. this._titleObject.text=""+Math.round(this._max);
  15186. break ;
  15187. }
  15188. };
  15189. var fullWidth=this.width-this._barMaxWidthDelta;
  15190. var fullHeight=this.height-this._barMaxHeightDelta;
  15191. if(!this._reverse){
  15192. if(this._barObjectH){
  15193. if (((this._barObjectH instanceof fairygui.GImage ))&& (this._barObjectH).fillMethod !=0)
  15194. (this._barObjectH).fillAmount=percent;
  15195. else
  15196. this._barObjectH.width=Math.round(fullWidth *percent);
  15197. }
  15198. if(this._barObjectV){
  15199. if (((this._barObjectV instanceof fairygui.GImage ))&& (this._barObjectV).fillMethod !=0)
  15200. (this._barObjectV).fillAmount=percent;
  15201. else
  15202. this._barObjectV.height=Math.round(fullHeight *percent);
  15203. }
  15204. }
  15205. else {
  15206. if(this._barObjectH){
  15207. if (((this._barObjectH instanceof fairygui.GImage ))&& (this._barObjectH).fillMethod !=0)
  15208. (this._barObjectH).fillAmount=1-percent;
  15209. else{
  15210. this._barObjectH.width=Math.round(fullWidth *percent);
  15211. this._barObjectH.x=this._barStartX+(fullWidth-this._barObjectH.width);
  15212. }
  15213. }
  15214. if(this._barObjectV){
  15215. if (((this._barObjectV instanceof fairygui.GImage ))&& (this._barObjectV).fillMethod !=0)
  15216. (this._barObjectV).fillAmount=1-percent;
  15217. else{
  15218. this._barObjectV.height=Math.round(fullHeight *percent);
  15219. this._barObjectV.y=this._barStartY+(fullHeight-this._barObjectV.height);
  15220. }
  15221. }
  15222. }
  15223. if((this._aniObject instanceof fairygui.GMovieClip ))
  15224. (this._aniObject).frame=Math.round(percent *100);
  15225. }
  15226. __proto.constructExtension=function(buffer){
  15227. buffer.seek(0,6);
  15228. this._titleType=buffer.readByte();
  15229. this._reverse=buffer.readBool();
  15230. this._titleObject=(this.getChild("title"));
  15231. this._barObjectH=this.getChild("bar");
  15232. this._barObjectV=this.getChild("bar_v");
  15233. this._aniObject=this.getChild("ani");
  15234. if(this._barObjectH){
  15235. this._barMaxWidth=this._barObjectH.width;
  15236. this._barMaxWidthDelta=this.width-this._barMaxWidth;
  15237. this._barStartX=this._barObjectH.x;
  15238. }
  15239. if(this._barObjectV){
  15240. this._barMaxHeight=this._barObjectV.height;
  15241. this._barMaxHeightDelta=this.height-this._barMaxHeight;
  15242. this._barStartY=this._barObjectV.y;
  15243. }
  15244. }
  15245. __proto.handleSizeChanged=function(){
  15246. _super.prototype.handleSizeChanged.call(this);
  15247. if(this._barObjectH)
  15248. this._barMaxWidth=this.width-this._barMaxWidthDelta;
  15249. if(this._barObjectV)
  15250. this._barMaxHeight=this.height-this._barMaxHeightDelta;
  15251. if(!this._underConstruct)
  15252. this.update(this._value);
  15253. }
  15254. __proto.setup_afterAdd=function(buffer,beginPos){
  15255. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  15256. if (!buffer.seek(beginPos,6)){
  15257. this.update(this._value);
  15258. return;
  15259. }
  15260. if (buffer.readByte()!=this.packageItem.objectType){
  15261. this.update(this._value);
  15262. return;
  15263. }
  15264. this._value=buffer.getInt32();
  15265. this._max=buffer.getInt32();
  15266. this.update(this._value);
  15267. }
  15268. __proto.dispose=function(){
  15269. if(this._tweening)
  15270. GTween.kill(this);
  15271. _super.prototype.dispose.call(this);
  15272. }
  15273. __getset(0,__proto,'max',function(){
  15274. return this._max;
  15275. },function(value){
  15276. if(this._max !=value){
  15277. this._max=value;
  15278. this.update(this._value);
  15279. }
  15280. });
  15281. /**
  15282. *@see ProgressTitleType
  15283. */
  15284. /**
  15285. *@see ProgressTitleType
  15286. */
  15287. __getset(0,__proto,'titleType',function(){
  15288. return this._titleType;
  15289. },function(value){
  15290. if(this._titleType !=value){
  15291. this._titleType=value;
  15292. this.update(this._value);
  15293. }
  15294. });
  15295. __getset(0,__proto,'value',function(){
  15296. return this._value;
  15297. },function(value){
  15298. if(this._tweening){
  15299. GTween.kill(this,true,this.update);
  15300. this._tweening=false;
  15301. }
  15302. if(this._value !=value){
  15303. this._value=value;
  15304. this.update(this._value);
  15305. }
  15306. });
  15307. return GProgressBar;
  15308. })(GComponent)
  15309. //class fairygui.GRoot extends fairygui.GComponent
  15310. var GRoot=(function(_super){
  15311. function GRoot(){
  15312. this.uiScale=1;
  15313. this._modalLayer=null;
  15314. this._popupStack=null;
  15315. this._justClosedPopups=null;
  15316. this._modalWaitPane=null;
  15317. this._focusedObject=null;
  15318. this._tooltipWin=null;
  15319. this._defaultTooltipWin=null;
  15320. this._checkPopups=false;
  15321. GRoot.__super.call(this);
  15322. if(fairygui.GRoot._inst==null)
  15323. fairygui.GRoot._inst=this;
  15324. this.opaque=false;
  15325. this._popupStack=[];
  15326. this._justClosedPopups=[];
  15327. this.displayObject.once("display",this,this.__addedToStage);
  15328. }
  15329. __class(GRoot,'fairygui.GRoot',_super);
  15330. var __proto=GRoot.prototype;
  15331. __proto.showWindow=function(win){
  15332. this.addChild(win);
  15333. win.requestFocus();
  15334. if(win.x > this.width)
  15335. win.x=this.width-win.width;
  15336. else if(win.x+win.width < 0)
  15337. win.x=0;
  15338. if(win.y > this.height)
  15339. win.y=this.height-win.height;
  15340. else if(win.y+win.height < 0)
  15341. win.y=0;
  15342. this.adjustModalLayer();
  15343. }
  15344. __proto.hideWindow=function(win){
  15345. win.hide();
  15346. }
  15347. __proto.hideWindowImmediately=function(win){
  15348. if(win.parent==this)
  15349. this.removeChild(win);
  15350. this.adjustModalLayer();
  15351. }
  15352. __proto.bringToFront=function(win){
  15353. var cnt=this.numChildren;
  15354. var i=NaN;
  15355. if(this._modalLayer.parent!=null && !win.modal)
  15356. i=this.getChildIndex(this._modalLayer)-1;
  15357. else
  15358. i=cnt-1;
  15359. for(;i >=0;i--){
  15360. var g=this.getChildAt(i);
  15361. if(g==win)
  15362. return;
  15363. if((g instanceof fairygui.Window ))
  15364. break ;
  15365. }
  15366. if(i>=0)
  15367. this.setChildIndex(win,i);
  15368. }
  15369. __proto.showModalWait=function(msg){
  15370. if(UIConfig$1.globalModalWaiting !=null){
  15371. if(this._modalWaitPane==null)
  15372. this._modalWaitPane=UIPackage.createObjectFromURL(UIConfig$1.globalModalWaiting);
  15373. this._modalWaitPane.setSize(this.width,this.height);
  15374. this._modalWaitPane.addRelation(this,24);
  15375. this.addChild(this._modalWaitPane);
  15376. this._modalWaitPane.text=msg;
  15377. }
  15378. }
  15379. __proto.closeModalWait=function(){
  15380. if(this._modalWaitPane !=null && this._modalWaitPane.parent !=null)
  15381. this.removeChild(this._modalWaitPane);
  15382. }
  15383. __proto.closeAllExceptModals=function(){
  15384. var arr=this._children.slice();
  15385. var cnt=arr.length;
  15386. for(var i=0;i < cnt;i++){
  15387. var g=arr[i];
  15388. if(((g instanceof fairygui.Window ))&& !(g).modal)
  15389. (g).hide();
  15390. }
  15391. }
  15392. __proto.closeAllWindows=function(){
  15393. var arr=this._children.slice();
  15394. var cnt=arr.length;
  15395. for(var i=0;i < cnt;i++){
  15396. var g=arr[i];
  15397. if((g instanceof fairygui.Window ))
  15398. (g).hide();
  15399. }
  15400. }
  15401. __proto.getTopWindow=function(){
  15402. var cnt=this.numChildren;
  15403. for(var i=cnt-1;i >=0;i--){
  15404. var g=this.getChildAt(i);
  15405. if((g instanceof fairygui.Window )){
  15406. return (g);
  15407. }
  15408. }
  15409. return null;
  15410. }
  15411. __proto.showPopup=function(popup,target,downward){
  15412. if(this._popupStack.length > 0){
  15413. var k=this._popupStack.indexOf(popup);
  15414. if(k !=-1){
  15415. for(var i=this._popupStack.length-1;i >=k;i--)
  15416. this.removeChild(this._popupStack.pop());
  15417. }
  15418. }
  15419. this._popupStack.push(popup);
  15420. if (target !=null){
  15421. var p=target;
  15422. while (p !=null){
  15423. if (p.parent==this){
  15424. if (popup.sortingOrder < p.sortingOrder){
  15425. popup.sortingOrder=p.sortingOrder;
  15426. }
  15427. break ;
  15428. }
  15429. p=p.parent;
  15430. }
  15431. }
  15432. this.addChild(popup);
  15433. this.adjustModalLayer();
  15434. var pos;
  15435. var sizeW=0,sizeH=0;
  15436. if(target){
  15437. pos=target.localToGlobal();
  15438. sizeW=target.width;
  15439. sizeH=target.height;
  15440. }
  15441. else {
  15442. pos=this.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY);
  15443. };
  15444. var xx=NaN,yy=NaN;
  15445. xx=pos.x;
  15446. if(xx+popup.width > this.width)
  15447. xx=xx+sizeW-popup.width;
  15448. yy=pos.y+sizeH;
  15449. if((downward==null && yy+popup.height > this.height)
  15450. || downward==false){
  15451. yy=pos.y-popup.height-1;
  15452. if(yy < 0){
  15453. yy=0;
  15454. xx+=sizeW / 2;
  15455. }
  15456. }
  15457. popup.x=xx;
  15458. popup.y=yy;
  15459. }
  15460. __proto.togglePopup=function(popup,target,downward){
  15461. if(this._justClosedPopups.indexOf(popup)!=-1)
  15462. return;
  15463. this.showPopup(popup,target,downward);
  15464. }
  15465. __proto.hidePopup=function(popup){
  15466. if(popup !=null){
  15467. var k=this._popupStack.indexOf(popup);
  15468. if(k !=-1){
  15469. for(var i=this._popupStack.length-1;i >=k;i--)
  15470. this.closePopup(this._popupStack.pop());
  15471. }
  15472. }
  15473. else {
  15474. var cnt=this._popupStack.length;
  15475. for(i=cnt-1;i >=0;i--)
  15476. this.closePopup(this._popupStack[i]);
  15477. this._popupStack.length=0;
  15478. }
  15479. }
  15480. __proto.closePopup=function(target){
  15481. if(target.parent !=null){
  15482. if((target instanceof fairygui.Window ))
  15483. (target).hide();
  15484. else
  15485. this.removeChild(target);
  15486. }
  15487. }
  15488. __proto.showTooltips=function(msg){
  15489. if (this._defaultTooltipWin==null){
  15490. var resourceURL=UIConfig$1.tooltipsWin;
  15491. if (!resourceURL){
  15492. Log.print("UIConfig.tooltipsWin not defined");
  15493. return;
  15494. }
  15495. this._defaultTooltipWin=UIPackage.createObjectFromURL(resourceURL);
  15496. }
  15497. this._defaultTooltipWin.text=msg;
  15498. this.showTooltipsWin(this._defaultTooltipWin);
  15499. }
  15500. __proto.showTooltipsWin=function(tooltipWin,position){
  15501. this.hideTooltips();
  15502. this._tooltipWin=tooltipWin;
  15503. var xx=0;
  15504. var yy=0;
  15505. if (position==null){
  15506. xx=Laya.stage.mouseX+10;
  15507. yy=Laya.stage.mouseY+20;
  15508. }
  15509. else {
  15510. xx=position.x;
  15511. yy=position.y;
  15512. };
  15513. var pt=this.globalToLocal(xx,yy);
  15514. xx=pt.x;
  15515. yy=pt.y;
  15516. if (xx+this._tooltipWin.width > this.width){
  15517. xx=xx-this._tooltipWin.width-1;
  15518. if (xx < 0)
  15519. xx=10;
  15520. }
  15521. if (yy+this._tooltipWin.height > this.height){
  15522. yy=yy-this._tooltipWin.height-1;
  15523. if (xx-this._tooltipWin.width-1 > 0)
  15524. xx=xx-this._tooltipWin.width-1;
  15525. if (yy < 0)
  15526. yy=10;
  15527. }
  15528. this._tooltipWin.x=xx;
  15529. this._tooltipWin.y=yy;
  15530. this.addChild(this._tooltipWin);
  15531. }
  15532. __proto.hideTooltips=function(){
  15533. if (this._tooltipWin !=null){
  15534. if (this._tooltipWin.parent)
  15535. this.removeChild(this._tooltipWin);
  15536. this._tooltipWin=null;
  15537. }
  15538. }
  15539. __proto.getObjectUnderPoint=function(globalX,globalY){
  15540. return null;
  15541. }
  15542. __proto.setFocus=function(value){
  15543. if(this._focusedObject!=value){
  15544. this._focusedObject=value;
  15545. this.displayObject.event("fui_focus_changed");
  15546. }
  15547. }
  15548. __proto.playOneShotSound=function(url,volumeScale){
  15549. (volumeScale===void 0)&& (volumeScale=1);
  15550. if(ToolSet.startsWith(url,"ui://"))
  15551. return;
  15552. SoundManager.playSound(url);
  15553. }
  15554. __proto.adjustModalLayer=function(){
  15555. var cnt=this.numChildren;
  15556. if (this._modalWaitPane !=null && this._modalWaitPane.parent !=null)
  15557. this.setChildIndex(this._modalWaitPane,cnt-1);
  15558. for(var i=cnt-1;i >=0;i--){
  15559. var g=this.getChildAt(i);
  15560. if(((g instanceof fairygui.Window ))&& (g).modal){
  15561. if(this._modalLayer.parent==null)
  15562. this.addChildAt(this._modalLayer,i);
  15563. else
  15564. this.setChildIndexBefore(this._modalLayer,i);
  15565. return;
  15566. }
  15567. }
  15568. if (this._modalLayer.parent !=null)
  15569. this.removeChild(this._modalLayer);
  15570. }
  15571. __proto.__addedToStage=function(){
  15572. Laya.stage.on("mousedown",this,this.__stageMouseDown);
  15573. Laya.stage.on("mouseup",this,this.__stageMouseUp);
  15574. this._modalLayer=new GGraph();
  15575. this._modalLayer.setSize(this.width,this.height);
  15576. this._modalLayer.drawRect(0,null,UIConfig$1.modalLayerColor);
  15577. this._modalLayer.addRelation(this,24);
  15578. this.displayObject.stage.on("resize",this,this.__winResize);
  15579. this.__winResize();
  15580. }
  15581. __proto.checkPopups=function(clickTarget){
  15582. if(this._checkPopups)
  15583. return;
  15584. this._checkPopups=true;
  15585. this._justClosedPopups.length=0;
  15586. if (this._popupStack.length > 0){
  15587. var mc=clickTarget;
  15588. while (mc !=this.displayObject.stage && mc !=null){
  15589. if (mc["$owner"]){
  15590. var pindex=this._popupStack.indexOf(mc["$owner"]);
  15591. if (pindex !=-1){
  15592. for(var i=this._popupStack.length-1;i > pindex;i--){
  15593. var popup=this._popupStack.pop();
  15594. this.closePopup(popup);
  15595. this._justClosedPopups.push(popup);
  15596. }
  15597. return;
  15598. }
  15599. }
  15600. mc=mc.parent;
  15601. };
  15602. var cnt=this._popupStack.length;
  15603. for(i=cnt-1;i >=0;i--){
  15604. popup=this._popupStack[i];
  15605. this.closePopup(popup);
  15606. this._justClosedPopups.push(popup);
  15607. }
  15608. this._popupStack.length=0;
  15609. }
  15610. }
  15611. __proto.__stageMouseDown=function(evt){
  15612. var mc=evt.target;
  15613. while (mc !=this.displayObject.stage && mc !=null){
  15614. if (mc["$owner"]){
  15615. var gg=mc["$owner"];
  15616. if (gg.touchable && gg.focusable){
  15617. this.setFocus(gg);
  15618. break ;
  15619. }
  15620. }
  15621. mc=mc.parent;
  15622. }
  15623. if (this._tooltipWin !=null)
  15624. this.hideTooltips();
  15625. this.checkPopups(evt.target);
  15626. }
  15627. __proto.__stageMouseUp=function(){
  15628. this._checkPopups=false;
  15629. }
  15630. __proto.__winResize=function(){
  15631. this.setSize(Laya.stage.width,Laya.stage.height);
  15632. }
  15633. __getset(0,__proto,'focus',function(){
  15634. if (this._focusedObject && !this._focusedObject.onStage)
  15635. this._focusedObject=null;
  15636. return this._focusedObject;
  15637. },function(value){
  15638. if (value && (!value.focusable || !value.onStage))
  15639. throw "invalid focus target";
  15640. this.setFocus(value);
  15641. });
  15642. __getset(0,__proto,'hasAnyPopup',function(){
  15643. return this._popupStack.length !=0;
  15644. });
  15645. __getset(0,__proto,'modalLayer',function(){
  15646. return this._modalLayer;
  15647. });
  15648. __getset(0,__proto,'hasModalWindow',function(){
  15649. return this._modalLayer.parent !=null;
  15650. });
  15651. __getset(0,__proto,'modalWaiting',function(){
  15652. return this._modalWaitPane && this._modalWaitPane.inContainer;
  15653. });
  15654. __getset(0,__proto,'volumeScale',function(){
  15655. return SoundManager.soundVolume;
  15656. },function(value){
  15657. SoundManager.soundVolume=value;
  15658. });
  15659. __getset(1,GRoot,'inst',function(){
  15660. if(fairygui.GRoot._inst==null)
  15661. new GRoot();
  15662. return fairygui.GRoot._inst;
  15663. },fairygui.GComponent._$SET_inst);
  15664. GRoot._inst=null;
  15665. return GRoot;
  15666. })(GComponent)
  15667. //class fairygui.GTextInput extends fairygui.GTextField
  15668. var GTextInput=(function(_super){
  15669. function GTextInput(){
  15670. this.input=null;
  15671. GTextInput.__super.call(this);
  15672. }
  15673. __class(GTextInput,'fairygui.GTextInput',_super);
  15674. var __proto=GTextInput.prototype;
  15675. __proto.createDisplayObject=function(){
  15676. this._displayObject=this.input=new Input();
  15677. this._displayObject.mouseEnabled=true;
  15678. this._displayObject["$owner"]=this;
  15679. }
  15680. __proto.handleSizeChanged=function(){
  15681. this.input.size(this.width,this.height);
  15682. }
  15683. __proto.setup_beforeAdd=function(buffer,beginPos){
  15684. _super.prototype.setup_beforeAdd.call(this,buffer,beginPos);
  15685. buffer.seek(beginPos,4);
  15686. var str=buffer.readS();
  15687. if (str !=null)
  15688. this.promptText=str;
  15689. str=buffer.readS();
  15690. if (str !=null)
  15691. this.input.restrict=str;
  15692. var iv=buffer.getInt32();
  15693. if (iv !=0)
  15694. this.input.maxChars=iv;
  15695. iv=buffer.getInt32();
  15696. if (iv !=0){
  15697. if(iv==4)
  15698. this.keyboardType="number";
  15699. else if(iv==3)
  15700. this.keyboardType="url";
  15701. }
  15702. if (buffer.readBool())
  15703. this.password=true;
  15704. }
  15705. __getset(0,__proto,'bold',function(){
  15706. return this.input.bold;
  15707. },function(value){
  15708. this.input.bold=value;
  15709. });
  15710. __getset(0,__proto,'align',function(){
  15711. return this.input.align;
  15712. },function(value){
  15713. this.input.align=value;
  15714. });
  15715. __getset(0,__proto,'text',function(){
  15716. return this.input.text;
  15717. },function(value){
  15718. this.input.text=value;
  15719. });
  15720. __getset(0,__proto,'password',function(){
  15721. return this.input.type=="password";
  15722. },function(value){
  15723. if (value)
  15724. this.input.type="password";
  15725. else
  15726. this.input.type="text";
  15727. });
  15728. __getset(0,__proto,'color',function(){
  15729. return this.input.color;
  15730. },function(value){
  15731. this.input.color=value;
  15732. });
  15733. __getset(0,__proto,'font',function(){
  15734. return this.input.font;
  15735. },function(value){
  15736. this.input.font=value;
  15737. });
  15738. __getset(0,__proto,'leading',function(){
  15739. return this.input.leading;
  15740. },function(value){
  15741. this.input.leading=value;
  15742. });
  15743. __getset(0,__proto,'maxLength',function(){
  15744. return this.input.maxChars;
  15745. },function(value){
  15746. this.input.maxChars=value;
  15747. });
  15748. __getset(0,__proto,'fontSize',function(){
  15749. return this.input.fontSize;
  15750. },function(value){
  15751. this.input.fontSize=value;
  15752. });
  15753. __getset(0,__proto,'valign',function(){
  15754. return this.input.valign;
  15755. },function(value){
  15756. this.input.valign=value;
  15757. });
  15758. __getset(0,__proto,'italic',function(){
  15759. return this.input.italic;
  15760. },function(value){
  15761. this.input.italic=value;
  15762. });
  15763. __getset(0,__proto,'singleLine',function(){
  15764. return !this.input.multiline;
  15765. },function(value){
  15766. this.input.multiline=!value;
  15767. });
  15768. __getset(0,__proto,'stroke',function(){
  15769. return this.input.stroke;
  15770. },function(value){
  15771. this.input.stroke=value;
  15772. });
  15773. __getset(0,__proto,'strokeColor',function(){
  15774. return this.input.strokeColor;
  15775. },function(value){
  15776. this.input.strokeColor=value;
  15777. this.updateGear(4);
  15778. });
  15779. __getset(0,__proto,'keyboardType',function(){
  15780. return this.input.type;
  15781. },function(value){
  15782. this.input.type=value;
  15783. });
  15784. __getset(0,__proto,'editable',function(){
  15785. return this.input.editable;
  15786. },function(value){
  15787. this.input.editable=value;
  15788. });
  15789. __getset(0,__proto,'promptText',function(){
  15790. return this.input.prompt;
  15791. },function(value){
  15792. this.input.prompt=value;
  15793. });
  15794. __getset(0,__proto,'restrict',function(){
  15795. return this.input.restrict;
  15796. },function(value){
  15797. this.input.restrict=value;
  15798. });
  15799. __getset(0,__proto,'textWidth',function(){
  15800. return this.input.textWidth;
  15801. });
  15802. return GTextInput;
  15803. })(GTextField)
  15804. //class fairygui.GScrollBar extends fairygui.GComponent
  15805. var GScrollBar=(function(_super){
  15806. function GScrollBar(){
  15807. this._grip=null;
  15808. this._arrowButton1=null;
  15809. this._arrowButton2=null;
  15810. this._bar=null;
  15811. this._target=null;
  15812. this._vertical=false;
  15813. this._scrollPerc=0;
  15814. this._fixedGripSize=false;
  15815. this._dragOffset=null;
  15816. GScrollBar.__super.call(this);
  15817. this._dragOffset=new laya.maths.Point();
  15818. this._scrollPerc=0;
  15819. }
  15820. __class(GScrollBar,'fairygui.GScrollBar',_super);
  15821. var __proto=GScrollBar.prototype;
  15822. __proto.setScrollPane=function(target,vertical){
  15823. this._target=target;
  15824. this._vertical=vertical;
  15825. }
  15826. __proto.constructExtension=function(buffer){
  15827. buffer.seek(0,6);
  15828. this._fixedGripSize=buffer.readBool();
  15829. this._grip=this.getChild("grip");
  15830. if(!this._grip){
  15831. Log.print("需要定义grip");
  15832. return;
  15833. }
  15834. this._bar=this.getChild("bar");
  15835. if(!this._bar){
  15836. Log.print("需要定义bar");
  15837. return;
  15838. }
  15839. this._arrowButton1=this.getChild("arrow1");
  15840. this._arrowButton2=this.getChild("arrow2");
  15841. this._grip.on("mousedown",this,this.__gripMouseDown);
  15842. if(this._arrowButton1)
  15843. this._arrowButton1.on("mousedown",this,this.__arrowButton1Click);
  15844. if(this._arrowButton2)
  15845. this._arrowButton2.on("mousedown",this,this.__arrowButton2Click);
  15846. this.on("mousedown",this,this.__barMouseDown);
  15847. }
  15848. __proto.__gripMouseDown=function(evt){
  15849. if (!this._bar)
  15850. return;
  15851. evt.stopPropagation();
  15852. Laya.stage.on("mousemove",this,this.__gripMouseMove);
  15853. Laya.stage.on("mouseup",this,this.__gripMouseUp);
  15854. this.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY,this._dragOffset);
  15855. this._dragOffset.x-=this._grip.x;
  15856. this._dragOffset.y-=this._grip.y;
  15857. }
  15858. __proto.__gripMouseMove=function(){
  15859. var pt=this.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY,fairygui.GScrollBar.sScrollbarHelperPoint);
  15860. if (this._vertical){
  15861. var curY=pt.y-this._dragOffset.y;
  15862. this._target.setPercY((curY-this._bar.y)/ (this._bar.height-this._grip.height),false);
  15863. }
  15864. else {
  15865. var curX=pt.x-this._dragOffset.x;
  15866. this._target.setPercX((curX-this._bar.x)/ (this._bar.width-this._grip.width),false);
  15867. }
  15868. }
  15869. __proto.__gripMouseUp=function(evt){
  15870. if (!this._bar)
  15871. return;
  15872. Laya.stage.off("mousemove",this,this.__gripMouseMove);
  15873. Laya.stage.off("mouseup",this,this.__gripMouseUp);
  15874. }
  15875. __proto.__arrowButton1Click=function(evt){
  15876. evt.stopPropagation();
  15877. if (this._vertical)
  15878. this._target.scrollUp();
  15879. else
  15880. this._target.scrollLeft();
  15881. }
  15882. __proto.__arrowButton2Click=function(evt){
  15883. evt.stopPropagation();
  15884. if (this._vertical)
  15885. this._target.scrollDown();
  15886. else
  15887. this._target.scrollRight();
  15888. }
  15889. __proto.__barMouseDown=function(evt){
  15890. var pt=this._grip.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY,fairygui.GScrollBar.sScrollbarHelperPoint);
  15891. if (this._vertical){
  15892. if (pt.y < 0)
  15893. this._target.scrollUp(4);
  15894. else
  15895. this._target.scrollDown(4);
  15896. }
  15897. else {
  15898. if (pt.x < 0)
  15899. this._target.scrollLeft(4);
  15900. else
  15901. this._target.scrollRight(4);
  15902. }
  15903. }
  15904. __getset(0,__proto,'displayPerc',null,function(val){
  15905. if (this._vertical){
  15906. if(!this._fixedGripSize)
  15907. this._grip.height=val *this._bar.height;
  15908. this._grip.y=this._bar.y+(this._bar.height-this._grip.height)*this._scrollPerc;
  15909. }
  15910. else {
  15911. if(!this._fixedGripSize)
  15912. this._grip.width=val *this._bar.width;
  15913. this._grip.x=this._bar.x+(this._bar.width-this._grip.width)*this._scrollPerc;
  15914. }
  15915. });
  15916. __getset(0,__proto,'scrollPerc',null,function(val){
  15917. this._scrollPerc=val;
  15918. if (this._vertical)
  15919. this._grip.y=this._bar.y+(this._bar.height-this._grip.height)*this._scrollPerc;
  15920. else
  15921. this._grip.x=this._bar.x+(this._bar.width-this._grip.width)*this._scrollPerc;
  15922. });
  15923. __getset(0,__proto,'minSize',function(){
  15924. if (this._vertical)
  15925. return (this._arrowButton1 !=null ? this._arrowButton1.height :0)+(this._arrowButton2 !=null ? this._arrowButton2.height :0);
  15926. else
  15927. return (this._arrowButton1 !=null ? this._arrowButton1.width :0)+(this._arrowButton2 !=null ? this._arrowButton2.width :0);
  15928. });
  15929. __static(GScrollBar,
  15930. ['sScrollbarHelperPoint',function(){return this.sScrollbarHelperPoint=new Point();}
  15931. ]);
  15932. return GScrollBar;
  15933. })(GComponent)
  15934. //class fairygui.GSlider extends fairygui.GComponent
  15935. var GSlider=(function(_super){
  15936. function GSlider(){
  15937. this._max=0;
  15938. this._value=0;
  15939. this._titleType=0;
  15940. this._reverse=false;
  15941. this._titleObject=null;
  15942. this._barObjectH=null;
  15943. this._barObjectV=null;
  15944. this._barMaxWidth=0;
  15945. this._barMaxHeight=0;
  15946. this._barMaxWidthDelta=0;
  15947. this._barMaxHeightDelta=0;
  15948. this._gripObject=null;
  15949. this._clickPos=null;
  15950. this._clickPercent=0;
  15951. this._barStartX=0;
  15952. this._barStartY=0;
  15953. this.changeOnClick=true;
  15954. /**是否可拖动开关**/
  15955. this.canDrag=true;
  15956. GSlider.__super.call(this);
  15957. this._titleType=0;
  15958. this._value=50;
  15959. this._max=100;
  15960. this._clickPos=new laya.maths.Point();
  15961. }
  15962. __class(GSlider,'fairygui.GSlider',_super);
  15963. var __proto=GSlider.prototype;
  15964. __proto.update=function(){
  15965. var percent=Math.min(this._value / this._max,1);
  15966. this.updateWidthPercent(percent);
  15967. }
  15968. __proto.updateWidthPercent=function(percent){
  15969. if (this._titleObject){
  15970. switch (this._titleType){
  15971. case 0:
  15972. this._titleObject.text=Math.round(percent *100)+"%";
  15973. break ;
  15974. case 1:
  15975. this._titleObject.text=this._value+"/"+this._max;
  15976. break ;
  15977. case 2:
  15978. this._titleObject.text=""+this._value;
  15979. break ;
  15980. case 3:
  15981. this._titleObject.text=""+this._max;
  15982. break ;
  15983. }
  15984. };
  15985. var fullWidth=this.width-this._barMaxWidthDelta;
  15986. var fullHeight=this.height-this._barMaxHeightDelta;
  15987. if(!this._reverse){
  15988. if(this._barObjectH)
  15989. this._barObjectH.width=Math.round(fullWidth*percent);
  15990. if(this._barObjectV)
  15991. this._barObjectV.height=Math.round(fullHeight*percent);
  15992. }
  15993. else{
  15994. if(this._barObjectH){
  15995. this._barObjectH.width=Math.round(fullWidth*percent);
  15996. this._barObjectH.x=this._barStartX+(fullWidth-this._barObjectH.width);
  15997. }
  15998. if(this._barObjectV){
  15999. this._barObjectV.height=Math.round(fullHeight*percent);
  16000. this._barObjectV.y=this._barStartY+(fullHeight-this._barObjectV.height);
  16001. }
  16002. }
  16003. }
  16004. __proto.constructExtension=function(buffer){
  16005. buffer.seek(0,6);
  16006. this._titleType=buffer.readByte();
  16007. this._reverse=buffer.readBool();
  16008. this._titleObject=(this.getChild("title"));
  16009. this._barObjectH=this.getChild("bar");
  16010. this._barObjectV=this.getChild("bar_v");
  16011. this._gripObject=this.getChild("grip");
  16012. if(this._barObjectH){
  16013. this._barMaxWidth=this._barObjectH.width;
  16014. this._barMaxWidthDelta=this.width-this._barMaxWidth;
  16015. this._barStartX=this._barObjectH.x;
  16016. }
  16017. if(this._barObjectV){
  16018. this._barMaxHeight=this._barObjectV.height;
  16019. this._barMaxHeightDelta=this.height-this._barMaxHeight;
  16020. this._barStartY=this._barObjectV.y;
  16021. }
  16022. if(this._gripObject){
  16023. this._gripObject.on("mousedown",this,this.__gripMouseDown);
  16024. }
  16025. this.displayObject.on("mousedown",this,this.__barMouseDown);
  16026. }
  16027. __proto.handleSizeChanged=function(){
  16028. _super.prototype.handleSizeChanged.call(this);
  16029. if(this._barObjectH)
  16030. this._barMaxWidth=this.width-this._barMaxWidthDelta;
  16031. if(this._barObjectV)
  16032. this._barMaxHeight=this.height-this._barMaxHeightDelta;
  16033. if(!this._underConstruct)
  16034. this.update();
  16035. }
  16036. __proto.setup_afterAdd=function(buffer,beginPos){
  16037. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  16038. if (!buffer.seek(beginPos,6)){
  16039. this.update();
  16040. return;
  16041. }
  16042. if (buffer.readByte()!=this.packageItem.objectType){
  16043. this.update();
  16044. return;
  16045. }
  16046. this._value=buffer.getInt32();
  16047. this._max=buffer.getInt32();
  16048. this.update();
  16049. }
  16050. __proto.__gripMouseDown=function(evt){
  16051. this.canDrag=true;
  16052. evt.stopPropagation();
  16053. this._clickPos=this.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY);
  16054. this._clickPercent=this._value / this._max;
  16055. Laya.stage.on("mousemove",this,this.__gripMouseMove);
  16056. Laya.stage.on("mouseup",this,this.__gripMouseUp);
  16057. }
  16058. __proto.__gripMouseMove=function(evt){
  16059. if(!this.canDrag){
  16060. return;
  16061. };
  16062. var pt=this.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY,fairygui.GSlider.sSilderHelperPoint);
  16063. var deltaX=pt.x-this._clickPos.x;
  16064. var deltaY=pt.y-this._clickPos.y;
  16065. if(this._reverse){
  16066. deltaX=-deltaX;
  16067. deltaY=-deltaY;
  16068. };
  16069. var percent=NaN;
  16070. if (this._barObjectH)
  16071. percent=this._clickPercent+deltaX / this._barMaxWidth;
  16072. else
  16073. percent=this._clickPercent+deltaY / this._barMaxHeight;
  16074. if (percent > 1)
  16075. percent=1;
  16076. else if (percent < 0)
  16077. percent=0;
  16078. var newValue=Math.round(this._max *percent);
  16079. if (newValue !=this._value){
  16080. this._value=newValue;
  16081. Events.dispatch("fui_state_changed",this.displayObject,evt);
  16082. }
  16083. this.updateWidthPercent(percent);
  16084. }
  16085. __proto.__gripMouseUp=function(evt){
  16086. Laya.stage.off("mousemove",this,this.__gripMouseMove);
  16087. Laya.stage.off("mouseup",this,this.__gripMouseUp);
  16088. }
  16089. __proto.__barMouseDown=function(evt){
  16090. if(!this.changeOnClick)
  16091. return;
  16092. var pt=this._gripObject.globalToLocal(evt.stageX,evt.stageY,fairygui.GSlider.sSilderHelperPoint);
  16093. var percent=this._value/this._max;
  16094. var delta=NaN;
  16095. if(this._barObjectH)
  16096. delta=(pt.x-this._gripObject.width/2)/this._barMaxWidth;
  16097. if(this._barObjectV)
  16098. delta=(pt.y-this._gripObject.height/2)/this._barMaxHeight;
  16099. if(this._reverse)
  16100. percent-=delta;
  16101. else
  16102. percent+=delta;
  16103. if(percent>1)
  16104. percent=1;
  16105. else if(percent<0)
  16106. percent=0;
  16107. var newValue=Math.round(this._max*percent);
  16108. if(newValue!=this._value){
  16109. this._value=newValue;
  16110. Events.dispatch("fui_state_changed",this.displayObject,evt);
  16111. }
  16112. this.updateWidthPercent(percent);
  16113. }
  16114. __getset(0,__proto,'max',function(){
  16115. return this._max;
  16116. },function(value){
  16117. if (this._max !=value){
  16118. this._max=value;
  16119. this.update();
  16120. }
  16121. });
  16122. /**
  16123. *@see ProgressTitleType
  16124. */
  16125. /**
  16126. *@see ProgressTitleType
  16127. */
  16128. __getset(0,__proto,'titleType',function(){
  16129. return this._titleType;
  16130. },function(value){
  16131. this._titleType=value;
  16132. });
  16133. __getset(0,__proto,'value',function(){
  16134. return this._value;
  16135. },function(value){
  16136. if (this._value !=value){
  16137. this._value=value;
  16138. this.update();
  16139. }
  16140. });
  16141. __static(GSlider,
  16142. ['sSilderHelperPoint',function(){return this.sSilderHelperPoint=new Point();}
  16143. ]);
  16144. return GSlider;
  16145. })(GComponent)
  16146. //class fairygui.Window extends fairygui.GComponent
  16147. var Window$2=(function(_super){
  16148. function Window(){
  16149. this._contentPane=null;
  16150. this._modalWaitPane=null;
  16151. this._closeButton=null;
  16152. this._dragArea=null;
  16153. this._contentArea=null;
  16154. this._frame=null;
  16155. this._modal=false;
  16156. this._uiSources=null;
  16157. this._inited=false;
  16158. this._loading=false;
  16159. this._requestingCmd=0;
  16160. this.bringToFontOnClick=false;
  16161. Window.__super.call(this);
  16162. this.focusable=true;
  16163. this._uiSources=[];
  16164. this.bringToFontOnClick=UIConfig$1.bringWindowToFrontOnClick;
  16165. this.displayObject.on("display",this,this.__onShown);
  16166. this.displayObject.on("undisplay",this,this.__onHidden);
  16167. this.displayObject.on("mousedown",this,this.__mouseDown);
  16168. }
  16169. __class(Window,'fairygui.Window',_super,'Window$2');
  16170. var __proto=Window.prototype;
  16171. __proto.addUISource=function(source){
  16172. this._uiSources.push(source);
  16173. }
  16174. __proto.show=function(){
  16175. GRoot.inst.showWindow(this);
  16176. }
  16177. __proto.showOn=function(root){
  16178. root.showWindow(this);
  16179. }
  16180. __proto.hide=function(){
  16181. if(this.isShowing)
  16182. this.doHideAnimation();
  16183. }
  16184. __proto.hideImmediately=function(){
  16185. var r=((this.parent instanceof fairygui.GRoot ))? (this.parent):null;
  16186. if(!r)
  16187. r=GRoot.inst;
  16188. r.hideWindowImmediately(this);
  16189. }
  16190. __proto.centerOn=function(r,restraint){
  16191. (restraint===void 0)&& (restraint=false);
  16192. this.setXY(Math.round((r.width-this.width)/ 2),Math.round((r.height-this.height)/ 2));
  16193. if(restraint){
  16194. this.addRelation(r,3);
  16195. this.addRelation(r,10);
  16196. }
  16197. }
  16198. __proto.toggleStatus=function(){
  16199. if(this.isTop)
  16200. this.hide();
  16201. else
  16202. this.show();
  16203. }
  16204. __proto.bringToFront=function(){
  16205. this.root.bringToFront(this);
  16206. }
  16207. __proto.showModalWait=function(requestingCmd){
  16208. (requestingCmd===void 0)&& (requestingCmd=0);
  16209. if(requestingCmd !=0)
  16210. this._requestingCmd=requestingCmd;
  16211. if(UIConfig$1.windowModalWaiting){
  16212. if(!this._modalWaitPane)
  16213. this._modalWaitPane=UIPackage.createObjectFromURL(UIConfig$1.windowModalWaiting);
  16214. this.layoutModalWaitPane();
  16215. this.addChild(this._modalWaitPane);
  16216. }
  16217. }
  16218. __proto.layoutModalWaitPane=function(){
  16219. if(this._contentArea !=null){
  16220. var pt=this._frame.localToGlobal();
  16221. pt=this.globalToLocal(pt.x,pt.y,pt);
  16222. this._modalWaitPane.setXY(pt.x+this._contentArea.x,pt.y+this._contentArea.y);
  16223. this._modalWaitPane.setSize(this._contentArea.width,this._contentArea.height);
  16224. }
  16225. else
  16226. this._modalWaitPane.setSize(fairygui.GRoot.inst.width, fairygui.GRoot.inst.height);
  16227. }
  16228. __proto.closeModalWait=function(requestingCmd){
  16229. (requestingCmd===void 0)&& (requestingCmd=0);
  16230. if(requestingCmd !=0){
  16231. if(this._requestingCmd !=requestingCmd)
  16232. return false;
  16233. }
  16234. this._requestingCmd=0;
  16235. if(this._modalWaitPane && this._modalWaitPane.parent !=null)
  16236. this.removeChild(this._modalWaitPane);
  16237. return true;
  16238. }
  16239. __proto.init=function(){
  16240. if(this._inited || this._loading)
  16241. return;
  16242. if(this._uiSources.length > 0){
  16243. this._loading=false;
  16244. var cnt=this._uiSources.length;
  16245. for(var i=0;i < cnt;i++){
  16246. var lib=this._uiSources[i];
  16247. if(!lib.loaded){
  16248. lib.load(this.__uiLoadComplete,this);
  16249. this._loading=true;
  16250. }
  16251. }
  16252. if(!this._loading)
  16253. this._init();
  16254. }
  16255. else
  16256. this._init();
  16257. }
  16258. __proto.onInit=function(){}
  16259. __proto.onShown=function(){}
  16260. __proto.onHide=function(){}
  16261. __proto.doShowAnimation=function(){
  16262. this.onShown();
  16263. }
  16264. __proto.doHideAnimation=function(){
  16265. this.hideImmediately();
  16266. }
  16267. __proto.__uiLoadComplete=function(){
  16268. var cnt=this._uiSources.length;
  16269. for(var i=0;i < cnt;i++){
  16270. var lib=this._uiSources[i];
  16271. if(!lib.loaded)
  16272. return;
  16273. }
  16274. this._loading=false;
  16275. this._init();
  16276. }
  16277. __proto._init=function(){
  16278. this._inited=true;
  16279. this.onInit();
  16280. if(this.isShowing)
  16281. this.doShowAnimation();
  16282. }
  16283. __proto.dispose=function(){
  16284. if(this.parent !=null)
  16285. this.hideImmediately();
  16286. _super.prototype.dispose.call(this);
  16287. }
  16288. __proto.closeEventHandler=function(){
  16289. this.hide();
  16290. }
  16291. __proto.__onShown=function(){
  16292. if(!this._inited)
  16293. this.init();
  16294. else
  16295. this.doShowAnimation();
  16296. }
  16297. __proto.__onHidden=function(){
  16298. this.closeModalWait();
  16299. this.onHide();
  16300. }
  16301. __proto.__mouseDown=function(){
  16302. if(this.isShowing && this.bringToFontOnClick)
  16303. this.bringToFront();
  16304. }
  16305. __proto.__dragStart=function(evt){
  16306. GObject.cast(evt.currentTarget).stopDrag();
  16307. this.startDrag();
  16308. }
  16309. __getset(0,__proto,'contentPane',function(){
  16310. return this._contentPane;
  16311. },function(val){
  16312. if(this._contentPane !=val){
  16313. if(this._contentPane !=null)
  16314. this.removeChild(this._contentPane);
  16315. this._contentPane=val;
  16316. if(this._contentPane !=null){
  16317. this.addChild(this._contentPane);
  16318. this.setSize(this._contentPane.width,this._contentPane.height);
  16319. this._contentPane.addRelation(this,24);
  16320. this._frame=(this._contentPane.getChild("frame"));
  16321. if(this._frame !=null){
  16322. this.closeButton=this._frame.getChild("closeButton");
  16323. this.dragArea=this._frame.getChild("dragArea");
  16324. this.contentArea=this._frame.getChild("contentArea");
  16325. }
  16326. }
  16327. }
  16328. });
  16329. __getset(0,__proto,'isShowing',function(){
  16330. return this.parent !=null;
  16331. });
  16332. __getset(0,__proto,'isTop',function(){
  16333. return this.parent !=null && this.parent.getChildIndex(this)==this.parent.numChildren-1;
  16334. });
  16335. __getset(0,__proto,'modal',function(){
  16336. return this._modal;
  16337. },function(val){
  16338. this._modal=val;
  16339. });
  16340. __getset(0,__proto,'dragArea',function(){
  16341. return this._dragArea;
  16342. },function(value){
  16343. if(this._dragArea !=value){
  16344. if(this._dragArea !=null){
  16345. this._dragArea.draggable=false;
  16346. this._dragArea.off("fui_drag_start",this,this.__dragStart);
  16347. }
  16348. this._dragArea=value;
  16349. if(this._dragArea !=null){
  16350. if((this._dragArea instanceof fairygui.GGraph ))
  16351. this._dragArea.asGraph.drawRect(0,null,null);
  16352. this._dragArea.draggable=true;
  16353. this._dragArea.on("fui_drag_start",this,this.__dragStart);
  16354. }
  16355. }
  16356. });
  16357. __getset(0,__proto,'frame',function(){
  16358. return this._frame;
  16359. });
  16360. __getset(0,__proto,'closeButton',function(){
  16361. return this._closeButton;
  16362. },function(value){
  16363. if(this._closeButton !=null)
  16364. this._closeButton.offClick(this,this.closeEventHandler);
  16365. this._closeButton=value;
  16366. if(this._closeButton !=null)
  16367. this._closeButton.onClick(this,this.closeEventHandler);
  16368. });
  16369. __getset(0,__proto,'contentArea',function(){
  16370. return this._contentArea;
  16371. },function(value){
  16372. this._contentArea=value;
  16373. });
  16374. __getset(0,__proto,'modalWaiting',function(){
  16375. return this._modalWaitPane && this._modalWaitPane.parent !=null;
  16376. });
  16377. return Window;
  16378. })(GComponent)
  16379. //class fairygui.display.Image extends laya.display.Sprite
  16380. var Image$1=(function(_super){
  16381. function Image(){
  16382. this._tex=null;
  16383. this._scaleByTile=false;
  16384. this._scale9Grid=null;
  16385. this._tileGridIndice=0;
  16386. this._textureScaleX=1;
  16387. this._textureScaleY=1;
  16388. this._needRebuild=0;
  16389. this._fillMethod=0;
  16390. this._fillOrigin=0;
  16391. this._fillAmount=0;
  16392. this._fillClockwise=false;
  16393. this._mask=null;
  16394. Image.__super.call(this);
  16395. this.mouseEnabled=false;
  16396. }
  16397. __class(Image,'fairygui.display.Image',_super,'Image$1');
  16398. var __proto=Image.prototype;
  16399. __proto.scaleTexture=function(sx,sy){
  16400. if(this._textureScaleX!=sx || this._textureScaleY!=sy){
  16401. this._textureScaleX=sx;
  16402. this._textureScaleY=sy;
  16403. if(this._tex)
  16404. this.size(this._tex.width*sx,this._tex.height*sy);
  16405. this.markChanged(1);
  16406. }
  16407. }
  16408. __proto.markChanged=function(flag){
  16409. if(!this._needRebuild){
  16410. this._needRebuild=flag;
  16411. Laya.timer.callLater(this,this.rebuild);
  16412. }
  16413. else
  16414. this._needRebuild |=flag;
  16415. }
  16416. __proto.rebuild=function(){
  16417. if((this._needRebuild & 1)!=0)
  16418. this.doDraw();
  16419. if((this._needRebuild & 2)!=0 && this._fillMethod!=0)
  16420. this.doFill();
  16421. this._needRebuild=0;
  16422. }
  16423. __proto.doDraw=function(){
  16424. var w=this.width;
  16425. var h=this.height;
  16426. var g=this.graphics;
  16427. g.clear();
  16428. if(this._tex==null || w==0 || h==0){
  16429. return;
  16430. }
  16431. if(this._scaleByTile){
  16432. g.fillTexture(this._tex,0,0,w,h);
  16433. }
  16434. else if(this._scale9Grid!=null){
  16435. var tw=this._tex.width;
  16436. var th=this._tex.height;
  16437. var left=this._scale9Grid.x;
  16438. var right=Math.max(tw-this._scale9Grid.right,0);
  16439. var top=this._scale9Grid.y;
  16440. var bottom=Math.max(th-this._scale9Grid.bottom,0);
  16441. var tmp=NaN;
  16442. if (h >=(th-this._scale9Grid.height)){
  16443. top=this._scale9Grid.y;
  16444. bottom=th-this._scale9Grid.bottom;
  16445. }
  16446. else{
  16447. tmp=this._scale9Grid.y / (th-this._scale9Grid.bottom);
  16448. tmp=h *tmp / (1+tmp);
  16449. top=Math.round(tmp);
  16450. bottom=h-tmp;
  16451. }
  16452. if (w >=(tw-this._scale9Grid.width)){
  16453. left=this._scale9Grid.x;
  16454. right=tw-this._scale9Grid.right;
  16455. }
  16456. else{
  16457. tmp=this._scale9Grid.x / (tw-this._scale9Grid.right);
  16458. tmp=w *tmp / (1+tmp);
  16459. left=Math.round(tmp);
  16460. right=w-tmp;
  16461. };
  16462. var centerWidth=Math.max(w-left-right,0);
  16463. var centerHeight=Math.max(h-top-bottom,0);
  16464. left && top && g.drawImage(fairygui.display.Image.getTexture(this._tex,0,0,left,top),0,0,left,top);
  16465. right && top && g.drawImage(fairygui.display.Image.getTexture(this._tex,tw-right,0,right,top),w-right,0,right,top);
  16466. left && bottom && g.drawImage(fairygui.display.Image.getTexture(this._tex,0,th-bottom,left,bottom),0,h-bottom,left,bottom);
  16467. right && bottom && g.drawImage(fairygui.display.Image.getTexture(this._tex,tw-right,th-bottom,right,bottom),w-right,h-bottom,right,bottom);
  16468. centerWidth && top && this.drawTexture(0,fairygui.display.Image.getTexture(this._tex,left,0,tw-left-right,top),left,0,centerWidth,top);
  16469. centerWidth && bottom && this.drawTexture(1,fairygui.display.Image.getTexture(this._tex,left,th-bottom,tw-left-right,bottom),left,h-bottom,centerWidth,bottom);
  16470. centerHeight && left && this.drawTexture(2,fairygui.display.Image.getTexture(this._tex,0,top,left,th-top-bottom),0,top,left,centerHeight);
  16471. centerHeight && right && this.drawTexture(3,fairygui.display.Image.getTexture(this._tex,tw-right,top,right,th-top-bottom),w-right,top,right,centerHeight);
  16472. centerWidth && centerHeight && this.drawTexture(4,fairygui.display.Image.getTexture(this._tex,left,top,tw-left-right,th-top-bottom),left,top,centerWidth,centerHeight);
  16473. }
  16474. else {
  16475. g.drawImage(this._tex,0,0,w,h);
  16476. }
  16477. }
  16478. __proto.drawTexture=function(part,tex,x,y,width,height){
  16479. (width===void 0)&& (width=0);
  16480. (height===void 0)&& (height=0);
  16481. if(part==-1 || (this._tileGridIndice & (1<<part))==0)
  16482. this.graphics.drawImage(tex,x,y,width,height);
  16483. else
  16484. this.graphics.fillTexture(tex,x,y,width,height);
  16485. }
  16486. __proto.doFill=function(){
  16487. var w=this.width;
  16488. var h=this.height;
  16489. var g=this._mask.graphics;
  16490. g.clear();
  16491. if(w==0 || h==0)
  16492. return;
  16493. var points=FillUtils.fill(w,h,this._fillMethod,this._fillOrigin,this._fillClockwise,this._fillAmount);
  16494. if(points==null){
  16495. this.mask=null;
  16496. this.mask=this._mask;
  16497. return;
  16498. }
  16499. g.drawPoly(0,0,points,"#FFFFFF");
  16500. }
  16501. __getset(0,__proto,'fillClockwise',function(){
  16502. return this._fillClockwise;
  16503. },function(value){
  16504. if(this._fillClockwise!=value){
  16505. this._fillClockwise=value;
  16506. if(this._fillMethod!=0)
  16507. this.markChanged(2);
  16508. }
  16509. });
  16510. __getset(0,__proto,'tex',function(){
  16511. return this._tex;
  16512. },function(value){
  16513. if(this._tex!=value){
  16514. this._tex=value;
  16515. if(this._tex)
  16516. this.size(this._tex.width*this._textureScaleX,this._tex.height*this._textureScaleY);
  16517. else
  16518. this.size(0,0);
  16519. this.markChanged(1);
  16520. }
  16521. });
  16522. __getset(0,__proto,'scale9Grid',function(){
  16523. return this._scale9Grid;
  16524. },function(value){
  16525. this._scale9Grid=value;
  16526. this.markChanged(1);
  16527. });
  16528. __getset(0,__proto,'fillAmount',function(){
  16529. return this._fillAmount;
  16530. },function(value){
  16531. if(this._fillAmount!=value){
  16532. this._fillAmount=value;
  16533. if(this._fillMethod!=0)
  16534. this.markChanged(2);
  16535. }
  16536. });
  16537. __getset(0,__proto,'scaleByTile',function(){
  16538. return this._scaleByTile;
  16539. },function(value){
  16540. if(this._scaleByTile!=value){
  16541. this._scaleByTile=value;
  16542. this.markChanged(1);
  16543. }
  16544. });
  16545. __getset(0,__proto,'tileGridIndice',function(){
  16546. return this._tileGridIndice;
  16547. },function(value){
  16548. if(this._tileGridIndice!=value){
  16549. this._tileGridIndice=value;
  16550. this.markChanged(1);
  16551. }
  16552. });
  16553. __getset(0,__proto,'fillMethod',function(){
  16554. return this._fillMethod;
  16555. },function(value){
  16556. if(this._fillMethod!=value){
  16557. this._fillMethod=value;
  16558. if(this._fillMethod!=0){
  16559. if(!this._mask){
  16560. this._mask=new Sprite();
  16561. this._mask.mouseEnabled=false;
  16562. }
  16563. this.mask=this._mask;
  16564. this.markChanged(2);
  16565. }
  16566. else if(this.mask){
  16567. this._mask.graphics.clear();
  16568. this.mask=null;
  16569. }
  16570. }
  16571. });
  16572. __getset(0,__proto,'fillOrigin',function(){
  16573. return this._fillOrigin;
  16574. },function(value){
  16575. if(this._fillOrigin!=value){
  16576. this._fillOrigin=value;
  16577. if(this._fillMethod!=0)
  16578. this.markChanged(2);
  16579. }
  16580. });
  16581. Image.getTexture=function(tex,x,y,width,height){
  16582. if (width <=0)width=1;
  16583. if (height <=0)height=1;
  16584. tex.$_GID || (tex.$_GID=Utils.getGID())
  16585. var texture;
  16586. if (!texture||!texture._getSource()){
  16587. texture=Texture.createFromTexture(tex,x,y,width,height);
  16588. }
  16589. return texture;
  16590. }
  16591. return Image;
  16592. })(Sprite)
  16593. //class fairygui.display.MovieClip extends laya.display.Sprite
  16594. var MovieClip$1=(function(_super){
  16595. function MovieClip(){
  16596. this.interval=0;
  16597. this.swing=false;
  16598. this.repeatDelay=0;
  16599. this.timeScale=1;
  16600. this._$3__texture=null;
  16601. this._needRebuild=false;
  16602. this._playing=true;
  16603. this._frameCount=0;
  16604. this._frames=null;
  16605. this._frame=0;
  16606. this._boundsRect=null;
  16607. this._start=0;
  16608. this._end=0;
  16609. this._times=0;
  16610. this._endAt=0;
  16611. this._status=0;
  16612. //0-none,1-next loop,2-ending,3-ended
  16613. this._endHandler=null;
  16614. this._frameElapsed=0;
  16615. //当前帧延迟
  16616. this._reversed=false;
  16617. this._repeatedCount=0;
  16618. MovieClip.__super.call(this);
  16619. this.mouseEnabled=false;
  16620. this.setPlaySettings();
  16621. this.on("display",this,this.__addToStage);
  16622. this.on("undisplay",this,this.__removeFromStage);
  16623. }
  16624. __class(MovieClip,'fairygui.display.MovieClip',_super,'MovieClip$1');
  16625. var __proto=MovieClip.prototype;
  16626. //从start帧开始,播放到end帧(-1表示结尾),重复times次(0表示无限循环),循环结束后,停止在endAt帧(-1表示参数end)
  16627. __proto.rewind=function(){
  16628. this._frame=0;
  16629. this._frameElapsed=0;
  16630. this._reversed=false;
  16631. this._repeatedCount=0;
  16632. this.drawFrame();
  16633. }
  16634. __proto.syncStatus=function(anotherMc){
  16635. this._frame=anotherMc._frame;
  16636. this._frameElapsed=anotherMc._frameElapsed;
  16637. this._reversed=anotherMc._reversed;
  16638. this._repeatedCount=anotherMc._repeatedCount;
  16639. this.drawFrame();
  16640. }
  16641. __proto.advance=function(timeInMiniseconds){
  16642. var beginFrame=this._frame;
  16643. var beginReversed=this._reversed;
  16644. var backupTime=timeInMiniseconds;
  16645. while (true){
  16646. var tt=this.interval+this._frames[this._frame].addDelay;
  16647. if (this._frame==0 && this._repeatedCount > 0)
  16648. tt+=this.repeatDelay;
  16649. if (timeInMiniseconds < tt){
  16650. this._frameElapsed=0;
  16651. break ;
  16652. }
  16653. timeInMiniseconds-=tt;
  16654. if (this.swing){
  16655. if (this._reversed){
  16656. this._frame--;
  16657. if (this._frame <=0){
  16658. this._frame=0;
  16659. this._repeatedCount++;
  16660. this._reversed=!this._reversed;
  16661. }
  16662. }
  16663. else{
  16664. this._frame++;
  16665. if (this._frame > this._frameCount-1){
  16666. this._frame=Math.max(0,this._frameCount-2);
  16667. this._repeatedCount++;
  16668. this._reversed=!this._reversed;
  16669. }
  16670. }
  16671. }
  16672. else{
  16673. this._frame++;
  16674. if (this._frame > this._frameCount-1){
  16675. this._frame=0;
  16676. this._repeatedCount++;
  16677. }
  16678. }
  16679. if (this._frame==beginFrame && this._reversed==beginReversed){
  16680. var roundTime=backupTime-timeInMiniseconds;
  16681. timeInMiniseconds-=Math.floor(timeInMiniseconds / roundTime)*roundTime;
  16682. }
  16683. }
  16684. this.drawFrame();
  16685. }
  16686. //从start帧开始,播放到end帧(-1表示结尾),重复times次(0表示无限循环),循环结束后,停止在endAt帧(-1表示参数end)
  16687. __proto.setPlaySettings=function(start,end,times,endAt,endHandler){
  16688. (start===void 0)&& (start=0);
  16689. (end===void 0)&& (end=-1);
  16690. (times===void 0)&& (times=0);
  16691. (endAt===void 0)&& (endAt=-1);
  16692. this._start=start;
  16693. this._end=end;
  16694. if(this._end==-1 || this._end>this._frameCount-1)
  16695. this._end=this._frameCount-1;
  16696. this._times=times;
  16697. this._endAt=endAt;
  16698. if (this._endAt==-1)
  16699. this._endAt=this._end;
  16700. this._status=0;
  16701. this._endHandler=endHandler;
  16702. this.frame=start;
  16703. }
  16704. __proto.update=function(bo){
  16705. (bo===void 0)&& (bo=true);
  16706. if ((!this._playing&&bo) || this._frameCount==0 || this._status==3)
  16707. return;
  16708. var dt=Laya.timer.delta;
  16709. if(dt>100)
  16710. dt=100;
  16711. if(this.timeScale!=1)
  16712. dt *=this.timeScale;
  16713. this._frameElapsed+=dt;
  16714. var tt=this.interval+this._frames[this._frame].addDelay;
  16715. if (this._frame==0 && this._repeatedCount > 0)
  16716. tt+=this.repeatDelay;
  16717. if (this._frameElapsed < tt)
  16718. return;
  16719. this._frameElapsed-=tt;
  16720. if (this._frameElapsed > this.interval)
  16721. this._frameElapsed=this.interval;
  16722. if (this.swing){
  16723. if (this._reversed){
  16724. this._frame--;
  16725. if (this._frame <=0){
  16726. this._frame=0;
  16727. this._repeatedCount++;
  16728. this._reversed=!this._reversed;
  16729. }
  16730. }
  16731. else{
  16732. this._frame++;
  16733. if (this._frame > this._frameCount-1){
  16734. this._frame=Math.max(0,this._frameCount-2);
  16735. this._repeatedCount++;
  16736. this._reversed=!this._reversed;
  16737. }
  16738. }
  16739. }
  16740. else{
  16741. this._frame++;
  16742. if (this._frame > this._frameCount-1){
  16743. this._frame=0;
  16744. this._repeatedCount++;
  16745. }
  16746. }
  16747. if (this._status==1){
  16748. this._frame=this._start;
  16749. this._frameElapsed=0;
  16750. this._status=0;
  16751. }
  16752. else if (this._status==2){
  16753. this._frame=this._endAt;
  16754. this._frameElapsed=0;
  16755. this._status=3;
  16756. if(this._endHandler!=null){
  16757. var handler=this._endHandler;
  16758. this._endHandler=null;
  16759. handler.run();
  16760. }
  16761. }
  16762. else{
  16763. if (this._frame==this._end){
  16764. if (this._times > 0){
  16765. this._times--;
  16766. if (this._times==0)
  16767. this._status=2;
  16768. else
  16769. this._status=1;
  16770. }
  16771. else if (this._start !=0)
  16772. this._status=1;
  16773. }
  16774. }
  16775. this.drawFrame();
  16776. }
  16777. __proto.drawFrame=function(){
  16778. if (this._frameCount>0 && this._frame < this._frames.length){
  16779. var frame=this._frames[this._frame];
  16780. this.graphics.clear();
  16781. this.graphics.drawImage(frame.texture,frame.rect.x,frame.rect.y);
  16782. }
  16783. else
  16784. this.graphics.clear();
  16785. }
  16786. __proto.checkTimer=function(){
  16787. if (this._playing && this._frameCount>0 && this.stage!=null)
  16788. Laya.timer.frameLoop(1,this,this.update);
  16789. else
  16790. Laya.timer.clear(this,this.update);
  16791. }
  16792. __proto.__addToStage=function(){
  16793. if(this._playing && this._frameCount>0)
  16794. Laya.timer.frameLoop(1,this,this.update);
  16795. }
  16796. __proto.__removeFromStage=function(){
  16797. Laya.timer.clear(this,this.update);
  16798. }
  16799. __getset(0,__proto,'frames',function(){
  16800. return this._frames;
  16801. },function(value){
  16802. this._frames=value;
  16803. if (this._frames !=null)
  16804. this._frameCount=this._frames.length;
  16805. else
  16806. this._frameCount=0;
  16807. if(this._end==-1 || this._end > this._frameCount-1)
  16808. this._end=this._frameCount-1;
  16809. if(this._endAt==-1 || this._endAt > this._frameCount-1)
  16810. this._endAt=this._frameCount-1;
  16811. if(this._frame < 0 || this._frame > this._frameCount-1)
  16812. this._frame=this._frameCount-1;
  16813. this.drawFrame();
  16814. this._frameElapsed=0;
  16815. this._repeatedCount=0;
  16816. this._reversed=false;
  16817. this.checkTimer();
  16818. });
  16819. __getset(0,__proto,'playing',function(){
  16820. return this._playing;
  16821. },function(value){
  16822. if(this._playing!=value){
  16823. this._playing=value;
  16824. this.checkTimer();
  16825. }
  16826. });
  16827. __getset(0,__proto,'frameCount',function(){
  16828. return this._frameCount;
  16829. });
  16830. __getset(0,__proto,'frame',function(){
  16831. return this._frame;
  16832. },function(value){
  16833. if (this._frame !=value){
  16834. if(this._frames!=null && value>=this._frameCount)
  16835. value=this._frameCount-1;
  16836. this._frame=value;
  16837. this._frameElapsed=0;
  16838. this.drawFrame();
  16839. }
  16840. });
  16841. __getset(0,__proto,'boundsRect',function(){
  16842. return this._boundsRect;
  16843. },function(value){
  16844. this._boundsRect=value;
  16845. });
  16846. return MovieClip;
  16847. })(Sprite)
  16848. Laya.__init([GBasicTextField,GList,AsyncOperation,GearLook,UIPackage,GearColor,Transition,EaseManager,GearAnimation,GearSize,RelationItem]);
  16849. })(window,document,Laya);