fairygui.js 457 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183
  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. if(this._displayObject){
  1245. this._displayObject.pos(xv+this._pivotOffsetX,yv+this._pivotOffsetY);
  1246. }
  1247. }
  1248. __proto.handleSizeChanged=function(){
  1249. if(this._displayObject!=null){
  1250. if(this._sizeImplType==0 || this.sourceWidth==0 || this.sourceHeight==0)
  1251. this._displayObject.size(this._width,this._height);
  1252. else
  1253. this._displayObject.scale(this._width/this.sourceWidth*this._scaleX,
  1254. this._height/this.sourceHeight*this._scaleY);
  1255. }
  1256. }
  1257. __proto.handleScaleChanged=function(){
  1258. if(this._displayObject!=null){
  1259. if(this._sizeImplType==0 || this.sourceWidth==0 || this.sourceHeight==0)
  1260. this._displayObject.scale(this._scaleX,this._scaleY);
  1261. else
  1262. this._displayObject.scale(this._width/this.sourceWidth*this._scaleX,
  1263. this._height/this.sourceHeight*this._scaleY);
  1264. }
  1265. }
  1266. __proto.handleGrayedChanged=function(){
  1267. if(this._displayObject){
  1268. if(this._grayed){
  1269. if(GObject.grayFilter==null)
  1270. 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]);
  1271. this._displayObject.filters=[GObject.grayFilter];
  1272. }
  1273. else
  1274. this._displayObject.filters=null;
  1275. }
  1276. }
  1277. __proto.handleAlphaChanged=function(){
  1278. if(this._displayObject)
  1279. this._displayObject.alpha=this._alpha;
  1280. }
  1281. __proto.handleVisibleChanged=function(){
  1282. if(this._displayObject)
  1283. this._displayObject.visible=this.internalVisible2;
  1284. }
  1285. __proto.constructFromResource=function(){}
  1286. __proto.setup_beforeAdd=function(buffer,beginPos){
  1287. buffer.seek(beginPos,0);
  1288. buffer.skip(5);
  1289. var f1=NaN;
  1290. var f2=NaN;
  1291. this._id=buffer.readS();
  1292. this._name=buffer.readS();
  1293. f1=buffer.getInt32();
  1294. f2=buffer.getInt32();
  1295. this.setXY(f1,f2);
  1296. if (buffer.readBool()){
  1297. this.initWidth=buffer.getInt32();
  1298. this.initHeight=buffer.getInt32();
  1299. this.setSize(this.initWidth,this.initHeight,true);
  1300. }
  1301. if (buffer.readBool()){
  1302. this.minWidth=buffer.getInt32();
  1303. this.maxWidth=buffer.getInt32();
  1304. this.minHeight=buffer.getInt32();
  1305. this.maxHeight=buffer.getInt32();
  1306. }
  1307. if (buffer.readBool()){
  1308. f1=buffer.getFloat32();
  1309. f2=buffer.getFloat32();
  1310. this.setScale(f1,f2);
  1311. }
  1312. if (buffer.readBool()){
  1313. f1=buffer.getFloat32();
  1314. f2=buffer.getFloat32();
  1315. this.setSkew(f1,f2);
  1316. }
  1317. if (buffer.readBool()){
  1318. f1=buffer.getFloat32();
  1319. f2=buffer.getFloat32();
  1320. this.setPivot(f1,f2,buffer.readBool());
  1321. }
  1322. f1=buffer.getFloat32();
  1323. if (f1 !=1)
  1324. this.alpha=f1;
  1325. f1=buffer.getFloat32();
  1326. if (f1 !=0)
  1327. this.rotation=f1;
  1328. if (!buffer.readBool())
  1329. this.visible=false;
  1330. if (!buffer.readBool())
  1331. this.touchable=false;
  1332. if (buffer.readBool())
  1333. this.grayed=true;
  1334. var bm=buffer.readByte();
  1335. if(bm==2)
  1336. this.blendMode="lighter";
  1337. var filter=buffer.readByte();
  1338. if (filter==1){
  1339. var cm=new ColorMatrix();
  1340. cm.adjustBrightness(buffer.getFloat32());
  1341. cm.adjustContrast(buffer.getFloat32());
  1342. cm.adjustSaturation(buffer.getFloat32());
  1343. cm.adjustHue(buffer.getFloat32());
  1344. var cf=new ColorFilter(cm);
  1345. this.filters=[cf];
  1346. };
  1347. var str=buffer.readS();
  1348. if (str !=null)
  1349. this.data=str;
  1350. }
  1351. __proto.setup_afterAdd=function(buffer,beginPos){
  1352. buffer.seek(beginPos,1);
  1353. var str=buffer.readS();
  1354. if (str !=null)
  1355. this.tooltips=str;
  1356. var groupId=buffer.getInt16();
  1357. if (groupId >=0)
  1358. this.group=this.parent.getChildAt(groupId);
  1359. buffer.seek(beginPos,2);
  1360. var cnt=buffer.getInt16();
  1361. for (var i=0;i < cnt;i++){
  1362. var nextPos=buffer.getInt16();
  1363. nextPos+=buffer.pos;
  1364. var gear=this.getGear(buffer.readByte());
  1365. gear.setup(buffer);
  1366. buffer.pos=nextPos;
  1367. }
  1368. }
  1369. __proto.initDrag=function(){
  1370. if (this._draggable)
  1371. this.on("mousedown",this,this.__begin);
  1372. else
  1373. this.off("mousedown",this,this.__begin);
  1374. }
  1375. __proto.dragBegin=function(){
  1376. if (fairygui.GObject.draggingObject !=null)
  1377. fairygui.GObject.draggingObject.stopDrag();
  1378. fairygui.GObject.sGlobalDragStart.x=Laya.stage.mouseX;
  1379. fairygui.GObject.sGlobalDragStart.y=Laya.stage.mouseY;
  1380. this.localToGlobalRect(0,0,this.width,this.height,fairygui.GObject.sGlobalRect);
  1381. fairygui.GObject.draggingObject=this;
  1382. Laya.stage.on("mousemove",this,this.__moving2);
  1383. Laya.stage.on("mouseup",this,this.__end2);
  1384. }
  1385. __proto.dragEnd=function(){
  1386. if (fairygui.GObject.draggingObject==this){
  1387. Laya.stage.off("mousemove",this,this.__moving2);
  1388. Laya.stage.off("mouseup",this,this.__end2);
  1389. fairygui.GObject.draggingObject=null;
  1390. }
  1391. fairygui.GObject.sDraggingQuery=false;
  1392. }
  1393. __proto.reset=function(){
  1394. Laya.stage.off("mousemove",this,this.__moving);
  1395. Laya.stage.off("mouseup",this,this.__end);
  1396. }
  1397. __proto.__begin=function(){
  1398. if(this._touchDownPoint==null)
  1399. this._touchDownPoint=new Point();
  1400. this._touchDownPoint.x=Laya.stage.mouseX;
  1401. this._touchDownPoint.y=Laya.stage.mouseY;
  1402. Laya.stage.on("mousemove",this,this.__moving);
  1403. Laya.stage.on("mouseup",this,this.__end);
  1404. }
  1405. __proto.__end=function(){
  1406. this.reset();
  1407. }
  1408. __proto.__moving=function(evt){
  1409. var sensitivity=UIConfig$1.touchDragSensitivity;
  1410. if(this._touchDownPoint !=null
  1411. && Math.abs(this._touchDownPoint.x-Laya.stage.mouseX)< sensitivity
  1412. && Math.abs(this._touchDownPoint.y-Laya.stage.mouseY)< sensitivity)
  1413. return;
  1414. this.reset();
  1415. fairygui.GObject.sDraggingQuery=true;
  1416. Events.dispatch("fui_drag_start",this._displayObject,evt);
  1417. if (fairygui.GObject.sDraggingQuery)
  1418. this.dragBegin();
  1419. }
  1420. __proto.__moving2=function(evt){
  1421. var xx=Laya.stage.mouseX-fairygui.GObject.sGlobalDragStart.x+fairygui.GObject.sGlobalRect.x;
  1422. var yy=Laya.stage.mouseY-fairygui.GObject.sGlobalDragStart.y+fairygui.GObject.sGlobalRect.y;
  1423. if(this._dragBounds !=null){
  1424. var rect=GRoot.inst.localToGlobalRect(this._dragBounds.x,this._dragBounds.y,
  1425. this._dragBounds.width,this._dragBounds.height,fairygui.GObject.sDragHelperRect);
  1426. if(xx < rect.x)
  1427. xx=rect.x;
  1428. else if(xx+fairygui.GObject.sGlobalRect.width > rect.right){
  1429. xx=rect.right-fairygui.GObject.sGlobalRect.width;
  1430. if(xx < rect.x)
  1431. xx=rect.x;
  1432. }
  1433. if(yy < rect.y)
  1434. yy=rect.y;
  1435. else if(yy+fairygui.GObject.sGlobalRect.height > rect.bottom){
  1436. yy=rect.bottom-fairygui.GObject.sGlobalRect.height;
  1437. if(yy < rect.y)
  1438. yy=rect.y;
  1439. }
  1440. }
  1441. GObject.sUpdateInDragging=true;
  1442. var pt=this.parent.globalToLocal(xx,yy,fairygui.GObject.sHelperPoint);
  1443. this.setXY(Math.round(pt.x),Math.round(pt.y));
  1444. GObject.sUpdateInDragging=false;
  1445. Events.dispatch("fui_drag_move",this._displayObject,evt);
  1446. }
  1447. __proto.__end2=function(evt){
  1448. if (fairygui.GObject.draggingObject==this){
  1449. this.stopDrag();
  1450. Events.dispatch("fui_drag_end",this._displayObject,evt);
  1451. }
  1452. }
  1453. __getset(0,__proto,'yMin',function(){
  1454. return this._pivotAsAnchor ? (this._y-this._height *this._pivotY):this._y;
  1455. },function(value){
  1456. if (this._pivotAsAnchor)
  1457. this.setXY(this._x,value+this._height *this._pivotY);
  1458. else
  1459. this.setXY(this._x,value);
  1460. });
  1461. __getset(0,__proto,'id',function(){
  1462. return this._id;
  1463. });
  1464. __getset(0,__proto,'name',function(){
  1465. return this._name;
  1466. },function(value){
  1467. this._name=value;
  1468. });
  1469. __getset(0,__proto,'rotation',function(){
  1470. return this._rotation;
  1471. },function(value){
  1472. if(this._rotation !=value){
  1473. this._rotation=value;
  1474. if(this._displayObject!=null){
  1475. this._displayObject.rotation=this.normalizeRotation;
  1476. this.applyPivot();
  1477. }
  1478. this.updateGear(3);
  1479. }
  1480. });
  1481. __getset(0,__proto,'width',function(){
  1482. this.ensureSizeCorrect();
  1483. if(this._relations.sizeDirty)
  1484. this._relations.ensureRelationsSizeCorrect();
  1485. return this._width;
  1486. },function(value){
  1487. this.setSize(value,this._rawHeight);
  1488. });
  1489. __getset(0,__proto,'x',function(){
  1490. return this._x;
  1491. },function(value){
  1492. this.setXY(value,this._y);
  1493. });
  1494. __getset(0,__proto,'draggable',function(){
  1495. return this._draggable;
  1496. },function(value){
  1497. if (this._draggable !=value){
  1498. this._draggable=value;
  1499. this.initDrag();
  1500. }
  1501. });
  1502. __getset(0,__proto,'y',function(){
  1503. return this._y;
  1504. },function(value){
  1505. this.setXY(this._x,value);
  1506. });
  1507. __getset(0,__proto,'gearXY',function(){
  1508. return (this.getGear(1));
  1509. });
  1510. __getset(0,__proto,'xMin',function(){
  1511. return this._pivotAsAnchor ? (this._x-this._width *this._pivotX):this._x;
  1512. },function(value){
  1513. if (this._pivotAsAnchor)
  1514. this.setXY(value+this._width *this._pivotX,this._y);
  1515. else
  1516. this.setXY(value,this._y);
  1517. });
  1518. __getset(0,__proto,'pixelSnapping',function(){
  1519. return this._pixelSnapping;
  1520. },function(value){
  1521. if(this._pixelSnapping!=value){
  1522. this._pixelSnapping=value;
  1523. this.handleXYChanged();
  1524. }
  1525. });
  1526. __getset(0,__proto,'height',function(){
  1527. this.ensureSizeCorrect();
  1528. if(this._relations.sizeDirty)
  1529. this._relations.ensureRelationsSizeCorrect();
  1530. return this._height;
  1531. },function(value){
  1532. this.setSize(this._rawWidth,value);
  1533. });
  1534. __getset(0,__proto,'asButton',function(){
  1535. return this;
  1536. });
  1537. __getset(0,__proto,'actualWidth',function(){
  1538. return this.width *Math.abs(this._scaleX);
  1539. });
  1540. __getset(0,__proto,'actualHeight',function(){
  1541. return this.height *Math.abs(this._scaleY);
  1542. });
  1543. __getset(0,__proto,'blendMode',function(){
  1544. return this._displayObject.blendMode;
  1545. },function(value){
  1546. this._displayObject.blendMode=value;
  1547. });
  1548. __getset(0,__proto,'scaleX',function(){
  1549. return this._scaleX;
  1550. },function(value){
  1551. this.setScale(value,this._scaleY);
  1552. });
  1553. __getset(0,__proto,'scaleY',function(){
  1554. return this._scaleY;
  1555. },function(value){
  1556. this.setScale(this._scaleX,value);
  1557. });
  1558. __getset(0,__proto,'skewX',function(){
  1559. return this._skewX;
  1560. },function(value){
  1561. this.setSkew(value,this._skewY);
  1562. });
  1563. __getset(0,__proto,'pivotAsAnchor',function(){
  1564. return this._pivotAsAnchor;
  1565. });
  1566. __getset(0,__proto,'skewY',function(){
  1567. return this._skewY;
  1568. },function(value){
  1569. this.setSkew(this._skewX,value);
  1570. });
  1571. __getset(0,__proto,'pivotX',function(){
  1572. return this._pivotX;
  1573. },function(value){
  1574. this.setPivot(value,this._pivotY);
  1575. });
  1576. __getset(0,__proto,'asLoader',function(){
  1577. return this;
  1578. });
  1579. __getset(0,__proto,'asTextInput',function(){
  1580. return this;
  1581. });
  1582. __getset(0,__proto,'displayObject',function(){
  1583. return this._displayObject;
  1584. });
  1585. __getset(0,__proto,'normalizeRotation',function(){
  1586. var rot=this._rotation % 360;
  1587. if(rot > 180)
  1588. rot=rot-360;
  1589. else if(rot <-180)
  1590. rot=360+rot;
  1591. return rot;
  1592. });
  1593. __getset(0,__proto,'pivotY',function(){
  1594. return this._pivotY;
  1595. },function(value){
  1596. this.setPivot(this._pivotX,value);
  1597. });
  1598. __getset(0,__proto,'touchable',function(){
  1599. return this._touchable;
  1600. },function(value){
  1601. if(this._touchable!=value){
  1602. this._touchable=value;
  1603. this.updateGear(3);
  1604. if(((this instanceof fairygui.GImage ))|| ((this instanceof fairygui.GMovieClip ))
  1605. || ((this instanceof fairygui.GTextField ))&& !((this instanceof fairygui.GTextInput ))&& !((this instanceof fairygui.GRichTextField )))
  1606. return;
  1607. if(this._displayObject !=null)
  1608. this._displayObject.mouseEnabled=this._touchable;
  1609. }
  1610. });
  1611. __getset(0,__proto,'alpha',function(){
  1612. return this._alpha;
  1613. },function(value){
  1614. if(this._alpha!=value){
  1615. this._alpha=value;
  1616. this.handleAlphaChanged();
  1617. this.updateGear(3);
  1618. }
  1619. });
  1620. __getset(0,__proto,'grayed',function(){
  1621. return this._grayed;
  1622. },function(value){
  1623. if(this._grayed !=value){
  1624. this._grayed=value;
  1625. this.handleGrayedChanged();
  1626. this.updateGear(3);
  1627. }
  1628. });
  1629. __getset(0,__proto,'dragBounds',function(){
  1630. return this._dragBounds;
  1631. },function(value){
  1632. this._dragBounds=value;
  1633. });
  1634. __getset(0,__proto,'asProgress',function(){
  1635. return this;
  1636. });
  1637. __getset(0,__proto,'enabled',function(){
  1638. return !this._grayed && this._touchable;
  1639. },function(value){
  1640. this.grayed=!value;
  1641. this.touchable=value;
  1642. });
  1643. __getset(0,__proto,'sortingOrder',function(){
  1644. return this._sortingOrder;
  1645. },function(value){
  1646. if (value < 0)
  1647. value=0;
  1648. if (this._sortingOrder !=value){
  1649. var old=this._sortingOrder;
  1650. this._sortingOrder=value;
  1651. if (this._parent !=null)
  1652. this._parent.childSortingOrderChanged(this,old,this._sortingOrder);
  1653. }
  1654. });
  1655. __getset(0,__proto,'visible',function(){
  1656. return this._visible;
  1657. },function(value){
  1658. if (this._visible !=value){
  1659. this._visible=value;
  1660. this.handleVisibleChanged();
  1661. if (this._parent)
  1662. this._parent.setBoundsChangedFlag();
  1663. }
  1664. });
  1665. __getset(0,__proto,'internalVisible',function(){
  1666. return this._internalVisible && (!this._group || this._group.internalVisible)
  1667. && !this._displayObject._cacheStyle.maskParent;
  1668. });
  1669. __getset(0,__proto,'icon',function(){
  1670. return null;
  1671. },function(value){
  1672. });
  1673. __getset(0,__proto,'internalVisible2',function(){
  1674. return this._visible && (!this._group || this._group.internalVisible2);
  1675. });
  1676. __getset(0,__proto,'asGraph',function(){
  1677. return this;
  1678. });
  1679. __getset(0,__proto,'gearSize',function(){
  1680. return (this.getGear(2));
  1681. });
  1682. __getset(0,__proto,'focusable',function(){
  1683. return this._focusable;
  1684. },function(value){
  1685. this._focusable=value;
  1686. });
  1687. __getset(0,__proto,'focused',function(){
  1688. return this.root.focus==this;
  1689. });
  1690. __getset(0,__proto,'tooltips',function(){
  1691. return this._tooltips;
  1692. },function(value){
  1693. if(this._tooltips){
  1694. this.off("mouseover",this,this.__rollOver);
  1695. this.off("mouseout",this,this.__rollOut);
  1696. }
  1697. this._tooltips=value;
  1698. if(this._tooltips){
  1699. this.on("mouseover",this,this.__rollOver);
  1700. this.on("mouseout",this,this.__rollOut);
  1701. }
  1702. });
  1703. __getset(0,__proto,'dragging',function(){
  1704. return fairygui.GObject.draggingObject==this;
  1705. });
  1706. __getset(0,__proto,'group',function(){
  1707. return this._group;
  1708. },function(value){
  1709. if (this._group !=value){
  1710. if (this._group !=null)
  1711. this._group.setBoundsChangedFlag(true);
  1712. this._group=value;
  1713. if (this._group !=null)
  1714. this._group.setBoundsChangedFlag(true);
  1715. }
  1716. });
  1717. __getset(0,__proto,'filters',function(){
  1718. return this._displayObject.filters;
  1719. },function(value){
  1720. this._displayObject.filters=value;
  1721. });
  1722. __getset(0,__proto,'inContainer',function(){
  1723. return this._displayObject !=null && this._displayObject.parent !=null;
  1724. });
  1725. __getset(0,__proto,'resourceURL',function(){
  1726. if (this.packageItem !=null)
  1727. return "ui://"+this.packageItem.owner.id+this.packageItem.id;
  1728. else
  1729. return null;
  1730. });
  1731. __getset(0,__proto,'onStage',function(){
  1732. return this._displayObject !=null && this._displayObject.stage !=null;
  1733. });
  1734. __getset(0,__proto,'root',function(){
  1735. if((this instanceof fairygui.GRoot ))
  1736. return (this);
  1737. var p=this._parent;
  1738. while (p){
  1739. if ((p instanceof fairygui.GRoot ))
  1740. return (p);
  1741. p=p.parent;
  1742. }
  1743. return GRoot.inst;
  1744. });
  1745. __getset(0,__proto,'gearLook',function(){
  1746. return (this.getGear(3));
  1747. });
  1748. __getset(0,__proto,'asCom',function(){
  1749. return this;
  1750. });
  1751. __getset(0,__proto,'relations',function(){
  1752. return this._relations;
  1753. });
  1754. __getset(0,__proto,'parent',function(){
  1755. return this._parent;
  1756. },function(val){
  1757. this._parent=val;
  1758. });
  1759. __getset(0,__proto,'asLabel',function(){
  1760. return this;
  1761. });
  1762. __getset(0,__proto,'asImage',function(){
  1763. return this;
  1764. });
  1765. __getset(0,__proto,'asTextField',function(){
  1766. return this;
  1767. });
  1768. __getset(0,__proto,'asGroup',function(){
  1769. return this;
  1770. });
  1771. __getset(0,__proto,'asRichTextField',function(){
  1772. return this;
  1773. });
  1774. __getset(0,__proto,'asList',function(){
  1775. return this;
  1776. });
  1777. __getset(0,__proto,'asSlider',function(){
  1778. return this;
  1779. });
  1780. __getset(0,__proto,'asComboBox',function(){
  1781. return this;
  1782. });
  1783. __getset(0,__proto,'asMovieClip',function(){
  1784. return this;
  1785. });
  1786. __getset(0,__proto,'text',function(){
  1787. return null;
  1788. },function(value){
  1789. });
  1790. GObject.cast=function(sprite){
  1791. return (sprite["$owner"]);
  1792. }
  1793. GObject.draggingObject=null;
  1794. GObject._gInstanceCounter=0;
  1795. GObject.grayFilter=null;
  1796. GObject.sDraggingQuery=false;
  1797. GObject.sUpdateInDragging=false;
  1798. __static(GObject,
  1799. ['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();}
  1800. ]);
  1801. return GObject;
  1802. })()
  1803. //class fairygui.gears.GearBase
  1804. var GearBase=(function(){
  1805. function GearBase(owner){
  1806. this._owner=null;
  1807. this._controller=null;
  1808. this._tweenConfig=null;
  1809. this._owner=owner;
  1810. }
  1811. __class(GearBase,'fairygui.gears.GearBase');
  1812. var __proto=GearBase.prototype;
  1813. __proto.setup=function(buffer){
  1814. this._controller=this._owner.parent.getControllerAt(buffer.getInt16());
  1815. this.init();
  1816. var cnt=0;
  1817. var i=0;
  1818. var page;
  1819. if ((this instanceof fairygui.gears.GearDisplay )){
  1820. cnt=buffer.getInt16();
  1821. var pages=[];
  1822. for (i=0;i < cnt;i++)
  1823. pages[i]=buffer.readS();
  1824. (this).pages=pages;
  1825. }
  1826. else{
  1827. cnt=buffer.getInt16();
  1828. for (i=0;i < cnt;i++){
  1829. page=buffer.readS();
  1830. if (page==null)
  1831. continue ;
  1832. this.addStatus(page,buffer);
  1833. }
  1834. if (buffer.readBool())
  1835. this.addStatus(null,buffer);
  1836. }
  1837. if (buffer.readBool()){
  1838. this._tweenConfig=new GearTweenConfig();
  1839. this._tweenConfig.easeType=buffer.readByte();
  1840. this._tweenConfig.duration=buffer.getFloat32();
  1841. this._tweenConfig.delay=buffer.getFloat32();
  1842. }
  1843. }
  1844. __proto.updateFromRelations=function(dx,dy){}
  1845. __proto.addStatus=function(pageId,buffer){}
  1846. __proto.init=function(){}
  1847. __proto.apply=function(){}
  1848. __proto.updateState=function(){}
  1849. __getset(0,__proto,'controller',function(){
  1850. return this._controller;
  1851. },function(val){
  1852. if (val !=this._controller){
  1853. this._controller=val;
  1854. if(this._controller)
  1855. this.init();
  1856. }
  1857. });
  1858. __getset(0,__proto,'tweenConfig',function(){
  1859. if(this._tweenConfig==null)
  1860. this._tweenConfig=new GearTweenConfig();
  1861. return this._tweenConfig;
  1862. });
  1863. GearBase.disableAllTweenEffect=false;
  1864. return GearBase;
  1865. })()
  1866. //class fairygui.gears.GearTweenConfig
  1867. var GearTweenConfig=(function(){
  1868. function GearTweenConfig(){
  1869. this.tween=false;
  1870. this.easeType=0;
  1871. this.duration=NaN;
  1872. this.delay=NaN;
  1873. this._displayLockToken=NaN;
  1874. this._tweener=null;
  1875. this.tween=true;
  1876. this.easeType=5;
  1877. this.duration=0.3;
  1878. this.delay=0;
  1879. }
  1880. __class(GearTweenConfig,'fairygui.gears.GearTweenConfig');
  1881. return GearTweenConfig;
  1882. })()
  1883. //class fairygui.GObjectPool
  1884. var GObjectPool=(function(){
  1885. function GObjectPool(){
  1886. this._pool=null;
  1887. this._count=0;
  1888. this._pool={};
  1889. }
  1890. __class(GObjectPool,'fairygui.GObjectPool');
  1891. var __proto=GObjectPool.prototype;
  1892. __proto.clear=function(){
  1893. for (var i1 in this._pool){
  1894. var arr=this._pool[i1];
  1895. var cnt=arr.length;
  1896. for (var i=0;i < cnt;i++)
  1897. arr[i].dispose();
  1898. }
  1899. this._pool={};
  1900. this._count=0;
  1901. }
  1902. __proto.getObject=function(url){
  1903. url=UIPackage.normalizeURL(url);
  1904. if(url==null)
  1905. return null;
  1906. var arr=this._pool[url];
  1907. if (arr !=null && arr.length>0){
  1908. this._count--;
  1909. return arr.shift();
  1910. };
  1911. var child=UIPackage.createObjectFromURL(url);
  1912. return child;
  1913. }
  1914. __proto.returnObject=function(obj){
  1915. var url=obj.resourceURL;
  1916. if (!url)
  1917. return;
  1918. var arr=this._pool[url];
  1919. if (arr==null){
  1920. arr=[];
  1921. this._pool[url]=arr;
  1922. }
  1923. this._count++;
  1924. arr.push(obj);
  1925. }
  1926. __getset(0,__proto,'count',function(){
  1927. return this._count;
  1928. });
  1929. return GObjectPool;
  1930. })()
  1931. /**
  1932. *Use for GGroup.layout
  1933. */
  1934. //class fairygui.GroupLayoutType
  1935. var GroupLayoutType=(function(){
  1936. function GroupLayoutType(){}
  1937. __class(GroupLayoutType,'fairygui.GroupLayoutType');
  1938. GroupLayoutType.None=0;
  1939. GroupLayoutType.Horizontal=1;
  1940. GroupLayoutType.Vertical=2;
  1941. return GroupLayoutType;
  1942. })()
  1943. /**
  1944. *Use for GList.layout
  1945. */
  1946. //class fairygui.ListLayoutType
  1947. var ListLayoutType=(function(){
  1948. function ListLayoutType(){}
  1949. __class(ListLayoutType,'fairygui.ListLayoutType');
  1950. ListLayoutType.SingleColumn=0;
  1951. ListLayoutType.SingleRow=1;
  1952. ListLayoutType.FlowHorizontal=2;
  1953. ListLayoutType.FlowVertical=3;
  1954. ListLayoutType.Pagination=4;
  1955. return ListLayoutType;
  1956. })()
  1957. /**
  1958. *Use for GList.selectionMode
  1959. */
  1960. //class fairygui.ListSelectionMode
  1961. var ListSelectionMode=(function(){
  1962. function ListSelectionMode(){}
  1963. __class(ListSelectionMode,'fairygui.ListSelectionMode');
  1964. ListSelectionMode.Single=0;
  1965. ListSelectionMode.Multiple=1;
  1966. ListSelectionMode.Multiple_SingleClick=2;
  1967. ListSelectionMode.None=3;
  1968. return ListSelectionMode;
  1969. })()
  1970. /**
  1971. *Use for GLoader.fill
  1972. */
  1973. //class fairygui.LoaderFillType
  1974. var LoaderFillType=(function(){
  1975. function LoaderFillType(){}
  1976. __class(LoaderFillType,'fairygui.LoaderFillType');
  1977. LoaderFillType.None=0;
  1978. LoaderFillType.Scale=1;
  1979. LoaderFillType.ScaleMatchHeight=2;
  1980. LoaderFillType.ScaleMatchWidth=3;
  1981. LoaderFillType.ScaleFree=4;
  1982. LoaderFillType.ScaleNoBorder=5;
  1983. return LoaderFillType;
  1984. })()
  1985. //class fairygui.Margin
  1986. var Margin=(function(){
  1987. function Margin(){
  1988. this.left=0;
  1989. this.right=0;
  1990. this.top=0;
  1991. this.bottom=0;
  1992. }
  1993. __class(Margin,'fairygui.Margin');
  1994. var __proto=Margin.prototype;
  1995. __proto.copy=function(source){
  1996. this.top=source.top;
  1997. this.bottom=source.bottom;
  1998. this.left=source.left;
  1999. this.right=source.right;
  2000. }
  2001. return Margin;
  2002. })()
  2003. /**
  2004. *Use for UIObjectFactory.newObject
  2005. */
  2006. //class fairygui.ObjectType
  2007. var ObjectType=(function(){
  2008. function ObjectType(){}
  2009. __class(ObjectType,'fairygui.ObjectType');
  2010. ObjectType.Image=0;
  2011. ObjectType.MovieClip=1;
  2012. ObjectType.Swf=2;
  2013. ObjectType.Graph=3;
  2014. ObjectType.Loader=4;
  2015. ObjectType.Group=5;
  2016. ObjectType.Text=6;
  2017. ObjectType.RichText=7;
  2018. ObjectType.InputText=8;
  2019. ObjectType.Component=9;
  2020. ObjectType.List=10;
  2021. ObjectType.Label=11;
  2022. ObjectType.Button=12;
  2023. ObjectType.ComboBox=13;
  2024. ObjectType.ProgressBar=14;
  2025. ObjectType.Slider=15;
  2026. ObjectType.ScrollBar=16;
  2027. return ObjectType;
  2028. })()
  2029. /**
  2030. *Use for GComponent.overflow
  2031. */
  2032. //class fairygui.OverflowType
  2033. var OverflowType=(function(){
  2034. function OverflowType(){}
  2035. __class(OverflowType,'fairygui.OverflowType');
  2036. OverflowType.Visible=0;
  2037. OverflowType.Hidden=1;
  2038. OverflowType.Scroll=2;
  2039. return OverflowType;
  2040. })()
  2041. //class fairygui.PackageItem
  2042. var PackageItem=(function(){
  2043. function PackageItem(){
  2044. this.owner=null;
  2045. this.type=0;
  2046. this.objectType=0;
  2047. this.id=null;
  2048. this.name=null;
  2049. this.width=0;
  2050. this.height=0;
  2051. this.file=null;
  2052. this.decoded=false;
  2053. this.rawData=null;
  2054. //image
  2055. this.scale9Grid=null;
  2056. this.scaleByTile=false;
  2057. this.tileGridIndice=0;
  2058. this.smoothing=false;
  2059. this.texture=null;
  2060. this.pixelHitTestData=null;
  2061. //movieclip
  2062. this.interval=0;
  2063. this.repeatDelay=0;
  2064. this.swing=false;
  2065. this.frames=null;
  2066. //componenet
  2067. this.extensionType=null;
  2068. //font
  2069. this.bitmapFont=null;
  2070. }
  2071. __class(PackageItem,'fairygui.PackageItem');
  2072. var __proto=PackageItem.prototype;
  2073. __proto.load=function(){
  2074. return this.owner.getItemAsset(this);
  2075. }
  2076. __proto.toString=function(){
  2077. return this.name;
  2078. }
  2079. return PackageItem;
  2080. })()
  2081. //class fairygui.PackageItemType
  2082. var PackageItemType=(function(){
  2083. function PackageItemType(){}
  2084. __class(PackageItemType,'fairygui.PackageItemType');
  2085. PackageItemType.Image=0;
  2086. PackageItemType.MovieClip=1;
  2087. PackageItemType.Sound=2;
  2088. PackageItemType.Component=3;
  2089. PackageItemType.Atlas=4;
  2090. PackageItemType.Font=5;
  2091. PackageItemType.Swf=6;
  2092. PackageItemType.Misc=7;
  2093. PackageItemType.Unknown=8;
  2094. return PackageItemType;
  2095. })()
  2096. //class fairygui.PageOption
  2097. var PageOption=(function(){
  2098. function PageOption(){
  2099. this._controller=null;
  2100. this._id=null;
  2101. }
  2102. __class(PageOption,'fairygui.PageOption');
  2103. var __proto=PageOption.prototype;
  2104. __proto.clear=function(){
  2105. this._id=null;
  2106. }
  2107. __getset(0,__proto,'controller',null,function(val){
  2108. this._controller=val;
  2109. });
  2110. __getset(0,__proto,'index',function(){
  2111. if (this._id)
  2112. return this._controller.getPageIndexById(this._id);
  2113. else
  2114. return-1;
  2115. },function(pageIndex){
  2116. this._id=this._controller.getPageId(pageIndex);
  2117. });
  2118. __getset(0,__proto,'name',function(){
  2119. if (this._id)
  2120. return this._controller.getPageNameById(this._id);
  2121. else
  2122. return null;
  2123. },function(pageName){
  2124. this._id=this._controller.getPageIdByName(pageName);
  2125. });
  2126. __getset(0,__proto,'id',function(){
  2127. return this._id;
  2128. },function(id){
  2129. this._id=id;
  2130. });
  2131. return PageOption;
  2132. })()
  2133. /**
  2134. *Use for GComboBox.popupDirection
  2135. */
  2136. //class fairygui.PopupDirection
  2137. var PopupDirection=(function(){
  2138. function PopupDirection(){}
  2139. __class(PopupDirection,'fairygui.PopupDirection');
  2140. PopupDirection.Auto=0;
  2141. PopupDirection.Up=1;
  2142. PopupDirection.Down=2;
  2143. return PopupDirection;
  2144. })()
  2145. //class fairygui.PopupMenu
  2146. var PopupMenu=(function(){
  2147. function PopupMenu(resourceURL){
  2148. this._contentPane=null;
  2149. this._list=null;
  2150. if(!resourceURL){
  2151. resourceURL=UIConfig$1.popupMenu;
  2152. if(!resourceURL)
  2153. throw "UIConfig.popupMenu not defined";
  2154. }
  2155. this._contentPane=UIPackage.createObjectFromURL(resourceURL).asCom;
  2156. this._contentPane.on("display",this,this.__addedToStage);
  2157. this._list=(this._contentPane.getChild("list"));
  2158. this._list.removeChildrenToPool();
  2159. this._list.addRelation(this._contentPane,14);
  2160. this._list.removeRelation(this._contentPane,15);
  2161. this._contentPane.addRelation(this._list,15);
  2162. this._list.on("fui_click_item",this,this.__clickItem);
  2163. }
  2164. __class(PopupMenu,'fairygui.PopupMenu');
  2165. var __proto=PopupMenu.prototype;
  2166. __proto.dispose=function(){
  2167. this._contentPane.dispose();
  2168. }
  2169. __proto.addItem=function(caption,handler){
  2170. var item=this._list.addItemFromPool().asButton;
  2171. item.title=caption;
  2172. item.data=handler;
  2173. item.grayed=false;
  2174. var c=item.getController("checked");
  2175. if(c !=null)
  2176. c.selectedIndex=0;
  2177. return item;
  2178. }
  2179. __proto.addItemAt=function(caption,index,handler){
  2180. var item=this._list.getFromPool().asButton;
  2181. this._list.addChildAt(item,index);
  2182. item.title=caption;
  2183. item.data=handler;
  2184. item.grayed=false;
  2185. var c=item.getController("checked");
  2186. if(c !=null)
  2187. c.selectedIndex=0;
  2188. return item;
  2189. }
  2190. __proto.addSeperator=function(){
  2191. if(UIConfig$1.popupMenu_seperator==null)
  2192. throw "UIConfig.popupMenu_seperator not defined";
  2193. this.list.addItemFromPool(UIConfig$1.popupMenu_seperator);
  2194. }
  2195. __proto.getItemName=function(index){
  2196. var item=this._list.getChildAt(index);
  2197. return item.name;
  2198. }
  2199. __proto.setItemText=function(name,caption){
  2200. var item=this._list.getChild(name).asButton;
  2201. item.title=caption;
  2202. }
  2203. __proto.setItemVisible=function(name,visible){
  2204. var item=this._list.getChild(name).asButton;
  2205. if(item.visible !=visible){
  2206. item.visible=visible;
  2207. this._list.setBoundsChangedFlag();
  2208. }
  2209. }
  2210. __proto.setItemGrayed=function(name,grayed){
  2211. var item=this._list.getChild(name).asButton;
  2212. item.grayed=grayed;
  2213. }
  2214. __proto.setItemCheckable=function(name,checkable){
  2215. var item=this._list.getChild(name).asButton;
  2216. var c=item.getController("checked");
  2217. if(c !=null){
  2218. if(checkable){
  2219. if(c.selectedIndex==0)
  2220. c.selectedIndex=1;
  2221. }
  2222. else
  2223. c.selectedIndex=0;
  2224. }
  2225. }
  2226. __proto.setItemChecked=function(name,checked){
  2227. var item=this._list.getChild(name).asButton;
  2228. var c=item.getController("checked");
  2229. if(c !=null)
  2230. c.selectedIndex=checked?2:1;
  2231. }
  2232. __proto.isItemChecked=function(name){
  2233. var item=this._list.getChild(name).asButton;
  2234. var c=item.getController("checked");
  2235. if(c !=null)
  2236. return c.selectedIndex==2;
  2237. else
  2238. return false;
  2239. }
  2240. __proto.removeItem=function(name){
  2241. var item=this._list.getChild(name);
  2242. if(item !=null){
  2243. var index=this._list.getChildIndex(item);
  2244. this._list.removeChildToPoolAt(index);
  2245. return true;
  2246. }
  2247. else
  2248. return false;
  2249. }
  2250. __proto.clearItems=function(){
  2251. this._list.removeChildrenToPool();
  2252. }
  2253. __proto.show=function(target,downward){
  2254. var r=target !=null?target.root:GRoot.inst;
  2255. r.showPopup(this.contentPane,((target instanceof fairygui.GRoot ))?null:target,downward);
  2256. }
  2257. __proto.__clickItem=function(itemObject){
  2258. Laya.timer.once(100,this,this.__clickItem2,[itemObject]);
  2259. }
  2260. __proto.__clickItem2=function(itemObject){
  2261. if(!((itemObject instanceof fairygui.GButton )))
  2262. return;
  2263. if(itemObject.grayed){
  2264. this._list.selectedIndex=-1;
  2265. return;
  2266. };
  2267. var c=itemObject.asCom.getController("checked");
  2268. if(c !=null && c.selectedIndex !=0){
  2269. if(c.selectedIndex==1)
  2270. c.selectedIndex=2;
  2271. else
  2272. c.selectedIndex=1;
  2273. };
  2274. var r=(this._contentPane.parent);
  2275. r.hidePopup(this.contentPane);
  2276. if(itemObject.data !=null){
  2277. (itemObject.data).run();
  2278. }
  2279. }
  2280. __proto.__addedToStage=function(){
  2281. this._list.selectedIndex=-1;
  2282. this._list.resizeToFit(100000,10);
  2283. }
  2284. __getset(0,__proto,'itemCount',function(){
  2285. return this._list.numChildren;
  2286. });
  2287. __getset(0,__proto,'contentPane',function(){
  2288. return this._contentPane;
  2289. });
  2290. __getset(0,__proto,'list',function(){
  2291. return this._list;
  2292. });
  2293. return PopupMenu;
  2294. })()
  2295. /**
  2296. *Use for GProgressBar.titleType and GSlider.titleType
  2297. */
  2298. //class fairygui.ProgressTitleType
  2299. var ProgressTitleType=(function(){
  2300. function ProgressTitleType(){}
  2301. __class(ProgressTitleType,'fairygui.ProgressTitleType');
  2302. ProgressTitleType.Percent=0;
  2303. ProgressTitleType.ValueAndMax=1;
  2304. ProgressTitleType.Value=2;
  2305. ProgressTitleType.Max=3;
  2306. return ProgressTitleType;
  2307. })()
  2308. //class fairygui.RelationItem
  2309. var RelationItem=(function(){
  2310. var RelationDef;
  2311. function RelationItem(owner){
  2312. this._owner=null;
  2313. this._target=null;
  2314. this._defs=null;
  2315. this._targetX=NaN;
  2316. this._targetY=NaN;
  2317. this._targetWidth=NaN;
  2318. this._targetHeight=NaN;
  2319. this._owner=owner;
  2320. this._defs=[];
  2321. }
  2322. __class(RelationItem,'fairygui.RelationItem');
  2323. var __proto=RelationItem.prototype;
  2324. __proto.add=function(relationType,usePercent){
  2325. if (relationType==24){
  2326. this.add(14,usePercent);
  2327. this.add(15,usePercent);
  2328. return;
  2329. };
  2330. var cnt=this._defs.length;
  2331. for(var i=0;i<cnt;i++){
  2332. if (this._defs[i].type==relationType)
  2333. return;
  2334. }
  2335. this.internalAdd(relationType,usePercent);
  2336. }
  2337. __proto.internalAdd=function(relationType,usePercent){
  2338. if (relationType==24){
  2339. this.internalAdd(14,usePercent);
  2340. this.internalAdd(15,usePercent);
  2341. return;
  2342. };
  2343. var info=new RelationDef();
  2344. info.percent=usePercent;
  2345. info.type=relationType;
  2346. info.axis=(relationType <=6 || relationType==14 || relationType >=16 && relationType <=19)? 0 :1;
  2347. this._defs.push(info);
  2348. if (usePercent || relationType==1 || relationType==3 || relationType==5
  2349. || relationType==8 || relationType==10 || relationType==12)
  2350. this._owner.pixelSnapping=true;
  2351. }
  2352. __proto.remove=function(relationType){
  2353. if (relationType==24){
  2354. this.remove(14);
  2355. this.remove(15);
  2356. return;
  2357. };
  2358. var dc=this._defs.length;
  2359. for (var k=0;k < dc;k++){
  2360. if (this._defs[k].type==relationType){
  2361. this._defs.splice(k,1);
  2362. break ;
  2363. }
  2364. }
  2365. }
  2366. __proto.copyFrom=function(source){
  2367. this.target=source.target;
  2368. this._defs.length=0;
  2369. var cnt=source._defs.length;
  2370. for(var i=0;i<cnt;i++){
  2371. var info=source._defs[i];
  2372. var info2=new RelationDef();
  2373. info2.copyFrom(info);
  2374. this._defs.push(info2);
  2375. }
  2376. }
  2377. __proto.dispose=function(){
  2378. if (this._target !=null){
  2379. this.releaseRefTarget(this._target);
  2380. this._target=null;
  2381. }
  2382. }
  2383. __proto.applyOnSelfResized=function(dWidth,dHeight,applyPivot){
  2384. var cnt=this._defs.length;
  2385. if(cnt==0)
  2386. return;
  2387. var ox=this._owner.x;
  2388. var oy=this._owner.y;
  2389. for (var i=0;i < cnt;i++){
  2390. var info=this._defs[i];
  2391. switch (info.type){
  2392. case 3:
  2393. this._owner.x-=(0.5-(applyPivot ? this._owner.pivotX :0))*dWidth;
  2394. break ;
  2395. case 5:
  2396. case 4:
  2397. case 6:
  2398. this._owner.x-=(1-(applyPivot ? this._owner.pivotX :0))*dWidth;
  2399. break ;
  2400. case 10:
  2401. this._owner.y-=(0.5-(applyPivot ? this._owner.pivotY :0))*dHeight;
  2402. break ;
  2403. case 12:
  2404. case 11:
  2405. case 13:
  2406. this._owner.y-=(1-(applyPivot ? this._owner.pivotY :0))*dHeight;
  2407. break ;
  2408. }
  2409. }
  2410. if (ox!=this._owner.x || oy!=this._owner.y){
  2411. ox=this._owner.x-ox;
  2412. oy=this._owner.y-oy;
  2413. this._owner.updateGearFromRelations(1,ox,oy);
  2414. if (this._owner.parent !=null && this._owner.parent._transitions.length > 0){
  2415. cnt=this._owner.parent._transitions.length;
  2416. for(var j=0;j<cnt;j++){
  2417. var trans=this._owner.parent._transitions[j];
  2418. trans.updateFromRelations(this._owner.id,ox,oy);
  2419. }
  2420. }
  2421. }
  2422. }
  2423. __proto.applyOnXYChanged=function(info,dx,dy){
  2424. var tmp=NaN;
  2425. switch (info.type){
  2426. case 0:
  2427. case 1:
  2428. case 2:
  2429. case 3:
  2430. case 4:
  2431. case 5:
  2432. case 6:
  2433. this._owner.x+=dx;
  2434. break ;
  2435. case 7:
  2436. case 8:
  2437. case 9:
  2438. case 10:
  2439. case 11:
  2440. case 12:
  2441. case 13:
  2442. this._owner.y+=dy;
  2443. break ;
  2444. case 14:
  2445. case 15:
  2446. break ;
  2447. case 16:
  2448. case 17:
  2449. tmp=this._owner.xMin;
  2450. this._owner.width=this._owner._rawWidth-dx;
  2451. this._owner.xMin=tmp+dx;
  2452. break ;
  2453. case 18:
  2454. case 19:
  2455. tmp=this._owner.xMin;
  2456. this._owner.width=this._owner._rawWidth+dx;
  2457. this._owner.xMin=tmp;
  2458. break ;
  2459. case 20:
  2460. case 21:
  2461. tmp=this._owner.yMin;
  2462. this._owner.height=this._owner._rawHeight-dy;
  2463. this._owner.yMin=tmp+dy;
  2464. break ;
  2465. case 22:
  2466. case 23:
  2467. tmp=this._owner.yMin;
  2468. this._owner.height=this._owner._rawHeight+dy;
  2469. this._owner.yMin=tmp;
  2470. break ;
  2471. }
  2472. }
  2473. __proto.applyOnSizeChanged=function(info){
  2474. var pos=0,pivot=0,delta=0;
  2475. var v=NaN,tmp=NaN;
  2476. if (info.axis==0){
  2477. if (this._target !=this._owner.parent){
  2478. pos=this._target.x;
  2479. if (this._target.pivotAsAnchor)
  2480. pivot=this._target.pivotX;
  2481. }
  2482. if (info.percent){
  2483. if (this._targetWidth !=0)
  2484. delta=this._target._width / this._targetWidth;
  2485. }
  2486. else
  2487. delta=this._target._width-this._targetWidth;
  2488. }
  2489. else{
  2490. if (this._target !=this._owner.parent){
  2491. pos=this._target.y;
  2492. if (this._target.pivotAsAnchor)
  2493. pivot=this._target.pivotY;
  2494. }
  2495. if (info.percent){
  2496. if (this._targetHeight !=0)
  2497. delta=this._target._height / this._targetHeight;
  2498. }
  2499. else
  2500. delta=this._target._height-this._targetHeight;
  2501. }
  2502. switch (info.type){
  2503. case 0:
  2504. if (info.percent)
  2505. this._owner.xMin=pos+(this._owner.xMin-pos)*delta;
  2506. else if (pivot !=0)
  2507. this._owner.x+=delta *(-pivot);
  2508. break ;
  2509. case 1:
  2510. if (info.percent)
  2511. this._owner.xMin=pos+(this._owner.xMin-pos)*delta;
  2512. else
  2513. this._owner.x+=delta *(0.5-pivot);
  2514. break ;
  2515. case 2:
  2516. if (info.percent)
  2517. this._owner.xMin=pos+(this._owner.xMin-pos)*delta;
  2518. else
  2519. this._owner.x+=delta *(1-pivot);
  2520. break ;
  2521. case 3:
  2522. if (info.percent)
  2523. this._owner.xMin=pos+(this._owner.xMin+this._owner._rawWidth *0.5-pos)*delta-this._owner._rawWidth *0.5;
  2524. else
  2525. this._owner.x+=delta *(0.5-pivot);
  2526. break ;
  2527. case 4:
  2528. if (info.percent)
  2529. this._owner.xMin=pos+(this._owner.xMin+this._owner._rawWidth-pos)*delta-this._owner._rawWidth;
  2530. else if (pivot !=0)
  2531. this._owner.x+=delta *(-pivot);
  2532. break ;
  2533. case 5:
  2534. if (info.percent)
  2535. this._owner.xMin=pos+(this._owner.xMin+this._owner._rawWidth-pos)*delta-this._owner._rawWidth;
  2536. else
  2537. this._owner.x+=delta *(0.5-pivot);
  2538. break ;
  2539. case 6:
  2540. if (info.percent)
  2541. this._owner.xMin=pos+(this._owner.xMin+this._owner._rawWidth-pos)*delta-this._owner._rawWidth;
  2542. else
  2543. this._owner.x+=delta *(1-pivot);
  2544. break ;
  2545. case 7:
  2546. if (info.percent)
  2547. this._owner.yMin=pos+(this._owner.yMin-pos)*delta;
  2548. else if (pivot !=0)
  2549. this._owner.y+=delta *(-pivot);
  2550. break ;
  2551. case 8:
  2552. if (info.percent)
  2553. this._owner.yMin=pos+(this._owner.yMin-pos)*delta;
  2554. else
  2555. this._owner.y+=delta *(0.5-pivot);
  2556. break ;
  2557. case 9:
  2558. if (info.percent)
  2559. this._owner.yMin=pos+(this._owner.yMin-pos)*delta;
  2560. else
  2561. this._owner.y+=delta *(1-pivot);
  2562. break ;
  2563. case 10:
  2564. if (info.percent)
  2565. this._owner.yMin=pos+(this._owner.yMin+this._owner._rawHeight *0.5-pos)*delta-this._owner._rawHeight *0.5;
  2566. else
  2567. this._owner.y+=delta *(0.5-pivot);
  2568. break ;
  2569. case 11:
  2570. if (info.percent)
  2571. this._owner.yMin=pos+(this._owner.yMin+this._owner._rawHeight-pos)*delta-this._owner._rawHeight;
  2572. else if (pivot !=0)
  2573. this._owner.y+=delta *(-pivot);
  2574. break ;
  2575. case 12:
  2576. if (info.percent)
  2577. this._owner.yMin=pos+(this._owner.yMin+this._owner._rawHeight-pos)*delta-this._owner._rawHeight;
  2578. else
  2579. this._owner.y+=delta *(0.5-pivot);
  2580. break ;
  2581. case 13:
  2582. if (info.percent)
  2583. this._owner.yMin=pos+(this._owner.yMin+this._owner._rawHeight-pos)*delta-this._owner._rawHeight;
  2584. else
  2585. this._owner.y+=delta *(1-pivot);
  2586. break ;
  2587. case 14:
  2588. if (this._owner._underConstruct && this._owner==this._target.parent)
  2589. v=this._owner.sourceWidth-this._target.initWidth;
  2590. else
  2591. v=this._owner._rawWidth-this._targetWidth;
  2592. if (info.percent)
  2593. v=v *delta;
  2594. if (this._target==this._owner.parent){
  2595. if (this._owner.pivotAsAnchor){
  2596. tmp=this._owner.xMin;
  2597. this._owner.setSize(this._target._width+v,this._owner._rawHeight,true);
  2598. this._owner.xMin=tmp;
  2599. }
  2600. else
  2601. this._owner.setSize(this._target._width+v,this._owner._rawHeight,true);
  2602. }
  2603. else
  2604. this._owner.width=this._target._width+v;
  2605. break ;
  2606. case 15:
  2607. if (this._owner._underConstruct && this._owner==this._target.parent)
  2608. v=this._owner.sourceHeight-this._target.initHeight;
  2609. else
  2610. v=this._owner._rawHeight-this._targetHeight;
  2611. if (info.percent)
  2612. v=v *delta;
  2613. if (this._target==this._owner.parent){
  2614. if (this._owner.pivotAsAnchor){
  2615. tmp=this._owner.yMin;
  2616. this._owner.setSize(this._owner._rawWidth,this._target._height+v,true);
  2617. this._owner.yMin=tmp;
  2618. }
  2619. else
  2620. this._owner.setSize(this._owner._rawWidth,this._target._height+v,true);
  2621. }
  2622. else
  2623. this._owner.height=this._target._height+v;
  2624. break ;
  2625. case 16:
  2626. tmp=this._owner.xMin;
  2627. if (info.percent)
  2628. v=pos+(tmp-pos)*delta-tmp;
  2629. else
  2630. v=delta *(-pivot);
  2631. this._owner.width=this._owner._rawWidth-v;
  2632. this._owner.xMin=tmp+v;
  2633. break ;
  2634. case 17:
  2635. tmp=this._owner.xMin;
  2636. if (info.percent)
  2637. v=pos+(tmp-pos)*delta-tmp;
  2638. else
  2639. v=delta *(1-pivot);
  2640. this._owner.width=this._owner._rawWidth-v;
  2641. this._owner.xMin=tmp+v;
  2642. break ;
  2643. case 18:
  2644. tmp=this._owner.xMin;
  2645. if (info.percent)
  2646. v=pos+(tmp+this._owner._rawWidth-pos)*delta-(tmp+this._owner._rawWidth);
  2647. else
  2648. v=delta *(-pivot);
  2649. this._owner.width=this._owner._rawWidth+v;
  2650. this._owner.xMin=tmp;
  2651. break ;
  2652. case 19:
  2653. tmp=this._owner.xMin;
  2654. if (info.percent){
  2655. if (this._owner==this._target.parent){
  2656. if (this._owner._underConstruct)
  2657. this._owner.width=pos+this._target._width-this._target._width *pivot+
  2658. (this._owner.sourceWidth-pos-this._target.initWidth+this._target.initWidth *pivot)*delta;
  2659. else
  2660. this._owner.width=pos+(this._owner._rawWidth-pos)*delta;
  2661. }
  2662. else{
  2663. v=pos+(tmp+this._owner._rawWidth-pos)*delta-(tmp+this._owner._rawWidth);
  2664. this._owner.width=this._owner._rawWidth+v;
  2665. this._owner.xMin=tmp;
  2666. }
  2667. }
  2668. else{
  2669. if (this._owner==this._target.parent){
  2670. if (this._owner._underConstruct)
  2671. this._owner.width=this._owner.sourceWidth+(this._target._width-this._target.initWidth)*(1-pivot);
  2672. else
  2673. this._owner.width=this._owner._rawWidth+delta *(1-pivot);
  2674. }
  2675. else{
  2676. v=delta *(1-pivot);
  2677. this._owner.width=this._owner._rawWidth+v;
  2678. this._owner.xMin=tmp;
  2679. }
  2680. }
  2681. break ;
  2682. case 20:
  2683. tmp=this._owner.yMin;
  2684. if (info.percent)
  2685. v=pos+(tmp-pos)*delta-tmp;
  2686. else
  2687. v=delta *(-pivot);
  2688. this._owner.height=this._owner._rawHeight-v;
  2689. this._owner.yMin=tmp+v;
  2690. break ;
  2691. case 21:
  2692. tmp=this._owner.yMin;
  2693. if (info.percent)
  2694. v=pos+(tmp-pos)*delta-tmp;
  2695. else
  2696. v=delta *(1-pivot);
  2697. this._owner.height=this._owner._rawHeight-v;
  2698. this._owner.yMin=tmp+v;
  2699. break ;
  2700. case 22:
  2701. tmp=this._owner.yMin;
  2702. if (info.percent)
  2703. v=pos+(tmp+this._owner._rawHeight-pos)*delta-(tmp+this._owner._rawHeight);
  2704. else
  2705. v=delta *(-pivot);
  2706. this._owner.height=this._owner._rawHeight+v;
  2707. this._owner.yMin=tmp;
  2708. break ;
  2709. case 23:
  2710. tmp=this._owner.yMin;
  2711. if (info.percent){
  2712. if (this._owner==this._target.parent){
  2713. if (this._owner._underConstruct)
  2714. this._owner.height=pos+this._target._height-this._target._height *pivot+
  2715. (this._owner.sourceHeight-pos-this._target.initHeight+this._target.initHeight *pivot)*delta;
  2716. else
  2717. this._owner.height=pos+(this._owner._rawHeight-pos)*delta;
  2718. }
  2719. else{
  2720. v=pos+(tmp+this._owner._rawHeight-pos)*delta-(tmp+this._owner._rawHeight);
  2721. this._owner.height=this._owner._rawHeight+v;
  2722. this._owner.yMin=tmp;
  2723. }
  2724. }
  2725. else{
  2726. if (this._owner==this._target.parent){
  2727. if (this._owner._underConstruct)
  2728. this._owner.height=this._owner.sourceHeight+(this._target._height-this._target.initHeight)*(1-pivot);
  2729. else
  2730. this._owner.height=this._owner._rawHeight+delta *(1-pivot);
  2731. }
  2732. else{
  2733. v=delta *(1-pivot);
  2734. this._owner.height=this._owner._rawHeight+v;
  2735. this._owner.yMin=tmp;
  2736. }
  2737. }
  2738. break ;
  2739. }
  2740. }
  2741. __proto.addRefTarget=function(target){
  2742. if (target !=this._owner.parent)
  2743. target.on("fui_xy_changed",this,this.__targetXYChanged);
  2744. target.on("fui_size_changed",this,this.__targetSizeChanged);
  2745. target.on("fui_size_delay_change",this,this.__targetSizeWillChange);
  2746. this._targetX=this._target.x;
  2747. this._targetY=this._target.y;
  2748. this._targetWidth=this._target._width;
  2749. this._targetHeight=this._target._height;
  2750. }
  2751. __proto.releaseRefTarget=function(target){
  2752. if(target.displayObject==null)
  2753. return;
  2754. target.off("fui_xy_changed",this,this.__targetXYChanged);
  2755. target.off("fui_size_changed",this,this.__targetSizeChanged);
  2756. target.off("fui_size_delay_change",this,this.__targetSizeWillChange);
  2757. }
  2758. __proto.__targetXYChanged=function(target){
  2759. if (this._owner.relations.handling!=null || this._owner.group!=null && this._owner.group._updating){
  2760. this._targetX=this._target.x;
  2761. this._targetY=this._target.y;
  2762. return;
  2763. }
  2764. this._owner.relations.handling=target;
  2765. var ox=this._owner.x;
  2766. var oy=this._owner.y;
  2767. var dx=this._target.x-this._targetX;
  2768. var dy=this._target.y-this._targetY;
  2769. var cnt=this._defs.length;
  2770. for(var i=0;i<cnt;i++){
  2771. this.applyOnXYChanged(this._defs[i],dx,dy);
  2772. }
  2773. this._targetX=this._target.x;
  2774. this._targetY=this._target.y;
  2775. if (ox!=this._owner.x || oy!=this._owner.y){
  2776. ox=this._owner.x-ox;
  2777. oy=this._owner.y-oy;
  2778. this._owner.updateGearFromRelations(1,ox,oy);
  2779. if (this._owner.parent !=null && this._owner.parent._transitions.length > 0){
  2780. cnt=this._owner.parent._transitions.length;
  2781. for(var j=0;j<cnt;j++){
  2782. var trans=this._owner.parent._transitions[j];
  2783. trans.updateFromRelations(this._owner.id,ox,oy);
  2784. }
  2785. }
  2786. }
  2787. this._owner.relations.handling=null;
  2788. }
  2789. __proto.__targetSizeChanged=function(target){
  2790. if (this._owner.relations.handling!=null){
  2791. this._targetWidth=this._target._width;
  2792. this._targetHeight=this._target._height;
  2793. return;
  2794. }
  2795. this._owner.relations.handling=target;
  2796. var ox=this._owner.x;
  2797. var oy=this._owner.y;
  2798. var ow=this._owner._rawWidth;
  2799. var oh=this._owner._rawHeight;
  2800. var cnt=this._defs.length;
  2801. for(var i=0;i<cnt;i++){
  2802. this.applyOnSizeChanged(this._defs[i]);
  2803. }
  2804. this._targetWidth=this._target._width;
  2805. this._targetHeight=this._target._height;
  2806. if (ox!=this._owner.x || oy!=this._owner.y){
  2807. ox=this._owner.x-ox;
  2808. oy=this._owner.y-oy;
  2809. this._owner.updateGearFromRelations(1,ox,oy);
  2810. if (this._owner.parent !=null && this._owner.parent._transitions.length > 0){
  2811. cnt=this._owner.parent._transitions.length;
  2812. for(var j=0;j<cnt;j++){
  2813. var trans=this._owner.parent._transitions[j];
  2814. trans.updateFromRelations(this._owner.id,ox,oy);
  2815. }
  2816. }
  2817. }
  2818. if (ow!=this._owner._rawWidth || oh!=this._owner._rawHeight){
  2819. ow=this._owner._rawWidth-ow;
  2820. oh=this._owner._rawHeight-oh;
  2821. this._owner.updateGearFromRelations(2,ow,oh);
  2822. }
  2823. this._owner.relations.handling=null;
  2824. }
  2825. __proto.__targetSizeWillChange=function(target){
  2826. this._owner.relations.sizeDirty=true;
  2827. }
  2828. __getset(0,__proto,'owner',function(){
  2829. return this._owner;
  2830. });
  2831. __getset(0,__proto,'target',function(){
  2832. return this._target;
  2833. },function(value){
  2834. if(this._target!=value){
  2835. if(this._target)
  2836. this.releaseRefTarget(this._target);
  2837. this._target=value;
  2838. if(this._target)
  2839. this.addRefTarget(this._target);
  2840. }
  2841. });
  2842. __getset(0,__proto,'isEmpty',function(){
  2843. return this._defs.length==0;
  2844. });
  2845. RelationItem.__init$=function(){
  2846. //class RelationDef
  2847. RelationDef=(function(){
  2848. function RelationDef(){
  2849. this.percent=false;
  2850. this.type=0;
  2851. this.axis=0;
  2852. }
  2853. __class(RelationDef,'');
  2854. var __proto=RelationDef.prototype;
  2855. __proto.copyFrom=function(source){
  2856. this.percent=source.percent;
  2857. this.type=source.type;
  2858. this.axis=source.axis;
  2859. }
  2860. return RelationDef;
  2861. })()
  2862. }
  2863. return RelationItem;
  2864. })()
  2865. //class fairygui.Relations
  2866. var Relations=(function(){
  2867. function Relations(owner){
  2868. this._owner=null;
  2869. this._items=null;
  2870. this.handling=null;
  2871. this.sizeDirty=false;
  2872. this._owner=owner;
  2873. this._items=[];
  2874. }
  2875. __class(Relations,'fairygui.Relations');
  2876. var __proto=Relations.prototype;
  2877. __proto.add=function(target,relationType,usePercent){
  2878. (usePercent===void 0)&& (usePercent=false);
  2879. var length=this._items.length;
  2880. for (var i=0;i < length;i++){
  2881. var item=this._items[i];
  2882. if (item.target==target){
  2883. item.add(relationType,usePercent);
  2884. return;
  2885. }
  2886. };
  2887. var newItem=new RelationItem(this._owner);
  2888. newItem.target=target;
  2889. newItem.add(relationType,usePercent);
  2890. this._items.push(newItem);
  2891. }
  2892. __proto.remove=function(target,relationType){
  2893. (relationType===void 0)&& (relationType=0);
  2894. var cnt=this._items.length;
  2895. var i=0;
  2896. while (i < cnt){
  2897. var item=this._items[i];
  2898. if (item.target==target){
  2899. item.remove(relationType);
  2900. if (item.isEmpty){
  2901. item.dispose();
  2902. this._items.splice(i,1);
  2903. cnt--;
  2904. }
  2905. else
  2906. i++;
  2907. }
  2908. else
  2909. i++;
  2910. }
  2911. }
  2912. __proto.contains=function(target){
  2913. var length=this._items.length;
  2914. for (var i=0;i < length;i++){
  2915. var item=this._items[i];
  2916. if (item.target==target)
  2917. return true;
  2918. }
  2919. return false;
  2920. }
  2921. __proto.clearFor=function(target){
  2922. var cnt=this._items.length;
  2923. var i=0;
  2924. while (i < cnt){
  2925. var item=this._items[i];
  2926. if (item.target==target){
  2927. item.dispose();
  2928. this._items.splice(i,1);
  2929. cnt--;
  2930. }
  2931. else
  2932. i++;
  2933. }
  2934. }
  2935. __proto.clearAll=function(){
  2936. var length=this._items.length;
  2937. for (var i=0;i < length;i++){
  2938. var item=this._items[i];
  2939. item.dispose();
  2940. }
  2941. this._items.length=0;
  2942. }
  2943. __proto.copyFrom=function(source){
  2944. this.clearAll();
  2945. var arr=source._items;
  2946. var length=arr.length;
  2947. for (var i=0;i < length;i++){
  2948. var ri=arr[i];
  2949. var item=new RelationItem(this._owner);
  2950. item.copyFrom(ri);
  2951. this._items.push(item);
  2952. }
  2953. }
  2954. __proto.dispose=function(){
  2955. this.clearAll();
  2956. }
  2957. __proto.onOwnerSizeChanged=function(dWidth,dHeight,applyPivot){
  2958. if (this._items.length==0)
  2959. return;
  2960. var length=this._items.length;
  2961. for (var i=0;i < length;i++){
  2962. var item=this._items[i];
  2963. item.applyOnSelfResized(dWidth,dHeight,applyPivot);
  2964. }
  2965. }
  2966. __proto.ensureRelationsSizeCorrect=function(){
  2967. if (this._items.length==0)
  2968. return;
  2969. this.sizeDirty=false;
  2970. var length=this._items.length;
  2971. for (var i=0;i < length;i++){
  2972. var item=this._items[i];
  2973. item.target.ensureSizeCorrect();
  2974. }
  2975. }
  2976. __proto.setup=function(buffer,parentToChild){
  2977. var cnt=buffer.readByte();
  2978. var target;
  2979. for (var i=0;i < cnt;i++){
  2980. var targetIndex=buffer.getInt16();
  2981. if (targetIndex==-1)
  2982. target=this._owner.parent;
  2983. else if (parentToChild)
  2984. target=(this._owner).getChildAt(targetIndex);
  2985. else
  2986. target=this._owner.parent.getChildAt(targetIndex);
  2987. var newItem=new RelationItem(this._owner);
  2988. newItem.target=target;
  2989. this._items.push(newItem);
  2990. var cnt2=buffer.readByte();
  2991. for (var j=0;j < cnt2;j++){
  2992. var rt=buffer.readByte();
  2993. var usePercent=buffer.readBool();
  2994. newItem.internalAdd(rt,usePercent);
  2995. }
  2996. }
  2997. }
  2998. __getset(0,__proto,'empty',function(){
  2999. return this._items.length==0;
  3000. });
  3001. return Relations;
  3002. })()
  3003. //class fairygui.RelationType
  3004. var RelationType=(function(){
  3005. function RelationType(){}
  3006. __class(RelationType,'fairygui.RelationType');
  3007. RelationType.Left_Left=0;
  3008. RelationType.Left_Center=1;
  3009. RelationType.Left_Right=2;
  3010. RelationType.Center_Center=3;
  3011. RelationType.Right_Left=4;
  3012. RelationType.Right_Center=5;
  3013. RelationType.Right_Right=6;
  3014. RelationType.Top_Top=7;
  3015. RelationType.Top_Middle=8;
  3016. RelationType.Top_Bottom=9;
  3017. RelationType.Middle_Middle=10;
  3018. RelationType.Bottom_Top=11;
  3019. RelationType.Bottom_Middle=12;
  3020. RelationType.Bottom_Bottom=13;
  3021. RelationType.Width=14;
  3022. RelationType.Height=15;
  3023. RelationType.LeftExt_Left=16;
  3024. RelationType.LeftExt_Right=17;
  3025. RelationType.RightExt_Left=18;
  3026. RelationType.RightExt_Right=19;
  3027. RelationType.TopExt_Top=20;
  3028. RelationType.TopExt_Bottom=21;
  3029. RelationType.BottomExt_Top=22;
  3030. RelationType.BottomExt_Bottom=23;
  3031. RelationType.Size=24;
  3032. return RelationType;
  3033. })()
  3034. //class fairygui.ScrollBarDisplayType
  3035. var ScrollBarDisplayType=(function(){
  3036. function ScrollBarDisplayType(){}
  3037. __class(ScrollBarDisplayType,'fairygui.ScrollBarDisplayType');
  3038. ScrollBarDisplayType.Default=0;
  3039. ScrollBarDisplayType.Visible=1;
  3040. ScrollBarDisplayType.Auto=2;
  3041. ScrollBarDisplayType.Hidden=3;
  3042. return ScrollBarDisplayType;
  3043. })()
  3044. //class fairygui.ScrollPane
  3045. var ScrollPane=(function(){
  3046. function ScrollPane(owner){
  3047. this._owner=null;
  3048. this._container=null;
  3049. this._maskContainer=null;
  3050. this._alignContainer=null;
  3051. this._scrollType=0;
  3052. this._scrollStep=0;
  3053. this._mouseWheelStep=0;
  3054. this._decelerationRate=NaN;
  3055. this._scrollBarMargin=null;
  3056. this._bouncebackEffect=false;
  3057. this._touchEffect=false;
  3058. this._scrollBarDisplayAuto=false;
  3059. this._vScrollNone=false;
  3060. this._hScrollNone=false;
  3061. this._needRefresh=false;
  3062. this._refreshBarAxis=null;
  3063. this._displayOnLeft=false;
  3064. this._snapToItem=false;
  3065. this._displayInDemand=false;
  3066. this._mouseWheelEnabled=false;
  3067. this._pageMode=false;
  3068. this._inertiaDisabled=false;
  3069. this._xPos=NaN;
  3070. this._yPos=NaN;
  3071. this._viewSize=null;
  3072. this._contentSize=null;
  3073. this._overlapSize=null;
  3074. this._pageSize=null;
  3075. this._containerPos=null;
  3076. this._beginTouchPos=null;
  3077. this._lastTouchPos=null;
  3078. this._lastTouchGlobalPos=null;
  3079. this._velocity=null;
  3080. this._velocityScale=NaN;
  3081. this._lastMoveTime=NaN;
  3082. this._isHoldAreaDone=false;
  3083. this._aniFlag=0;
  3084. this._scrollBarVisible=false;
  3085. this._loop=0;
  3086. this._headerLockedSize=0;
  3087. this._footerLockedSize=0;
  3088. this._refreshEventDispatching=false;
  3089. this._tweening=0;
  3090. this._tweenTime=null;
  3091. this._tweenDuration=null;
  3092. this._tweenStart=null;
  3093. this._tweenChange=null;
  3094. this._pageController=null;
  3095. this._hzScrollBar=null;
  3096. this._vtScrollBar=null;
  3097. this._header=null;
  3098. this._footer=null;
  3099. this.isDragged=false;
  3100. ;
  3101. this._owner=owner;
  3102. this._maskContainer=new Sprite();
  3103. this._owner.displayObject.addChild(this._maskContainer);
  3104. this._container=this._owner._container;
  3105. this._container.pos(0,0);
  3106. this._maskContainer.addChild(this._container);
  3107. this._scrollBarVisible=true;
  3108. this._mouseWheelEnabled=true;
  3109. this._xPos=0;
  3110. this._yPos=0;
  3111. this._aniFlag=0;
  3112. this._footerLockedSize=0;
  3113. this._headerLockedSize=0;
  3114. this._scrollBarMargin=new Margin();
  3115. this._viewSize=new Point();
  3116. this._contentSize=new Point();
  3117. this._pageSize=new Point(1,1);
  3118. this._overlapSize=new Point();
  3119. this._tweenTime=new Point();
  3120. this._tweenStart=new Point();
  3121. this._tweenDuration=new Point();
  3122. this._tweenChange=new Point();
  3123. this._velocity=new Point();
  3124. this._containerPos=new Point();
  3125. this._beginTouchPos=new Point();
  3126. this._lastTouchPos=new Point();
  3127. this._lastTouchGlobalPos=new Point();
  3128. this._scrollStep=UIConfig$1.defaultScrollStep;
  3129. this._mouseWheelStep=this._scrollStep*2;
  3130. this._decelerationRate=UIConfig$1.defaultScrollDecelerationRate;
  3131. this._owner.on("mousedown",this,this.__mouseDown);
  3132. this._owner.on("mousewheel",this,this.__mouseWheel);
  3133. }
  3134. __class(ScrollPane,'fairygui.ScrollPane');
  3135. var __proto=ScrollPane.prototype;
  3136. __proto.setup=function(buffer){
  3137. this._scrollType=buffer.readByte();
  3138. var scrollBarDisplay=buffer.readByte();
  3139. var flags=buffer.getInt32();
  3140. if (buffer.readBool()){
  3141. this._scrollBarMargin.top=buffer.getInt32();
  3142. this._scrollBarMargin.bottom=buffer.getInt32();
  3143. this._scrollBarMargin.left=buffer.getInt32();
  3144. this._scrollBarMargin.right=buffer.getInt32();
  3145. };
  3146. var vtScrollBarRes=buffer.readS();
  3147. var hzScrollBarRes=buffer.readS();
  3148. var headerRes=buffer.readS();
  3149. var footerRes=buffer.readS();
  3150. this._displayOnLeft=(flags & 1)!=0;
  3151. this._snapToItem=(flags & 2)!=0;
  3152. this._displayInDemand=(flags & 4)!=0;
  3153. this._pageMode=(flags & 8)!=0;
  3154. if(flags & 16)
  3155. this._touchEffect=true;
  3156. else if(flags & 32)
  3157. this._touchEffect=false;
  3158. else
  3159. this._touchEffect=UIConfig$1.defaultScrollTouchEffect;
  3160. if(flags & 64)
  3161. this._bouncebackEffect=true;
  3162. else if(flags & 128)
  3163. this._bouncebackEffect=false;
  3164. else
  3165. this._bouncebackEffect=UIConfig$1.defaultScrollBounceEffect;
  3166. this._inertiaDisabled=(flags & 256)!=0;
  3167. if((flags & 512)==0)
  3168. this._maskContainer.scrollRect=new Rectangle();
  3169. if(scrollBarDisplay==0)
  3170. scrollBarDisplay=UIConfig$1.defaultScrollBarDisplay;
  3171. if(scrollBarDisplay !=3){
  3172. if(this._scrollType==2 || this._scrollType==1){
  3173. var res=vtScrollBarRes ? vtScrollBarRes :UIConfig$1.verticalScrollBar;
  3174. if(res){
  3175. this._vtScrollBar=(UIPackage.createObjectFromURL(res));
  3176. if(!this._vtScrollBar)
  3177. throw "cannot create scrollbar from "+res;
  3178. this._vtScrollBar.setScrollPane(this,true);
  3179. this._owner.displayObject.addChild(this._vtScrollBar.displayObject);
  3180. }
  3181. }
  3182. if(this._scrollType==2 || this._scrollType==0){
  3183. res=hzScrollBarRes ? hzScrollBarRes :UIConfig$1.horizontalScrollBar;
  3184. if(res){
  3185. this._hzScrollBar=(UIPackage.createObjectFromURL(res));
  3186. if(!this._hzScrollBar)
  3187. throw "cannot create scrollbar from "+res;
  3188. this._hzScrollBar.setScrollPane(this,false);
  3189. this._owner.displayObject.addChild(this._hzScrollBar.displayObject);
  3190. }
  3191. }
  3192. this._scrollBarDisplayAuto=scrollBarDisplay==2;
  3193. if(this._scrollBarDisplayAuto){
  3194. this._scrollBarVisible=false;
  3195. if(this._vtScrollBar)
  3196. this._vtScrollBar.displayObject.visible=false;
  3197. if(this._hzScrollBar)
  3198. this._hzScrollBar.displayObject.visible=false;
  3199. }
  3200. }
  3201. else
  3202. this._mouseWheelEnabled=false;
  3203. if (headerRes){
  3204. this._header=UIPackage.createObjectFromURL(headerRes);
  3205. if (this._header==null)
  3206. throw new Error("FairyGUI: cannot create scrollPane header from "+headerRes);
  3207. }
  3208. if (footerRes){
  3209. this._footer=UIPackage.createObjectFromURL(footerRes);
  3210. if (this._footer==null)
  3211. throw new Error("FairyGUI: cannot create scrollPane footer from "+footerRes);
  3212. }
  3213. if (this._header !=null || this._footer !=null)
  3214. this._refreshBarAxis=(this._scrollType==2 || this._scrollType==1)? "y" :"x";
  3215. this.setSize(this.owner.width,this.owner.height);
  3216. }
  3217. __proto.dispose=function(){
  3218. if (this._tweening !=0)
  3219. Laya.timer.clear(this,this.tweenUpdate);
  3220. this._pageController=null;
  3221. if (this._hzScrollBar !=null)
  3222. this._hzScrollBar.dispose();
  3223. if (this._vtScrollBar !=null)
  3224. this._vtScrollBar.dispose();
  3225. if (this._header !=null)
  3226. this._header.dispose();
  3227. if (this._footer !=null)
  3228. this._footer.dispose();
  3229. }
  3230. __proto.setPercX=function(value,ani){
  3231. (ani===void 0)&& (ani=false);
  3232. this._owner.ensureBoundsCorrect();
  3233. this.setPosX(this._overlapSize.x *ToolSet.clamp01(value),ani);
  3234. }
  3235. __proto.setPercY=function(value,ani){
  3236. (ani===void 0)&& (ani=false);
  3237. this._owner.ensureBoundsCorrect();
  3238. this.setPosY(this._overlapSize.y *ToolSet.clamp01(value),ani);
  3239. }
  3240. __proto.setPosX=function(value,ani){
  3241. (ani===void 0)&& (ani=false);
  3242. this._owner.ensureBoundsCorrect();
  3243. if (this._loop==1)
  3244. value=this.loopCheckingNewPos(value,"x");
  3245. value=ToolSet.clamp(value,0,this._overlapSize.x);
  3246. if (value !=this._xPos){
  3247. this._xPos=value;
  3248. this.posChanged(ani);
  3249. }
  3250. }
  3251. __proto.setPosY=function(value,ani){
  3252. (ani===void 0)&& (ani=false);
  3253. this._owner.ensureBoundsCorrect();
  3254. if (this._loop==1)
  3255. value=this.loopCheckingNewPos(value,"y");
  3256. value=ToolSet.clamp(value,0,this._overlapSize.y);
  3257. if (value !=this._yPos){
  3258. this._yPos=value;
  3259. this.posChanged(ani);
  3260. }
  3261. }
  3262. __proto.setCurrentPageX=function(value,ani){
  3263. if (this._pageMode && this._overlapSize.x>0)
  3264. this.setPosX(value *this._pageSize.x,ani);
  3265. }
  3266. __proto.setCurrentPageY=function(value,ani){
  3267. if (this._pageMode && this._overlapSize.y>0)
  3268. this.setPosY(value *this._pageSize.y,ani);
  3269. }
  3270. __proto.scrollTop=function(ani){
  3271. (ani===void 0)&& (ani=false);
  3272. this.setPercY(0,ani);
  3273. }
  3274. __proto.scrollBottom=function(ani){
  3275. (ani===void 0)&& (ani=false);
  3276. this.setPercY(1,ani);
  3277. }
  3278. __proto.scrollUp=function(ratio,ani){
  3279. (ratio===void 0)&& (ratio=1);
  3280. (ani===void 0)&& (ani=false);
  3281. if (this._pageMode)
  3282. this.setPosY(this._yPos-this._pageSize.y *ratio,ani);
  3283. else
  3284. this.setPosY(this._yPos-this._scrollStep *ratio,ani);;
  3285. }
  3286. __proto.scrollDown=function(ratio,ani){
  3287. (ratio===void 0)&& (ratio=1);
  3288. (ani===void 0)&& (ani=false);
  3289. if (this._pageMode)
  3290. this.setPosY(this._yPos+this._pageSize.y *ratio,ani);
  3291. else
  3292. this.setPosY(this._yPos+this._scrollStep *ratio,ani);
  3293. }
  3294. __proto.scrollLeft=function(ratio,ani){
  3295. (ratio===void 0)&& (ratio=1);
  3296. (ani===void 0)&& (ani=false);
  3297. if (this._pageMode)
  3298. this.setPosX(this._xPos-this._pageSize.x *ratio,ani);
  3299. else
  3300. this.setPosX(this._xPos-this._scrollStep *ratio,ani);
  3301. }
  3302. __proto.scrollRight=function(ratio,ani){
  3303. (ratio===void 0)&& (ratio=1);
  3304. (ani===void 0)&& (ani=false);
  3305. if (this._pageMode)
  3306. this.setPosX(this._xPos+this._pageSize.x *ratio,ani);
  3307. else
  3308. this.setPosX(this._xPos+this._scrollStep *ratio,ani);
  3309. }
  3310. __proto.scrollToView=function(target,ani,setFirst){
  3311. (ani===void 0)&& (ani=false);
  3312. (setFirst===void 0)&& (setFirst=false);
  3313. this._owner.ensureBoundsCorrect();
  3314. if(this._needRefresh)
  3315. this.refresh();
  3316. var rect;
  3317. if((target instanceof fairygui.GObject )){
  3318. if(target.parent !=this._owner){
  3319. target.parent.localToGlobalRect(target.x,target.y,
  3320. target.width,target.height,fairygui.ScrollPane.sHelperRect);
  3321. rect=this._owner.globalToLocalRect(fairygui.ScrollPane.sHelperRect.x,fairygui.ScrollPane.sHelperRect.y,
  3322. fairygui.ScrollPane.sHelperRect.width,fairygui.ScrollPane.sHelperRect.height,fairygui.ScrollPane.sHelperRect);
  3323. }
  3324. else {
  3325. rect=fairygui.ScrollPane.sHelperRect;
  3326. rect.setTo(target.x,target.y,target.width,target.height);
  3327. }
  3328. }
  3329. else
  3330. rect=(target);
  3331. if(this._overlapSize.y>0){
  3332. var bottom=this._yPos+this._viewSize.y;
  3333. if(setFirst || rect.y<=this._yPos || rect.height>=this._viewSize.y){
  3334. if(this._pageMode)
  3335. this.setPosY(Math.floor(rect.y/this._pageSize.y)*this._pageSize.y,ani);
  3336. else
  3337. this.setPosY(rect.y,ani);
  3338. }
  3339. else if(rect.y+rect.height>bottom){
  3340. if(this._pageMode)
  3341. this.setPosY(Math.floor(rect.y/this._pageSize.y)*this._pageSize.y,ani);
  3342. else if (rect.height <=this._viewSize.y/2)
  3343. this.setPosY(rect.y+rect.height*2-this._viewSize.y,ani);
  3344. else
  3345. this.setPosY(rect.y+rect.height-this._viewSize.y,ani);
  3346. }
  3347. }
  3348. if(this._overlapSize.x>0){
  3349. var right=this._xPos+this._viewSize.x;
  3350. if(setFirst || rect.x<=this._xPos || rect.width>=this._viewSize.x){
  3351. if(this._pageMode)
  3352. this.setPosX(Math.floor(rect.x/this._pageSize.x)*this._pageSize.x,ani);
  3353. else
  3354. this.setPosX(rect.x,ani);
  3355. }
  3356. else if(rect.x+rect.width>right){
  3357. if(this._pageMode)
  3358. this.setPosX(Math.floor(rect.x/this._pageSize.x)*this._pageSize.x,ani);
  3359. else if (rect.width <=this._viewSize.x/2)
  3360. this.setPosX(rect.x+rect.width*2-this._viewSize.x,ani);
  3361. else
  3362. this.setPosX(rect.x+rect.width-this._viewSize.x,ani);
  3363. }
  3364. }
  3365. if(!ani && this._needRefresh)
  3366. this.refresh();
  3367. }
  3368. __proto.isChildInView=function(obj){
  3369. if(this._overlapSize.y>0){
  3370. var dist=obj.y+this._container.y;
  3371. if(dist<-obj.height || dist>this._viewSize.y)
  3372. return false;
  3373. }
  3374. if(this._overlapSize.x>0){
  3375. dist=obj.x+this._container.x;
  3376. if(dist<-obj.width || dist>this._viewSize.x)
  3377. return false;
  3378. }
  3379. return true;
  3380. }
  3381. __proto.cancelDragging=function(){
  3382. this._owner.displayObject.stage.off("mousemove",this,this.__mouseMove);
  3383. this._owner.displayObject.stage.off("mouseup",this,this.__mouseUp);
  3384. this._owner.displayObject.stage.off("click",this,this.__click);
  3385. if (ScrollPane.draggingPane==this)
  3386. ScrollPane.draggingPane=null;
  3387. ScrollPane._gestureFlag=0;
  3388. this.isDragged=false;
  3389. this._maskContainer.mouseEnabled=true;
  3390. }
  3391. __proto.lockHeader=function(size){
  3392. if (this._headerLockedSize==size)
  3393. return;
  3394. this._headerLockedSize=size;
  3395. if (!this._refreshEventDispatching && this._container[this._refreshBarAxis] >=0){
  3396. this._tweenStart.setTo(this._container.x,this._container.y);
  3397. this._tweenChange.setTo(0,0);
  3398. this._tweenChange[this._refreshBarAxis]=this._headerLockedSize-this._tweenStart[this._refreshBarAxis];
  3399. this._tweenDuration.setTo(0.3,0.3);
  3400. this._tweenTime.setTo(0,0);
  3401. this._tweening=2;
  3402. Laya.timer.frameLoop(1,this,this.tweenUpdate);
  3403. }
  3404. }
  3405. __proto.lockFooter=function(size){
  3406. if (this._footerLockedSize==size)
  3407. return;
  3408. this._footerLockedSize=size;
  3409. if (!this._refreshEventDispatching && this._container[this._refreshBarAxis] <=-this._overlapSize[this._refreshBarAxis]){
  3410. this._tweenStart.setTo(this._container.x,this._container.y);
  3411. this._tweenChange.setTo(0,0);
  3412. var max=this._overlapSize[this._refreshBarAxis];
  3413. if (max==0)
  3414. max=Math.max(this._contentSize[this._refreshBarAxis]+this._footerLockedSize-this._viewSize[this._refreshBarAxis],0);
  3415. else
  3416. max+=this._footerLockedSize;
  3417. this._tweenChange[this._refreshBarAxis]=-max-this._tweenStart[this._refreshBarAxis];
  3418. this._tweenDuration.setTo(0.3,0.3);
  3419. this._tweenTime.setTo(0,0);
  3420. this._tweening=2;
  3421. Laya.timer.frameLoop(1,this,this.tweenUpdate);
  3422. }
  3423. }
  3424. __proto.onOwnerSizeChanged=function(){
  3425. this.setSize(this._owner.width,this._owner.height);
  3426. this.posChanged(false);
  3427. }
  3428. __proto.handleControllerChanged=function(c){
  3429. if (this._pageController==c){
  3430. if (this._scrollType==0)
  3431. this.setCurrentPageX(c.selectedIndex,true);
  3432. else
  3433. this.setCurrentPageY(c.selectedIndex,true);
  3434. }
  3435. }
  3436. __proto.updatePageController=function(){
  3437. if (this._pageController !=null && !this._pageController.changing){
  3438. var index=0;
  3439. if (this._scrollType==0)
  3440. index=this.currentPageX;
  3441. else
  3442. index=this.currentPageY;
  3443. if (index < this._pageController.pageCount){
  3444. var c=this._pageController;
  3445. this._pageController=null;
  3446. c.selectedIndex=index;
  3447. this._pageController=c;
  3448. }
  3449. }
  3450. }
  3451. __proto.adjustMaskContainer=function(){
  3452. var mx=NaN,my=NaN;
  3453. if (this._displayOnLeft && this._vtScrollBar !=null)
  3454. mx=Math.floor(this._owner.margin.left+this._vtScrollBar.width);
  3455. else
  3456. mx=Math.floor(this._owner.margin.left);
  3457. my=Math.floor(this._owner.margin.top);
  3458. this._maskContainer.pos(mx,my);
  3459. if(this._owner._alignOffset.x!=0 || this._owner._alignOffset.y!=0){
  3460. if(this._alignContainer==null){
  3461. this._alignContainer=new Sprite();
  3462. this._maskContainer.addChild(this._alignContainer);
  3463. this._alignContainer.addChild(this._container);
  3464. }
  3465. this._alignContainer.pos(this._owner._alignOffset.x,this._owner._alignOffset.y);
  3466. }
  3467. else if(this._alignContainer){
  3468. this._alignContainer.pos(0,0);
  3469. }
  3470. }
  3471. __proto.setSize=function(aWidth,aHeight){
  3472. this.adjustMaskContainer();
  3473. if (this._hzScrollBar){
  3474. this._hzScrollBar.y=aHeight-this._hzScrollBar.height;
  3475. if(this._vtScrollBar && !this._vScrollNone){
  3476. this._hzScrollBar.width=aWidth-this._vtScrollBar.width-this._scrollBarMargin.left-this._scrollBarMargin.right;
  3477. if(this._displayOnLeft)
  3478. this._hzScrollBar.x=this._scrollBarMargin.left+this._vtScrollBar.width;
  3479. else
  3480. this._hzScrollBar.x=this._scrollBarMargin.left;
  3481. }
  3482. else {
  3483. this._hzScrollBar.width=aWidth-this._scrollBarMargin.left-this._scrollBarMargin.right;
  3484. this._hzScrollBar.x=this._scrollBarMargin.left;
  3485. }
  3486. }
  3487. if (this._vtScrollBar){
  3488. if (!this._displayOnLeft)
  3489. this._vtScrollBar.x=aWidth-this._vtScrollBar.width;
  3490. if(this._hzScrollBar)
  3491. this._vtScrollBar.height=aHeight-this._hzScrollBar.height-this._scrollBarMargin.top-this._scrollBarMargin.bottom;
  3492. else
  3493. this._vtScrollBar.height=aHeight-this._scrollBarMargin.top-this._scrollBarMargin.bottom;
  3494. this._vtScrollBar.y=this._scrollBarMargin.top;
  3495. }
  3496. this._viewSize.x=aWidth;
  3497. this._viewSize.y=aHeight;
  3498. if(this._hzScrollBar && !this._hScrollNone)
  3499. this._viewSize.y-=this._hzScrollBar.height;
  3500. if(this._vtScrollBar && !this._vScrollNone)
  3501. this._viewSize.x-=this._vtScrollBar.width;
  3502. this._viewSize.x-=(this._owner.margin.left+this._owner.margin.right);
  3503. this._viewSize.y-=(this._owner.margin.top+this._owner.margin.bottom);
  3504. this._viewSize.x=Math.max(1,this._viewSize.x);
  3505. this._viewSize.y=Math.max(1,this._viewSize.y);
  3506. this._pageSize.x=this._viewSize.x;
  3507. this._pageSize.y=this._viewSize.y;
  3508. this.handleSizeChanged();
  3509. }
  3510. __proto.setContentSize=function(aWidth,aHeight){
  3511. if(this._contentSize.x==aWidth && this._contentSize.y==aHeight)
  3512. return;
  3513. this._contentSize.x=aWidth;
  3514. this._contentSize.y=aHeight;
  3515. this.handleSizeChanged();
  3516. }
  3517. __proto.changeContentSizeOnScrolling=function(deltaWidth,deltaHeight,deltaPosX,deltaPosY){
  3518. var isRightmost=this._xPos==this._overlapSize.x;
  3519. var isBottom=this._yPos==this._overlapSize.y;
  3520. this._contentSize.x+=deltaWidth;
  3521. this._contentSize.y+=deltaHeight;
  3522. this.handleSizeChanged();
  3523. if (this._tweening==1){
  3524. if (deltaWidth !=0 && isRightmost && this._tweenChange.x < 0){
  3525. this._xPos=this._overlapSize.x;
  3526. this._tweenChange.x=-this._xPos-this._tweenStart.x;
  3527. }
  3528. if (deltaHeight !=0 && isBottom && this._tweenChange.y < 0){
  3529. this._yPos=this._overlapSize.y;
  3530. this._tweenChange.y=-this._yPos-this._tweenStart.y;
  3531. }
  3532. }
  3533. else if (this._tweening==2){
  3534. if (deltaPosX !=0){
  3535. this._container.x-=deltaPosX;
  3536. this._tweenStart.x-=deltaPosX;
  3537. this._xPos=-this._container.x;
  3538. }
  3539. if (deltaPosY !=0){
  3540. this._container.y-=deltaPosY;
  3541. this._tweenStart.y-=deltaPosY;
  3542. this._yPos=-this._container.y;
  3543. }
  3544. }
  3545. else if (this.isDragged){
  3546. if (deltaPosX !=0){
  3547. this._container.x-=deltaPosX;
  3548. this._containerPos.x-=deltaPosX;
  3549. this._xPos=-this._container.x;
  3550. }
  3551. if (deltaPosY !=0){
  3552. this._container.y-=deltaPosY;
  3553. this._containerPos.y-=deltaPosY;
  3554. this._yPos=-this._container.y;
  3555. }
  3556. }
  3557. else{
  3558. if (deltaWidth !=0 && isRightmost){
  3559. this._xPos=this._overlapSize.x;
  3560. this._container.x=-this._xPos;
  3561. }
  3562. if (deltaHeight !=0 && isBottom){
  3563. this._yPos=this._overlapSize.y;
  3564. this._container.y=-this._yPos;
  3565. }
  3566. }
  3567. if (this._pageMode)
  3568. this.updatePageController();
  3569. }
  3570. __proto.handleSizeChanged=function(onScrolling){
  3571. (onScrolling===void 0)&& (onScrolling=false);
  3572. if(this._displayInDemand){
  3573. if(this._vtScrollBar){
  3574. if(this._contentSize.y<=this._viewSize.y){
  3575. if(!this._vScrollNone){
  3576. this._vScrollNone=true;
  3577. this._viewSize.x+=this._vtScrollBar.width;
  3578. }
  3579. }
  3580. else{
  3581. if(this._vScrollNone){
  3582. this._vScrollNone=false;
  3583. this._viewSize.x-=this._vtScrollBar.width;
  3584. }
  3585. }
  3586. }
  3587. if(this._hzScrollBar){
  3588. if(this._contentSize.x<=this._viewSize.x){
  3589. if(!this._hScrollNone){
  3590. this._hScrollNone=true;
  3591. this._viewSize.y+=this._hzScrollBar.height;
  3592. }
  3593. }
  3594. else{
  3595. if(this._hScrollNone){
  3596. this._hScrollNone=false;
  3597. this._viewSize.y-=this._hzScrollBar.height;
  3598. }
  3599. }
  3600. }
  3601. }
  3602. if(this._vtScrollBar){
  3603. if(this._viewSize.y<this._vtScrollBar.minSize)
  3604. this._vtScrollBar.displayObject.visible=false;
  3605. else{
  3606. this._vtScrollBar.displayObject.visible=this._scrollBarVisible && !this._vScrollNone;
  3607. if(this._contentSize.y==0)
  3608. this._vtScrollBar.displayPerc=0;
  3609. else
  3610. this._vtScrollBar.displayPerc=Math.min(1,this._viewSize.y/this._contentSize.y);
  3611. }
  3612. }
  3613. if(this._hzScrollBar){
  3614. if(this._viewSize.x<this._hzScrollBar.minSize)
  3615. this._hzScrollBar.displayObject.visible=false;
  3616. else{
  3617. this._hzScrollBar.displayObject.visible=this._scrollBarVisible && !this._hScrollNone;
  3618. if(this._contentSize.x==0)
  3619. this._hzScrollBar.displayPerc=0;
  3620. else
  3621. this._hzScrollBar.displayPerc=Math.min(1,this._viewSize.x/this._contentSize.x);
  3622. }
  3623. };
  3624. var rect=this._maskContainer.scrollRect;
  3625. if (rect){
  3626. rect.width=this._viewSize.x;
  3627. rect.height=this._viewSize.y;
  3628. this._maskContainer.scrollRect=rect;
  3629. }
  3630. if (this._scrollType==0 || this._scrollType==2)
  3631. this._overlapSize.x=Math.ceil(Math.max(0,this._contentSize.x-this._viewSize.x));
  3632. else
  3633. this._overlapSize.x=0;
  3634. if (this._scrollType==1 || this._scrollType==2)
  3635. this._overlapSize.y=Math.ceil(Math.max(0,this._contentSize.y-this._viewSize.y));
  3636. else
  3637. this._overlapSize.y=0;
  3638. this._xPos=ToolSet.clamp(this._xPos,0,this._overlapSize.x);
  3639. this._yPos=ToolSet.clamp(this._yPos,0,this._overlapSize.y);
  3640. if(this._refreshBarAxis!=null){
  3641. var max=this._overlapSize[this._refreshBarAxis];
  3642. if (max==0)
  3643. max=Math.max(this._contentSize[this._refreshBarAxis]+this._footerLockedSize-this._viewSize[this._refreshBarAxis],0);
  3644. else
  3645. max+=this._footerLockedSize;
  3646. if (this._refreshBarAxis=="x"){
  3647. this._container.pos(ToolSet.clamp(this._container.x,-max,this._headerLockedSize),
  3648. ToolSet.clamp(this._container.y,-this._overlapSize.y,0));
  3649. }
  3650. else{
  3651. this._container.pos(ToolSet.clamp(this._container.x,-this._overlapSize.x,0),
  3652. ToolSet.clamp(this._container.y,-max,this._headerLockedSize));
  3653. }
  3654. if (this._header !=null){
  3655. if (this._refreshBarAxis=="x")
  3656. this._header.height=this._viewSize.y;
  3657. else
  3658. this._header.width=this._viewSize.x;
  3659. }
  3660. if (this._footer !=null){
  3661. if (this._refreshBarAxis=="y")
  3662. this._footer.height=this._viewSize.y;
  3663. else
  3664. this._footer.width=this._viewSize.x;
  3665. }
  3666. }
  3667. else{
  3668. this._container.pos(ToolSet.clamp(this._container.x,-this._overlapSize.x,0),
  3669. ToolSet.clamp(this._container.y,-this._overlapSize.y,0));
  3670. }
  3671. this.syncScrollBar(true);
  3672. this.checkRefreshBar();
  3673. if (this._pageMode)
  3674. this.updatePageController();
  3675. }
  3676. __proto.posChanged=function(ani){
  3677. if (this._aniFlag==0)
  3678. this._aniFlag=ani ? 1 :-1;
  3679. else if (this._aniFlag==1 && !ani)
  3680. this._aniFlag=-1;
  3681. this._needRefresh=true;
  3682. Laya.timer.callLater(this,this.refresh);
  3683. }
  3684. __proto.refresh=function(){
  3685. this._needRefresh=false;
  3686. Laya.timer.clear(this,this.refresh);
  3687. if (this._pageMode || this._snapToItem){
  3688. ScrollPane.sEndPos.setTo(-this._xPos,-this._yPos);
  3689. this.alignPosition(ScrollPane.sEndPos,false);
  3690. this._xPos=-ScrollPane.sEndPos.x;
  3691. this._yPos=-ScrollPane.sEndPos.y;
  3692. }
  3693. this.refresh2();
  3694. if(this._owner&&this._owner.displayObject){
  3695. Events.dispatch("fui_scroll",this._owner.displayObject);
  3696. }
  3697. if (this._needRefresh){
  3698. this._needRefresh=false;
  3699. Laya.timer.clear(this,this.refresh);
  3700. this.refresh2();
  3701. }
  3702. this.syncScrollBar();
  3703. this._aniFlag=0;
  3704. }
  3705. __proto.refresh2=function(){
  3706. if (this._aniFlag==1 && !this.isDragged){
  3707. var posX=NaN;
  3708. var posY=NaN;
  3709. if (this._overlapSize.x > 0)
  3710. posX=-Math.floor(this._xPos);
  3711. else{
  3712. if (this._container.x !=0)
  3713. this._container.x=0;
  3714. posX=0;
  3715. }
  3716. if (this._overlapSize.y > 0)
  3717. posY=-Math.floor(this._yPos);
  3718. else{
  3719. if (this._container.y !=0)
  3720. this._container.y=0;
  3721. posY=0;
  3722. }
  3723. if (posX !=this._container.x || posY !=this._container.y){
  3724. this._tweening=1;
  3725. this._tweenTime.setTo(0,0);
  3726. this._tweenDuration.setTo(0.5,0.5);
  3727. this._tweenStart.setTo(this._container.x,this._container.y);
  3728. this._tweenChange.setTo(posX-this._tweenStart.x,posY-this._tweenStart.y);
  3729. Laya.timer.frameLoop(1,this,this.tweenUpdate);
  3730. }
  3731. else if (this._tweening !=0)
  3732. this.killTween();
  3733. }
  3734. else{
  3735. if (this._tweening !=0)
  3736. this.killTween();
  3737. this._container.pos(Math.floor(-this._xPos),Math.floor(-this._yPos));
  3738. this.loopCheckingCurrent();
  3739. }
  3740. if (this._pageMode)
  3741. this.updatePageController();
  3742. }
  3743. __proto.syncScrollBar=function(end){
  3744. (end===void 0)&& (end=false);
  3745. if (this._vtScrollBar !=null){
  3746. this._vtScrollBar.scrollPerc=this._overlapSize.y==0 ? 0 :ToolSet.clamp(-this._container.y,0,this._overlapSize.y)/ this._overlapSize.y;
  3747. if (this._scrollBarDisplayAuto)
  3748. this.showScrollBar(!end);
  3749. }
  3750. if (this._hzScrollBar !=null){
  3751. this._hzScrollBar.scrollPerc=this._overlapSize.x==0 ? 0 :ToolSet.clamp(-this._container.x,0,this._overlapSize.x)/ this._overlapSize.x;
  3752. if (this._scrollBarDisplayAuto)
  3753. this.showScrollBar(!end);
  3754. }
  3755. if(end)
  3756. this._maskContainer.mouseEnabled=true;
  3757. }
  3758. __proto.__mouseDown=function(){
  3759. if(!this._touchEffect)
  3760. return;
  3761. if(this._tweening!=0){
  3762. this.killTween();
  3763. this.isDragged=true;
  3764. }
  3765. else
  3766. this.isDragged=false;
  3767. var pt=this._owner.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY,fairygui.ScrollPane.sHelperPoint);
  3768. this._containerPos.setTo(this._container.x,this._container.y);
  3769. this._beginTouchPos.setTo(pt.x,pt.y);
  3770. this._lastTouchPos.setTo(pt.x,pt.y);
  3771. this._lastTouchGlobalPos.setTo(Laya.stage.mouseX,Laya.stage.mouseY);
  3772. this._isHoldAreaDone=false;
  3773. this._velocity.setTo(0,0);
  3774. this._velocityScale=1;
  3775. this._lastMoveTime=Laya.timer.currTimer/1000;
  3776. this._owner.displayObject.stage.on("mousemove",this,this.__mouseMove);
  3777. this._owner.displayObject.stage.on("mouseup",this,this.__mouseUp);
  3778. this._owner.displayObject.stage.on("click",this,this.__click);
  3779. }
  3780. __proto.__mouseMove=function(){
  3781. if(!this._touchEffect)
  3782. return;
  3783. if (ScrollPane.draggingPane !=null && ScrollPane.draggingPane !=this || GObject.draggingObject !=null)
  3784. return;
  3785. var sensitivity=UIConfig$1.touchScrollSensitivity;
  3786. var pt=this._owner.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY,fairygui.ScrollPane.sHelperPoint);
  3787. var diff=NaN,diff2=NaN;
  3788. var sv=false,sh=false,st=false;
  3789. if (this._scrollType==1){
  3790. if (!this._isHoldAreaDone){
  3791. ScrollPane._gestureFlag |=1;
  3792. diff=Math.abs(this._beginTouchPos.y-pt.y);
  3793. if (diff < sensitivity)
  3794. return;
  3795. if ((ScrollPane._gestureFlag & 2)!=0){
  3796. diff2=Math.abs(this._beginTouchPos.x-pt.x);
  3797. if (diff < diff2)
  3798. return;
  3799. }
  3800. }
  3801. sv=true;
  3802. }
  3803. else if (this._scrollType==0){
  3804. if (!this._isHoldAreaDone){
  3805. ScrollPane._gestureFlag |=2;
  3806. diff=Math.abs(this._beginTouchPos.x-pt.x);
  3807. if (diff < sensitivity)
  3808. return;
  3809. if ((ScrollPane._gestureFlag & 1)!=0){
  3810. diff2=Math.abs(this._beginTouchPos.y-pt.y);
  3811. if (diff < diff2)
  3812. return;
  3813. }
  3814. }
  3815. sh=true;
  3816. }
  3817. else{
  3818. ScrollPane._gestureFlag=3;
  3819. if (!this._isHoldAreaDone){
  3820. diff=Math.abs(this._beginTouchPos.y-pt.y);
  3821. if (diff < sensitivity){
  3822. diff=Math.abs(this._beginTouchPos.x-pt.x);
  3823. if (diff < sensitivity)
  3824. return;
  3825. }
  3826. }
  3827. sv=sh=true;
  3828. };
  3829. var newPosX=Math.floor(this._containerPos.x+pt.x-this._beginTouchPos.x);
  3830. var newPosY=Math.floor(this._containerPos.y+pt.y-this._beginTouchPos.y);
  3831. if (sv){
  3832. if (newPosY > 0){
  3833. if (!this._bouncebackEffect)
  3834. this._container.y=0;
  3835. else if (this._header !=null && this._header.maxHeight !=0)
  3836. this._container.y=Math.floor(Math.min(newPosY *0.5,this._header.maxHeight));
  3837. else
  3838. this._container.y=Math.floor(Math.min(newPosY *0.5,this._viewSize.y *0.5));
  3839. }
  3840. else if (newPosY <-this._overlapSize.y){
  3841. if (!this._bouncebackEffect)
  3842. this._container.y=-this._overlapSize.y;
  3843. else if (this._footer !=null && this._footer.maxHeight > 0)
  3844. this._container.y=Math.floor(Math.max((newPosY+this._overlapSize.y)*0.5,-this._footer.maxHeight)-this._overlapSize.y);
  3845. else
  3846. this._container.y=Math.floor(Math.max((newPosY+this._overlapSize.y)*0.5,-this._viewSize.y *0.5)-this._overlapSize.y);
  3847. }
  3848. else
  3849. this._container.y=newPosY;
  3850. }
  3851. if (sh){
  3852. if (newPosX > 0){
  3853. if (!this._bouncebackEffect)
  3854. this._container.x=0;
  3855. else if (this._header !=null && this._header.maxWidth !=0)
  3856. this._container.x=Math.floor(Math.min(newPosX *0.5,this._header.maxWidth));
  3857. else
  3858. this._container.x=Math.floor(Math.min(newPosX *0.5,this._viewSize.x *0.5));
  3859. }
  3860. else if (newPosX < 0-this._overlapSize.x){
  3861. if (!this._bouncebackEffect)
  3862. this._container.x=-this._overlapSize.x;
  3863. else if (this._footer !=null && this._footer.maxWidth > 0)
  3864. this._container.x=Math.floor(Math.max((newPosX+this._overlapSize.x)*0.5,-this._footer.maxWidth)-this._overlapSize.x);
  3865. else
  3866. this._container.x=Math.floor(Math.max((newPosX+this._overlapSize.x)*0.5,-this._viewSize.x *0.5)-this._overlapSize.x);
  3867. }
  3868. else
  3869. this._container.x=newPosX;
  3870. };
  3871. var frameRate=Laya.stage.frameRate=="slow"?30:60;
  3872. var now=Laya.timer.currTimer/1000;
  3873. var deltaTime=Math.max(now-this._lastMoveTime,1/frameRate);
  3874. var deltaPositionX=pt.x-this._lastTouchPos.x;
  3875. var deltaPositionY=pt.y-this._lastTouchPos.y;
  3876. if (!sh)
  3877. deltaPositionX=0;
  3878. if (!sv)
  3879. deltaPositionY=0;
  3880. if(deltaTime!=0){
  3881. var elapsed=deltaTime *frameRate-1;
  3882. if (elapsed > 1){
  3883. var factor=Math.pow(0.833,elapsed);
  3884. this._velocity.x=this._velocity.x *factor;
  3885. this._velocity.y=this._velocity.y *factor;
  3886. }
  3887. this._velocity.x=ToolSet.lerp(this._velocity.x,deltaPositionX *60 / frameRate / deltaTime,deltaTime *10);
  3888. this._velocity.y=ToolSet.lerp(this._velocity.y,deltaPositionY *60 / frameRate / deltaTime,deltaTime *10);
  3889. };
  3890. var deltaGlobalPositionX=this._lastTouchGlobalPos.x-Laya.stage.mouseX;
  3891. var deltaGlobalPositionY=this._lastTouchGlobalPos.y-Laya.stage.mouseY;
  3892. if (deltaPositionX !=0)
  3893. this._velocityScale=Math.abs(deltaGlobalPositionX / deltaPositionX);
  3894. else if (deltaPositionY !=0)
  3895. this._velocityScale=Math.abs(deltaGlobalPositionY / deltaPositionY);
  3896. this._lastTouchPos.setTo(pt.x,pt.y);
  3897. this._lastTouchGlobalPos.setTo(Laya.stage.mouseX,Laya.stage.mouseY);
  3898. this._lastMoveTime=now;
  3899. if (this._overlapSize.x > 0)
  3900. this._xPos=ToolSet.clamp(-this._container.x,0,this._overlapSize.x);
  3901. if (this._overlapSize.y > 0)
  3902. this._yPos=ToolSet.clamp(-this._container.y,0,this._overlapSize.y);
  3903. if (this._loop !=0){
  3904. newPosX=this._container.x;
  3905. newPosY=this._container.y;
  3906. if (this.loopCheckingCurrent()){
  3907. this._containerPos.x+=this._container.x-newPosX;
  3908. this._containerPos.y+=this._container.y-newPosY;
  3909. }
  3910. }
  3911. ScrollPane.draggingPane=this;
  3912. this._isHoldAreaDone=true;
  3913. this.isDragged=true;
  3914. this._maskContainer.mouseEnabled=false;
  3915. this.syncScrollBar();
  3916. this.checkRefreshBar();
  3917. if (this._pageMode)
  3918. this.updatePageController();
  3919. Events.dispatch("fui_scroll",this._owner.displayObject);
  3920. }
  3921. __proto.__mouseUp=function(){
  3922. this._owner.displayObject.stage.off("mousemove",this,this.__mouseMove);
  3923. this._owner.displayObject.stage.off("mouseup",this,this.__mouseUp);
  3924. this._owner.displayObject.stage.off("click",this,this.__click);
  3925. if (ScrollPane.draggingPane==this)
  3926. ScrollPane.draggingPane=null;
  3927. ScrollPane._gestureFlag=0;
  3928. if (!this.isDragged || !this._touchEffect){
  3929. this.isDragged=false;
  3930. this._maskContainer.mouseEnabled=true;
  3931. return;
  3932. }
  3933. this.isDragged=false;
  3934. this._maskContainer.mouseEnabled=true;
  3935. this._tweenStart.setTo(this._container.x,this._container.y);
  3936. ScrollPane.sEndPos.setTo(this._tweenStart.x,this._tweenStart.y);
  3937. var flag=false;
  3938. if (this._container.x > 0){
  3939. ScrollPane.sEndPos.x=0;
  3940. flag=true;
  3941. }
  3942. else if (this._container.x <-this._overlapSize.x){
  3943. ScrollPane.sEndPos.x=-this._overlapSize.x;
  3944. flag=true;
  3945. }
  3946. if (this._container.y > 0){
  3947. ScrollPane.sEndPos.y=0;
  3948. flag=true;
  3949. }
  3950. else if (this._container.y <-this._overlapSize.y){
  3951. ScrollPane.sEndPos.y=-this._overlapSize.y;
  3952. flag=true;
  3953. }
  3954. if (flag){
  3955. this._tweenChange.setTo(ScrollPane.sEndPos.x-this._tweenStart.x,ScrollPane.sEndPos.y-this._tweenStart.y);
  3956. if (this._tweenChange.x <-UIConfig$1.touchDragSensitivity || this._tweenChange.y <-UIConfig$1.touchDragSensitivity){
  3957. this._refreshEventDispatching=true;
  3958. Events.dispatch("fui_pull_down_release",this._owner.displayObject);
  3959. this._refreshEventDispatching=false;
  3960. }
  3961. else if (this._tweenChange.x > UIConfig$1.touchDragSensitivity || this._tweenChange.y > UIConfig$1.touchDragSensitivity){
  3962. this._refreshEventDispatching=true;
  3963. Events.dispatch("fui_pull_up_release",this._owner.displayObject);
  3964. this._refreshEventDispatching=false;
  3965. }
  3966. if (this._headerLockedSize > 0 && ScrollPane.sEndPos[this._refreshBarAxis]==0){
  3967. ScrollPane.sEndPos[this._refreshBarAxis]=this._headerLockedSize;
  3968. this._tweenChange.x=ScrollPane.sEndPos.x-this._tweenStart.x;
  3969. this._tweenChange.y=ScrollPane.sEndPos.y-this._tweenStart.y;
  3970. }
  3971. else if (this._footerLockedSize > 0 && ScrollPane.sEndPos[this._refreshBarAxis]==-this._overlapSize[this._refreshBarAxis]){
  3972. var max=this._overlapSize[this._refreshBarAxis];
  3973. if (max==0)
  3974. max=Math.max(this._contentSize[this._refreshBarAxis]+this._footerLockedSize-this._viewSize[this._refreshBarAxis],0);
  3975. else
  3976. max+=this._footerLockedSize;
  3977. ScrollPane.sEndPos[this._refreshBarAxis]=-max;
  3978. this._tweenChange.x=ScrollPane.sEndPos.x-this._tweenStart.x;
  3979. this._tweenChange.y=ScrollPane.sEndPos.y-this._tweenStart.y;
  3980. }
  3981. this._tweenDuration.setTo(0.3,0.3);
  3982. }
  3983. else{
  3984. if (!this._inertiaDisabled){
  3985. var frameRate=Laya.stage.frameRate=="slow"?30:60;
  3986. var elapsed=(Laya.timer.currTimer/1000-this._lastMoveTime)*frameRate-1;
  3987. if (elapsed > 1){
  3988. var factor=Math.pow(0.833,elapsed);
  3989. this._velocity.x=this._velocity.x *factor;
  3990. this._velocity.y=this._velocity.y *factor;
  3991. }
  3992. this.updateTargetAndDuration(this._tweenStart,ScrollPane.sEndPos);
  3993. }
  3994. else
  3995. this._tweenDuration.setTo(0.3,0.3);
  3996. ScrollPane.sOldChange.setTo(ScrollPane.sEndPos.x-this._tweenStart.x,ScrollPane.sEndPos.y-this._tweenStart.y);
  3997. this.loopCheckingTarget(ScrollPane.sEndPos);
  3998. if (this._pageMode || this._snapToItem)
  3999. this.alignPosition(ScrollPane.sEndPos,true);
  4000. this._tweenChange.x=ScrollPane.sEndPos.x-this._tweenStart.x;
  4001. this._tweenChange.y=ScrollPane.sEndPos.y-this._tweenStart.y;
  4002. if (this._tweenChange.x==0 && this._tweenChange.y==0){
  4003. if (this._scrollBarDisplayAuto)
  4004. this.showScrollBar(false);
  4005. return;
  4006. }
  4007. if (this._pageMode || this._snapToItem){
  4008. this.fixDuration("x",ScrollPane.sOldChange.x);
  4009. this.fixDuration("y",ScrollPane.sOldChange.y);
  4010. }
  4011. }
  4012. this._tweening=2;
  4013. this._tweenTime.setTo(0,0);
  4014. Laya.timer.frameLoop(1,this,this.tweenUpdate);
  4015. }
  4016. __proto.__click=function(){
  4017. this.isDragged=false;
  4018. }
  4019. __proto.__mouseWheel=function(evt){
  4020. if(!this._mouseWheelEnabled)
  4021. return;
  4022. var pt=this._owner.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY,fairygui.ScrollPane.sHelperPoint);
  4023. var delta=evt["delta"];
  4024. delta=delta>0?-1:(delta<0?1:0);
  4025. if (this._overlapSize.x > 0 && this._overlapSize.y==0){
  4026. if (this._pageMode)
  4027. this.setPosX(this._xPos+this._pageSize.x *delta,false);
  4028. else
  4029. this.setPosX(this._xPos+this._mouseWheelStep *delta,false);
  4030. }
  4031. else {
  4032. if (this._pageMode)
  4033. this.setPosY(this._yPos+this._pageSize.y *delta,false);
  4034. else
  4035. this.setPosY(this._yPos+this._mouseWheelStep *delta,false);
  4036. }
  4037. }
  4038. __proto.__rollOver=function(){
  4039. this.showScrollBar(true);
  4040. }
  4041. __proto.__rollOut=function(){
  4042. this.showScrollBar(false);
  4043. }
  4044. __proto.showScrollBar=function(val){
  4045. if (val){
  4046. this.__showScrollBar(true);
  4047. Laya.timer.clear(this,this.__showScrollBar);
  4048. }
  4049. else
  4050. Laya.timer.once(500,this,this.__showScrollBar,[val]);
  4051. }
  4052. __proto.__showScrollBar=function(val){
  4053. this._scrollBarVisible=val && this._viewSize.x>0 && this._viewSize.y>0;
  4054. if (this._vtScrollBar)
  4055. this._vtScrollBar.displayObject.visible=this._scrollBarVisible && !this._vScrollNone;
  4056. if (this._hzScrollBar)
  4057. this._hzScrollBar.displayObject.visible=this._scrollBarVisible && !this._hScrollNone;
  4058. }
  4059. __proto.getLoopPartSize=function(division,axis){
  4060. return (this._contentSize[axis]+(axis=="x" ? (this._owner).columnGap :(this._owner).lineGap))/ division;
  4061. }
  4062. __proto.loopCheckingCurrent=function(){
  4063. var changed=false;
  4064. if (this._loop==1 && this._overlapSize.x > 0){
  4065. if (this._xPos < 0.001){
  4066. this._xPos+=this.getLoopPartSize(2,"x");
  4067. changed=true;
  4068. }
  4069. else if (this._xPos >=this._overlapSize.x){
  4070. this._xPos-=this.getLoopPartSize(2,"x");
  4071. changed=true;
  4072. }
  4073. }
  4074. else if (this._loop==2 && this._overlapSize.y > 0){
  4075. if (this._yPos < 0.001){
  4076. this._yPos+=this.getLoopPartSize(2,"y");
  4077. changed=true;
  4078. }
  4079. else if (this._yPos >=this._overlapSize.y){
  4080. this._yPos-=this.getLoopPartSize(2,"y");
  4081. changed=true;
  4082. }
  4083. }
  4084. if (changed)
  4085. this._container.pos(Math.floor(-this._xPos),Math.floor(-this._yPos));
  4086. return changed;
  4087. }
  4088. __proto.loopCheckingTarget=function(endPos){
  4089. if (this._loop==1)
  4090. this.loopCheckingTarget2(endPos,"x");
  4091. if (this._loop==2)
  4092. this.loopCheckingTarget2(endPos,"y");
  4093. }
  4094. __proto.loopCheckingTarget2=function(endPos,axis){
  4095. var halfSize=NaN;
  4096. var tmp=NaN;
  4097. if (endPos[axis] > 0){
  4098. halfSize=this.getLoopPartSize(2,axis);
  4099. tmp=this._tweenStart[axis]-halfSize;
  4100. if (tmp <=0 && tmp >=-this._overlapSize[axis]){
  4101. endPos[axis]-=halfSize;
  4102. this._tweenStart[axis]=tmp;
  4103. }
  4104. }
  4105. else if (endPos[axis] <-this._overlapSize[axis]){
  4106. halfSize=this.getLoopPartSize(2,axis);
  4107. tmp=this._tweenStart[axis]+halfSize;
  4108. if (tmp <=0 && tmp >=-this._overlapSize[axis]){
  4109. endPos[axis]+=halfSize;
  4110. this._tweenStart[axis]=tmp;
  4111. }
  4112. }
  4113. }
  4114. __proto.loopCheckingNewPos=function(value,axis){
  4115. if (this._overlapSize[axis]==0)
  4116. return value;
  4117. var pos=axis=="x" ? this._xPos :this._yPos;
  4118. var changed=false;
  4119. var v=NaN;
  4120. if (value < 0.001){
  4121. value+=this.getLoopPartSize(2,axis);
  4122. if (value > pos){
  4123. v=this.getLoopPartSize(6,axis);
  4124. v=Math.ceil((value-pos)/ v)*v;
  4125. pos=ToolSet.clamp(pos+v,0,this._overlapSize[axis]);
  4126. changed=true;
  4127. }
  4128. }
  4129. else if (value >=this._overlapSize[axis]){
  4130. value-=this.getLoopPartSize(2,axis);
  4131. if (value < pos){
  4132. v=this.getLoopPartSize(6,axis);
  4133. v=Math.ceil((pos-value)/ v)*v;
  4134. pos=ToolSet.clamp(pos-v,0,this._overlapSize[axis]);
  4135. changed=true;
  4136. }
  4137. }
  4138. if (changed){
  4139. if (axis=="x")
  4140. this._container.x=-Math.floor(pos);
  4141. else
  4142. this._container.y=-Math.floor(pos);
  4143. }
  4144. return value;
  4145. }
  4146. __proto.alignPosition=function(pos,inertialScrolling){
  4147. if (this._pageMode){
  4148. pos.x=this.alignByPage(pos.x,"x",inertialScrolling);
  4149. pos.y=this.alignByPage(pos.y,"y",inertialScrolling);
  4150. }
  4151. else if (this._snapToItem){
  4152. var pt=this._owner.getSnappingPosition(-pos.x,-pos.y,ScrollPane.sHelperPoint);
  4153. if (pos.x < 0 && pos.x >-this._overlapSize.x)
  4154. pos.x=-pt.x;
  4155. if (pos.y < 0 && pos.y >-this._overlapSize.y)
  4156. pos.y=-pt.y;
  4157. }
  4158. }
  4159. __proto.alignByPage=function(pos,axis,inertialScrolling){
  4160. var page=0;
  4161. if (pos > 0)
  4162. page=0;
  4163. else if (pos <-this._overlapSize[axis])
  4164. page=Math.ceil(this._contentSize[axis] / this._pageSize[axis])-1;
  4165. else{
  4166. page=Math.floor(-pos / this._pageSize[axis]);
  4167. var change=inertialScrolling ? (pos-this._containerPos[axis]):(pos-this._container[axis]);
  4168. var testPageSize=Math.min(this._pageSize[axis],this._contentSize[axis]-(page+1)*this._pageSize[axis]);
  4169. var delta=-pos-page *this._pageSize[axis];
  4170. if (Math.abs(change)> this._pageSize[axis]){
  4171. if (delta > testPageSize *0.5)
  4172. page++;
  4173. }
  4174. else{
  4175. if (delta > testPageSize *(change < 0 ? 0.3 :0.7))
  4176. page++;
  4177. }
  4178. pos=-page *this._pageSize[axis];
  4179. if (pos <-this._overlapSize[axis])
  4180. pos=-this._overlapSize[axis];
  4181. }
  4182. if (inertialScrolling){
  4183. var oldPos=this._tweenStart[axis];
  4184. var oldPage=0;
  4185. if (oldPos > 0)
  4186. oldPage=0;
  4187. else if (oldPos <-this._overlapSize[axis])
  4188. oldPage=Math.ceil(this._contentSize[axis] / this._pageSize[axis])-1;
  4189. else
  4190. oldPage=Math.floor(-oldPos / this._pageSize[axis]);
  4191. var startPage=Math.floor(-this._containerPos[axis] / this._pageSize[axis]);
  4192. if (Math.abs(page-startPage)> 1 && Math.abs(oldPage-startPage)<=1){
  4193. if (page > startPage)
  4194. page=startPage+1;
  4195. else
  4196. page=startPage-1;
  4197. pos=-page *this._pageSize[axis];
  4198. }
  4199. }
  4200. return pos;
  4201. }
  4202. __proto.updateTargetAndDuration=function(orignPos,resultPos){
  4203. resultPos.x=this.updateTargetAndDuration2(orignPos.x,"x");
  4204. resultPos.y=this.updateTargetAndDuration2(orignPos.y,"y");
  4205. }
  4206. __proto.updateTargetAndDuration2=function(pos,axis){
  4207. var v=this._velocity[axis];
  4208. var duration=0;
  4209. if (pos > 0)
  4210. pos=0;
  4211. else if (pos <-this._overlapSize[axis])
  4212. pos=-this._overlapSize[axis];
  4213. else{
  4214. var v2=Math.abs(v)*this._velocityScale;
  4215. if(Browser.onMobile)
  4216. v2 *=1136 / Math.max(Laya.stage.width,Laya.stage.height);
  4217. var ratio=0;
  4218. if (this._pageMode || !Browser.onMobile){
  4219. if (v2 > 500)
  4220. ratio=Math.pow((v2-500)/ 500,2);
  4221. }
  4222. else{
  4223. if (v2 > 1000)
  4224. ratio=Math.pow((v2-1000)/ 1000,2);
  4225. }
  4226. if (ratio !=0){
  4227. if (ratio > 1)
  4228. ratio=1;
  4229. v2 *=ratio;
  4230. v *=ratio;
  4231. this._velocity[axis]=v;
  4232. duration=Math.log(60 / v2)/Math.log(this._decelerationRate)/ 60;
  4233. var change=Math.floor(v *duration *0.4);
  4234. pos+=change;
  4235. }
  4236. }
  4237. if (duration < 0.3)
  4238. duration=0.3;
  4239. this._tweenDuration[axis]=duration;
  4240. return pos;
  4241. }
  4242. __proto.fixDuration=function(axis,oldChange){
  4243. if (this._tweenChange[axis]==0 || Math.abs(this._tweenChange[axis])>=Math.abs(oldChange))
  4244. return;
  4245. var newDuration=Math.abs(this._tweenChange[axis] / oldChange)*this._tweenDuration[axis];
  4246. if (newDuration < 0.3)
  4247. newDuration=0.3;
  4248. this._tweenDuration[axis]=newDuration;
  4249. }
  4250. __proto.killTween=function(){
  4251. if (this._tweening==1){
  4252. this._container.pos(this._tweenStart.x+this._tweenChange.x,this._tweenStart.y+this._tweenChange.y);
  4253. Events.dispatch("fui_scroll",this._owner.displayObject);
  4254. }
  4255. this._tweening=0;
  4256. Laya.timer.clear(this,this.tweenUpdate);
  4257. Events.dispatch("fui_scroll_end",this._owner.displayObject);
  4258. }
  4259. __proto.checkRefreshBar=function(){
  4260. if (this._header==null && this._footer==null)
  4261. return;
  4262. var pos=this._container[this._refreshBarAxis];
  4263. if (this._header !=null){
  4264. if (pos > 0){
  4265. if (this._header.displayObject.parent==null)
  4266. this._maskContainer.addChildAt(this._header.displayObject,0);
  4267. var pt=ScrollPane.sHelperPoint;
  4268. pt.setTo(this._header.width,this._header.height);
  4269. pt[this._refreshBarAxis]=pos;
  4270. this._header.setSize(pt.x,pt.y);
  4271. }
  4272. else{
  4273. if (this._header.displayObject.parent !=null)
  4274. this._maskContainer.removeChild(this._header.displayObject);
  4275. }
  4276. }
  4277. if (this._footer !=null){
  4278. var max=this._overlapSize[this._refreshBarAxis];
  4279. if (pos <-max || max==0 && this._footerLockedSize > 0){
  4280. if (this._footer.displayObject.parent==null)
  4281. this._maskContainer.addChildAt(this._footer.displayObject,0);
  4282. pt=ScrollPane.sHelperPoint;
  4283. pt.setTo(this._footer.x,this._footer.y);
  4284. if (max > 0)
  4285. pt[this._refreshBarAxis]=pos+this._contentSize[this._refreshBarAxis];
  4286. else
  4287. pt[this._refreshBarAxis]=Math.max(Math.min(pos+this._viewSize[this._refreshBarAxis],this._viewSize[this._refreshBarAxis]-this._footerLockedSize),
  4288. this._viewSize[this._refreshBarAxis]-this._contentSize[this._refreshBarAxis]);
  4289. this._footer.setXY(pt.x,pt.y);
  4290. pt.setTo(this._footer.width,this._footer.height);
  4291. if (max > 0)
  4292. pt[this._refreshBarAxis]=-max-pos;
  4293. else
  4294. pt[this._refreshBarAxis]=this._viewSize[this._refreshBarAxis]-this._footer[this._refreshBarAxis];
  4295. this._footer.setSize(pt.x,pt.y);
  4296. }
  4297. else{
  4298. if (this._footer.displayObject.parent !=null)
  4299. this._maskContainer.removeChild(this._footer.displayObject);
  4300. }
  4301. }
  4302. }
  4303. __proto.tweenUpdate=function(){
  4304. var nx=this.runTween("x");
  4305. var ny=this.runTween("y");
  4306. this._container.pos(nx,ny);
  4307. if (this._tweening==2){
  4308. if (this._overlapSize.x > 0)
  4309. this._xPos=ToolSet.clamp(-nx,0,this._overlapSize.x);
  4310. if (this._overlapSize.y > 0)
  4311. this._yPos=ToolSet.clamp(-ny,0,this._overlapSize.y);
  4312. if (this._pageMode)
  4313. this.updatePageController();
  4314. }
  4315. if (this._tweenChange.x==0 && this._tweenChange.y==0){
  4316. this._tweening=0;
  4317. Laya.timer.clear(this,this.tweenUpdate);
  4318. this.loopCheckingCurrent();
  4319. this.syncScrollBar(true);
  4320. this.checkRefreshBar();
  4321. Events.dispatch("fui_scroll",this._owner.displayObject);
  4322. Events.dispatch("fui_scroll_end",this._owner.displayObject);
  4323. }
  4324. else{
  4325. this.syncScrollBar(false);
  4326. this.checkRefreshBar();
  4327. Events.dispatch("fui_scroll",this._owner.displayObject);
  4328. }
  4329. }
  4330. __proto.runTween=function(axis){
  4331. var newValue=NaN;
  4332. if (this._tweenChange[axis] !=0){
  4333. this._tweenTime[axis]+=Laya.timer.delta/1000;
  4334. if (this._tweenTime[axis] >=this._tweenDuration[axis]){
  4335. newValue=this._tweenStart[axis]+this._tweenChange[axis];
  4336. this._tweenChange[axis]=0;
  4337. }
  4338. else{
  4339. var ratio=ScrollPane.easeFunc(this._tweenTime[axis],this._tweenDuration[axis]);
  4340. newValue=this._tweenStart[axis]+Math.floor(this._tweenChange[axis] *ratio);
  4341. };
  4342. var threshold1=0;
  4343. var threshold2=-this._overlapSize[axis];
  4344. if (this._headerLockedSize > 0 && this._refreshBarAxis==axis)
  4345. threshold1=this._headerLockedSize;
  4346. if (this._footerLockedSize > 0 && this._refreshBarAxis==axis){
  4347. var max=this._overlapSize[this._refreshBarAxis];
  4348. if (max==0)
  4349. max=Math.max(this._contentSize[this._refreshBarAxis]+this._footerLockedSize-this._viewSize[this._refreshBarAxis],0);
  4350. else
  4351. max+=this._footerLockedSize;
  4352. threshold2=-max;
  4353. }
  4354. if (this._tweening==2 && this._bouncebackEffect){
  4355. if (newValue > 20+threshold1 && this._tweenChange[axis] > 0
  4356. || newValue > threshold1 && this._tweenChange[axis]==0){
  4357. this._tweenTime[axis]=0;
  4358. this._tweenDuration[axis]=0.3;
  4359. this._tweenChange[axis]=-newValue+threshold1;
  4360. this._tweenStart[axis]=newValue;
  4361. }
  4362. else if (newValue < threshold2-20 && this._tweenChange[axis] < 0
  4363. || newValue < threshold2 && this._tweenChange[axis]==0){
  4364. this._tweenTime[axis]=0;
  4365. this._tweenDuration[axis]=0.3;
  4366. this._tweenChange[axis]=threshold2-newValue;
  4367. this._tweenStart[axis]=newValue;
  4368. }
  4369. }
  4370. else{
  4371. if (newValue > threshold1){
  4372. newValue=threshold1;
  4373. this._tweenChange[axis]=0;
  4374. }
  4375. else if (newValue < threshold2){
  4376. newValue=threshold2;
  4377. this._tweenChange[axis]=0;
  4378. }
  4379. }
  4380. }
  4381. else
  4382. newValue=this._container[axis];
  4383. return newValue;
  4384. }
  4385. __getset(0,__proto,'viewWidth',function(){
  4386. return this._viewSize.x;
  4387. },function(value){
  4388. value=value+this._owner.margin.left+this._owner.margin.right;
  4389. if (this._vtScrollBar !=null)
  4390. value+=this._vtScrollBar.width;
  4391. this._owner.width=value;
  4392. });
  4393. __getset(0,__proto,'percY',function(){
  4394. return this._overlapSize.y==0 ? 0 :this._yPos / this._overlapSize.y;
  4395. },function(value){
  4396. this.setPercY(value,false);
  4397. });
  4398. __getset(0,__proto,'owner',function(){
  4399. return this._owner;
  4400. });
  4401. __getset(0,__proto,'bouncebackEffect',function(){
  4402. return this._bouncebackEffect;
  4403. },function(sc){
  4404. this._bouncebackEffect=sc;
  4405. });
  4406. __getset(0,__proto,'vtScrollBar',function(){
  4407. return this._vtScrollBar;
  4408. });
  4409. __getset(0,__proto,'hzScrollBar',function(){
  4410. return this._hzScrollBar;
  4411. });
  4412. __getset(0,__proto,'header',function(){
  4413. return this._header;
  4414. });
  4415. __getset(0,__proto,'footer',function(){
  4416. return this._footer;
  4417. });
  4418. __getset(0,__proto,'isBottomMost',function(){
  4419. return this._yPos==this._overlapSize.y || this._overlapSize.y==0;
  4420. });
  4421. __getset(0,__proto,'touchEffect',function(){
  4422. return this._touchEffect;
  4423. },function(sc){
  4424. this._touchEffect=sc;
  4425. });
  4426. __getset(0,__proto,'contentWidth',function(){
  4427. return this._contentSize.x;
  4428. });
  4429. __getset(0,__proto,'scrollStep',function(){
  4430. return this._scrollStep;
  4431. },function(val){
  4432. this._scrollStep=val;
  4433. if(this._scrollStep==0)
  4434. this._scrollStep=UIConfig$1.defaultScrollStep;
  4435. this._mouseWheelStep=this._scrollStep*2;
  4436. });
  4437. __getset(0,__proto,'viewHeight',function(){
  4438. return this._viewSize.y;
  4439. },function(value){
  4440. value=value+this._owner.margin.top+this._owner.margin.bottom;
  4441. if (this._hzScrollBar !=null)
  4442. value+=this._hzScrollBar.height;
  4443. this._owner.height=value;
  4444. });
  4445. __getset(0,__proto,'posX',function(){
  4446. return this._xPos;
  4447. },function(value){
  4448. this.setPosX(value,false);
  4449. });
  4450. __getset(0,__proto,'snapToItem',function(){
  4451. return this._snapToItem;
  4452. },function(value){
  4453. this._snapToItem=value;
  4454. });
  4455. __getset(0,__proto,'mouseWheelEnabled',function(){
  4456. return this._mouseWheelEnabled;
  4457. },function(value){
  4458. this._mouseWheelEnabled=value;
  4459. });
  4460. __getset(0,__proto,'decelerationRate',function(){
  4461. return this._decelerationRate;
  4462. },function(value){
  4463. this._decelerationRate=value;
  4464. });
  4465. __getset(0,__proto,'percX',function(){
  4466. return this._overlapSize.x==0 ? 0 :this._xPos / this._overlapSize.x;
  4467. },function(value){
  4468. this.setPercX(value,false);
  4469. });
  4470. __getset(0,__proto,'posY',function(){
  4471. return this._yPos;
  4472. },function(value){
  4473. this.setPosY(value,false);
  4474. });
  4475. __getset(0,__proto,'contentHeight',function(){
  4476. return this._contentSize.y;
  4477. });
  4478. __getset(0,__proto,'currentPageX',function(){
  4479. if (!this._pageMode)
  4480. return 0;
  4481. var page=Math.floor(this._xPos / this._pageSize.x);
  4482. if (this._xPos-page *this._pageSize.x > this._pageSize.x *0.5)
  4483. page++;
  4484. return page;
  4485. },function(value){
  4486. this.setCurrentPageX(value,false);
  4487. });
  4488. __getset(0,__proto,'currentPageY',function(){
  4489. if (!this._pageMode)
  4490. return 0;
  4491. var page=Math.floor(this._yPos / this._pageSize.y);
  4492. if (this._yPos-page *this._pageSize.y > this._pageSize.y *0.5)
  4493. page++;
  4494. return page;
  4495. },function(value){
  4496. this.setCurrentPageY(value,false);
  4497. });
  4498. __getset(0,__proto,'isRightMost',function(){
  4499. return this._xPos==this._overlapSize.x || this._overlapSize.x==0;
  4500. });
  4501. __getset(0,__proto,'pageController',function(){
  4502. return this._pageController;
  4503. },function(value){
  4504. this._pageController=value;
  4505. });
  4506. __getset(0,__proto,'scrollingPosX',function(){
  4507. return ToolSet.clamp(-this._container.x,0,this._overlapSize.x);
  4508. });
  4509. __getset(0,__proto,'scrollingPosY',function(){
  4510. return ToolSet.clamp(-this._container.y,0,this._overlapSize.y);
  4511. });
  4512. ScrollPane.easeFunc=function(t,d){
  4513. return (t=t / d-1)*t *t+1;
  4514. }
  4515. ScrollPane.draggingPane=null;
  4516. ScrollPane._gestureFlag=0;
  4517. ScrollPane.TWEEN_TIME_GO=0.5;
  4518. ScrollPane.TWEEN_TIME_DEFAULT=0.3;
  4519. ScrollPane.PULL_RATIO=0.5;
  4520. __static(ScrollPane,
  4521. ['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();}
  4522. ]);
  4523. return ScrollPane;
  4524. })()
  4525. //class fairygui.ScrollType
  4526. var ScrollType=(function(){
  4527. function ScrollType(){}
  4528. __class(ScrollType,'fairygui.ScrollType');
  4529. ScrollType.Horizontal=0;
  4530. ScrollType.Vertical=1;
  4531. ScrollType.Both=2;
  4532. return ScrollType;
  4533. })()
  4534. //class fairygui.Transition
  4535. var Transition=(function(){
  4536. var TransitionActionType,TransitionItem,TweenConfig,TValue_Visible,TValue_Animation,TValue_Sound,TValue_Transition,TValue_Shake,TValue_Text,TValue;
  4537. function Transition(owner){
  4538. this.name=null;
  4539. this._owner=null;
  4540. this._ownerBaseX=NaN;
  4541. this._ownerBaseY=NaN;
  4542. this._items=null;
  4543. this._totalTimes=0;
  4544. this._totalTasks=0;
  4545. this._playing=false;
  4546. this._paused=false;
  4547. this._onComplete=null;
  4548. this._options=0;
  4549. this._reversed=false;
  4550. this._totalDuration=NaN;
  4551. this._autoPlay=false;
  4552. this._autoPlayTimes=0;
  4553. this._autoPlayDelay=NaN;
  4554. this._timeScale=NaN;
  4555. this._startTime=NaN;
  4556. this._endTime=NaN;
  4557. this.OPTION_IGNORE_DISPLAY_CONTROLLER=1;
  4558. this.OPTION_AUTO_STOP_DISABLED=2;
  4559. this.OPTION_AUTO_STOP_AT_END=4;
  4560. this._owner=owner;
  4561. this._items=[];
  4562. this._totalDuration=0;
  4563. this._autoPlayTimes=1;
  4564. this._autoPlayDelay=0;
  4565. this._timeScale=1;
  4566. this._startTime=0;
  4567. this._endTime=0;
  4568. }
  4569. __class(Transition,'fairygui.Transition');
  4570. var __proto=Transition.prototype;
  4571. __proto.play=function(onComplete,times,delay,startTime,endTime){
  4572. (times===void 0)&& (times=1);
  4573. (delay===void 0)&& (delay=0);
  4574. (startTime===void 0)&& (startTime=0);
  4575. (endTime===void 0)&& (endTime=-1);
  4576. this._play(onComplete,times,delay,startTime,endTime,false);
  4577. }
  4578. __proto.playReverse=function(onComplete,times,delay,startTime,endTime){
  4579. (times===void 0)&& (times=1);
  4580. (delay===void 0)&& (delay=0);
  4581. (startTime===void 0)&& (startTime=0);
  4582. (endTime===void 0)&& (endTime=-1);
  4583. this._play(onComplete,1,delay,startTime,endTime,true);
  4584. }
  4585. __proto.changePlayTimes=function(value){
  4586. this._totalTimes=value;
  4587. }
  4588. __proto.setAutoPlay=function(value,times,delay){
  4589. (times===void 0)&& (times=1);
  4590. (delay===void 0)&& (delay=0);
  4591. if (this._autoPlay !=value){
  4592. this._autoPlay=value;
  4593. this._autoPlayTimes=times;
  4594. this._autoPlayDelay=delay;
  4595. if (this._autoPlay){
  4596. if (this._owner.onStage)
  4597. this.play(null,null,this._autoPlayTimes,this._autoPlayDelay);
  4598. }
  4599. else{
  4600. if (!this._owner.onStage)
  4601. this.stop(false,true);
  4602. }
  4603. }
  4604. }
  4605. __proto._play=function(onComplete,times,delay,startTime,endTime,reversed){
  4606. (times===void 0)&& (times=1);
  4607. (delay===void 0)&& (delay=0);
  4608. (startTime===void 0)&& (startTime=0);
  4609. (endTime===void 0)&& (endTime=-1);
  4610. (reversed===void 0)&& (reversed=false);
  4611. this.stop(true,true);
  4612. this._totalTimes=times;
  4613. this._reversed=reversed;
  4614. this._startTime=startTime;
  4615. this._endTime=endTime;
  4616. this._playing=true;
  4617. this._paused=false;
  4618. this._onComplete=onComplete;
  4619. var cnt=this._items.length;
  4620. for (var i=0;i < cnt;i++){
  4621. var item=this._items[i];
  4622. if(item.target==null){
  4623. if (item.targetId)
  4624. item.target=this._owner.getChildById(item.targetId);
  4625. else
  4626. item.target=this._owner;
  4627. }
  4628. else if (item.target !=this._owner && item.target.parent !=this._owner)
  4629. item.target=null;
  4630. if (item.target !=null && item.type==10){
  4631. var trans=(item.target).getTransition(item.value.transName);
  4632. if(trans==this)
  4633. trans=null;
  4634. if (trans !=null){
  4635. if (item.value.playTimes==0){
  4636. var j=0;
  4637. for (j=i-1;j >=0;j--){
  4638. var item2=this._items[j];
  4639. if (item2.type==10){
  4640. if (item2.value.trans==trans){
  4641. item2.value.stopTime=item.time-item2.time;
  4642. break ;
  4643. }
  4644. }
  4645. }
  4646. if(j<0)
  4647. item.value.stopTime=0;
  4648. else
  4649. trans=null;
  4650. }
  4651. else
  4652. item.value.stopTime=-1;
  4653. }
  4654. item.value.trans=trans;
  4655. }
  4656. }
  4657. if(delay==0)
  4658. this.onDelayedPlay();
  4659. else
  4660. GTween.delayedCall(delay).onComplete(this.onDelayedPlay,this);
  4661. }
  4662. __proto.stop=function(setToComplete,processCallback){
  4663. (setToComplete===void 0)&& (setToComplete=true);
  4664. (processCallback===void 0)&& (processCallback=false);
  4665. if (!this._playing)
  4666. return;
  4667. this._playing=false;
  4668. this._totalTasks=0;
  4669. this._totalTimes=0;
  4670. var handler=this._onComplete;
  4671. this._onComplete=null;
  4672. GTween.kill(this);
  4673. var cnt=this._items.length;
  4674. if(this._reversed){
  4675. for (var i=cnt-1;i >=0;i--){
  4676. var item=this._items[i];
  4677. if(item.target==null)
  4678. continue ;
  4679. this.stopItem(item,setToComplete);
  4680. }
  4681. }
  4682. else{
  4683. for (i=0;i < cnt;i++){
  4684. item=this._items[i];
  4685. if(item.target==null)
  4686. continue ;
  4687. this.stopItem(item,setToComplete);
  4688. }
  4689. }
  4690. if (processCallback && handler !=null){
  4691. handler.run();
  4692. }
  4693. }
  4694. __proto.stopItem=function(item,setToComplete){
  4695. if (item.displayLockToken!=0){
  4696. item.target.releaseDisplayLock(item.displayLockToken);
  4697. item.displayLockToken=0;
  4698. }
  4699. if (item.tweener !=null){
  4700. item.tweener.kill(setToComplete);
  4701. item.tweener=null;
  4702. if (item.type==11 && !setToComplete){
  4703. item.target._gearLocked=true;
  4704. item.target.setXY(item.target.x-item.value.lastOffsetX,item.target.y-item.value.lastOffsetY);
  4705. item.target._gearLocked=false;
  4706. }
  4707. }
  4708. if (item.type==10){
  4709. var trans=item.value.trans;
  4710. if (trans !=null)
  4711. trans.stop(setToComplete,false);
  4712. }
  4713. }
  4714. __proto.setPaused=function(paused){
  4715. if (!this._playing || this._paused==paused)
  4716. return;
  4717. this._paused=paused;
  4718. var tweener=GTween.getTween(this);
  4719. if (tweener !=null)
  4720. tweener.setPaused(paused);
  4721. var cnt=this._items.length;
  4722. for (var i=0;i < cnt;i++){
  4723. var item=this._items[i];
  4724. if (item.target==null)
  4725. continue ;
  4726. if (item.type==10){
  4727. if (item.value.trans !=null)
  4728. item.value.trans.setPaused(paused);
  4729. }
  4730. else if (item.type==7){
  4731. if (paused){
  4732. item.value.flag=(item.target).playing;
  4733. (item.target).playing=false;
  4734. }
  4735. else
  4736. (item.target).playing=item.value.flag;
  4737. }
  4738. if (item.tweener !=null)
  4739. item.tweener.setPaused(paused);
  4740. }
  4741. }
  4742. __proto.dispose=function(){
  4743. if(this._playing)
  4744. GTween.kill(this);
  4745. var cnt=this._items.length;
  4746. for (var i=0;i < cnt;i++){
  4747. var item=this._items[i];
  4748. if (item.tweener !=null){
  4749. item.tweener.kill();
  4750. item.tweener=null;
  4751. }
  4752. item.target=null;
  4753. item.hook=null;
  4754. if (item.tweenConfig !=null)
  4755. item.tweenConfig.endHook=null;
  4756. }
  4757. this._items.length=0;
  4758. this._playing=false;
  4759. this._onComplete=null;
  4760. }
  4761. __proto.setValue=function(label,__args){
  4762. var args=[];for(var i=1,sz=arguments.length;i<sz;i++)args.push(arguments[i]);
  4763. var cnt=this._items.length;
  4764. var value;
  4765. for (var i=0;i < cnt;i++){
  4766. var item=this._items[i];
  4767. if (item.label==label){
  4768. if (item.tweenConfig !=null)
  4769. value=item.tweenConfig.startValue;
  4770. else
  4771. value=item.value;
  4772. }
  4773. else if (item.tweenConfig !=null && item.tweenConfig.endLabel==label){
  4774. value=item.tweenConfig.endValue;
  4775. }
  4776. else
  4777. continue ;
  4778. switch (item.type){
  4779. case 0:
  4780. case 1:
  4781. case 3:
  4782. case 2:
  4783. case 13:
  4784. value.b1=true;
  4785. value.b2=true;
  4786. value.f1=parseFloat(args[0]);
  4787. value.f2=parseFloat(args[1]);
  4788. break ;
  4789. case 4:
  4790. value.f1=parseFloat(args[0]);
  4791. break ;
  4792. case 5:
  4793. value.f1=parseFloat(args[0]);
  4794. break ;
  4795. case 6:
  4796. value.f1=parseFloat(args[0]);
  4797. break ;
  4798. case 7:
  4799. value.frame=parseInt(args[0]);
  4800. if (args.length > 1)
  4801. value.playing=args[1];
  4802. break ;
  4803. case 8:
  4804. value.visible=args[0];
  4805. break ;
  4806. case 9:
  4807. value.sound=args[0];
  4808. if(args.length > 1)
  4809. value.volume=parseFloat(args[1]);
  4810. break ;
  4811. case 10:
  4812. value.transName=args[0];
  4813. if (args.length > 1)
  4814. value.playTimes=parseInt(args[1]);
  4815. break ;
  4816. case 11:
  4817. value.amplitude=parseFloat(args[0]);
  4818. if (args.length > 1)
  4819. value.duration=parseFloat(args[1]);
  4820. break ;
  4821. case 12:
  4822. value.f1=parseFloat(args[0]);
  4823. value.f2=parseFloat(args[1]);
  4824. value.f3=parseFloat(args[2]);
  4825. value.f4=parseFloat(args[3]);
  4826. break ;
  4827. case 14:
  4828. case 15:
  4829. value.text=args[0];
  4830. break ;
  4831. }
  4832. }
  4833. }
  4834. __proto.setHook=function(label,callback){
  4835. var cnt=this._items.length;
  4836. for (var i=0;i < cnt;i++){
  4837. var item=this._items[i];
  4838. if (item.label==label){
  4839. item.hook=callback;
  4840. break ;
  4841. }
  4842. else if (item.tweenConfig !=null && item.tweenConfig.endLabel==label){
  4843. item.tweenConfig.endHook=callback;
  4844. break ;
  4845. }
  4846. }
  4847. }
  4848. __proto.clearHooks=function(){
  4849. var cnt=this._items.length;
  4850. for (var i=0;i < cnt;i++){
  4851. var item=this._items[i];
  4852. item.hook=null;
  4853. if (item.tweenConfig !=null)
  4854. item.tweenConfig.endHook=null;
  4855. }
  4856. }
  4857. __proto.setTarget=function(label,newTarget){
  4858. var cnt=this._items.length;
  4859. for (var i=0;i < cnt;i++){
  4860. var item=this._items[i];
  4861. if (item.label==label){
  4862. item.targetId=newTarget.id;
  4863. item.target=null;
  4864. }
  4865. }
  4866. }
  4867. __proto.setDuration=function(label,value){
  4868. var cnt=this._items.length;
  4869. for (var i=0;i < cnt;i++){
  4870. var item=this._items[i];
  4871. if (item.tweenConfig !=null && item.label==label)
  4872. item.tweenConfig.duration=value;
  4873. }
  4874. }
  4875. __proto.getLabelTime=function(label){
  4876. var cnt=this._items.length;
  4877. for (var i=0;i < cnt;i++){
  4878. var item=this._items[i];
  4879. if (item.label==label)
  4880. return item.time;
  4881. else if (item.tweenConfig !=null && item.tweenConfig.endLabel==label)
  4882. return item.time+item.tweenConfig.duration;
  4883. }
  4884. return Number.NaN;
  4885. }
  4886. __proto.updateFromRelations=function(targetId,dx,dy){
  4887. var cnt=this._items.length;
  4888. if (cnt==0)
  4889. return;
  4890. for (var i=0;i < cnt;i++){
  4891. var item=this._items[i];
  4892. if (item.type==0 && item.targetId==targetId){
  4893. if (item.tweenConfig!=null){
  4894. item.tweenConfig.startValue.f1+=dx;
  4895. item.tweenConfig.startValue.f2+=dy;
  4896. item.tweenConfig.endValue.f1+=dx;
  4897. item.tweenConfig.endValue.f2+=dy;
  4898. }
  4899. else{
  4900. item.value.f1+=dx;
  4901. item.value.f2+=dy;
  4902. }
  4903. }
  4904. }
  4905. }
  4906. __proto.onOwnerAddedToStage=function(){
  4907. if (this._autoPlay && !this._playing)
  4908. this.play(null,this._autoPlayTimes,this._autoPlayDelay);
  4909. }
  4910. __proto.onOwnerRemovedFromStage=function(){
  4911. if ((this._options & this.OPTION_AUTO_STOP_DISABLED)==0)
  4912. this.stop((this._options & this.OPTION_AUTO_STOP_AT_END)!=0 ? true :false,false);
  4913. }
  4914. __proto.onDelayedPlay=function(){
  4915. this.internalPlay();
  4916. this._playing=this._totalTasks>0;
  4917. if (this._playing){
  4918. if ((this._options & this.OPTION_IGNORE_DISPLAY_CONTROLLER)!=0){
  4919. var cnt=this._items.length;
  4920. for (var i=0;i < cnt;i++){
  4921. var item=this._items[i];
  4922. if (item.target !=null && item.target!=this._owner)
  4923. item.displayLockToken=item.target.addDisplayLock();
  4924. }
  4925. }
  4926. }
  4927. else if (this._onComplete !=null){
  4928. var handler=this._onComplete;
  4929. this._onComplete=null;
  4930. handler.run();
  4931. }
  4932. }
  4933. __proto.internalPlay=function(){
  4934. this._ownerBaseX=this._owner.x;
  4935. this._ownerBaseY=this._owner.y;
  4936. this._totalTasks=0;
  4937. var cnt=this._items.length;
  4938. var item;
  4939. var needSkipAnimations=false;
  4940. if (!this._reversed){
  4941. for (var i=0;i < cnt;i++){
  4942. item=this._items[i];
  4943. if (item.target==null)
  4944. continue ;
  4945. if (item.type==7 && this._startTime !=0 && item.time <=this._startTime){
  4946. needSkipAnimations=true;
  4947. item.value.flag=false;
  4948. }
  4949. else
  4950. this.playItem(item);
  4951. }
  4952. }
  4953. else{
  4954. for (i=cnt-1;i >=0;i--){
  4955. item=this._items[i];
  4956. if (item.target==null)
  4957. continue ;
  4958. this.playItem(item);
  4959. }
  4960. }
  4961. if (needSkipAnimations)
  4962. this.skipAnimations();
  4963. }
  4964. __proto.playItem=function(item){
  4965. var time=NaN;
  4966. if (item.tweenConfig !=null){
  4967. if (this._reversed)
  4968. time=(this._totalDuration-item.time-item.tweenConfig.duration);
  4969. else
  4970. time=item.time;
  4971. if (this._endTime==-1 || time <=this._endTime){
  4972. var startValue;
  4973. var endValue;
  4974. if(this._reversed){
  4975. startValue=item.tweenConfig.endValue;
  4976. endValue=item.tweenConfig.startValue;
  4977. }
  4978. else{
  4979. startValue=item.tweenConfig.startValue;
  4980. endValue=item.tweenConfig.endValue;
  4981. }
  4982. item.value.b1=startValue.b1 || endValue.b1;
  4983. item.value.b2=startValue.b2 || endValue.b2;
  4984. switch(item.type){
  4985. case 0:
  4986. case 1:
  4987. case 2:
  4988. case 13:
  4989. item.tweener=GTween.to2(startValue.f1,startValue.f2,endValue.f1,endValue.f2,item.tweenConfig.duration);
  4990. break ;
  4991. case 4:
  4992. case 5:
  4993. item.tweener=GTween.to(startValue.f1,endValue.f1,item.tweenConfig.duration);
  4994. break ;
  4995. case 6:
  4996. item.tweener=GTween.toColor(startValue.f1,endValue.f1,item.tweenConfig.duration);
  4997. break ;
  4998. case 12:
  4999. item.tweener=GTween.to4(startValue.f1,startValue.f2,startValue.f3,startValue.f4,
  5000. endValue.f1,endValue.f2,endValue.f3,endValue.f4,item.tweenConfig.duration);
  5001. break ;
  5002. }
  5003. item.tweener.setDelay(time)
  5004. .setEase(item.tweenConfig.easeType)
  5005. .setRepeat(item.tweenConfig.repeat,item.tweenConfig.yoyo)
  5006. .setTimeScale(this._timeScale)
  5007. .setTarget(item)
  5008. .onStart(this.onTweenStart,this)
  5009. .onUpdate(this.onTweenUpdate,this)
  5010. .onComplete(this.onTweenComplete,this);
  5011. if (this._endTime >=0)
  5012. item.tweener.setBreakpoint(this._endTime-time);
  5013. this._totalTasks++;
  5014. }
  5015. }
  5016. else if(item.type==11){
  5017. if (this._reversed)
  5018. time=(this._totalDuration-item.time-item.value.duration);
  5019. else
  5020. time=item.time;
  5021. item.value.offsetX=item.value.offsetY=0;
  5022. item.value.lastOffsetX=item.value.lastOffsetY=0;
  5023. item.tweener=GTween.shake(0,0,item.value.amplitude,item.value.duration)
  5024. .setDelay(time)
  5025. .setTimeScale(this._timeScale)
  5026. .setTarget(item)
  5027. .onUpdate(this.onTweenUpdate,this)
  5028. .onComplete(this.onTweenComplete,this);
  5029. if (this._endTime >=0)
  5030. item.tweener.setBreakpoint(this._endTime-item.time);
  5031. this._totalTasks++;
  5032. }
  5033. else{
  5034. if (this._reversed)
  5035. time=(this._totalDuration-item.time);
  5036. else
  5037. time=item.time;
  5038. if (time <=this._startTime){
  5039. this.applyValue(item);
  5040. this.callHook(item,false);
  5041. }
  5042. else if (this._endTime==-1 || time <=this._endTime){
  5043. this._totalTasks++;
  5044. item.tweener=GTween.delayedCall(time)
  5045. .setTimeScale(this._timeScale)
  5046. .setTarget(item)
  5047. .onComplete(this.onDelayedPlayItem,this);
  5048. }
  5049. }
  5050. if (item.tweener !=null)
  5051. item.tweener.seek(this._startTime);
  5052. }
  5053. __proto.skipAnimations=function(){
  5054. var frame=0;
  5055. var playStartTime=NaN;
  5056. var playTotalTime=NaN;
  5057. var value;
  5058. var target;
  5059. var item;
  5060. var cnt=this._items.length;
  5061. for (var i=0;i < cnt;i++){
  5062. item=this._items[i];
  5063. if (item.type !=7 || item.time > this._startTime)
  5064. continue ;
  5065. value=item.value;
  5066. if (value.flag)
  5067. continue ;
  5068. target=(item.target);
  5069. frame=target.frame;
  5070. playStartTime=target.playing ? 0 :-1;
  5071. playTotalTime=0;
  5072. for (var j=i;j < cnt;j++){
  5073. item=this._items[j];
  5074. if (item.type !=7 || item.target !=target || item.time > this._startTime)
  5075. continue ;
  5076. value=item.value;
  5077. value.flag=true;
  5078. if (value.frame !=-1){
  5079. frame=value.frame;
  5080. if (value.playing)
  5081. playStartTime=item.time;
  5082. else
  5083. playStartTime=-1;
  5084. playTotalTime=0;
  5085. }
  5086. else{
  5087. if (value.playing){
  5088. if (playStartTime < 0)
  5089. playStartTime=item.time;
  5090. }
  5091. else{
  5092. if (playStartTime >=0)
  5093. playTotalTime+=(item.time-playStartTime);
  5094. playStartTime=-1;
  5095. }
  5096. }
  5097. this.callHook(item,false);
  5098. }
  5099. if (playStartTime >=0)
  5100. playTotalTime+=(this._startTime-playStartTime);
  5101. target.playing=playStartTime>=0;
  5102. target.frame=frame;
  5103. if (playTotalTime > 0)
  5104. target.advance(playTotalTime*1000);
  5105. }
  5106. }
  5107. __proto.onDelayedPlayItem=function(tweener){
  5108. var item=tweener.target;
  5109. item.tweener=null;
  5110. this._totalTasks--;
  5111. this.applyValue(item);
  5112. this.callHook(item,false);
  5113. this.checkAllComplete();
  5114. }
  5115. __proto.onTweenStart=function(tweener){
  5116. var item=tweener.target;
  5117. if (item.type==0 || item.type==1){
  5118. var startValue;
  5119. var endValue;
  5120. if (this._reversed){
  5121. startValue=item.tweenConfig.endValue;
  5122. endValue=item.tweenConfig.startValue;
  5123. }
  5124. else{
  5125. startValue=item.tweenConfig.startValue;
  5126. endValue=item.tweenConfig.endValue;
  5127. }
  5128. if (item.type==0){
  5129. if (item.target !=this._owner){
  5130. if (!startValue.b1)
  5131. startValue.f1=item.target.x;
  5132. if (!startValue.b2)
  5133. startValue.f2=item.target.y;
  5134. }
  5135. else{
  5136. if (!startValue.b1)
  5137. startValue.f1=item.target.x-this._ownerBaseX;
  5138. if (!startValue.b2)
  5139. startValue.f2=item.target.y-this._ownerBaseY;
  5140. }
  5141. }
  5142. else{
  5143. if (!startValue.b1)
  5144. startValue.f1=item.target.width;
  5145. if (!startValue.b2)
  5146. startValue.f2=item.target.height;
  5147. }
  5148. if (!endValue.b1)
  5149. endValue.f1=startValue.f1;
  5150. if (!endValue.b2)
  5151. endValue.f2=startValue.f2;
  5152. tweener.startValue.x=startValue.f1;
  5153. tweener.startValue.y=startValue.f2;
  5154. tweener.endValue.x=endValue.f1;
  5155. tweener.endValue.y=endValue.f2;
  5156. }
  5157. this.callHook(item,false);
  5158. }
  5159. __proto.onTweenUpdate=function(tweener){
  5160. var item=tweener.target;
  5161. switch (item.type){
  5162. case 0:
  5163. case 1:
  5164. case 2:
  5165. case 13:
  5166. item.value.f1=tweener.value.x;
  5167. item.value.f2=tweener.value.y;
  5168. break ;
  5169. case 4:
  5170. case 5:
  5171. item.value.f1=tweener.value.x;
  5172. break ;
  5173. case 6:
  5174. item.value.f1=tweener.value.color;
  5175. break ;
  5176. case 12:
  5177. item.value.f1=tweener.value.x;
  5178. item.value.f2=tweener.value.y;
  5179. item.value.f3=tweener.value.z;
  5180. item.value.f4=tweener.value.w;
  5181. break ;
  5182. case 11:
  5183. item.value.offsetX=tweener.deltaValue.x;
  5184. item.value.offsetY=tweener.deltaValue.y;
  5185. break ;
  5186. }
  5187. this.applyValue(item);
  5188. }
  5189. __proto.onTweenComplete=function(tweener){
  5190. var item=tweener.target;
  5191. item.tweener=null;
  5192. this._totalTasks--;
  5193. if (tweener.allCompleted)
  5194. this.callHook(item,true);
  5195. this.checkAllComplete();
  5196. }
  5197. __proto.onPlayTransCompleted=function(item){
  5198. this._totalTasks--;
  5199. this.checkAllComplete();
  5200. }
  5201. __proto.callHook=function(item,tweenEnd){
  5202. if (tweenEnd){
  5203. if (item.tweenConfig!=null && item.tweenConfig.endHook !=null)
  5204. item.tweenConfig.endHook.run();
  5205. }
  5206. else{
  5207. if (item.time >=this._startTime && item.hook !=null)
  5208. item.hook.run();
  5209. }
  5210. }
  5211. __proto.checkAllComplete=function(){
  5212. if (this._playing && this._totalTasks==0){
  5213. if (this._totalTimes < 0){
  5214. this.internalPlay();
  5215. }
  5216. else{
  5217. this._totalTimes--;
  5218. if (this._totalTimes > 0)
  5219. this.internalPlay();
  5220. else{
  5221. this._playing=false;
  5222. var cnt=this._items.length;
  5223. for (var i=0;i < cnt;i++){
  5224. var item=this._items[i];
  5225. if (item.target !=null && item.displayLockToken!=0){
  5226. item.target.releaseDisplayLock(item.displayLockToken);
  5227. item.displayLockToken=0;
  5228. }
  5229. }
  5230. if (this._onComplete !=null){
  5231. var handler=this._onComplete;
  5232. this._onComplete=null;
  5233. handler.run();
  5234. }
  5235. }
  5236. }
  5237. }
  5238. }
  5239. __proto.applyValue=function(item){
  5240. item.target._gearLocked=true;
  5241. switch (item.type){
  5242. case 0:
  5243. if(item.target==this._owner){
  5244. var f1=NaN,f2=NaN;
  5245. if (!item.value.b1)
  5246. f1=item.target.x;
  5247. else
  5248. f1=item.value.f1+this._ownerBaseX;
  5249. if (!item.value.b2)
  5250. f2=item.target.y;
  5251. else
  5252. f2=item.value.f2+this._ownerBaseY;
  5253. item.target.setXY(f1,f2);
  5254. }
  5255. else{
  5256. if (!item.value.b1)
  5257. item.value.f1=item.target.x;
  5258. if (!item.value.b2)
  5259. item.value.f2=item.target.y;
  5260. item.target.setXY(item.value.f1,item.value.f2);
  5261. }
  5262. break ;
  5263. case 1:
  5264. if (!item.value.b1)
  5265. item.value.f1=item.target.width;
  5266. if (!item.value.b2)
  5267. item.value.f2=item.target.height;
  5268. item.target.setSize(item.value.f1,item.value.f2);
  5269. break ;
  5270. case 3:
  5271. item.target.setPivot(item.value.f1,item.value.f2,item.target.pivotAsAnchor);
  5272. break ;
  5273. case 4:
  5274. item.target.alpha=item.value.f1;
  5275. break ;
  5276. case 5:
  5277. item.target.rotation=item.value.f1;
  5278. break ;
  5279. case 2:
  5280. item.target.setScale(item.value.f1,item.value.f2);
  5281. break ;
  5282. case 13:
  5283. item.target.setSkew(item.value.f1,item.value.f2);
  5284. break ;
  5285. case 6:
  5286. (item.target).color=ToolSet.convertToHtmlColor(item.value.f1,false);
  5287. break ;
  5288. case 7:
  5289. if (item.value.frame>=0)
  5290. (item.target).frame=item.value.frame;
  5291. (item.target).playing=item.value.playing;
  5292. (item.target).timeScale=this._timeScale;
  5293. break ;
  5294. case 8:
  5295. item.target.visible=item.value.visible;
  5296. break ;
  5297. case 10:
  5298. if (this._playing){
  5299. var trans=item.value.trans;
  5300. if (trans !=null){
  5301. this._totalTasks++;
  5302. var startTime=this._startTime > item.time ? (this._startTime-item.time):0;
  5303. var endTime=this._endTime >=0 ? (this._endTime-item.time):-1;
  5304. if (item.value.stopTime >=0 && (endTime < 0 || endTime > item.value.stopTime))
  5305. endTime=item.value.stopTime;
  5306. trans.timeScale=this._timeScale;
  5307. trans._play(Handler.create(this,this.onPlayTransCompleted,[item]),item.value.playTimes,0,startTime,endTime,this._reversed);
  5308. }
  5309. }
  5310. break ;
  5311. case 9:
  5312. if (this._playing && item.time >=this._startTime){
  5313. if(item.value.audioClip==null){
  5314. var pi=UIPackage.getItemByURL(item.value.sound);
  5315. if(pi)
  5316. item.value.audioClip=pi.file;
  5317. else
  5318. item.value.audioClip=item.value.sound;
  5319. }
  5320. if(item.value.audioClip)
  5321. GRoot.inst.playOneShotSound(item.value.audioClip,item.value.volume);
  5322. }
  5323. break ;
  5324. case 11:
  5325. item.target.setXY(item.target.x-item.value.lastOffsetX+item.value.offsetX,item.target.y-item.value.lastOffsetY+item.value.offsetY);
  5326. item.value.lastOffsetX=item.value.offsetX;
  5327. item.value.lastOffsetY=item.value.offsetY;
  5328. break ;
  5329. case 12:{
  5330. var arr=item.target.filters;
  5331. var cm=new ColorMatrix();
  5332. cm.adjustBrightness(item.value.f1);
  5333. cm.adjustContrast(item.value.f2);
  5334. cm.adjustSaturation(item.value.f3);
  5335. cm.adjustHue(item.value.f4);
  5336. arr=[new ColorFilter(cm)];
  5337. item.target.filters=arr;
  5338. break ;
  5339. }
  5340. case 14:
  5341. item.target.text=item.value.text;
  5342. break ;
  5343. case 15:
  5344. item.target.icon=item.value.text;
  5345. break ;
  5346. }
  5347. item.target._gearLocked=false;
  5348. }
  5349. __proto.setup=function(buffer){
  5350. this.name=buffer.readS();
  5351. this._options=buffer.getInt32();
  5352. this._autoPlay=buffer.readBool();
  5353. this._autoPlayTimes=buffer.getInt32();
  5354. this._autoPlayDelay=buffer.getFloat32();
  5355. var cnt=buffer.getInt16();
  5356. for (var i=0;i < cnt;i++){
  5357. var dataLen=buffer.getInt16();
  5358. var curPos=buffer.pos;
  5359. buffer.seek(curPos,0);
  5360. var item=new TransitionItem(buffer.readByte());
  5361. this._items[i]=item;
  5362. item.time=buffer.getFloat32();
  5363. var targetId=buffer.getInt16();
  5364. if (targetId < 0)
  5365. item.targetId="";
  5366. else
  5367. item.targetId=this._owner.getChildAt(targetId).id;
  5368. item.label=buffer.readS();
  5369. if (buffer.readBool()){
  5370. buffer.seek(curPos,1);
  5371. item.tweenConfig=new TweenConfig();
  5372. item.tweenConfig.duration=buffer.getFloat32();
  5373. if (item.time+item.tweenConfig.duration > this._totalDuration)
  5374. this._totalDuration=item.time+item.tweenConfig.duration;
  5375. item.tweenConfig.easeType=buffer.readByte();
  5376. item.tweenConfig.repeat=buffer.getInt32();
  5377. item.tweenConfig.yoyo=buffer.readBool();
  5378. item.tweenConfig.endLabel=buffer.readS();
  5379. buffer.seek(curPos,2);
  5380. this.decodeValue(item,buffer,item.tweenConfig.startValue);
  5381. buffer.seek(curPos,3);
  5382. this.decodeValue(item,buffer,item.tweenConfig.endValue);
  5383. }
  5384. else{
  5385. if (item.time > this._totalDuration)
  5386. this._totalDuration=item.time;
  5387. buffer.seek(curPos,2);
  5388. this.decodeValue(item,buffer,item.value);
  5389. }
  5390. buffer.pos=curPos+dataLen;
  5391. }
  5392. }
  5393. __proto.decodeValue=function(item,buffer,value){
  5394. switch(item.type){
  5395. case 0:
  5396. case 1:
  5397. case 3:
  5398. case 13:
  5399. value.b1=buffer.readBool();
  5400. value.b2=buffer.readBool();
  5401. value.f1=buffer.getFloat32();
  5402. value.f2=buffer.getFloat32();
  5403. break ;
  5404. case 4:
  5405. case 5:
  5406. value.f1=buffer.getFloat32();
  5407. break ;
  5408. case 2:
  5409. value.f1=buffer.getFloat32();
  5410. value.f2=buffer.getFloat32();
  5411. break ;
  5412. case 6:
  5413. value.f1=buffer.readColor();
  5414. break ;
  5415. case 7:
  5416. value.playing=buffer.readBool();
  5417. value.frame=buffer.getInt32();
  5418. break ;
  5419. case 8:
  5420. value.visible=buffer.readBool();
  5421. break ;
  5422. case 9:
  5423. value.sound=buffer.readS();
  5424. value.volume=buffer.getFloat32();
  5425. break ;
  5426. case 10:
  5427. value.transName=buffer.readS();
  5428. value.playTimes=buffer.getInt32();
  5429. break ;
  5430. case 11:
  5431. value.amplitude=buffer.getFloat32();
  5432. value.duration=buffer.getFloat32();
  5433. break ;
  5434. case 12:
  5435. value.f1=buffer.getFloat32();
  5436. value.f2=buffer.getFloat32();
  5437. value.f3=buffer.getFloat32();
  5438. value.f4=buffer.getFloat32();
  5439. break ;
  5440. case 14:
  5441. case 15:
  5442. value.text=buffer.readS();
  5443. break ;
  5444. }
  5445. }
  5446. __getset(0,__proto,'playing',function(){
  5447. return this._playing;
  5448. },function(value){
  5449. this._playing=value;
  5450. }
  5451. );
  5452. __getset(0,__proto,'timeScale',function(){
  5453. return this._timeScale;
  5454. },function(value){
  5455. if(this._timeScale !=value){
  5456. this._timeScale=value;
  5457. if (this._playing){
  5458. var cnt=this._items.length;
  5459. for (var i=0;i < cnt;i++){
  5460. var item=this._items[i];
  5461. if (item.tweener !=null)
  5462. item.tweener.setTimeScale(value);
  5463. else if (item.type==10){
  5464. if(item.value.trans !=null)
  5465. item.value.trans.timeScale=value;
  5466. }
  5467. else if(item.type==7){
  5468. if(item.target !=null)
  5469. (item.target).timeScale=value;
  5470. }
  5471. }
  5472. }
  5473. }
  5474. });
  5475. Transition.__init$=function(){
  5476. //class TransitionActionType
  5477. TransitionActionType=(function(){
  5478. function TransitionActionType(){}
  5479. __class(TransitionActionType,'');
  5480. TransitionActionType.XY=0;
  5481. TransitionActionType.Size=1;
  5482. TransitionActionType.Scale=2;
  5483. TransitionActionType.Pivot=3;
  5484. TransitionActionType.Alpha=4;
  5485. TransitionActionType.Rotation=5;
  5486. TransitionActionType.Color=6;
  5487. TransitionActionType.Animation=7;
  5488. TransitionActionType.Visible=8;
  5489. TransitionActionType.Sound=9;
  5490. TransitionActionType.Transition=10;
  5491. TransitionActionType.Shake=11;
  5492. TransitionActionType.ColorFilter=12;
  5493. TransitionActionType.Skew=13;
  5494. TransitionActionType.Text=14;
  5495. TransitionActionType.Icon=15;
  5496. TransitionActionType.Unknown=16;
  5497. return TransitionActionType;
  5498. })()
  5499. //class TransitionItem
  5500. TransitionItem=(function(){
  5501. function TransitionItem(type){
  5502. this.time=NaN;
  5503. this.targetId=null;
  5504. this.type=0;
  5505. this.tweenConfig=null;
  5506. this.label=null;
  5507. this.value=null;
  5508. this.hook=null;
  5509. this.tweener=null;
  5510. this.target=null;
  5511. this.displayLockToken=0;
  5512. this.type=type;
  5513. switch (type){
  5514. case 0:
  5515. case 1:
  5516. case 2:
  5517. case 3:
  5518. case 13:
  5519. case 4:
  5520. case 5:
  5521. case 6:
  5522. case 12:
  5523. this.value=new TValue();
  5524. break ;
  5525. case 7:
  5526. this.value=new TValue_Animation();
  5527. break ;
  5528. case 11:
  5529. this.value=new TValue_Shake();
  5530. break ;
  5531. case 9:
  5532. this.value=new TValue_Sound();
  5533. break ;
  5534. case 10:
  5535. this.value=new TValue_Transition();
  5536. break ;
  5537. case 8:
  5538. this.value=new TValue_Visible();
  5539. break ;
  5540. case 14:
  5541. case 15:
  5542. this.value=new TValue_Text();
  5543. break ;
  5544. }
  5545. }
  5546. __class(TransitionItem,'');
  5547. return TransitionItem;
  5548. })()
  5549. //class TweenConfig
  5550. TweenConfig=(function(){
  5551. function TweenConfig(){
  5552. this.duration=NaN;
  5553. this.easeType=0;
  5554. this.repeat=0;
  5555. this.yoyo=false;
  5556. this.startValue=null;
  5557. this.endValue=null;
  5558. this.endLabel=null;
  5559. this.endHook=null;
  5560. this.easeType=5;
  5561. this.startValue=new TValue();
  5562. this.endValue=new TValue();
  5563. }
  5564. __class(TweenConfig,'');
  5565. return TweenConfig;
  5566. })()
  5567. //class TValue_Visible
  5568. TValue_Visible=(function(){
  5569. function TValue_Visible(){
  5570. this.visible=false;
  5571. }
  5572. __class(TValue_Visible,'');
  5573. return TValue_Visible;
  5574. })()
  5575. //class TValue_Animation
  5576. TValue_Animation=(function(){
  5577. function TValue_Animation(){
  5578. this.frame=0;
  5579. this.playing=false;
  5580. this.flag=false;
  5581. }
  5582. __class(TValue_Animation,'');
  5583. return TValue_Animation;
  5584. })()
  5585. //class TValue_Sound
  5586. TValue_Sound=(function(){
  5587. function TValue_Sound(){
  5588. this.sound=null;
  5589. this.volume=NaN;
  5590. this.audioClip=null;
  5591. }
  5592. __class(TValue_Sound,'');
  5593. return TValue_Sound;
  5594. })()
  5595. //class TValue_Transition
  5596. TValue_Transition=(function(){
  5597. function TValue_Transition(){
  5598. this.transName=null;
  5599. this.playTimes=0;
  5600. this.trans=null;
  5601. this.stopTime=NaN;
  5602. }
  5603. __class(TValue_Transition,'');
  5604. return TValue_Transition;
  5605. })()
  5606. //class TValue_Shake
  5607. TValue_Shake=(function(){
  5608. function TValue_Shake(){
  5609. this.amplitude=NaN;
  5610. this.duration=NaN;
  5611. this.offsetX=NaN;
  5612. this.offsetY=NaN;
  5613. this.lastOffsetX=NaN;
  5614. this.lastOffsetY=NaN;
  5615. }
  5616. __class(TValue_Shake,'');
  5617. return TValue_Shake;
  5618. })()
  5619. //class TValue_Text
  5620. TValue_Text=(function(){
  5621. function TValue_Text(){
  5622. this.text=null;
  5623. }
  5624. __class(TValue_Text,'');
  5625. return TValue_Text;
  5626. })()
  5627. //class TValue
  5628. TValue=(function(){
  5629. function TValue(){
  5630. this.f1=NaN;
  5631. this.f2=NaN;
  5632. this.f3=NaN;
  5633. this.f4=NaN;
  5634. this.b1=false;
  5635. this.b2=false;
  5636. this.b1=this.b2=true;
  5637. }
  5638. __class(TValue,'');
  5639. return TValue;
  5640. })()
  5641. }
  5642. return Transition;
  5643. })()
  5644. //class fairygui.TranslationHelper
  5645. var TranslationHelper=(function(){
  5646. function TranslationHelper(){}
  5647. __class(TranslationHelper,'fairygui.TranslationHelper');
  5648. TranslationHelper.loadFromXML=function(source){
  5649. TranslationHelper.strings={};
  5650. var xml=Utils.parseXMLFromString(source);
  5651. var resNode=TranslationHelper.findChildNode(xml,"resources");
  5652. var nodes=resNode.childNodes;
  5653. var length1=nodes.length;
  5654. for (var i1=0;i1 < length1;i1++){
  5655. var cxml=nodes[i1];
  5656. if (cxml.nodeName=="string"){
  5657. var key=cxml.getAttribute("name");
  5658. var text=cxml.textContent;
  5659. var i=key.indexOf("-");
  5660. if(i==-1)
  5661. continue ;
  5662. var key2=key.substr(0,i);
  5663. var key3=key.substr(i+1);
  5664. var col=TranslationHelper.strings[key2];
  5665. if(!col){
  5666. col={};
  5667. TranslationHelper.strings[key2]=col;
  5668. }
  5669. col[key3]=text;
  5670. }
  5671. }
  5672. }
  5673. TranslationHelper.translateComponent=function(item){
  5674. if(TranslationHelper.strings==null)
  5675. return;
  5676. var compStrings=TranslationHelper.strings[item.owner.id+item.id];
  5677. if(compStrings==null)
  5678. return;
  5679. var elementId,value;
  5680. var buffer=item.rawData;
  5681. var nextPos=0;
  5682. var itemCount=0;
  5683. var i=0,j=0,k=0;
  5684. var dataLen=0;
  5685. var curPos=0;
  5686. var valueCnt=0;
  5687. var page;
  5688. buffer.seek(0,2);
  5689. var childCount=buffer.getInt16();
  5690. for (i=0;i < childCount;i++){
  5691. dataLen=buffer.getInt16();
  5692. curPos=buffer.pos;
  5693. buffer.seek(curPos,0);
  5694. var type=buffer.readByte();
  5695. buffer.skip(4);
  5696. elementId=buffer.readS();
  5697. if (type==9){
  5698. if (buffer.seek(curPos,6))
  5699. type=buffer.readByte();
  5700. }
  5701. buffer.seek(curPos,1);
  5702. if((value=compStrings[elementId+"-tips"])!=null)
  5703. buffer.writeS(value);
  5704. buffer.seek(curPos,2);
  5705. var gearCnt=buffer.getInt16();
  5706. for (j=0;j < gearCnt;j++){
  5707. nextPos=buffer.getInt16();
  5708. nextPos+=buffer.pos;
  5709. if (buffer.readByte()==6){
  5710. buffer.skip(2);
  5711. valueCnt=buffer.getInt16();
  5712. for (k=0;k < valueCnt;k++){
  5713. page=buffer.readS();
  5714. if (page !=null){
  5715. if((value=compStrings[elementId+"-texts_"+k])!=null)
  5716. buffer.writeS(value);
  5717. else
  5718. buffer.skip(2);
  5719. }
  5720. }
  5721. if (buffer.readBool()&& (value=compStrings[elementId+"-texts_def"])!=null)
  5722. buffer.writeS(value);
  5723. }
  5724. buffer.pos=nextPos;
  5725. }
  5726. switch (type){
  5727. case 6:
  5728. case 7:
  5729. case 8:{
  5730. if ((value=compStrings[elementId])!=null){
  5731. buffer.seek(curPos,6);
  5732. buffer.writeS(value);
  5733. }
  5734. if ((value=compStrings[elementId+"-prompt"])!=null){
  5735. buffer.seek(curPos,4);
  5736. buffer.writeS(value);
  5737. }
  5738. break ;
  5739. }
  5740. case 10:{
  5741. buffer.seek(curPos,8);
  5742. buffer.skip(2);
  5743. itemCount=buffer.getInt16();
  5744. for (j=0;j<itemCount;j++){
  5745. nextPos=buffer.getInt16();
  5746. nextPos+=buffer.pos;
  5747. buffer.skip(2);
  5748. if ((value=compStrings[elementId+"-"+j])!=null)
  5749. buffer.writeS(value);
  5750. else
  5751. buffer.skip(2);
  5752. if ((value=compStrings[elementId+"-"+j+"-0"])!=null)
  5753. buffer.writeS(value);
  5754. buffer.pos=nextPos;
  5755. }
  5756. break ;
  5757. }
  5758. case 11:{
  5759. if (buffer.seek(curPos,6)&& buffer.readByte()==type){
  5760. if ((value=compStrings[elementId])!=null)
  5761. buffer.writeS(value);
  5762. else
  5763. buffer.skip(2);
  5764. buffer.skip(2);
  5765. if (buffer.readBool())
  5766. buffer.skip(4);
  5767. buffer.skip(4);
  5768. if (buffer.readBool()&& (value=compStrings[elementId+"-prompt"])!=null)
  5769. buffer.writeS(value);
  5770. }
  5771. break ;
  5772. }
  5773. case 12:{
  5774. if (buffer.seek(curPos,6)&& buffer.readByte()==type){
  5775. if ((value=compStrings[elementId])!=null)
  5776. buffer.writeS(value);
  5777. else
  5778. buffer.skip(2);
  5779. if ((value=compStrings[elementId+"-0"])!=null)
  5780. buffer.writeS(value);
  5781. }
  5782. break ;
  5783. }
  5784. case 13:{
  5785. if (buffer.seek(curPos,6)&& buffer.readByte()==type){
  5786. itemCount=buffer.getInt16();
  5787. for (j=0;j < itemCount;j++){
  5788. nextPos=buffer.getInt16();
  5789. nextPos+=buffer.pos;
  5790. if ((value=compStrings[elementId+"-"+j])!=null)
  5791. buffer.writeS(value);
  5792. buffer.pos=nextPos;
  5793. }
  5794. if ((value=compStrings[elementId])!=null)
  5795. buffer.writeS(value);
  5796. }
  5797. break ;
  5798. }
  5799. }
  5800. buffer.pos=curPos+dataLen;
  5801. }
  5802. }
  5803. TranslationHelper.findChildNode=function(xml,name){
  5804. var col=xml.childNodes;
  5805. var length1=col.length;
  5806. if (length1>0){
  5807. for (var i1=0;i1 < length1;i1++){
  5808. var cxml=col[i1];
  5809. if (cxml.nodeName==name){
  5810. return cxml;
  5811. }
  5812. }
  5813. }
  5814. return null;
  5815. }
  5816. TranslationHelper.strings=null;
  5817. return TranslationHelper;
  5818. })()
  5819. //class fairygui.tree.TreeNode
  5820. var TreeNode=(function(){
  5821. function TreeNode(hasChild){
  5822. this._data=null;
  5823. this._parent=null;
  5824. this._children=null;
  5825. this._expanded=false;
  5826. this._tree=null;
  5827. this._cell=null;
  5828. this._level=0;
  5829. if(hasChild)
  5830. this._children=[];
  5831. }
  5832. __class(TreeNode,'fairygui.tree.TreeNode');
  5833. var __proto=TreeNode.prototype;
  5834. __proto.setCell=function(value){
  5835. this._cell=value;
  5836. }
  5837. __proto.setLevel=function(value){
  5838. this._level=value;
  5839. }
  5840. __proto.addChild=function(child){
  5841. this.addChildAt(child,this._children.length);
  5842. return child;
  5843. }
  5844. __proto.addChildAt=function(child,index){
  5845. if(!child)
  5846. throw new Error("child is null");
  5847. var numChildren=this._children.length;
  5848. if (index >=0 && index <=numChildren){
  5849. if (child._parent==this){
  5850. this.setChildIndex(child,index);
  5851. }
  5852. else{
  5853. if(child._parent)
  5854. child._parent.removeChild(child);
  5855. var cnt=this._children.length;
  5856. if (index==cnt)
  5857. this._children.push(child);
  5858. else
  5859. this._children.splice(index,0,child);
  5860. child._parent=this;
  5861. child._level=this._level+1;
  5862. child.setTree(this._tree);
  5863. if(this._cell!=null && this._cell.parent!=null && this._expanded)
  5864. this._tree.afterInserted(child);
  5865. }
  5866. return child;
  5867. }
  5868. else{
  5869. throw new Error("Invalid child index");
  5870. }
  5871. }
  5872. __proto.removeChild=function(child){
  5873. var childIndex=this._children.indexOf(child);
  5874. if (childIndex !=-1){
  5875. this.removeChildAt(childIndex);
  5876. }
  5877. return child;
  5878. }
  5879. __proto.removeChildAt=function(index){
  5880. if (index >=0 && index < this.numChildren){
  5881. var child=this._children[index];
  5882. this._children.splice(index,1);
  5883. child._parent=null;
  5884. if(this._tree!=null){
  5885. child.setTree(null);
  5886. this._tree.afterRemoved(child);
  5887. }
  5888. return child;
  5889. }
  5890. else{
  5891. throw new Error("Invalid child index");
  5892. }
  5893. }
  5894. __proto.removeChildren=function(beginIndex,endIndex){
  5895. (beginIndex===void 0)&& (beginIndex=0);
  5896. (endIndex===void 0)&& (endIndex=-1);
  5897. if (endIndex < 0 || endIndex >=this.numChildren)
  5898. endIndex=this.numChildren-1;
  5899. for (var i=beginIndex;i<=endIndex;++i)
  5900. this.removeChildAt(beginIndex);
  5901. }
  5902. __proto.getChildAt=function(index){
  5903. if (index >=0 && index < this.numChildren)
  5904. return this._children[index];
  5905. else
  5906. throw new Error("Invalid child index");
  5907. }
  5908. __proto.getChildIndex=function(child){
  5909. return this._children.indexOf(child);
  5910. }
  5911. __proto.getPrevSibling=function(){
  5912. if(this._parent==null)
  5913. return null;
  5914. var i=this._parent._children.indexOf(this);
  5915. if(i<=0)
  5916. return null;
  5917. return this._parent._children[i-1];
  5918. }
  5919. __proto.getNextSibling=function(){
  5920. if(this._parent==null)
  5921. return null;
  5922. var i=this._parent._children.indexOf(this);
  5923. if(i<0 || i>=this._parent._children.length-1)
  5924. return null;
  5925. return this._parent._children[i+1];
  5926. }
  5927. __proto.setChildIndex=function(child,index){
  5928. var oldIndex=this._children.indexOf(child);
  5929. if (oldIndex==-1)
  5930. throw new Error("Not a child of this container");
  5931. var cnt=this._children.length;
  5932. if(index<0)
  5933. index=0;
  5934. else if(index>cnt)
  5935. index=cnt;
  5936. if(oldIndex==index)
  5937. return;
  5938. this._children.splice(oldIndex,1);
  5939. this._children.splice(index,0,child);
  5940. if(this._cell!=null && this._cell.parent!=null && this._expanded)
  5941. this._tree.afterMoved(child);
  5942. }
  5943. __proto.swapChildren=function(child1,child2){
  5944. var index1=this._children.indexOf(child1);
  5945. var index2=this._children.indexOf(child2);
  5946. if (index1==-1 || index2==-1)
  5947. throw new Error("Not a child of this container");
  5948. this.swapChildrenAt(index1,index2);
  5949. }
  5950. __proto.swapChildrenAt=function(index1,index2){
  5951. var child1=this._children[index1];
  5952. var child2=this._children[index2];
  5953. this.setChildIndex(child1,index2);
  5954. this.setChildIndex(child2,index1);
  5955. }
  5956. __proto.setTree=function(value){
  5957. this._tree=value;
  5958. if(this._tree!=null && this._tree.treeNodeWillExpand && this._expanded)
  5959. this._tree.treeNodeWillExpand.runWith(this);
  5960. if(this._children!=null){
  5961. var cnt=this._children.length;
  5962. for(var i=0;i<cnt;i++){
  5963. var node=this._children[i];
  5964. node._level=this._level+1;
  5965. node.setTree(value);
  5966. }
  5967. }
  5968. }
  5969. __getset(0,__proto,'expanded',function(){
  5970. return this._expanded;
  5971. },function(value){
  5972. if(this._children==null)
  5973. return;
  5974. if(this._expanded!=value){
  5975. this._expanded=value;
  5976. if(this._tree!=null){
  5977. if(this._expanded)
  5978. this._tree.afterExpanded(this);
  5979. else
  5980. this._tree.afterCollapsed(this);
  5981. }
  5982. }
  5983. });
  5984. __getset(0,__proto,'tree',function(){
  5985. return this._tree;
  5986. });
  5987. __getset(0,__proto,'level',function(){
  5988. return this._level;
  5989. });
  5990. __getset(0,__proto,'cell',function(){
  5991. return this._cell;
  5992. });
  5993. __getset(0,__proto,'data',function(){
  5994. return this._data;
  5995. },function(value){
  5996. this._data=value;
  5997. });
  5998. __getset(0,__proto,'parent',function(){
  5999. return this._parent;
  6000. });
  6001. __getset(0,__proto,'isFolder',function(){
  6002. return this._children!=null;
  6003. });
  6004. __getset(0,__proto,'text',function(){
  6005. if(this._cell!=null)
  6006. return this._cell.text;
  6007. else
  6008. return null;
  6009. });
  6010. __getset(0,__proto,'numChildren',function(){
  6011. return this._children.length;
  6012. });
  6013. return TreeNode;
  6014. })()
  6015. //class fairygui.tree.TreeView
  6016. var TreeView=(function(){
  6017. function TreeView(list){
  6018. this._list=null;
  6019. this._root=null;
  6020. this._indent=0;
  6021. /**
  6022. *当需要为节点创建一个显示对象时调用这个Handler。参数为节点对象(TreeNode)。应该返回一个GObject。
  6023. */
  6024. this.treeNodeCreateCell=null;
  6025. /**
  6026. *当节点需要渲染时调用这个Handler。参数为节点对象(TreeNode)。
  6027. */
  6028. this.treeNodeRender=null;
  6029. /**
  6030. *当目录节点展开或者收缩时调用这个Handler。参数为节点对象(TreeNode)。可以用节点的expanded属性判断目标状态。
  6031. */
  6032. this.treeNodeWillExpand=null;
  6033. /**
  6034. *当节点被点击时调用这个Handler。参数有两个,第一个为节点对象(TreeNode),第二个为事件对象(Event)。
  6035. */
  6036. this.treeNodeClick=null;
  6037. this._list=list;
  6038. this._list.removeChildrenToPool();
  6039. this._list.on("fui_click_item",this,this.__clickItem);
  6040. this._root=new TreeNode(true);
  6041. this._root.setTree(this);
  6042. this._root.setCell(this._list);
  6043. this._root.expanded=true;
  6044. this._indent=15;
  6045. }
  6046. __class(TreeView,'fairygui.tree.TreeView');
  6047. var __proto=TreeView.prototype;
  6048. __proto.getSelectedNode=function(){
  6049. if(this._list.selectedIndex!=-1)
  6050. return (this._list.getChildAt(this._list.selectedIndex).data);
  6051. else
  6052. return null;
  6053. }
  6054. __proto.getSelection=function(){
  6055. var sels=this._list.getSelection();
  6056. var cnt=sels.length;
  6057. var ret=[];
  6058. for(var i=0;i<cnt;i++){
  6059. var node=(this._list.getChildAt(sels[i]).data);
  6060. ret.push(node);
  6061. }
  6062. return ret;
  6063. }
  6064. __proto.addSelection=function(node,scrollItToView){
  6065. (scrollItToView===void 0)&& (scrollItToView=false);
  6066. var parentNode=node.parent;
  6067. while(parentNode!=null && parentNode!=this._root){
  6068. parentNode.expanded=true;
  6069. parentNode=parentNode.parent;
  6070. }
  6071. if(!node.cell)
  6072. return;
  6073. this._list.addSelection(this._list.getChildIndex(node.cell),scrollItToView);
  6074. }
  6075. __proto.removeSelection=function(node){
  6076. if(!node.cell)
  6077. return;
  6078. this._list.removeSelection(this._list.getChildIndex(node.cell));
  6079. }
  6080. __proto.clearSelection=function(){
  6081. this._list.clearSelection();
  6082. }
  6083. __proto.getNodeIndex=function(node){
  6084. return this._list.getChildIndex(node.cell);
  6085. }
  6086. __proto.updateNode=function(node){
  6087. if(node.cell==null)
  6088. return;
  6089. if(this.treeNodeRender)
  6090. this.treeNodeRender.runWith(node);
  6091. }
  6092. __proto.updateNodes=function(nodes){
  6093. var cnt=nodes.length;
  6094. for(var i=0;i<cnt;i++){
  6095. var node=nodes[i];
  6096. if(node.cell==null)
  6097. return;
  6098. if(this.treeNodeRender)
  6099. this.treeNodeRender.runWith(node);
  6100. }
  6101. }
  6102. __proto.expandAll=function(folderNode){
  6103. folderNode.expanded=true;
  6104. var cnt=folderNode.numChildren;
  6105. for(var i=0;i<cnt;i++){
  6106. var node=folderNode.getChildAt(i);
  6107. if(node.isFolder)
  6108. this.expandAll(node);
  6109. }
  6110. }
  6111. __proto.collapseAll=function(folderNode){
  6112. if(folderNode!=this._root)
  6113. folderNode.expanded=false;
  6114. var cnt=folderNode.numChildren;
  6115. for(var i=0;i<cnt;i++){
  6116. var node=folderNode.getChildAt(i);
  6117. if(node.isFolder)
  6118. this.collapseAll(node);
  6119. }
  6120. }
  6121. __proto.createCell=function(node){
  6122. if(this.treeNodeCreateCell)
  6123. node.setCell(this.treeNodeCreateCell.runWith(node));
  6124. else
  6125. node.setCell((this._list.itemPool.getObject(this._list.defaultItem)));
  6126. node.cell.data=node;
  6127. var indentObj=node.cell.getChild("indent");
  6128. if(indentObj!=null)
  6129. indentObj.width=(node.level-1)*this._indent;
  6130. var expandButton=(node.cell.getChild("expandButton"));
  6131. if(expandButton){
  6132. if(node.isFolder){
  6133. expandButton.visible=true;
  6134. expandButton.onClick(this,this.__clickExpandButton);
  6135. expandButton.data=node;
  6136. expandButton.selected=node.expanded;
  6137. }
  6138. else
  6139. expandButton.visible=false;
  6140. }
  6141. if(this.treeNodeRender)
  6142. this.treeNodeRender.runWith(node);
  6143. }
  6144. __proto.afterInserted=function(node){
  6145. this.createCell(node);
  6146. var index=this.getInsertIndexForNode(node);
  6147. this._list.addChildAt(node.cell,index);
  6148. if(this.treeNodeRender)
  6149. this.treeNodeRender.runWith(node);
  6150. if(node.isFolder && node.expanded)
  6151. this.checkChildren(node,index);
  6152. }
  6153. __proto.getInsertIndexForNode=function(node){
  6154. var prevNode=node.getPrevSibling();
  6155. if(prevNode==null)
  6156. prevNode=node.parent;
  6157. var insertIndex=this._list.getChildIndex(prevNode.cell)+1;
  6158. var myLevel=node.level;
  6159. var cnt=this._list.numChildren;
  6160. for(var i=insertIndex;i<cnt;i++){
  6161. var testNode=(this._list.getChildAt(i).data);
  6162. if(testNode.level<=myLevel)
  6163. break ;
  6164. insertIndex++;
  6165. }
  6166. return insertIndex;
  6167. }
  6168. __proto.afterRemoved=function(node){
  6169. this.removeNode(node);
  6170. }
  6171. __proto.afterExpanded=function(node){
  6172. if(node!=this._root && this.treeNodeWillExpand)
  6173. this.treeNodeWillExpand(node);
  6174. if(node.cell==null)
  6175. return;
  6176. if(node!=this._root){
  6177. if(this.treeNodeRender)
  6178. this.treeNodeRender.runWith(node);
  6179. var expandButton=(node.cell.getChild("expandButton"));
  6180. if(expandButton)
  6181. expandButton.selected=true;
  6182. }
  6183. if(node.cell.parent!=null)
  6184. this.checkChildren(node,this._list.getChildIndex(node.cell));
  6185. }
  6186. __proto.afterCollapsed=function(node){
  6187. if(node!=this._root && this.treeNodeWillExpand)
  6188. this.treeNodeWillExpand(node);
  6189. if(node.cell==null)
  6190. return;
  6191. if(node!=this._root){
  6192. if(this.treeNodeRender)
  6193. this.treeNodeRender.runWith(node);
  6194. var expandButton=(node.cell.getChild("expandButton"));
  6195. if(expandButton)
  6196. expandButton.selected=false;
  6197. }
  6198. if(node.cell.parent!=null)
  6199. this.hideFolderNode(node);
  6200. }
  6201. __proto.afterMoved=function(node){
  6202. if(!node.isFolder)
  6203. this._list.removeChild(node.cell);
  6204. else
  6205. this.hideFolderNode(node);
  6206. var index=this.getInsertIndexForNode(node);
  6207. this._list.addChildAt(node.cell,index);
  6208. if(node.isFolder && node.expanded)
  6209. this.checkChildren(node,index);
  6210. }
  6211. __proto.checkChildren=function(folderNode,index){
  6212. var cnt=folderNode.numChildren;
  6213. for(var i=0;i<cnt;i++){
  6214. index++;
  6215. var node=folderNode.getChildAt(i);
  6216. if(node.cell==null)
  6217. this.createCell(node);
  6218. if(!node.cell.parent)
  6219. this._list.addChildAt(node.cell,index);
  6220. if(node.isFolder && node.expanded)
  6221. index=this.checkChildren(node,index);
  6222. }
  6223. return index;
  6224. }
  6225. __proto.hideFolderNode=function(folderNode){
  6226. var cnt=folderNode.numChildren;
  6227. for(var i=0;i<cnt;i++){
  6228. var node=folderNode.getChildAt(i);
  6229. if(node.cell && node.cell.parent!=null)
  6230. this._list.removeChild(node.cell);
  6231. if(node.isFolder && node.expanded)
  6232. this.hideFolderNode(node);
  6233. }
  6234. }
  6235. __proto.removeNode=function(node){
  6236. if(node.cell!=null){
  6237. if(node.cell.parent!=null)
  6238. this._list.removeChild(node.cell);
  6239. this._list.returnToPool(node.cell);
  6240. node.cell.data=null;
  6241. node.setCell(null);
  6242. }
  6243. if(node.isFolder){
  6244. var cnt=node.numChildren;
  6245. for(var i=0;i<cnt;i++){
  6246. var node2=node.getChildAt(i);
  6247. this.removeNode(node2);
  6248. }
  6249. }
  6250. }
  6251. __proto.__clickExpandButton=function(evt){
  6252. evt.stopPropagation();
  6253. var expandButton=(GObject.cast(evt.currentTarget));
  6254. var node=(expandButton.parent.data);
  6255. if(this._list.scrollPane!=null){
  6256. var posY=this._list.scrollPane.posY;
  6257. if(expandButton.selected)
  6258. node.expanded=true;
  6259. else
  6260. node.expanded=false;
  6261. this._list.scrollPane.posY=posY;
  6262. this._list.scrollPane.scrollToView(node.cell);
  6263. }
  6264. else{
  6265. if(expandButton.selected)
  6266. node.expanded=true;
  6267. else
  6268. node.expanded=false;
  6269. }
  6270. }
  6271. __proto.__clickItem=function(item,evt){
  6272. if(this._list.scrollPane!=null)
  6273. var posY=this._list.scrollPane.posY;
  6274. var node=(item.data);
  6275. if(this.treeNodeClick)
  6276. this.treeNodeClick.runWith([node,evt]);
  6277. if(this._list.scrollPane!=null){
  6278. this._list.scrollPane.posY=posY;
  6279. if(node.cell)
  6280. this._list.scrollPane.scrollToView(node.cell);
  6281. }
  6282. }
  6283. __getset(0,__proto,'list',function(){
  6284. return this._list;
  6285. });
  6286. __getset(0,__proto,'root',function(){
  6287. return this._root;
  6288. });
  6289. __getset(0,__proto,'indent',function(){
  6290. return this._indent;
  6291. },function(value){
  6292. this._indent=value;
  6293. });
  6294. return TreeView;
  6295. })()
  6296. //class fairygui.tween.EaseManager
  6297. var EaseManager=(function(){
  6298. var Bounce;
  6299. function EaseManager(){}
  6300. __class(EaseManager,'fairygui.tween.EaseManager');
  6301. EaseManager.evaluate=function(easeType,time,duration,overshootOrAmplitude,period){
  6302. switch (easeType){
  6303. case 0:
  6304. return time / duration;
  6305. case 1:
  6306. return-Math.cos(time / duration *EaseManager._PiOver2)+1;
  6307. case 2:
  6308. return Math.sin(time / duration *EaseManager._PiOver2);
  6309. case 3:
  6310. return-0.5 *(Math.cos(Math.PI *time / duration)-1);
  6311. case 4:
  6312. return (time /=duration)*time;
  6313. case 5:
  6314. return-(time /=duration)*(time-2);
  6315. case 6:
  6316. if ((time /=duration *0.5)< 1)return 0.5 *time *time;
  6317. return-0.5 *((--time)*(time-2)-1);
  6318. case 7:
  6319. return (time /=duration)*time *time;
  6320. case 8:
  6321. return ((time=time / duration-1)*time *time+1);
  6322. case 9:
  6323. if ((time /=duration *0.5)< 1)return 0.5 *time *time *time;
  6324. return 0.5 *((time-=2)*time *time+2);
  6325. case 10:
  6326. return (time /=duration)*time *time *time;
  6327. case 11:
  6328. return-((time=time / duration-1)*time *time *time-1);
  6329. case 12:
  6330. if ((time /=duration *0.5)< 1)return 0.5 *time *time *time *time;
  6331. return-0.5 *((time-=2)*time *time *time-2);
  6332. case 13:
  6333. return (time /=duration)*time *time *time *time;
  6334. case 14:
  6335. return ((time=time / duration-1)*time *time *time *time+1);
  6336. case 15:
  6337. if ((time /=duration *0.5)< 1)return 0.5 *time *time *time *time *time;
  6338. return 0.5 *((time-=2)*time *time *time *time+2);
  6339. case 16:
  6340. return (time==0)? 0 :Math.pow(2,10 *(time / duration-1));
  6341. case 17:
  6342. if (time==duration)return 1;
  6343. return (-Math.pow(2,-10 *time / duration)+1);
  6344. case 18:
  6345. if (time==0)return 0;
  6346. if (time==duration)return 1;
  6347. if ((time /=duration *0.5)< 1)return 0.5 *Math.pow(2,10 *(time-1));
  6348. return 0.5 *(-Math.pow(2,-10 *--time)+2);
  6349. case 19:
  6350. return-(Math.sqrt(1-(time /=duration)*time)-1);
  6351. case 20:
  6352. return Math.sqrt(1-(time=time / duration-1)*time);
  6353. case 21:
  6354. if ((time /=duration *0.5)< 1)return-0.5 *(Math.sqrt(1-time *time)-1);
  6355. return 0.5 *(Math.sqrt(1-(time-=2)*time)+1);
  6356. case 22:;
  6357. var s0=NaN;
  6358. if (time==0)return 0;
  6359. if ((time /=duration)==1)return 1;
  6360. if (period==0)period=duration *0.3;
  6361. if (overshootOrAmplitude < 1){
  6362. overshootOrAmplitude=1;
  6363. s0=period / 4;
  6364. }
  6365. else s0=period / EaseManager._TwoPi *Math.asin(1 / overshootOrAmplitude);
  6366. return-(overshootOrAmplitude *Math.pow(2,10 *(time-=1))*Math.sin((time *duration-s0)*EaseManager._TwoPi / period));
  6367. case 23:;
  6368. var s1=NaN;
  6369. if (time==0)return 0;
  6370. if ((time /=duration)==1)return 1;
  6371. if (period==0)period=duration *0.3;
  6372. if (overshootOrAmplitude < 1){
  6373. overshootOrAmplitude=1;
  6374. s1=period / 4;
  6375. }
  6376. else s1=period / EaseManager._TwoPi *Math.asin(1 / overshootOrAmplitude);
  6377. return (overshootOrAmplitude *Math.pow(2,-10 *time)*Math.sin((time *duration-s1)*EaseManager._TwoPi / period)+1);
  6378. case 24:;
  6379. var s=NaN;
  6380. if (time==0)return 0;
  6381. if ((time /=duration *0.5)==2)return 1;
  6382. if (period==0)period=duration *(0.3 *1.5);
  6383. if (overshootOrAmplitude < 1){
  6384. overshootOrAmplitude=1;
  6385. s=period / 4;
  6386. }
  6387. else s=period / EaseManager._TwoPi *Math.asin(1 / overshootOrAmplitude);
  6388. if (time < 1)return-0.5 *(overshootOrAmplitude *Math.pow(2,10 *(time-=1))*Math.sin((time *duration-s)*EaseManager._TwoPi / period));
  6389. return overshootOrAmplitude *Math.pow(2,-10 *(time-=1))*Math.sin((time *duration-s)*EaseManager._TwoPi / period)*0.5+1;
  6390. case 25:
  6391. return (time /=duration)*time *((overshootOrAmplitude+1)*time-overshootOrAmplitude);
  6392. case 26:
  6393. return ((time=time / duration-1)*time *((overshootOrAmplitude+1)*time+overshootOrAmplitude)+1);
  6394. case 27:
  6395. if ((time /=duration *0.5)< 1)return 0.5 *(time *time *(((overshootOrAmplitude *=(1.525))+1)*time-overshootOrAmplitude));
  6396. return 0.5 *((time-=2)*time *(((overshootOrAmplitude *=(1.525))+1)*time+overshootOrAmplitude)+2);
  6397. case 28:
  6398. return Bounce.easeIn(time,duration);
  6399. case 29:
  6400. return Bounce.easeOut(time,duration);
  6401. case 30:
  6402. return Bounce.easeInOut(time,duration);
  6403. default :
  6404. return-(time /=duration)*(time-2);
  6405. }
  6406. }
  6407. __static(EaseManager,
  6408. ['_PiOver2',function(){return this._PiOver2=Math.PI *0.5;},'_TwoPi',function(){return this._TwoPi=Math.PI *2;}
  6409. ]);
  6410. EaseManager.__init$=function(){
  6411. /// This class contains a C# port of the easing equations created by Robert Penner (http://robertpenner.com/easing).
  6412. //class Bounce
  6413. Bounce=(function(){
  6414. function Bounce(){}
  6415. __class(Bounce,'');
  6416. Bounce.easeIn=function(time,duration){
  6417. return 1-Bounce.easeOut(duration-time,duration);
  6418. }
  6419. Bounce.easeOut=function(time,duration){
  6420. if ((time /=duration)< (1 / 2.75)){
  6421. return (7.5625 *time *time);
  6422. }
  6423. if (time < (2 / 2.75)){
  6424. return (7.5625 *(time-=(1.5 / 2.75))*time+0.75);
  6425. }
  6426. if (time < (2.5 / 2.75)){
  6427. return (7.5625 *(time-=(2.25 / 2.75))*time+0.9375);
  6428. }
  6429. return (7.5625 *(time-=(2.625 / 2.75))*time+0.984375);
  6430. }
  6431. Bounce.easeInOut=function(time,duration){
  6432. if (time < duration *0.5){
  6433. return Bounce.easeIn(time *2,duration)*0.5;
  6434. }
  6435. return Bounce.easeOut(time *2-duration,duration)*0.5+0.5;
  6436. }
  6437. return Bounce;
  6438. })()
  6439. }
  6440. return EaseManager;
  6441. })()
  6442. //class fairygui.tween.EaseType
  6443. var EaseType=(function(){
  6444. function EaseType(){}
  6445. __class(EaseType,'fairygui.tween.EaseType');
  6446. EaseType.Linear=0;
  6447. EaseType.SineIn=1;
  6448. EaseType.SineOut=2;
  6449. EaseType.SineInOut=3;
  6450. EaseType.QuadIn=4;
  6451. EaseType.QuadOut=5;
  6452. EaseType.QuadInOut=6;
  6453. EaseType.CubicIn=7;
  6454. EaseType.CubicOut=8;
  6455. EaseType.CubicInOut=9;
  6456. EaseType.QuartIn=10;
  6457. EaseType.QuartOut=11;
  6458. EaseType.QuartInOut=12;
  6459. EaseType.QuintIn=13;
  6460. EaseType.QuintOut=14;
  6461. EaseType.QuintInOut=15;
  6462. EaseType.ExpoIn=16;
  6463. EaseType.ExpoOut=17;
  6464. EaseType.ExpoInOut=18;
  6465. EaseType.CircIn=19;
  6466. EaseType.CircOut=20;
  6467. EaseType.CircInOut=21;
  6468. EaseType.ElasticIn=22;
  6469. EaseType.ElasticOut=23;
  6470. EaseType.ElasticInOut=24;
  6471. EaseType.BackIn=25;
  6472. EaseType.BackOut=26;
  6473. EaseType.BackInOut=27;
  6474. EaseType.BounceIn=28;
  6475. EaseType.BounceOut=29;
  6476. EaseType.BounceInOut=30;
  6477. EaseType.Custom=31;
  6478. return EaseType;
  6479. })()
  6480. //class fairygui.tween.GTween
  6481. var GTween=(function(){
  6482. function GTween(){}
  6483. __class(GTween,'fairygui.tween.GTween');
  6484. GTween.to=function(start,end,duration){
  6485. return TweenManager.createTween()._to(start,end,duration);
  6486. }
  6487. GTween.to2=function(start,start2,end,end2,duration){
  6488. return TweenManager.createTween()._to2(start,start2,end,end2,duration);
  6489. }
  6490. GTween.to3=function(start,start2,start3,end,end2,end3,duration){
  6491. return TweenManager.createTween()._to3(start,start2,start3,end,end2,end3,duration);
  6492. }
  6493. GTween.to4=function(start,start2,start3,start4,end,end2,end3,end4,duration){
  6494. return TweenManager.createTween()._to4(start,start2,start3,start4,end,end2,end3,end4,duration);
  6495. }
  6496. GTween.toColor=function(start,end,duration){
  6497. return TweenManager.createTween()._toColor(start,end,duration);
  6498. }
  6499. GTween.delayedCall=function(delay){
  6500. return TweenManager.createTween().setDelay(delay);
  6501. }
  6502. GTween.shake=function(startX,startY,amplitude,duration){
  6503. return TweenManager.createTween()._shake(startX,startY,amplitude,duration);
  6504. }
  6505. GTween.isTweening=function(target,propType){
  6506. return TweenManager.isTweening(target,propType);
  6507. }
  6508. GTween.kill=function(target,complete,propType){
  6509. (complete===void 0)&& (complete=false);
  6510. TweenManager.killTweens(target,false,null);
  6511. }
  6512. GTween.getTween=function(target,propType){
  6513. return TweenManager.getTween(target,propType);
  6514. }
  6515. GTween.catchCallbackExceptions=true;
  6516. return GTween;
  6517. })()
  6518. //class fairygui.tween.GTweener
  6519. var GTweener=(function(){
  6520. function GTweener(){
  6521. this._target=null;
  6522. this._propType=null;
  6523. this._killed=false;
  6524. this._paused=false;
  6525. this._delay=NaN;
  6526. this._duration=NaN;
  6527. this._breakpoint=NaN;
  6528. this._easeType=0;
  6529. this._easeOvershootOrAmplitude=NaN;
  6530. this._easePeriod=NaN;
  6531. this._repeat=0;
  6532. this._yoyo=false;
  6533. this._timeScale=NaN;
  6534. this._snapping=false;
  6535. this._userData=null;
  6536. this._onUpdate=null;
  6537. this._onUpdateCaller=null;
  6538. this._onStart=null;
  6539. this._onStartCaller=null;
  6540. this._onComplete=null;
  6541. this._onCompleteCaller=null;
  6542. this._startValue=null;
  6543. this._endValue=null;
  6544. this._value=null;
  6545. this._deltaValue=null;
  6546. this._valueSize=0;
  6547. this._started=false;
  6548. this._ended=0;
  6549. this._elapsedTime=NaN;
  6550. this._normalizedTime=NaN;
  6551. this._startValue=new TweenValue();
  6552. this._endValue=new TweenValue();
  6553. this._value=new TweenValue();
  6554. this._deltaValue=new TweenValue();
  6555. this._reset();
  6556. }
  6557. __class(GTweener,'fairygui.tween.GTweener');
  6558. var __proto=GTweener.prototype;
  6559. __proto.setDelay=function(value){
  6560. this._delay=value;
  6561. return this;
  6562. }
  6563. __proto.setDuration=function(value){
  6564. this._duration=value;
  6565. return this;
  6566. }
  6567. __proto.setBreakpoint=function(value){
  6568. this._breakpoint=value;
  6569. return this;
  6570. }
  6571. __proto.setEase=function(value){
  6572. this._easeType=value;
  6573. return this;
  6574. }
  6575. __proto.setEasePeriod=function(value){
  6576. this._easePeriod=value;
  6577. return this;
  6578. }
  6579. __proto.setEaseOvershootOrAmplitude=function(value){
  6580. this._easeOvershootOrAmplitude=value;
  6581. return this;
  6582. }
  6583. __proto.setRepeat=function(repeat,yoyo){
  6584. (yoyo===void 0)&& (yoyo=false);
  6585. this._repeat=repeat;
  6586. this._yoyo=yoyo;
  6587. return this;
  6588. }
  6589. __proto.setTimeScale=function(value){
  6590. this._timeScale=value;
  6591. return this;
  6592. }
  6593. __proto.setSnapping=function(value){
  6594. this._snapping=value;
  6595. return this;
  6596. }
  6597. __proto.setTarget=function(value,propType){
  6598. this._target=value;
  6599. this._propType=propType;
  6600. return this;
  6601. }
  6602. __proto.setUserData=function(value){
  6603. this._userData=value;
  6604. return this;
  6605. }
  6606. __proto.onUpdate=function(callback,caller){
  6607. this._onUpdate=callback;
  6608. this._onUpdateCaller=caller;
  6609. return this;
  6610. }
  6611. __proto.onStart=function(callback,caller){
  6612. this._onStart=callback;
  6613. this._onStartCaller=caller;
  6614. return this;
  6615. }
  6616. __proto.onComplete=function(callback,caller){
  6617. this._onComplete=callback;
  6618. this._onCompleteCaller=caller;
  6619. return this;
  6620. }
  6621. __proto.setPaused=function(paused){
  6622. this._paused=paused;
  6623. return this;
  6624. }
  6625. /**
  6626. *seek position of the tween,in seconds.
  6627. */
  6628. __proto.seek=function(time){
  6629. if (this._killed)
  6630. return;
  6631. this._elapsedTime=time;
  6632. if (this._elapsedTime < this._delay){
  6633. if (this._started)
  6634. this._elapsedTime=this._delay;
  6635. else
  6636. return;
  6637. }
  6638. this.update();
  6639. }
  6640. __proto.kill=function(complete){
  6641. (complete===void 0)&& (complete=false);
  6642. if (this._killed)
  6643. return;
  6644. if (complete){
  6645. if (this._ended==0){
  6646. if (this._breakpoint >=0)
  6647. this._elapsedTime=this._delay+this._breakpoint;
  6648. else if (this._repeat >=0)
  6649. this._elapsedTime=this._delay+this._duration *(this._repeat+1);
  6650. else
  6651. this._elapsedTime=this._delay+this._duration *2;
  6652. this.update();
  6653. }
  6654. this.callCompleteCallback();
  6655. }
  6656. this._killed=true;
  6657. }
  6658. __proto._to=function(start,end,duration){
  6659. this._valueSize=1;
  6660. this._startValue.x=start;
  6661. this._endValue.x=end;
  6662. this._duration=duration;
  6663. return this;
  6664. }
  6665. __proto._to2=function(start,start2,end,end2,duration){
  6666. this._valueSize=2;
  6667. this._startValue.x=start;
  6668. this._endValue.x=end;
  6669. this._startValue.y=start2;
  6670. this._endValue.y=end2;
  6671. this._duration=duration;
  6672. return this;
  6673. }
  6674. __proto._to3=function(start,start2,start3,end,end2,end3,duration){
  6675. this._valueSize=3;
  6676. this._startValue.x=start;
  6677. this._endValue.x=end;
  6678. this._startValue.y=start2;
  6679. this._endValue.y=end2;
  6680. this._startValue.z=start3;
  6681. this._endValue.z=end3;
  6682. this._duration=duration;
  6683. return this;
  6684. }
  6685. __proto._to4=function(start,start2,start3,start4,end,end2,end3,end4,duration){
  6686. this._valueSize=4;
  6687. this._startValue.x=start;
  6688. this._endValue.x=end;
  6689. this._startValue.y=start2;
  6690. this._endValue.y=end2;
  6691. this._startValue.z=start3;
  6692. this._endValue.z=end3;
  6693. this._startValue.w=start4;
  6694. this._endValue.w=end4;
  6695. this._duration=duration;
  6696. return this;
  6697. }
  6698. __proto._toColor=function(start,end,duration){
  6699. this._valueSize=4;
  6700. this._startValue.color=start;
  6701. this._endValue.color=end;
  6702. this._duration=duration;
  6703. return this;
  6704. }
  6705. __proto._shake=function(startX,startY,amplitude,duration){
  6706. this._valueSize=5;
  6707. this._startValue.x=startX;
  6708. this._startValue.y=startY;
  6709. this._startValue.w=amplitude;
  6710. this._duration=duration;
  6711. this._easeType=0;
  6712. return this;
  6713. }
  6714. __proto._init=function(){
  6715. this._delay=0;
  6716. this._duration=0;
  6717. this._breakpoint=-1;
  6718. this._easeType=5;
  6719. this._timeScale=1;
  6720. this._easePeriod=0;
  6721. this._easeOvershootOrAmplitude=1.70158;
  6722. this._snapping=false;
  6723. this._repeat=0;
  6724. this._yoyo=false;
  6725. this._valueSize=0;
  6726. this._started=false;
  6727. this._paused=false;
  6728. this._killed=false;
  6729. this._elapsedTime=0;
  6730. this._normalizedTime=0;
  6731. this._ended=0;
  6732. }
  6733. __proto._reset=function(){
  6734. this._target=null;
  6735. this._userData=null;
  6736. this._onStart=this._onUpdate=this._onComplete=null;
  6737. this._onStartCaller=this._onUpdateCaller=this._onCompleteCaller=null;
  6738. }
  6739. __proto._update=function(dt){
  6740. if (this._timeScale !=1)
  6741. dt *=this._timeScale;
  6742. if (dt==0)
  6743. return;
  6744. if (this._ended !=0){
  6745. this.callCompleteCallback();
  6746. this._killed=true;
  6747. return;
  6748. }
  6749. this._elapsedTime+=dt;
  6750. this.update();
  6751. if (this._ended !=0){
  6752. if (!this._killed){
  6753. this.callCompleteCallback();
  6754. this._killed=true;
  6755. }
  6756. }
  6757. }
  6758. __proto.update=function(){
  6759. this._ended=0;
  6760. if (this._valueSize==0){
  6761. if (this._elapsedTime >=this._delay+this._duration)
  6762. this._ended=1;
  6763. return;
  6764. }
  6765. if (!this._started){
  6766. if (this._elapsedTime < this._delay)
  6767. return;
  6768. this._started=true;
  6769. this.callStartCallback();
  6770. if (this._killed)
  6771. return;
  6772. };
  6773. var reversed=false;
  6774. var tt=this._elapsedTime-this._delay;
  6775. if (this._breakpoint >=0 && tt >=this._breakpoint){
  6776. tt=this._breakpoint;
  6777. this._ended=2;
  6778. }
  6779. if (this._repeat !=0){
  6780. var round=Math.floor(tt / this._duration);
  6781. tt-=this._duration *round;
  6782. if (this._yoyo)
  6783. reversed=round % 2==1;
  6784. if (this._repeat > 0 && this._repeat-round < 0){
  6785. if (this._yoyo)
  6786. reversed=this._repeat % 2==1;
  6787. tt=this._duration;
  6788. this._ended=1;
  6789. }
  6790. }
  6791. else if (tt >=this._duration){
  6792. tt=this._duration;
  6793. this._ended=1;
  6794. }
  6795. this._normalizedTime=EaseManager.evaluate(this._easeType,reversed ? (this._duration-tt):tt,this._duration,
  6796. this._easeOvershootOrAmplitude,this._easePeriod);
  6797. this._value.setZero();
  6798. this._deltaValue.setZero();
  6799. if (this._valueSize==5){
  6800. if (this._ended==0){
  6801. var r=this._startValue.w*(1-this._normalizedTime);
  6802. var rx=(Math.random()*2-1)*r;
  6803. var ry=(Math.random()*2-1)*r;
  6804. rx=rx > 0 ? Math.ceil(rx):Math.floor(rx);
  6805. ry=ry > 0 ? Math.ceil(ry):Math.floor(ry);
  6806. this._deltaValue.x=rx;
  6807. this._deltaValue.y=ry;
  6808. this._value.x=this._startValue.x+rx;
  6809. this._value.y=this._startValue.y+ry;
  6810. }
  6811. else{
  6812. this._value.x=this._startValue.x;
  6813. this._value.y=this._startValue.y;
  6814. }
  6815. }
  6816. else{
  6817. for (var i=0;i < this._valueSize;i++){
  6818. var n1=this._startValue.getField(i);
  6819. var n2=this._endValue.getField(i);
  6820. var f=n1+(n2-n1)*this._normalizedTime;
  6821. if (this._snapping)
  6822. f=Math.round(f);
  6823. this._deltaValue.setField(i,f-this._value.getField(i));
  6824. this._value.setField(i,f);
  6825. }
  6826. }
  6827. if (this._target !=null && this._propType !=null){
  6828. if((typeof this._propType=='function')){
  6829. switch(this._valueSize){
  6830. case 1:
  6831. this._propType.call(this._target,this._value.x);
  6832. break ;
  6833. case 2:
  6834. this._propType.call(this._target,this._value.x,this._value.y);
  6835. break ;
  6836. case 3:
  6837. this._propType.call(this._target,this._value.x,this._value.y,this._value.z);
  6838. break ;
  6839. case 4:
  6840. this._propType.call(this._target,this._value.x,this._value.y,this._value.z,this._value.w);
  6841. break ;
  6842. case 5:
  6843. this._propType.call(this._target,this._value.color);
  6844. break ;
  6845. case 6:
  6846. this._propType.call(this._target,this._value.x,this._value.y);
  6847. break ;
  6848. }
  6849. }
  6850. else{
  6851. if(this._valueSize==5)
  6852. this._target[this._propType]=this._value.color;
  6853. else
  6854. this._target[this._propType]=this._value.x;
  6855. }
  6856. }
  6857. this.callUpdateCallback();
  6858. }
  6859. __proto.callStartCallback=function(){
  6860. if (this._onStart !=null){
  6861. if(GTween.catchCallbackExceptions){
  6862. try{
  6863. this._onStart.call(this._onStartCaller,this);
  6864. }
  6865. catch(err){
  6866. console.log("FairyGUI: error in start callback > "+err.message);
  6867. }
  6868. }
  6869. else
  6870. this._onStart.call(this._onStartCaller,this);
  6871. }
  6872. }
  6873. __proto.callUpdateCallback=function(){
  6874. if (this._onUpdate !=null){
  6875. if(GTween.catchCallbackExceptions){
  6876. try{
  6877. this._onUpdate.call(this._onUpdateCaller,this);
  6878. }
  6879. catch(err){
  6880. console.log("FairyGUI: error in update callback > "+err.message);
  6881. }
  6882. }
  6883. else
  6884. this._onUpdate.call(this._onUpdateCaller,this);
  6885. }
  6886. }
  6887. __proto.callCompleteCallback=function(){
  6888. if (this._onComplete !=null){
  6889. if(GTween.catchCallbackExceptions){
  6890. try{
  6891. this._onComplete.call(this._onCompleteCaller,this);
  6892. }
  6893. catch(err){
  6894. console.log("FairyGUI: error in complete callback > "+err.message);
  6895. }
  6896. }
  6897. else
  6898. this._onComplete.call(this._onCompleteCaller,this);
  6899. }
  6900. }
  6901. __getset(0,__proto,'target',function(){
  6902. return this._target;
  6903. });
  6904. __getset(0,__proto,'delay',function(){
  6905. return this._delay;
  6906. });
  6907. __getset(0,__proto,'duration',function(){
  6908. return this._duration;
  6909. });
  6910. __getset(0,__proto,'value',function(){
  6911. return this._value;
  6912. });
  6913. __getset(0,__proto,'userData',function(){
  6914. return this._userData;
  6915. });
  6916. __getset(0,__proto,'repeat',function(){
  6917. return this._repeat;
  6918. });
  6919. __getset(0,__proto,'startValue',function(){
  6920. return this._startValue;
  6921. });
  6922. __getset(0,__proto,'endValue',function(){
  6923. return this._endValue;
  6924. });
  6925. __getset(0,__proto,'deltaValue',function(){
  6926. return this._deltaValue;
  6927. });
  6928. __getset(0,__proto,'normalizedTime',function(){
  6929. return this._normalizedTime;
  6930. });
  6931. __getset(0,__proto,'completed',function(){
  6932. return this._ended !=0;
  6933. });
  6934. __getset(0,__proto,'allCompleted',function(){
  6935. return this._ended==1;
  6936. });
  6937. return GTweener;
  6938. })()
  6939. //class fairygui.tween.TweenManager
  6940. var TweenManager=(function(){
  6941. function TweenManager(){}
  6942. __class(TweenManager,'fairygui.tween.TweenManager');
  6943. TweenManager.createTween=function(){
  6944. if (!TweenManager._inited){
  6945. Laya.timer.frameLoop(1,null,TweenManager.update);
  6946. TweenManager._inited=true;
  6947. };
  6948. var tweener;
  6949. var cnt=TweenManager._tweenerPool.length;
  6950. if (cnt > 0){
  6951. tweener=TweenManager._tweenerPool.pop();
  6952. }
  6953. else
  6954. tweener=new GTweener();
  6955. tweener._init();
  6956. TweenManager._activeTweens[TweenManager._totalActiveTweens++]=tweener;
  6957. if (TweenManager._totalActiveTweens==TweenManager._activeTweens.length)
  6958. TweenManager._activeTweens.length=TweenManager._activeTweens.length+Math.ceil(TweenManager._activeTweens.length *0.5);
  6959. return tweener;
  6960. }
  6961. TweenManager.isTweening=function(target,propType){
  6962. if (target==null)
  6963. return false;
  6964. var anyType=propType==null;
  6965. for (var i=0;i < TweenManager._totalActiveTweens;i++){
  6966. var tweener=TweenManager._activeTweens[i];
  6967. if (tweener !=null && tweener.target==target && !tweener._killed
  6968. && (anyType || tweener._propType==propType))
  6969. return true;
  6970. }
  6971. return false;
  6972. }
  6973. TweenManager.killTweens=function(target,completed,propType){
  6974. if (target==null)
  6975. return false;
  6976. var flag=false;
  6977. var cnt=TweenManager._totalActiveTweens;
  6978. var anyType=propType==null;
  6979. for (var i=0;i < cnt;i++){
  6980. var tweener=TweenManager._activeTweens[i];
  6981. if (tweener !=null && tweener.target==target && !tweener._killed
  6982. && (anyType || tweener._propType==propType)){
  6983. tweener.kill(completed);
  6984. flag=true;
  6985. }
  6986. }
  6987. return flag;
  6988. }
  6989. TweenManager.getTween=function(target,propType){
  6990. if (target==null)
  6991. return null;
  6992. var cnt=TweenManager._totalActiveTweens;
  6993. var anyType=propType==null;
  6994. for (var i=0;i < cnt;i++){
  6995. var tweener=TweenManager._activeTweens[i];
  6996. if (tweener !=null && tweener.target==target && !tweener._killed
  6997. && (anyType || tweener._propType==propType)){
  6998. return tweener;
  6999. }
  7000. }
  7001. return null;
  7002. }
  7003. TweenManager.update=function(){
  7004. var dt=Laya.timer.delta/1000;
  7005. var cnt=TweenManager._totalActiveTweens;
  7006. var freePosStart=-1;
  7007. var freePosCount=0;
  7008. for (var i=0;i < cnt;i++){
  7009. var tweener=TweenManager._activeTweens[i];
  7010. if (tweener==null){
  7011. if (freePosStart==-1)
  7012. freePosStart=i;
  7013. freePosCount++;
  7014. }
  7015. else if (tweener._killed){
  7016. tweener._reset();
  7017. TweenManager._tweenerPool.push(tweener);
  7018. TweenManager._activeTweens[i]=null;
  7019. if (freePosStart==-1)
  7020. freePosStart=i;
  7021. freePosCount++;
  7022. }
  7023. else{
  7024. if(!tweener._paused)
  7025. tweener._update(dt);
  7026. if (freePosStart !=-1){
  7027. TweenManager._activeTweens[freePosStart]=tweener;
  7028. TweenManager._activeTweens[i]=null;
  7029. freePosStart++;
  7030. }
  7031. }
  7032. }
  7033. if (freePosStart >=0){
  7034. if (TweenManager._totalActiveTweens !=cnt){
  7035. var j=cnt;
  7036. cnt=TweenManager._totalActiveTweens-cnt;
  7037. for (i=0;i < cnt;i++)
  7038. TweenManager._activeTweens[freePosStart++]=TweenManager._activeTweens[j++];
  7039. }
  7040. TweenManager._totalActiveTweens=freePosStart;
  7041. }
  7042. }
  7043. TweenManager._tweenerPool=[];
  7044. TweenManager._totalActiveTweens=0;
  7045. TweenManager._inited=false;
  7046. __static(TweenManager,
  7047. ['_activeTweens',function(){return this._activeTweens=new Array(30);}
  7048. ]);
  7049. return TweenManager;
  7050. })()
  7051. //class fairygui.tween.TweenValue
  7052. var TweenValue=(function(){
  7053. function TweenValue(){
  7054. this.x=NaN;
  7055. this.y=NaN;
  7056. this.z=NaN;
  7057. this.w=NaN;
  7058. this.x=this.y=this.z=this.w=0;
  7059. }
  7060. __class(TweenValue,'fairygui.tween.TweenValue');
  7061. var __proto=TweenValue.prototype;
  7062. __proto.getField=function(index){
  7063. switch (index){
  7064. case 0:
  7065. return this.x;
  7066. case 1:
  7067. return this.y;
  7068. case 2:
  7069. return this.z;
  7070. case 3:
  7071. return this.w;
  7072. default :
  7073. throw new Error("Index out of bounds: "+index);
  7074. }
  7075. }
  7076. __proto.setField=function(index,value){
  7077. switch (index){
  7078. case 0:
  7079. this.x=value;
  7080. break ;
  7081. case 1:
  7082. this.y=value;
  7083. break ;
  7084. case 2:
  7085. this.z=value;
  7086. break ;
  7087. case 3:
  7088. this.w=value;
  7089. break ;
  7090. default :
  7091. throw new Error("Index out of bounds: "+index);
  7092. }
  7093. }
  7094. __proto.setZero=function(){
  7095. this.x=this.y=this.z=this.w=0;
  7096. }
  7097. __getset(0,__proto,'color',function(){
  7098. return (this.w<<24)+(this.x<<16)+(this.y<<8)+this.z;
  7099. },function(value){
  7100. this.x=(value & 0xFF0000)>>16;
  7101. this.y=(value & 0x00FF00)>>8;
  7102. this.z=(value & 0x0000FF);
  7103. this.w=(value & 0xFF000000)>>24;
  7104. });
  7105. return TweenValue;
  7106. })()
  7107. //class fairygui.UIConfig
  7108. var UIConfig$1=(function(){
  7109. function UIConfig(){}
  7110. __class(UIConfig,'fairygui.UIConfig',null,'UIConfig$1');
  7111. UIConfig.defaultFont="SimSun";
  7112. UIConfig.windowModalWaiting=null;
  7113. UIConfig.globalModalWaiting=null;
  7114. UIConfig.modalLayerColor="rgba(33,33,33,0.2)";
  7115. UIConfig.buttonSound=null;
  7116. UIConfig.buttonSoundVolumeScale=1;
  7117. UIConfig.horizontalScrollBar=null;
  7118. UIConfig.verticalScrollBar=null;
  7119. UIConfig.defaultScrollStep=25;
  7120. UIConfig.defaultScrollDecelerationRate=0.967;
  7121. UIConfig.defaultScrollBarDisplay=1;
  7122. UIConfig.defaultScrollTouchEffect=true;
  7123. UIConfig.defaultScrollBounceEffect=true;
  7124. UIConfig.popupMenu=null;
  7125. UIConfig.popupMenu_seperator=null;
  7126. UIConfig.loaderErrorSign=null;
  7127. UIConfig.tooltipsWin=null;
  7128. UIConfig.defaultComboBoxVisibleItemCount=10;
  7129. UIConfig.touchScrollSensitivity=20;
  7130. UIConfig.touchDragSensitivity=10;
  7131. UIConfig.clickDragSensitivity=2;
  7132. UIConfig.bringWindowToFrontOnClick=true;
  7133. UIConfig.frameTimeForAsyncUIConstruction=2;
  7134. UIConfig.textureLinearSampling=true;
  7135. UIConfig.packageFileExtension="fui";
  7136. UIConfig.versions="";
  7137. UIConfig.resourceurl="";
  7138. UIConfig.equipPlatform="";
  7139. UIConfig.gameWidth=0;
  7140. UIConfig.gameHeight=0;
  7141. UIConfig.disTips=3000;
  7142. UIConfig.gameBgResousedict=null;
  7143. UIConfig.maskLayer=null;
  7144. UIConfig.gameEffectDict=null;
  7145. UIConfig.gameLoaderManager=null;
  7146. return UIConfig;
  7147. })()
  7148. //class fairygui.UIObjectFactory
  7149. var UIObjectFactory=(function(){
  7150. function UIObjectFactory(){}
  7151. __class(UIObjectFactory,'fairygui.UIObjectFactory');
  7152. UIObjectFactory.setPackageItemExtension=function(url,type){
  7153. if (url==null)
  7154. throw new Error("Invaild url: "+url);
  7155. var pi=UIPackage.getItemByURL(url);
  7156. if (pi !=null)
  7157. pi.extensionType=type;
  7158. UIObjectFactory.packageItemExtensions[url]=type;
  7159. }
  7160. UIObjectFactory.setLoaderExtension=function(type){
  7161. fairygui.UIObjectFactory.loaderType=type;
  7162. }
  7163. UIObjectFactory.resolvePackageItemExtension=function(pi){
  7164. pi.extensionType=UIObjectFactory.packageItemExtensions["ui://"+pi.owner.id+pi.id];
  7165. if(!pi.extensionType)
  7166. pi.extensionType=UIObjectFactory.packageItemExtensions["ui://"+pi.owner.name+"/"+pi.name];
  7167. }
  7168. UIObjectFactory.newObject=function(pi){
  7169. if(pi.extensionType!=null)
  7170. return new pi.extensionType();
  7171. else
  7172. return UIObjectFactory.newObject2(pi.objectType);
  7173. }
  7174. UIObjectFactory.newObject2=function(type){
  7175. switch (type){
  7176. case 0:
  7177. return new GImage();
  7178. case 1:
  7179. return new GMovieClip();
  7180. case 9:
  7181. return new GComponent();
  7182. case 6:
  7183. return new GBasicTextField();
  7184. case 7:
  7185. return new GRichTextField();
  7186. case 8:
  7187. return new GTextInput();
  7188. case 5:
  7189. return new GGroup();
  7190. case 10:
  7191. return new GList();
  7192. case 3:
  7193. return new GGraph();
  7194. case 4:
  7195. if (fairygui.UIObjectFactory.loaderType !=null)
  7196. return new fairygui.UIObjectFactory.loaderType();
  7197. else
  7198. return new GLoader();
  7199. case 12:
  7200. return new GButton();
  7201. case 11:
  7202. return new GLabel();
  7203. case 14:
  7204. return new GProgressBar();
  7205. case 15:
  7206. return new GSlider();
  7207. case 16:
  7208. return new GScrollBar();
  7209. case 13:
  7210. return new GComboBox();
  7211. default :
  7212. return null;
  7213. }
  7214. }
  7215. UIObjectFactory.packageItemExtensions={};
  7216. UIObjectFactory.loaderType=null;
  7217. return UIObjectFactory;
  7218. })()
  7219. //class fairygui.UIPackage
  7220. var UIPackage=(function(){
  7221. var AtlasSprite;
  7222. function UIPackage(){
  7223. this._id=null;
  7224. this._name=null;
  7225. this._items=null;
  7226. this._itemsById=null;
  7227. this._itemsByName=null;
  7228. this._customId=null;
  7229. this._sprites=null;
  7230. this._items=[];
  7231. this._itemsById={};
  7232. this._itemsByName={};
  7233. this._sprites={};
  7234. }
  7235. __class(UIPackage,'fairygui.UIPackage');
  7236. var __proto=UIPackage.prototype;
  7237. __proto.loadPackage=function(buffer,resKey){
  7238. if (buffer.getUint32()!=0x46475549)
  7239. throw new Error("FairyGUI: old package format found in '"+resKey+"'");
  7240. buffer.version=buffer.getInt32();
  7241. var compressed=buffer.readBool();
  7242. this._id=buffer.readUTFString();
  7243. this._name=buffer.readUTFString();
  7244. buffer.skip(20);
  7245. if(compressed){
  7246. var buf=new Uint8Array(buffer.buffer,buffer.pos,buffer.length-buffer.pos);
  7247. var inflater=new Zlib.RawInflate(buf);buf=inflater.decompress();;
  7248. buffer=new ByteBuffer(buf);
  7249. };
  7250. var indexTablePos=buffer.pos;
  7251. var cnt=0;
  7252. var i=0;
  7253. var nextPos=0;
  7254. buffer.seek(indexTablePos,4);
  7255. cnt=buffer.getInt32();
  7256. var stringTable=__newvec(cnt);
  7257. for (i=0;i < cnt;i++)
  7258. stringTable[i]=buffer.readUTFString();
  7259. buffer.stringTable=stringTable;
  7260. buffer.seek(indexTablePos,1);
  7261. var pi;
  7262. resKey=resKey+"_";
  7263. cnt=buffer.getUint16();
  7264. for (i=0;i < cnt;i++){
  7265. nextPos=buffer.getInt32();
  7266. nextPos+=buffer.pos;
  7267. pi=new PackageItem();
  7268. pi.owner=this;
  7269. pi.type=buffer.readByte();
  7270. pi.id=buffer.readS();
  7271. pi.name=buffer.readS();
  7272. buffer.readS();
  7273. pi.file=buffer.readS();
  7274. buffer.readBool();
  7275. pi.width=buffer.getInt32();
  7276. pi.height=buffer.getInt32();
  7277. switch (pi.type){
  7278. case 0:{
  7279. pi.objectType=0;
  7280. var scaleOption=buffer.readByte();
  7281. if (scaleOption==1){
  7282. pi.scale9Grid=new laya.maths.Rectangle();
  7283. pi.scale9Grid.x=buffer.getInt32();
  7284. pi.scale9Grid.y=buffer.getInt32();
  7285. pi.scale9Grid.width=buffer.getInt32();
  7286. pi.scale9Grid.height=buffer.getInt32();
  7287. pi.tileGridIndice=buffer.getInt32();
  7288. }
  7289. else if (scaleOption==2)
  7290. pi.scaleByTile=true;
  7291. pi.smoothing=buffer.readBool();
  7292. break ;
  7293. }
  7294. case 1:{
  7295. pi.smoothing=buffer.readBool();
  7296. pi.objectType=1;
  7297. pi.rawData=buffer.readBuffer();
  7298. break ;
  7299. }
  7300. case 5:{
  7301. pi.rawData=buffer.readBuffer();
  7302. break ;
  7303. }
  7304. case 3:{
  7305. var extension=buffer.readByte();
  7306. if (extension > 0)
  7307. pi.objectType=extension;
  7308. else
  7309. pi.objectType=9;
  7310. pi.rawData=buffer.readBuffer();
  7311. UIObjectFactory.resolvePackageItemExtension(pi);
  7312. break ;
  7313. }
  7314. case 4:
  7315. case 2:
  7316. case 7:{
  7317. pi.file=resKey+pi.file;
  7318. break ;
  7319. }
  7320. }
  7321. this._items.push(pi);
  7322. this._itemsById[pi.id]=pi;
  7323. if (pi.name !=null)
  7324. this._itemsByName[pi.name]=pi;
  7325. buffer.pos=nextPos;
  7326. }
  7327. buffer.seek(indexTablePos,2);
  7328. cnt=buffer.getUint16();
  7329. for (i=0;i < cnt;i++){
  7330. nextPos=buffer.getUint16();
  7331. nextPos+=buffer.pos;
  7332. var itemId=buffer.readS();
  7333. pi=this._itemsById[buffer.readS()];
  7334. var sprite=new AtlasSprite();
  7335. sprite.atlas=pi;
  7336. sprite.rect.x=buffer.getInt32();
  7337. sprite.rect.y=buffer.getInt32();
  7338. sprite.rect.width=buffer.getInt32();
  7339. sprite.rect.height=buffer.getInt32();
  7340. sprite.rotated=buffer.readBool();
  7341. this._sprites[itemId]=sprite;
  7342. buffer.pos=nextPos;
  7343. }
  7344. if (buffer.seek(indexTablePos,3)){
  7345. cnt=buffer.getUint16();
  7346. for (i=0;i < cnt;i++){
  7347. nextPos=buffer.getInt32();
  7348. nextPos+=buffer.pos;
  7349. pi=this._itemsById[buffer.readS()];
  7350. if (pi && pi.type==0){
  7351. pi.pixelHitTestData=new PixelHitTestData();
  7352. pi.pixelHitTestData.load(buffer);
  7353. }
  7354. buffer.pos=nextPos;
  7355. }
  7356. }
  7357. }
  7358. __proto.loadAllAssets=function(){
  7359. var cnt=this._items.length;
  7360. for(var i=0;i < cnt;i++){
  7361. var pi=this._items[i];
  7362. this.getItemAsset(pi);
  7363. }
  7364. }
  7365. __proto.unloadAssets=function(){
  7366. var cnt=this._items.length;
  7367. for(var i=0;i < cnt;i++){
  7368. var pi=this._items[i];
  7369. if(pi.type==4){
  7370. if(pi.texture!=null)
  7371. Laya.loader.clearTextureRes(pi.texture.url);
  7372. }
  7373. }
  7374. }
  7375. __proto.dispose=function(){
  7376. var cnt=this._items.length;
  7377. for(var i=0;i < cnt;i++){
  7378. var pi=this._items[i];
  7379. if(pi.type==4){
  7380. if(pi.texture!=null){
  7381. pi.texture.destroy();
  7382. pi.texture=null;
  7383. }
  7384. }
  7385. else if(pi.type==2){
  7386. SoundManager.destroySound(pi.file);
  7387. }
  7388. }
  7389. }
  7390. __proto.createObject=function(resName,userClass){
  7391. var pi=this._itemsByName[resName];
  7392. if (pi)
  7393. return this.internalCreateObject(pi,userClass);
  7394. else
  7395. return null;
  7396. }
  7397. __proto.internalCreateObject=function(item,userClass){
  7398. var g;
  7399. if (item.type==3){
  7400. if (userClass !=null)
  7401. g=new userClass();
  7402. else
  7403. g=UIObjectFactory.newObject(item);
  7404. }
  7405. else
  7406. g=UIObjectFactory.newObject(item);
  7407. if (g==null)
  7408. return null;
  7409. fairygui.UIPackage._constructing++;
  7410. g.packageItem=item;
  7411. g.constructFromResource();
  7412. fairygui.UIPackage._constructing--;
  7413. return g;
  7414. }
  7415. __proto.getItemById=function(itemId){
  7416. return this._itemsById[itemId];
  7417. }
  7418. __proto.getItemByName=function(resName){
  7419. return this._itemsByName[resName];
  7420. }
  7421. __proto.getItemAssetByName=function(resName){
  7422. var pi=this._itemsByName[resName];
  7423. if (pi==null){
  7424. throw "Resource not found -"+resName;
  7425. }
  7426. return this.getItemAsset(pi);
  7427. }
  7428. __proto.getItemAsset=function(item){
  7429. switch (item.type){
  7430. case 0:
  7431. if (!item.decoded){
  7432. item.decoded=true;
  7433. var sprite=this._sprites[item.id];
  7434. if (sprite !=null)
  7435. item.texture=this.createSpriteTexture(sprite);
  7436. else
  7437. item.texture=null;
  7438. }
  7439. return item.texture;
  7440. case 4:
  7441. if (!item.decoded){
  7442. item.decoded=true;
  7443. item.texture=AssetProxy.inst.getRes(item.file);
  7444. if(!UIConfig$1.textureLinearSampling)
  7445. item.texture.isLinearSampling=false;
  7446. }
  7447. return item.texture;
  7448. case 5:
  7449. if (!item.decoded){
  7450. item.decoded=true;
  7451. this.loadFont(item);
  7452. }
  7453. return item.bitmapFont;
  7454. case 1:
  7455. if (!item.decoded){
  7456. item.decoded=true;
  7457. this.loadMovieClip(item);
  7458. }
  7459. return item.frames;
  7460. case 3:
  7461. return item.rawData;
  7462. case 7:
  7463. if(item.file)
  7464. return AssetProxy.inst.getRes(item.file);
  7465. else
  7466. return null;
  7467. default :
  7468. return null;
  7469. }
  7470. }
  7471. __proto.createSpriteTexture=function(sprite){
  7472. var atlasTexture=(this.getItemAsset(sprite.atlas));
  7473. return Texture.createFromTexture(atlasTexture,
  7474. sprite.rect.x,sprite.rect.y,sprite.rect.width,sprite.rect.height);
  7475. }
  7476. __proto.loadMovieClip=function(item){
  7477. var buffer=item.rawData;
  7478. buffer.seek(0,0);
  7479. item.interval=buffer.getInt32();
  7480. item.swing=buffer.readBool();
  7481. item.repeatDelay=buffer.getInt32();
  7482. buffer.seek(0,1);
  7483. var frameCount=buffer.getInt16();
  7484. item.frames=__newvec(frameCount);
  7485. var spriteId;
  7486. var frame;
  7487. var sprite;
  7488. for (var i=0;i < frameCount;i++){
  7489. var nextPos=buffer.getInt16();
  7490. nextPos+=buffer.pos;
  7491. frame=new Frame();
  7492. frame.rect.x=buffer.getInt32();
  7493. frame.rect.y=buffer.getInt32();
  7494. frame.rect.width=buffer.getInt32();
  7495. frame.rect.height=buffer.getInt32();
  7496. frame.addDelay=buffer.getInt32();
  7497. spriteId=buffer.readS();
  7498. if (spriteId !=null && (sprite=this._sprites[spriteId])!=null)
  7499. frame.texture=this.createSpriteTexture(sprite);
  7500. item.frames[i]=frame;
  7501. buffer.pos=nextPos;
  7502. }
  7503. }
  7504. __proto.loadFont=function(item){
  7505. var font=new BitmapFont$1();
  7506. item.bitmapFont=font;
  7507. var buffer=item.rawData;
  7508. buffer.seek(0,0);
  7509. font.ttf=buffer.readBool();
  7510. buffer.readBool();
  7511. font.resizable=buffer.readBool();
  7512. buffer.readBool();
  7513. font.size=buffer.getInt32();
  7514. var xadvance=buffer.getInt32();
  7515. var lineHeight=buffer.getInt32();
  7516. var mainTexture=null;
  7517. var mainSprite=this._sprites[item.id];
  7518. if (mainSprite!=null)
  7519. mainTexture=(this.getItemAsset(mainSprite.atlas));
  7520. buffer.seek(0,1);
  7521. var bg=null;
  7522. var cnt=buffer.getInt32();
  7523. for (var i=0;i < cnt;i++){
  7524. var nextPos=buffer.getInt16();
  7525. nextPos+=buffer.pos;
  7526. bg=new BMGlyph();
  7527. var ch=buffer.readChar();
  7528. font.glyphs[ch]=bg;
  7529. var img=buffer.readS();
  7530. var bx=buffer.getInt32();
  7531. var by=buffer.getInt32();
  7532. bg.offsetX=buffer.getInt32();
  7533. bg.offsetY=buffer.getInt32();
  7534. bg.width=buffer.getInt32();
  7535. bg.height=buffer.getInt32();
  7536. bg.advance=buffer.getInt32();
  7537. bg.channel=buffer.readByte();
  7538. if (bg.channel==1)
  7539. bg.channel=3;
  7540. else if (bg.channel==2)
  7541. bg.channel=2;
  7542. else if (bg.channel==3)
  7543. bg.channel=1;
  7544. if (!font.ttf){
  7545. var charImg=this._itemsById[img];
  7546. if (charImg){
  7547. this.getItemAsset(charImg);
  7548. bg.width=charImg.width;
  7549. bg.height=charImg.height;
  7550. bg.texture=charImg.texture;
  7551. }
  7552. }
  7553. else{
  7554. bg.texture=Texture.createFromTexture(mainTexture,
  7555. bx+mainSprite.rect.x,by+mainSprite.rect.y,bg.width,bg.height);
  7556. }
  7557. if (font.ttf)
  7558. bg.lineHeight=lineHeight;
  7559. else{
  7560. if (bg.advance==0){
  7561. if (xadvance==0)
  7562. bg.advance=bg.offsetX+bg.width;
  7563. else
  7564. bg.advance=xadvance;
  7565. }
  7566. bg.lineHeight=bg.offsetY < 0 ? bg.height :(bg.offsetY+bg.height);
  7567. if (bg.lineHeight < font.size)
  7568. bg.lineHeight=font.size;
  7569. }
  7570. buffer.pos=nextPos;
  7571. }
  7572. }
  7573. __getset(0,__proto,'id',function(){
  7574. return this._id;
  7575. });
  7576. __getset(0,__proto,'name',function(){
  7577. return this._name;
  7578. });
  7579. __getset(0,__proto,'customId',function(){
  7580. return this._customId;
  7581. },function(value){
  7582. if (this._customId !=null)
  7583. delete fairygui.UIPackage._packageInstById[this._customId];
  7584. this._customId=value;
  7585. if (this._customId !=null)
  7586. fairygui.UIPackage._packageInstById[this._customId]=this;
  7587. });
  7588. UIPackage.getById=function(id){
  7589. return fairygui.UIPackage._packageInstById[id];
  7590. }
  7591. UIPackage.getByName=function(name){
  7592. return fairygui.UIPackage._packageInstByName[name];
  7593. }
  7594. UIPackage.addPackage=function(resKey,pkgName,descData){
  7595. var pkg = fairygui.UIPackage._packageInstByName[pkgName];
  7596. if(!pkg){
  7597. if(!descData){
  7598. descData=AssetProxy.inst.getRes(resKey+"."+UIConfig$1.packageFileExtension);
  7599. if(!descData || descData.length==0)
  7600. throw new Error("package resource not ready: "+resKey);
  7601. };
  7602. var buffer=new ByteBuffer(descData);
  7603. var pkg=new UIPackage();
  7604. pkg.loadPackage(buffer,resKey);
  7605. fairygui.UIPackage._packageInstById[pkg.id]=pkg;
  7606. fairygui.UIPackage._packageInstByName[pkg.name]=pkg;
  7607. pkg.customId=resKey;
  7608. }
  7609. return pkg;
  7610. }
  7611. UIPackage.removePackage=function(packageIdOrName){
  7612. var pkg=fairygui.UIPackage._packageInstById[packageIdOrName];
  7613. if(!pkg)
  7614. pkg=fairygui.UIPackage._packageInstByName[packageIdOrName];
  7615. if(!pkg)
  7616. return;
  7617. pkg.dispose();
  7618. delete fairygui.UIPackage._packageInstById[pkg.id];
  7619. if(pkg._customId !=null)
  7620. delete fairygui.UIPackage._packageInstById[pkg._customId];
  7621. delete fairygui.UIPackage._packageInstByName[pkg.name];
  7622. }
  7623. UIPackage.createObject=function(pkgName,resName,userClass){
  7624. var pkg=fairygui.UIPackage.getByName(pkgName);
  7625. if(pkg)
  7626. return pkg.createObject(resName,userClass);
  7627. else
  7628. return null;
  7629. }
  7630. UIPackage.createObjectFromURL=function(url,userClass){
  7631. var pi=fairygui.UIPackage.getItemByURL(url);
  7632. if(pi)
  7633. return pi.owner.internalCreateObject(pi,userClass);
  7634. else
  7635. return null;
  7636. }
  7637. UIPackage.getItemURL=function(pkgName,resName){
  7638. var pkg=fairygui.UIPackage.getByName(pkgName);
  7639. if(!pkg)
  7640. return null;
  7641. var pi=pkg._itemsByName[resName];
  7642. if(!pi)
  7643. return null;
  7644. return "ui://"+pkg.id+pi.id;
  7645. }
  7646. UIPackage.getItemByURL=function(url){
  7647. var pos1=url.indexOf("//");
  7648. if (pos1==-1)
  7649. return null;
  7650. var pos2=url.indexOf("/",pos1+2);
  7651. if (pos2==-1){
  7652. if (url.length > 13){
  7653. var pkgId=url.substr(5,8);
  7654. var pkg=UIPackage.getById(pkgId);
  7655. if (pkg !=null){
  7656. var srcId=url.substr(13);
  7657. return pkg.getItemById(srcId);
  7658. }
  7659. }
  7660. }
  7661. else{
  7662. var pkgName=url.substr(pos1+2,pos2-pos1-2);
  7663. pkg=UIPackage.getByName(pkgName);
  7664. if (pkg !=null){
  7665. var srcName=url.substr(pos2+1);
  7666. return pkg.getItemByName(srcName);
  7667. }
  7668. }
  7669. return null;
  7670. }
  7671. UIPackage.getItemAssetByURL=function(url){
  7672. var item=UIPackage.getItemByURL(url);
  7673. if (item==null)
  7674. return null;
  7675. return item.owner.getItemAsset(item);
  7676. }
  7677. UIPackage.normalizeURL=function(url){
  7678. if(url==null)
  7679. return null;
  7680. var pos1=url.indexOf("//");
  7681. if (pos1==-1)
  7682. return null;
  7683. var pos2=url.indexOf("/",pos1+2);
  7684. if (pos2==-1)
  7685. return url;
  7686. var pkgName=url.substr(pos1+2,pos2-pos1-2);
  7687. var srcName=url.substr(pos2+1);
  7688. return UIPackage.getItemURL(pkgName,srcName);
  7689. }
  7690. UIPackage.setStringsSource=function(source){
  7691. TranslationHelper.loadFromXML(source);
  7692. }
  7693. UIPackage._constructing=0;
  7694. UIPackage._packageInstById={};
  7695. UIPackage._packageInstByName={};
  7696. UIPackage.__init$=function(){
  7697. //class AtlasSprite
  7698. AtlasSprite=(function(){
  7699. function AtlasSprite(){
  7700. this.atlas=null;
  7701. this.rect=null;
  7702. this.rotated=false;
  7703. this.rect=new Rectangle();
  7704. }
  7705. __class(AtlasSprite,'');
  7706. return AtlasSprite;
  7707. })()
  7708. }
  7709. return UIPackage;
  7710. })()
  7711. //class fairygui.utils.PixelHitTestData
  7712. var PixelHitTestData=(function(){
  7713. function PixelHitTestData(){
  7714. this.pixelWidth=0;
  7715. this.scale=NaN;
  7716. this.pixels=null;
  7717. }
  7718. __class(PixelHitTestData,'fairygui.utils.PixelHitTestData');
  7719. var __proto=PixelHitTestData.prototype;
  7720. __proto.load=function(ba){
  7721. ba.getInt32();
  7722. this.pixelWidth=ba.getInt32();
  7723. this.scale=1/ba.readByte();
  7724. var len=ba.getInt32();
  7725. this.pixels=__newvec(len);
  7726. for(var i=0;i<len;i++){
  7727. var j=ba.readByte();
  7728. if(j<0)
  7729. j+=256;
  7730. this.pixels[i]=j;
  7731. }
  7732. }
  7733. return PixelHitTestData;
  7734. })()
  7735. //class fairygui.utils.ToolSet
  7736. var ToolSet=(function(){
  7737. function ToolSet(){}
  7738. __class(ToolSet,'fairygui.utils.ToolSet');
  7739. ToolSet.getFileName=function(source){
  7740. var i=source.lastIndexOf("/");
  7741. if (i !=-1)
  7742. source=source.substr(i+1);
  7743. i=source.lastIndexOf("\\");
  7744. if (i !=-1)
  7745. source=source.substr(i+1);
  7746. i=source.lastIndexOf(".");
  7747. if (i !=-1)
  7748. return source.substring(0,i);
  7749. else
  7750. return source;
  7751. }
  7752. ToolSet.startsWith=function(source,str,ignoreCase){
  7753. (ignoreCase===void 0)&& (ignoreCase=false);
  7754. if (!source)
  7755. return false;
  7756. else if (source.length < str.length)
  7757. return false;
  7758. else {
  7759. source=source.substring(0,str.length);
  7760. if (!ignoreCase)
  7761. return source==str;
  7762. else
  7763. return source.toLowerCase()==str.toLowerCase();
  7764. }
  7765. }
  7766. ToolSet.endsWith=function(source,str,ignoreCase){
  7767. (ignoreCase===void 0)&& (ignoreCase=false);
  7768. if (!source)
  7769. return false;
  7770. else if (source.length < str.length)
  7771. return false;
  7772. else {
  7773. source=source.substring(source.length-str.length);
  7774. if (!ignoreCase)
  7775. return source==str;
  7776. else
  7777. return source.toLowerCase()==str.toLowerCase();
  7778. }
  7779. }
  7780. ToolSet.trim=function(targetString){
  7781. return fairygui.utils.ToolSet.trimLeft(fairygui.utils.ToolSet.trimRight(targetString));
  7782. }
  7783. ToolSet.trimLeft=function(targetString){
  7784. var tempChar="";
  7785. for (var i=0;i < targetString.length;i++){
  7786. tempChar=targetString.charAt(i);
  7787. if (tempChar !=" " && tempChar !="\n" && tempChar !="\r"){
  7788. break ;
  7789. }
  7790. }
  7791. return targetString.substr(i);
  7792. }
  7793. ToolSet.trimRight=function(targetString){
  7794. var tempChar="";
  7795. for (var i=targetString.length-1;i >=0;i--){
  7796. tempChar=targetString.charAt(i);
  7797. if (tempChar !=" " && tempChar !="\n" && tempChar !="\r"){
  7798. break ;
  7799. }
  7800. }
  7801. return targetString.substring(0,i+1);
  7802. }
  7803. ToolSet.convertToHtmlColor=function(argb,hasAlpha){
  7804. (hasAlpha===void 0)&& (hasAlpha=false);
  7805. var alpha;
  7806. if (hasAlpha)
  7807. alpha=(argb >> 24 & 0xFF).toString(16);
  7808. else
  7809. alpha="";
  7810. var red=(argb >> 16 & 0xFF).toString(16);
  7811. var green=(argb >> 8 & 0xFF).toString(16);
  7812. var blue=(argb & 0xFF).toString(16);
  7813. if (alpha.length==1)
  7814. alpha="0"+alpha;
  7815. if (red.length==1)
  7816. red="0"+red;
  7817. if (green.length==1)
  7818. green="0"+green;
  7819. if (blue.length==1)
  7820. blue="0"+blue;
  7821. return "#"+alpha+red+green+blue;
  7822. }
  7823. ToolSet.convertFromHtmlColor=function(str,hasAlpha){
  7824. (hasAlpha===void 0)&& (hasAlpha=false);
  7825. if (str.length < 1)
  7826. return 0;
  7827. if (str.charAt(0)=="#")
  7828. str=str.substr(1);
  7829. if (str.length==8)
  7830. return (parseInt(str.substr(0,2),16)<< 24)+parseInt(str.substr(2),16);
  7831. else if (hasAlpha)
  7832. return 0xFF000000+parseInt(str,16);
  7833. else
  7834. return parseInt(str,16);
  7835. }
  7836. ToolSet.displayObjectToGObject=function(obj){
  7837. while (obj !=null && !((obj instanceof laya.display.Stage ))){
  7838. if (obj["$owner"])
  7839. return obj["$owner"];
  7840. obj=obj.parent;
  7841. }
  7842. return null;
  7843. }
  7844. ToolSet.encodeHTML=function(str){
  7845. if (!str)
  7846. return "";
  7847. else
  7848. return str.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;").replace("'","&apos;");
  7849. }
  7850. ToolSet.parseUBB=function(text){
  7851. return fairygui.utils.ToolSet.defaultUBBParser.parse(text);
  7852. }
  7853. ToolSet.removeUBB=function(text){
  7854. return fairygui.utils.ToolSet.defaultUBBParser.parse(text,true);
  7855. }
  7856. ToolSet.clamp=function(value,min,max){
  7857. if(value<min)
  7858. value=min;
  7859. else if(value>max)
  7860. value=max;
  7861. return value;
  7862. }
  7863. ToolSet.clamp01=function(value){
  7864. if(value>1)
  7865. value=1;
  7866. else if(value<0)
  7867. value=0;
  7868. return value;
  7869. }
  7870. ToolSet.lerp=function(start,end,percent){
  7871. return (start+percent*(end-start));
  7872. }
  7873. __static(ToolSet,
  7874. ['defaultUBBParser',function(){return this.defaultUBBParser=new UBBParser();}
  7875. ]);
  7876. return ToolSet;
  7877. })()
  7878. //class fairygui.utils.UBBParser
  7879. var UBBParser=(function(){
  7880. function UBBParser(){
  7881. this._text=null;
  7882. this._readPos=0;
  7883. this._handlers=null;
  7884. this.smallFontSize=12;
  7885. this.normalFontSize=14;
  7886. this.largeFontSize=16;
  7887. this.defaultImgWidth=0;
  7888. this.defaultImgHeight=0;
  7889. this._handlers={};
  7890. this._handlers["url"]=this.onTag_URL;
  7891. this._handlers["img"]=this.onTag_IMG;
  7892. this._handlers["b"]=this.onTag_Simple;
  7893. this._handlers["i"]=this.onTag_Simple;
  7894. this._handlers["u"]=this.onTag_Simple;
  7895. this._handlers["sup"]=this.onTag_Simple;
  7896. this._handlers["sub"]=this.onTag_Simple;
  7897. this._handlers["color"]=this.onTag_COLOR;
  7898. this._handlers["font"]=this.onTag_FONT;
  7899. this._handlers["size"]=this.onTag_SIZE;
  7900. }
  7901. __class(UBBParser,'fairygui.utils.UBBParser');
  7902. var __proto=UBBParser.prototype;
  7903. __proto.onTag_URL=function(tagName,end,attr){
  7904. if (!end){
  7905. if (attr !=null)
  7906. return "<a href=\""+attr+"\" target=\"_blank\">";
  7907. else {
  7908. var href=this.getTagText();
  7909. return "<a href=\""+href+"\" target=\"_blank\">";
  7910. }
  7911. }
  7912. else
  7913. return "</a>";
  7914. }
  7915. __proto.onTag_IMG=function(tagName,end,attr){
  7916. if (!end){
  7917. var src=this.getTagText(true);
  7918. if (!src)
  7919. return null;
  7920. if (this.defaultImgWidth)
  7921. return "<img src=\""+src+"\" width=\""+this.defaultImgWidth+"\" height=\""+this.defaultImgHeight+"\"/>";
  7922. else
  7923. return "<img src=\""+src+"\"/>";
  7924. }
  7925. else
  7926. return null;
  7927. }
  7928. __proto.onTag_Simple=function(tagName,end,attr){
  7929. return end ? ("</"+tagName+">"):("<"+tagName+">");
  7930. }
  7931. __proto.onTag_COLOR=function(tagName,end,attr){
  7932. if (!end)
  7933. return "<font color=\""+attr+"\">";
  7934. else
  7935. return "</font>";
  7936. }
  7937. __proto.onTag_FONT=function(tagName,end,attr){
  7938. if (!end)
  7939. return "<font face=\""+attr+"\">";
  7940. else
  7941. return "</font>";
  7942. }
  7943. __proto.onTag_SIZE=function(tagName,end,attr){
  7944. if (!end){
  7945. if (attr=="normal")
  7946. attr=""+this.normalFontSize;
  7947. else if (attr=="small")
  7948. attr=""+this.smallFontSize;
  7949. else if (attr=="large")
  7950. attr=""+this.largeFontSize;
  7951. else if (attr.length && attr.charAt(0)=="+")
  7952. attr=""+(this.smallFontSize+parseInt(attr.substr(1)));
  7953. else if (attr.length && attr.charAt(0)=="-")
  7954. attr=""+(this.smallFontSize-parseInt(attr.substr(1)));
  7955. return "<font size=\""+attr+"\">";
  7956. }
  7957. else
  7958. return "</font>";
  7959. }
  7960. __proto.getTagText=function(remove){
  7961. (remove===void 0)&& (remove=false);
  7962. var pos1=this._readPos;
  7963. var pos2=0;
  7964. var result="";
  7965. while ((pos2=this._text.indexOf("[",pos1))!=-1){
  7966. if (this._text.charCodeAt(pos2-1)==92){
  7967. result+=this._text.substring(pos1,pos2-1);
  7968. result+="[";
  7969. pos1=pos2+1;
  7970. }
  7971. else{
  7972. result+=this._text.substring(pos1,pos2);
  7973. break ;
  7974. }
  7975. }
  7976. if (pos2==-1)
  7977. return null;
  7978. if (remove)
  7979. this._readPos=pos2;
  7980. return result;
  7981. }
  7982. __proto.parse=function(text,remove){
  7983. (remove===void 0)&& (remove=false);
  7984. this._text=text;
  7985. var pos1=0,pos2=0,pos3=0;
  7986. var end=false;
  7987. var tag,attr;
  7988. var repl;
  7989. var func;
  7990. var result="";
  7991. while((pos2=this._text.indexOf("[",pos1))!=-1){
  7992. if (pos2 > 0 && this._text.charCodeAt(pos2-1)==92){
  7993. result+=this._text.substring(pos1,pos2-1);
  7994. result+="[";
  7995. pos1=pos2+1;
  7996. continue ;
  7997. }
  7998. result+=this._text.substring(pos1,pos2);
  7999. pos1=pos2;
  8000. pos2=this._text.indexOf("]",pos1);
  8001. if(pos2==-1)
  8002. break ;
  8003. end=this._text.charAt(pos1+1)=='/';
  8004. tag=this._text.substring(end?pos1+2:pos1+1,pos2);
  8005. this._readPos=pos2+1;
  8006. attr=null;
  8007. repl=null;
  8008. pos3=tag.indexOf("=");
  8009. if(pos3!=-1){
  8010. attr=tag.substring(pos3+1);
  8011. tag=tag.substring(0,pos3);
  8012. }
  8013. tag=tag.toLowerCase();
  8014. func=this._handlers[tag];
  8015. if(func!=null){
  8016. if(!remove){
  8017. repl=func.call(this,tag,end,attr);
  8018. if(repl!=null)
  8019. result+=repl;
  8020. }
  8021. }
  8022. else
  8023. result+=this._text.substring(pos1,this._readPos);
  8024. pos1=this._readPos;
  8025. }
  8026. if (pos1 < this._text.length)
  8027. result+=this._text.substr(pos1);
  8028. this._text=null;
  8029. return result;
  8030. }
  8031. __static(UBBParser,
  8032. ['inst',function(){return this.inst=new UBBParser();}
  8033. ]);
  8034. return UBBParser;
  8035. })()
  8036. //class fairygui.utils.ColorMatrix extends Array
  8037. var ColorMatrix=(function(_super){
  8038. // initialization:
  8039. function ColorMatrix(){
  8040. ColorMatrix.__super.call(this);
  8041. this.reset();
  8042. }
  8043. __class(ColorMatrix,'fairygui.utils.ColorMatrix',Array);
  8044. var __proto=ColorMatrix.prototype;
  8045. // public methods:
  8046. __proto.reset=function(){
  8047. for (var i=0;i<ColorMatrix.LENGTH;i++){
  8048. this[i]=ColorMatrix.IDENTITY_MATRIX[i];
  8049. }
  8050. }
  8051. __proto.invert=function(){
  8052. this.multiplyMatrix([-1,0,0,0,255,
  8053. 0,-1,0,0,255,
  8054. 0,0,-1,0,255,
  8055. 0,0,0,1,0]);
  8056. }
  8057. __proto.adjustColor=function(p_brightness,p_contrast,p_saturation,p_hue){
  8058. this.adjustHue(p_hue);
  8059. this.adjustContrast(p_contrast);
  8060. this.adjustBrightness(p_brightness);
  8061. this.adjustSaturation(p_saturation);
  8062. }
  8063. __proto.adjustBrightness=function(p_val){
  8064. p_val=this.cleanValue(p_val,1)*255;
  8065. this.multiplyMatrix([
  8066. 1,0,0,0,p_val,
  8067. 0,1,0,0,p_val,
  8068. 0,0,1,0,p_val,
  8069. 0,0,0,1,0]);
  8070. }
  8071. __proto.adjustContrast=function(p_val){
  8072. p_val=this.cleanValue(p_val,1);
  8073. var s=p_val+1;
  8074. var o=128 *(1-s);
  8075. this.multiplyMatrix([
  8076. s,0,0,0,o,
  8077. 0,s,0,0,o,
  8078. 0,0,s,0,o,
  8079. 0,0,0,1,0]);
  8080. }
  8081. __proto.adjustSaturation=function(p_val){
  8082. p_val=this.cleanValue(p_val,1);
  8083. p_val+=1;
  8084. var invSat=1-p_val;
  8085. var invLumR=invSat *0.299;
  8086. var invLumG=invSat *0.587;
  8087. var invLumB=invSat *0.114;
  8088. this.multiplyMatrix([
  8089. (invLumR+p_val),invLumG,invLumB,0,0,
  8090. invLumR,(invLumG+p_val),invLumB,0,0,
  8091. invLumR,invLumG,(invLumB+p_val),0,0,
  8092. 0,0,0,1,0]);
  8093. }
  8094. __proto.adjustHue=function(p_val){
  8095. p_val=this.cleanValue(p_val,1);
  8096. p_val *=Math.PI;
  8097. var cos=Math.cos(p_val);
  8098. var sin=Math.sin(p_val);
  8099. this.multiplyMatrix([
  8100. ((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,
  8101. ((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,
  8102. ((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,
  8103. 0,0,0,1,0]);
  8104. }
  8105. __proto.concat=function(p_matrix){
  8106. if (p_matrix.length !=ColorMatrix.LENGTH){return;}
  8107. this.multiplyMatrix(p_matrix);
  8108. }
  8109. __proto.clone=function(){
  8110. var result=new ColorMatrix();
  8111. result.copyMatrix(this);
  8112. return result;
  8113. }
  8114. __proto.copyMatrix=function(p_matrix){
  8115. var l=ColorMatrix.LENGTH;
  8116. for (var i=0;i<l;i++){
  8117. this[i]=p_matrix[i];
  8118. }
  8119. }
  8120. __proto.multiplyMatrix=function(p_matrix){
  8121. var col=[];
  8122. var i=0;
  8123. for (var y=0;y<4;++y){
  8124. for (var x=0;x<5;++x){
  8125. col[i+x]=p_matrix[i] *this[x]+
  8126. p_matrix[i+1] *this[x+5]+
  8127. p_matrix[i+2] *this[x+10]+
  8128. p_matrix[i+3] *this[x+15]+
  8129. (x==4 ? p_matrix[i+4] :0);
  8130. }
  8131. i+=5;
  8132. }
  8133. this.copyMatrix(col);
  8134. }
  8135. __proto.cleanValue=function(p_val,p_limit){
  8136. return Math.min(p_limit,Math.max(-p_limit,p_val));
  8137. }
  8138. ColorMatrix.create=function(p_brightness,p_contrast,p_saturation,p_hue){
  8139. var ret=new ColorMatrix();
  8140. ret.adjustColor(p_brightness,p_contrast,p_saturation,p_hue);
  8141. return ret;
  8142. }
  8143. ColorMatrix.LUMA_R=0.299;
  8144. ColorMatrix.LUMA_G=0.587;
  8145. ColorMatrix.LUMA_B=0.114;
  8146. __static(ColorMatrix,
  8147. ['IDENTITY_MATRIX',function(){return this.IDENTITY_MATRIX=[
  8148. 1,0,0,0,0,
  8149. 0,1,0,0,0,
  8150. 0,0,1,0,0,
  8151. 0,0,0,1,0];},'LENGTH',function(){return this.LENGTH=ColorMatrix.IDENTITY_MATRIX.length;}
  8152. ]);
  8153. return ColorMatrix;
  8154. })(Array)
  8155. //class fairygui.Controller extends laya.events.EventDispatcher
  8156. var Controller=(function(_super){
  8157. function Controller(){
  8158. this._selectedIndex=0;
  8159. this._previousIndex=0;
  8160. this._pageIds=null;
  8161. this._pageNames=null;
  8162. this._actions=null;
  8163. this.name=null;
  8164. this.parent=null;
  8165. this.autoRadioGroupDepth=false;
  8166. this.changing=false;
  8167. Controller.__super.call(this);
  8168. this._pageIds=[];
  8169. this._pageNames=[];
  8170. this._selectedIndex=-1;
  8171. this._previousIndex=-1;
  8172. }
  8173. __class(Controller,'fairygui.Controller',_super);
  8174. var __proto=Controller.prototype;
  8175. __proto.dispose=function(){
  8176. this.offAll();
  8177. }
  8178. //功能和设置selectedIndex一样,但不会触发事件
  8179. __proto.setSelectedIndex=function(value){
  8180. (value===void 0)&& (value=0);
  8181. if (this._selectedIndex !=value){
  8182. if(value > this._pageIds.length-1)
  8183. throw "index out of bounds: "+value;
  8184. this.changing=true;
  8185. this._previousIndex=this._selectedIndex;
  8186. this._selectedIndex=value;
  8187. this.parent.applyController(this);
  8188. this.changing=false;
  8189. }
  8190. }
  8191. //功能和设置selectedPage一样,但不会触发事件
  8192. __proto.setSelectedPage=function(value){
  8193. var i=this._pageNames.indexOf(value);
  8194. if (i==-1)
  8195. i=0;
  8196. this.setSelectedIndex(i);
  8197. }
  8198. __proto.getPageName=function(index){
  8199. (index===void 0)&& (index=0);
  8200. return this._pageNames[index];
  8201. }
  8202. __proto.addPage=function(name){
  8203. (name===void 0)&& (name="");
  8204. this.addPageAt(name,this._pageIds.length);
  8205. }
  8206. __proto.addPageAt=function(name,index){
  8207. (index===void 0)&& (index=0);
  8208. var nid=""+(fairygui.Controller._nextPageId++);
  8209. if (index==this._pageIds.length){
  8210. this._pageIds.push(nid);
  8211. this._pageNames.push(name);
  8212. }
  8213. else {
  8214. this._pageIds.splice(index,0,nid);
  8215. this._pageNames.splice(index,0,name);
  8216. }
  8217. }
  8218. __proto.removePage=function(name){
  8219. var i=this._pageNames.indexOf(name);
  8220. if (i !=-1){
  8221. this._pageIds.splice(i,1);
  8222. this._pageNames.splice(i,1);
  8223. if (this._selectedIndex >=this._pageIds.length)
  8224. this.selectedIndex=this._selectedIndex-1;
  8225. else
  8226. this.parent.applyController(this);
  8227. }
  8228. }
  8229. __proto.removePageAt=function(index){
  8230. (index===void 0)&& (index=0);
  8231. this._pageIds.splice(index,1);
  8232. this._pageNames.splice(index,1);
  8233. if (this._selectedIndex >=this._pageIds.length)
  8234. this.selectedIndex=this._selectedIndex-1;
  8235. else
  8236. this.parent.applyController(this);
  8237. }
  8238. __proto.clearPages=function(){
  8239. this._pageIds.length=0;
  8240. this._pageNames.length=0;
  8241. if (this._selectedIndex !=-1)
  8242. this.selectedIndex=-1;
  8243. else
  8244. this.parent.applyController(this);
  8245. }
  8246. __proto.hasPage=function(aName){
  8247. return this._pageNames.indexOf(aName)!=-1;
  8248. }
  8249. __proto.getPageIndexById=function(aId){
  8250. return this._pageIds.indexOf(aId);
  8251. }
  8252. __proto.getPageIdByName=function(aName){
  8253. var i=this._pageNames.indexOf(aName);
  8254. if(i !=-1)
  8255. return this._pageIds[i];
  8256. else
  8257. return null;
  8258. }
  8259. __proto.getPageNameById=function(aId){
  8260. var i=this._pageIds.indexOf(aId);
  8261. if(i !=-1)
  8262. return this._pageNames[i];
  8263. else
  8264. return null;
  8265. }
  8266. __proto.getPageId=function(index){
  8267. (index===void 0)&& (index=0);
  8268. return this._pageIds[index];
  8269. }
  8270. __proto.runActions=function(){
  8271. if(this._actions){
  8272. var cnt=this._actions.length;
  8273. for(var i=0;i<cnt;i++){
  8274. this._actions[i].run(this,this.previousPageId,this.selectedPageId);
  8275. }
  8276. }
  8277. }
  8278. __proto.setup=function(buffer){
  8279. var beginPos=buffer.pos;
  8280. buffer.seek(beginPos,0);
  8281. this.name=buffer.readS();
  8282. this.autoRadioGroupDepth=buffer.readBool();
  8283. buffer.seek(beginPos,1);
  8284. var i=0;
  8285. var nextPos=0;
  8286. var cnt=buffer.getInt16();
  8287. for (i=0;i < cnt;i++){
  8288. this._pageIds.push(buffer.readS());
  8289. this._pageNames.push(buffer.readS());
  8290. }
  8291. buffer.seek(beginPos,2);
  8292. cnt=buffer.getInt16();
  8293. if (cnt > 0){
  8294. if (this._actions==null)
  8295. this._actions=[];
  8296. for (i=0;i < cnt;i++){
  8297. nextPos=buffer.getInt16();
  8298. nextPos+=buffer.pos;
  8299. var action=ControllerAction.createAction(buffer.readByte());
  8300. action.setup(buffer);
  8301. this._actions.push(action);
  8302. buffer.pos=nextPos;
  8303. }
  8304. }
  8305. if (this.parent !=null && this._pageIds.length > 0)
  8306. this._selectedIndex=0;
  8307. else
  8308. this._selectedIndex=-1;
  8309. }
  8310. __getset(0,__proto,'selectedIndex',function(){
  8311. return this._selectedIndex;
  8312. },function(value){
  8313. if(this._selectedIndex !=value){
  8314. if(value > this._pageIds.length-1)
  8315. throw "index out of bounds: "+value;
  8316. this.changing=true;
  8317. this._previousIndex=this._selectedIndex;
  8318. this._selectedIndex=value;
  8319. this.parent.applyController(this);
  8320. this.event("fui_state_changed");
  8321. this.changing=false;
  8322. }
  8323. });
  8324. __getset(0,__proto,'selectedPage',function(){
  8325. if (this._selectedIndex==-1)
  8326. return null;
  8327. else
  8328. return this._pageNames[this._selectedIndex];
  8329. },function(val){
  8330. var i=this._pageNames.indexOf(val);
  8331. if (i==-1)
  8332. i=0;
  8333. this.selectedIndex=i;
  8334. });
  8335. __getset(0,__proto,'previsousIndex',function(){
  8336. return this._previousIndex;
  8337. });
  8338. __getset(0,__proto,'previousPage',function(){
  8339. if (this._previousIndex==-1)
  8340. return null;
  8341. else
  8342. return this._pageNames[this._previousIndex];
  8343. });
  8344. __getset(0,__proto,'pageCount',function(){
  8345. return this._pageIds.length;
  8346. });
  8347. __getset(0,__proto,'selectedPageId',function(){
  8348. if (this._selectedIndex==-1)
  8349. return null;
  8350. else
  8351. return this._pageIds[this._selectedIndex];
  8352. },function(val){
  8353. var i=this._pageIds.indexOf(val);
  8354. this.selectedIndex=i;
  8355. });
  8356. __getset(0,__proto,'previousPageId',function(){
  8357. if(this._previousIndex==-1)
  8358. return null;
  8359. else
  8360. return this._pageIds[this._previousIndex];
  8361. });
  8362. __getset(0,__proto,'oppositePageId',null,function(val){
  8363. var i=this._pageIds.indexOf(val);
  8364. if(i > 0)
  8365. this.selectedIndex=0;
  8366. else if(this._pageIds.length > 1)
  8367. this.selectedIndex=1;
  8368. });
  8369. Controller._nextPageId=0;
  8370. return Controller;
  8371. })(EventDispatcher)
  8372. //class fairygui.utils.ByteBuffer extends laya.utils.Byte
  8373. var ByteBuffer=(function(_super){
  8374. function ByteBuffer(data,offset,length){
  8375. this.stringTable=null;
  8376. this.version=0;
  8377. (offset===void 0)&& (offset=0);
  8378. (length===void 0)&& (length=-1);
  8379. if(length==-1)
  8380. length=data.byteLength-offset;
  8381. if(offset==0 && length==data.byteLength)
  8382. ByteBuffer.__super.call(this,data);
  8383. else{
  8384. this._u8d_=new Uint8Array(data,offset,length);
  8385. this._d_=new DataView(this._u8d_.buffer,offset,length);
  8386. this._length=length;
  8387. }
  8388. this.endian="bigEndian";
  8389. }
  8390. __class(ByteBuffer,'fairygui.utils.ByteBuffer',_super);
  8391. var __proto=ByteBuffer.prototype;
  8392. __proto.skip=function(count){
  8393. this.pos+=count;
  8394. }
  8395. __proto.readBool=function(){
  8396. return this.getUint8()==1;
  8397. }
  8398. __proto.readS=function(){
  8399. var index=this.getUint16();
  8400. if (index==65534)
  8401. return null;
  8402. else if (index==65533)
  8403. return ""
  8404. else
  8405. return this.stringTable[index];
  8406. }
  8407. __proto.writeS=function(value){
  8408. var index=this.getUint16();
  8409. if (index !=65534 && index !=65533)
  8410. this.stringTable[index]=value;
  8411. }
  8412. __proto.readColor=function(hasAlpha){
  8413. (hasAlpha===void 0)&& (hasAlpha=false);
  8414. var r=this.getUint8();
  8415. var g=this.getUint8();
  8416. var b=this.getUint8();
  8417. var a=this.getUint8();
  8418. return (hasAlpha?(a<<24):0)+(r<<16)+(g<<8)+b;
  8419. }
  8420. __proto.readColorS=function(hasAlpha){
  8421. (hasAlpha===void 0)&& (hasAlpha=false);
  8422. var r=this.getUint8();
  8423. var g=this.getUint8();
  8424. var b=this.getUint8();
  8425. var a=this.getUint8();
  8426. if(hasAlpha && a!=255)
  8427. return "rgba("+r+","+g+","+b+","+(a/255)+")";
  8428. else{
  8429. var sr=r.toString(16);
  8430. var sg=g.toString(16);
  8431. var sb=b.toString(16);
  8432. if (sr.length==1)
  8433. sr="0"+sr;
  8434. if (sg.length==1)
  8435. sg="0"+sg;
  8436. if (sb.length==1)
  8437. sb="0"+sb;
  8438. return "#"+sr+sg+sb;
  8439. }
  8440. }
  8441. __proto.readChar=function(){
  8442. var i=this.getUint16();
  8443. return String.fromCharCode(i);
  8444. }
  8445. __proto.readBuffer=function(){
  8446. var count=this.getUint32();
  8447. var ba=new ByteBuffer(this.buffer,this._pos_,count);
  8448. ba.stringTable=this.stringTable;
  8449. ba.version=this.version;
  8450. return ba;
  8451. }
  8452. __proto.seek=function(indexTablePos,blockIndex){
  8453. var tmp=this._pos_;
  8454. this.pos=indexTablePos;
  8455. var segCount=this.getUint8();
  8456. if (blockIndex < segCount){
  8457. var useShort=this.getUint8()==1;
  8458. var newPos=0;
  8459. if (useShort){
  8460. this.pos+=2 *blockIndex;
  8461. newPos=this.getUint16();
  8462. }
  8463. else{
  8464. this.pos+=4 *blockIndex;
  8465. newPos=this.getUint32();
  8466. }
  8467. if (newPos > 0){
  8468. this.pos=indexTablePos+newPos;
  8469. return true;
  8470. }
  8471. else{
  8472. this.pos=tmp;
  8473. return false;
  8474. }
  8475. }
  8476. else{
  8477. this.pos=tmp;
  8478. return false;
  8479. }
  8480. }
  8481. return ByteBuffer;
  8482. })(Byte)
  8483. //class fairygui.utils.ChildHitArea extends laya.utils.HitArea
  8484. var ChildHitArea=(function(_super){
  8485. function ChildHitArea(child,reversed){
  8486. this._child=null;
  8487. this._reversed=false;
  8488. ChildHitArea.__super.call(this);
  8489. this._child=child;
  8490. this._reversed=reversed;
  8491. if(this._reversed)
  8492. this.unHit=child.hitArea.hit;
  8493. else
  8494. this.hit=child.hitArea.hit;
  8495. }
  8496. __class(ChildHitArea,'fairygui.utils.ChildHitArea',_super);
  8497. var __proto=ChildHitArea.prototype;
  8498. __proto.contains=function(x,y){
  8499. var tPos;
  8500. tPos=Point.TEMP;
  8501. tPos.setTo(0,0);
  8502. tPos=this._child.toParentPoint(tPos);
  8503. if (this._reversed)
  8504. return !HitArea._isHitGraphic(x-tPos.x,y-tPos.y,this.unHit);
  8505. else
  8506. return HitArea._isHitGraphic(x-tPos.x,y-tPos.y,this.hit);
  8507. }
  8508. return ChildHitArea;
  8509. })(HitArea)
  8510. //class fairygui.utils.PixelHitTest extends laya.utils.HitArea
  8511. var PixelHitTest=(function(_super){
  8512. function PixelHitTest(data,offsetX,offsetY){
  8513. this._data=null;
  8514. this.offsetX=0;
  8515. this.offsetY=0;
  8516. this.scaleX=NaN;
  8517. this.scaleY=NaN;
  8518. PixelHitTest.__super.call(this);
  8519. (offsetX===void 0)&& (offsetX=0);
  8520. (offsetY===void 0)&& (offsetY=0);
  8521. this._data=data;
  8522. this.offsetX=offsetX;
  8523. this.offsetY=offsetY;
  8524. this.scaleX=1;
  8525. this.scaleY=1;
  8526. }
  8527. __class(PixelHitTest,'fairygui.utils.PixelHitTest',_super);
  8528. var __proto=PixelHitTest.prototype;
  8529. __proto.contains=function(x,y){
  8530. x=Math.floor((x / this.scaleX-this.offsetX)*this._data.scale);
  8531. y=Math.floor((y / this.scaleY-this.offsetY)*this._data.scale);
  8532. if (x < 0 || y < 0 || x >=this._data.pixelWidth)
  8533. return false;
  8534. var pos=y *this._data.pixelWidth+x;
  8535. var pos2=Math.floor(pos / 8);
  8536. var pos3=pos % 8;
  8537. if (pos2 >=0 && pos2 < this._data.pixels.length)
  8538. return ((this._data.pixels[pos2] >> pos3)& 0x1)==1;
  8539. else
  8540. return false;
  8541. }
  8542. return PixelHitTest;
  8543. })(HitArea)
  8544. //class fairygui.action.ChangePageAction extends fairygui.action.ControllerAction
  8545. var ChangePageAction=(function(_super){
  8546. function ChangePageAction(){
  8547. this.objectId=null;
  8548. this.controllerName=null;
  8549. this.targetPage=null;
  8550. ChangePageAction.__super.call(this);
  8551. }
  8552. __class(ChangePageAction,'fairygui.action.ChangePageAction',_super);
  8553. var __proto=ChangePageAction.prototype;
  8554. __proto.enter=function(controller){
  8555. if(!this.controllerName)
  8556. return;
  8557. var gcom;
  8558. if(this.objectId)
  8559. gcom=controller.parent.getChildById(this.objectId);
  8560. else
  8561. gcom=controller.parent;
  8562. if(gcom){
  8563. var cc=gcom.getController(this.controllerName);
  8564. if(cc && cc!=controller && !cc.changing)
  8565. cc.selectedPageId=this.targetPage;
  8566. }
  8567. }
  8568. __proto.setup=function(buffer){
  8569. _super.prototype.setup.call(this,buffer);
  8570. this.objectId=buffer.readS();
  8571. this.controllerName=buffer.readS();
  8572. this.targetPage=buffer.readS();
  8573. }
  8574. return ChangePageAction;
  8575. })(ControllerAction)
  8576. //class fairygui.action.PlayTransitionAction extends fairygui.action.ControllerAction
  8577. var PlayTransitionAction=(function(_super){
  8578. function PlayTransitionAction(){
  8579. this.transitionName=null;
  8580. this.playTimes=1;
  8581. this.delay=0;
  8582. this.stopOnExit=false;
  8583. this._currentTransition=null;
  8584. PlayTransitionAction.__super.call(this);
  8585. }
  8586. __class(PlayTransitionAction,'fairygui.action.PlayTransitionAction',_super);
  8587. var __proto=PlayTransitionAction.prototype;
  8588. __proto.enter=function(controller){
  8589. var trans=controller.parent.getTransition(this.transitionName);
  8590. if(trans){
  8591. if(this._currentTransition && this._currentTransition.playing)
  8592. trans.changePlayTimes(this.playTimes);
  8593. else
  8594. trans.play(null,this.playTimes,this.delay);
  8595. this._currentTransition=trans;
  8596. }
  8597. }
  8598. __proto.leave=function(controller){
  8599. if(this.stopOnExit && this._currentTransition){
  8600. this._currentTransition.stop();
  8601. this._currentTransition=null;
  8602. }
  8603. }
  8604. __proto.setup=function(buffer){
  8605. _super.prototype.setup.call(this,buffer);
  8606. this.transitionName=buffer.readS();
  8607. this.playTimes=buffer.getInt32();
  8608. this.delay=buffer.getFloat32();
  8609. this.stopOnExit=buffer.readBool();
  8610. }
  8611. return PlayTransitionAction;
  8612. })(ControllerAction)
  8613. //class fairygui.GTextField extends fairygui.GObject
  8614. var GTextField=(function(_super){
  8615. function GTextField(){
  8616. this._gearColor=null;
  8617. this._templateVars=null;
  8618. this._text=null;
  8619. GTextField.__super.call(this);
  8620. this._gearColor=new GearColor(this);
  8621. }
  8622. __class(GTextField,'fairygui.GTextField',_super);
  8623. var __proto=GTextField.prototype;
  8624. Laya.imps(__proto,{"fairygui.gears.IColorGear":true})
  8625. __proto.parseTemplate=function(template){
  8626. var pos1=0,pos2=0,pos3=0;
  8627. var tag;
  8628. var value;
  8629. var result="";
  8630. while((pos2=template.indexOf("{",pos1))!=-1){
  8631. if (pos2 > 0 && template.charCodeAt(pos2-1)==92){
  8632. result+=template.substring(pos1,pos2-1);
  8633. result+="{";
  8634. pos1=pos2+1;
  8635. continue ;
  8636. }
  8637. result+=template.substring(pos1,pos2);
  8638. pos1=pos2;
  8639. pos2=template.indexOf("}",pos1);
  8640. if(pos2==-1)
  8641. break ;
  8642. if(pos2==pos1+1){
  8643. result+=template.substr(pos1,2);
  8644. pos1=pos2+1;
  8645. continue ;
  8646. }
  8647. tag=template.substring(pos1+1,pos2);
  8648. pos3=tag.indexOf("=");
  8649. if(pos3!=-1){
  8650. value=this._templateVars[tag.substring(0,pos3)];
  8651. if(value==null)
  8652. result+=tag.substring(pos3+1);
  8653. else
  8654. result+=value;
  8655. }
  8656. else{
  8657. value=this._templateVars[tag];
  8658. if(value!=null)
  8659. result+=value;
  8660. }
  8661. pos1=pos2+1;
  8662. }
  8663. if (pos1 < template.length)
  8664. result+=template.substr(pos1);
  8665. return result;
  8666. }
  8667. __proto.setVar=function(name,value){
  8668. if(!this._templateVars)
  8669. this._templateVars={};
  8670. this._templateVars[name]=value;
  8671. return this;
  8672. }
  8673. __proto.flushVars=function(){
  8674. this.text=this._text;
  8675. }
  8676. __proto.handleControllerChanged=function(c){
  8677. _super.prototype.handleControllerChanged.call(this,c);
  8678. if(this._gearColor.controller==c)
  8679. this._gearColor.apply();
  8680. }
  8681. __proto.setup_beforeAdd=function(buffer,beginPos){
  8682. _super.prototype.setup_beforeAdd.call(this,buffer,beginPos);
  8683. buffer.seek(beginPos,5);
  8684. var iv=0;
  8685. this.font=buffer.readS();
  8686. this.fontSize=buffer.getInt16();
  8687. this.color=buffer.readColorS();
  8688. iv=buffer.readByte();
  8689. this.align=iv==0?"left":(iv==1?"center":"right");
  8690. iv=buffer.readByte();
  8691. this.valign=iv==0?"top":(iv==1?"middle":"bottom");
  8692. this.leading=buffer.getInt16();
  8693. this.letterSpacing=buffer.getInt16();
  8694. this.ubbEnabled=buffer.readBool();
  8695. this.autoSize=buffer.readByte();
  8696. this.underline=buffer.readBool();
  8697. this.italic=buffer.readBool();
  8698. this.bold=buffer.readBool();
  8699. this.singleLine=buffer.readBool();
  8700. if (buffer.readBool()){
  8701. this.strokeColor=buffer.readColorS();
  8702. this.stroke=buffer.getFloat32()+1;
  8703. }
  8704. if (buffer.readBool())
  8705. buffer.skip(12);
  8706. if (buffer.readBool())
  8707. this._templateVars={};
  8708. }
  8709. __proto.setup_afterAdd=function(buffer,beginPos){
  8710. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  8711. buffer.seek(beginPos,6);
  8712. var str=buffer.readS();
  8713. if (str !=null)
  8714. this.text=str;
  8715. }
  8716. __getset(0,__proto,'color',function(){
  8717. return null;
  8718. },function(value){
  8719. });
  8720. __getset(0,__proto,'font',function(){
  8721. return null;
  8722. },function(value){
  8723. });
  8724. __getset(0,__proto,'templateVars',function(){
  8725. return this._templateVars;
  8726. },function(value){
  8727. if(this._templateVars==null && value==null)
  8728. return;
  8729. this._templateVars=value;
  8730. this.flushVars();
  8731. });
  8732. __getset(0,__proto,'leading',function(){
  8733. return 0;
  8734. },function(value){
  8735. });
  8736. __getset(0,__proto,'fontSize',function(){
  8737. return 0;
  8738. },function(value){
  8739. });
  8740. __getset(0,__proto,'bold',function(){
  8741. return false;
  8742. },function(value){
  8743. });
  8744. __getset(0,__proto,'letterSpacing',function(){
  8745. return 0;
  8746. },function(value){
  8747. });
  8748. __getset(0,__proto,'align',function(){
  8749. return null;
  8750. },function(value){
  8751. });
  8752. __getset(0,__proto,'valign',function(){
  8753. return null;
  8754. },function(value){
  8755. });
  8756. __getset(0,__proto,'italic',function(){
  8757. return false;
  8758. },function(value){
  8759. });
  8760. __getset(0,__proto,'underline',function(){
  8761. return false;
  8762. },function(value){
  8763. });
  8764. __getset(0,__proto,'singleLine',function(){
  8765. return false;
  8766. },function(value){
  8767. });
  8768. __getset(0,__proto,'stroke',function(){
  8769. return 0;
  8770. },function(value){
  8771. });
  8772. __getset(0,__proto,'strokeColor',function(){
  8773. return null;
  8774. },function(value){
  8775. });
  8776. __getset(0,__proto,'ubbEnabled',function(){
  8777. return false;
  8778. },function(value){
  8779. });
  8780. /**
  8781. *@see AutoSizeType
  8782. */
  8783. /**
  8784. *@see AutoSizeType
  8785. */
  8786. __getset(0,__proto,'autoSize',function(){
  8787. return 0;
  8788. },function(value){
  8789. });
  8790. __getset(0,__proto,'textWidth',function(){
  8791. return 0;
  8792. });
  8793. return GTextField;
  8794. })(GObject)
  8795. //class fairygui.GComponent extends fairygui.GObject
  8796. var GComponent=(function(_super){
  8797. function GComponent(){
  8798. this._sortingChildCount=0;
  8799. this._opaque=false;
  8800. this._applyingController=null;
  8801. this._mask=null;
  8802. this._margin=null;
  8803. this._trackBounds=false;
  8804. this._boundsChanged=false;
  8805. this._childrenRenderOrder=0;
  8806. this._apexIndex=0;
  8807. this._buildingDisplayList=false;
  8808. this._children=null;
  8809. this._controllers=null;
  8810. this._transitions=null;
  8811. this._container=null;
  8812. this._scrollPane=null;
  8813. this._alignOffset=null;
  8814. GComponent.__super.call(this);
  8815. this._children=[];
  8816. this._controllers=[];
  8817. this._transitions=[];
  8818. this._margin=new Margin();
  8819. this._alignOffset=new Point();
  8820. this._opaque=false;
  8821. }
  8822. __class(GComponent,'fairygui.GComponent',_super);
  8823. var __proto=GComponent.prototype;
  8824. __proto.createDisplayObject=function(){
  8825. _super.prototype.createDisplayObject.call(this);
  8826. this._displayObject.mouseEnabled=true;
  8827. this._displayObject.mouseThrough=true;
  8828. this._container=this._displayObject;
  8829. }
  8830. __proto.dispose=function(){
  8831. var i=0;
  8832. var cnt=0;
  8833. cnt=this._transitions.length;
  8834. for (i=0;i < cnt;++i){
  8835. var trans=this._transitions[i];
  8836. trans.dispose();
  8837. }
  8838. cnt=this._controllers.length;
  8839. for (i=0;i < cnt;++i){
  8840. var cc=this._controllers[i];
  8841. cc.dispose();
  8842. }
  8843. if (this.scrollPane !=null)
  8844. this.scrollPane.dispose();
  8845. cnt=this._children.length;
  8846. for(i=cnt-1;i >=0;--i){
  8847. var obj=this._children[i];
  8848. obj.parent=null;
  8849. obj.dispose();
  8850. }
  8851. this._boundsChanged=false;
  8852. this._mask=null;
  8853. _super.prototype.dispose.call(this);
  8854. }
  8855. __proto.addChild=function(child){
  8856. this.addChildAt(child,this._children.length);
  8857. return child;
  8858. }
  8859. __proto.addChildAt=function(child,index){
  8860. (index===void 0)&& (index=0);
  8861. if(!child)
  8862. throw "child is null";
  8863. var numChildren=this._children.length;
  8864. if(index >=0 && index <=numChildren){
  8865. if(child.parent==this){
  8866. this.setChildIndex(child,index);
  8867. }
  8868. else {
  8869. child.removeFromParent();
  8870. child.parent=this;
  8871. var cnt=this._children.length;
  8872. if(child.sortingOrder !=0){
  8873. this._sortingChildCount++;
  8874. index=this.getInsertPosForSortingChild(child);
  8875. }
  8876. else if(this._sortingChildCount > 0){
  8877. if(index > (cnt-this._sortingChildCount))
  8878. index=cnt-this._sortingChildCount;
  8879. }
  8880. if(index==cnt)
  8881. this._children.push(child);
  8882. else
  8883. this._children.splice(index,0,child);
  8884. this.childStateChanged(child);
  8885. this.setBoundsChangedFlag();
  8886. }
  8887. return child;
  8888. }
  8889. else {
  8890. throw "Invalid child index";
  8891. }
  8892. }
  8893. __proto.getInsertPosForSortingChild=function(target){
  8894. var cnt=this._children.length;
  8895. var i=0;
  8896. for(i=0;i < cnt;i++){
  8897. var child=this._children[i];
  8898. if(child==target)
  8899. continue ;
  8900. if(target.sortingOrder < child.sortingOrder)
  8901. break ;
  8902. }
  8903. return i;
  8904. }
  8905. __proto.removeChild=function(child,dispose){
  8906. (dispose===void 0)&& (dispose=false);
  8907. var childIndex=this._children.indexOf(child);
  8908. if(childIndex !=-1){
  8909. this.removeChildAt(childIndex,dispose);
  8910. }
  8911. return child;
  8912. }
  8913. __proto.removeChildAt=function(index,dispose){
  8914. (dispose===void 0)&& (dispose=false);
  8915. if(index >=0 && index < this.numChildren){
  8916. var child=this._children[index];
  8917. child.parent=null;
  8918. if(child.sortingOrder !=0)
  8919. this._sortingChildCount--;
  8920. this._children.splice(index,1);
  8921. child.group=null;
  8922. if(child.inContainer){
  8923. this._container.removeChild(child.displayObject);
  8924. if (this._childrenRenderOrder==2)
  8925. Laya.timer.callLater(this,this.buildNativeDisplayList);
  8926. }
  8927. if(dispose)
  8928. child.dispose();
  8929. this.setBoundsChangedFlag();
  8930. return child;
  8931. }
  8932. else {
  8933. throw "Invalid child index";
  8934. }
  8935. }
  8936. __proto.removeChildren=function(beginIndex,endIndex,dispose){
  8937. (beginIndex===void 0)&& (beginIndex=0);
  8938. (endIndex===void 0)&& (endIndex=-1);
  8939. (dispose===void 0)&& (dispose=false);
  8940. if(endIndex < 0 || endIndex >=this.numChildren)
  8941. endIndex=this.numChildren-1;
  8942. for(var i=beginIndex;i <=endIndex;++i)
  8943. this.removeChildAt(beginIndex,dispose);
  8944. }
  8945. __proto.getChildAt=function(index){
  8946. (index===void 0)&& (index=0);
  8947. if(index >=0 && index < this.numChildren)
  8948. return this._children[index];
  8949. else
  8950. throw "Invalid child index";
  8951. }
  8952. __proto.getChild=function(name){
  8953. var cnt=this._children.length;
  8954. for(var i=0;i < cnt;++i){
  8955. if(this._children[i].name==name)
  8956. return this._children[i];
  8957. }
  8958. return null;
  8959. }
  8960. __proto.getVisibleChild=function(name){
  8961. var cnt=this._children.length;
  8962. for(var i=0;i < cnt;++i){
  8963. var child=this._children[i];
  8964. if(child.internalVisible && child.internalVisible2 && child.name==name)
  8965. return child;
  8966. }
  8967. return null;
  8968. }
  8969. __proto.getChildInGroup=function(name,group){
  8970. var cnt=this._children.length;
  8971. for(var i=0;i < cnt;++i){
  8972. var child=this._children[i];
  8973. if(child.group==group && child.name==name)
  8974. return child;
  8975. }
  8976. return null;
  8977. }
  8978. __proto.getChildById=function(id){
  8979. var cnt=this._children.length;
  8980. for(var i=0;i < cnt;++i){
  8981. if(this._children[i]._id==id)
  8982. return this._children[i];
  8983. }
  8984. return null;
  8985. }
  8986. __proto.getChildIndex=function(child){
  8987. return this._children.indexOf(child);
  8988. }
  8989. __proto.setChildIndex=function(child,index){
  8990. (index===void 0)&& (index=0);
  8991. var oldIndex=this._children.indexOf(child);
  8992. if(oldIndex==-1)
  8993. throw "Not a child of this container";
  8994. if(child.sortingOrder !=0)
  8995. return;
  8996. var cnt=this._children.length;
  8997. if(this._sortingChildCount > 0){
  8998. if(index > (cnt-this._sortingChildCount-1))
  8999. index=cnt-this._sortingChildCount-1;
  9000. }
  9001. this._setChildIndex(child,oldIndex,index);
  9002. }
  9003. __proto.setChildIndexBefore=function(child,index){
  9004. var oldIndex=this._children.indexOf(child);
  9005. if (oldIndex==-1)
  9006. throw "Not a child of this container";
  9007. if(child.sortingOrder!=0)
  9008. return oldIndex;
  9009. var cnt=this._children.length;
  9010. if(this._sortingChildCount>0){
  9011. if (index > (cnt-this._sortingChildCount-1))
  9012. index=cnt-this._sortingChildCount-1;
  9013. }
  9014. if (oldIndex < index)
  9015. return this._setChildIndex(child,oldIndex,index-1);
  9016. else
  9017. return this._setChildIndex(child,oldIndex,index);
  9018. }
  9019. __proto._setChildIndex=function(child,oldIndex,index){
  9020. var cnt=this._children.length;
  9021. if(index > cnt)
  9022. index=cnt;
  9023. if(oldIndex==index)
  9024. return oldIndex;
  9025. this._children.splice(oldIndex,1);
  9026. this._children.splice(index,0,child);
  9027. if(child.inContainer){
  9028. var displayIndex=0;
  9029. var g;
  9030. var i=0;
  9031. if (this._childrenRenderOrder==0){
  9032. for(i=0;i<index;i++){
  9033. g=this._children[i];
  9034. if(g.inContainer)
  9035. displayIndex++;
  9036. }
  9037. if(displayIndex==this._container.numChildren)
  9038. displayIndex--;
  9039. this._container.setChildIndex(child.displayObject,displayIndex);
  9040. }
  9041. else if (this._childrenRenderOrder==1){
  9042. for (i=cnt-1;i > index;i--){
  9043. g=this._children[i];
  9044. if (g.inContainer)
  9045. displayIndex++;
  9046. }
  9047. if(displayIndex==this._container.numChildren)
  9048. displayIndex--;
  9049. this._container.setChildIndex(child.displayObject,displayIndex);
  9050. }
  9051. else{
  9052. Laya.timer.callLater(this,this.buildNativeDisplayList);
  9053. }
  9054. this.setBoundsChangedFlag();
  9055. }
  9056. return index;
  9057. }
  9058. __proto.swapChildren=function(child1,child2){
  9059. var index1=this._children.indexOf(child1);
  9060. var index2=this._children.indexOf(child2);
  9061. if(index1==-1 || index2==-1)
  9062. throw "Not a child of this container";
  9063. this.swapChildrenAt(index1,index2);
  9064. }
  9065. __proto.swapChildrenAt=function(index1,index2){
  9066. (index2===void 0)&& (index2=0);
  9067. var child1=this._children[index1];
  9068. var child2=this._children[index2];
  9069. this.setChildIndex(child1,index2);
  9070. this.setChildIndex(child2,index1);
  9071. }
  9072. __proto.isAncestorOf=function(child){
  9073. if (child==null)
  9074. return false;
  9075. var p=child.parent;
  9076. while(p){
  9077. if(p==this)
  9078. return true;
  9079. p=p.parent;
  9080. }
  9081. return false;
  9082. }
  9083. __proto.addController=function(controller){
  9084. this._controllers.push(controller);
  9085. controller.parent=this;
  9086. this.applyController(controller);
  9087. }
  9088. __proto.getControllerAt=function(index){
  9089. return this._controllers[index];
  9090. }
  9091. __proto.getController=function(name){
  9092. var cnt=this._controllers.length;
  9093. for(var i=0;i < cnt;++i){
  9094. var c=this._controllers[i];
  9095. if(c.name==name)
  9096. return c;
  9097. }
  9098. return null;
  9099. }
  9100. __proto.removeController=function(c){
  9101. var index=this._controllers.indexOf(c);
  9102. if(index==-1)
  9103. throw new Error("controller not exists");
  9104. c.parent=null;
  9105. this._controllers.splice(index,1);
  9106. var length=this._children.length;
  9107. for(var i=0;i < length;i++){
  9108. var child=this._children[i];
  9109. child.handleControllerChanged(c);
  9110. }
  9111. }
  9112. __proto.childStateChanged=function(child){
  9113. if(this._buildingDisplayList)
  9114. return;
  9115. var cnt=this._children.length;
  9116. if((child instanceof fairygui.GGroup )){
  9117. for(var i=0;i < cnt;i++){
  9118. var g=this._children[i];
  9119. if(g.group==child)
  9120. this.childStateChanged(g);
  9121. }
  9122. return;
  9123. }
  9124. if(!child.displayObject)
  9125. return;
  9126. if(child.internalVisible && child.displayObject!=this._displayObject.mask){
  9127. if(!child.displayObject.parent){
  9128. var index=0
  9129. if (this._childrenRenderOrder==0){
  9130. for (i=0;i < cnt;i++){
  9131. g=this._children[i];
  9132. if (g==child)
  9133. break ;
  9134. if (g.displayObject !=null && g.displayObject.parent !=null)
  9135. index++;
  9136. }
  9137. this._container.addChildAt(child.displayObject,index);
  9138. }
  9139. else if (this._childrenRenderOrder==1){
  9140. for (i=cnt-1;i >=0;i--){
  9141. g=this._children[i];
  9142. if (g==child)
  9143. break ;
  9144. if (g.displayObject !=null && g.displayObject.parent !=null)
  9145. index++;
  9146. }
  9147. this._container.addChildAt(child.displayObject,index);
  9148. }
  9149. else{
  9150. this._container.addChild(child.displayObject);
  9151. Laya.timer.callLater(this,this.buildNativeDisplayList);
  9152. }
  9153. }
  9154. }
  9155. else {
  9156. if(child.displayObject.parent){
  9157. this._container.removeChild(child.displayObject);
  9158. if (this._childrenRenderOrder==2)
  9159. Laya.timer.callLater(this,this.buildNativeDisplayList);
  9160. }
  9161. }
  9162. }
  9163. __proto.buildNativeDisplayList=function(){
  9164. var cnt=this._children.length;
  9165. if (cnt==0)
  9166. return;
  9167. var i=0;
  9168. var child;
  9169. switch (this._childrenRenderOrder){
  9170. case 0:{
  9171. for (i=0;i < cnt;i++){
  9172. child=this._children[i];
  9173. if (child.displayObject !=null && child.internalVisible)
  9174. this._container.addChild(child.displayObject);
  9175. }
  9176. }
  9177. break ;
  9178. case 1:{
  9179. for (i=cnt-1;i >=0;i--){
  9180. child=this._children[i];
  9181. if (child.displayObject !=null && child.internalVisible)
  9182. this._container.addChild(child.displayObject);
  9183. }
  9184. }
  9185. break ;
  9186. case 2:{
  9187. for (i=0;i < this._apexIndex;i++){
  9188. child=this._children[i];
  9189. if (child.displayObject !=null && child.internalVisible)
  9190. this._container.addChild(child.displayObject);
  9191. }
  9192. for (i=cnt-1;i >=this._apexIndex;i--){
  9193. child=this._children[i];
  9194. if (child.displayObject !=null && child.internalVisible)
  9195. this._container.addChild(child.displayObject);
  9196. }
  9197. }
  9198. break ;
  9199. }
  9200. }
  9201. __proto.applyController=function(c){
  9202. this._applyingController=c;
  9203. var child;
  9204. var length=this._children.length;
  9205. for(var i=0;i < length;i++){
  9206. child=this._children[i];
  9207. child.handleControllerChanged(c);
  9208. }
  9209. this._applyingController=null;
  9210. c.runActions();
  9211. }
  9212. __proto.applyAllControllers=function(){
  9213. var cnt=this._controllers.length;
  9214. for(var i=0;i < cnt;++i){
  9215. this.applyController(this._controllers[i]);
  9216. }
  9217. }
  9218. __proto.adjustRadioGroupDepth=function(obj,c){
  9219. var cnt=this._children.length;
  9220. var i=NaN;
  9221. var child;
  9222. var myIndex=-1,maxIndex=-1;
  9223. for(i=0;i < cnt;i++){
  9224. child=this._children[i];
  9225. if(child==obj){
  9226. myIndex=i;
  9227. }
  9228. else if(((child instanceof fairygui.GButton ))
  9229. && (child).relatedController==c){
  9230. if(i > maxIndex)
  9231. maxIndex=i;
  9232. }
  9233. }
  9234. if(myIndex < maxIndex){
  9235. if(this._applyingController!=null)
  9236. this._children[maxIndex].handleControllerChanged(this._applyingController);
  9237. this.swapChildrenAt(myIndex,maxIndex);
  9238. }
  9239. }
  9240. __proto.getTransitionAt=function(index){
  9241. return this._transitions[index];
  9242. }
  9243. __proto.getTransition=function(transName){
  9244. var cnt=this._transitions.length;
  9245. for(var i=0;i < cnt;++i){
  9246. var trans=this._transitions[i];
  9247. if(trans.name==transName)
  9248. return trans;
  9249. }
  9250. return null;
  9251. }
  9252. __proto.isChildInView=function(child){
  9253. if(this._displayObject.scrollRect !=null){
  9254. return child.x+child.width >=0 && child.x <=this.width
  9255. && child.y+child.height >=0 && child.y <=this.height;
  9256. }
  9257. else if(this._scrollPane !=null){
  9258. return this._scrollPane.isChildInView(child);
  9259. }
  9260. else
  9261. return true;
  9262. }
  9263. __proto.getFirstChildInView=function(){
  9264. var cnt=this._children.length;
  9265. for(var i=0;i < cnt;++i){
  9266. var child=this._children[i];
  9267. if(this.isChildInView(child))
  9268. return i;
  9269. }
  9270. return-1;
  9271. }
  9272. __proto.setMask=function(value,reversed){
  9273. if(this._mask && this._mask!=value){
  9274. if(this._mask.blendMode=="destination-out")
  9275. this._mask.blendMode=null;
  9276. }
  9277. this._mask=value;
  9278. if(!this._mask){
  9279. this._displayObject.mask=null;
  9280. if((this._displayObject.hitArea instanceof fairygui.utils.ChildHitArea ))
  9281. this._displayObject.hitArea=null;
  9282. return;
  9283. }
  9284. if(this._mask.hitArea){
  9285. this._displayObject.hitArea=new ChildHitArea(this._mask,reversed);
  9286. this._displayObject.mouseThrough=false;
  9287. this._displayObject.hitTestPrior=true;
  9288. }
  9289. if(reversed){
  9290. this._displayObject.mask=null;
  9291. this._displayObject.cacheAs="bitmap";
  9292. this._mask.blendMode="destination-out";
  9293. }
  9294. else
  9295. this._displayObject.mask=this._mask;
  9296. }
  9297. __proto.updateHitArea=function(){
  9298. if((this._displayObject.hitArea instanceof fairygui.utils.PixelHitTest )){
  9299. var hitTest=(this._displayObject.hitArea);
  9300. if(this.sourceWidth!=0)
  9301. hitTest.scaleX=this.width/this.sourceWidth;
  9302. if(this.sourceHeight!=0)
  9303. hitTest.scaleY=this.height/this.sourceHeight;
  9304. }
  9305. else if((this._displayObject.hitArea instanceof laya.maths.Rectangle )){
  9306. this._displayObject.hitArea.setTo(0,0,this.width,this.height);
  9307. }
  9308. }
  9309. __proto.updateMask=function(){
  9310. var rect=this._displayObject.scrollRect;
  9311. if(rect==null)
  9312. rect=new Rectangle();
  9313. rect.x=this._margin.left;
  9314. rect.y=this._margin.top;
  9315. rect.width=this.width-this._margin.right;
  9316. rect.height=this.height-this._margin.bottom;
  9317. this._displayObject.scrollRect=rect;
  9318. }
  9319. __proto.setupScroll=function(buffer){
  9320. if (this._displayObject==this._container){
  9321. this._container=new Sprite();
  9322. this._displayObject.addChild(this._container);
  9323. }
  9324. this._scrollPane=new ScrollPane(this);
  9325. this._scrollPane.setup(buffer);
  9326. }
  9327. __proto.setupOverflow=function(overflow){
  9328. if(overflow==1){
  9329. if (this._displayObject==this._container){
  9330. this._container=new Sprite();
  9331. this._displayObject.addChild(this._container);
  9332. }
  9333. this.updateMask();
  9334. this._container.pos(this._margin.left,this._margin.top);
  9335. }
  9336. else if(this._margin.left !=0 || this._margin.top !=0){
  9337. if (this._displayObject==this._container){
  9338. this._container=new Sprite();
  9339. this._displayObject.addChild(this._container);
  9340. }
  9341. this._container.pos(this._margin.left,this._margin.top);
  9342. }
  9343. }
  9344. __proto.handleSizeChanged=function(){
  9345. _super.prototype.handleSizeChanged.call(this);
  9346. if(this._scrollPane)
  9347. this._scrollPane.onOwnerSizeChanged();
  9348. else if(this._displayObject.scrollRect !=null)
  9349. this.updateMask();
  9350. if(this._displayObject.hitArea!=null)
  9351. this.updateHitArea();
  9352. }
  9353. __proto.handleGrayedChanged=function(){
  9354. var c=this.getController("grayed");
  9355. if(c !=null){
  9356. c.selectedIndex=this.grayed ? 1 :0;
  9357. return;
  9358. };
  9359. var v=this.grayed;
  9360. var cnt=this._children.length;
  9361. for(var i=0;i < cnt;++i){
  9362. this._children[i].grayed=v;
  9363. }
  9364. }
  9365. __proto.handleControllerChanged=function(c){
  9366. _super.prototype.handleControllerChanged.call(this,c);
  9367. if (this._scrollPane !=null)
  9368. this._scrollPane.handleControllerChanged(c);
  9369. }
  9370. __proto.setBoundsChangedFlag=function(){
  9371. if (!this._scrollPane && !this._trackBounds)
  9372. return;
  9373. if (!this._boundsChanged){
  9374. this._boundsChanged=true;
  9375. Laya.timer.callLater(this,this.__render);
  9376. }
  9377. }
  9378. __proto.__render=function(){
  9379. if (this._boundsChanged){
  9380. var i1=0;
  9381. var len=this._children.length;
  9382. var child
  9383. for(i1=0;i1 < len;i1++){
  9384. child=this._children[i1];
  9385. child.ensureSizeCorrect();
  9386. }
  9387. this.updateBounds();
  9388. }
  9389. }
  9390. __proto.ensureBoundsCorrect=function(){
  9391. var i1=0;
  9392. var len=this._children.length;
  9393. var child
  9394. for(i1=0;i1 < len;i1++){
  9395. child=this._children[i1];
  9396. child.ensureSizeCorrect();
  9397. }
  9398. if (this._boundsChanged)
  9399. this.updateBounds();
  9400. }
  9401. __proto.updateBounds=function(){
  9402. var ax=0,ay=0,aw=0,ah=0;
  9403. var len=this._children.length;
  9404. if(len > 0){
  9405. ax=Number.POSITIVE_INFINITY,ay=Number.POSITIVE_INFINITY;
  9406. var ar=Number.NEGATIVE_INFINITY,ab=Number.NEGATIVE_INFINITY;
  9407. var tmp=0;
  9408. var i1=0;
  9409. for(i1=0;i1 < len;i1++){
  9410. var child=this._children[i1];
  9411. tmp=child.x;
  9412. if(tmp < ax)
  9413. ax=tmp;
  9414. tmp=child.y;
  9415. if(tmp < ay)
  9416. ay=tmp;
  9417. tmp=child.x+child.actualWidth;
  9418. if(tmp > ar)
  9419. ar=tmp;
  9420. tmp=child.y+child.actualHeight;
  9421. if(tmp > ab)
  9422. ab=tmp;
  9423. }
  9424. aw=ar-ax;
  9425. ah=ab-ay;
  9426. }
  9427. this.setBounds(ax,ay,aw,ah);
  9428. }
  9429. __proto.setBounds=function(ax,ay,aw,ah){
  9430. this._boundsChanged=false;
  9431. if (this._scrollPane)
  9432. this._scrollPane.setContentSize(Math.round(ax+aw),Math.round(ay+ah));
  9433. }
  9434. __proto.getSnappingPosition=function(xValue,yValue,resultPoint){
  9435. if(!resultPoint)
  9436. resultPoint=new Point();
  9437. var cnt=this._children.length;
  9438. if(cnt==0){
  9439. resultPoint.x=0;
  9440. resultPoint.y=0;
  9441. return resultPoint;
  9442. }
  9443. this.ensureBoundsCorrect();
  9444. var obj=null;
  9445. var prev=null;
  9446. var i=0;
  9447. if(yValue !=0){
  9448. for(;i < cnt;i++){
  9449. obj=this._children[i];
  9450. if(yValue < obj.y){
  9451. if(i==0){
  9452. yValue=0;
  9453. break ;
  9454. }
  9455. else {
  9456. prev=this._children[i-1];
  9457. if(yValue < prev.y+prev.actualHeight / 2)
  9458. yValue=prev.y;
  9459. else
  9460. yValue=obj.y;
  9461. break ;
  9462. }
  9463. }
  9464. }
  9465. if(i==cnt)
  9466. yValue=obj.y;
  9467. }
  9468. if(xValue !=0){
  9469. if(i > 0)
  9470. i--;
  9471. for(;i < cnt;i++){
  9472. obj=this._children[i];
  9473. if(xValue < obj.x){
  9474. if(i==0){
  9475. xValue=0;
  9476. break ;
  9477. }
  9478. else {
  9479. prev=this._children[i-1];
  9480. if(xValue < prev.x+prev.actualWidth / 2)
  9481. xValue=prev.x;
  9482. else
  9483. xValue=obj.x;
  9484. break ;
  9485. }
  9486. }
  9487. }
  9488. if(i==cnt)
  9489. xValue=obj.x;
  9490. }
  9491. resultPoint.x=xValue;
  9492. resultPoint.y=yValue;
  9493. return resultPoint;
  9494. }
  9495. __proto.childSortingOrderChanged=function(child,oldValue,newValue){
  9496. (newValue===void 0)&& (newValue=0);
  9497. if (newValue==0){
  9498. this._sortingChildCount--;
  9499. this.setChildIndex(child,this._children.length);
  9500. }
  9501. else {
  9502. if (oldValue==0)
  9503. this._sortingChildCount++;
  9504. var oldIndex=this._children.indexOf(child);
  9505. var index=this.getInsertPosForSortingChild(child);
  9506. if (oldIndex < index)
  9507. this._setChildIndex(child,oldIndex,index-1);
  9508. else
  9509. this._setChildIndex(child,oldIndex,index);
  9510. }
  9511. }
  9512. __proto.constructFromResource=function(){
  9513. this.constructFromResource2(null,0);
  9514. }
  9515. __proto.constructFromResource2=function(objectPool,poolIndex){
  9516. if (!this.packageItem.decoded){
  9517. this.packageItem.decoded=true;
  9518. TranslationHelper.translateComponent(this.packageItem);
  9519. };
  9520. var i=0;
  9521. var dataLen=0;
  9522. var curPos=0;
  9523. var nextPos=0;
  9524. var f1=NaN;
  9525. var f2=NaN;
  9526. var i1=0;
  9527. var i2=0;
  9528. var buffer=this.packageItem.rawData;
  9529. buffer.seek(0,0);
  9530. this._underConstruct=true;
  9531. this.sourceWidth=buffer.getInt32();
  9532. this.sourceHeight=buffer.getInt32();
  9533. this.initWidth=this.sourceWidth;
  9534. this.initHeight=this.sourceHeight;
  9535. this.setSize(this.sourceWidth,this.sourceHeight);
  9536. if (buffer.readBool()){
  9537. this.minWidth=buffer.getInt32();
  9538. this.maxWidth=buffer.getInt32();
  9539. this.minHeight=buffer.getInt32();
  9540. this.maxHeight=buffer.getInt32();
  9541. }
  9542. if (buffer.readBool()){
  9543. f1=buffer.getFloat32();
  9544. f2=buffer.getFloat32();
  9545. this.internalSetPivot(f1,f2,buffer.readBool());
  9546. }
  9547. if (buffer.readBool()){
  9548. this._margin.top=buffer.getInt32();
  9549. this._margin.bottom=buffer.getInt32();
  9550. this._margin.left=buffer.getInt32();
  9551. this._margin.right=buffer.getInt32();
  9552. };
  9553. var overflow=buffer.readByte();
  9554. if (overflow==2){
  9555. var savedPos=buffer.pos;
  9556. buffer.seek(0,7);
  9557. this.setupScroll(buffer);
  9558. buffer.pos=savedPos;
  9559. }
  9560. else
  9561. this.setupOverflow(overflow);
  9562. if (buffer.readBool())
  9563. buffer.skip(8);
  9564. this._buildingDisplayList=true;
  9565. buffer.seek(0,1);
  9566. var controllerCount=buffer.getInt16();
  9567. for (i=0;i < controllerCount;i++){
  9568. nextPos=buffer.getInt16();
  9569. nextPos+=buffer.pos;
  9570. var controller=new Controller();
  9571. this._controllers.push(controller);
  9572. controller.parent=this;
  9573. controller.setup(buffer);
  9574. buffer.pos=nextPos;
  9575. }
  9576. buffer.seek(0,2);
  9577. var child;
  9578. var childCount=buffer.getInt16();
  9579. for (i=0;i < childCount;i++){
  9580. dataLen=buffer.getInt16();
  9581. curPos=buffer.pos;
  9582. if (objectPool !=null)
  9583. child=objectPool[poolIndex+i];
  9584. else{
  9585. buffer.seek(curPos,0);
  9586. var type=buffer.readByte();
  9587. var src=buffer.readS();
  9588. var pkgId=buffer.readS();
  9589. var pi=null;
  9590. if (src !=null){
  9591. var pkg;
  9592. if (pkgId !=null)
  9593. pkg=UIPackage.getById(pkgId);
  9594. else
  9595. pkg=this.packageItem.owner;
  9596. pi=pkg !=null ? pkg.getItemById(src):null;
  9597. }
  9598. if (pi !=null){
  9599. child=UIObjectFactory.newObject(pi);
  9600. child.packageItem=pi;
  9601. child.constructFromResource();
  9602. }
  9603. else
  9604. child=UIObjectFactory.newObject2(type);
  9605. }
  9606. child._underConstruct=true;
  9607. child.setup_beforeAdd(buffer,curPos);
  9608. child.parent=this;
  9609. this._children.push(child);
  9610. buffer.pos=curPos+dataLen;
  9611. }
  9612. buffer.seek(0,3);
  9613. this.relations.setup(buffer,true);
  9614. buffer.seek(0,2);
  9615. buffer.skip(2);
  9616. for (i=0;i < childCount;i++){
  9617. nextPos=buffer.getInt16();
  9618. nextPos+=buffer.pos;
  9619. buffer.seek(buffer.pos,3);
  9620. this._children[i].relations.setup(buffer,false);
  9621. buffer.pos=nextPos;
  9622. }
  9623. buffer.seek(0,2);
  9624. buffer.skip(2);
  9625. for (i=0;i < childCount;i++){
  9626. nextPos=buffer.getInt16();
  9627. nextPos+=buffer.pos;
  9628. child=this._children[i];
  9629. child.setup_afterAdd(buffer,buffer.pos);
  9630. child._underConstruct=false;
  9631. buffer.pos=nextPos;
  9632. }
  9633. buffer.seek(0,4);
  9634. buffer.skip(2);
  9635. this.opaque=buffer.readBool();
  9636. var maskId=buffer.getInt16();
  9637. if (maskId !=-1){
  9638. this.setMask(this.getChildAt(maskId).displayObject,buffer.readBool());
  9639. };
  9640. var hitTestId=buffer.readS();
  9641. if (hitTestId !=null){
  9642. pi=this.packageItem.owner.getItemById(hitTestId);
  9643. if (pi !=null && pi.pixelHitTestData !=null){
  9644. i1=buffer.getInt32();
  9645. i2=buffer.getInt32();
  9646. this._displayObject.hitArea=new PixelHitTest(pi.pixelHitTestData,i1,i2);
  9647. this._displayObject.mouseThrough=false;
  9648. this._displayObject.hitTestPrior=true;
  9649. }
  9650. }
  9651. buffer.seek(0,5);
  9652. var transitionCount=buffer.getInt16();
  9653. for (i=0;i < transitionCount;i++){
  9654. nextPos=buffer.getInt16();
  9655. nextPos+=buffer.pos;
  9656. var trans=new Transition(this);
  9657. trans.setup(buffer);
  9658. this._transitions.push(trans);
  9659. buffer.pos=nextPos;
  9660. }
  9661. if (this._transitions.length > 0){
  9662. this.displayObject.on("display",this,this.___added);
  9663. this.displayObject.on("undisplay",this,this.___removed);
  9664. }
  9665. this.applyAllControllers();
  9666. this._buildingDisplayList=false;
  9667. this._underConstruct=false;
  9668. this.buildNativeDisplayList();
  9669. this.setBoundsChangedFlag();
  9670. if (this.packageItem.objectType !=9)
  9671. this.constructExtension(buffer);
  9672. this.constructFromXML(null);
  9673. }
  9674. __proto.constructExtension=function(buffer){}
  9675. __proto.constructFromXML=function(xml){}
  9676. __proto.setup_afterAdd=function(buffer,beginPos){
  9677. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  9678. buffer.seek(beginPos,4);
  9679. var pageController=buffer.getInt16();
  9680. if (pageController !=-1 && this._scrollPane !=null)
  9681. this._scrollPane.pageController=this._parent.getControllerAt(pageController);
  9682. var cnt=buffer.getInt16();
  9683. for (var i=0;i < cnt;i++){
  9684. var cc=this.getController(buffer.readS());
  9685. var pageId=buffer.readS();
  9686. if(cc)
  9687. cc.selectedPageId=pageId;
  9688. }
  9689. }
  9690. __proto.___added=function(){
  9691. var cnt=this._transitions.length;
  9692. for(var i=0;i < cnt;++i){
  9693. this._transitions[i].onOwnerAddedToStage();
  9694. }
  9695. }
  9696. __proto.___removed=function(){
  9697. var cnt=this._transitions.length;
  9698. for(var i=0;i < cnt;++i){
  9699. this._transitions[i].onOwnerRemovedFromStage();
  9700. }
  9701. }
  9702. __getset(0,__proto,'numChildren',function(){
  9703. return this._children.length;
  9704. });
  9705. __getset(0,__proto,'displayListContainer',function(){
  9706. return this._container;
  9707. });
  9708. /**
  9709. *@see ChildrenRenderOrder
  9710. */
  9711. /**
  9712. *@see ChildrenRenderOrder
  9713. */
  9714. __getset(0,__proto,'childrenRenderOrder',function(){
  9715. return this._childrenRenderOrder;
  9716. },function(value){
  9717. if (this._childrenRenderOrder !=value){
  9718. this._childrenRenderOrder=value;
  9719. this.buildNativeDisplayList();
  9720. }
  9721. });
  9722. __getset(0,__proto,'opaque',function(){
  9723. return this._opaque;
  9724. },function(value){
  9725. if(this._opaque!=value){
  9726. this._opaque=value;
  9727. if (this._opaque){
  9728. if(this._displayObject.hitArea==null)
  9729. this._displayObject.hitArea=new Rectangle();
  9730. if((this._displayObject.hitArea instanceof laya.maths.Rectangle ))
  9731. this._displayObject.hitArea.setTo(0,0,this.width,this.height);
  9732. this._displayObject.mouseThrough=false;
  9733. }
  9734. else {
  9735. if((this._displayObject.hitArea instanceof laya.maths.Rectangle ))
  9736. this._displayObject.hitArea=null;
  9737. this._displayObject.mouseThrough=true;
  9738. }
  9739. }
  9740. });
  9741. __getset(0,__proto,'controllers',function(){
  9742. return this._controllers;
  9743. });
  9744. __getset(0,__proto,'scrollPane',function(){
  9745. return this._scrollPane;
  9746. });
  9747. __getset(0,__proto,'margin',function(){
  9748. return this._margin;
  9749. },function(value){
  9750. this._margin.copy(value);
  9751. if(this._displayObject.scrollRect!=null){
  9752. this._container.pos(this._margin.left+this._alignOffset.x,this._margin.top+this._alignOffset.y);
  9753. }
  9754. this.handleSizeChanged();
  9755. });
  9756. __getset(0,__proto,'apexIndex',function(){
  9757. return this._apexIndex;
  9758. },function(value){
  9759. if (this._apexIndex !=value){
  9760. this._apexIndex=value;
  9761. if (this._childrenRenderOrder==2)
  9762. this.buildNativeDisplayList();
  9763. }
  9764. });
  9765. __getset(0,__proto,'mask',function(){
  9766. return this._mask;
  9767. },function(value){
  9768. this.setMask(value,false);
  9769. });
  9770. __getset(0,__proto,'viewHeight',function(){
  9771. if (this._scrollPane !=null)
  9772. return this._scrollPane.viewHeight;
  9773. else
  9774. return this.height-this._margin.top-this._margin.bottom;
  9775. },function(value){
  9776. if (this._scrollPane !=null)
  9777. this._scrollPane.viewHeight=value;
  9778. else
  9779. this.height=value+this._margin.top+this._margin.bottom;
  9780. });
  9781. __getset(0,__proto,'baseUserData',function(){
  9782. var buffer=this.packageItem.rawData;
  9783. buffer.seek(0,4);
  9784. return buffer.readS();
  9785. });
  9786. __getset(0,__proto,'viewWidth',function(){
  9787. if (this._scrollPane !=null)
  9788. return this._scrollPane.viewWidth;
  9789. else
  9790. return this.width-this._margin.left-this._margin.right;
  9791. },function(value){
  9792. if (this._scrollPane !=null)
  9793. this._scrollPane.viewWidth=value;
  9794. else
  9795. this.width=value+this._margin.left+this._margin.right;
  9796. });
  9797. return GComponent;
  9798. })(GObject)
  9799. //class fairygui.gears.GearAnimation extends fairygui.gears.GearBase
  9800. var GearAnimation=(function(_super){
  9801. var GearAnimationValue;
  9802. function GearAnimation(owner){
  9803. this._storage=null;
  9804. this._default=null;
  9805. GearAnimation.__super.call(this,owner);
  9806. }
  9807. __class(GearAnimation,'fairygui.gears.GearAnimation',_super);
  9808. var __proto=GearAnimation.prototype;
  9809. __proto.init=function(){
  9810. this._default=new GearAnimationValue((this._owner).playing,
  9811. (this._owner).frame);
  9812. this._storage={};
  9813. }
  9814. __proto.addStatus=function(pageId,buffer){
  9815. var gv;
  9816. if (pageId==null)
  9817. gv=this._default;
  9818. else {
  9819. gv=new GearAnimationValue();
  9820. this._storage[pageId]=gv;
  9821. }
  9822. gv.playing=buffer.readBool();
  9823. gv.frame=buffer.getInt32();
  9824. }
  9825. __proto.apply=function(){
  9826. this._owner._gearLocked=true;
  9827. var gv=this._storage[this._controller.selectedPageId];
  9828. if (!gv)
  9829. gv=this._default;
  9830. (this._owner).frame=gv.frame;
  9831. (this._owner).playing=gv.playing;
  9832. this._owner._gearLocked=false;
  9833. }
  9834. __proto.updateState=function(){
  9835. var mc=(this._owner);
  9836. var gv=this._storage[this._controller.selectedPageId];
  9837. if(!gv){
  9838. gv=new GearAnimationValue();
  9839. this._storage[this._controller.selectedPageId]=gv;
  9840. }
  9841. gv.frame=mc.frame;
  9842. gv.playing=mc.playing;
  9843. }
  9844. GearAnimation.__init$=function(){
  9845. //class GearAnimationValue
  9846. GearAnimationValue=(function(){
  9847. function GearAnimationValue(playing,frame){
  9848. this.playing=false;
  9849. this.frame=NaN;
  9850. (playing===void 0)&& (playing=true);
  9851. (frame===void 0)&& (frame=0);
  9852. this.playing=playing;
  9853. this.frame=frame;
  9854. }
  9855. __class(GearAnimationValue,'');
  9856. return GearAnimationValue;
  9857. })()
  9858. }
  9859. return GearAnimation;
  9860. })(GearBase)
  9861. //class fairygui.gears.GearColor extends fairygui.gears.GearBase
  9862. var GearColor=(function(_super){
  9863. var GearColorValue;
  9864. function GearColor(owner){
  9865. this._storage=null;
  9866. this._default=null;
  9867. GearColor.__super.call(this,owner);
  9868. }
  9869. __class(GearColor,'fairygui.gears.GearColor',_super);
  9870. var __proto=GearColor.prototype;
  9871. __proto.init=function(){
  9872. if(this._owner["strokeColor"]!=undefined)
  9873. this._default=new GearColorValue(this._owner["color"],this._owner["strokeColor"]);
  9874. else
  9875. this._default=new GearColorValue(this._owner["color"],null);
  9876. this._storage={};
  9877. }
  9878. __proto.addStatus=function(pageId,buffer){
  9879. var gv;
  9880. if (pageId==null)
  9881. gv=this._default;
  9882. else {
  9883. gv=new GearColorValue();
  9884. this._storage[pageId]=gv;
  9885. }
  9886. gv.color=buffer.readColorS();
  9887. gv.strokeColor=buffer.readColorS();
  9888. }
  9889. __proto.apply=function(){
  9890. this._owner._gearLocked=true;
  9891. var gv=this._storage[this._controller.selectedPageId];
  9892. if(!gv)
  9893. gv=this._default;
  9894. (this._owner).color=gv.color;
  9895. if(this._owner["strokeColor"]!=undefined && gv.strokeColor!=null)
  9896. this._owner["strokeColor"]=gv.strokeColor;
  9897. this._owner._gearLocked=false;
  9898. }
  9899. __proto.updateState=function(){
  9900. var gv=this._storage[this._controller.selectedPageId];
  9901. if(!gv){
  9902. gv=new GearColorValue(null,null);
  9903. this._storage[this._controller.selectedPageId]=gv;
  9904. }
  9905. gv.color=(this._owner).color;
  9906. if(this._owner["strokeColor"]!=undefined)
  9907. gv.strokeColor=this._owner["strokeColor"];
  9908. }
  9909. GearColor.__init$=function(){
  9910. //class GearColorValue
  9911. GearColorValue=(function(){
  9912. function GearColorValue(color,strokeColor){
  9913. this.color=null;
  9914. this.strokeColor=null;
  9915. this.color=color;
  9916. this.strokeColor=strokeColor;
  9917. }
  9918. __class(GearColorValue,'');
  9919. return GearColorValue;
  9920. })()
  9921. }
  9922. return GearColor;
  9923. })(GearBase)
  9924. //class fairygui.gears.GearDisplay extends fairygui.gears.GearBase
  9925. var GearDisplay=(function(_super){
  9926. function GearDisplay(owner){
  9927. this.pages=null;
  9928. this._visible=0;
  9929. this._displayLockToken=0;
  9930. GearDisplay.__super.call(this,owner);
  9931. this._displayLockToken=1;
  9932. }
  9933. __class(GearDisplay,'fairygui.gears.GearDisplay',_super);
  9934. var __proto=GearDisplay.prototype;
  9935. __proto.init=function(){
  9936. this.pages=null;
  9937. }
  9938. __proto.addLock=function(){
  9939. this._visible++;
  9940. return this._displayLockToken;
  9941. }
  9942. __proto.releaseLock=function(token){
  9943. if(token==this._displayLockToken)
  9944. this._visible--;
  9945. }
  9946. __proto.apply=function(){
  9947. this._displayLockToken++;
  9948. if(this._displayLockToken<=0)
  9949. this._displayLockToken=1;
  9950. if(this.pages==null || this.pages.length==0
  9951. || this.pages.indexOf(this._controller.selectedPageId)!=-1)
  9952. this._visible=1;
  9953. else
  9954. this._visible=0;
  9955. }
  9956. __getset(0,__proto,'connected',function(){
  9957. return this._controller==null || this._visible>0;
  9958. });
  9959. return GearDisplay;
  9960. })(GearBase)
  9961. //class fairygui.gears.GearIcon extends fairygui.gears.GearBase
  9962. var GearIcon=(function(_super){
  9963. function GearIcon(owner){
  9964. this._storage=null;
  9965. this._default=null;
  9966. GearIcon.__super.call(this,owner);
  9967. }
  9968. __class(GearIcon,'fairygui.gears.GearIcon',_super);
  9969. var __proto=GearIcon.prototype;
  9970. __proto.init=function(){
  9971. this._default=this._owner.icon;
  9972. this._storage={};
  9973. }
  9974. __proto.addStatus=function(pageId,buffer){
  9975. if(pageId==null)
  9976. this._default=buffer.readS();
  9977. else
  9978. this._storage[pageId]=buffer.readS();
  9979. }
  9980. __proto.apply=function(){
  9981. this._owner._gearLocked=true;
  9982. var data=this._storage[this._controller.selectedPageId];
  9983. if(data!==undefined)
  9984. this._owner.icon=data;
  9985. else
  9986. this._owner.icon=this._default;
  9987. this._owner._gearLocked=false;
  9988. }
  9989. __proto.updateState=function(){
  9990. this._storage[this._controller.selectedPageId]=this._owner.icon;
  9991. }
  9992. return GearIcon;
  9993. })(GearBase)
  9994. //class fairygui.gears.GearLook extends fairygui.gears.GearBase
  9995. var GearLook=(function(_super){
  9996. var GearLookValue;
  9997. function GearLook(owner){
  9998. this._storage=null;
  9999. this._default=null;
  10000. GearLook.__super.call(this,owner);
  10001. }
  10002. __class(GearLook,'fairygui.gears.GearLook',_super);
  10003. var __proto=GearLook.prototype;
  10004. __proto.init=function(){
  10005. this._default=new GearLookValue(this._owner.alpha,this._owner.rotation,this._owner.grayed,this._owner.touchable);
  10006. this._storage={};
  10007. }
  10008. __proto.addStatus=function(pageId,buffer){
  10009. var gv;
  10010. if (pageId==null)
  10011. gv=this._default;
  10012. else {
  10013. gv=new GearLookValue();
  10014. this._storage[pageId]=gv;
  10015. }
  10016. gv.alpha=buffer.getFloat32();
  10017. gv.rotation=buffer.getFloat32();
  10018. gv.grayed=buffer.readBool();
  10019. gv.touchable=buffer.readBool();
  10020. }
  10021. __proto.apply=function(){
  10022. var gv=this._storage[this._controller.selectedPageId];
  10023. if(!gv)
  10024. gv=this._default;
  10025. if(this._tweenConfig!=null && this._tweenConfig.tween && !UIPackage._constructing && !GearBase.disableAllTweenEffect){
  10026. this._owner._gearLocked=true;
  10027. this._owner.grayed=gv.grayed;
  10028. this._owner.touchable=gv.touchable;
  10029. this._owner._gearLocked=false;
  10030. if (this._tweenConfig._tweener !=null){
  10031. if (this._tweenConfig._tweener.endValue.x !=gv.alpha || this._tweenConfig._tweener.endValue.y !=gv.rotation){
  10032. this._tweenConfig._tweener.kill(true);
  10033. this._tweenConfig._tweener=null;
  10034. }
  10035. else
  10036. return;
  10037. };
  10038. var a=gv.alpha!=this._owner.alpha;
  10039. var b=gv.rotation!=this._owner.rotation;
  10040. if(a || b){
  10041. if(this._owner.checkGearController(0,this._controller))
  10042. this._tweenConfig._displayLockToken=this._owner.addDisplayLock();
  10043. this._tweenConfig._tweener=GTween.to2(this._owner.alpha,this._owner.rotation,gv.alpha,gv.rotation,this._tweenConfig.duration)
  10044. .setDelay(this._tweenConfig.delay)
  10045. .setEase(this._tweenConfig.easeType)
  10046. .setUserData((a ? 1 :0)+(b ? 2 :0))
  10047. .setTarget(this)
  10048. .onUpdate(this.__tweenUpdate,this)
  10049. .onComplete(this.__tweenComplete,this);
  10050. }
  10051. }
  10052. else {
  10053. this._owner._gearLocked=true;
  10054. this._owner.grayed=gv.grayed;
  10055. this._owner.alpha=gv.alpha;
  10056. this._owner.rotation=gv.rotation;
  10057. this._owner.touchable=gv.touchable;
  10058. this._owner._gearLocked=false;
  10059. }
  10060. }
  10061. __proto.__tweenUpdate=function(tweener){
  10062. var flag=tweener.userData;
  10063. this._owner._gearLocked=true;
  10064. if ((flag & 1)!=0)
  10065. this._owner.alpha=tweener.value.x;
  10066. if ((flag & 2)!=0)
  10067. this._owner.rotation=tweener.value.y;
  10068. this._owner._gearLocked=false;
  10069. }
  10070. __proto.__tweenComplete=function(){
  10071. if(this._tweenConfig._displayLockToken!=0){
  10072. this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken);
  10073. this._tweenConfig._displayLockToken=0;
  10074. }
  10075. this._tweenConfig._tweener=null;
  10076. }
  10077. __proto.updateState=function(){
  10078. var gv=this._storage[this._controller.selectedPageId];
  10079. if(!gv){
  10080. gv=new GearLookValue();
  10081. this._storage[this._controller.selectedPageId]=gv;
  10082. }
  10083. gv.alpha=this._owner.alpha;
  10084. gv.rotation=this._owner.rotation;
  10085. gv.grayed=this._owner.grayed;
  10086. gv.touchable=this._owner.touchable;
  10087. }
  10088. GearLook.__init$=function(){
  10089. //class GearLookValue
  10090. GearLookValue=(function(){
  10091. function GearLookValue(alpha,rotation,grayed,touchable){
  10092. this.alpha=NaN;
  10093. this.rotation=NaN;
  10094. this.grayed=false;
  10095. this.touchable=false;
  10096. (alpha===void 0)&& (alpha=0);
  10097. (rotation===void 0)&& (rotation=0);
  10098. (grayed===void 0)&& (grayed=false);
  10099. (touchable===void 0)&& (touchable=true);
  10100. this.alpha=alpha;
  10101. this.rotation=rotation;
  10102. this.grayed=grayed;
  10103. this.touchable=touchable;
  10104. }
  10105. __class(GearLookValue,'');
  10106. return GearLookValue;
  10107. })()
  10108. }
  10109. return GearLook;
  10110. })(GearBase)
  10111. //class fairygui.gears.GearSize extends fairygui.gears.GearBase
  10112. var GearSize=(function(_super){
  10113. var GearSizeValue;
  10114. function GearSize(owner){
  10115. this._storage=null;
  10116. this._default=null;
  10117. GearSize.__super.call(this,owner);
  10118. }
  10119. __class(GearSize,'fairygui.gears.GearSize',_super);
  10120. var __proto=GearSize.prototype;
  10121. __proto.init=function(){
  10122. this._default=new GearSizeValue(this._owner.width,this._owner.height,
  10123. this._owner.scaleX,this._owner.scaleY);
  10124. this._storage={};
  10125. }
  10126. __proto.addStatus=function(pageId,buffer){
  10127. var gv;
  10128. if (pageId==null)
  10129. gv=this._default;
  10130. else {
  10131. gv=new GearSizeValue();
  10132. this._storage[pageId]=gv;
  10133. }
  10134. gv.width=buffer.getInt32();
  10135. gv.height=buffer.getInt32();
  10136. gv.scaleX=buffer.getFloat32();
  10137. gv.scaleY=buffer.getFloat32();
  10138. }
  10139. __proto.apply=function(){
  10140. var gv=this._storage[this._controller.selectedPageId];
  10141. if (!gv)
  10142. gv=this._default;
  10143. if(this._tweenConfig!=null && this._tweenConfig.tween && !UIPackage._constructing && !GearBase.disableAllTweenEffect){
  10144. if (this._tweenConfig._tweener !=null){
  10145. if (this._tweenConfig._tweener.endValue.x !=gv.width || this._tweenConfig._tweener.endValue.y !=gv.height
  10146. || this._tweenConfig._tweener.endValue.z !=gv.scaleX || this._tweenConfig._tweener.endValue.w !=gv.scaleY){
  10147. this._tweenConfig._tweener.kill(true);
  10148. this._tweenConfig._tweener=null;
  10149. }
  10150. else
  10151. return;
  10152. };
  10153. var a=gv.width !=this._owner.width || gv.height !=this._owner.height;
  10154. var b=gv.scaleX !=this._owner.scaleX || gv.scaleY !=this._owner.scaleY;
  10155. if(a || b){
  10156. if(this._owner.checkGearController(0,this._controller))
  10157. this._tweenConfig._displayLockToken=this._owner.addDisplayLock();
  10158. 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)
  10159. .setDelay(this._tweenConfig.delay)
  10160. .setEase(this._tweenConfig.easeType)
  10161. .setUserData((a ? 1 :0)+(b ? 2 :0))
  10162. .setTarget(this)
  10163. .onUpdate(this.__tweenUpdate,this)
  10164. .onComplete(this.__tweenComplete,this);
  10165. }
  10166. }
  10167. else {
  10168. this._owner._gearLocked=true;
  10169. this._owner.setSize(gv.width,gv.height,this._owner.checkGearController(1,this._controller));
  10170. this._owner.setScale(gv.scaleX,gv.scaleY);
  10171. this._owner._gearLocked=false;
  10172. }
  10173. }
  10174. __proto.__tweenUpdate=function(tweener){
  10175. var flag=tweener.userData;
  10176. this._owner._gearLocked=true;
  10177. if ((flag & 1)!=0)
  10178. this._owner.setSize(tweener.value.x,tweener.value.y,this._owner.checkGearController(1,this._controller));
  10179. if ((flag & 2)!=0)
  10180. this._owner.setScale(tweener.value.z,tweener.value.w);
  10181. this._owner._gearLocked=false;
  10182. }
  10183. __proto.__tweenComplete=function(){
  10184. if(this._tweenConfig._displayLockToken!=0){
  10185. this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken);
  10186. this._tweenConfig._displayLockToken=0;
  10187. }
  10188. this._tweenConfig._tweener=null;
  10189. }
  10190. __proto.updateState=function(){
  10191. var gv=this._storage[this._controller.selectedPageId];
  10192. if(!gv){
  10193. gv=new GearSizeValue();
  10194. this._storage[this._controller.selectedPageId]=gv;
  10195. }
  10196. gv.width=this._owner.width;
  10197. gv.height=this._owner.height;
  10198. gv.scaleX=this._owner.scaleX;
  10199. gv.scaleY=this._owner.scaleY;
  10200. }
  10201. __proto.updateFromRelations=function(dx,dy){
  10202. if(this._controller==null || this._storage==null)
  10203. return;
  10204. for(var key in this._storage){
  10205. var gv=this._storage[key];
  10206. gv.width+=dx;
  10207. gv.height+=dy;
  10208. }
  10209. this._default.width+=dx;
  10210. this._default.height+=dy;
  10211. this.updateState();
  10212. }
  10213. GearSize.__init$=function(){
  10214. //class GearSizeValue
  10215. GearSizeValue=(function(){
  10216. function GearSizeValue(width,height,scaleX,scaleY){
  10217. this.width=NaN;
  10218. this.height=NaN;
  10219. this.scaleX=NaN;
  10220. this.scaleY=NaN;
  10221. (width===void 0)&& (width=0);
  10222. (height===void 0)&& (height=0);
  10223. (scaleX===void 0)&& (scaleX=0);
  10224. (scaleY===void 0)&& (scaleY=0);
  10225. this.width=width;
  10226. this.height=height;
  10227. this.scaleX=scaleX;
  10228. this.scaleY=scaleY;
  10229. }
  10230. __class(GearSizeValue,'');
  10231. return GearSizeValue;
  10232. })()
  10233. }
  10234. return GearSize;
  10235. })(GearBase)
  10236. //class fairygui.GGraph extends fairygui.GObject
  10237. var GGraph=(function(_super){
  10238. function GGraph(){
  10239. this._type=0;
  10240. this._lineSize=NaN;
  10241. this._lineColor=null;
  10242. this._fillColor=null;
  10243. this._cornerRadius=null;
  10244. this._hitArea=null;
  10245. GGraph.__super.call(this);
  10246. this._type=0;
  10247. this._lineSize=1;
  10248. this._lineColor="#000000"
  10249. this._fillColor="#FFFFFF";
  10250. this._cornerRadius=null;
  10251. }
  10252. __class(GGraph,'fairygui.GGraph',_super);
  10253. var __proto=GGraph.prototype;
  10254. Laya.imps(__proto,{"fairygui.gears.IColorGear":true})
  10255. __proto.drawRect=function(lineSize,lineColor,fillColor,cornerRadius){
  10256. this._type=1;
  10257. this._lineSize=lineSize;
  10258. this._lineColor=lineColor;
  10259. this._fillColor=fillColor;
  10260. this._cornerRadius=cornerRadius;
  10261. this.drawCommon();
  10262. }
  10263. __proto.drawEllipse=function(lineSize,lineColor,fillColor){
  10264. this._type=2;
  10265. this._lineSize=lineSize;
  10266. this._lineColor=lineColor;
  10267. this._fillColor=fillColor;
  10268. this.drawCommon();
  10269. }
  10270. __proto.drawCommon=function(){
  10271. this._displayObject.mouseEnabled=this.touchable;
  10272. var gr=this._displayObject.graphics;
  10273. gr.clear();
  10274. var w=this.width;
  10275. var h=this.height;
  10276. if(w==0 || h==0)
  10277. return;
  10278. var fillColor=this._fillColor;
  10279. var lineColor=this._lineColor;
  10280. if(Render.isWebGL && ToolSet.startsWith(fillColor,"rgba")){
  10281. var arr=fillColor.substring(5,fillColor.lastIndexOf(")")).split(",");
  10282. var a=parseFloat(arr[3]);
  10283. if(a==0)
  10284. fillColor=null;
  10285. else {
  10286. fillColor=Utils.toHexColor((parseInt(arr[0])<<16)+(parseInt(arr[1])<<8)+parseInt(arr[2]));
  10287. this.alpha=a;
  10288. }
  10289. }
  10290. if (this._type==1){
  10291. if(this._cornerRadius!=null){
  10292. var paths=[
  10293. ["moveTo",this._cornerRadius[0],0],
  10294. ["lineTo",w-this._cornerRadius[1],0],
  10295. ["arcTo",w,0,w,this._cornerRadius[1],this._cornerRadius[1]],
  10296. ["lineTo",w,h-this._cornerRadius[3]],
  10297. ["arcTo",w,h,w-this._cornerRadius[3],h,this._cornerRadius[3]],
  10298. ["lineTo",this._cornerRadius[2],h],
  10299. ["arcTo",0,h,0,h-this._cornerRadius[2],this._cornerRadius[2]],
  10300. ["lineTo",0,this._cornerRadius[0]],
  10301. ["arcTo",0,0,this._cornerRadius[0],0,this._cornerRadius[0]],
  10302. ["closePath"]];
  10303. gr.drawPath(0,0,paths,{fillStyle:fillColor},this._lineSize>0?{strokeStyle:lineColor,lineWidth:this._lineSize}:null);
  10304. }
  10305. else
  10306. gr.drawRect(0,0,w,h,fillColor,this._lineSize>0?lineColor:null,this._lineSize);
  10307. }else{
  10308. gr.drawCircle(w/2,h/2,w/2,fillColor,this._lineSize>0?lineColor:null,this._lineSize);
  10309. }
  10310. this._displayObject.repaint();
  10311. }
  10312. __proto.replaceMe=function(target){
  10313. if (!this._parent)
  10314. throw "parent not set";
  10315. target.name=this.name;
  10316. target.alpha=this.alpha;
  10317. target.rotation=this.rotation;
  10318. target.visible=this.visible;
  10319. target.touchable=this.touchable;
  10320. target.grayed=this.grayed;
  10321. target.setXY(this.x,this.y);
  10322. target.setSize(this.width,this.height);
  10323. var index=this._parent.getChildIndex(this);
  10324. this._parent.addChildAt(target,index);
  10325. target.relations.copyFrom(this.relations);
  10326. this._parent.removeChild(this,true);
  10327. }
  10328. __proto.addBeforeMe=function(target){
  10329. if (this._parent==null)
  10330. throw "parent not set";
  10331. var index=this._parent.getChildIndex(this);
  10332. this._parent.addChildAt(target,index);
  10333. }
  10334. __proto.addAfterMe=function(target){
  10335. if (this._parent==null)
  10336. throw "parent not set";
  10337. var index=this._parent.getChildIndex(this);
  10338. index++;
  10339. this._parent.addChildAt(target,index);
  10340. }
  10341. __proto.setNativeObject=function(obj){
  10342. this._type=0;
  10343. this._displayObject.mouseEnabled=this.touchable;
  10344. this._displayObject.graphics.clear();
  10345. this._displayObject.addChild(obj);
  10346. }
  10347. __proto.createDisplayObject=function(){
  10348. _super.prototype.createDisplayObject.call(this);
  10349. this._displayObject.mouseEnabled=false;
  10350. this._hitArea=new HitArea();
  10351. this._hitArea.hit=this._displayObject.graphics;
  10352. this._displayObject.hitArea=this._hitArea;
  10353. }
  10354. __proto.handleSizeChanged=function(){
  10355. _super.prototype.handleSizeChanged.call(this);
  10356. if(this._type !=0)
  10357. this.drawCommon();
  10358. }
  10359. __proto.setup_beforeAdd=function(buffer,beginPos){
  10360. _super.prototype.setup_beforeAdd.call(this,buffer,beginPos);
  10361. buffer.seek(beginPos,5);
  10362. this._type=buffer.readByte();
  10363. if (this._type!=0){
  10364. this._lineSize=buffer.getInt32();
  10365. this._lineColor=buffer.readColorS(true);
  10366. this._fillColor=buffer.readColorS(true);
  10367. if (buffer.readBool()){
  10368. this._cornerRadius=[];
  10369. for (var i=0;i < 4;i++)
  10370. this._cornerRadius[i]=buffer.getFloat32();
  10371. }
  10372. this.drawCommon();
  10373. }
  10374. }
  10375. __getset(0,__proto,'color',function(){
  10376. return this._fillColor;
  10377. },function(value){
  10378. this._fillColor=value;
  10379. if(this._type!=0)
  10380. this.drawCommon();
  10381. });
  10382. return GGraph;
  10383. })(GObject)
  10384. //class fairygui.gears.GearText extends fairygui.gears.GearBase
  10385. var GearText=(function(_super){
  10386. function GearText(owner){
  10387. this._storage=null;
  10388. this._default=null;
  10389. GearText.__super.call(this,owner);
  10390. }
  10391. __class(GearText,'fairygui.gears.GearText',_super);
  10392. var __proto=GearText.prototype;
  10393. __proto.init=function(){
  10394. this._default=this._owner.text;
  10395. this._storage={};
  10396. }
  10397. __proto.addStatus=function(pageId,buffer){
  10398. if(pageId==null)
  10399. this._default=buffer.readS();
  10400. else
  10401. this._storage[pageId]=buffer.readS();
  10402. }
  10403. __proto.apply=function(){
  10404. this._owner._gearLocked=true;
  10405. var data=this._storage[this._controller.selectedPageId];
  10406. if(data!==undefined)
  10407. this._owner.text=data;
  10408. else
  10409. this._owner.text=this._default;
  10410. this._owner._gearLocked=false;
  10411. }
  10412. __proto.updateState=function(){
  10413. this._storage[this._controller.selectedPageId]=this._owner.text;
  10414. }
  10415. return GearText;
  10416. })(GearBase)
  10417. //class fairygui.GGroup extends fairygui.GObject
  10418. var GGroup=(function(_super){
  10419. function GGroup(){
  10420. this._layout=0;
  10421. this._lineGap=0;
  10422. this._columnGap=0;
  10423. this._percentReady=false;
  10424. this._boundsChanged=false;
  10425. this._updating=0;
  10426. GGroup.__super.call(this);
  10427. }
  10428. __class(GGroup,'fairygui.GGroup',_super);
  10429. var __proto=GGroup.prototype;
  10430. __proto.setBoundsChangedFlag=function(childSizeChanged){
  10431. (childSizeChanged===void 0)&& (childSizeChanged=false);
  10432. if (this._updating==0 && this.parent !=null){
  10433. if (childSizeChanged)
  10434. this._percentReady=false;
  10435. if(!this._boundsChanged){
  10436. this._boundsChanged=true;
  10437. if(this._layout!=0)
  10438. Laya.timer.callLater(this,this.ensureBoundsCorrect);
  10439. }
  10440. }
  10441. }
  10442. __proto.ensureBoundsCorrect=function(){
  10443. if (this._boundsChanged)
  10444. this.updateBounds();
  10445. }
  10446. __proto.updateBounds=function(){
  10447. Laya.timer.clear(this,this.ensureBoundsCorrect);
  10448. this._boundsChanged=false;
  10449. if (this.parent==null)
  10450. return;
  10451. this.handleLayout();
  10452. var cnt=this._parent.numChildren;
  10453. var i=0;
  10454. var child;
  10455. var ax=Number.POSITIVE_INFINITY,ay=Number.POSITIVE_INFINITY;
  10456. var ar=Number.NEGATIVE_INFINITY,ab=Number.NEGATIVE_INFINITY;
  10457. var tmp=0;
  10458. var empty=true;
  10459. for(i=0;i<cnt;i++){
  10460. child=this._parent.getChildAt(i);
  10461. if(child.group==this){
  10462. tmp=child.x;
  10463. if(tmp<ax)
  10464. ax=tmp;
  10465. tmp=child.y;
  10466. if(tmp<ay)
  10467. ay=tmp;
  10468. tmp=child.x+child.width;
  10469. if(tmp>ar)
  10470. ar=tmp;
  10471. tmp=child.y+child.height;
  10472. if(tmp>ab)
  10473. ab=tmp;
  10474. empty=false;
  10475. }
  10476. }
  10477. if (!empty){
  10478. this._updating=1;
  10479. this.setXY(ax,ay);
  10480. this._updating=2;
  10481. this.setSize(ar-ax,ab-ay);
  10482. }
  10483. else{
  10484. this._updating=2;
  10485. this.setSize(0,0);
  10486. }
  10487. this._updating=0;
  10488. }
  10489. __proto.handleLayout=function(){
  10490. this._updating |=1;
  10491. var child;
  10492. var i=0;
  10493. var cnt=0;
  10494. if (this._layout==1){
  10495. var curX=NaN;
  10496. cnt=this.parent.numChildren;
  10497. for (i=0;i < cnt;i++){
  10498. child=this.parent.getChildAt(i);
  10499. if (child.group !=this)
  10500. continue ;
  10501. if (isNaN(curX))
  10502. curX=Math.floor(child.x);
  10503. else
  10504. child.x=curX;
  10505. if (child.width !=0)
  10506. curX+=Math.floor(child.width+this._columnGap);
  10507. }
  10508. if (!this._percentReady)
  10509. this.updatePercent();
  10510. }
  10511. else if (this._layout==2){
  10512. var curY=NaN;
  10513. cnt=this.parent.numChildren;
  10514. for (i=0;i < cnt;i++){
  10515. child=this.parent.getChildAt(i);
  10516. if (child.group !=this)
  10517. continue ;
  10518. if (isNaN(curY))
  10519. curY=Math.floor(child.y);
  10520. else
  10521. child.y=curY;
  10522. if (child.height !=0)
  10523. curY+=Math.floor(child.height+this._lineGap);
  10524. }
  10525. if (!this._percentReady)
  10526. this.updatePercent();
  10527. }
  10528. this._updating &=2;
  10529. }
  10530. __proto.updatePercent=function(){
  10531. this._percentReady=true;
  10532. var cnt=this.parent.numChildren;
  10533. var i=0;
  10534. var child;
  10535. var size=0;
  10536. if (this._layout==1){
  10537. for (i=0;i < cnt;i++){
  10538. child=this.parent.getChildAt(i);
  10539. if (child.group !=this)
  10540. continue ;
  10541. size+=child.width;
  10542. }
  10543. for (i=0;i < cnt;i++){
  10544. child=this.parent.getChildAt(i);
  10545. if (child.group !=this)
  10546. continue ;
  10547. if (size > 0)
  10548. child._sizePercentInGroup=child.width / size;
  10549. else
  10550. child._sizePercentInGroup=0;
  10551. }
  10552. }
  10553. else{
  10554. for (i=0;i < cnt;i++){
  10555. child=this.parent.getChildAt(i);
  10556. if (child.group !=this)
  10557. continue ;
  10558. size+=child.height;
  10559. }
  10560. for (i=0;i < cnt;i++){
  10561. child=this.parent.getChildAt(i);
  10562. if (child.group !=this)
  10563. continue ;
  10564. if (size > 0)
  10565. child._sizePercentInGroup=child.height / size;
  10566. else
  10567. child._sizePercentInGroup=0;
  10568. }
  10569. }
  10570. }
  10571. __proto.moveChildren=function(dx,dy){
  10572. if ((this._updating & 1)!=0 || this.parent==null)
  10573. return;
  10574. this._updating |=1;
  10575. var cnt=this.parent.numChildren;
  10576. var i=0;
  10577. var child;
  10578. for (i=0;i < cnt;i++){
  10579. child=this.parent.getChildAt(i);
  10580. if (child.group==this){
  10581. child.setXY(child.x+dx,child.y+dy);
  10582. }
  10583. }
  10584. this._updating &=2;
  10585. }
  10586. __proto.resizeChildren=function(dw,dh){
  10587. if (this._layout==0 || (this._updating & 2)!=0 || this.parent==null)
  10588. return;
  10589. this._updating |=2;
  10590. if (!this._percentReady)
  10591. this.updatePercent();
  10592. var cnt=this.parent.numChildren;
  10593. var i=0;
  10594. var j=0;
  10595. var child;
  10596. var last=-1;
  10597. var numChildren=0;
  10598. var lineSize=0;
  10599. var remainSize=0;
  10600. var found=false;
  10601. for (i=0;i < cnt;i++){
  10602. child=this.parent.getChildAt(i);
  10603. if (child.group !=this)
  10604. continue ;
  10605. last=i;
  10606. numChildren++;
  10607. }
  10608. if (this._layout==1){
  10609. remainSize=lineSize=this.width-(numChildren-1)*this._columnGap;
  10610. var curX=NaN;
  10611. var nw=NaN;
  10612. for (i=0;i < cnt;i++){
  10613. child=this.parent.getChildAt(i);
  10614. if (child.group !=this)
  10615. continue ;
  10616. if (isNaN(curX))
  10617. curX=Math.floor(child.x);
  10618. else
  10619. child.x=curX;
  10620. if (last==i)
  10621. nw=remainSize;
  10622. else
  10623. nw=Math.round(child._sizePercentInGroup *lineSize);
  10624. child.setSize(nw,child._rawHeight+dh,true);
  10625. remainSize-=child.width;
  10626. if (last==i){
  10627. if (remainSize >=1){
  10628. for (j=0;j <=i;j++){
  10629. child=this.parent.getChildAt(j);
  10630. if (child.group !=this)
  10631. continue ;
  10632. if (!found){
  10633. nw=child.width+remainSize;
  10634. if ((child.maxWidth==0 || nw < child.maxWidth)
  10635. && (child.minWidth==0 || nw > child.minWidth)){
  10636. child.setSize(nw,child.height,true);
  10637. found=true;
  10638. }
  10639. }
  10640. else
  10641. child.x+=remainSize;
  10642. }
  10643. }
  10644. }
  10645. else
  10646. curX+=(child.width+this._columnGap);
  10647. }
  10648. }
  10649. else if (this._layout==2){
  10650. remainSize=lineSize=this.height-(numChildren-1)*this._lineGap;
  10651. var curY=NaN;
  10652. var nh=NaN;
  10653. for (i=0;i < cnt;i++){
  10654. child=this.parent.getChildAt(i);
  10655. if (child.group !=this)
  10656. continue ;
  10657. if (isNaN(curY))
  10658. curY=Math.floor(child.y);
  10659. else
  10660. child.y=curY;
  10661. if (last==i)
  10662. nh=remainSize;
  10663. else
  10664. nh=Math.round(child._sizePercentInGroup *lineSize);
  10665. child.setSize(child._rawWidth+dw,nh,true);
  10666. remainSize-=child.height;
  10667. if (last==i){
  10668. if (remainSize >=1){
  10669. for (j=0;j <=i;j++){
  10670. child=this.parent.getChildAt(j);
  10671. if (child.group !=this)
  10672. continue ;
  10673. if (!found){
  10674. nh=child.height+remainSize;
  10675. if ((child.maxHeight==0 || nh < child.maxHeight)
  10676. && (child.minHeight==0 || nh > child.minHeight)){
  10677. child.setSize(child.width,nh,true);
  10678. found=true;
  10679. }
  10680. }
  10681. else
  10682. child.y+=remainSize;
  10683. }
  10684. }
  10685. }
  10686. else
  10687. curY+=(child.height+this._lineGap);
  10688. }
  10689. }
  10690. this._updating &=1;
  10691. }
  10692. __proto.handleAlphaChanged=function(){
  10693. if(this._underConstruct||this._parent==null)
  10694. return;
  10695. var cnt=this._parent.numChildren;
  10696. for(var i=0;i<cnt;i++){
  10697. var child=this._parent.getChildAt(i);
  10698. if(child.group==this)
  10699. child.alpha=this.alpha;
  10700. }
  10701. }
  10702. __proto.handleVisibleChanged=function(){
  10703. if(!this._parent)
  10704. return;
  10705. var cnt=this._parent.numChildren;
  10706. for(var i=0;i<cnt;i++){
  10707. var child=this._parent.getChildAt(i);
  10708. if(child.group==this)
  10709. child.handleVisibleChanged();
  10710. }
  10711. }
  10712. __proto.setup_beforeAdd=function(buffer,beginPos){
  10713. _super.prototype.setup_beforeAdd.call(this,buffer,beginPos);
  10714. buffer.seek(beginPos,5);
  10715. this._layout=buffer.readByte();
  10716. this._lineGap=buffer.getInt32();
  10717. this._columnGap=buffer.getInt32();
  10718. }
  10719. __proto.setup_afterAdd=function(buffer,beginPos){
  10720. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  10721. if(!this.visible)
  10722. this.handleVisibleChanged();
  10723. }
  10724. /**
  10725. *@see GroupLayout
  10726. */
  10727. /**
  10728. *@see GroupLayout
  10729. */
  10730. __getset(0,__proto,'layout',function(){
  10731. return this._layout;
  10732. },function(value){
  10733. if(this._layout !=value){
  10734. this._layout=value;
  10735. this.setBoundsChangedFlag(true);
  10736. }
  10737. });
  10738. __getset(0,__proto,'columnGap',function(){
  10739. return this._columnGap;
  10740. },function(value){
  10741. if(this._columnGap !=value){
  10742. this._columnGap=value;
  10743. this.setBoundsChangedFlag();
  10744. }
  10745. });
  10746. __getset(0,__proto,'lineGap',function(){
  10747. return this._lineGap;
  10748. },function(value){
  10749. if(this._lineGap !=value){
  10750. this._lineGap=value;
  10751. this.setBoundsChangedFlag();
  10752. }
  10753. });
  10754. return GGroup;
  10755. })(GObject)
  10756. //class fairygui.GImage extends fairygui.GObject
  10757. var GImage=(function(_super){
  10758. function GImage(){
  10759. this.image=null;
  10760. this._color=null;
  10761. this._flip=0;
  10762. GImage.__super.call(this);
  10763. this._color="#FFFFFF";
  10764. }
  10765. __class(GImage,'fairygui.GImage',_super);
  10766. var __proto=GImage.prototype;
  10767. Laya.imps(__proto,{"fairygui.gears.IColorGear":true})
  10768. __proto.applyColor=function(){}
  10769. __proto.createDisplayObject=function(){
  10770. this._displayObject=this.image=new Image$1();
  10771. this.image.mouseEnabled=false;
  10772. this._displayObject["$owner"]=this;
  10773. }
  10774. __proto.constructFromResource=function(){
  10775. this.packageItem.load();
  10776. this.sourceWidth=this.packageItem.width;
  10777. this.sourceHeight=this.packageItem.height;
  10778. this.initWidth=this.sourceWidth;
  10779. this.initHeight=this.sourceHeight;
  10780. this.image.scale9Grid=this.packageItem.scale9Grid;
  10781. this.image.scaleByTile=this.packageItem.scaleByTile;
  10782. this.image.tileGridIndice=this.packageItem.tileGridIndice;
  10783. this.image.tex=this.packageItem.texture;
  10784. this.setSize(this.sourceWidth,this.sourceHeight);
  10785. }
  10786. __proto.handleXYChanged=function(){
  10787. _super.prototype.handleXYChanged.call(this);
  10788. if(this._flip !=0){
  10789. if(this.scaleX==-1)
  10790. this.image.x+=this.width;
  10791. if(this.scaleY==-1)
  10792. this.image.y+=this.height;
  10793. }
  10794. }
  10795. __proto.handleSizeChanged=function(){
  10796. if(this.image.tex!=null){
  10797. this.image.scaleTexture(this.width/this.sourceWidth,this.height/this.sourceHeight);
  10798. }
  10799. }
  10800. __proto.setup_beforeAdd=function(buffer,beginPos){
  10801. _super.prototype.setup_beforeAdd.call(this,buffer,beginPos);
  10802. buffer.seek(beginPos,5);
  10803. if (buffer.readBool())
  10804. this.color=buffer.readColorS();
  10805. this.flip=buffer.readByte();
  10806. this.image.fillMethod=buffer.readByte();
  10807. if (this.image.fillMethod !=0){
  10808. this.image.fillOrigin=buffer.readByte();
  10809. this.image.fillClockwise=buffer.readBool();
  10810. this.image.fillAmount=buffer.getFloat32();
  10811. }
  10812. }
  10813. __getset(0,__proto,'color',function(){
  10814. return this._color;
  10815. },function(value){
  10816. if(this._color !=value){
  10817. this._color=value;
  10818. this.updateGear(4);
  10819. this.applyColor();
  10820. }
  10821. });
  10822. __getset(0,__proto,'fillClockwise',function(){
  10823. return this.image.fillClockwise;
  10824. },function(value){
  10825. this.image.fillClockwise=value;
  10826. });
  10827. /**
  10828. *@see FlipType
  10829. */
  10830. /**
  10831. *@see FlipType
  10832. */
  10833. __getset(0,__proto,'flip',function(){
  10834. return this._flip;
  10835. },function(value){
  10836. if(this._flip!=value){
  10837. this._flip=value;
  10838. var sx=1,sy=1;
  10839. if(this._flip==1 || this._flip==3)
  10840. sx=-1;
  10841. if(this._flip==2 || this._flip==3)
  10842. sy=-1;
  10843. this.setScale(sx,sy);
  10844. this.handleXYChanged();
  10845. }
  10846. });
  10847. __getset(0,__proto,'fillMethod',function(){
  10848. return this.image.fillMethod;
  10849. },function(value){
  10850. this.image.fillMethod=value;
  10851. });
  10852. __getset(0,__proto,'fillOrigin',function(){
  10853. return this.image.fillOrigin;
  10854. },function(value){
  10855. this.image.fillOrigin=value;
  10856. });
  10857. __getset(0,__proto,'fillAmount',function(){
  10858. return this.image.fillAmount;
  10859. },function(value){
  10860. this.image.fillAmount=value;
  10861. });
  10862. return GImage;
  10863. })(GObject)
  10864. //class fairygui.gears.GearXY extends fairygui.gears.GearBase
  10865. var GearXY=(function(_super){
  10866. function GearXY(owner){
  10867. this._storage=null;
  10868. this._default=null;
  10869. GearXY.__super.call(this,owner);
  10870. }
  10871. __class(GearXY,'fairygui.gears.GearXY',_super);
  10872. var __proto=GearXY.prototype;
  10873. __proto.init=function(){
  10874. this._default=new Point(this._owner.x,this._owner.y);
  10875. this._storage={};
  10876. }
  10877. __proto.addStatus=function(pageId,buffer){
  10878. var gv;
  10879. if (pageId==null)
  10880. gv=this._default;
  10881. else {
  10882. gv=new Point();
  10883. this._storage[pageId]=gv;
  10884. }
  10885. gv.x=buffer.getInt32();
  10886. gv.y=buffer.getInt32();
  10887. }
  10888. __proto.apply=function(){
  10889. var pt=this._storage[this._controller.selectedPageId];
  10890. if (!pt)
  10891. pt=this._default;
  10892. if(this._tweenConfig!=null && this._tweenConfig.tween && !UIPackage._constructing && !GearBase.disableAllTweenEffect){
  10893. if (this._tweenConfig._tweener !=null){
  10894. if (this._tweenConfig._tweener.endValue.x !=pt.x || this._tweenConfig._tweener.endValue.y !=pt.y){
  10895. this._tweenConfig._tweener.kill(true);
  10896. this._tweenConfig._tweener=null;
  10897. }
  10898. else
  10899. return;
  10900. }
  10901. if (this._owner.x !=pt.x || this._owner.y !=pt.y){
  10902. if(this._owner.checkGearController(0,this._controller))
  10903. this._tweenConfig._displayLockToken=this._owner.addDisplayLock();
  10904. this._tweenConfig._tweener=GTween.to2(this._owner.x,this._owner.y,pt.x,pt.y,this._tweenConfig.duration)
  10905. .setDelay(this._tweenConfig.delay)
  10906. .setEase(this._tweenConfig.easeType)
  10907. .setTarget(this)
  10908. .onUpdate(this.__tweenUpdate,this)
  10909. .onComplete(this.__tweenComplete,this);
  10910. }
  10911. }
  10912. else {
  10913. this._owner._gearLocked=true;
  10914. this._owner.setXY(pt.x,pt.y);
  10915. this._owner._gearLocked=false;
  10916. }
  10917. }
  10918. __proto.__tweenUpdate=function(tweener){
  10919. this._owner._gearLocked=true;
  10920. this._owner.setXY(tweener.value.x,tweener.value.y);
  10921. this._owner._gearLocked=false;
  10922. }
  10923. __proto.__tweenComplete=function(){
  10924. if(this._tweenConfig._displayLockToken!=0){
  10925. this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken);
  10926. this._tweenConfig._displayLockToken=0;
  10927. }
  10928. this._tweenConfig._tweener=null;
  10929. }
  10930. __proto.updateState=function(){
  10931. var pt=this._storage[this._controller.selectedPageId];
  10932. if(!pt){
  10933. pt=new Point();
  10934. this._storage[this._controller.selectedPageId]=pt;
  10935. }
  10936. pt.x=this._owner.x;
  10937. pt.y=this._owner.y;
  10938. }
  10939. __proto.updateFromRelations=function(dx,dy){
  10940. if(this._controller==null || this._storage==null)
  10941. return;
  10942. for (var key in this._storage){
  10943. var pt=this._storage[key];
  10944. pt.x+=dx;
  10945. pt.y+=dy;
  10946. }
  10947. this._default.x+=dx;
  10948. this._default.y+=dy;
  10949. this.updateState();
  10950. }
  10951. return GearXY;
  10952. })(GearBase)
  10953. //class fairygui.GLoader extends fairygui.GObject
  10954. var GLoader=(function(_super){
  10955. function GLoader(){
  10956. this._url=null;
  10957. this._align=null;
  10958. this._valign=null;
  10959. this._autoSize=false;
  10960. this._fill=0;
  10961. this._shrinkOnly=false;
  10962. this._showErrorSign=false;
  10963. this._playing=false;
  10964. this._frame=0;
  10965. this._color=null;
  10966. this._contentItem=null;
  10967. this._contentSourceWidth=0;
  10968. this._contentSourceHeight=0;
  10969. this._contentWidth=0;
  10970. this._contentHeight=0;
  10971. this._content=null;
  10972. this._errorSign=null;
  10973. this._content2=null;
  10974. this._updatingLayout=false;
  10975. GLoader.__super.call(this);
  10976. this._playing=true;
  10977. this._url="";
  10978. this._fill=0;
  10979. this._align="left";
  10980. this._valign="top";
  10981. this._showErrorSign=true;
  10982. this._color="#FFFFFF";
  10983. this.isdispose=false;
  10984. this.effectpkgdict=null;
  10985. }
  10986. __class(GLoader,'fairygui.GLoader',_super);
  10987. var __proto=GLoader.prototype;
  10988. Laya.imps(__proto,{"fairygui.gears.IAnimationGear":true,"fairygui.gears.IColorGear":true})
  10989. __proto.createDisplayObject=function(){
  10990. _super.prototype.createDisplayObject.call(this);
  10991. this._displayObject.mouseEnabled=true;
  10992. }
  10993. __proto.dispose=function(){
  10994. if(this._contentItem==null && ((this._content instanceof fairygui.display.Image ))){
  10995. var texture=(this._content).tex;
  10996. if(texture !=null)
  10997. this.freeExternal(texture);
  10998. }
  10999. if(this._content2!=null)
  11000. this._content2.dispose();
  11001. this.isdispose=true;
  11002. this.clearEffectDict();
  11003. this.effectpkgdict=null;
  11004. _super.prototype.dispose.call(this);
  11005. }
  11006. __proto.advance=function(timeInMiniseconds){
  11007. if((this._content instanceof fairygui.display.MovieClip ))
  11008. (this._content).advance(timeInMiniseconds);
  11009. }
  11010. __proto.applyColor=function(){}
  11011. __proto.loadContent=function(){
  11012. this.clearContent();
  11013. this.clearEffectDict();
  11014. if (!this._url)
  11015. return;
  11016. if( UIConfig$1.gameEffectDict && UIConfig$1.gameEffectDict[this._url] !=null ){
  11017. if(UIConfig$1.gameEffectDict[this._url]=="1"){
  11018. UIConfig$1.gameLoaderManager.loadEffect( this._url,this,this.effectComplete,this._url );
  11019. }else{
  11020. UIConfig$1.gameLoaderManager.loadEffect( UIConfig$1.gameEffectDict[this._url],this,this.effectComplete,this._url );
  11021. }
  11022. }
  11023. else
  11024. {
  11025. if(ToolSet.startsWith(this._url,"ui://"))
  11026. this.loadFromPackage(this._url);
  11027. else
  11028. this.loadExternal();
  11029. }
  11030. }
  11031. __proto.clearEffectDict=function(){
  11032. if(this.effectpkgdict){
  11033. for(var s in this.effectpkgdict){
  11034. UIConfig$1.gameLoaderManager.removeeffectpackage(this.effectpkgdict[s]);
  11035. delete this.effectpkgdict[s];
  11036. }
  11037. }
  11038. }
  11039. __proto.effectComplete=function(itemurl){
  11040. if(itemurl==this._url&&!this.isdispose){
  11041. var pkgname=UIConfig$1.gameEffectDict[this._url];
  11042. var effecturl;
  11043. if(pkgname=="1"){
  11044. pkgname=itemurl;
  11045. UIConfig$1.gameLoaderManager.addeffectPackage(pkgname);
  11046. effecturl=fairygui.UIPackage.getItemURL(pkgname,pkgname);
  11047. }else{
  11048. UIConfig$1.gameLoaderManager.addeffectPackage(pkgname);
  11049. effecturl=this._url;
  11050. }
  11051. if(!this.effectpkgdict){
  11052. this.effectpkgdict={};
  11053. }
  11054. this.effectpkgdict[itemurl]=pkgname;
  11055. this.loadFromPackage(effecturl);
  11056. }
  11057. }
  11058. __proto.loadFromPackage=function(itemURL){
  11059. this._contentItem=UIPackage.getItemByURL(itemURL);
  11060. if(this._contentItem !=null){
  11061. this._contentItem.load();
  11062. if(this._autoSize)
  11063. this.setSize(this._contentItem.width,this._contentItem.height);
  11064. if(this._contentItem.type==0){
  11065. if(this._contentItem.texture==null){
  11066. if( UIConfig$1.gameBgResousedict && UIConfig$1.gameBgResousedict[this._url]!=null){
  11067. this._url=UIConfig$1.gameBgResousedict[this._url];
  11068. this.loadExternal();
  11069. }else{
  11070. this.setErrorState();
  11071. }
  11072. }
  11073. else {
  11074. if(!((this._content instanceof fairygui.display.Image ))){
  11075. this._content=new Image$1();
  11076. this._displayObject.addChild(this._content);
  11077. }
  11078. else
  11079. this._displayObject.addChild(this._content);
  11080. (this._content).tex=this._contentItem.texture;
  11081. (this._content).scale9Grid=this._contentItem.scale9Grid;
  11082. (this._content).scaleByTile=this._contentItem.scaleByTile;
  11083. (this._content).tileGridIndice=this._contentItem.tileGridIndice;
  11084. this._contentSourceWidth=this._contentItem.width;
  11085. this._contentSourceHeight=this._contentItem.height;
  11086. this.updateLayout();
  11087. }
  11088. }
  11089. else if(this._contentItem.type==1){
  11090. if(!((this._content instanceof fairygui.display.MovieClip ))){
  11091. this._content=new MovieClip$1();
  11092. this._displayObject.addChild(this._content);
  11093. }
  11094. else
  11095. this._displayObject.addChild(this._content);
  11096. this._contentSourceWidth=this._contentItem.width;
  11097. this._contentSourceHeight=this._contentItem.height;
  11098. (this._content).interval=this._contentItem.interval;
  11099. (this._content).swing=this._contentItem.swing;
  11100. (this._content).repeatDelay=this._contentItem.repeatDelay;
  11101. (this._content).frames=this._contentItem.frames;
  11102. (this._content).boundsRect=new Rectangle(0,0,this._contentSourceWidth,this._contentSourceHeight);
  11103. this.updateLayout();
  11104. }
  11105. else if(this._contentItem.type==3){
  11106. var obj=UIPackage.createObjectFromURL(itemURL);
  11107. if(!obj)
  11108. this.setErrorState();
  11109. else if(!((obj instanceof fairygui.GComponent ))){
  11110. obj.dispose();
  11111. this.setErrorState();
  11112. }
  11113. else{
  11114. this._content2=obj.asCom;
  11115. this._displayObject.addChild(this._content2.displayObject);
  11116. this._contentSourceWidth=this._contentItem.width;
  11117. this._contentSourceHeight=this._contentItem.height;
  11118. this.updateLayout();
  11119. }
  11120. }
  11121. else
  11122. this.setErrorState();
  11123. }
  11124. else{
  11125. if( UIConfig$1.gameBgResousedict && UIConfig$1.gameBgResousedict[this._url]!=null){
  11126. this._url=UIConfig$1.gameBgResousedict[this._url];
  11127. this.loadExternal();
  11128. }else{
  11129. this.setErrorState();
  11130. }
  11131. }
  11132. }
  11133. __proto.loadFromContentItem=function(contentItem){
  11134. this._contentItem=null;
  11135. this._contentItem=contentItem;
  11136. if(this._contentItem){
  11137. if(!this._content){
  11138. this._content=new MovieClip$1();
  11139. this._displayObject.addChild(this._content);
  11140. (this._content).playing=false;
  11141. }
  11142. this._contentSourceWidth=this._contentItem.width;
  11143. this._contentSourceHeight=this._contentItem.height;
  11144. (this._content).interval=this._contentItem.interval;
  11145. (this._content).swing=this._contentItem.swing;
  11146. (this._content).repeatDelay=this._contentItem.repeatDelay;
  11147. (this._content).frames=this._contentItem.frames;
  11148. this.updateLayout();
  11149. }
  11150. }
  11151. __proto.loadExternal=function(){
  11152. var texture = AssetProxy.inst.getRes(this._url);
  11153. if(texture){
  11154. this.onExternalLoadSuccess(this._url);
  11155. }else{
  11156. AssetProxy.inst.load([{ url:this._url, type:"image" }],Handler.create(this,this.__getResCompleted,[this._url]));
  11157. }
  11158. }
  11159. __proto.freeExternal=function(texture){}
  11160. __proto.onExternalLoadSuccess=function(urls){
  11161. if(!((this._content instanceof fairygui.display.Image ))){
  11162. this._content=new Image$1();
  11163. this._displayObject.addChild(this._content);
  11164. }
  11165. else
  11166. this._displayObject.addChild(this._content);
  11167. var texture = AssetProxy.inst.getRes(urls);
  11168. (this._content).tex=texture;//texture;
  11169. (this._content).scale9Grid=null;
  11170. (this._content).scaleByTile=false;
  11171. if( !texture ){
  11172. return;
  11173. }
  11174. this._contentSourceWidth=texture.width;
  11175. this._contentSourceHeight=texture.height;
  11176. this.updateLayout();
  11177. }
  11178. __proto.onExternalLoadFailed=function(){
  11179. this.setErrorState();
  11180. }
  11181. __proto.__getResCompleted=function(tex){
  11182. if(tex!=null)
  11183. this.onExternalLoadSuccess(tex);
  11184. else
  11185. this.onExternalLoadFailed();
  11186. }
  11187. __proto.setErrorState=function(){
  11188. if (!this._showErrorSign)
  11189. return;
  11190. if (this._errorSign==null){
  11191. if (UIConfig$1.loaderErrorSign !=null){
  11192. this._errorSign=fairygui.GLoader._errorSignPool.getObject(UIConfig$1.loaderErrorSign);
  11193. }
  11194. }
  11195. if (this._errorSign !=null){
  11196. this._errorSign.setSize(this.width,this.height);
  11197. this._displayObject.addChild(this._errorSign.displayObject);
  11198. }
  11199. }
  11200. __proto.clearErrorState=function(){
  11201. if (this._errorSign !=null){
  11202. this._displayObject.removeChild(this._errorSign.displayObject);
  11203. fairygui.GLoader._errorSignPool.returnObject(this._errorSign);
  11204. this._errorSign=null;
  11205. }
  11206. }
  11207. __proto.updateLayout=function(){
  11208. if (this._content2==null && this._content==null){
  11209. if (this._autoSize){
  11210. this._updatingLayout=true;
  11211. this.setSize(50,30);
  11212. this._updatingLayout=false;
  11213. }
  11214. return;
  11215. }
  11216. this._contentWidth=this._contentSourceWidth;
  11217. this._contentHeight=this._contentSourceHeight;
  11218. if (this._autoSize){
  11219. this._updatingLayout=true;
  11220. if (this._contentWidth==0)
  11221. this._contentWidth=50;
  11222. if (this._contentHeight==0)
  11223. this._contentHeight=30;
  11224. this.setSize(this._contentWidth,this._contentHeight);
  11225. this._updatingLayout=false;
  11226. if(this._contentWidth==this._width && this._contentHeight==this._height){
  11227. if(this._content2!=null){
  11228. this._content2.setXY(0,0);
  11229. this._content2.setScale(1,1);
  11230. }
  11231. else{
  11232. this._content.x=0;
  11233. this._content.y=0;
  11234. this._content.scaleX=1;
  11235. this._content.scaleY=1;
  11236. }
  11237. return;
  11238. }
  11239. };
  11240. var sx=1,sy=1;
  11241. if(this._fill!=0){
  11242. sx=this.width/this._contentSourceWidth;
  11243. sy=this.height/this._contentSourceHeight;
  11244. if(sx!=1 || sy!=1){
  11245. if (this._fill==2)
  11246. sx=sy;
  11247. else if (this._fill==3)
  11248. sy=sx;
  11249. else if (this._fill==1){
  11250. if (sx > sy)
  11251. sx=sy;
  11252. else
  11253. sy=sx;
  11254. }
  11255. else if (this._fill==5){
  11256. if (sx > sy)
  11257. sy=sx;
  11258. else
  11259. sx=sy;
  11260. }
  11261. if(this._shrinkOnly){
  11262. if(sx>1)
  11263. sx=1;
  11264. if(sy>1)
  11265. sy=1;
  11266. }
  11267. this._contentWidth=this._contentSourceWidth *sx;
  11268. this._contentHeight=this._contentSourceHeight *sy;
  11269. }
  11270. }
  11271. if(this._content2!=null)
  11272. this._content2.setScale(sx,sy);
  11273. else if ((this._content instanceof fairygui.display.Image ))
  11274. (this._content).scaleTexture(sx,sy);
  11275. else
  11276. this._content.scale(sx,sy);
  11277. var nx=NaN,ny=NaN;
  11278. if (this._align=="center")
  11279. nx=Math.floor((this.width-this._contentWidth)/ 2);
  11280. else if (this._align=="right")
  11281. nx=this.width-this._contentWidth;
  11282. else
  11283. nx=0;
  11284. if (this._valign=="middle")
  11285. ny=Math.floor((this.height-this._contentHeight)/ 2);
  11286. else if (this._valign=="bottom")
  11287. ny=this.height-this._contentHeight;
  11288. else
  11289. ny=0;
  11290. if(this._content2!=null)
  11291. this._content2.setXY(nx,ny);
  11292. else{
  11293. this._content.x=nx;
  11294. this._content.y=ny;
  11295. }
  11296. }
  11297. __proto.clearContent=function(){
  11298. this.clearErrorState();
  11299. if (this._content !=null && this._content.parent !=null)
  11300. this._displayObject.removeChild(this._content);
  11301. if(this._contentItem==null && ((this._content instanceof fairygui.display.Image ))){
  11302. var texture=(this._content).tex;
  11303. if(texture !=null)
  11304. this.freeExternal(texture);
  11305. }
  11306. if(this._content2!=null){
  11307. this._content2.dispose();
  11308. this._content2=null;
  11309. }
  11310. this._contentItem=null;
  11311. }
  11312. __proto.handleSizeChanged=function(){
  11313. _super.prototype.handleSizeChanged.call(this);
  11314. if(!this._updatingLayout)
  11315. this.updateLayout();
  11316. }
  11317. __proto.setup_beforeAdd=function(buffer,beginPos){
  11318. _super.prototype.setup_beforeAdd.call(this,buffer,beginPos);
  11319. buffer.seek(beginPos,5);
  11320. var iv=0;
  11321. this._url=buffer.readS();
  11322. iv=buffer.readByte();
  11323. this._align=iv==0?"left":(iv==1?"center":"right");
  11324. iv=buffer.readByte();
  11325. this._valign=iv==0?"top":(iv==1?"middle":"bottom");
  11326. this._fill=buffer.readByte();
  11327. this._shrinkOnly=buffer.readBool();
  11328. this._autoSize=buffer.readBool();
  11329. this._showErrorSign=buffer.readBool();
  11330. this._playing=buffer.readBool();
  11331. this._frame=buffer.getInt32();
  11332. if (buffer.readBool())
  11333. this.color=buffer.readColorS();
  11334. var fillMethod=buffer.readByte();
  11335. if (fillMethod !=0)
  11336. buffer.skip(6);
  11337. if (this._url)
  11338. this.loadContent();
  11339. }
  11340. __getset(0,__proto,'frame',function(){
  11341. return this._frame;
  11342. },function(value){
  11343. if (this._frame !=value){
  11344. this._frame=value;
  11345. if ((this._content instanceof fairygui.display.MovieClip ))
  11346. (this._content).frame=value;
  11347. this.updateGear(5);
  11348. }
  11349. });
  11350. __getset(0,__proto,'url',function(){
  11351. return this._url;
  11352. },function(value){
  11353. if (this._url==value)
  11354. return;
  11355. this._url=value;
  11356. this.loadContent();
  11357. this.updateGear(7);
  11358. });
  11359. __getset(0,__proto,'align',function(){
  11360. return this._align;
  11361. },function(value){
  11362. if (this._align !=value){
  11363. this._align=value;
  11364. this.updateLayout();
  11365. }
  11366. });
  11367. /**
  11368. *@see LoaderFillType
  11369. */
  11370. /**
  11371. *@see LoaderFillType
  11372. */
  11373. __getset(0,__proto,'fill',function(){
  11374. return this._fill;
  11375. },function(value){
  11376. if (this._fill !=value){
  11377. this._fill=value;
  11378. this.updateLayout();
  11379. }
  11380. });
  11381. __getset(0,__proto,'verticalAlign',function(){
  11382. return this._valign;
  11383. },function(value){
  11384. if (this._valign !=value){
  11385. this._valign=value;
  11386. this.updateLayout();
  11387. }
  11388. });
  11389. __getset(0,__proto,'icon',function(){
  11390. return this._url;
  11391. },function(value){
  11392. this.url=value;
  11393. });
  11394. __getset(0,__proto,'content',function(){
  11395. return this._content;
  11396. });
  11397. __getset(0,__proto,'shrinkOnly',function(){
  11398. return this._shrinkOnly;
  11399. },function(value){
  11400. if(this._shrinkOnly!=value){
  11401. this._shrinkOnly=value;
  11402. this.updateLayout();
  11403. }
  11404. });
  11405. //todo:
  11406. __getset(0,__proto,'showErrorSign',function(){
  11407. return this._showErrorSign;
  11408. },function(value){
  11409. this._showErrorSign=value;
  11410. });
  11411. __getset(0,__proto,'autoSize',function(){
  11412. return this._autoSize;
  11413. },function(value){
  11414. if (this._autoSize !=value){
  11415. this._autoSize=value;
  11416. this.updateLayout();
  11417. }
  11418. });
  11419. __getset(0,__proto,'playing',function(){
  11420. return this._playing;
  11421. },function(value){
  11422. if (this._playing !=value){
  11423. this._playing=value;
  11424. if ((this._content instanceof fairygui.display.MovieClip ))
  11425. (this._content).playing=value;
  11426. this.updateGear(5);
  11427. }
  11428. });
  11429. //从start帧开始,播放到end帧(-1表示结尾),重复times次(0表示无限循环),循环结束后,停止在endAt帧(-1表示参数end)
  11430. __proto.setPlaySettings=function(start,end,times,endAt,endHandler){
  11431. (start===void 0)&& (start=0);
  11432. (end===void 0)&& (end=-1);
  11433. (times===void 0)&& (times=0);
  11434. (endAt===void 0)&& (endAt=-1);
  11435. if ((this._content instanceof fairygui.display.MovieClip )){
  11436. (this._content).setPlaySettings(start,end,times,endAt,endHandler);
  11437. }
  11438. }
  11439. __getset(0,__proto,'content',function(){
  11440. return this._content;
  11441. });
  11442. __getset(0,__proto,'timeScale',function(){
  11443. if((this._content instanceof fairygui.display.MovieClip ))
  11444. return (this._content).timeScale;
  11445. else
  11446. return 1;
  11447. },function(value){
  11448. if((this._content instanceof fairygui.display.MovieClip ))
  11449. (this._content).timeScale=value;
  11450. });
  11451. __getset(0,__proto,'color',function(){
  11452. return this._color;
  11453. },function(value){
  11454. if(this._color !=value){
  11455. this._color=value;
  11456. this.updateGear(4);
  11457. this.applyColor();
  11458. }
  11459. });
  11460. __getset(0,__proto,'component',function(){
  11461. return this._content2;
  11462. });
  11463. __static(GLoader,
  11464. ['_errorSignPool',function(){return this._errorSignPool=new GObjectPool();}
  11465. ]);
  11466. return GLoader;
  11467. })(GObject)
  11468. //class fairygui.GMovieClip extends fairygui.GObject
  11469. var GMovieClip=(function(_super){
  11470. function GMovieClip(){
  11471. this._movieClip=null;
  11472. GMovieClip.__super.call(this);
  11473. this._sizeImplType=1;
  11474. }
  11475. __class(GMovieClip,'fairygui.GMovieClip',_super);
  11476. var __proto=GMovieClip.prototype;
  11477. Laya.imps(__proto,{"fairygui.gears.IAnimationGear":true,"fairygui.gears.IColorGear":true})
  11478. __proto.createDisplayObject=function(){
  11479. this._displayObject=this._movieClip=new MovieClip$1();
  11480. this._movieClip.mouseEnabled=false;
  11481. this._displayObject["$owner"]=this;
  11482. }
  11483. __proto.rewind=function(){
  11484. this._movieClip.rewind();
  11485. }
  11486. __proto.syncStatus=function(anotherMc){
  11487. this._movieClip.syncStatus(anotherMc._movieClip);
  11488. }
  11489. __proto.advance=function(timeInMiniseconds){
  11490. this._movieClip.advance(timeInMiniseconds);
  11491. }
  11492. //从start帧开始,播放到end帧(-1表示结尾),重复times次(0表示无限循环),循环结束后,停止在endAt帧(-1表示参数end)
  11493. __proto.setPlaySettings=function(start,end,times,endAt,endHandler){
  11494. (start===void 0)&& (start=0);
  11495. (end===void 0)&& (end=-1);
  11496. (times===void 0)&& (times=0);
  11497. (endAt===void 0)&& (endAt=-1);
  11498. this._movieClip.setPlaySettings(start,end,times,endAt,endHandler);
  11499. }
  11500. __proto.constructFromResource=function(){
  11501. this.sourceWidth=this.packageItem.width;
  11502. this.sourceHeight=this.packageItem.height;
  11503. this.initWidth=this.sourceWidth;
  11504. this.initHeight=this.sourceHeight;
  11505. this.setSize(this.sourceWidth,this.sourceHeight);
  11506. this.packageItem.load();
  11507. this._movieClip.interval=this.packageItem.interval;
  11508. this._movieClip.swing=this.packageItem.swing;
  11509. this._movieClip.repeatDelay=this.packageItem.repeatDelay;
  11510. this._movieClip.frames=this.packageItem.frames;
  11511. this._movieClip.boundsRect=new Rectangle(0,0,this.sourceWidth,this.sourceHeight);
  11512. }
  11513. __proto.setinterval=function(value){
  11514. if(this._movieClip){
  11515. this._movieClip.interval=value;
  11516. }
  11517. }
  11518. __proto.setup_beforeAdd=function(buffer,beginPos){
  11519. _super.prototype.setup_beforeAdd.call(this,buffer,beginPos);
  11520. buffer.seek(beginPos,5);
  11521. if (buffer.readBool())
  11522. this.color=buffer.readColorS();
  11523. buffer.readByte();
  11524. this._movieClip.frame=buffer.getInt32();
  11525. this._movieClip.playing=buffer.readBool();
  11526. }
  11527. __getset(0,__proto,'color',function(){
  11528. return "#FFFFFF";
  11529. },function(value){
  11530. });
  11531. __getset(0,__proto,'playing',function(){
  11532. return this._movieClip.playing;
  11533. },function(value){
  11534. if (this._movieClip.playing !=value){
  11535. this._movieClip.playing=value;
  11536. this.updateGear(5);
  11537. }
  11538. });
  11539. __getset(0,__proto,'timeScale',function(){
  11540. return this._movieClip.timeScale;
  11541. },function(value){
  11542. this._movieClip.timeScale=value;
  11543. });
  11544. __getset(0,__proto,'frame',function(){
  11545. return this._movieClip.frame;
  11546. },function(value){
  11547. if (this._movieClip.frame !=value){
  11548. this._movieClip.frame=value;
  11549. this.updateGear(5);
  11550. }
  11551. });
  11552. return GMovieClip;
  11553. })(GObject)
  11554. //class fairygui.GBasicTextField extends fairygui.GTextField
  11555. var GBasicTextField=(function(_super){
  11556. var LineInfo,TextExt;
  11557. function GBasicTextField(){
  11558. this.textField=null;
  11559. this._font=null;
  11560. this._color=null;
  11561. this._ubbEnabled=false;
  11562. this._singleLine=false;
  11563. this._letterSpacing=0;
  11564. this._autoSize=0;
  11565. this._widthAutoSize=false;
  11566. this._heightAutoSize=false;
  11567. this._updatingSize=false;
  11568. this._textWidth=0;
  11569. this._textHeight=0;
  11570. this._bitmapFont=null;
  11571. this._lines=null;
  11572. GBasicTextField.__super.call(this);
  11573. this._text="";
  11574. this._color="#000000";
  11575. this.textField.align="left";
  11576. this.textField.font=UIConfig$1.defaultFont;
  11577. this._autoSize=1;
  11578. this._widthAutoSize=this._heightAutoSize=true;
  11579. this.textField["_sizeDirty"]=false;
  11580. }
  11581. __class(GBasicTextField,'fairygui.GBasicTextField',_super);
  11582. var __proto=GBasicTextField.prototype;
  11583. __proto.createDisplayObject=function(){
  11584. this._displayObject=this.textField=new TextExt(this);
  11585. this._displayObject["$owner"]=this;
  11586. this._displayObject.mouseEnabled=false;
  11587. }
  11588. __proto.setAutoSize=function(value){
  11589. this._autoSize=value;
  11590. this._widthAutoSize=value==1;
  11591. this._heightAutoSize=value==1 || value==2;
  11592. this.textField.wordWrap=!this._widthAutoSize && !this._singleLine;
  11593. if(!this._underConstruct){
  11594. if(!this._heightAutoSize)
  11595. this.textField.size(this.width,this.height);
  11596. else if(!this._widthAutoSize)
  11597. this.textField.width=this.width;
  11598. }
  11599. }
  11600. __proto.ensureSizeCorrect=function(){
  11601. if (!this._underConstruct && this.textField["_isChanged"])
  11602. this.textField.typeset();
  11603. }
  11604. __proto.typeset=function(){
  11605. if(this._bitmapFont!=null)
  11606. this.renderWithBitmapFont();
  11607. else if(this._widthAutoSize || this._heightAutoSize)
  11608. this.updateSize();
  11609. }
  11610. __proto.updateSize=function(){
  11611. this._textWidth=Math.ceil(this.textField.textWidth);
  11612. this._textHeight=Math.ceil(this.textField.textHeight);
  11613. var w=NaN,h=0;
  11614. if(this._widthAutoSize){
  11615. w=this._textWidth;
  11616. if(this.textField.width!=w){
  11617. this.textField.width=w;
  11618. if(this.textField.align!="left")
  11619. this.textField["baseTypeset"]();
  11620. }
  11621. }
  11622. else
  11623. w=this.width;
  11624. if(this._heightAutoSize){
  11625. h=this._textHeight;
  11626. if(!this._widthAutoSize){
  11627. if(this.textField.height!=this._textHeight)
  11628. this.textField.height=this._textHeight;
  11629. }
  11630. }
  11631. else {
  11632. h=this.height;
  11633. if(this._textHeight > h)
  11634. this._textHeight=h;
  11635. if(this.textField.height!=this._textHeight)
  11636. this.textField.height=this._textHeight;
  11637. }
  11638. this._updatingSize=true;
  11639. this.setSize(w,h);
  11640. this._updatingSize=false;
  11641. }
  11642. __proto.renderWithBitmapFont=function(){
  11643. var gr=this._displayObject.graphics;
  11644. gr.clear();
  11645. if (!this._lines)
  11646. this._lines=[];
  11647. else
  11648. LineInfo.returnList(this._lines);
  11649. var letterSpacing=this.letterSpacing;
  11650. var lineSpacing=this.leading-1;
  11651. var rectWidth=this.width-2 *2;
  11652. var lineWidth=0,lineHeight=0,lineTextHeight=0;
  11653. var glyphWidth=0,glyphHeight=0;
  11654. var wordChars=0,wordStart=0,wordEnd=0;
  11655. var lastLineHeight=0;
  11656. var lineBuffer="";
  11657. var lineY=2;
  11658. var line;
  11659. var wordWrap=!this._widthAutoSize && !this._singleLine;
  11660. var fontSize=this.fontSize;
  11661. var fontScale=this._bitmapFont.resizable?fontSize/this._bitmapFont.size:1;
  11662. this._textWidth=0;
  11663. this._textHeight=0;
  11664. var text2=this._text;
  11665. if (this._templateVars !=null)
  11666. text2=this.parseTemplate(text2);
  11667. var textLength=text2.length;
  11668. for (var offset=0;offset < textLength;++offset){
  11669. var ch=text2.charAt(offset);
  11670. var cc=ch.charCodeAt(0);
  11671. if (cc==10){
  11672. lineBuffer+=ch;
  11673. line=LineInfo.borrow();
  11674. line.width=lineWidth;
  11675. if (lineTextHeight==0){
  11676. if (lastLineHeight==0)
  11677. lastLineHeight=fontSize;
  11678. if (lineHeight==0)
  11679. lineHeight=lastLineHeight;
  11680. lineTextHeight=lineHeight;
  11681. }
  11682. line.height=lineHeight;
  11683. lastLineHeight=lineHeight;
  11684. line.textHeight=lineTextHeight;
  11685. line.text=lineBuffer;
  11686. line.y=lineY;
  11687. lineY+=(line.height+lineSpacing);
  11688. if (line.width > this._textWidth)
  11689. this._textWidth=line.width;
  11690. this._lines.push(line);
  11691. lineBuffer="";
  11692. lineWidth=0;
  11693. lineHeight=0;
  11694. lineTextHeight=0;
  11695. wordChars=0;
  11696. wordStart=0;
  11697. wordEnd=0;
  11698. continue ;
  11699. }
  11700. if (cc>=65 && cc<=90 || cc>=97 && cc<=122){
  11701. if (wordChars==0)
  11702. wordStart=lineWidth;
  11703. wordChars++;
  11704. }
  11705. else{
  11706. if (wordChars > 0)
  11707. wordEnd=lineWidth;
  11708. wordChars=0;
  11709. }
  11710. if (cc==32){
  11711. glyphWidth=Math.ceil(fontSize / 2);
  11712. glyphHeight=fontSize;
  11713. }
  11714. else {
  11715. var glyph=this._bitmapFont.glyphs[ch];
  11716. if (glyph){
  11717. glyphWidth=Math.ceil(glyph.advance*fontScale);
  11718. glyphHeight=Math.ceil(glyph.lineHeight*fontScale);
  11719. }
  11720. else {
  11721. glyphWidth=0;
  11722. glyphHeight=0;
  11723. }
  11724. }
  11725. if (glyphHeight > lineTextHeight)
  11726. lineTextHeight=glyphHeight;
  11727. if (glyphHeight > lineHeight)
  11728. lineHeight=glyphHeight;
  11729. if (lineWidth !=0)
  11730. lineWidth+=letterSpacing;
  11731. lineWidth+=glyphWidth;
  11732. if (!wordWrap || lineWidth <=rectWidth){
  11733. lineBuffer+=ch;
  11734. }
  11735. else {
  11736. line=LineInfo.borrow();
  11737. line.height=lineHeight;
  11738. line.textHeight=lineTextHeight;
  11739. if (lineBuffer.length==0){
  11740. line.text=ch;
  11741. }
  11742. else if (wordChars > 0 && wordEnd > 0){
  11743. lineBuffer+=ch;
  11744. var len=lineBuffer.length-wordChars;
  11745. line.text=ToolSet.trimRight(lineBuffer.substr(0,len));
  11746. line.width=wordEnd;
  11747. lineBuffer=lineBuffer.substr(len);
  11748. lineWidth-=wordStart;
  11749. }
  11750. else {
  11751. line.text=lineBuffer;
  11752. line.width=lineWidth-(glyphWidth+letterSpacing);
  11753. lineBuffer=ch;
  11754. lineWidth=glyphWidth;
  11755. lineHeight=glyphHeight;
  11756. lineTextHeight=glyphHeight;
  11757. }
  11758. line.y=lineY;
  11759. lineY+=(line.height+lineSpacing);
  11760. if (line.width > this._textWidth)
  11761. this._textWidth=line.width;
  11762. wordChars=0;
  11763. wordStart=0;
  11764. wordEnd=0;
  11765. this._lines.push(line);
  11766. }
  11767. }
  11768. if (lineBuffer.length > 0){
  11769. line=LineInfo.borrow();
  11770. line.width=lineWidth;
  11771. if (lineHeight==0)
  11772. lineHeight=lastLineHeight;
  11773. if (lineTextHeight==0)
  11774. lineTextHeight=lineHeight;
  11775. line.height=lineHeight;
  11776. line.textHeight=lineTextHeight;
  11777. line.text=lineBuffer;
  11778. line.y=lineY;
  11779. if (line.width > this._textWidth)
  11780. this._textWidth=line.width;
  11781. this._lines.push(line);
  11782. }
  11783. if (this._textWidth > 0)
  11784. this._textWidth+=2 *2;
  11785. var count=this._lines.length;
  11786. if (count==0){
  11787. this._textHeight=0;
  11788. }
  11789. else {
  11790. line=this._lines[this._lines.length-1];
  11791. this._textHeight=line.y+line.height+2;
  11792. };
  11793. var w=NaN,h=0;
  11794. if (this._widthAutoSize){
  11795. if (this._textWidth==0)
  11796. w=0;
  11797. else
  11798. w=this._textWidth;
  11799. }
  11800. else
  11801. w=this.width;
  11802. if (this._heightAutoSize){
  11803. if (this._textHeight==0)
  11804. h=0;
  11805. else
  11806. h=this._textHeight;
  11807. }
  11808. else
  11809. h=this.height;
  11810. this._updatingSize=true;
  11811. this.setSize(w,h);
  11812. this._updatingSize=false;
  11813. this.doAlign();
  11814. if (w==0 || h==0)
  11815. return;
  11816. var charX=2;
  11817. var lineIndent=0;
  11818. var charIndent=0;
  11819. rectWidth=this.width-2 *2;
  11820. var lineCount=this._lines.length;
  11821. for (var i=0;i < lineCount;i++){
  11822. line=this._lines[i];
  11823. charX=2;
  11824. if (this.align=="center")
  11825. lineIndent=(rectWidth-line.width)/ 2;
  11826. else if (this.align=="right")
  11827. lineIndent=rectWidth-line.width;
  11828. else
  11829. lineIndent=0;
  11830. textLength=line.text.length;
  11831. for (var j=0;j < textLength;j++){
  11832. ch=line.text.charAt(j);
  11833. cc=ch.charCodeAt(0);
  11834. if(cc==10)
  11835. continue ;
  11836. if(cc==32){
  11837. charX+=this._letterSpacing+Math.ceil(fontSize/2);
  11838. continue ;
  11839. }
  11840. glyph=this._bitmapFont.glyphs[ch];
  11841. if (glyph !=null){
  11842. charIndent=(line.height+line.textHeight)/ 2-Math.ceil(glyph.lineHeight*fontScale);
  11843. if(glyph.texture){
  11844. gr.drawTexture(glyph.texture,
  11845. charX+lineIndent+Math.ceil(glyph.offsetX*fontScale),
  11846. line.y+charIndent+Math.ceil(glyph.offsetY*fontScale),
  11847. glyph.texture.width *fontScale,
  11848. glyph.texture.height *fontScale);
  11849. }
  11850. charX+=letterSpacing+Math.ceil(glyph.advance*fontScale);
  11851. }
  11852. else {
  11853. charX+=letterSpacing;
  11854. }
  11855. }
  11856. }
  11857. }
  11858. //line loop
  11859. __proto.handleSizeChanged=function(){
  11860. if(this._updatingSize)
  11861. return;
  11862. if(this._underConstruct)
  11863. this.textField.size(this.width,this.height);
  11864. else{
  11865. if(this._bitmapFont!=null){
  11866. if(!this._widthAutoSize)
  11867. this.textField["setChanged"]();
  11868. else
  11869. this.doAlign();
  11870. }
  11871. else {
  11872. if(!this._widthAutoSize){
  11873. if(!this._heightAutoSize)
  11874. this.textField.size(this.width,this.height);
  11875. else
  11876. this.textField.width=this.width;
  11877. }
  11878. }
  11879. }
  11880. }
  11881. __proto.handleGrayedChanged=function(){
  11882. fairygui.GObject.prototype.handleGrayedChanged.call(this);
  11883. if(this.grayed)
  11884. this.textField.color="#AAAAAA";
  11885. else
  11886. this.textField.color=this._color;
  11887. }
  11888. __proto.doAlign=function(){
  11889. if(this.valign=="top" || this._textHeight==0)
  11890. this._yOffset=2;
  11891. else {
  11892. var dh=this.height-this._textHeight;
  11893. if(dh < 0)
  11894. dh=0;
  11895. if(this.valign=="middle")
  11896. this._yOffset=Math.floor(dh / 2);
  11897. else
  11898. this._yOffset=Math.floor(dh);
  11899. }
  11900. this.handleXYChanged();
  11901. }
  11902. __proto.flushVars=function(){
  11903. this.text=this._text;
  11904. }
  11905. __getset(0,__proto,'bold',function(){
  11906. return this.textField.bold;
  11907. },function(value){
  11908. this.textField.bold=value;
  11909. });
  11910. __getset(0,__proto,'letterSpacing',function(){
  11911. return this._letterSpacing;
  11912. },function(value){
  11913. this._letterSpacing=value;
  11914. });
  11915. __getset(0,__proto,'align',function(){
  11916. return this.textField.align;
  11917. },function(value){
  11918. this.textField.align=value;
  11919. });
  11920. __getset(0,__proto,'text',function(){
  11921. return this._text;
  11922. },function(value){
  11923. this._text=value;
  11924. if(this._text==null)
  11925. this._text="";
  11926. if(this._bitmapFont==null){
  11927. if(this._widthAutoSize)
  11928. this.textField.width=10000;
  11929. var text2=this._text;
  11930. if (this._templateVars !=null)
  11931. text2=this.parseTemplate(text2);
  11932. if(this._ubbEnabled)
  11933. this.textField.text=ToolSet.removeUBB(ToolSet.encodeHTML(text2));
  11934. else
  11935. this.textField.text=text2;
  11936. }
  11937. else{
  11938. this.textField.text="";
  11939. this.textField["setChanged"]();
  11940. }
  11941. if(this.parent && this.parent._underConstruct)
  11942. this.textField.typeset();
  11943. });
  11944. __getset(0,__proto,'color',function(){
  11945. return this._color;
  11946. },function(value){
  11947. if (this._color !=value){
  11948. this._color=value;
  11949. if (this._gearColor.controller)
  11950. this._gearColor.updateState();
  11951. if(this.grayed)
  11952. this.textField.color="#AAAAAA";
  11953. else
  11954. this.textField.color=this._color;
  11955. }
  11956. });
  11957. __getset(0,__proto,'font',function(){
  11958. return this.textField.font;
  11959. },function(value){
  11960. this._font=value;
  11961. if(ToolSet.startsWith(this._font,"ui://"))
  11962. this._bitmapFont=UIPackage.getItemAssetByURL(this._font);
  11963. else
  11964. this._bitmapFont=null;
  11965. if(this._bitmapFont!=null){
  11966. this.textField["setChanged"]();
  11967. }
  11968. else {
  11969. if(this._font)
  11970. this.textField.font=this._font;
  11971. else
  11972. this.textField.font=UIConfig$1.defaultFont;
  11973. }
  11974. });
  11975. __getset(0,__proto,'leading',function(){
  11976. return this.textField.leading;
  11977. },function(value){
  11978. this.textField.leading=value;
  11979. });
  11980. __getset(0,__proto,'fontSize',function(){
  11981. return this.textField.fontSize;
  11982. },function(value){
  11983. this.textField.fontSize=value;
  11984. });
  11985. __getset(0,__proto,'valign',function(){
  11986. return this.textField.valign;
  11987. },function(value){
  11988. this.textField.valign=value;
  11989. });
  11990. __getset(0,__proto,'italic',function(){
  11991. return this.textField.italic;
  11992. },function(value){
  11993. this.textField.italic=value;
  11994. });
  11995. __getset(0,__proto,'underline',function(){
  11996. return this.textField.underline;
  11997. },function(value){
  11998. this.textField.underline=value;
  11999. });
  12000. __getset(0,__proto,'singleLine',function(){
  12001. return this._singleLine;
  12002. },function(value){
  12003. this._singleLine=value;
  12004. this.textField.wordWrap=!this._widthAutoSize && !this._singleLine;
  12005. });
  12006. __getset(0,__proto,'stroke',function(){
  12007. return this.textField.stroke;
  12008. },function(value){
  12009. this.textField.stroke=value;
  12010. });
  12011. __getset(0,__proto,'strokeColor',function(){
  12012. return this.textField.strokeColor;
  12013. },function(value){
  12014. this.textField.strokeColor=value;
  12015. this.updateGear(4);
  12016. });
  12017. __getset(0,__proto,'ubbEnabled',function(){
  12018. return this._ubbEnabled;
  12019. },function(value){
  12020. this._ubbEnabled=value;
  12021. });
  12022. __getset(0,__proto,'autoSize',function(){
  12023. return this._autoSize;
  12024. },function(value){
  12025. if (this._autoSize !=value){
  12026. this.setAutoSize(value);
  12027. }
  12028. });
  12029. __getset(0,__proto,'textWidth',function(){
  12030. if (this.textField["_isChanged"])
  12031. this.textField.typeset();
  12032. return this._textWidth;
  12033. });
  12034. __getset(0,__proto,'textHeight',function(){
  12035. if (this.textField["_isChanged"])
  12036. this.textField.typeset();
  12037. return this._textHeight;
  12038. });
  12039. GBasicTextField.GUTTER_X=2;
  12040. GBasicTextField.GUTTER_Y=2;
  12041. GBasicTextField.__init$=function(){
  12042. //class LineInfo
  12043. LineInfo=(function(){
  12044. function LineInfo(){
  12045. this.width=0;
  12046. this.height=0;
  12047. this.textHeight=0;
  12048. this.text=null;
  12049. this.y=0;
  12050. }
  12051. __class(LineInfo,'');
  12052. LineInfo.borrow=function(){
  12053. if (LineInfo.pool.length){
  12054. var ret=LineInfo.pool.pop();
  12055. ret.width=0;
  12056. ret.height=0;
  12057. ret.textHeight=0;
  12058. ret.text=null;
  12059. ret.y=0;
  12060. return ret;
  12061. }
  12062. else
  12063. return new LineInfo();
  12064. }
  12065. LineInfo.returns=function(value){
  12066. LineInfo.pool.push(value);
  12067. }
  12068. LineInfo.returnList=function(value){
  12069. var length=value.length;
  12070. for (var i=0;i < length;i++){
  12071. var li=value[i];
  12072. LineInfo.pool.push(li);
  12073. }
  12074. value.length=0;
  12075. }
  12076. LineInfo.pool=[];
  12077. return LineInfo;
  12078. })()
  12079. //class TextExt extends laya.display.Text
  12080. TextExt=(function(_super){
  12081. function TextExt(owner){
  12082. this._owner=null;
  12083. this._lock=false;
  12084. this._sizeDirty=false;
  12085. TextExt.__super.call(this);
  12086. this._owner=owner;
  12087. }
  12088. __class(TextExt,'',_super);
  12089. var __proto=TextExt.prototype;
  12090. __proto.baseTypeset=function(){
  12091. this._lock=true;
  12092. this.typeset();
  12093. this._lock=false;
  12094. }
  12095. __proto.typeset=function(){
  12096. this._sizeDirty=true;
  12097. _super.prototype.typeset.call(this);
  12098. if(!this._lock)
  12099. this._owner.typeset();
  12100. if(this._isChanged){
  12101. Laya.timer.clear(this,this.typeset);
  12102. this._isChanged=false;
  12103. }
  12104. this._sizeDirty=false;
  12105. }
  12106. __proto.setChanged=function(){
  12107. this.isChanged=true;
  12108. }
  12109. __getset(0,__proto,'isChanged',null,function(value){
  12110. if (value && !this._sizeDirty){
  12111. if(this._owner.autoSize!=0 && this._owner.parent){
  12112. this._sizeDirty=true;
  12113. this.event("fui_size_delay_change");
  12114. }
  12115. }
  12116. Laya.superSet(Text,this,'isChanged',value);
  12117. });
  12118. return TextExt;
  12119. })(Text)
  12120. }
  12121. return GBasicTextField;
  12122. })(GTextField)
  12123. //class fairygui.GButton extends fairygui.GComponent
  12124. var GButton=(function(_super){
  12125. function GButton(){
  12126. this._titleObject=null;
  12127. this._iconObject=null;
  12128. this._relatedController=null;
  12129. this._mode=0;
  12130. this._selected=false;
  12131. this._title=null;
  12132. this._selectedTitle=null;
  12133. this._icon=null;
  12134. this._selectedIcon=null;
  12135. this._sound=null;
  12136. this._soundVolumeScale=0;
  12137. this._pageOption=null;
  12138. this._buttonController=null;
  12139. this._changeStateOnClick=false;
  12140. this._linkedPopup=null;
  12141. this._downEffect=0;
  12142. this._downEffectValue=0;
  12143. this._downScaled=false;
  12144. this._down=false;
  12145. this._over=false;
  12146. GButton.__super.call(this);
  12147. this._mode=0;
  12148. this._title="";
  12149. this._icon="";
  12150. this._sound=UIConfig$1.buttonSound;
  12151. this._soundVolumeScale=UIConfig$1.buttonSoundVolumeScale;
  12152. this._pageOption=new PageOption();
  12153. this._changeStateOnClick=true;
  12154. this._downEffectValue=0.8;
  12155. }
  12156. __class(GButton,'fairygui.GButton',_super);
  12157. var __proto=GButton.prototype;
  12158. __proto.getTextField=function(){
  12159. if ((this._titleObject instanceof fairygui.GTextField ))
  12160. return this._titleObject;
  12161. else if ((this._titleObject instanceof fairygui.GLabel ))
  12162. return (this._titleObject).getTextField();
  12163. else if ((this._titleObject instanceof fairygui.GButton ))
  12164. return (this._titleObject).getTextField();
  12165. else
  12166. return null;
  12167. }
  12168. __proto.fireClick=function(downEffect){
  12169. (downEffect===void 0)&& (downEffect=true);
  12170. if (downEffect && this._mode==0){
  12171. this.setState("over");
  12172. Laya.timer.once(100,this,this.setState,["down"],false);
  12173. Laya.timer.once(200,this,this.setState,["up"],false);
  12174. }
  12175. this.__click(Events.createEvent("click",this.displayObject));
  12176. }
  12177. __proto.setState=function(val){
  12178. if (this._buttonController)
  12179. this._buttonController.selectedPage=val;
  12180. if(this._downEffect==1){
  12181. var cnt=this.numChildren;
  12182. if(val=="down" || val=="selectedOver" || val=="selectedDisabled"){
  12183. var r=this._downEffectValue *255;
  12184. var color=Utils.toHexColor((r << 16)+(r << 8)+r);
  12185. for(var i=0;i < cnt;i++){
  12186. var obj=this.getChildAt(i);
  12187. if(((obj instanceof fairygui.GImage ))|| ((obj instanceof fairygui.GLoader ))
  12188. || ((obj instanceof fairygui.GMovieClip )))
  12189. (obj).color=color;
  12190. }
  12191. }
  12192. else {
  12193. for(i=0;i < cnt;i++){
  12194. obj=this.getChildAt(i);
  12195. if(((obj instanceof fairygui.GImage ))|| ((obj instanceof fairygui.GLoader ))
  12196. || ((obj instanceof fairygui.GMovieClip )))
  12197. (obj).color="#FFFFFF";
  12198. }
  12199. }
  12200. }
  12201. else if(this._downEffect==2){
  12202. if(val=="down" || val=="selectedOver" || val=="selectedDisabled"){
  12203. if(!this._downScaled){
  12204. this.setScale(this.scaleX*this._downEffectValue,this.scaleY*this._downEffectValue);
  12205. this._downScaled=true;
  12206. }
  12207. }
  12208. else{
  12209. if(this._downScaled){
  12210. this.setScale(this.scaleX/this._downEffectValue,this.scaleY/this._downEffectValue);
  12211. this._downScaled=false;
  12212. }
  12213. }
  12214. }
  12215. }
  12216. __proto.handleControllerChanged=function(c){
  12217. _super.prototype.handleControllerChanged.call(this,c);
  12218. if (this._relatedController==c)
  12219. this.selected=this._pageOption.id==c.selectedPageId;
  12220. }
  12221. __proto.handleGrayedChanged=function(){
  12222. if(this._buttonController && this._buttonController.hasPage("disabled")){
  12223. if(this.grayed){
  12224. if(this._selected && this._buttonController.hasPage("selectedDisabled"))
  12225. this.setState("selectedDisabled");
  12226. else
  12227. this.setState("disabled");
  12228. }
  12229. else if(this._selected)
  12230. this.setState("down");
  12231. else
  12232. this.setState("up");
  12233. }
  12234. else
  12235. _super.prototype.handleGrayedChanged.call(this);
  12236. }
  12237. __proto.constructExtension=function(buffer){
  12238. buffer.seek(0,6);
  12239. this._mode=buffer.readByte();
  12240. var str=buffer.readS();
  12241. if(str)
  12242. this._sound=str;
  12243. this._soundVolumeScale=buffer.getFloat32();
  12244. this._downEffect=buffer.readByte();
  12245. this._downEffectValue=buffer.getFloat32();
  12246. if(this._downEffect==2)
  12247. this.setPivot(0.5,0.5,this.pivotAsAnchor);
  12248. this._buttonController=this.getController("button");
  12249. this._titleObject=this.getChild("title");
  12250. this._iconObject=this.getChild("icon");
  12251. if (this._titleObject !=null)
  12252. this._title=this._titleObject.text;
  12253. if (this._iconObject !=null)
  12254. this._icon=this._iconObject.icon;
  12255. if (this._mode==0)
  12256. this.setState("up");
  12257. this.on("mouseover",this,this.__rollover);
  12258. this.on("mouseout",this,this.__rollout);
  12259. this.on("mousedown",this,this.__mousedown);
  12260. this.on("click",this,this.__click);
  12261. }
  12262. __proto.setup_afterAdd=function(buffer,beginPos){
  12263. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  12264. if (!buffer.seek(beginPos,6))
  12265. return;
  12266. if (buffer.readByte()!=this.packageItem.objectType)
  12267. return;
  12268. var str;
  12269. var iv=0;
  12270. str=buffer.readS();
  12271. if (str !=null)
  12272. this.title=str;
  12273. str=buffer.readS();
  12274. if (str !=null)
  12275. this.selectedTitle=str;
  12276. str=buffer.readS();
  12277. if (str !=null)
  12278. this.icon=str;
  12279. str=buffer.readS();
  12280. if (str !=null)
  12281. this.selectedIcon=str;
  12282. if (buffer.readBool())
  12283. this.titleColor=buffer.readColorS();
  12284. iv=buffer.getInt32();
  12285. if (iv !=0)
  12286. this.titleFontSize=iv;
  12287. iv=buffer.getInt16();
  12288. if (iv >=0)
  12289. this._relatedController=this.parent.getControllerAt(iv);
  12290. this.pageOption.id=buffer.readS();
  12291. str=buffer.readS();
  12292. if (str !=null)
  12293. this._sound=str;
  12294. if (buffer.readBool())
  12295. this._soundVolumeScale=buffer.getFloat32();
  12296. this.selected=buffer.readBool();
  12297. }
  12298. __proto.__rollover=function(){
  12299. if(!this._buttonController || !this._buttonController.hasPage("over"))
  12300. return;
  12301. this._over=true;
  12302. if (this._down)
  12303. return;
  12304. if(this.grayed && this._buttonController.hasPage("disabled"))
  12305. return;
  12306. this.setState(this._selected ? "selectedOver" :"over");
  12307. }
  12308. __proto.__rollout=function(){
  12309. if(!this._buttonController || !this._buttonController.hasPage("over"))
  12310. return;
  12311. this._over=false;
  12312. if (this._down)
  12313. return;
  12314. if(this.grayed && this._buttonController.hasPage("disabled"))
  12315. return;
  12316. this.setState(this._selected ? "down" :"up");
  12317. }
  12318. __proto.dispose=function(){
  12319. _super.prototype.dispose.call(this);
  12320. }
  12321. __proto.__mousedown=function(evt){
  12322. this._down=true;
  12323. GRoot.inst.checkPopups(evt.target);
  12324. Laya.stage.on("mouseup",this,this.__mouseup);
  12325. if(this._mode==0){
  12326. if(this.grayed && this._buttonController && this._buttonController.hasPage("disabled"))
  12327. this.setState("selectedDisabled");
  12328. else
  12329. this.setState("down");
  12330. }
  12331. if (this._linkedPopup !=null){
  12332. if ((this._linkedPopup instanceof fairygui.Window ))
  12333. (this._linkedPopup).toggleStatus();
  12334. else
  12335. this.root.togglePopup(this._linkedPopup,this);
  12336. }
  12337. }
  12338. __proto.__mouseup=function(){
  12339. if (this._down){
  12340. Laya.stage.off("mouseup",this,this.__mouseup);
  12341. this._down=false;
  12342. if(this._displayObject==null)
  12343. return;
  12344. if(this._mode==0){
  12345. if(this.grayed && this._buttonController && this._buttonController.hasPage("disabled"))
  12346. this.setState("disabled");
  12347. else if(this._over)
  12348. this.setState("over");
  12349. else
  12350. this.setState("up");
  12351. }
  12352. }
  12353. }
  12354. __proto.__click=function(evt){
  12355. if(this._sound&&UIConfig$1.buttonSoundVolumeScale!=0){
  12356. var pi=UIPackage.getItemByURL(this._sound);
  12357. if (pi)
  12358. GRoot.inst.playOneShotSound(pi.file);
  12359. else
  12360. GRoot.inst.playOneShotSound(this._sound);
  12361. }
  12362. if (this._mode==1){
  12363. if(this._changeStateOnClick){
  12364. this.selected=!this._selected;
  12365. Events.dispatch("fui_state_changed",this.displayObject,evt);
  12366. }
  12367. }
  12368. else if (this._mode==2){
  12369. if (this._changeStateOnClick && !this._selected){
  12370. this.selected=true;
  12371. Events.dispatch("fui_state_changed",this.displayObject,evt);
  12372. }
  12373. }
  12374. else{
  12375. if(this._relatedController)
  12376. this._relatedController.selectedPageId=this._pageOption.id;
  12377. }
  12378. }
  12379. __getset(0,__proto,'relatedController',function(){
  12380. return this._relatedController;
  12381. },function(val){
  12382. if (val !=this._relatedController){
  12383. this._relatedController=val;
  12384. this._pageOption.controller=val;
  12385. this._pageOption.clear();
  12386. }
  12387. });
  12388. __getset(0,__proto,'icon',function(){
  12389. return this._icon;
  12390. },function(value){
  12391. this._icon=value;
  12392. value=(this._selected && this._selectedIcon)? this._selectedIcon :this._icon;
  12393. if(this._iconObject!=null)
  12394. this._iconObject.icon=value;
  12395. this.updateGear(7);
  12396. });
  12397. __getset(0,__proto,'titleFontSize',function(){
  12398. var tf=this.getTextField();
  12399. if(tf!=null)
  12400. return tf.fontSize;
  12401. else
  12402. return 0;
  12403. },function(value){
  12404. var tf=this.getTextField();
  12405. if(tf!=null)
  12406. tf.fontSize=value;
  12407. });
  12408. __getset(0,__proto,'selectedIcon',function(){
  12409. return this._selectedIcon;
  12410. },function(value){
  12411. this._selectedIcon=value;
  12412. value=(this._selected && this._selectedIcon)? this._selectedIcon :this._icon;
  12413. if(this._iconObject!=null)
  12414. this._iconObject.icon=value;
  12415. });
  12416. __getset(0,__proto,'title',function(){
  12417. return this._title;
  12418. },function(value){
  12419. this._title=value;
  12420. if (this._titleObject)
  12421. this._titleObject.text=(this._selected && this._selectedTitle)? this._selectedTitle :this._title;
  12422. this.updateGear(6);
  12423. });
  12424. __getset(0,__proto,'text',function(){
  12425. return this.title;
  12426. },function(value){
  12427. this.title=value;
  12428. });
  12429. __getset(0,__proto,'selectedTitle',function(){
  12430. return this._selectedTitle;
  12431. },function(value){
  12432. this._selectedTitle=value;
  12433. if (this._titleObject)
  12434. this._titleObject.text=(this._selected && this._selectedTitle)? this._selectedTitle :this._title;
  12435. });
  12436. __getset(0,__proto,'soundVolumeScale',function(){
  12437. return this._soundVolumeScale;
  12438. },function(value){
  12439. this._soundVolumeScale=value;
  12440. });
  12441. __getset(0,__proto,'sound',function(){
  12442. return this._sound;
  12443. },function(val){
  12444. this._sound=val;
  12445. });
  12446. __getset(0,__proto,'titleColor',function(){
  12447. var tf=this.getTextField();
  12448. if(tf!=null)
  12449. return tf.color;
  12450. else
  12451. return "#000000";
  12452. },function(value){
  12453. var tf=this.getTextField();
  12454. if(tf!=null)
  12455. tf.color=value;
  12456. this.updateGear(4);
  12457. });
  12458. __getset(0,__proto,'selected',function(){
  12459. return this._selected;
  12460. },function(val){
  12461. if (this._mode==0)
  12462. return;
  12463. if (this._selected !=val){
  12464. this._selected=val;
  12465. if(this.grayed && this._buttonController && this._buttonController.hasPage("disabled")){
  12466. if(this._selected)
  12467. this.setState("selectedDisabled");
  12468. else
  12469. this.setState("disabled");
  12470. }
  12471. else {
  12472. if(this._selected)
  12473. this.setState(this._over ? "selectedOver" :"down");
  12474. else
  12475. this.setState(this._over ? "over" :"up");
  12476. }
  12477. if(this._selectedTitle && this._titleObject)
  12478. this._titleObject.text=this._selected ? this._selectedTitle :this._title;
  12479. if(this._selectedIcon){
  12480. var str=this._selected ? this._selectedIcon :this._icon;
  12481. if(this._iconObject!=null)
  12482. this._iconObject.icon=str;
  12483. }
  12484. if(this._relatedController
  12485. && this._parent
  12486. && !this._parent._buildingDisplayList){
  12487. if(this._selected){
  12488. this._relatedController.selectedPageId=this._pageOption.id;
  12489. if(this._relatedController.autoRadioGroupDepth)
  12490. this._parent.adjustRadioGroupDepth(this,this._relatedController);
  12491. }
  12492. else if(this._mode==1 && this._relatedController.selectedPageId==this._pageOption.id)
  12493. this._relatedController.oppositePageId=this._pageOption.id;
  12494. }
  12495. }
  12496. });
  12497. /**
  12498. *@see ButtonMode
  12499. */
  12500. /**
  12501. *@see ButtonMode
  12502. */
  12503. __getset(0,__proto,'mode',function(){
  12504. return this._mode;
  12505. },function(value){
  12506. if (this._mode !=value){
  12507. if (value==0)
  12508. this.selected=false;
  12509. this._mode=value;
  12510. }
  12511. });
  12512. __getset(0,__proto,'pageOption',function(){
  12513. return this._pageOption;
  12514. });
  12515. __getset(0,__proto,'changeStateOnClick',function(){
  12516. return this._changeStateOnClick;
  12517. },function(value){
  12518. this._changeStateOnClick=value;
  12519. });
  12520. __getset(0,__proto,'linkedPopup',function(){
  12521. return this._linkedPopup;
  12522. },function(value){
  12523. this._linkedPopup=value;
  12524. });
  12525. GButton.UP="up";
  12526. GButton.DOWN="down";
  12527. GButton.OVER="over";
  12528. GButton.SELECTED_OVER="selectedOver";
  12529. GButton.DISABLED="disabled";
  12530. GButton.SELECTED_DISABLED="selectedDisabled";
  12531. return GButton;
  12532. })(GComponent)
  12533. //class fairygui.GComboBox extends fairygui.GComponent
  12534. var GComboBox=(function(_super){
  12535. function GComboBox(){
  12536. this.dropdown=null;
  12537. this._titleObject=null;
  12538. this._iconObject=null;
  12539. this._list=null;
  12540. this._items=null;
  12541. this._icons=null;
  12542. this._values=null;
  12543. this._popupDirection=0;
  12544. this._visibleItemCount=0;
  12545. this._itemsUpdated=false;
  12546. this._selectedIndex=0;
  12547. this._buttonController=null;
  12548. this._selectionController=null;
  12549. this._down=false;
  12550. this._over=false;
  12551. GComboBox.__super.call(this);
  12552. this._visibleItemCount=UIConfig$1.defaultComboBoxVisibleItemCount;
  12553. this._itemsUpdated=true;
  12554. this._selectedIndex=-1;
  12555. this._items=[];
  12556. this._values=[];
  12557. }
  12558. __class(GComboBox,'fairygui.GComboBox',_super);
  12559. var __proto=GComboBox.prototype;
  12560. __proto.getTextField=function(){
  12561. if ((this._titleObject instanceof fairygui.GTextField ))
  12562. return this._titleObject;
  12563. else if ((this._titleObject instanceof fairygui.GLabel ))
  12564. return (this._titleObject).getTextField();
  12565. else if ((this._titleObject instanceof fairygui.GButton ))
  12566. return (this._titleObject).getTextField();
  12567. else
  12568. return null;
  12569. }
  12570. __proto.setState=function(val){
  12571. if (this._buttonController)
  12572. this._buttonController.selectedPage=val;
  12573. }
  12574. __proto.handleControllerChanged=function(c){
  12575. _super.prototype.handleControllerChanged.call(this,c);
  12576. if (this._selectionController==c)
  12577. this.selectedIndex=c.selectedIndex;
  12578. }
  12579. __proto.updateSelectionController=function(){
  12580. if (this._selectionController !=null && !this._selectionController.changing
  12581. && this._selectedIndex < this._selectionController.pageCount){
  12582. var c=this._selectionController;
  12583. this._selectionController=null;
  12584. c.selectedIndex=this._selectedIndex;
  12585. this._selectionController=c;
  12586. }
  12587. }
  12588. __proto.dispose=function(){
  12589. if(this.dropdown){
  12590. this.dropdown.dispose();
  12591. this.dropdown=null;
  12592. }
  12593. this._selectionController=null;
  12594. _super.prototype.dispose.call(this);
  12595. }
  12596. __proto.constructExtension=function(buffer){
  12597. var str;
  12598. this._buttonController=this.getController("button");
  12599. this._titleObject=this.getChild("title");
  12600. this._iconObject=this.getChild("icon");
  12601. str=buffer.readS();
  12602. if (str){
  12603. this.dropdown=(UIPackage.createObjectFromURL(str));
  12604. if (!this.dropdown){
  12605. Log.print("下拉框必须为元件");
  12606. return;
  12607. }
  12608. this.dropdown.name="this._dropdownObject";
  12609. this._list=this.dropdown.getChild("list").asList;
  12610. if (this._list==null){
  12611. Log.print(this.resourceURL+": 下拉框的弹出元件里必须包含名为list的列表");
  12612. return;
  12613. }
  12614. this._list.on("fui_click_item",this,this.__clickItem);
  12615. this._list.addRelation(this.dropdown,14);
  12616. this._list.removeRelation(this.dropdown,15);
  12617. this.dropdown.addRelation(this._list,15);
  12618. this.dropdown.removeRelation(this._list,14);
  12619. this.dropdown.displayObject.on("undisplay",this,this.__popupWinClosed);
  12620. }
  12621. this.on("mouseover",this,this.__rollover);
  12622. this.on("mouseout",this,this.__rollout);
  12623. this.on("mousedown",this,this.__mousedown);
  12624. }
  12625. __proto.setup_afterAdd=function(buffer,beginPos){
  12626. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  12627. if (!buffer.seek(beginPos,6))
  12628. return;
  12629. if (buffer.readByte()!=this.packageItem.objectType)
  12630. return;
  12631. var i=0;
  12632. var iv=0;
  12633. var nextPos=0;
  12634. var str;
  12635. var itemCount=buffer.getInt16();
  12636. for (i=0;i < itemCount;i++){
  12637. nextPos=buffer.getInt16();
  12638. nextPos+=buffer.pos;
  12639. this._items[i]=buffer.readS();
  12640. this._values[i]=buffer.readS();
  12641. str=buffer.readS();
  12642. if (str !=null){
  12643. if (this._icons==null)
  12644. this._icons=[];
  12645. this._icons[i]=str;
  12646. }
  12647. buffer.pos=nextPos;
  12648. }
  12649. str=buffer.readS();
  12650. if (str !=null){
  12651. this.text=str;
  12652. this._selectedIndex=this._items.indexOf(str);
  12653. }
  12654. else if (this._items.length > 0){
  12655. this._selectedIndex=0;
  12656. this.text=this._items[0];
  12657. }
  12658. else
  12659. this._selectedIndex=-1;
  12660. str=buffer.readS();
  12661. if (str !=null)
  12662. this.icon=str;
  12663. if (buffer.readBool())
  12664. this.titleColor=buffer.readColorS();
  12665. iv=buffer.getInt32();
  12666. if (iv > 0)
  12667. this._visibleItemCount=iv;
  12668. this._popupDirection=buffer.readByte();
  12669. iv=buffer.getInt16();
  12670. if (iv >=0)
  12671. this._selectionController=this.parent.getControllerAt(iv);
  12672. }
  12673. __proto.showDropdown=function(){
  12674. if (this._itemsUpdated){
  12675. this._itemsUpdated=false;
  12676. this._list.removeChildrenToPool();
  12677. var cnt=this._items.length;
  12678. for (var i=0;i < cnt;i++){
  12679. var item=this._list.addItemFromPool();
  12680. item.name=i < this._values.length ? this._values[i] :"";
  12681. item.text=this._items[i];
  12682. item.icon=(this._icons !=null && i < this._icons.length)? this._icons[i] :null;
  12683. }
  12684. this._list.resizeToFit(this._visibleItemCount);
  12685. }
  12686. this._list.selectedIndex=this._selectedIndex;
  12687. this.dropdown.width=this.width;
  12688. var downward=null;
  12689. if (this._popupDirection==2)
  12690. downward=true;
  12691. else if (this._popupDirection==1)
  12692. downward=false;
  12693. this.root.togglePopup(this.dropdown,this,downward);
  12694. if (this.dropdown.parent)
  12695. this.setState("down");
  12696. }
  12697. __proto.__popupWinClosed=function(){
  12698. if(this._over)
  12699. this.setState("over");
  12700. else
  12701. this.setState("up");
  12702. }
  12703. __proto.__clickItem=function(itemObject,evt){
  12704. Laya.timer.callLater(this,this.__clickItem2,[this._list.getChildIndex(itemObject),evt])
  12705. }
  12706. __proto.__clickItem2=function(index,evt){
  12707. if ((this.dropdown.parent instanceof fairygui.GRoot ))
  12708. (this.dropdown.parent).hidePopup();
  12709. this._selectedIndex=-1;
  12710. this.selectedIndex=index;
  12711. Events.dispatch("fui_state_changed",this.displayObject,evt);
  12712. }
  12713. __proto.__rollover=function(){
  12714. this._over=true;
  12715. if (this._down || this.dropdown && this.dropdown.parent)
  12716. return;
  12717. this.setState("over");
  12718. }
  12719. __proto.__rollout=function(){
  12720. this._over=false;
  12721. if (this._down || this.dropdown && this.dropdown.parent)
  12722. return;
  12723. this.setState("up");
  12724. }
  12725. __proto.__mousedown=function(evt){
  12726. if((evt.target instanceof laya.display.Input ))
  12727. return;
  12728. this._down=true;
  12729. GRoot.inst.checkPopups(evt.target);
  12730. Laya.stage.on("mouseup",this,this.__mouseup);
  12731. if (this.dropdown)
  12732. this.showDropdown();
  12733. }
  12734. __proto.__mouseup=function(){
  12735. if(this._down){
  12736. this._down=false;
  12737. Laya.stage.off("mouseup",this,this.__mouseup);
  12738. if(this.dropdown && !this.dropdown.parent){
  12739. if(this._over)
  12740. this.setState("over");
  12741. else
  12742. this.setState("up");
  12743. }
  12744. }
  12745. }
  12746. __getset(0,__proto,'text',function(){
  12747. if (this._titleObject)
  12748. return this._titleObject.text;
  12749. else
  12750. return null;
  12751. },function(value){
  12752. if (this._titleObject)
  12753. this._titleObject.text=value;
  12754. this.updateGear(6);
  12755. });
  12756. __getset(0,__proto,'titleColor',function(){
  12757. var tf=this.getTextField();
  12758. if(tf!=null)
  12759. return tf.color;
  12760. else
  12761. return "#000000";
  12762. },function(value){
  12763. var tf=this.getTextField();
  12764. if(tf!=null)
  12765. tf.color=value;
  12766. this.updateGear(4);
  12767. });
  12768. __getset(0,__proto,'titleFontSize',function(){
  12769. var tf=this.getTextField();
  12770. if(tf!=null)
  12771. return tf.fontSize;
  12772. else
  12773. return 0;
  12774. },function(value){
  12775. var tf=this.getTextField();
  12776. if(tf!=null)
  12777. tf.fontSize=value;
  12778. });
  12779. __getset(0,__proto,'icon',function(){
  12780. if(this._iconObject)
  12781. return this._iconObject.icon;
  12782. else
  12783. return null;
  12784. },function(value){
  12785. if(this._iconObject)
  12786. this._iconObject.icon=value;
  12787. this.updateGear(7);
  12788. });
  12789. __getset(0,__proto,'icons',function(){
  12790. return this._icons;
  12791. },function(value){
  12792. this._icons=value;
  12793. if (this._icons !=null && this._selectedIndex !=-1 && this._selectedIndex < this._icons.length)
  12794. this.icon=this._icons[this._selectedIndex];
  12795. });
  12796. __getset(0,__proto,'selectionController',function(){
  12797. return this._selectionController;
  12798. },function(value){
  12799. this._selectionController=value;
  12800. });
  12801. __getset(0,__proto,'visibleItemCount',function(){
  12802. return this._visibleItemCount;
  12803. },function(value){
  12804. this._visibleItemCount=value;
  12805. });
  12806. /**
  12807. *@see PopupDirection
  12808. */
  12809. /**
  12810. *@see PopupDirection
  12811. */
  12812. __getset(0,__proto,'popupDirection',function(){
  12813. return this._popupDirection;
  12814. },function(value){
  12815. this._popupDirection=value;
  12816. });
  12817. __getset(0,__proto,'items',function(){
  12818. return this._items;
  12819. },function(value){
  12820. if(!value)
  12821. this._items.length=0;
  12822. else
  12823. this._items=value.concat();
  12824. if(this._items.length>0){
  12825. if(this._selectedIndex>=this._items.length)
  12826. this._selectedIndex=this._items.length-1;
  12827. else if(this._selectedIndex==-1)
  12828. this._selectedIndex=0;
  12829. this.text=this._items[this._selectedIndex];
  12830. if (this._icons !=null && this._selectedIndex < this._icons.length)
  12831. this.icon=this._icons[this._selectedIndex];
  12832. }
  12833. else{
  12834. this.text="";
  12835. if (this._icons !=null)
  12836. this.icon=null;
  12837. this._selectedIndex=-1;
  12838. }
  12839. this._itemsUpdated=true;
  12840. });
  12841. __getset(0,__proto,'values',function(){
  12842. return this._values;
  12843. },function(value){
  12844. if (!value)
  12845. this._values.length=0;
  12846. else
  12847. this._values=value.concat();
  12848. });
  12849. __getset(0,__proto,'selectedIndex',function(){
  12850. return this._selectedIndex;
  12851. },function(val){
  12852. if(this._selectedIndex==val)
  12853. return;
  12854. this._selectedIndex=val;
  12855. if(this._selectedIndex>=0 && this._selectedIndex<this._items.length){
  12856. this.text=this._items[this._selectedIndex];
  12857. if (this._icons !=null && this._selectedIndex < this._icons.length)
  12858. this.icon=this._icons[this._selectedIndex];
  12859. }
  12860. else{
  12861. this.text="";
  12862. if (this._icons !=null)
  12863. this.icon=null;
  12864. }
  12865. this.updateSelectionController();
  12866. });
  12867. __getset(0,__proto,'value',function(){
  12868. return this._values[this._selectedIndex];
  12869. },function(val){
  12870. this.selectedIndex=this._values.indexOf(val);
  12871. });
  12872. return GComboBox;
  12873. })(GComponent)
  12874. //class fairygui.GLabel extends fairygui.GComponent
  12875. var GLabel=(function(_super){
  12876. function GLabel(){
  12877. this._titleObject=null;
  12878. this._iconObject=null;
  12879. GLabel.__super.call(this);
  12880. }
  12881. __class(GLabel,'fairygui.GLabel',_super);
  12882. var __proto=GLabel.prototype;
  12883. Laya.imps(__proto,{"fairygui.gears.IColorGear":true})
  12884. __proto.getTextField=function(){
  12885. if ((this._titleObject instanceof fairygui.GTextField ))
  12886. return this._titleObject;
  12887. else if ((this._titleObject instanceof fairygui.GLabel ))
  12888. return (this._titleObject).getTextField();
  12889. else if ((this._titleObject instanceof fairygui.GButton ))
  12890. return (this._titleObject).getTextField();
  12891. else
  12892. return null;
  12893. }
  12894. __proto.constructExtension=function(buffer){
  12895. this._titleObject=this.getChild("title");
  12896. this._iconObject=this.getChild("icon");
  12897. }
  12898. __proto.setup_afterAdd=function(buffer,beginPos){
  12899. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  12900. if (!buffer.seek(beginPos,6))
  12901. return;
  12902. if (buffer.readByte()!=this.packageItem.objectType)
  12903. return;
  12904. var str;
  12905. str=buffer.readS();
  12906. if (str !=null)
  12907. this.title=str;
  12908. str=buffer.readS();
  12909. if (str !=null)
  12910. this.icon=str;
  12911. if (buffer.readBool())
  12912. this.titleColor=buffer.readColorS();
  12913. var iv=buffer.getInt32();
  12914. if (iv !=0)
  12915. this.titleFontSize=iv;
  12916. if (buffer.readBool()){
  12917. var input=this.getTextField();
  12918. if (input !=null){
  12919. str=buffer.readS();
  12920. if (str !=null)
  12921. input.promptText=str;
  12922. str=buffer.readS();
  12923. if (str !=null)
  12924. input.restrict=str;
  12925. iv=buffer.getInt32();
  12926. if (iv !=0)
  12927. input.maxLength=iv;
  12928. iv=buffer.getInt32();
  12929. if (iv !=0){
  12930. if(iv==4)
  12931. input.keyboardType="number";
  12932. else if(iv==3)
  12933. input.keyboardType="url";
  12934. }
  12935. if (buffer.readBool())
  12936. input.password=true;
  12937. }
  12938. else
  12939. buffer.skip(13);
  12940. }
  12941. }
  12942. __getset(0,__proto,'color',function(){
  12943. return this.titleColor;
  12944. },function(value){
  12945. this.titleColor=value;
  12946. });
  12947. __getset(0,__proto,'icon',function(){
  12948. if(this._iconObject!=null)
  12949. return this._iconObject.icon;
  12950. else
  12951. return null;
  12952. },function(value){
  12953. if(this._iconObject!=null)
  12954. this._iconObject.icon=value;
  12955. this.updateGear(7);
  12956. });
  12957. __getset(0,__proto,'editable',function(){
  12958. if (this._titleObject && ((this._titleObject instanceof fairygui.GTextInput )))
  12959. return this._titleObject.asTextInput.editable;
  12960. else
  12961. return false;
  12962. },function(val){
  12963. if (this._titleObject)
  12964. this._titleObject.asTextInput.editable=val;
  12965. });
  12966. __getset(0,__proto,'title',function(){
  12967. if (this._titleObject)
  12968. return this._titleObject.text;
  12969. else
  12970. return null;
  12971. },function(value){
  12972. if (this._titleObject)
  12973. this._titleObject.text=value;
  12974. this.updateGear(6);
  12975. });
  12976. __getset(0,__proto,'text',function(){
  12977. return this.title;
  12978. },function(value){
  12979. this.title=value;
  12980. });
  12981. __getset(0,__proto,'titleColor',function(){
  12982. var tf=this.getTextField();
  12983. if(tf!=null)
  12984. return tf.color;
  12985. else
  12986. return "#000000";
  12987. },function(value){
  12988. var tf=this.getTextField();
  12989. if(tf!=null)
  12990. tf.color=value;
  12991. this.updateGear(4);
  12992. });
  12993. __getset(0,__proto,'titleFontSize',function(){
  12994. var tf=this.getTextField();
  12995. if(tf!=null)
  12996. return tf.fontSize;
  12997. else
  12998. return 0;
  12999. },function(value){
  13000. var tf=this.getTextField();
  13001. if(tf!=null)
  13002. tf.fontSize=value;
  13003. });
  13004. return GLabel;
  13005. })(GComponent)
  13006. //class fairygui.GList extends fairygui.GComponent
  13007. var GList=(function(_super){
  13008. var ItemInfo;
  13009. function GList(){
  13010. /**
  13011. *itemRenderer(int index,GObject item);
  13012. */
  13013. this.itemRenderer=null;
  13014. /**
  13015. *itemProvider(index:int):String;
  13016. */
  13017. this.itemProvider=null;
  13018. this.scrollItemToViewOnClick=false;
  13019. this.foldInvisibleItems=false;
  13020. this._layout=0;
  13021. this._lineCount=0;
  13022. this._columnCount=0;
  13023. this._lineGap=0;
  13024. this._columnGap=0;
  13025. this._defaultItem=null;
  13026. this._autoResizeItem=false;
  13027. this._selectionMode=0;
  13028. this._align=null;
  13029. this._verticalAlign=null;
  13030. this._selectionController=null;
  13031. this._lastSelectedIndex=0;
  13032. this._pool=null;
  13033. //Virtual List support
  13034. this._virtual=false;
  13035. this._loop=false;
  13036. this._numItems=0;
  13037. this._realNumItems=0;
  13038. this._firstIndex=0;
  13039. //the top left index
  13040. this._curLineItemCount=0;
  13041. //item count in one line
  13042. this._curLineItemCount2=0;
  13043. //只用在页面模式,表示垂直方向的项目数
  13044. this._itemSize=null;
  13045. this._virtualListChanged=0;
  13046. //1-content changed,2-size changed
  13047. this._virtualItems=null;
  13048. this._eventLocked=false;
  13049. this.itemInfoVer=0;
  13050. GList.__super.call(this);
  13051. this._trackBounds=true;
  13052. this._pool=new GObjectPool();
  13053. this._layout=0;
  13054. this._autoResizeItem=true;
  13055. this._lastSelectedIndex=-1;
  13056. this._selectionMode=0;
  13057. this.opaque=true;
  13058. this.scrollItemToViewOnClick=true;
  13059. this._align="left";
  13060. this._verticalAlign="top";
  13061. this._container=new Sprite();
  13062. this._displayObject.addChild(this._container);
  13063. }
  13064. __class(GList,'fairygui.GList',_super);
  13065. var __proto=GList.prototype;
  13066. __proto.dispose=function(){
  13067. this._pool.clear();
  13068. _super.prototype.dispose.call(this);
  13069. }
  13070. __proto.getFromPool=function(url){
  13071. if (!url)
  13072. url=this._defaultItem;
  13073. var obj=this._pool.getObject(url);
  13074. if(obj!=null)
  13075. obj.visible=true;
  13076. return obj;
  13077. }
  13078. __proto.returnToPool=function(obj){
  13079. obj.displayObject.cacheAs="none";
  13080. this._pool.returnObject(obj);
  13081. }
  13082. __proto.addChildAt=function(child,index){
  13083. (index===void 0)&& (index=0);
  13084. _super.prototype.addChildAt.call(this,child,index);
  13085. if ((child instanceof fairygui.GButton )){
  13086. var button=(child);
  13087. button.selected=false;
  13088. button.changeStateOnClick=false;
  13089. }
  13090. child.on("click",this,this.__clickItem);
  13091. return child;
  13092. }
  13093. __proto.addItem=function(url){
  13094. if (!url)
  13095. url=this._defaultItem;
  13096. return this.addChild(UIPackage.createObjectFromURL(url));
  13097. }
  13098. __proto.addItemFromPool=function(url){
  13099. return this.addChild(this.getFromPool(url));
  13100. }
  13101. __proto.removeChildAt=function(index,dispose){
  13102. (dispose===void 0)&& (dispose=false);
  13103. var child=_super.prototype.removeChildAt.call(this,index,dispose);
  13104. child.off("click",this,this.__clickItem);
  13105. return child;
  13106. }
  13107. __proto.removeChildToPoolAt=function(index){
  13108. (index===void 0)&& (index=0);
  13109. var child=_super.prototype.removeChildAt.call(this,index);
  13110. this.returnToPool(child);
  13111. }
  13112. __proto.removeChildToPool=function(child){
  13113. this.removeChild(child);
  13114. this.returnToPool(child);
  13115. }
  13116. __proto.removeChildrenToPool=function(beginIndex,endIndex){
  13117. (beginIndex===void 0)&& (beginIndex=0);
  13118. (endIndex===void 0)&& (endIndex=-1);
  13119. if (endIndex < 0 || endIndex >=this._children.length)
  13120. endIndex=this._children.length-1;
  13121. for (var i=beginIndex;i <=endIndex;++i)
  13122. this.removeChildToPoolAt(beginIndex);
  13123. }
  13124. __proto.getSelection=function(){
  13125. var ret=[];
  13126. var i=0;
  13127. if (this._virtual){
  13128. for (i=0;i < this._realNumItems;i++){
  13129. var ii=this._virtualItems[i];
  13130. if (((ii.obj instanceof fairygui.GButton ))&& (ii.obj).selected
  13131. || ii.obj==null && ii.selected){
  13132. var j=i;
  13133. if (this._loop){
  13134. j=i % this._numItems;
  13135. if (ret.indexOf(j)!=-1)
  13136. continue ;
  13137. }
  13138. ret.push(j);
  13139. }
  13140. }
  13141. }
  13142. else{
  13143. var cnt=this._children.length;
  13144. for (i=0;i < cnt;i++){
  13145. var obj=this._children[i].asButton;
  13146. if (obj !=null && obj.selected)
  13147. ret.push(i);
  13148. }
  13149. }
  13150. return ret;
  13151. }
  13152. __proto.addSelection=function(index,scrollItToView){
  13153. (scrollItToView===void 0)&& (scrollItToView=false);
  13154. if(this._selectionMode==3)
  13155. return;
  13156. this.checkVirtualList();
  13157. if(this._selectionMode==0)
  13158. this.clearSelection();
  13159. if (scrollItToView)
  13160. this.scrollToView(index);
  13161. this._lastSelectedIndex=index;
  13162. var obj=null;
  13163. if (this._virtual){
  13164. var ii=this._virtualItems[index];
  13165. if (ii.obj !=null)
  13166. obj=ii.obj.asButton;
  13167. ii.selected=true;
  13168. }
  13169. else
  13170. obj=this.getChildAt(index).asButton;
  13171. if (obj !=null && !obj.selected){
  13172. obj.selected=true;
  13173. this.updateSelectionController(index);
  13174. }
  13175. }
  13176. __proto.removeSelection=function(index){
  13177. if(this._selectionMode==3)
  13178. return;
  13179. var obj=null;
  13180. if (this._virtual){
  13181. var ii=this._virtualItems[index];
  13182. if (ii.obj !=null)
  13183. obj=ii.obj.asButton;
  13184. ii.selected=false;
  13185. }
  13186. else
  13187. obj=this.getChildAt(index).asButton;
  13188. if (obj !=null)
  13189. obj.selected=false;
  13190. }
  13191. __proto.clearSelection=function(){
  13192. var i=0;
  13193. if (this._virtual){
  13194. for (i=0;i < this._realNumItems;i++){
  13195. var ii=this._virtualItems[i];
  13196. if ((ii.obj instanceof fairygui.GButton ))
  13197. (ii.obj).selected=false;
  13198. ii.selected=false;
  13199. }
  13200. }
  13201. else{
  13202. var cnt=this._children.length;
  13203. for (i=0;i < cnt;i++){
  13204. var obj=this._children[i].asButton;
  13205. if (obj !=null)
  13206. obj.selected=false;
  13207. }
  13208. }
  13209. }
  13210. __proto.clearSelectionExcept=function(g){
  13211. var i=0;
  13212. if (this._virtual){
  13213. for (i=0;i < this._realNumItems;i++){
  13214. var ii=this._virtualItems[i];
  13215. if (ii.obj !=g){
  13216. if (((ii.obj instanceof fairygui.GButton )))
  13217. (ii.obj).selected=false;
  13218. ii.selected=false;
  13219. }
  13220. }
  13221. }
  13222. else{
  13223. var cnt=this._children.length;
  13224. for (i=0;i < cnt;i++){
  13225. var obj=this._children[i].asButton;
  13226. if (obj !=null && obj !=g)
  13227. obj.selected=false;
  13228. }
  13229. }
  13230. }
  13231. __proto.selectAll=function(){
  13232. this.checkVirtualList();
  13233. var last=-1;
  13234. var i=0;
  13235. if (this._virtual){
  13236. for (i=0;i < this._realNumItems;i++){
  13237. var ii=this._virtualItems[i];
  13238. if (((ii.obj instanceof fairygui.GButton ))&& !(ii.obj).selected){
  13239. (ii.obj).selected=true;
  13240. last=i;
  13241. }
  13242. ii.selected=true;
  13243. }
  13244. }
  13245. else{
  13246. var cnt=this._children.length;
  13247. for (i=0;i < cnt;i++){
  13248. var obj=this._children[i].asButton;
  13249. if (obj !=null && !obj.selected){
  13250. obj.selected=true;
  13251. last=i;
  13252. }
  13253. }
  13254. }
  13255. if(last!=-1)
  13256. this.updateSelectionController(last);
  13257. }
  13258. __proto.selectNone=function(){
  13259. this.clearSelection();
  13260. }
  13261. __proto.selectReverse=function(){
  13262. this.checkVirtualList();
  13263. var last=-1;
  13264. var i=0;
  13265. if (this._virtual){
  13266. for (i=0;i < this._realNumItems;i++){
  13267. var ii=this._virtualItems[i];
  13268. if ((ii.obj instanceof fairygui.GButton )){
  13269. (ii.obj).selected=!(ii.obj).selected;
  13270. if ((ii.obj).selected)
  13271. last=i;
  13272. }
  13273. ii.selected=!ii.selected;
  13274. }
  13275. }
  13276. else{
  13277. var cnt=this._children.length;
  13278. for (i=0;i < cnt;i++){
  13279. var obj=this._children[i].asButton;
  13280. if (obj !=null){
  13281. obj.selected=!obj.selected;
  13282. if (obj.selected)
  13283. last=i;
  13284. }
  13285. }
  13286. }
  13287. if(last!=-1)
  13288. this.updateSelectionController(last);
  13289. }
  13290. __proto.handleArrowKey=function(dir){
  13291. (dir===void 0)&& (dir=0);
  13292. var index=this.selectedIndex;
  13293. if (index==-1)
  13294. return;
  13295. switch (dir){
  13296. case 1:
  13297. if (this._layout==0 || this._layout==3){
  13298. index--;
  13299. if (index >=0){
  13300. this.clearSelection();
  13301. this.addSelection(index,true);
  13302. }
  13303. }
  13304. else if (this._layout==2 || this._layout==4){
  13305. var current=this._children[index];
  13306. var k=0;
  13307. for (var i=index-1;i >=0;i--){
  13308. var obj=this._children[i];
  13309. if (obj.y !=current.y){
  13310. current=obj;
  13311. break ;
  13312. }
  13313. k++;
  13314. }
  13315. for (;i >=0;i--){
  13316. obj=this._children[i];
  13317. if (obj.y !=current.y){
  13318. this.clearSelection();
  13319. this.addSelection(i+k+1,true);
  13320. break ;
  13321. }
  13322. }
  13323. }
  13324. break ;
  13325. case 3:
  13326. if (this._layout==1 || this._layout==2 || this._layout==4){
  13327. index++;
  13328. if (index < this._children.length){
  13329. this.clearSelection();
  13330. this.addSelection(index,true);
  13331. }
  13332. }
  13333. else if (this._layout==3){
  13334. current=this._children[index];
  13335. k=0;
  13336. var cnt=this._children.length;
  13337. for (i=index+1;i < cnt;i++){
  13338. obj=this._children[i];
  13339. if (obj.x !=current.x){
  13340. current=obj;
  13341. break ;
  13342. }
  13343. k++;
  13344. }
  13345. for (;i < cnt;i++){
  13346. obj=this._children[i];
  13347. if (obj.x !=current.x){
  13348. this.clearSelection();
  13349. this.addSelection(i-k-1,true);
  13350. break ;
  13351. }
  13352. }
  13353. }
  13354. break ;
  13355. case 5:
  13356. if (this._layout==0 || this._layout==3){
  13357. index++;
  13358. if (index < this._children.length){
  13359. this.clearSelection();
  13360. this.addSelection(index,true);
  13361. }
  13362. }
  13363. else if (this._layout==2 || this._layout==4){
  13364. current=this._children[index];
  13365. k=0;
  13366. cnt=this._children.length;
  13367. for (i=index+1;i < cnt;i++){
  13368. obj=this._children[i];
  13369. if (obj.y !=current.y){
  13370. current=obj;
  13371. break ;
  13372. }
  13373. k++;
  13374. }
  13375. for (;i < cnt;i++){
  13376. obj=this._children[i];
  13377. if (obj.y !=current.y){
  13378. this.clearSelection();
  13379. this.addSelection(i-k-1,true);
  13380. break ;
  13381. }
  13382. }
  13383. }
  13384. break ;
  13385. case 7:
  13386. if (this._layout==1 || this._layout==2 || this._layout==4){
  13387. index--;
  13388. if (index >=0){
  13389. this.clearSelection();
  13390. this.addSelection(index,true);
  13391. }
  13392. }
  13393. else if (this._layout==3){
  13394. current=this._children[index];
  13395. k=0;
  13396. for (i=index-1;i >=0;i--){
  13397. obj=this._children[i];
  13398. if (obj.x !=current.x){
  13399. current=obj;
  13400. break ;
  13401. }
  13402. k++;
  13403. }
  13404. for (;i >=0;i--){
  13405. obj=this._children[i];
  13406. if (obj.x !=current.x){
  13407. this.clearSelection();
  13408. this.addSelection(i+k+1,true);
  13409. break ;
  13410. }
  13411. }
  13412. }
  13413. break ;
  13414. }
  13415. }
  13416. __proto.__clickItem=function(evt){
  13417. if (this._scrollPane !=null && this._scrollPane.isDragged)
  13418. return;
  13419. var item=GObject.cast(evt.currentTarget);
  13420. this.setSelectionOnEvent(item,evt);
  13421. if(this._scrollPane && this.scrollItemToViewOnClick)
  13422. this._scrollPane.scrollToView(item,true);
  13423. this.displayObject.event("fui_click_item",[item,Events.createEvent("fui_click_item",this.displayObject,evt)]);
  13424. }
  13425. __proto.setSelectionOnEvent=function(item,evt){
  13426. if (!((item instanceof fairygui.GButton ))|| this._selectionMode==3)
  13427. return;
  13428. var dontChangeLastIndex=false;
  13429. var button=(item);
  13430. var index=this.childIndexToItemIndex(this.getChildIndex(item));
  13431. if (this._selectionMode==0){
  13432. if (!button.selected){
  13433. this.clearSelectionExcept(button);
  13434. button.selected=true;
  13435. }
  13436. }
  13437. else {
  13438. if (evt.shiftKey){
  13439. if (!button.selected){
  13440. if (this._lastSelectedIndex !=-1){
  13441. var min=Math.min(this._lastSelectedIndex,index);
  13442. var max=Math.max(this._lastSelectedIndex,index);
  13443. max=Math.min(max,this.numItems-1);
  13444. var i=0;
  13445. if (this._virtual){
  13446. for (i=min;i <=max;i++){
  13447. var ii=this._virtualItems[i];
  13448. if ((ii.obj instanceof fairygui.GButton ))
  13449. (ii.obj).selected=true;
  13450. ii.selected=true;
  13451. }
  13452. }
  13453. else{
  13454. for(i=min;i<=max;i++){
  13455. var obj=this.getChildAt(i).asButton;
  13456. if(obj!=null)
  13457. obj.selected=true;
  13458. }
  13459. }
  13460. dontChangeLastIndex=true;
  13461. }
  13462. else {
  13463. button.selected=true;
  13464. }
  13465. }
  13466. }
  13467. else if (evt.ctrlKey || this._selectionMode==2){
  13468. button.selected=!button.selected;
  13469. }
  13470. else {
  13471. if (!button.selected){
  13472. this.clearSelectionExcept(button);
  13473. button.selected=true;
  13474. }
  13475. else
  13476. this.clearSelectionExcept(button);
  13477. }
  13478. }
  13479. if (!dontChangeLastIndex)
  13480. this._lastSelectedIndex=index;
  13481. if(button.selected)
  13482. this.updateSelectionController(index);
  13483. }
  13484. __proto.resizeToFit=function(itemCount,minSize){
  13485. (itemCount===void 0)&& (itemCount=1000000);
  13486. (minSize===void 0)&& (minSize=0);
  13487. this.ensureBoundsCorrect();
  13488. var curCount=this.numItems;
  13489. if (itemCount > curCount)
  13490. itemCount=curCount;
  13491. if(this._virtual){
  13492. var lineCount=Math.ceil(itemCount / this._curLineItemCount);
  13493. if(this._layout==0 || this._layout==2)
  13494. this.viewHeight=lineCount *this._itemSize.y+Math.max(0,lineCount-1)*this._lineGap;
  13495. else
  13496. this.viewWidth=lineCount *this._itemSize.x+Math.max(0,lineCount-1)*this._columnGap;
  13497. }
  13498. else if(itemCount==0){
  13499. if (this._layout==0 || this._layout==2)
  13500. this.viewHeight=minSize;
  13501. else
  13502. this.viewWidth=minSize;
  13503. }
  13504. else {
  13505. var i=itemCount-1;
  13506. var obj=null;
  13507. while (i >=0){
  13508. obj=this.getChildAt(i);
  13509. if (!this.foldInvisibleItems || obj.visible)
  13510. break ;
  13511. i--;
  13512. }
  13513. if (i < 0){
  13514. if (this._layout==0 || this._layout==2)
  13515. this.viewHeight=minSize;
  13516. else
  13517. this.viewWidth=minSize;
  13518. }
  13519. else {
  13520. var size=0;
  13521. if (this._layout==0 || this._layout==2){
  13522. size=obj.y+obj.height;
  13523. if (size < minSize)
  13524. size=minSize;
  13525. this.viewHeight=size;
  13526. }
  13527. else {
  13528. size=obj.x+obj.width;
  13529. if (size < minSize)
  13530. size=minSize;
  13531. this.viewWidth=size;
  13532. }
  13533. }
  13534. }
  13535. }
  13536. __proto.getMaxItemWidth=function(){
  13537. var cnt=this._children.length;
  13538. var max=0;
  13539. for (var i=0;i < cnt;i++){
  13540. var child=this.getChildAt(i);
  13541. if (child.width > max)
  13542. max=child.width;
  13543. }
  13544. return max;
  13545. }
  13546. __proto.handleSizeChanged=function(){
  13547. _super.prototype.handleSizeChanged.call(this);
  13548. this.setBoundsChangedFlag();
  13549. if (this._virtual)
  13550. this.setVirtualListChangedFlag(true);
  13551. }
  13552. __proto.handleControllerChanged=function(c){
  13553. _super.prototype.handleControllerChanged.call(this,c);
  13554. if (this._selectionController==c)
  13555. this.selectedIndex=c.selectedIndex;
  13556. }
  13557. __proto.updateSelectionController=function(index){
  13558. if (this._selectionController !=null && !this._selectionController.changing
  13559. && index < this._selectionController.pageCount){
  13560. var c=this._selectionController;
  13561. this._selectionController=null;
  13562. c.selectedIndex=index;
  13563. this._selectionController=c;
  13564. }
  13565. }
  13566. __proto.getSnappingPosition=function(xValue,yValue,resultPoint){
  13567. if (this._virtual){
  13568. if(!resultPoint)
  13569. resultPoint=new Point();
  13570. var saved=NaN;
  13571. var index=0;
  13572. if (this._layout==0 || this._layout==2){
  13573. saved=yValue;
  13574. fairygui.GList.pos_param=yValue;
  13575. index=this.getIndexOnPos1(false);
  13576. yValue=fairygui.GList.pos_param;
  13577. if (index < this._virtualItems.length && saved-yValue > this._virtualItems[index].height / 2 && index < this._realNumItems)
  13578. yValue+=this._virtualItems[index].height+this._lineGap;
  13579. }
  13580. else if (this._layout==1 || this._layout==3){
  13581. saved=xValue;
  13582. fairygui.GList.pos_param=xValue;
  13583. index=this.getIndexOnPos2(false);
  13584. xValue=fairygui.GList.pos_param;
  13585. if (index < this._virtualItems.length && saved-xValue > this._virtualItems[index].width / 2 && index < this._realNumItems)
  13586. xValue+=this._virtualItems[index].width+this._columnGap;
  13587. }
  13588. else{
  13589. saved=xValue;
  13590. fairygui.GList.pos_param=xValue;
  13591. index=this.getIndexOnPos3(false);
  13592. xValue=fairygui.GList.pos_param;
  13593. if (index < this._virtualItems.length && saved-xValue > this._virtualItems[index].width / 2 && index < this._realNumItems)
  13594. xValue+=this._virtualItems[index].width+this._columnGap;
  13595. }
  13596. resultPoint.x=xValue;
  13597. resultPoint.y=yValue;
  13598. return resultPoint;
  13599. }
  13600. else
  13601. return _super.prototype.getSnappingPosition.call(this,xValue,yValue,resultPoint);
  13602. }
  13603. __proto.scrollToView=function(index,ani,setFirst){
  13604. (ani===void 0)&& (ani=false);
  13605. (setFirst===void 0)&& (setFirst=false);
  13606. if (this._virtual){
  13607. if(this._numItems==0)
  13608. return;
  13609. this.checkVirtualList();
  13610. if (index >=this._virtualItems.length)
  13611. throw new Error("Invalid child index: "+index+">"+this._virtualItems.length);
  13612. if(this._loop)
  13613. index=Math.floor(this._firstIndex/this._numItems)*this._numItems+index;
  13614. var rect;
  13615. var ii=this._virtualItems[index];
  13616. var pos=0;
  13617. var i=0;
  13618. if (this._layout==0 || this._layout==2){
  13619. for (i=this._curLineItemCount-1;i < index;i+=this._curLineItemCount)
  13620. pos+=this._virtualItems[i].height+this._lineGap;
  13621. rect=new Rectangle(0,pos,this._itemSize.x,ii.height);
  13622. }
  13623. else if (this._layout==1 || this._layout==3){
  13624. for (i=this._curLineItemCount-1;i < index;i+=this._curLineItemCount)
  13625. pos+=this._virtualItems[i].width+this._columnGap;
  13626. rect=new Rectangle(pos,0,ii.width,this._itemSize.y);
  13627. }
  13628. else{
  13629. var page=index / (this._curLineItemCount *this._curLineItemCount2);
  13630. rect=new Rectangle(page *this.viewWidth+(index % this._curLineItemCount)*(ii.width+this._columnGap),
  13631. (index / this._curLineItemCount)% this._curLineItemCount2 *(ii.height+this._lineGap),
  13632. ii.width,ii.height);
  13633. }
  13634. setFirst=true;
  13635. if (this._scrollPane !=null)
  13636. this._scrollPane.scrollToView(rect,ani,setFirst);
  13637. }
  13638. else{
  13639. var obj=this.getChildAt(index);
  13640. if (this._scrollPane !=null)
  13641. this._scrollPane.scrollToView(obj,ani,setFirst);
  13642. else if (this.parent !=null && this.parent.scrollPane !=null)
  13643. this.parent.scrollPane.scrollToView(obj,ani,setFirst);
  13644. }
  13645. }
  13646. __proto.getFirstChildInView=function(){
  13647. return this.childIndexToItemIndex(_super.prototype.getFirstChildInView.call(this));
  13648. }
  13649. __proto.childIndexToItemIndex=function(index){
  13650. if (!this._virtual)
  13651. return index;
  13652. if (this._layout==4){
  13653. for (var i=this._firstIndex;i < this._realNumItems;i++){
  13654. if (this._virtualItems[i].obj !=null){
  13655. index--;
  13656. if (index < 0)
  13657. return i;
  13658. }
  13659. }
  13660. return index;
  13661. }
  13662. else{
  13663. index+=this._firstIndex;
  13664. if (this._loop && this._numItems > 0)
  13665. index=index % this._numItems;
  13666. return index;
  13667. }
  13668. }
  13669. __proto.itemIndexToChildIndex=function(index){
  13670. if (!this._virtual)
  13671. return index;
  13672. if (this._layout==4){
  13673. return this.getChildIndex(this._virtualItems[index].obj);
  13674. }
  13675. else{
  13676. if (this._loop && this._numItems > 0){
  13677. var j=this._firstIndex % this._numItems;
  13678. if (index >=j)
  13679. index=index-j;
  13680. else
  13681. index=this._numItems-j+index;
  13682. }
  13683. else
  13684. index-=this._firstIndex;
  13685. return index;
  13686. }
  13687. }
  13688. __proto.setVirtual=function(){
  13689. this._setVirtual(false);
  13690. }
  13691. /**
  13692. *Set the list to be virtual list,and has loop behavior.
  13693. */
  13694. __proto.setVirtualAndLoop=function(){
  13695. this._setVirtual(true);
  13696. }
  13697. __proto._setVirtual=function(loop){
  13698. if(!this._virtual){
  13699. if(this._scrollPane==null)
  13700. throw new Error("Virtual list must be scrollable!");
  13701. if(loop){
  13702. if(this._layout==2 || this._layout==3)
  13703. throw new Error("Loop list is not supported for FlowHorizontal or FlowVertical layout!");
  13704. this._scrollPane.bouncebackEffect=false;
  13705. }
  13706. this._virtual=true;
  13707. this._loop=loop;
  13708. this._virtualItems=[];
  13709. this.removeChildrenToPool();
  13710. if(this._itemSize==null){
  13711. this._itemSize=new Point();
  13712. var obj=this.getFromPool(null);
  13713. if (obj==null){
  13714. throw new Error("Virtual List must have a default list item resource.");
  13715. }
  13716. else{
  13717. this._itemSize.x=obj.width;
  13718. this._itemSize.y=obj.height;
  13719. }
  13720. this.returnToPool(obj);
  13721. }
  13722. if(this._layout==0 || this._layout==2){
  13723. this._scrollPane.scrollStep=this._itemSize.y;
  13724. if(this._loop)
  13725. this._scrollPane._loop=2;
  13726. }
  13727. else{
  13728. this._scrollPane.scrollStep=this._itemSize.x;
  13729. if(this._loop)
  13730. this._scrollPane._loop=1;
  13731. }
  13732. this.on("fui_scroll",this,this.__scrolled);
  13733. this.setVirtualListChangedFlag(true);
  13734. }
  13735. }
  13736. __proto.refreshVirtualList=function(){
  13737. this.setVirtualListChangedFlag(false);
  13738. }
  13739. __proto.checkVirtualList=function(){
  13740. if(this._virtualListChanged!=0){
  13741. this._refreshVirtualList();
  13742. Laya.timer.clear(this,this._refreshVirtualList);
  13743. }
  13744. }
  13745. __proto.setVirtualListChangedFlag=function(layoutChanged){
  13746. (layoutChanged===void 0)&& (layoutChanged=false);
  13747. if(layoutChanged)
  13748. this._virtualListChanged=2;
  13749. else if(this._virtualListChanged==0)
  13750. this._virtualListChanged=1;
  13751. Laya.timer.callLater(this,this._refreshVirtualList);
  13752. }
  13753. __proto._refreshVirtualList=function(){
  13754. var layoutChanged=this._virtualListChanged==2;
  13755. this._virtualListChanged=0;
  13756. this._eventLocked=true;
  13757. if (layoutChanged){
  13758. if (this._layout==0 || this._layout==1)
  13759. this._curLineItemCount=1;
  13760. else if (this._layout==2){
  13761. if (this._columnCount > 0)
  13762. this._curLineItemCount=this._columnCount;
  13763. else{
  13764. this._curLineItemCount=Math.floor((this._scrollPane.viewWidth+this._columnGap)/ (this._itemSize.x+this._columnGap));
  13765. if (this._curLineItemCount <=0)
  13766. this._curLineItemCount=1;
  13767. }
  13768. }
  13769. else if (this._layout==3){
  13770. if (this._lineCount > 0)
  13771. this._curLineItemCount=this._lineCount;
  13772. else{
  13773. this._curLineItemCount=Math.floor((this._scrollPane.viewHeight+this._lineGap)/ (this._itemSize.y+this._lineGap));
  13774. if (this._curLineItemCount <=0)
  13775. this._curLineItemCount=1;
  13776. }
  13777. }
  13778. else{
  13779. if (this._columnCount > 0)
  13780. this._curLineItemCount=this._columnCount;
  13781. else{
  13782. this._curLineItemCount=Math.floor((this._scrollPane.viewWidth+this._columnGap)/ (this._itemSize.x+this._columnGap));
  13783. if (this._curLineItemCount <=0)
  13784. this._curLineItemCount=1;
  13785. }
  13786. if (this._lineCount > 0)
  13787. this._curLineItemCount2=this._lineCount;
  13788. else{
  13789. this._curLineItemCount2=Math.floor((this._scrollPane.viewHeight+this._lineGap)/ (this._itemSize.y+this._lineGap));
  13790. if (this._curLineItemCount2 <=0)
  13791. this._curLineItemCount2=1;
  13792. }
  13793. }
  13794. };
  13795. var ch=0,cw=0;
  13796. if (this._realNumItems > 0){
  13797. var i=0;
  13798. var len=Math.ceil(this._realNumItems / this._curLineItemCount)*this._curLineItemCount;
  13799. var len2=Math.min(this._curLineItemCount,this._realNumItems);
  13800. if (this._layout==0 || this._layout==2){
  13801. for (i=0;i < len;i+=this._curLineItemCount)
  13802. ch+=this._virtualItems[i].height+this._lineGap;
  13803. if (ch > 0)
  13804. ch-=this._lineGap;
  13805. if (this._autoResizeItem)
  13806. cw=this._scrollPane.viewWidth;
  13807. else{
  13808. for (i=0;i < len2;i++)
  13809. cw+=this._virtualItems[i].width+this._columnGap;
  13810. if (cw > 0)
  13811. cw-=this._columnGap;
  13812. }
  13813. }
  13814. else if (this._layout==1 || this._layout==3){
  13815. for (i=0;i < len;i+=this._curLineItemCount)
  13816. cw+=this._virtualItems[i].width+this._columnGap;
  13817. if (cw > 0)
  13818. cw-=this._columnGap;
  13819. if (this._autoResizeItem)
  13820. ch=this._scrollPane.viewHeight;
  13821. else{
  13822. for (i=0;i < len2;i++)
  13823. ch+=this._virtualItems[i].height+this._lineGap;
  13824. if (ch > 0)
  13825. ch-=this._lineGap;
  13826. }
  13827. }
  13828. else{
  13829. var pageCount=Math.ceil(len / (this._curLineItemCount *this._curLineItemCount2));
  13830. cw=pageCount *this.viewWidth;
  13831. ch=this.viewHeight;
  13832. }
  13833. }
  13834. this.handleAlign(cw,ch);
  13835. this._scrollPane.setContentSize(cw,ch);
  13836. this._eventLocked=false;
  13837. this.handleScroll(true);
  13838. }
  13839. __proto.__scrolled=function(evt){
  13840. this.handleScroll(false);
  13841. }
  13842. __proto.getIndexOnPos1=function(forceUpdate){
  13843. if (this._realNumItems < this._curLineItemCount){
  13844. GList.pos_param=0;
  13845. return 0;
  13846. };
  13847. var i=0;
  13848. var pos2=NaN;
  13849. var pos3=NaN;
  13850. if (this.numChildren > 0 && !forceUpdate){
  13851. pos2=this.getChildAt(0).y;
  13852. if (pos2 > GList.pos_param){
  13853. for (i=this._firstIndex-this._curLineItemCount;i >=0;i-=this._curLineItemCount){
  13854. pos2-=(this._virtualItems[i].height+this._lineGap);
  13855. if (pos2 <=GList.pos_param){
  13856. GList.pos_param=pos2;
  13857. return i;
  13858. }
  13859. }
  13860. GList.pos_param=0;
  13861. return 0;
  13862. }
  13863. else{
  13864. for (i=this._firstIndex;i < this._realNumItems;i+=this._curLineItemCount){
  13865. pos3=pos2+this._virtualItems[i].height+this._lineGap;
  13866. if (pos3 > GList.pos_param){
  13867. GList.pos_param=pos2;
  13868. return i;
  13869. }
  13870. pos2=pos3;
  13871. }
  13872. GList.pos_param=pos2;
  13873. return this._realNumItems-this._curLineItemCount;
  13874. }
  13875. }
  13876. else{
  13877. pos2=0;
  13878. for (i=0;i < this._realNumItems;i+=this._curLineItemCount){
  13879. pos3=pos2+this._virtualItems[i].height+this._lineGap;
  13880. if (pos3 > GList.pos_param){
  13881. GList.pos_param=pos2;
  13882. return i;
  13883. }
  13884. pos2=pos3;
  13885. }
  13886. GList.pos_param=pos2;
  13887. return this._realNumItems-this._curLineItemCount;
  13888. }
  13889. }
  13890. __proto.getIndexOnPos2=function(forceUpdate){
  13891. if (this._realNumItems < this._curLineItemCount){
  13892. GList.pos_param=0;
  13893. return 0;
  13894. };
  13895. var i=0;
  13896. var pos2=NaN;
  13897. var pos3=NaN;
  13898. if (this.numChildren > 0 && !forceUpdate){
  13899. pos2=this.getChildAt(0).x;
  13900. if (pos2 > GList.pos_param){
  13901. for (i=this._firstIndex-this._curLineItemCount;i >=0;i-=this._curLineItemCount){
  13902. pos2-=(this._virtualItems[i].width+this._columnGap);
  13903. if (pos2 <=GList.pos_param){
  13904. GList.pos_param=pos2;
  13905. return i;
  13906. }
  13907. }
  13908. GList.pos_param=0;
  13909. return 0;
  13910. }
  13911. else{
  13912. for (i=this._firstIndex;i < this._realNumItems;i+=this._curLineItemCount){
  13913. pos3=pos2+this._virtualItems[i].width+this._columnGap;
  13914. if (pos3 > GList.pos_param){
  13915. GList.pos_param=pos2;
  13916. return i;
  13917. }
  13918. pos2=pos3;
  13919. }
  13920. GList.pos_param=pos2;
  13921. return this._realNumItems-this._curLineItemCount;
  13922. }
  13923. }
  13924. else{
  13925. pos2=0;
  13926. for (i=0;i < this._realNumItems;i+=this._curLineItemCount){
  13927. pos3=pos2+this._virtualItems[i].width+this._columnGap;
  13928. if (pos3 > GList.pos_param){
  13929. GList.pos_param=pos2;
  13930. return i;
  13931. }
  13932. pos2=pos3;
  13933. }
  13934. GList.pos_param=pos2;
  13935. return this._realNumItems-this._curLineItemCount;
  13936. }
  13937. }
  13938. __proto.getIndexOnPos3=function(forceUpdate){
  13939. if (this._realNumItems < this._curLineItemCount){
  13940. GList.pos_param=0;
  13941. return 0;
  13942. };
  13943. var viewWidth=this.viewWidth;
  13944. var page=Math.floor(GList.pos_param / viewWidth);
  13945. var startIndex=page *(this._curLineItemCount *this._curLineItemCount2);
  13946. var pos2=page *viewWidth;
  13947. var i=0;
  13948. var pos3=NaN;
  13949. for (i=0;i < this._curLineItemCount;i++){
  13950. pos3=pos2+this._virtualItems[startIndex+i].width+this._columnGap;
  13951. if (pos3 > GList.pos_param){
  13952. GList.pos_param=pos2;
  13953. return startIndex+i;
  13954. }
  13955. pos2=pos3;
  13956. }
  13957. GList.pos_param=pos2;
  13958. return startIndex+this._curLineItemCount-1;
  13959. }
  13960. __proto.handleScroll=function(forceUpdate){
  13961. if (this._eventLocked)
  13962. return;
  13963. if (this._layout==0 || this._layout==2){
  13964. var enterCounter=0;
  13965. while(this.handleScroll1(forceUpdate)){
  13966. enterCounter++;
  13967. forceUpdate=false;
  13968. if(enterCounter>20){
  13969. console.log("FairyGUI: list will never be filled as the item renderer function always returns a different size.");
  13970. break ;
  13971. }
  13972. }
  13973. this.handleArchOrder1();
  13974. }
  13975. else if (this._layout==1 || this._layout==3){
  13976. enterCounter=0;
  13977. while(this.handleScroll2(forceUpdate)){
  13978. enterCounter++;
  13979. forceUpdate=false;
  13980. if(enterCounter>20){
  13981. console.log("FairyGUI: list will never be filled as the item renderer function always returns a different size.");
  13982. break ;
  13983. }
  13984. }
  13985. this.handleArchOrder2();
  13986. }
  13987. else{
  13988. this.handleScroll3(forceUpdate);
  13989. }
  13990. this._boundsChanged=false;
  13991. }
  13992. __proto.handleScroll1=function(forceUpdate){
  13993. var pos=this._scrollPane.scrollingPosY;
  13994. var max=pos+this._scrollPane.viewHeight;
  13995. var end=max==this._scrollPane.contentHeight;
  13996. fairygui.GList.pos_param=pos;
  13997. var newFirstIndex=this.getIndexOnPos1(forceUpdate);
  13998. pos=fairygui.GList.pos_param;
  13999. if (newFirstIndex==this._firstIndex && !forceUpdate)
  14000. return false;
  14001. var oldFirstIndex=this._firstIndex;
  14002. this._firstIndex=newFirstIndex;
  14003. var curIndex=newFirstIndex;
  14004. var forward=oldFirstIndex > newFirstIndex;
  14005. var childCount=this.numChildren;
  14006. var lastIndex=oldFirstIndex+childCount-1;
  14007. var reuseIndex=forward ? lastIndex :oldFirstIndex;
  14008. var curX=0,curY=pos;
  14009. var needRender=false;
  14010. var deltaSize=0;
  14011. var firstItemDeltaSize=0;
  14012. var url=this.defaultItem;
  14013. var ii,ii2;
  14014. var i=0,j=0;
  14015. var partSize=(this._scrollPane.viewWidth-this._columnGap *(this._curLineItemCount-1))/ this._curLineItemCount;
  14016. this.itemInfoVer++;
  14017. while (curIndex < this._realNumItems && (end || curY < max)){
  14018. ii=this._virtualItems[curIndex];
  14019. if (ii.obj==null || forceUpdate){
  14020. if (this.itemProvider !=null){
  14021. url=this.itemProvider.runWith(curIndex % this._numItems);
  14022. if (url==null)
  14023. url=this._defaultItem;
  14024. url=UIPackage.normalizeURL(url);
  14025. }
  14026. if (ii.obj !=null && ii.obj.resourceURL !=url){
  14027. if ((ii.obj instanceof fairygui.GButton ))
  14028. ii.selected=(ii.obj).selected;
  14029. this.removeChildToPool(ii.obj);
  14030. ii.obj=null;
  14031. }
  14032. }
  14033. if (ii.obj==null){
  14034. if (forward){
  14035. for (j=reuseIndex;j >=oldFirstIndex;j--){
  14036. ii2=this._virtualItems[j];
  14037. if (ii2.obj !=null && ii2.updateFlag !=this.itemInfoVer && ii2.obj.resourceURL==url){
  14038. if ((ii2.obj instanceof fairygui.GButton ))
  14039. ii2.selected=(ii2.obj).selected;
  14040. ii.obj=ii2.obj;
  14041. ii2.obj=null;
  14042. if (j==reuseIndex)
  14043. reuseIndex--;
  14044. break ;
  14045. }
  14046. }
  14047. }
  14048. else{
  14049. for (j=reuseIndex;j <=lastIndex;j++){
  14050. ii2=this._virtualItems[j];
  14051. if (ii2.obj !=null && ii2.updateFlag !=this.itemInfoVer && ii2.obj.resourceURL==url){
  14052. if ((ii2.obj instanceof fairygui.GButton ))
  14053. ii2.selected=(ii2.obj).selected;
  14054. ii.obj=ii2.obj;
  14055. ii2.obj=null;
  14056. if (j==reuseIndex)
  14057. reuseIndex++;
  14058. break ;
  14059. }
  14060. }
  14061. }
  14062. if (ii.obj !=null){
  14063. this.setChildIndex(ii.obj,forward ? curIndex-newFirstIndex :this.numChildren);
  14064. }
  14065. else{
  14066. ii.obj=this._pool.getObject(url);
  14067. if (forward)
  14068. this.addChildAt(ii.obj,curIndex-newFirstIndex);
  14069. else
  14070. this.addChild(ii.obj);
  14071. }
  14072. if ((ii.obj instanceof fairygui.GButton ))
  14073. (ii.obj).selected=ii.selected;
  14074. needRender=true;
  14075. }
  14076. else
  14077. needRender=forceUpdate;
  14078. if (needRender){
  14079. if (this._autoResizeItem && (this._layout==0 || this._columnCount > 0))
  14080. ii.obj.setSize(partSize,ii.obj.height,true);
  14081. this.itemRenderer.runWith([curIndex % this._numItems,ii.obj]);
  14082. if (curIndex % this._curLineItemCount==0){
  14083. deltaSize+=Math.ceil(ii.obj.height)-ii.height;
  14084. if (curIndex==newFirstIndex && oldFirstIndex > newFirstIndex){
  14085. firstItemDeltaSize=Math.ceil(ii.obj.height)-ii.height;
  14086. }
  14087. }
  14088. ii.width=Math.ceil(ii.obj.width);
  14089. ii.height=Math.ceil(ii.obj.height);
  14090. }
  14091. ii.updateFlag=this.itemInfoVer;
  14092. ii.obj.setXY(curX,curY);
  14093. if (curIndex==newFirstIndex)
  14094. max+=ii.height;
  14095. curX+=ii.width+this._columnGap;
  14096. if (curIndex % this._curLineItemCount==this._curLineItemCount-1){
  14097. curX=0;
  14098. curY+=ii.height+this._lineGap;
  14099. }
  14100. curIndex++;
  14101. }
  14102. for (i=0;i < childCount;i++){
  14103. ii=this._virtualItems[oldFirstIndex+i];
  14104. if (ii.updateFlag !=this.itemInfoVer && ii.obj !=null){
  14105. if ((ii.obj instanceof fairygui.GButton ))
  14106. ii.selected=(ii.obj).selected;
  14107. this.removeChildToPool(ii.obj);
  14108. ii.obj=null;
  14109. }
  14110. }
  14111. childCount=this._children.length;
  14112. for (i=0;i < childCount;i++){
  14113. var obj=this._virtualItems[newFirstIndex+i].obj;
  14114. if (this._children[i] !=obj)
  14115. this.setChildIndex(obj,i);
  14116. }
  14117. if (deltaSize !=0 || firstItemDeltaSize !=0)
  14118. this._scrollPane.changeContentSizeOnScrolling(0,deltaSize,0,firstItemDeltaSize);
  14119. if (curIndex > 0 && this.numChildren > 0 && this._container.y < 0 && this.getChildAt(0).y >-this._container.y)
  14120. return true;
  14121. else
  14122. return false;
  14123. }
  14124. __proto.handleScroll2=function(forceUpdate){
  14125. var pos=this._scrollPane.scrollingPosX;
  14126. var max=pos+this._scrollPane.viewWidth;
  14127. var end=pos==this._scrollPane.contentWidth;
  14128. fairygui.GList.pos_param=pos;
  14129. var newFirstIndex=this.getIndexOnPos2(forceUpdate);
  14130. pos=fairygui.GList.pos_param;
  14131. if (newFirstIndex==this._firstIndex && !forceUpdate)
  14132. return false;
  14133. var oldFirstIndex=this._firstIndex;
  14134. this._firstIndex=newFirstIndex;
  14135. var curIndex=newFirstIndex;
  14136. var forward=oldFirstIndex > newFirstIndex;
  14137. var childCount=this.numChildren;
  14138. var lastIndex=oldFirstIndex+childCount-1;
  14139. var reuseIndex=forward ? lastIndex :oldFirstIndex;
  14140. var curX=pos,curY=0;
  14141. var needRender=false;
  14142. var deltaSize=0;
  14143. var firstItemDeltaSize=0;
  14144. var url=this.defaultItem;
  14145. var ii,ii2;
  14146. var i=0,j=0;
  14147. var partSize=(this._scrollPane.viewHeight-this._lineGap *(this._curLineItemCount-1))/ this._curLineItemCount;
  14148. this.itemInfoVer++;
  14149. while (curIndex < this._realNumItems && (end || curX < max)){
  14150. ii=this._virtualItems[curIndex];
  14151. if (ii.obj==null || forceUpdate){
  14152. if (this.itemProvider !=null){
  14153. url=this.itemProvider.runWith(curIndex % this._numItems);
  14154. if (url==null)
  14155. url=this._defaultItem;
  14156. url=UIPackage.normalizeURL(url);
  14157. }
  14158. if (ii.obj !=null && ii.obj.resourceURL !=url){
  14159. if ((ii.obj instanceof fairygui.GButton ))
  14160. ii.selected=(ii.obj).selected;
  14161. this.removeChildToPool(ii.obj);
  14162. ii.obj=null;
  14163. }
  14164. }
  14165. if (ii.obj==null){
  14166. if (forward){
  14167. for (j=reuseIndex;j >=oldFirstIndex;j--){
  14168. ii2=this._virtualItems[j];
  14169. if (ii2.obj !=null && ii2.updateFlag !=this.itemInfoVer && ii2.obj.resourceURL==url){
  14170. if ((ii2.obj instanceof fairygui.GButton ))
  14171. ii2.selected=(ii2.obj).selected;
  14172. ii.obj=ii2.obj;
  14173. ii2.obj=null;
  14174. if (j==reuseIndex)
  14175. reuseIndex--;
  14176. break ;
  14177. }
  14178. }
  14179. }
  14180. else{
  14181. for (j=reuseIndex;j <=lastIndex;j++){
  14182. ii2=this._virtualItems[j];
  14183. if (ii2.obj !=null && ii2.updateFlag !=this.itemInfoVer && ii2.obj.resourceURL==url){
  14184. if ((ii2.obj instanceof fairygui.GButton ))
  14185. ii2.selected=(ii2.obj).selected;
  14186. ii.obj=ii2.obj;
  14187. ii2.obj=null;
  14188. if (j==reuseIndex)
  14189. reuseIndex++;
  14190. break ;
  14191. }
  14192. }
  14193. }
  14194. if (ii.obj !=null){
  14195. this.setChildIndex(ii.obj,forward ? curIndex-newFirstIndex :this.numChildren);
  14196. }
  14197. else{
  14198. ii.obj=this._pool.getObject(url);
  14199. if (forward)
  14200. this.addChildAt(ii.obj,curIndex-newFirstIndex);
  14201. else
  14202. this.addChild(ii.obj);
  14203. }
  14204. if ((ii.obj instanceof fairygui.GButton ))
  14205. (ii.obj).selected=ii.selected;
  14206. needRender=true;
  14207. }
  14208. else
  14209. needRender=forceUpdate;
  14210. if (needRender){
  14211. if (this._autoResizeItem && (this._layout==1 || this._lineCount > 0))
  14212. ii.obj.setSize(ii.obj.width,partSize,true);
  14213. this.itemRenderer.runWith([curIndex % this._numItems,ii.obj]);
  14214. if (curIndex % this._curLineItemCount==0){
  14215. deltaSize+=Math.ceil(ii.obj.width)-ii.width;
  14216. if (curIndex==newFirstIndex && oldFirstIndex > newFirstIndex){
  14217. firstItemDeltaSize=Math.ceil(ii.obj.width)-ii.width;
  14218. }
  14219. }
  14220. ii.width=Math.ceil(ii.obj.width);
  14221. ii.height=Math.ceil(ii.obj.height);
  14222. }
  14223. ii.updateFlag=this.itemInfoVer;
  14224. ii.obj.setXY(curX,curY);
  14225. if (curIndex==newFirstIndex)
  14226. max+=ii.width;
  14227. curY+=ii.height+this._lineGap;
  14228. if (curIndex % this._curLineItemCount==this._curLineItemCount-1){
  14229. curY=0;
  14230. curX+=ii.width+this._columnGap;
  14231. }
  14232. curIndex++;
  14233. }
  14234. for (i=0;i < childCount;i++){
  14235. ii=this._virtualItems[oldFirstIndex+i];
  14236. if (ii.updateFlag !=this.itemInfoVer && ii.obj !=null){
  14237. if ((ii.obj instanceof fairygui.GButton ))
  14238. ii.selected=(ii.obj).selected;
  14239. this.removeChildToPool(ii.obj);
  14240. ii.obj=null;
  14241. }
  14242. }
  14243. childCount=this._children.length;
  14244. for (i=0;i < childCount;i++){
  14245. var obj=this._virtualItems[newFirstIndex+i].obj;
  14246. if (this._children[i] !=obj)
  14247. this.setChildIndex(obj,i);
  14248. }
  14249. if (deltaSize !=0 || firstItemDeltaSize !=0)
  14250. this._scrollPane.changeContentSizeOnScrolling(deltaSize,0,firstItemDeltaSize,0);
  14251. if (curIndex > 0 && this.numChildren > 0 && this._container.x < 0 && this.getChildAt(0).x >-this._container.x)
  14252. return true;
  14253. else
  14254. return false;
  14255. }
  14256. __proto.handleScroll3=function(forceUpdate){
  14257. var pos=this._scrollPane.scrollingPosX;
  14258. fairygui.GList.pos_param=pos;
  14259. var newFirstIndex=this.getIndexOnPos3(forceUpdate);
  14260. pos=fairygui.GList.pos_param;
  14261. if (newFirstIndex==this._firstIndex && !forceUpdate)
  14262. return;
  14263. var oldFirstIndex=this._firstIndex;
  14264. this._firstIndex=newFirstIndex;
  14265. var reuseIndex=oldFirstIndex;
  14266. var virtualItemCount=this._virtualItems.length;
  14267. var pageSize=this._curLineItemCount *this._curLineItemCount2;
  14268. var startCol=newFirstIndex % this._curLineItemCount;
  14269. var viewWidth=this.viewWidth;
  14270. var page=Math.floor(newFirstIndex / pageSize);
  14271. var startIndex=page *pageSize;
  14272. var lastIndex=startIndex+pageSize *2;
  14273. var needRender=false;
  14274. var i=0;
  14275. var ii,ii2;
  14276. var col=0;
  14277. var url=this._defaultItem;
  14278. var partWidth=(this._scrollPane.viewWidth-this._columnGap *(this._curLineItemCount-1))/ this._curLineItemCount;
  14279. var partHeight=(this._scrollPane.viewHeight-this._lineGap *(this._curLineItemCount2-1))/ this._curLineItemCount2;
  14280. this.itemInfoVer++;
  14281. for (i=startIndex;i < lastIndex;i++){
  14282. if (i >=this._realNumItems)
  14283. continue ;
  14284. col=i % this._curLineItemCount;
  14285. if (i-startIndex < pageSize){
  14286. if (col < startCol)
  14287. continue ;
  14288. }
  14289. else{
  14290. if (col > startCol)
  14291. continue ;
  14292. }
  14293. ii=this._virtualItems[i];
  14294. ii.updateFlag=this.itemInfoVer;
  14295. };
  14296. var lastObj=null;
  14297. var insertIndex=0;
  14298. for (i=startIndex;i < lastIndex;i++){
  14299. if (i >=this._realNumItems)
  14300. continue ;
  14301. ii=this._virtualItems[i];
  14302. if (ii.updateFlag !=this.itemInfoVer)
  14303. continue ;
  14304. if (ii.obj==null){
  14305. while (reuseIndex < virtualItemCount){
  14306. ii2=this._virtualItems[reuseIndex];
  14307. if (ii2.obj !=null && ii2.updateFlag !=this.itemInfoVer){
  14308. if ((ii2.obj instanceof fairygui.GButton ))
  14309. ii2.selected=(ii2.obj).selected;
  14310. ii.obj=ii2.obj;
  14311. ii2.obj=null;
  14312. break ;
  14313. }
  14314. reuseIndex++;
  14315. }
  14316. if (insertIndex==-1)
  14317. insertIndex=this.getChildIndex(lastObj)+1;
  14318. if (ii.obj==null){
  14319. if (this.itemProvider !=null){
  14320. url=this.itemProvider.runWith(i % this._numItems);
  14321. if (url==null)
  14322. url=this._defaultItem;
  14323. url=UIPackage.normalizeURL(url);
  14324. }
  14325. ii.obj=this._pool.getObject(url);
  14326. this.addChildAt(ii.obj,insertIndex);
  14327. }
  14328. else{
  14329. insertIndex=this.setChildIndexBefore(ii.obj,insertIndex);
  14330. }
  14331. insertIndex++;
  14332. if ((ii.obj instanceof fairygui.GButton ))
  14333. (ii.obj).selected=ii.selected;
  14334. needRender=true;
  14335. }
  14336. else{
  14337. needRender=forceUpdate;
  14338. insertIndex=-1;
  14339. lastObj=ii.obj;
  14340. }
  14341. if (needRender){
  14342. if (this._autoResizeItem){
  14343. if (this._curLineItemCount==this._columnCount && this._curLineItemCount2==this._lineCount)
  14344. ii.obj.setSize(partWidth,partHeight,true);
  14345. else if (this._curLineItemCount==this._columnCount)
  14346. ii.obj.setSize(partWidth,ii.obj.height,true);
  14347. else if (this._curLineItemCount2==this._lineCount)
  14348. ii.obj.setSize(ii.obj.width,partHeight,true);
  14349. }
  14350. this.itemRenderer.runWith([i % this._numItems,ii.obj]);
  14351. ii.width=Math.ceil(ii.obj.width);
  14352. ii.height=Math.ceil(ii.obj.height);
  14353. }
  14354. };
  14355. var borderX=(startIndex / pageSize)*viewWidth;
  14356. var xx=borderX;
  14357. var yy=0;
  14358. var lineHeight=0;
  14359. for (i=startIndex;i < lastIndex;i++){
  14360. if (i >=this._realNumItems)
  14361. continue ;
  14362. ii=this._virtualItems[i];
  14363. if (ii.updateFlag==this.itemInfoVer)
  14364. ii.obj.setXY(xx,yy);
  14365. if (ii.height > lineHeight)
  14366. lineHeight=ii.height;
  14367. if (i % this._curLineItemCount==this._curLineItemCount-1){
  14368. xx=borderX;
  14369. yy+=lineHeight+this._lineGap;
  14370. lineHeight=0;
  14371. if (i==startIndex+pageSize-1){
  14372. borderX+=viewWidth;
  14373. xx=borderX;
  14374. yy=0;
  14375. }
  14376. }
  14377. else
  14378. xx+=ii.width+this._columnGap;
  14379. }
  14380. for (i=reuseIndex;i < virtualItemCount;i++){
  14381. ii=this._virtualItems[i];
  14382. if (ii.updateFlag !=this.itemInfoVer && ii.obj !=null){
  14383. if ((ii.obj instanceof fairygui.GButton ))
  14384. ii.selected=(ii.obj).selected;
  14385. this.removeChildToPool(ii.obj);
  14386. ii.obj=null;
  14387. }
  14388. }
  14389. }
  14390. __proto.handleArchOrder1=function(){
  14391. if (this.childrenRenderOrder==2){
  14392. var mid=this._scrollPane.posY+this.viewHeight / 2;
  14393. var minDist=Number.POSITIVE_INFINITY;
  14394. var dist=0;
  14395. var apexIndex=0;
  14396. var cnt=this.numChildren;
  14397. for (var i=0;i < cnt;i++){
  14398. var obj=this.getChildAt(i);
  14399. if (!this.foldInvisibleItems || obj.visible){
  14400. dist=Math.abs(mid-obj.y-obj.height / 2);
  14401. if (dist < minDist){
  14402. minDist=dist;
  14403. apexIndex=i;
  14404. }
  14405. }
  14406. }
  14407. this.apexIndex=apexIndex;
  14408. }
  14409. }
  14410. __proto.handleArchOrder2=function(){
  14411. if (this.childrenRenderOrder==2){
  14412. var mid=this._scrollPane.posX+this.viewWidth / 2;
  14413. var minDist=Number.POSITIVE_INFINITY;
  14414. var dist=0;
  14415. var apexIndex=0;
  14416. var cnt=this.numChildren;
  14417. for (var i=0;i < cnt;i++){
  14418. var obj=this.getChildAt(i);
  14419. if (!this.foldInvisibleItems || obj.visible){
  14420. dist=Math.abs(mid-obj.x-obj.width / 2);
  14421. if (dist < minDist){
  14422. minDist=dist;
  14423. apexIndex=i;
  14424. }
  14425. }
  14426. }
  14427. this.apexIndex=apexIndex;
  14428. }
  14429. }
  14430. __proto.handleAlign=function(contentWidth,contentHeight){
  14431. var newOffsetX=0;
  14432. var newOffsetY=0;
  14433. if (contentHeight < this.viewHeight){
  14434. if (this._verticalAlign=="middle")
  14435. newOffsetY=Math.floor((this.viewHeight-contentHeight)/ 2);
  14436. else if (this._verticalAlign=="bottom")
  14437. newOffsetY=this.viewHeight-contentHeight;
  14438. }
  14439. if (contentWidth < this.viewWidth){
  14440. if (this._align=="center")
  14441. newOffsetX=Math.floor((this.viewWidth-contentWidth)/ 2);
  14442. else if (this._align=="right")
  14443. newOffsetX=this.viewWidth-contentWidth;
  14444. }
  14445. if (newOffsetX!=this._alignOffset.x || newOffsetY!=this._alignOffset.y){
  14446. this._alignOffset.setTo(newOffsetX,newOffsetY);
  14447. if (this._scrollPane !=null)
  14448. this._scrollPane.adjustMaskContainer();
  14449. else
  14450. this._container.pos(this._margin.left+this._alignOffset.x,this._margin.top+this._alignOffset.y);
  14451. }
  14452. }
  14453. __proto.updateBounds=function(){
  14454. if(this._virtual)
  14455. return;
  14456. var i=0;
  14457. var child;
  14458. var curX=0;
  14459. var curY=0;
  14460. var maxWidth=0;
  14461. var maxHeight=0;
  14462. var cw=0,ch=0;
  14463. var j=0;
  14464. var page=0;
  14465. var k=0;
  14466. var cnt=this._children.length;
  14467. var viewWidth=this.viewWidth;
  14468. var viewHeight=this.viewHeight;
  14469. var lineSize=0;
  14470. var lineStart=0;
  14471. var ratio=NaN;
  14472. if(this._layout==0){
  14473. for(i=0;i<cnt;i++){
  14474. child=this.getChildAt(i);
  14475. if (this.foldInvisibleItems && !child.visible)
  14476. continue ;
  14477. if (curY !=0)
  14478. curY+=this._lineGap;
  14479. child.y=curY;
  14480. if (this._autoResizeItem)
  14481. child.setSize(viewWidth,child.height,true);
  14482. curY+=Math.ceil(child.height);
  14483. if(child.width>maxWidth)
  14484. maxWidth=child.width;
  14485. }
  14486. cw=Math.ceil(maxWidth);
  14487. ch=curY;
  14488. }
  14489. else if(this._layout==1){
  14490. for(i=0;i<cnt;i++){
  14491. child=this.getChildAt(i);
  14492. if (this.foldInvisibleItems && !child.visible)
  14493. continue ;
  14494. if(curX!=0)
  14495. curX+=this._columnGap;
  14496. child.x=curX;
  14497. if (this._autoResizeItem)
  14498. child.setSize(child.width,viewHeight,true);
  14499. curX+=Math.ceil(child.width);
  14500. if(child.height>maxHeight)
  14501. maxHeight=child.height;
  14502. }
  14503. cw=curX;
  14504. ch=Math.ceil(maxHeight);
  14505. }
  14506. else if(this._layout==2){
  14507. if (this._autoResizeItem && this._columnCount > 0){
  14508. for (i=0;i < cnt;i++){
  14509. child=this.getChildAt(i);
  14510. if (this.foldInvisibleItems && !child.visible)
  14511. continue ;
  14512. lineSize+=child.sourceWidth;
  14513. j++;
  14514. if (j==this._columnCount || i==cnt-1){
  14515. ratio=(viewWidth-lineSize-(j-1)*this._columnGap)/ lineSize;
  14516. curX=0;
  14517. for (j=lineStart;j <=i;j++){
  14518. child=this.getChildAt(j);
  14519. if (this.foldInvisibleItems && !child.visible)
  14520. continue ;
  14521. child.setXY(curX,curY);
  14522. if (j < i){
  14523. child.setSize(child.sourceWidth+Math.round(child.sourceWidth *ratio),child.height,true);
  14524. curX+=Math.ceil(child.width)+this._columnGap;
  14525. }
  14526. else{
  14527. child.setSize(viewWidth-curX,child.height,true);
  14528. }
  14529. if (child.height > maxHeight)
  14530. maxHeight=child.height;
  14531. }
  14532. curY+=Math.ceil(maxHeight)+this._lineGap;
  14533. maxHeight=0;
  14534. j=0;
  14535. lineStart=i+1;
  14536. lineSize=0;
  14537. }
  14538. }
  14539. ch=curY+Math.ceil(maxHeight);
  14540. cw=viewWidth;
  14541. }
  14542. else{
  14543. for(i=0;i<cnt;i++){
  14544. child=this.getChildAt(i);
  14545. if (this.foldInvisibleItems && !child.visible)
  14546. continue ;
  14547. if(curX!=0)
  14548. curX+=this._columnGap;
  14549. if (this._columnCount !=0 && j >=this._columnCount
  14550. || this._columnCount==0 && curX+child.width > viewWidth && maxHeight !=0){
  14551. curX=0;
  14552. curY+=Math.ceil(maxHeight)+this._lineGap;
  14553. maxHeight=0;
  14554. j=0;
  14555. }
  14556. child.setXY(curX,curY);
  14557. curX+=Math.ceil(child.width);
  14558. if (curX > maxWidth)
  14559. maxWidth=curX;
  14560. if (child.height > maxHeight)
  14561. maxHeight=child.height;
  14562. j++;
  14563. }
  14564. ch=curY+Math.ceil(maxHeight);
  14565. cw=Math.ceil(maxWidth);
  14566. }
  14567. }
  14568. else if (this._layout==3){
  14569. if (this._autoResizeItem && this._lineCount > 0){
  14570. for (i=0;i < cnt;i++){
  14571. child=this.getChildAt(i);
  14572. if (this.foldInvisibleItems && !child.visible)
  14573. continue ;
  14574. lineSize+=child.sourceHeight;
  14575. j++;
  14576. if (j==this._lineCount || i==cnt-1){
  14577. ratio=(viewHeight-lineSize-(j-1)*this._lineGap)/ lineSize;
  14578. curY=0;
  14579. for (j=lineStart;j <=i;j++){
  14580. child=this.getChildAt(j);
  14581. if (this.foldInvisibleItems && !child.visible)
  14582. continue ;
  14583. child.setXY(curX,curY);
  14584. if (j < i){
  14585. child.setSize(child.width,child.sourceHeight+Math.round(child.sourceHeight *ratio),true);
  14586. curY+=Math.ceil(child.height)+this._lineGap;
  14587. }
  14588. else{
  14589. child.setSize(child.width,viewHeight-curY,true);
  14590. }
  14591. if (child.width > maxWidth)
  14592. maxWidth=child.width;
  14593. }
  14594. curX+=Math.ceil(maxWidth)+this._columnGap;
  14595. maxWidth=0;
  14596. j=0;
  14597. lineStart=i+1;
  14598. lineSize=0;
  14599. }
  14600. }
  14601. cw=curX+Math.ceil(maxWidth);
  14602. ch=viewHeight;
  14603. }
  14604. else{
  14605. for(i=0;i<cnt;i++){
  14606. child=this.getChildAt(i);
  14607. if (this.foldInvisibleItems && !child.visible)
  14608. continue ;
  14609. if(curY!=0)
  14610. curY+=this._lineGap;
  14611. if (this._lineCount !=0 && j >=this._lineCount
  14612. || this._lineCount==0 && curY+child.height > viewHeight && maxWidth !=0){
  14613. curY=0;
  14614. curX+=Math.ceil(maxWidth)+this._columnGap;
  14615. maxWidth=0;
  14616. j=0;
  14617. }
  14618. child.setXY(curX,curY);
  14619. curY+=Math.ceil(child.height);
  14620. if (curY > maxHeight)
  14621. maxHeight=curY;
  14622. if (child.width > maxWidth)
  14623. maxWidth=child.width;
  14624. j++;
  14625. }
  14626. cw=curX+Math.ceil(maxWidth);
  14627. ch=Math.ceil(maxHeight);
  14628. }
  14629. }
  14630. else{
  14631. var eachHeight=0;
  14632. if(this._autoResizeItem && this._lineCount>0)
  14633. eachHeight=Math.floor((viewHeight-(this._lineCount-1)*this._lineGap)/this._lineCount);
  14634. if (this._autoResizeItem && this._columnCount > 0){
  14635. for (i=0;i < cnt;i++){
  14636. child=this.getChildAt(i);
  14637. if (this.foldInvisibleItems && !child.visible)
  14638. continue ;
  14639. if (j==0 && (this._lineCount !=0 && k >=this._lineCount
  14640. || this._lineCount==0 && curY+child.height > viewHeight)){
  14641. page++;
  14642. curY=0;
  14643. k=0;
  14644. }
  14645. lineSize+=child.sourceWidth;
  14646. j++;
  14647. if (j==this._columnCount || i==cnt-1){
  14648. ratio=(viewWidth-lineSize-(j-1)*this._columnGap)/ lineSize;
  14649. curX=0;
  14650. for (j=lineStart;j <=i;j++){
  14651. child=this.getChildAt(j);
  14652. if (this.foldInvisibleItems && !child.visible)
  14653. continue ;
  14654. child.setXY(page *viewWidth+curX,curY);
  14655. if (j < i){
  14656. child.setSize(child.sourceWidth+Math.round(child.sourceWidth *ratio),
  14657. this._lineCount>0?eachHeight:child.height,true);
  14658. curX+=Math.ceil(child.width)+this._columnGap;
  14659. }
  14660. else{
  14661. child.setSize(viewWidth-curX,this._lineCount>0?eachHeight:child.height,true);
  14662. }
  14663. if (child.height > maxHeight)
  14664. maxHeight=child.height;
  14665. }
  14666. curY+=Math.ceil(maxHeight)+this._lineGap;
  14667. maxHeight=0;
  14668. j=0;
  14669. lineStart=i+1;
  14670. lineSize=0;
  14671. k++;
  14672. }
  14673. }
  14674. }
  14675. else{
  14676. for (i=0;i < cnt;i++){
  14677. child=this.getChildAt(i);
  14678. if (this.foldInvisibleItems && !child.visible)
  14679. continue ;
  14680. if (curX !=0)
  14681. curX+=this._columnGap;
  14682. if (this._autoResizeItem && this._lineCount > 0)
  14683. child.setSize(child.width,eachHeight,true);
  14684. if (this._columnCount !=0 && j >=this._columnCount
  14685. || this._columnCount==0 && curX+child.width > viewWidth && maxHeight !=0){
  14686. curX=0;
  14687. curY+=Math.ceil(maxHeight)+this._lineGap;
  14688. maxHeight=0;
  14689. j=0;
  14690. k++;
  14691. if (this._lineCount !=0 && k >=this._lineCount
  14692. || this._lineCount==0 && curY+child.height > viewHeight && maxWidth !=0){
  14693. page++;
  14694. curY=0;
  14695. k=0;
  14696. }
  14697. }
  14698. child.setXY(page *viewWidth+curX,curY);
  14699. curX+=Math.ceil(child.width);
  14700. if (curX > maxWidth)
  14701. maxWidth=curX;
  14702. if (child.height > maxHeight)
  14703. maxHeight=child.height;
  14704. j++;
  14705. }
  14706. }
  14707. ch=page > 0 ? viewHeight :curY+Math.ceil(maxHeight);
  14708. cw=(page+1)*viewWidth;
  14709. }
  14710. this.handleAlign(cw,ch);
  14711. this.setBounds(0,0,cw,ch);
  14712. }
  14713. __proto.setup_beforeAdd=function(buffer,beginPos){
  14714. fairygui.GObject.prototype.setup_beforeAdd.call(this,buffer,beginPos);
  14715. buffer.seek(beginPos,5);
  14716. var i=0;
  14717. var j=0;
  14718. var cnt=0;
  14719. var i1=0;
  14720. var i2=0;
  14721. var nextPos=0;
  14722. var str;
  14723. this._layout=buffer.readByte();
  14724. this._selectionMode=buffer.readByte();
  14725. i1=buffer.readByte();
  14726. this._align=i1==0?"left":(i1==1?"center":"right");
  14727. i1=buffer.readByte();
  14728. this._verticalAlign=i1==0?"top":(i1==1?"middle":"bottom");
  14729. this._lineGap=buffer.getInt16();
  14730. this._columnGap=buffer.getInt16();
  14731. this._lineCount=buffer.getInt16();
  14732. this._columnCount=buffer.getInt16();
  14733. this._autoResizeItem=buffer.readBool();
  14734. this._childrenRenderOrder=buffer.readByte();
  14735. this._apexIndex=buffer.getInt16();
  14736. if (buffer.readBool()){
  14737. this._margin.top=buffer.getInt32();
  14738. this._margin.bottom=buffer.getInt32();
  14739. this._margin.left=buffer.getInt32();
  14740. this._margin.right=buffer.getInt32();
  14741. };
  14742. var overflow=buffer.readByte();
  14743. if (overflow==2){
  14744. var savedPos=buffer.pos;
  14745. buffer.seek(beginPos,7);
  14746. this.setupScroll(buffer);
  14747. buffer.pos=savedPos;
  14748. }
  14749. else
  14750. this.setupOverflow(overflow);
  14751. if (buffer.readBool())
  14752. buffer.skip(8);
  14753. buffer.seek(beginPos,8);
  14754. this._defaultItem=buffer.readS();
  14755. var itemCount=buffer.getInt16();
  14756. for (i=0;i < itemCount;i++){
  14757. nextPos=buffer.getInt16();
  14758. nextPos+=buffer.pos;
  14759. str=buffer.readS();
  14760. if (str==null){
  14761. str=this.defaultItem;
  14762. if (!str){
  14763. buffer.pos=nextPos;
  14764. continue ;
  14765. }
  14766. };
  14767. var obj=this.getFromPool(str);
  14768. if (obj !=null){
  14769. this.addChild(obj);
  14770. str=buffer.readS();
  14771. if (str !=null)
  14772. obj.text=str;
  14773. str=buffer.readS();
  14774. if (str !=null && ((obj instanceof fairygui.GButton )))
  14775. (obj).selectedTitle=str;
  14776. str=buffer.readS();
  14777. if (str !=null)
  14778. obj.icon=str;
  14779. str=buffer.readS();
  14780. if (str !=null && ((obj instanceof fairygui.GButton )))
  14781. (obj).selectedIcon=str;
  14782. str=buffer.readS();
  14783. if (str !=null)
  14784. obj.name=str;
  14785. if ((obj instanceof fairygui.GComponent )){
  14786. cnt=buffer.getInt16();
  14787. for (j=0;j < cnt;j++){
  14788. var cc=(obj).getController(buffer.readS());
  14789. str=buffer.readS();
  14790. if (cc !=null)
  14791. cc.selectedPageId=str;
  14792. }
  14793. }
  14794. }
  14795. buffer.pos=nextPos;
  14796. }
  14797. }
  14798. __proto.setup_afterAdd=function(buffer,beginPos){
  14799. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  14800. buffer.seek(beginPos,6);
  14801. var i=buffer.getInt16();
  14802. if (i !=-1)
  14803. this._selectionController=this.parent.getControllerAt(i);
  14804. }
  14805. /**
  14806. *@see ListLayoutType
  14807. */
  14808. /**
  14809. *@see ListLayoutType
  14810. */
  14811. __getset(0,__proto,'layout',function(){
  14812. return this._layout;
  14813. },function(value){
  14814. if (this._layout !=value){
  14815. this._layout=value;
  14816. this.setBoundsChangedFlag();
  14817. if(this._virtual)
  14818. this.setVirtualListChangedFlag(true);
  14819. }
  14820. });
  14821. __getset(0,__proto,'align',function(){
  14822. return this._align;
  14823. },function(value){
  14824. if(this._align!=value){
  14825. this._align=value;
  14826. this.setBoundsChangedFlag();
  14827. if (this._virtual)
  14828. this.setVirtualListChangedFlag(true);
  14829. }
  14830. });
  14831. __getset(0,__proto,'lineCount',function(){
  14832. return this._lineCount;
  14833. },function(value){
  14834. if (this._lineCount !=value){
  14835. this._lineCount=value;
  14836. if (this._layout==3 || this._layout==4){
  14837. this.setBoundsChangedFlag();
  14838. if (this._virtual)
  14839. this.setVirtualListChangedFlag(true);
  14840. }
  14841. }
  14842. });
  14843. __getset(0,__proto,'columnCount',function(){
  14844. return this._columnCount;
  14845. },function(value){
  14846. if (this._columnCount !=value){
  14847. this._columnCount=value;
  14848. if (this._layout==2 || this._layout==4){
  14849. this.setBoundsChangedFlag();
  14850. if (this._virtual)
  14851. this.setVirtualListChangedFlag(true);
  14852. }
  14853. }
  14854. });
  14855. __getset(0,__proto,'lineGap',function(){
  14856. return this._lineGap;
  14857. },function(value){
  14858. if (this._lineGap !=value){
  14859. this._lineGap=value;
  14860. this.setBoundsChangedFlag();
  14861. if(this._virtual)
  14862. this.setVirtualListChangedFlag(true);
  14863. }
  14864. });
  14865. __getset(0,__proto,'columnGap',function(){
  14866. return this._columnGap;
  14867. },function(value){
  14868. if(this._columnGap !=value){
  14869. this._columnGap=value;
  14870. this.setBoundsChangedFlag();
  14871. if (this._virtual)
  14872. this.setVirtualListChangedFlag(true);
  14873. }
  14874. });
  14875. __getset(0,__proto,'verticalAlign',function(){
  14876. return this._verticalAlign;
  14877. },function(value){
  14878. if(this._verticalAlign!=value){
  14879. this._verticalAlign=value;
  14880. this.setBoundsChangedFlag();
  14881. if (this._virtual)
  14882. this.setVirtualListChangedFlag(true);
  14883. }
  14884. });
  14885. __getset(0,__proto,'virtualItemSize',function(){
  14886. return this._itemSize;
  14887. },function(value){
  14888. if(this._virtual){
  14889. if(this._itemSize==null)
  14890. this._itemSize=new Point();
  14891. this._itemSize.setTo(value.x,value.y);
  14892. this.setVirtualListChangedFlag(true);
  14893. }
  14894. });
  14895. __getset(0,__proto,'defaultItem',function(){
  14896. return this._defaultItem;
  14897. },function(val){
  14898. this._defaultItem=val;
  14899. });
  14900. __getset(0,__proto,'autoResizeItem',function(){
  14901. return this._autoResizeItem;
  14902. },function(value){
  14903. if(this._autoResizeItem !=value){
  14904. this._autoResizeItem=value;
  14905. this.setBoundsChangedFlag();
  14906. if (this._virtual)
  14907. this.setVirtualListChangedFlag(true);
  14908. }
  14909. });
  14910. /**
  14911. *@see ListSelectionMode
  14912. */
  14913. /**
  14914. *@see ListSelectionMode
  14915. */
  14916. __getset(0,__proto,'selectionMode',function(){
  14917. return this._selectionMode;
  14918. },function(value){
  14919. this._selectionMode=value;
  14920. });
  14921. __getset(0,__proto,'selectionController',function(){
  14922. return this._selectionController;
  14923. },function(value){
  14924. this._selectionController=value;
  14925. });
  14926. __getset(0,__proto,'itemPool',function(){
  14927. return this._pool;
  14928. });
  14929. __getset(0,__proto,'selectedIndex',function(){
  14930. var i=0;
  14931. if (this._virtual){
  14932. for (i=0;i < this._realNumItems;i++){
  14933. var ii=this._virtualItems[i];
  14934. if (((ii.obj instanceof fairygui.GButton ))&& (ii.obj).selected
  14935. || ii.obj==null && ii.selected){
  14936. if (this._loop)
  14937. return i % this._numItems;
  14938. else
  14939. return i;
  14940. }
  14941. }
  14942. }
  14943. else{
  14944. var cnt=this._children.length;
  14945. for (i=0;i < cnt;i++){
  14946. var obj=this._children[i].asButton;
  14947. if (obj !=null && obj.selected)
  14948. return i;
  14949. }
  14950. }
  14951. return-1;
  14952. },function(value){
  14953. if (value >=0 && value < this.numItems){
  14954. if(this._selectionMode!=0)
  14955. this.clearSelection();
  14956. this.addSelection(value);
  14957. }
  14958. else
  14959. this.clearSelection();
  14960. });
  14961. /**
  14962. *Set the list item count.
  14963. *If the list is not virtual,specified Number of items will be created.
  14964. *If the list is virtual,only items in view will be created.
  14965. */
  14966. __getset(0,__proto,'numItems',function(){
  14967. if(this._virtual)
  14968. return this._numItems;
  14969. else
  14970. return this._children.length;
  14971. },function(value){
  14972. var i=0;
  14973. if (this._virtual){
  14974. if (this.itemRenderer==null)
  14975. throw new Error("Set itemRenderer first!");
  14976. this._numItems=value;
  14977. if (this._loop)
  14978. this._realNumItems=this._numItems *6;
  14979. else
  14980. this._realNumItems=this._numItems;
  14981. var oldCount=this._virtualItems.length;
  14982. if (this._realNumItems > oldCount){
  14983. for (i=oldCount;i < this._realNumItems;i++){
  14984. var ii=new ItemInfo();
  14985. ii.width=this._itemSize.x;
  14986. ii.height=this._itemSize.y;
  14987. this._virtualItems.push(ii);
  14988. }
  14989. }
  14990. else{
  14991. for (i=this._realNumItems;i < oldCount;i++)
  14992. this._virtualItems[i].selected=false;
  14993. }
  14994. if (this._virtualListChanged !=0)
  14995. Laya.timer.clear(this,this._refreshVirtualList);
  14996. this._refreshVirtualList();
  14997. }
  14998. else{
  14999. var cnt=this._children.length;
  15000. if (value > cnt){
  15001. for (i=cnt;i < value;i++){
  15002. if (this.itemProvider==null)
  15003. this.addItemFromPool();
  15004. else
  15005. this.addItemFromPool(this.itemProvider.runWith(i));
  15006. }
  15007. }
  15008. else{
  15009. this.removeChildrenToPool(value,cnt);
  15010. }
  15011. if (this.itemRenderer !=null){
  15012. for (i=0;i < value;i++)
  15013. this.itemRenderer.runWith([i,this.getChildAt(i)]);
  15014. }
  15015. }
  15016. });
  15017. GList.pos_param=NaN;
  15018. GList.__init$=function(){
  15019. //class ItemInfo
  15020. ItemInfo=(function(){
  15021. function ItemInfo(){
  15022. this.width=0;
  15023. this.height=0;
  15024. this.obj=null;
  15025. this.updateFlag=0;
  15026. this.selected=false;
  15027. }
  15028. __class(ItemInfo,'');
  15029. return ItemInfo;
  15030. })()
  15031. }
  15032. return GList;
  15033. })(GComponent)
  15034. //class fairygui.GRichTextField extends fairygui.GTextField
  15035. var GRichTextField=(function(_super){
  15036. function GRichTextField(){
  15037. this.div=null;
  15038. this._ubbEnabled=false;
  15039. this._color=null;
  15040. GRichTextField.__super.call(this);
  15041. this._text="";
  15042. }
  15043. __class(GRichTextField,'fairygui.GRichTextField',_super);
  15044. var __proto=GRichTextField.prototype;
  15045. __proto.createDisplayObject=function(){
  15046. this._displayObject=this.div=new HTMLDivElement();
  15047. this._displayObject.mouseEnabled=true;
  15048. this._displayObject["$owner"]=this;
  15049. this.font = UIConfig$1.defaultFont;
  15050. }
  15051. __proto.handleSizeChanged=function(){
  15052. this.div.size(this.width,this.height);
  15053. }
  15054. __getset(0,__proto,'bold',function(){
  15055. return this.div.style.bold;
  15056. },function(value){
  15057. this.div.style.bold=value;
  15058. });
  15059. __getset(0,__proto,'align',function(){
  15060. return this.div.style.align;
  15061. },function(value){
  15062. this.div.style.align=value;
  15063. });
  15064. __getset(0,__proto,'text',function(){
  15065. return this._text;
  15066. },function(value){
  15067. this._text=value;
  15068. var text2=this._text;
  15069. if (this._templateVars !=null)
  15070. text2=this.parseTemplate(text2);
  15071. if(this._ubbEnabled)
  15072. this.div.innerHTML=ToolSet.parseUBB(text2);
  15073. else
  15074. this.div.innerHTML=text2;
  15075. });
  15076. __getset(0,__proto,'color',function(){
  15077. return this._color;
  15078. },function(value){
  15079. if (this._color !=value){
  15080. this._color=value;
  15081. this.div.style.color=value;
  15082. if (this._gearColor.controller)
  15083. this._gearColor.updateState();
  15084. }
  15085. });
  15086. __getset(0,__proto,'font',function(){
  15087. return this.div.style.font;
  15088. },function(value){
  15089. if(value)
  15090. this.div.style.font=value;
  15091. else
  15092. this.div.style.font=UIConfig$1.defaultFont;
  15093. });
  15094. __getset(0,__proto,'leading',function(){
  15095. return this.div.style.leading;
  15096. },function(value){
  15097. this.div.style.leading=value;
  15098. });
  15099. __getset(0,__proto,'fontSize',function(){
  15100. return this.div.style.fontSize;
  15101. },function(value){
  15102. this.div.style.fontSize=value;
  15103. });
  15104. __getset(0,__proto,'valign',function(){
  15105. return this.div.style.valign;
  15106. },function(value){
  15107. this.div.style.valign=value;
  15108. });
  15109. __getset(0,__proto,'italic',function(){
  15110. return this.div.style.italic;
  15111. },function(value){
  15112. this.div.style.italic=value;
  15113. });
  15114. __getset(0,__proto,'stroke',function(){
  15115. return this.div.style.stroke;
  15116. },function(value){
  15117. this.div.style.stroke=value;
  15118. });
  15119. __getset(0,__proto,'strokeColor',function(){
  15120. return this.div.style.strokeColor;
  15121. },function(value){
  15122. this.div.style.strokeColor=value;
  15123. this.updateGear(4);
  15124. });
  15125. __getset(0,__proto,'ubbEnabled',function(){
  15126. return this._ubbEnabled;
  15127. },function(value){
  15128. this._ubbEnabled=value;
  15129. });
  15130. return GRichTextField;
  15131. })(GTextField)
  15132. //class fairygui.GProgressBar extends fairygui.GComponent
  15133. var GProgressBar=(function(_super){
  15134. function GProgressBar(){
  15135. this._max=0;
  15136. this._value=0;
  15137. this._titleType=0;
  15138. this._reverse=false;
  15139. this._titleObject=null;
  15140. this._aniObject=null;
  15141. this._barObjectH=null;
  15142. this._barObjectV=null;
  15143. this._barMaxWidth=0;
  15144. this._barMaxHeight=0;
  15145. this._barMaxWidthDelta=0;
  15146. this._barMaxHeightDelta=0;
  15147. this._barStartX=0;
  15148. this._barStartY=0;
  15149. this._tweening=false;
  15150. GProgressBar.__super.call(this);
  15151. this._titleType=0;
  15152. this._value=50;
  15153. this._max=100;
  15154. }
  15155. __class(GProgressBar,'fairygui.GProgressBar',_super);
  15156. var __proto=GProgressBar.prototype;
  15157. __proto.tweenValue=function(value,duration){
  15158. var _$this=this;
  15159. if(this._value !=value){
  15160. if(this._tweening){
  15161. GTween.kill(this,false,this.update);
  15162. this._tweening=false;
  15163. };
  15164. var oldValule=this._value;
  15165. this._value=value;
  15166. this._tweening=true;
  15167. return GTween.to(oldValule,this._value,duration).setTarget(this,this.update).setEase(0)
  15168. .onComplete(function(){_$this._tweening=false;},this);
  15169. }
  15170. else
  15171. return null;
  15172. }
  15173. __proto.update=function(newValue){
  15174. var percent=this._max!=0?Math.min(newValue / this._max,1):0;
  15175. if(this._titleObject){
  15176. switch(this._titleType){
  15177. case 0:
  15178. this._titleObject.text=Math.round(percent *100)+"%";
  15179. break ;
  15180. case 1:
  15181. this._titleObject.text=Math.round(newValue)+"/"+Math.round(this._max);
  15182. break ;
  15183. case 2:
  15184. this._titleObject.text=""+Math.round(newValue);
  15185. break ;
  15186. case 3:
  15187. this._titleObject.text=""+Math.round(this._max);
  15188. break ;
  15189. }
  15190. };
  15191. var fullWidth=this.width-this._barMaxWidthDelta;
  15192. var fullHeight=this.height-this._barMaxHeightDelta;
  15193. if(!this._reverse){
  15194. if(this._barObjectH){
  15195. if (((this._barObjectH instanceof fairygui.GImage ))&& (this._barObjectH).fillMethod !=0)
  15196. (this._barObjectH).fillAmount=percent;
  15197. else
  15198. this._barObjectH.width=Math.round(fullWidth *percent);
  15199. }
  15200. if(this._barObjectV){
  15201. if (((this._barObjectV instanceof fairygui.GImage ))&& (this._barObjectV).fillMethod !=0)
  15202. (this._barObjectV).fillAmount=percent;
  15203. else
  15204. this._barObjectV.height=Math.round(fullHeight *percent);
  15205. }
  15206. }
  15207. else {
  15208. if(this._barObjectH){
  15209. if (((this._barObjectH instanceof fairygui.GImage ))&& (this._barObjectH).fillMethod !=0)
  15210. (this._barObjectH).fillAmount=1-percent;
  15211. else{
  15212. this._barObjectH.width=Math.round(fullWidth *percent);
  15213. this._barObjectH.x=this._barStartX+(fullWidth-this._barObjectH.width);
  15214. }
  15215. }
  15216. if(this._barObjectV){
  15217. if (((this._barObjectV instanceof fairygui.GImage ))&& (this._barObjectV).fillMethod !=0)
  15218. (this._barObjectV).fillAmount=1-percent;
  15219. else{
  15220. this._barObjectV.height=Math.round(fullHeight *percent);
  15221. this._barObjectV.y=this._barStartY+(fullHeight-this._barObjectV.height);
  15222. }
  15223. }
  15224. }
  15225. if((this._aniObject instanceof fairygui.GMovieClip ))
  15226. (this._aniObject).frame=Math.round(percent *100);
  15227. }
  15228. __proto.constructExtension=function(buffer){
  15229. buffer.seek(0,6);
  15230. this._titleType=buffer.readByte();
  15231. this._reverse=buffer.readBool();
  15232. this._titleObject=(this.getChild("title"));
  15233. this._barObjectH=this.getChild("bar");
  15234. this._barObjectV=this.getChild("bar_v");
  15235. this._aniObject=this.getChild("ani");
  15236. if(this._barObjectH){
  15237. this._barMaxWidth=this._barObjectH.width;
  15238. this._barMaxWidthDelta=this.width-this._barMaxWidth;
  15239. this._barStartX=this._barObjectH.x;
  15240. }
  15241. if(this._barObjectV){
  15242. this._barMaxHeight=this._barObjectV.height;
  15243. this._barMaxHeightDelta=this.height-this._barMaxHeight;
  15244. this._barStartY=this._barObjectV.y;
  15245. }
  15246. }
  15247. __proto.handleSizeChanged=function(){
  15248. _super.prototype.handleSizeChanged.call(this);
  15249. if(this._barObjectH)
  15250. this._barMaxWidth=this.width-this._barMaxWidthDelta;
  15251. if(this._barObjectV)
  15252. this._barMaxHeight=this.height-this._barMaxHeightDelta;
  15253. if(!this._underConstruct)
  15254. this.update(this._value);
  15255. }
  15256. __proto.setup_afterAdd=function(buffer,beginPos){
  15257. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  15258. if (!buffer.seek(beginPos,6)){
  15259. this.update(this._value);
  15260. return;
  15261. }
  15262. if (buffer.readByte()!=this.packageItem.objectType){
  15263. this.update(this._value);
  15264. return;
  15265. }
  15266. this._value=buffer.getInt32();
  15267. this._max=buffer.getInt32();
  15268. this.update(this._value);
  15269. }
  15270. __proto.dispose=function(){
  15271. if(this._tweening)
  15272. GTween.kill(this);
  15273. _super.prototype.dispose.call(this);
  15274. }
  15275. __getset(0,__proto,'max',function(){
  15276. return this._max;
  15277. },function(value){
  15278. if(this._max !=value){
  15279. this._max=value;
  15280. this.update(this._value);
  15281. }
  15282. });
  15283. /**
  15284. *@see ProgressTitleType
  15285. */
  15286. /**
  15287. *@see ProgressTitleType
  15288. */
  15289. __getset(0,__proto,'titleType',function(){
  15290. return this._titleType;
  15291. },function(value){
  15292. if(this._titleType !=value){
  15293. this._titleType=value;
  15294. this.update(this._value);
  15295. }
  15296. });
  15297. __getset(0,__proto,'value',function(){
  15298. return this._value;
  15299. },function(value){
  15300. if(this._tweening){
  15301. GTween.kill(this,true,this.update);
  15302. this._tweening=false;
  15303. }
  15304. if(this._value !=value){
  15305. this._value=value;
  15306. this.update(this._value);
  15307. }
  15308. });
  15309. return GProgressBar;
  15310. })(GComponent)
  15311. //class fairygui.GRoot extends fairygui.GComponent
  15312. var GRoot=(function(_super){
  15313. function GRoot(){
  15314. this.uiScale=1;
  15315. this._modalLayer=null;
  15316. this._popupStack=null;
  15317. this._justClosedPopups=null;
  15318. this._modalWaitPane=null;
  15319. this._focusedObject=null;
  15320. this._tooltipWin=null;
  15321. this._defaultTooltipWin=null;
  15322. this._checkPopups=false;
  15323. GRoot.__super.call(this);
  15324. if(fairygui.GRoot._inst==null)
  15325. fairygui.GRoot._inst=this;
  15326. this.opaque=false;
  15327. this._popupStack=[];
  15328. this._justClosedPopups=[];
  15329. this.displayObject.once("display",this,this.__addedToStage);
  15330. }
  15331. __class(GRoot,'fairygui.GRoot',_super);
  15332. var __proto=GRoot.prototype;
  15333. __proto.showWindow=function(win){
  15334. this.addChild(win);
  15335. win.requestFocus();
  15336. if(win.x > this.width)
  15337. win.x=this.width-win.width;
  15338. else if(win.x+win.width < 0)
  15339. win.x=0;
  15340. if(win.y > this.height)
  15341. win.y=this.height-win.height;
  15342. else if(win.y+win.height < 0)
  15343. win.y=0;
  15344. this.adjustModalLayer();
  15345. }
  15346. __proto.hideWindow=function(win){
  15347. win.hide();
  15348. }
  15349. __proto.hideWindowImmediately=function(win){
  15350. if(win.parent==this)
  15351. this.removeChild(win);
  15352. this.adjustModalLayer();
  15353. }
  15354. __proto.bringToFront=function(win){
  15355. var cnt=this.numChildren;
  15356. var i=NaN;
  15357. if(this._modalLayer.parent!=null && !win.modal)
  15358. i=this.getChildIndex(this._modalLayer)-1;
  15359. else
  15360. i=cnt-1;
  15361. for(;i >=0;i--){
  15362. var g=this.getChildAt(i);
  15363. if(g==win)
  15364. return;
  15365. if((g instanceof fairygui.Window ))
  15366. break ;
  15367. }
  15368. if(i>=0)
  15369. this.setChildIndex(win,i);
  15370. }
  15371. __proto.showModalWait=function(msg){
  15372. if(UIConfig$1.globalModalWaiting !=null){
  15373. if(this._modalWaitPane==null)
  15374. this._modalWaitPane=UIPackage.createObjectFromURL(UIConfig$1.globalModalWaiting);
  15375. this._modalWaitPane.setSize(this.width,this.height);
  15376. this._modalWaitPane.addRelation(this,24);
  15377. this.addChild(this._modalWaitPane);
  15378. this._modalWaitPane.text=msg;
  15379. }
  15380. }
  15381. __proto.closeModalWait=function(){
  15382. if(this._modalWaitPane !=null && this._modalWaitPane.parent !=null)
  15383. this.removeChild(this._modalWaitPane);
  15384. }
  15385. __proto.closeAllExceptModals=function(){
  15386. var arr=this._children.slice();
  15387. var cnt=arr.length;
  15388. for(var i=0;i < cnt;i++){
  15389. var g=arr[i];
  15390. if(((g instanceof fairygui.Window ))&& !(g).modal)
  15391. (g).hide();
  15392. }
  15393. }
  15394. __proto.closeAllWindows=function(){
  15395. var arr=this._children.slice();
  15396. var cnt=arr.length;
  15397. for(var i=0;i < cnt;i++){
  15398. var g=arr[i];
  15399. if((g instanceof fairygui.Window ))
  15400. (g).hide();
  15401. }
  15402. }
  15403. __proto.getTopWindow=function(){
  15404. var cnt=this.numChildren;
  15405. for(var i=cnt-1;i >=0;i--){
  15406. var g=this.getChildAt(i);
  15407. if((g instanceof fairygui.Window )){
  15408. return (g);
  15409. }
  15410. }
  15411. return null;
  15412. }
  15413. __proto.showPopup=function(popup,target,downward){
  15414. if(this._popupStack.length > 0){
  15415. var k=this._popupStack.indexOf(popup);
  15416. if(k !=-1){
  15417. for(var i=this._popupStack.length-1;i >=k;i--)
  15418. this.removeChild(this._popupStack.pop());
  15419. }
  15420. }
  15421. this._popupStack.push(popup);
  15422. if (target !=null){
  15423. var p=target;
  15424. while (p !=null){
  15425. if (p.parent==this){
  15426. if (popup.sortingOrder < p.sortingOrder){
  15427. popup.sortingOrder=p.sortingOrder;
  15428. }
  15429. break ;
  15430. }
  15431. p=p.parent;
  15432. }
  15433. }
  15434. this.addChild(popup);
  15435. this.adjustModalLayer();
  15436. var pos;
  15437. var sizeW=0,sizeH=0;
  15438. if(target){
  15439. pos=target.localToGlobal();
  15440. sizeW=target.width;
  15441. sizeH=target.height;
  15442. }
  15443. else {
  15444. pos=this.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY);
  15445. };
  15446. var xx=NaN,yy=NaN;
  15447. xx=pos.x;
  15448. if(xx+popup.width > this.width)
  15449. xx=xx+sizeW-popup.width;
  15450. yy=pos.y+sizeH;
  15451. if((downward==null && yy+popup.height > this.height)
  15452. || downward==false){
  15453. yy=pos.y-popup.height-1;
  15454. if(yy < 0){
  15455. yy=0;
  15456. xx+=sizeW / 2;
  15457. }
  15458. }
  15459. popup.x=xx;
  15460. popup.y=yy;
  15461. }
  15462. __proto.togglePopup=function(popup,target,downward){
  15463. if(this._justClosedPopups.indexOf(popup)!=-1)
  15464. return;
  15465. this.showPopup(popup,target,downward);
  15466. }
  15467. __proto.hidePopup=function(popup){
  15468. if(popup !=null){
  15469. var k=this._popupStack.indexOf(popup);
  15470. if(k !=-1){
  15471. for(var i=this._popupStack.length-1;i >=k;i--)
  15472. this.closePopup(this._popupStack.pop());
  15473. }
  15474. }
  15475. else {
  15476. var cnt=this._popupStack.length;
  15477. for(i=cnt-1;i >=0;i--)
  15478. this.closePopup(this._popupStack[i]);
  15479. this._popupStack.length=0;
  15480. }
  15481. }
  15482. __proto.closePopup=function(target){
  15483. if(target.parent !=null){
  15484. if((target instanceof fairygui.Window ))
  15485. (target).hide();
  15486. else
  15487. this.removeChild(target);
  15488. }
  15489. }
  15490. __proto.showTooltips=function(msg){
  15491. if (this._defaultTooltipWin==null){
  15492. var resourceURL=UIConfig$1.tooltipsWin;
  15493. if (!resourceURL){
  15494. Log.print("UIConfig.tooltipsWin not defined");
  15495. return;
  15496. }
  15497. this._defaultTooltipWin=UIPackage.createObjectFromURL(resourceURL);
  15498. }
  15499. this._defaultTooltipWin.text=msg;
  15500. this.showTooltipsWin(this._defaultTooltipWin);
  15501. }
  15502. __proto.showTooltipsWin=function(tooltipWin,position){
  15503. this.hideTooltips();
  15504. this._tooltipWin=tooltipWin;
  15505. var xx=0;
  15506. var yy=0;
  15507. if (position==null){
  15508. xx=Laya.stage.mouseX+10;
  15509. yy=Laya.stage.mouseY+20;
  15510. }
  15511. else {
  15512. xx=position.x;
  15513. yy=position.y;
  15514. };
  15515. var pt=this.globalToLocal(xx,yy);
  15516. xx=pt.x;
  15517. yy=pt.y;
  15518. if (xx+this._tooltipWin.width > this.width){
  15519. xx=xx-this._tooltipWin.width-1;
  15520. if (xx < 0)
  15521. xx=10;
  15522. }
  15523. if (yy+this._tooltipWin.height > this.height){
  15524. yy=yy-this._tooltipWin.height-1;
  15525. if (xx-this._tooltipWin.width-1 > 0)
  15526. xx=xx-this._tooltipWin.width-1;
  15527. if (yy < 0)
  15528. yy=10;
  15529. }
  15530. this._tooltipWin.x=xx;
  15531. this._tooltipWin.y=yy;
  15532. this.addChild(this._tooltipWin);
  15533. }
  15534. __proto.hideTooltips=function(){
  15535. if (this._tooltipWin !=null){
  15536. if (this._tooltipWin.parent)
  15537. this.removeChild(this._tooltipWin);
  15538. this._tooltipWin=null;
  15539. }
  15540. }
  15541. __proto.getObjectUnderPoint=function(globalX,globalY){
  15542. return null;
  15543. }
  15544. __proto.setFocus=function(value){
  15545. if(this._focusedObject!=value){
  15546. this._focusedObject=value;
  15547. this.displayObject.event("fui_focus_changed");
  15548. }
  15549. }
  15550. __proto.playOneShotSound=function(url,volumeScale){
  15551. (volumeScale===void 0)&& (volumeScale=1);
  15552. if(ToolSet.startsWith(url,"ui://"))
  15553. return;
  15554. SoundManager.playSound(url);
  15555. }
  15556. __proto.adjustModalLayer=function(){
  15557. var cnt=this.numChildren;
  15558. if (this._modalWaitPane !=null && this._modalWaitPane.parent !=null)
  15559. this.setChildIndex(this._modalWaitPane,cnt-1);
  15560. for(var i=cnt-1;i >=0;i--){
  15561. var g=this.getChildAt(i);
  15562. if(((g instanceof fairygui.Window ))&& (g).modal){
  15563. if(this._modalLayer.parent==null)
  15564. this.addChildAt(this._modalLayer,i);
  15565. else
  15566. this.setChildIndexBefore(this._modalLayer,i);
  15567. return;
  15568. }
  15569. }
  15570. if (this._modalLayer.parent !=null)
  15571. this.removeChild(this._modalLayer);
  15572. }
  15573. __proto.__addedToStage=function(){
  15574. Laya.stage.on("mousedown",this,this.__stageMouseDown);
  15575. Laya.stage.on("mouseup",this,this.__stageMouseUp);
  15576. this._modalLayer=new GGraph();
  15577. this._modalLayer.setSize(this.width,this.height);
  15578. this._modalLayer.drawRect(0,null,UIConfig$1.modalLayerColor);
  15579. this._modalLayer.addRelation(this,24);
  15580. this.displayObject.stage.on("resize",this,this.__winResize);
  15581. this.__winResize();
  15582. }
  15583. __proto.checkPopups=function(clickTarget){
  15584. if(this._checkPopups)
  15585. return;
  15586. this._checkPopups=true;
  15587. this._justClosedPopups.length=0;
  15588. if (this._popupStack.length > 0){
  15589. var mc=clickTarget;
  15590. while (mc !=this.displayObject.stage && mc !=null){
  15591. if (mc["$owner"]){
  15592. var pindex=this._popupStack.indexOf(mc["$owner"]);
  15593. if (pindex !=-1){
  15594. for(var i=this._popupStack.length-1;i > pindex;i--){
  15595. var popup=this._popupStack.pop();
  15596. this.closePopup(popup);
  15597. this._justClosedPopups.push(popup);
  15598. }
  15599. return;
  15600. }
  15601. }
  15602. mc=mc.parent;
  15603. };
  15604. var cnt=this._popupStack.length;
  15605. for(i=cnt-1;i >=0;i--){
  15606. popup=this._popupStack[i];
  15607. this.closePopup(popup);
  15608. this._justClosedPopups.push(popup);
  15609. }
  15610. this._popupStack.length=0;
  15611. }
  15612. }
  15613. __proto.__stageMouseDown=function(evt){
  15614. var mc=evt.target;
  15615. while (mc !=this.displayObject.stage && mc !=null){
  15616. if (mc["$owner"]){
  15617. var gg=mc["$owner"];
  15618. if (gg.touchable && gg.focusable){
  15619. this.setFocus(gg);
  15620. break ;
  15621. }
  15622. }
  15623. mc=mc.parent;
  15624. }
  15625. if (this._tooltipWin !=null)
  15626. this.hideTooltips();
  15627. this.checkPopups(evt.target);
  15628. }
  15629. __proto.__stageMouseUp=function(){
  15630. this._checkPopups=false;
  15631. }
  15632. __proto.__winResize=function(){
  15633. this.setSize(Laya.stage.width,Laya.stage.height);
  15634. }
  15635. __getset(0,__proto,'focus',function(){
  15636. if (this._focusedObject && !this._focusedObject.onStage)
  15637. this._focusedObject=null;
  15638. return this._focusedObject;
  15639. },function(value){
  15640. if (value && (!value.focusable || !value.onStage))
  15641. throw "invalid focus target";
  15642. this.setFocus(value);
  15643. });
  15644. __getset(0,__proto,'hasAnyPopup',function(){
  15645. return this._popupStack.length !=0;
  15646. });
  15647. __getset(0,__proto,'modalLayer',function(){
  15648. return this._modalLayer;
  15649. });
  15650. __getset(0,__proto,'hasModalWindow',function(){
  15651. return this._modalLayer.parent !=null;
  15652. });
  15653. __getset(0,__proto,'modalWaiting',function(){
  15654. return this._modalWaitPane && this._modalWaitPane.inContainer;
  15655. });
  15656. __getset(0,__proto,'volumeScale',function(){
  15657. return SoundManager.soundVolume;
  15658. },function(value){
  15659. SoundManager.soundVolume=value;
  15660. });
  15661. __getset(1,GRoot,'inst',function(){
  15662. if(fairygui.GRoot._inst==null)
  15663. new GRoot();
  15664. return fairygui.GRoot._inst;
  15665. },fairygui.GComponent._$SET_inst);
  15666. GRoot._inst=null;
  15667. return GRoot;
  15668. })(GComponent)
  15669. //class fairygui.GTextInput extends fairygui.GTextField
  15670. var GTextInput=(function(_super){
  15671. function GTextInput(){
  15672. this.input=null;
  15673. GTextInput.__super.call(this);
  15674. }
  15675. __class(GTextInput,'fairygui.GTextInput',_super);
  15676. var __proto=GTextInput.prototype;
  15677. __proto.createDisplayObject=function(){
  15678. this._displayObject=this.input=new Input();
  15679. this._displayObject.mouseEnabled=true;
  15680. this._displayObject["$owner"]=this;
  15681. }
  15682. __proto.handleSizeChanged=function(){
  15683. this.input.size(this.width,this.height);
  15684. }
  15685. __proto.setup_beforeAdd=function(buffer,beginPos){
  15686. _super.prototype.setup_beforeAdd.call(this,buffer,beginPos);
  15687. buffer.seek(beginPos,4);
  15688. var str=buffer.readS();
  15689. if (str !=null)
  15690. this.promptText=str;
  15691. str=buffer.readS();
  15692. if (str !=null)
  15693. this.input.restrict=str;
  15694. var iv=buffer.getInt32();
  15695. if (iv !=0)
  15696. this.input.maxChars=iv;
  15697. iv=buffer.getInt32();
  15698. if (iv !=0){
  15699. if(iv==4)
  15700. this.keyboardType="number";
  15701. else if(iv==3)
  15702. this.keyboardType="url";
  15703. }
  15704. if (buffer.readBool())
  15705. this.password=true;
  15706. }
  15707. __getset(0,__proto,'bold',function(){
  15708. return this.input.bold;
  15709. },function(value){
  15710. this.input.bold=value;
  15711. });
  15712. __getset(0,__proto,'align',function(){
  15713. return this.input.align;
  15714. },function(value){
  15715. this.input.align=value;
  15716. });
  15717. __getset(0,__proto,'text',function(){
  15718. return this.input.text;
  15719. },function(value){
  15720. this.input.text=value;
  15721. });
  15722. __getset(0,__proto,'password',function(){
  15723. return this.input.type=="password";
  15724. },function(value){
  15725. if (value)
  15726. this.input.type="password";
  15727. else
  15728. this.input.type="text";
  15729. });
  15730. __getset(0,__proto,'color',function(){
  15731. return this.input.color;
  15732. },function(value){
  15733. this.input.color=value;
  15734. });
  15735. __getset(0,__proto,'font',function(){
  15736. return this.input.font;
  15737. },function(value){
  15738. this.input.font=value;
  15739. });
  15740. __getset(0,__proto,'leading',function(){
  15741. return this.input.leading;
  15742. },function(value){
  15743. this.input.leading=value;
  15744. });
  15745. __getset(0,__proto,'maxLength',function(){
  15746. return this.input.maxChars;
  15747. },function(value){
  15748. this.input.maxChars=value;
  15749. });
  15750. __getset(0,__proto,'fontSize',function(){
  15751. return this.input.fontSize;
  15752. },function(value){
  15753. this.input.fontSize=value;
  15754. });
  15755. __getset(0,__proto,'valign',function(){
  15756. return this.input.valign;
  15757. },function(value){
  15758. this.input.valign=value;
  15759. });
  15760. __getset(0,__proto,'italic',function(){
  15761. return this.input.italic;
  15762. },function(value){
  15763. this.input.italic=value;
  15764. });
  15765. __getset(0,__proto,'singleLine',function(){
  15766. return !this.input.multiline;
  15767. },function(value){
  15768. this.input.multiline=!value;
  15769. });
  15770. __getset(0,__proto,'stroke',function(){
  15771. return this.input.stroke;
  15772. },function(value){
  15773. this.input.stroke=value;
  15774. });
  15775. __getset(0,__proto,'strokeColor',function(){
  15776. return this.input.strokeColor;
  15777. },function(value){
  15778. this.input.strokeColor=value;
  15779. this.updateGear(4);
  15780. });
  15781. __getset(0,__proto,'keyboardType',function(){
  15782. return this.input.type;
  15783. },function(value){
  15784. this.input.type=value;
  15785. });
  15786. __getset(0,__proto,'editable',function(){
  15787. return this.input.editable;
  15788. },function(value){
  15789. this.input.editable=value;
  15790. });
  15791. __getset(0,__proto,'promptText',function(){
  15792. return this.input.prompt;
  15793. },function(value){
  15794. this.input.prompt=value;
  15795. });
  15796. __getset(0,__proto,'restrict',function(){
  15797. return this.input.restrict;
  15798. },function(value){
  15799. this.input.restrict=value;
  15800. });
  15801. __getset(0,__proto,'textWidth',function(){
  15802. return this.input.textWidth;
  15803. });
  15804. return GTextInput;
  15805. })(GTextField)
  15806. //class fairygui.GScrollBar extends fairygui.GComponent
  15807. var GScrollBar=(function(_super){
  15808. function GScrollBar(){
  15809. this._grip=null;
  15810. this._arrowButton1=null;
  15811. this._arrowButton2=null;
  15812. this._bar=null;
  15813. this._target=null;
  15814. this._vertical=false;
  15815. this._scrollPerc=0;
  15816. this._fixedGripSize=false;
  15817. this._dragOffset=null;
  15818. GScrollBar.__super.call(this);
  15819. this._dragOffset=new laya.maths.Point();
  15820. this._scrollPerc=0;
  15821. }
  15822. __class(GScrollBar,'fairygui.GScrollBar',_super);
  15823. var __proto=GScrollBar.prototype;
  15824. __proto.setScrollPane=function(target,vertical){
  15825. this._target=target;
  15826. this._vertical=vertical;
  15827. }
  15828. __proto.constructExtension=function(buffer){
  15829. buffer.seek(0,6);
  15830. this._fixedGripSize=buffer.readBool();
  15831. this._grip=this.getChild("grip");
  15832. if(!this._grip){
  15833. Log.print("需要定义grip");
  15834. return;
  15835. }
  15836. this._bar=this.getChild("bar");
  15837. if(!this._bar){
  15838. Log.print("需要定义bar");
  15839. return;
  15840. }
  15841. this._arrowButton1=this.getChild("arrow1");
  15842. this._arrowButton2=this.getChild("arrow2");
  15843. this._grip.on("mousedown",this,this.__gripMouseDown);
  15844. if(this._arrowButton1)
  15845. this._arrowButton1.on("mousedown",this,this.__arrowButton1Click);
  15846. if(this._arrowButton2)
  15847. this._arrowButton2.on("mousedown",this,this.__arrowButton2Click);
  15848. this.on("mousedown",this,this.__barMouseDown);
  15849. }
  15850. __proto.__gripMouseDown=function(evt){
  15851. if (!this._bar)
  15852. return;
  15853. evt.stopPropagation();
  15854. Laya.stage.on("mousemove",this,this.__gripMouseMove);
  15855. Laya.stage.on("mouseup",this,this.__gripMouseUp);
  15856. this.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY,this._dragOffset);
  15857. this._dragOffset.x-=this._grip.x;
  15858. this._dragOffset.y-=this._grip.y;
  15859. }
  15860. __proto.__gripMouseMove=function(){
  15861. var pt=this.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY,fairygui.GScrollBar.sScrollbarHelperPoint);
  15862. if (this._vertical){
  15863. var curY=pt.y-this._dragOffset.y;
  15864. this._target.setPercY((curY-this._bar.y)/ (this._bar.height-this._grip.height),false);
  15865. }
  15866. else {
  15867. var curX=pt.x-this._dragOffset.x;
  15868. this._target.setPercX((curX-this._bar.x)/ (this._bar.width-this._grip.width),false);
  15869. }
  15870. }
  15871. __proto.__gripMouseUp=function(evt){
  15872. if (!this._bar)
  15873. return;
  15874. Laya.stage.off("mousemove",this,this.__gripMouseMove);
  15875. Laya.stage.off("mouseup",this,this.__gripMouseUp);
  15876. }
  15877. __proto.__arrowButton1Click=function(evt){
  15878. evt.stopPropagation();
  15879. if (this._vertical)
  15880. this._target.scrollUp();
  15881. else
  15882. this._target.scrollLeft();
  15883. }
  15884. __proto.__arrowButton2Click=function(evt){
  15885. evt.stopPropagation();
  15886. if (this._vertical)
  15887. this._target.scrollDown();
  15888. else
  15889. this._target.scrollRight();
  15890. }
  15891. __proto.__barMouseDown=function(evt){
  15892. var pt=this._grip.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY,fairygui.GScrollBar.sScrollbarHelperPoint);
  15893. if (this._vertical){
  15894. if (pt.y < 0)
  15895. this._target.scrollUp(4);
  15896. else
  15897. this._target.scrollDown(4);
  15898. }
  15899. else {
  15900. if (pt.x < 0)
  15901. this._target.scrollLeft(4);
  15902. else
  15903. this._target.scrollRight(4);
  15904. }
  15905. }
  15906. __getset(0,__proto,'displayPerc',null,function(val){
  15907. if (this._vertical){
  15908. if(!this._fixedGripSize)
  15909. this._grip.height=val *this._bar.height;
  15910. this._grip.y=this._bar.y+(this._bar.height-this._grip.height)*this._scrollPerc;
  15911. }
  15912. else {
  15913. if(!this._fixedGripSize)
  15914. this._grip.width=val *this._bar.width;
  15915. this._grip.x=this._bar.x+(this._bar.width-this._grip.width)*this._scrollPerc;
  15916. }
  15917. });
  15918. __getset(0,__proto,'scrollPerc',null,function(val){
  15919. this._scrollPerc=val;
  15920. if (this._vertical)
  15921. this._grip.y=this._bar.y+(this._bar.height-this._grip.height)*this._scrollPerc;
  15922. else
  15923. this._grip.x=this._bar.x+(this._bar.width-this._grip.width)*this._scrollPerc;
  15924. });
  15925. __getset(0,__proto,'minSize',function(){
  15926. if (this._vertical)
  15927. return (this._arrowButton1 !=null ? this._arrowButton1.height :0)+(this._arrowButton2 !=null ? this._arrowButton2.height :0);
  15928. else
  15929. return (this._arrowButton1 !=null ? this._arrowButton1.width :0)+(this._arrowButton2 !=null ? this._arrowButton2.width :0);
  15930. });
  15931. __static(GScrollBar,
  15932. ['sScrollbarHelperPoint',function(){return this.sScrollbarHelperPoint=new Point();}
  15933. ]);
  15934. return GScrollBar;
  15935. })(GComponent)
  15936. //class fairygui.GSlider extends fairygui.GComponent
  15937. var GSlider=(function(_super){
  15938. function GSlider(){
  15939. this._max=0;
  15940. this._value=0;
  15941. this._titleType=0;
  15942. this._reverse=false;
  15943. this._titleObject=null;
  15944. this._barObjectH=null;
  15945. this._barObjectV=null;
  15946. this._barMaxWidth=0;
  15947. this._barMaxHeight=0;
  15948. this._barMaxWidthDelta=0;
  15949. this._barMaxHeightDelta=0;
  15950. this._gripObject=null;
  15951. this._clickPos=null;
  15952. this._clickPercent=0;
  15953. this._barStartX=0;
  15954. this._barStartY=0;
  15955. this.changeOnClick=true;
  15956. /**是否可拖动开关**/
  15957. this.canDrag=true;
  15958. GSlider.__super.call(this);
  15959. this._titleType=0;
  15960. this._value=50;
  15961. this._max=100;
  15962. this._clickPos=new laya.maths.Point();
  15963. }
  15964. __class(GSlider,'fairygui.GSlider',_super);
  15965. var __proto=GSlider.prototype;
  15966. __proto.update=function(){
  15967. var percent=Math.min(this._value / this._max,1);
  15968. this.updateWidthPercent(percent);
  15969. }
  15970. __proto.updateWidthPercent=function(percent){
  15971. if (this._titleObject){
  15972. switch (this._titleType){
  15973. case 0:
  15974. this._titleObject.text=Math.round(percent *100)+"%";
  15975. break ;
  15976. case 1:
  15977. this._titleObject.text=this._value+"/"+this._max;
  15978. break ;
  15979. case 2:
  15980. this._titleObject.text=""+this._value;
  15981. break ;
  15982. case 3:
  15983. this._titleObject.text=""+this._max;
  15984. break ;
  15985. }
  15986. };
  15987. var fullWidth=this.width-this._barMaxWidthDelta;
  15988. var fullHeight=this.height-this._barMaxHeightDelta;
  15989. if(!this._reverse){
  15990. if(this._barObjectH)
  15991. this._barObjectH.width=Math.round(fullWidth*percent);
  15992. if(this._barObjectV)
  15993. this._barObjectV.height=Math.round(fullHeight*percent);
  15994. }
  15995. else{
  15996. if(this._barObjectH){
  15997. this._barObjectH.width=Math.round(fullWidth*percent);
  15998. this._barObjectH.x=this._barStartX+(fullWidth-this._barObjectH.width);
  15999. }
  16000. if(this._barObjectV){
  16001. this._barObjectV.height=Math.round(fullHeight*percent);
  16002. this._barObjectV.y=this._barStartY+(fullHeight-this._barObjectV.height);
  16003. }
  16004. }
  16005. }
  16006. __proto.constructExtension=function(buffer){
  16007. buffer.seek(0,6);
  16008. this._titleType=buffer.readByte();
  16009. this._reverse=buffer.readBool();
  16010. this._titleObject=(this.getChild("title"));
  16011. this._barObjectH=this.getChild("bar");
  16012. this._barObjectV=this.getChild("bar_v");
  16013. this._gripObject=this.getChild("grip");
  16014. if(this._barObjectH){
  16015. this._barMaxWidth=this._barObjectH.width;
  16016. this._barMaxWidthDelta=this.width-this._barMaxWidth;
  16017. this._barStartX=this._barObjectH.x;
  16018. }
  16019. if(this._barObjectV){
  16020. this._barMaxHeight=this._barObjectV.height;
  16021. this._barMaxHeightDelta=this.height-this._barMaxHeight;
  16022. this._barStartY=this._barObjectV.y;
  16023. }
  16024. if(this._gripObject){
  16025. this._gripObject.on("mousedown",this,this.__gripMouseDown);
  16026. }
  16027. this.displayObject.on("mousedown",this,this.__barMouseDown);
  16028. }
  16029. __proto.handleSizeChanged=function(){
  16030. _super.prototype.handleSizeChanged.call(this);
  16031. if(this._barObjectH)
  16032. this._barMaxWidth=this.width-this._barMaxWidthDelta;
  16033. if(this._barObjectV)
  16034. this._barMaxHeight=this.height-this._barMaxHeightDelta;
  16035. if(!this._underConstruct)
  16036. this.update();
  16037. }
  16038. __proto.setup_afterAdd=function(buffer,beginPos){
  16039. _super.prototype.setup_afterAdd.call(this,buffer,beginPos);
  16040. if (!buffer.seek(beginPos,6)){
  16041. this.update();
  16042. return;
  16043. }
  16044. if (buffer.readByte()!=this.packageItem.objectType){
  16045. this.update();
  16046. return;
  16047. }
  16048. this._value=buffer.getInt32();
  16049. this._max=buffer.getInt32();
  16050. this.update();
  16051. }
  16052. __proto.__gripMouseDown=function(evt){
  16053. this.canDrag=true;
  16054. evt.stopPropagation();
  16055. this._clickPos=this.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY);
  16056. this._clickPercent=this._value / this._max;
  16057. Laya.stage.on("mousemove",this,this.__gripMouseMove);
  16058. Laya.stage.on("mouseup",this,this.__gripMouseUp);
  16059. }
  16060. __proto.__gripMouseMove=function(evt){
  16061. if(!this.canDrag){
  16062. return;
  16063. };
  16064. var pt=this.globalToLocal(Laya.stage.mouseX,Laya.stage.mouseY,fairygui.GSlider.sSilderHelperPoint);
  16065. var deltaX=pt.x-this._clickPos.x;
  16066. var deltaY=pt.y-this._clickPos.y;
  16067. if(this._reverse){
  16068. deltaX=-deltaX;
  16069. deltaY=-deltaY;
  16070. };
  16071. var percent=NaN;
  16072. if (this._barObjectH)
  16073. percent=this._clickPercent+deltaX / this._barMaxWidth;
  16074. else
  16075. percent=this._clickPercent+deltaY / this._barMaxHeight;
  16076. if (percent > 1)
  16077. percent=1;
  16078. else if (percent < 0)
  16079. percent=0;
  16080. var newValue=Math.round(this._max *percent);
  16081. if (newValue !=this._value){
  16082. this._value=newValue;
  16083. Events.dispatch("fui_state_changed",this.displayObject,evt);
  16084. }
  16085. this.updateWidthPercent(percent);
  16086. }
  16087. __proto.__gripMouseUp=function(evt){
  16088. Laya.stage.off("mousemove",this,this.__gripMouseMove);
  16089. Laya.stage.off("mouseup",this,this.__gripMouseUp);
  16090. }
  16091. __proto.__barMouseDown=function(evt){
  16092. if(!this.changeOnClick)
  16093. return;
  16094. var pt=this._gripObject.globalToLocal(evt.stageX,evt.stageY,fairygui.GSlider.sSilderHelperPoint);
  16095. var percent=this._value/this._max;
  16096. var delta=NaN;
  16097. if(this._barObjectH)
  16098. delta=(pt.x-this._gripObject.width/2)/this._barMaxWidth;
  16099. if(this._barObjectV)
  16100. delta=(pt.y-this._gripObject.height/2)/this._barMaxHeight;
  16101. if(this._reverse)
  16102. percent-=delta;
  16103. else
  16104. percent+=delta;
  16105. if(percent>1)
  16106. percent=1;
  16107. else if(percent<0)
  16108. percent=0;
  16109. var newValue=Math.round(this._max*percent);
  16110. if(newValue!=this._value){
  16111. this._value=newValue;
  16112. Events.dispatch("fui_state_changed",this.displayObject,evt);
  16113. }
  16114. this.updateWidthPercent(percent);
  16115. }
  16116. __getset(0,__proto,'max',function(){
  16117. return this._max;
  16118. },function(value){
  16119. if (this._max !=value){
  16120. this._max=value;
  16121. this.update();
  16122. }
  16123. });
  16124. /**
  16125. *@see ProgressTitleType
  16126. */
  16127. /**
  16128. *@see ProgressTitleType
  16129. */
  16130. __getset(0,__proto,'titleType',function(){
  16131. return this._titleType;
  16132. },function(value){
  16133. this._titleType=value;
  16134. });
  16135. __getset(0,__proto,'value',function(){
  16136. return this._value;
  16137. },function(value){
  16138. if (this._value !=value){
  16139. this._value=value;
  16140. this.update();
  16141. }
  16142. });
  16143. __static(GSlider,
  16144. ['sSilderHelperPoint',function(){return this.sSilderHelperPoint=new Point();}
  16145. ]);
  16146. return GSlider;
  16147. })(GComponent)
  16148. //class fairygui.Window extends fairygui.GComponent
  16149. var Window$2=(function(_super){
  16150. function Window(){
  16151. this._contentPane=null;
  16152. this._modalWaitPane=null;
  16153. this._closeButton=null;
  16154. this._dragArea=null;
  16155. this._contentArea=null;
  16156. this._frame=null;
  16157. this._modal=false;
  16158. this._uiSources=null;
  16159. this._inited=false;
  16160. this._loading=false;
  16161. this._requestingCmd=0;
  16162. this.bringToFontOnClick=false;
  16163. Window.__super.call(this);
  16164. this.focusable=true;
  16165. this._uiSources=[];
  16166. this.bringToFontOnClick=UIConfig$1.bringWindowToFrontOnClick;
  16167. this.displayObject.on("display",this,this.__onShown);
  16168. this.displayObject.on("undisplay",this,this.__onHidden);
  16169. this.displayObject.on("mousedown",this,this.__mouseDown);
  16170. }
  16171. __class(Window,'fairygui.Window',_super,'Window$2');
  16172. var __proto=Window.prototype;
  16173. __proto.addUISource=function(source){
  16174. this._uiSources.push(source);
  16175. }
  16176. __proto.show=function(){
  16177. GRoot.inst.showWindow(this);
  16178. }
  16179. __proto.showOn=function(root){
  16180. root.showWindow(this);
  16181. }
  16182. __proto.hide=function(){
  16183. if(this.isShowing)
  16184. this.doHideAnimation();
  16185. }
  16186. __proto.hideImmediately=function(){
  16187. var r=((this.parent instanceof fairygui.GRoot ))? (this.parent):null;
  16188. if(!r)
  16189. r=GRoot.inst;
  16190. r.hideWindowImmediately(this);
  16191. }
  16192. __proto.centerOn=function(r,restraint){
  16193. (restraint===void 0)&& (restraint=false);
  16194. this.setXY(Math.round((r.width-this.width)/ 2),Math.round((r.height-this.height)/ 2));
  16195. if(restraint){
  16196. this.addRelation(r,3);
  16197. this.addRelation(r,10);
  16198. }
  16199. }
  16200. __proto.toggleStatus=function(){
  16201. if(this.isTop)
  16202. this.hide();
  16203. else
  16204. this.show();
  16205. }
  16206. __proto.bringToFront=function(){
  16207. this.root.bringToFront(this);
  16208. }
  16209. __proto.showModalWait=function(requestingCmd){
  16210. (requestingCmd===void 0)&& (requestingCmd=0);
  16211. if(requestingCmd !=0)
  16212. this._requestingCmd=requestingCmd;
  16213. if(UIConfig$1.windowModalWaiting){
  16214. if(!this._modalWaitPane)
  16215. this._modalWaitPane=UIPackage.createObjectFromURL(UIConfig$1.windowModalWaiting);
  16216. this.layoutModalWaitPane();
  16217. this.addChild(this._modalWaitPane);
  16218. }
  16219. }
  16220. __proto.layoutModalWaitPane=function(){
  16221. if(this._contentArea !=null){
  16222. var pt=this._frame.localToGlobal();
  16223. pt=this.globalToLocal(pt.x,pt.y,pt);
  16224. this._modalWaitPane.setXY(pt.x+this._contentArea.x,pt.y+this._contentArea.y);
  16225. this._modalWaitPane.setSize(this._contentArea.width,this._contentArea.height);
  16226. }
  16227. else
  16228. this._modalWaitPane.setSize(fairygui.GRoot.inst.width, fairygui.GRoot.inst.height);
  16229. }
  16230. __proto.closeModalWait=function(requestingCmd){
  16231. (requestingCmd===void 0)&& (requestingCmd=0);
  16232. if(requestingCmd !=0){
  16233. if(this._requestingCmd !=requestingCmd)
  16234. return false;
  16235. }
  16236. this._requestingCmd=0;
  16237. if(this._modalWaitPane && this._modalWaitPane.parent !=null)
  16238. this.removeChild(this._modalWaitPane);
  16239. return true;
  16240. }
  16241. __proto.init=function(){
  16242. if(this._inited || this._loading)
  16243. return;
  16244. if(this._uiSources.length > 0){
  16245. this._loading=false;
  16246. var cnt=this._uiSources.length;
  16247. for(var i=0;i < cnt;i++){
  16248. var lib=this._uiSources[i];
  16249. if(!lib.loaded){
  16250. lib.load(this.__uiLoadComplete,this);
  16251. this._loading=true;
  16252. }
  16253. }
  16254. if(!this._loading)
  16255. this._init();
  16256. }
  16257. else
  16258. this._init();
  16259. }
  16260. __proto.onInit=function(){}
  16261. __proto.onShown=function(){}
  16262. __proto.onHide=function(){}
  16263. __proto.doShowAnimation=function(){
  16264. this.onShown();
  16265. }
  16266. __proto.doHideAnimation=function(){
  16267. this.hideImmediately();
  16268. }
  16269. __proto.__uiLoadComplete=function(){
  16270. var cnt=this._uiSources.length;
  16271. for(var i=0;i < cnt;i++){
  16272. var lib=this._uiSources[i];
  16273. if(!lib.loaded)
  16274. return;
  16275. }
  16276. this._loading=false;
  16277. this._init();
  16278. }
  16279. __proto._init=function(){
  16280. this._inited=true;
  16281. this.onInit();
  16282. if(this.isShowing)
  16283. this.doShowAnimation();
  16284. }
  16285. __proto.dispose=function(){
  16286. if(this.parent !=null)
  16287. this.hideImmediately();
  16288. _super.prototype.dispose.call(this);
  16289. }
  16290. __proto.closeEventHandler=function(){
  16291. this.hide();
  16292. }
  16293. __proto.__onShown=function(){
  16294. if(!this._inited)
  16295. this.init();
  16296. else
  16297. this.doShowAnimation();
  16298. }
  16299. __proto.__onHidden=function(){
  16300. this.closeModalWait();
  16301. this.onHide();
  16302. }
  16303. __proto.__mouseDown=function(){
  16304. if(this.isShowing && this.bringToFontOnClick)
  16305. this.bringToFront();
  16306. }
  16307. __proto.__dragStart=function(evt){
  16308. GObject.cast(evt.currentTarget).stopDrag();
  16309. this.startDrag();
  16310. }
  16311. __getset(0,__proto,'contentPane',function(){
  16312. return this._contentPane;
  16313. },function(val){
  16314. if(this._contentPane !=val){
  16315. if(this._contentPane !=null)
  16316. this.removeChild(this._contentPane);
  16317. this._contentPane=val;
  16318. if(this._contentPane !=null){
  16319. this.addChild(this._contentPane);
  16320. this.setSize(this._contentPane.width,this._contentPane.height);
  16321. this._contentPane.addRelation(this,24);
  16322. this._frame=(this._contentPane.getChild("frame"));
  16323. if(this._frame !=null){
  16324. this.closeButton=this._frame.getChild("closeButton");
  16325. this.dragArea=this._frame.getChild("dragArea");
  16326. this.contentArea=this._frame.getChild("contentArea");
  16327. }
  16328. }
  16329. }
  16330. });
  16331. __getset(0,__proto,'isShowing',function(){
  16332. return this.parent !=null;
  16333. });
  16334. __getset(0,__proto,'isTop',function(){
  16335. return this.parent !=null && this.parent.getChildIndex(this)==this.parent.numChildren-1;
  16336. });
  16337. __getset(0,__proto,'modal',function(){
  16338. return this._modal;
  16339. },function(val){
  16340. this._modal=val;
  16341. });
  16342. __getset(0,__proto,'dragArea',function(){
  16343. return this._dragArea;
  16344. },function(value){
  16345. if(this._dragArea !=value){
  16346. if(this._dragArea !=null){
  16347. this._dragArea.draggable=false;
  16348. this._dragArea.off("fui_drag_start",this,this.__dragStart);
  16349. }
  16350. this._dragArea=value;
  16351. if(this._dragArea !=null){
  16352. if((this._dragArea instanceof fairygui.GGraph ))
  16353. this._dragArea.asGraph.drawRect(0,null,null);
  16354. this._dragArea.draggable=true;
  16355. this._dragArea.on("fui_drag_start",this,this.__dragStart);
  16356. }
  16357. }
  16358. });
  16359. __getset(0,__proto,'frame',function(){
  16360. return this._frame;
  16361. });
  16362. __getset(0,__proto,'closeButton',function(){
  16363. return this._closeButton;
  16364. },function(value){
  16365. if(this._closeButton !=null)
  16366. this._closeButton.offClick(this,this.closeEventHandler);
  16367. this._closeButton=value;
  16368. if(this._closeButton !=null)
  16369. this._closeButton.onClick(this,this.closeEventHandler);
  16370. });
  16371. __getset(0,__proto,'contentArea',function(){
  16372. return this._contentArea;
  16373. },function(value){
  16374. this._contentArea=value;
  16375. });
  16376. __getset(0,__proto,'modalWaiting',function(){
  16377. return this._modalWaitPane && this._modalWaitPane.parent !=null;
  16378. });
  16379. return Window;
  16380. })(GComponent)
  16381. //class fairygui.display.Image extends laya.display.Sprite
  16382. var Image$1=(function(_super){
  16383. function Image(){
  16384. this._tex=null;
  16385. this._scaleByTile=false;
  16386. this._scale9Grid=null;
  16387. this._tileGridIndice=0;
  16388. this._textureScaleX=1;
  16389. this._textureScaleY=1;
  16390. this._needRebuild=0;
  16391. this._fillMethod=0;
  16392. this._fillOrigin=0;
  16393. this._fillAmount=0;
  16394. this._fillClockwise=false;
  16395. this._mask=null;
  16396. Image.__super.call(this);
  16397. this.mouseEnabled=false;
  16398. }
  16399. __class(Image,'fairygui.display.Image',_super,'Image$1');
  16400. var __proto=Image.prototype;
  16401. __proto.scaleTexture=function(sx,sy){
  16402. if(this._textureScaleX!=sx || this._textureScaleY!=sy){
  16403. this._textureScaleX=sx;
  16404. this._textureScaleY=sy;
  16405. if(this._tex)
  16406. this.size(this._tex.width*sx,this._tex.height*sy);
  16407. this.markChanged(1);
  16408. }
  16409. }
  16410. __proto.markChanged=function(flag){
  16411. if(!this._needRebuild){
  16412. this._needRebuild=flag;
  16413. Laya.timer.callLater(this,this.rebuild);
  16414. }
  16415. else
  16416. this._needRebuild |=flag;
  16417. }
  16418. __proto.rebuild=function(){
  16419. if((this._needRebuild & 1)!=0)
  16420. this.doDraw();
  16421. if((this._needRebuild & 2)!=0 && this._fillMethod!=0)
  16422. this.doFill();
  16423. this._needRebuild=0;
  16424. }
  16425. __proto.doDraw=function(){
  16426. var w=this.width;
  16427. var h=this.height;
  16428. var g=this.graphics;
  16429. g.clear();
  16430. if(this._tex==null || w==0 || h==0){
  16431. return;
  16432. }
  16433. if(this._scaleByTile){
  16434. g.fillTexture(this._tex,0,0,w,h);
  16435. }
  16436. else if(this._scale9Grid!=null){
  16437. var tw=this._tex.width;
  16438. var th=this._tex.height;
  16439. var left=this._scale9Grid.x;
  16440. var right=Math.max(tw-this._scale9Grid.right,0);
  16441. var top=this._scale9Grid.y;
  16442. var bottom=Math.max(th-this._scale9Grid.bottom,0);
  16443. var tmp=NaN;
  16444. if (h >=(th-this._scale9Grid.height)){
  16445. top=this._scale9Grid.y;
  16446. bottom=th-this._scale9Grid.bottom;
  16447. }
  16448. else{
  16449. tmp=this._scale9Grid.y / (th-this._scale9Grid.bottom);
  16450. tmp=h *tmp / (1+tmp);
  16451. top=Math.round(tmp);
  16452. bottom=h-tmp;
  16453. }
  16454. if (w >=(tw-this._scale9Grid.width)){
  16455. left=this._scale9Grid.x;
  16456. right=tw-this._scale9Grid.right;
  16457. }
  16458. else{
  16459. tmp=this._scale9Grid.x / (tw-this._scale9Grid.right);
  16460. tmp=w *tmp / (1+tmp);
  16461. left=Math.round(tmp);
  16462. right=w-tmp;
  16463. };
  16464. var centerWidth=Math.max(w-left-right,0);
  16465. var centerHeight=Math.max(h-top-bottom,0);
  16466. left && top && g.drawImage(fairygui.display.Image.getTexture(this._tex,0,0,left,top),0,0,left,top);
  16467. right && top && g.drawImage(fairygui.display.Image.getTexture(this._tex,tw-right,0,right,top),w-right,0,right,top);
  16468. left && bottom && g.drawImage(fairygui.display.Image.getTexture(this._tex,0,th-bottom,left,bottom),0,h-bottom,left,bottom);
  16469. right && bottom && g.drawImage(fairygui.display.Image.getTexture(this._tex,tw-right,th-bottom,right,bottom),w-right,h-bottom,right,bottom);
  16470. centerWidth && top && this.drawTexture(0,fairygui.display.Image.getTexture(this._tex,left,0,tw-left-right,top),left,0,centerWidth,top);
  16471. centerWidth && bottom && this.drawTexture(1,fairygui.display.Image.getTexture(this._tex,left,th-bottom,tw-left-right,bottom),left,h-bottom,centerWidth,bottom);
  16472. centerHeight && left && this.drawTexture(2,fairygui.display.Image.getTexture(this._tex,0,top,left,th-top-bottom),0,top,left,centerHeight);
  16473. centerHeight && right && this.drawTexture(3,fairygui.display.Image.getTexture(this._tex,tw-right,top,right,th-top-bottom),w-right,top,right,centerHeight);
  16474. centerWidth && centerHeight && this.drawTexture(4,fairygui.display.Image.getTexture(this._tex,left,top,tw-left-right,th-top-bottom),left,top,centerWidth,centerHeight);
  16475. }
  16476. else {
  16477. g.drawImage(this._tex,0,0,w,h);
  16478. }
  16479. }
  16480. __proto.drawTexture=function(part,tex,x,y,width,height){
  16481. (width===void 0)&& (width=0);
  16482. (height===void 0)&& (height=0);
  16483. if(part==-1 || (this._tileGridIndice & (1<<part))==0)
  16484. this.graphics.drawImage(tex,x,y,width,height);
  16485. else
  16486. this.graphics.fillTexture(tex,x,y,width,height);
  16487. }
  16488. __proto.doFill=function(){
  16489. var w=this.width;
  16490. var h=this.height;
  16491. var g=this._mask.graphics;
  16492. g.clear();
  16493. if(w==0 || h==0)
  16494. return;
  16495. var points=FillUtils.fill(w,h,this._fillMethod,this._fillOrigin,this._fillClockwise,this._fillAmount);
  16496. if(points==null){
  16497. this.mask=null;
  16498. this.mask=this._mask;
  16499. return;
  16500. }
  16501. g.drawPoly(0,0,points,"#FFFFFF");
  16502. }
  16503. __getset(0,__proto,'fillClockwise',function(){
  16504. return this._fillClockwise;
  16505. },function(value){
  16506. if(this._fillClockwise!=value){
  16507. this._fillClockwise=value;
  16508. if(this._fillMethod!=0)
  16509. this.markChanged(2);
  16510. }
  16511. });
  16512. __getset(0,__proto,'tex',function(){
  16513. return this._tex;
  16514. },function(value){
  16515. if(this._tex!=value){
  16516. this._tex=value;
  16517. if(this._tex)
  16518. this.size(this._tex.width*this._textureScaleX,this._tex.height*this._textureScaleY);
  16519. else
  16520. this.size(0,0);
  16521. this.markChanged(1);
  16522. }
  16523. });
  16524. __getset(0,__proto,'scale9Grid',function(){
  16525. return this._scale9Grid;
  16526. },function(value){
  16527. this._scale9Grid=value;
  16528. this.markChanged(1);
  16529. });
  16530. __getset(0,__proto,'fillAmount',function(){
  16531. return this._fillAmount;
  16532. },function(value){
  16533. if(this._fillAmount!=value){
  16534. this._fillAmount=value;
  16535. if(this._fillMethod!=0)
  16536. this.markChanged(2);
  16537. }
  16538. });
  16539. __getset(0,__proto,'scaleByTile',function(){
  16540. return this._scaleByTile;
  16541. },function(value){
  16542. if(this._scaleByTile!=value){
  16543. this._scaleByTile=value;
  16544. this.markChanged(1);
  16545. }
  16546. });
  16547. __getset(0,__proto,'tileGridIndice',function(){
  16548. return this._tileGridIndice;
  16549. },function(value){
  16550. if(this._tileGridIndice!=value){
  16551. this._tileGridIndice=value;
  16552. this.markChanged(1);
  16553. }
  16554. });
  16555. __getset(0,__proto,'fillMethod',function(){
  16556. return this._fillMethod;
  16557. },function(value){
  16558. if(this._fillMethod!=value){
  16559. this._fillMethod=value;
  16560. if(this._fillMethod!=0){
  16561. if(!this._mask){
  16562. this._mask=new Sprite();
  16563. this._mask.mouseEnabled=false;
  16564. }
  16565. this.mask=this._mask;
  16566. this.markChanged(2);
  16567. }
  16568. else if(this.mask){
  16569. this._mask.graphics.clear();
  16570. this.mask=null;
  16571. }
  16572. }
  16573. });
  16574. __getset(0,__proto,'fillOrigin',function(){
  16575. return this._fillOrigin;
  16576. },function(value){
  16577. if(this._fillOrigin!=value){
  16578. this._fillOrigin=value;
  16579. if(this._fillMethod!=0)
  16580. this.markChanged(2);
  16581. }
  16582. });
  16583. Image.getTexture=function(tex,x,y,width,height){
  16584. if (width <=0)width=1;
  16585. if (height <=0)height=1;
  16586. tex.$_GID || (tex.$_GID=Utils.getGID())
  16587. var texture;
  16588. if (!texture||!texture._getSource()){
  16589. texture=Texture.createFromTexture(tex,x,y,width,height);
  16590. }
  16591. return texture;
  16592. }
  16593. return Image;
  16594. })(Sprite)
  16595. //class fairygui.display.MovieClip extends laya.display.Sprite
  16596. var MovieClip$1=(function(_super){
  16597. function MovieClip(){
  16598. this.interval=0;
  16599. this.swing=false;
  16600. this.repeatDelay=0;
  16601. this.timeScale=1;
  16602. this._$3__texture=null;
  16603. this._needRebuild=false;
  16604. this._playing=true;
  16605. this._frameCount=0;
  16606. this._frames=null;
  16607. this._frame=0;
  16608. this._boundsRect=null;
  16609. this._start=0;
  16610. this._end=0;
  16611. this._times=0;
  16612. this._endAt=0;
  16613. this._status=0;
  16614. //0-none,1-next loop,2-ending,3-ended
  16615. this._endHandler=null;
  16616. this._frameElapsed=0;
  16617. //当前帧延迟
  16618. this._reversed=false;
  16619. this._repeatedCount=0;
  16620. MovieClip.__super.call(this);
  16621. this.mouseEnabled=false;
  16622. this.setPlaySettings();
  16623. this.on("display",this,this.__addToStage);
  16624. this.on("undisplay",this,this.__removeFromStage);
  16625. }
  16626. __class(MovieClip,'fairygui.display.MovieClip',_super,'MovieClip$1');
  16627. var __proto=MovieClip.prototype;
  16628. //从start帧开始,播放到end帧(-1表示结尾),重复times次(0表示无限循环),循环结束后,停止在endAt帧(-1表示参数end)
  16629. __proto.rewind=function(){
  16630. this._frame=0;
  16631. this._frameElapsed=0;
  16632. this._reversed=false;
  16633. this._repeatedCount=0;
  16634. this.drawFrame();
  16635. }
  16636. __proto.syncStatus=function(anotherMc){
  16637. this._frame=anotherMc._frame;
  16638. this._frameElapsed=anotherMc._frameElapsed;
  16639. this._reversed=anotherMc._reversed;
  16640. this._repeatedCount=anotherMc._repeatedCount;
  16641. this.drawFrame();
  16642. }
  16643. __proto.advance=function(timeInMiniseconds){
  16644. var beginFrame=this._frame;
  16645. var beginReversed=this._reversed;
  16646. var backupTime=timeInMiniseconds;
  16647. while (true){
  16648. var tt=this.interval+this._frames[this._frame].addDelay;
  16649. if (this._frame==0 && this._repeatedCount > 0)
  16650. tt+=this.repeatDelay;
  16651. if (timeInMiniseconds < tt){
  16652. this._frameElapsed=0;
  16653. break ;
  16654. }
  16655. timeInMiniseconds-=tt;
  16656. if (this.swing){
  16657. if (this._reversed){
  16658. this._frame--;
  16659. if (this._frame <=0){
  16660. this._frame=0;
  16661. this._repeatedCount++;
  16662. this._reversed=!this._reversed;
  16663. }
  16664. }
  16665. else{
  16666. this._frame++;
  16667. if (this._frame > this._frameCount-1){
  16668. this._frame=Math.max(0,this._frameCount-2);
  16669. this._repeatedCount++;
  16670. this._reversed=!this._reversed;
  16671. }
  16672. }
  16673. }
  16674. else{
  16675. this._frame++;
  16676. if (this._frame > this._frameCount-1){
  16677. this._frame=0;
  16678. this._repeatedCount++;
  16679. }
  16680. }
  16681. if (this._frame==beginFrame && this._reversed==beginReversed){
  16682. var roundTime=backupTime-timeInMiniseconds;
  16683. timeInMiniseconds-=Math.floor(timeInMiniseconds / roundTime)*roundTime;
  16684. }
  16685. }
  16686. this.drawFrame();
  16687. }
  16688. //从start帧开始,播放到end帧(-1表示结尾),重复times次(0表示无限循环),循环结束后,停止在endAt帧(-1表示参数end)
  16689. __proto.setPlaySettings=function(start,end,times,endAt,endHandler){
  16690. (start===void 0)&& (start=0);
  16691. (end===void 0)&& (end=-1);
  16692. (times===void 0)&& (times=0);
  16693. (endAt===void 0)&& (endAt=-1);
  16694. this._start=start;
  16695. this._end=end;
  16696. if(this._end==-1 || this._end>this._frameCount-1)
  16697. this._end=this._frameCount-1;
  16698. this._times=times;
  16699. this._endAt=endAt;
  16700. if (this._endAt==-1)
  16701. this._endAt=this._end;
  16702. this._status=0;
  16703. this._endHandler=endHandler;
  16704. this.frame=start;
  16705. }
  16706. __proto.update=function(bo){
  16707. (bo===void 0)&& (bo=true);
  16708. if ((!this._playing&&bo) || this._frameCount==0 || this._status==3)
  16709. return;
  16710. var dt=Laya.timer.delta;
  16711. if(dt>100)
  16712. dt=100;
  16713. if(this.timeScale!=1)
  16714. dt *=this.timeScale;
  16715. this._frameElapsed+=dt;
  16716. var tt=this.interval+this._frames[this._frame].addDelay;
  16717. if (this._frame==0 && this._repeatedCount > 0)
  16718. tt+=this.repeatDelay;
  16719. if (this._frameElapsed < tt)
  16720. return;
  16721. this._frameElapsed-=tt;
  16722. if (this._frameElapsed > this.interval)
  16723. this._frameElapsed=this.interval;
  16724. if (this.swing){
  16725. if (this._reversed){
  16726. this._frame--;
  16727. if (this._frame <=0){
  16728. this._frame=0;
  16729. this._repeatedCount++;
  16730. this._reversed=!this._reversed;
  16731. }
  16732. }
  16733. else{
  16734. this._frame++;
  16735. if (this._frame > this._frameCount-1){
  16736. this._frame=Math.max(0,this._frameCount-2);
  16737. this._repeatedCount++;
  16738. this._reversed=!this._reversed;
  16739. }
  16740. }
  16741. }
  16742. else{
  16743. this._frame++;
  16744. if (this._frame > this._frameCount-1){
  16745. this._frame=0;
  16746. this._repeatedCount++;
  16747. }
  16748. }
  16749. if (this._status==1){
  16750. this._frame=this._start;
  16751. this._frameElapsed=0;
  16752. this._status=0;
  16753. }
  16754. else if (this._status==2){
  16755. this._frame=this._endAt;
  16756. this._frameElapsed=0;
  16757. this._status=3;
  16758. if(this._endHandler!=null){
  16759. var handler=this._endHandler;
  16760. this._endHandler=null;
  16761. handler.run();
  16762. }
  16763. }
  16764. else{
  16765. if (this._frame==this._end){
  16766. if (this._times > 0){
  16767. this._times--;
  16768. if (this._times==0)
  16769. this._status=2;
  16770. else
  16771. this._status=1;
  16772. }
  16773. else if (this._start !=0)
  16774. this._status=1;
  16775. }
  16776. }
  16777. this.drawFrame();
  16778. }
  16779. __proto.drawFrame=function(){
  16780. if (this._frameCount>0 && this._frame < this._frames.length){
  16781. var frame=this._frames[this._frame];
  16782. this.graphics.clear();
  16783. this.graphics.drawImage(frame.texture,frame.rect.x,frame.rect.y);
  16784. }
  16785. else
  16786. this.graphics.clear();
  16787. }
  16788. __proto.checkTimer=function(){
  16789. if (this._playing && this._frameCount>0 && this.stage!=null)
  16790. Laya.timer.frameLoop(1,this,this.update);
  16791. else
  16792. Laya.timer.clear(this,this.update);
  16793. }
  16794. __proto.__addToStage=function(){
  16795. if(this._playing && this._frameCount>0)
  16796. Laya.timer.frameLoop(1,this,this.update);
  16797. }
  16798. __proto.__removeFromStage=function(){
  16799. Laya.timer.clear(this,this.update);
  16800. }
  16801. __getset(0,__proto,'frames',function(){
  16802. return this._frames;
  16803. },function(value){
  16804. this._frames=value;
  16805. if (this._frames !=null)
  16806. this._frameCount=this._frames.length;
  16807. else
  16808. this._frameCount=0;
  16809. if(this._end==-1 || this._end > this._frameCount-1)
  16810. this._end=this._frameCount-1;
  16811. if(this._endAt==-1 || this._endAt > this._frameCount-1)
  16812. this._endAt=this._frameCount-1;
  16813. if(this._frame < 0 || this._frame > this._frameCount-1)
  16814. this._frame=this._frameCount-1;
  16815. this.drawFrame();
  16816. this._frameElapsed=0;
  16817. this._repeatedCount=0;
  16818. this._reversed=false;
  16819. this.checkTimer();
  16820. });
  16821. __getset(0,__proto,'playing',function(){
  16822. return this._playing;
  16823. },function(value){
  16824. if(this._playing!=value){
  16825. this._playing=value;
  16826. this.checkTimer();
  16827. }
  16828. });
  16829. __getset(0,__proto,'frameCount',function(){
  16830. return this._frameCount;
  16831. });
  16832. __getset(0,__proto,'frame',function(){
  16833. return this._frame;
  16834. },function(value){
  16835. if (this._frame !=value){
  16836. if(this._frames!=null && value>=this._frameCount)
  16837. value=this._frameCount-1;
  16838. this._frame=value;
  16839. this._frameElapsed=0;
  16840. this.drawFrame();
  16841. }
  16842. });
  16843. __getset(0,__proto,'boundsRect',function(){
  16844. return this._boundsRect;
  16845. },function(value){
  16846. this._boundsRect=value;
  16847. });
  16848. return MovieClip;
  16849. })(Sprite)
  16850. Laya.__init([GBasicTextField,GList,AsyncOperation,GearLook,UIPackage,GearColor,Transition,EaseManager,GearAnimation,GearSize,RelationItem]);
  16851. })(window,document,Laya);