llviewermenu.cpp 319 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878
  1. /**
  2. * @file llviewermenu.cpp
  3. * @brief Builds menus out of items.
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #include "llviewerprecompiledheaders.h"
  33. #include "boost/tokenizer.hpp"
  34. #include "cef/dullahan.h" // For CHROME_VERSION_MAJOR
  35. #include "curl/curlver.h"
  36. #include "llviewermenu.h"
  37. #include "imageids.h"
  38. #include "llaudioengine.h"
  39. #include "llavatarjoint.h"
  40. #include "llassetstorage.h"
  41. #include "llcachename.h"
  42. #include "llcallbacklist.h"
  43. #include "llclipboard.h"
  44. #include "llconsole.h"
  45. #include "lldir.h"
  46. #include "lleconomy.h"
  47. #include "hbexternaleditor.h"
  48. #include "llfeaturemanager.h"
  49. #include "hbfileselector.h"
  50. #include "llimagebmp.h"
  51. #include "llimagej2c.h"
  52. #include "llimagejpeg.h"
  53. #include "llimagepng.h"
  54. #include "llimagetga.h"
  55. #include "llinstantmessage.h"
  56. #include "llkeyboard.h"
  57. #include "lllocale.h"
  58. #include "llmemberlistener.h"
  59. #include "llmenugl.h"
  60. #include "llmimetypes.h"
  61. #include "llmotioncontroller.h"
  62. #include "llnotifications.h"
  63. #include "llparcel.h"
  64. #include "llpermissionsflags.h"
  65. #include "llprimitive.h"
  66. #include "llregionhandle.h"
  67. #include "llrender.h" // For LLRender::sGLCoreProfile
  68. #include "llsdserialize.h"
  69. #include "llsdutil.h"
  70. #include "lltrans.h"
  71. #include "lltransactiontypes.h"
  72. #include "lluictrl.h"
  73. #include "lluictrlfactory.h"
  74. #include "lluploaddialog.h"
  75. #include "llview.h"
  76. #include "llvolume.h"
  77. #include "llvolumemgr.h"
  78. #include "llvorbisencode.h"
  79. #include "llwindow.h" // For gDebugClicks & gDebugWindowProc
  80. #include "llxfermanager.h"
  81. #include "object_flags.h"
  82. #include "llagent.h"
  83. #include "llagentpilot.h"
  84. #include "llagentwearables.h"
  85. #include "llappearancemgr.h"
  86. #include "llappviewer.h"
  87. #include "llavataractions.h"
  88. #include "llavatartracker.h"
  89. #include "llchatbar.h"
  90. #include "llcommandhandler.h"
  91. #include "lldebugview.h"
  92. #include "lldrawable.h"
  93. #include "lldrawpoolalpha.h"
  94. #include "lldrawpooltree.h"
  95. #include "lldrawpoolwlsky.h" // For HDRI sky
  96. #include "llenvironment.h"
  97. #include "llface.h"
  98. #include "llfasttimerview.h" // For HBTracyProfiler
  99. #include "llfirstuse.h"
  100. #include "llfloaterabout.h"
  101. #include "llfloateractivespeakers.h"
  102. #include "llfloateranimpreview.h"
  103. #include "hbfloaterareasearch.h"
  104. #include "llfloateravatarinfo.h"
  105. #include "llfloateravatartextures.h"
  106. #include "llfloaterbeacons.h"
  107. #include "hbfloaterbump.h"
  108. #include "llfloaterbuy.h"
  109. #include "llfloaterbuycontents.h"
  110. #include "llfloaterbuycurrency.h"
  111. #include "llfloaterbuyland.h"
  112. #include "llfloatercamera.h"
  113. #include "llfloaterchat.h"
  114. #include "llfloaterchatterbox.h"
  115. #include "llfloatercustomize.h"
  116. #include "llfloaterdebugsettings.h"
  117. #include "hbfloaterdebugtags.h"
  118. #include "llfloaterdisplayname.h"
  119. #include "hbfloatereditenvsettings.h"
  120. #include "llfloatereditui.h"
  121. #include "llfloaterexperiences.h"
  122. #include "llfloaterfriends.h"
  123. #include "llfloatergesture.h"
  124. #include "llfloatergodtools.h"
  125. #include "llfloatergroupinfo.h"
  126. #include "llfloatergroupinvite.h"
  127. #include "llfloatergroups.h"
  128. #include "hbfloatergrouptitles.h"
  129. #include "llfloaterimagepreview.h"
  130. #include "llfloaterinspect.h"
  131. #include "llfloaterinventory.h"
  132. #include "llfloaterlagmeter.h"
  133. #include "llfloaterland.h"
  134. #include "llfloaterlandholdings.h"
  135. #include "llfloatermediabrowser.h"
  136. #include "slfloatermediafilter.h"
  137. #include "llfloaterminimap.h"
  138. #include "llfloatermodelpreview.h"
  139. #include "llfloatermove.h"
  140. #include "llfloatermute.h"
  141. #include "llfloaternearbymedia.h"
  142. #include "llfloaternotificationsconsole.h"
  143. #include "llfloateropenobject.h"
  144. #include "llfloaterpathfindingcharacters.h"
  145. #include "llfloaterpathfindinglinksets.h"
  146. #include "llfloaterpay.h"
  147. #include "llfloaterperms.h"
  148. #include "llfloaterpreference.h"
  149. #include "hbfloaterradar.h"
  150. #include "llfloaterregiondebugconsole.h"
  151. #include "llfloaterregioninfo.h"
  152. #include "llfloaterreporter.h"
  153. #include "hbfloaterrlv.h"
  154. #include "llfloaterscriptdebug.h"
  155. #include "llfloaterscriptqueue.h"
  156. #include "hbfloatersearch.h"
  157. #include "llfloatersnapshot.h"
  158. #include "hbfloatersoundslist.h"
  159. #include "llfloaterstats.h"
  160. #include "hbfloaterteleporthistory.h"
  161. #include "llfloatertools.h"
  162. #include "hbfloateruploadasset.h" // For HBFloaterUploadSound
  163. #include "llfloaterwindlight.h"
  164. #include "llfloaterworldmap.h"
  165. #include "llfolderview.h"
  166. #include "llgltfmateriallist.h"
  167. #include "llgltfscenemanager.h"
  168. #include "llgridmanager.h"
  169. #include "llgroupmgr.h"
  170. #include "llhoverview.h"
  171. #include "llhudeffectspiral.h"
  172. #include "llimmgr.h"
  173. #include "llmeshrepository.h"
  174. #include "llmorphview.h"
  175. #include "llmutelist.h"
  176. #include "hbobjectbackup.h"
  177. #include "llpanellogin.h"
  178. #include "llpanelobject.h"
  179. #include "llpathfindingmanager.h"
  180. #include "llpipeline.h"
  181. #include "llpreviewmaterial.h"
  182. #include "llpuppetmodule.h"
  183. #include "llpuppetmotion.h"
  184. //MK
  185. #include "mkrlinterface.h"
  186. //mk
  187. #include "llselectmgr.h"
  188. #include "llsky.h"
  189. #include "llstartup.h"
  190. #include "llstatusbar.h"
  191. #include "llsurfacepatch.h"
  192. #include "lltexturecache.h"
  193. #include "lltextureview.h"
  194. #include "lltool.h"
  195. #include "lltoolbar.h"
  196. #include "lltoolcomp.h"
  197. #include "lltoolface.h"
  198. #include "lltoolfocus.h"
  199. #include "lltoolgrab.h"
  200. #include "lltoolmgr.h"
  201. #include "lltoolpie.h"
  202. #include "lltoolplacer.h"
  203. #include "lltoolselectland.h"
  204. #include "lluserauth.h"
  205. #include "llvelocitybar.h" // For gVelocityBarp
  206. #include "llviewerassetupload.h" // For the upload queue
  207. #include "llvieweraudio.h"
  208. #include "hbviewerautomation.h"
  209. #include "llviewercamera.h"
  210. #include "llviewercontrol.h"
  211. #include "llviewerdisplay.h" // For gShaderProfileFrame
  212. #include "llviewergesture.h"
  213. #include "llviewerinventory.h"
  214. #include "llviewerjoystick.h"
  215. #include "llviewermessage.h" // send_generic_message(), give_money()
  216. #include "llviewerobjectexport.h"
  217. #include "llviewerobjectlist.h"
  218. #include "llviewerparcelmgr.h"
  219. #include "llviewerparceloverlay.h"
  220. #include "llviewerregion.h"
  221. #include "llviewershadermgr.h" // For LLViewerShaderMgr::sHasRP
  222. #include "llviewerstats.h"
  223. #include "llviewertexturelist.h" // For gTextureList
  224. #include "llviewerwindow.h"
  225. #include "llvoavatarself.h"
  226. #include "llvotree.h"
  227. #include "llvocache.h" // For HB_AJUSTED_VOCACHE_PARAMETERS
  228. #include "llvovolume.h"
  229. #include "llweb.h"
  230. #include "llwlskyparammgr.h"
  231. #include "llworld.h"
  232. #include "roles_constants.h"
  233. // When set to non-zero, adds a "Test llerrs crash" entry to the Advanced menu
  234. // (for error handling debugging only). HB
  235. #define LL_ENABLE_CRASH_TEST 0
  236. using namespace LLOldEvents;
  237. using namespace LLAvatarAppearanceDefines;
  238. //
  239. // Globals
  240. //
  241. bool gMenusInitialized = false;
  242. LLViewerMenuHolderGL* gMenuHolderp = NULL;
  243. LLMenuBarGL* gMenuBarViewp = NULL;
  244. LLMenuBarGL* gLoginMenuBarViewp = NULL;
  245. // Pie menus
  246. LLPieMenu* gPieSelfp = NULL;
  247. LLPieMenu* gPieAvatarp = NULL;
  248. LLPieMenu* gPieObjectp = NULL;
  249. LLPieMenu* gPieAttachmentp = NULL;
  250. LLPieMenu* gPieLandp = NULL;
  251. LLPieMenu* gPieParticlep = NULL;
  252. // Pie sub-menus
  253. LLPieMenu* gAttachScreenPieMenup = NULL;
  254. LLPieMenu* gAttachPieMenup = NULL;
  255. LLPieMenu* gDetachPieMenup = NULL;
  256. LLPieMenu* gDetachScreenPieMenup = NULL;
  257. LLPieMenu* gMutesPieMenup = NULL;
  258. LLPieMenu* gPieObjectMutep = NULL;
  259. // Sub-menus
  260. LLMenuGL* gDetachSubMenup = NULL;
  261. // This is the cost of a 2K texture upload for the agent, when 2K textures are
  262. // indeed supported on the grid *and* the cost for such texture is greater than
  263. // for smaller textures. Else this is 0. HB
  264. static S32 s2KTextureCost = 0;
  265. // Local constants.
  266. static const std::string CLIENT_MENU_NAME("Advanced");
  267. static const std::string SERVER_MENU_NAME("Admin");
  268. typedef LLMemberListener<LLView> view_listener_t;
  269. // Local prototypes (forward declarations)
  270. void initialize_menus();
  271. void init_client_menu(LLMenuGL* menu);
  272. void init_server_menu(LLMenuGL* menu);
  273. class LLMenuParcelObserver final : public LLParcelSelectionObserver
  274. {
  275. public:
  276. LLMenuParcelObserver();
  277. ~LLMenuParcelObserver() override;
  278. void changed() override;
  279. private:
  280. LLView* mLandBuyPass;
  281. LLView* mLanBuy;
  282. LLView* mBuyLand;
  283. };
  284. static LLMenuParcelObserver* sMenuParcelObserverp = NULL;
  285. LLMenuParcelObserver::LLMenuParcelObserver()
  286. {
  287. mLandBuyPass = gMenuHolderp->getChild<LLView>("Land Buy Pass");
  288. mLanBuy = gMenuHolderp->getChild<LLView>("Land Buy");
  289. mBuyLand = gMenuHolderp->getChild<LLView>("Buy Land...");
  290. gViewerParcelMgr.addSelectionObserver(this);
  291. }
  292. LLMenuParcelObserver::~LLMenuParcelObserver()
  293. {
  294. gViewerParcelMgr.removeSelectionObserver(this);
  295. }
  296. bool enable_buy_land(void*)
  297. {
  298. LLParcel* parcelp = gViewerParcelMgr.getParcelSelection()->getParcel();
  299. return gViewerParcelMgr.canAgentBuyParcel(parcelp, false);
  300. }
  301. void LLMenuParcelObserver::changed()
  302. {
  303. if (mLandBuyPass)
  304. {
  305. mLandBuyPass->setEnabled(LLPanelLandGeneral::enableBuyPass(NULL));
  306. }
  307. bool buyable = enable_buy_land(NULL);
  308. if (mLanBuy)
  309. {
  310. mLanBuy->setEnabled(buyable);
  311. }
  312. if (mBuyLand)
  313. {
  314. mBuyLand->setEnabled(buyable);
  315. }
  316. }
  317. // Called from llstartup.cpp
  318. void set_underclothes_menu_options()
  319. {
  320. #if LL_TEEN_WERABLE_RESTRICTIONS
  321. if (!gAgent.isTeen())
  322. {
  323. return;
  324. }
  325. if (gMenuHolderp)
  326. {
  327. gMenuHolderp->getChild<LLView>("Self Underpants")->setVisible(false);
  328. gMenuHolderp->getChild<LLView>("Self Undershirt")->setVisible(false);
  329. }
  330. if (gMenuBarViewp)
  331. {
  332. gMenuBarViewp->getChild<LLView>("Menu Underpants")->setVisible(false);
  333. gMenuBarViewp->getChild<LLView>("Menu Undershirt")->setVisible(false);
  334. }
  335. #endif
  336. }
  337. // Returns a pointer to the avatar give the UUID of the avatar OR of an
  338. // attachment the avatar is wearing. Returns NULL on failure.
  339. LLVOAvatar* find_avatar_from_object(LLViewerObject* object)
  340. {
  341. if (object)
  342. {
  343. if (object->isAttachment())
  344. {
  345. do
  346. {
  347. object = (LLViewerObject*) object->getParent();
  348. }
  349. while (object && !object->isAvatar());
  350. }
  351. else if (!object->isAvatar())
  352. {
  353. object = NULL;
  354. }
  355. }
  356. return (LLVOAvatar*)object;
  357. }
  358. // Returns a pointer to the avatar give the UUID of the avatar OR of an
  359. // attachment the avatar is wearing. Returns NULL on failure.
  360. LLVOAvatar* find_avatar_from_object(const LLUUID& object_id)
  361. {
  362. return find_avatar_from_object(gObjectList.findObject(object_id));
  363. }
  364. // Code required to calculate anything about the menus
  365. void pre_init_menus()
  366. {
  367. // static information
  368. LLColor4 color;
  369. color = gColors.getColor("MenuDefaultBgColor");
  370. LLMenuGL::setDefaultBackgroundColor(color);
  371. color = gColors.getColor("MenuItemEnabledColor");
  372. LLMenuItemGL::setEnabledColor(color);
  373. color = gColors.getColor("MenuItemDisabledColor");
  374. LLMenuItemGL::setDisabledColor(color);
  375. color = gColors.getColor("MenuItemHighlightBgColor");
  376. LLMenuItemGL::setHighlightBGColor(color);
  377. color = gColors.getColor("MenuItemHighlightFgColor");
  378. LLMenuItemGL::setHighlightFGColor(color);
  379. }
  380. bool enable_picker_actions(void*)
  381. {
  382. return !HBFileSelector::isInUse();
  383. }
  384. class LLSampleFloater final : public LLFloater
  385. {
  386. public:
  387. LLSampleFloater(const std::string& name)
  388. : LLFloater(name),
  389. mPanelp(NULL)
  390. {
  391. }
  392. ~LLSampleFloater() override
  393. {
  394. if (mPanelp)
  395. {
  396. delete mPanelp;
  397. mPanelp = NULL;
  398. }
  399. }
  400. public:
  401. LLPanel* mPanelp;
  402. };
  403. void load_from_xml_callback(HBFileSelector::ELoadFilter,
  404. std::string& filename, void*)
  405. {
  406. if (filename.empty())
  407. {
  408. return;
  409. }
  410. LLSampleFloater* floaterp = new LLSampleFloater("sample_floater");
  411. if (LLUICtrlFactory::getInstance()->buildFloater(floaterp, filename))
  412. {
  413. // Make sure the floater can be closed !
  414. floaterp->setCanClose(true);
  415. return;
  416. }
  417. // It is not a floater... Maybe a panel ?
  418. delete floaterp; // do not keep the failed build attempt
  419. floaterp = new LLSampleFloater("sample_floater");
  420. LLPanel* panelp = new LLPanel("sample_panel");
  421. floaterp->mPanelp = panelp;
  422. if (!LLUICtrlFactory::getInstance()->buildPanel(panelp, filename,
  423. &panelp->getFactoryMap()))
  424. {
  425. gNotifications.add("NotAFloater");
  426. delete floaterp;
  427. return;
  428. }
  429. if (!panelp->hasBorder())
  430. {
  431. panelp->addBorder();
  432. }
  433. panelp->setUseBoundingRect(true);
  434. panelp->updateBoundingRect();
  435. LLRect rect = panelp->getBoundingRect();
  436. rect.setOriginAndSize(0, 0, rect.getWidth() + 64,
  437. rect.getHeight() + 64 + LLFLOATER_HEADER_SIZE);
  438. floaterp->initFloater(filename, false, rect.getWidth(), rect.getHeight(),
  439. false, true, true);
  440. floaterp->setRect(rect);
  441. floaterp->setTitleVisible(true);
  442. floaterp->addChild(panelp);
  443. rect.mTop -= LLFLOATER_HEADER_SIZE;
  444. panelp->centerWithin(rect);
  445. panelp->setBorderVisible(true);
  446. floaterp->center();
  447. floaterp->open();
  448. }
  449. void handle_load_from_xml(void*)
  450. {
  451. HBFileSelector::loadFile(HBFileSelector::FFLOAD_XUI,
  452. load_from_xml_callback);
  453. }
  454. void handle_debug_tags(void*)
  455. {
  456. HBFloaterDebugTags::showInstance();
  457. }
  458. void update_upload_costs_in_menus()
  459. {
  460. if (!gMenuHolderp) return;
  461. LLEconomy* economyp = LLEconomy::getInstance();
  462. S32 upload_cost = economyp->getTextureUploadCost();
  463. S32 upload_2k_cost = economyp->get2KTextureUploadCost();
  464. if (gMaxImageSizeDefault > 1024 && upload_cost >= 0 &&
  465. upload_2k_cost > upload_cost)
  466. {
  467. s2KTextureCost = upload_2k_cost;
  468. }
  469. else
  470. {
  471. s2KTextureCost = 0;
  472. }
  473. if (upload_cost >= 0)
  474. {
  475. std::string cost;
  476. if (s2KTextureCost)
  477. {
  478. cost = llformat("%d/%d", upload_cost, upload_2k_cost);
  479. }
  480. else
  481. {
  482. cost = llformat("%d", upload_cost);
  483. }
  484. gMenuHolderp->childSetLabelArg("Upload Image", "[COST]", cost);
  485. gMenuHolderp->childSetLabelArg("Upload Material", "[COST]", cost);
  486. }
  487. else
  488. {
  489. gMenuHolderp->childSetLabelArg("Upload Image", "[COST]", "?");
  490. gMenuHolderp->childSetLabelArg("Upload Material", "[COST]", "?");
  491. }
  492. upload_cost = economyp->getSoundUploadCost();
  493. if (upload_cost >= 0)
  494. {
  495. gMenuHolderp->childSetLabelArg("Upload Sound", "[COST]",
  496. llformat("%d", upload_cost));
  497. }
  498. else
  499. {
  500. gMenuHolderp->childSetLabelArg("Upload Sound", "[COST]", "?");
  501. }
  502. upload_cost = economyp->getAnimationUploadCost();
  503. if (upload_cost >= 0)
  504. {
  505. gMenuHolderp->childSetLabelArg("Upload Animation", "[COST]",
  506. llformat("%d", upload_cost));
  507. }
  508. else
  509. {
  510. gMenuHolderp->childSetLabelArg("Upload Animation", "[COST]", "?");
  511. }
  512. }
  513. void init_menus()
  514. {
  515. S32 top = gViewerWindowp->getRootView()->getRect().getHeight();
  516. S32 width = gViewerWindowp->getRootView()->getRect().getWidth();
  517. //
  518. // Main menu bar
  519. //
  520. gMenuHolderp = new LLViewerMenuHolderGL();
  521. gMenuHolderp->setRect(LLRect(0, top, width, 0));
  522. gMenuHolderp->setFollowsAll();
  523. LLMenuGL::sMenuContainer = gMenuHolderp;
  524. // Initialize actions
  525. initialize_menus();
  526. LLUICtrlFactory* factoryp = LLUICtrlFactory::getInstance();
  527. //
  528. // Pie menus
  529. //
  530. gPieSelfp = factoryp->buildPieMenu("menu_pie_self.xml", gMenuHolderp);
  531. gDetachScreenPieMenup =
  532. gMenuHolderp->getChild<LLPieMenu>("Object Detach HUD");
  533. gDetachPieMenup = gMenuHolderp->getChild<LLPieMenu>("Object Detach");
  534. gPieAvatarp = factoryp->buildPieMenu("menu_pie_avatar.xml", gMenuHolderp);
  535. gMutesPieMenup = gMenuHolderp->getChild<LLPieMenu>("Mutes", true, false);
  536. gPieObjectp = factoryp->buildPieMenu("menu_pie_object.xml", gMenuHolderp);
  537. gPieObjectMutep = gMenuHolderp->getChild<LLPieMenu>("Mute Object Menu",
  538. true, false);
  539. gAttachScreenPieMenup =
  540. gMenuHolderp->getChild<LLPieMenu>("Object Attach HUD");
  541. gAttachPieMenup = gMenuHolderp->getChild<LLPieMenu>("Object Attach");
  542. gPieAttachmentp = factoryp->buildPieMenu("menu_pie_attachment.xml",
  543. gMenuHolderp);
  544. gPieLandp = factoryp->buildPieMenu("menu_pie_land.xml", gMenuHolderp);
  545. gPieParticlep = factoryp->buildPieMenu("menu_pie_particle.xml",
  546. gMenuHolderp);
  547. new HBLuaPieMenu();
  548. //
  549. // Set up the colors
  550. //
  551. LLColor4 color = LLUI::sPieMenuBgColor;
  552. gPieSelfp->setBackgroundColor(color);
  553. gPieAvatarp->setBackgroundColor(color);
  554. gPieObjectp->setBackgroundColor(color);
  555. gPieAttachmentp->setBackgroundColor(color);
  556. gPieLandp->setBackgroundColor(color);
  557. gPieParticlep->setBackgroundColor(color);
  558. gLuaPiep->setBackgroundColor(color);
  559. color = gColors.getColor("MenuPopupBgColor");
  560. // If we are not in production, use a different color to make it apparent.
  561. if (gIsInProductionGrid)
  562. {
  563. color = gColors.getColor("MenuBarBgColor");
  564. }
  565. else
  566. {
  567. color = gColors.getColor("MenuNonProductionBgColor");
  568. }
  569. gMenuBarViewp = (LLMenuBarGL*)factoryp->buildMenu("menu_viewer.xml",
  570. gMenuHolderp);
  571. gMenuBarViewp->setRect(LLRect(0, top, 0, top - gMenuBarHeight));
  572. gMenuBarViewp->setBackgroundColor(color);
  573. gMenuBarViewp->arrange();
  574. gMenuHolderp->addChild(gMenuBarViewp);
  575. // Menu holder appears on top of menu bar so you can see the menu title
  576. // flash when an item is triggered (the flash occurs in the holder)
  577. gViewerWindowp->getRootView()->addChild(gMenuHolderp);
  578. gViewerWindowp->setMenuBackgroundColor();
  579. update_upload_costs_in_menus();
  580. gDetachSubMenup = gMenuBarViewp->getChildMenuByName("Detach Object", true);
  581. LLMenuGL* menu = new LLMenuGL(CLIENT_MENU_NAME);
  582. init_client_menu(menu);
  583. gMenuBarViewp->appendMenu(menu);
  584. menu->updateParent(gMenuHolderp);
  585. menu = new LLMenuGL(SERVER_MENU_NAME);
  586. init_server_menu(menu);
  587. gMenuBarViewp->appendMenu(menu);
  588. menu->updateParent(gMenuHolderp);
  589. gMenuBarViewp->createJumpKeys();
  590. // Let land based option enable when parcel changes
  591. sMenuParcelObserverp = new LLMenuParcelObserver();
  592. // Debug menu visiblity
  593. show_debug_menus();
  594. gLoginMenuBarViewp = (LLMenuBarGL*)factoryp->buildMenu("menu_login.xml",
  595. gMenuHolderp);
  596. LLRect rect = gLoginMenuBarViewp->getRect();
  597. gLoginMenuBarViewp->setRect(LLRect(rect.mLeft, rect.mTop,
  598. gViewerWindowp->getRootView()->getRect().getWidth() -
  599. rect.mLeft, rect.mBottom));
  600. gLoginMenuBarViewp->setBackgroundColor(color);
  601. gMenuHolderp->addChild(gLoginMenuBarViewp);
  602. gMenusInitialized = true;
  603. }
  604. void handle_rebake_textures(void*)
  605. {
  606. if (isAgentAvatarValid())
  607. {
  608. gAgentAvatarp->forceBakeAllTextures(true);
  609. if (LLVOAvatarSelf::canUseServerBaking())
  610. {
  611. gAgentAvatarp->computeBodySize(true);
  612. static LLCachedControl<bool> aggressive_rebake(gSavedSettings,
  613. "AvatarAggressiveRebake");
  614. if (aggressive_rebake)
  615. {
  616. gAppearanceMgr.incrementCofVersion();
  617. }
  618. else
  619. {
  620. gAppearanceMgr.mNeedsSyncWearables = true;
  621. gAppearanceMgr.mNeedsSyncAttachments = true;
  622. // This trick will force a rebake even if no wearable or
  623. // attachment link gets updated.
  624. gAgentAvatarp->mLastUpdateRequestCOFVersion =
  625. LLViewerInventoryCategory::VERSION_UNKNOWN;
  626. }
  627. }
  628. }
  629. }
  630. void toggle_visibility(void* user_data)
  631. {
  632. LLView* viewp = (LLView*)user_data;
  633. if (viewp)
  634. {
  635. viewp->setVisible(!viewp->getVisible());
  636. }
  637. }
  638. bool get_visibility(void* user_data)
  639. {
  640. LLView* viewp = (LLView*)user_data;
  641. return viewp && viewp->getVisible();
  642. }
  643. void menu_toggle_control(void* user_data)
  644. {
  645. std::string setting((char*)user_data);
  646. gSavedSettings.setBool(setting.c_str(),
  647. !gSavedSettings.getBool(setting.c_str()));
  648. }
  649. bool menu_check_control(void* user_data)
  650. {
  651. return gSavedSettings.getBool((char*)user_data);
  652. }
  653. void handle_show_debug_settings(void*)
  654. {
  655. LLFloaterDebugSettings::showInstance();
  656. }
  657. #if TRACY_ENABLE
  658. void handle_tracy_profiler(void*)
  659. {
  660. if (!TracyIsConnected)
  661. {
  662. HBTracyProfiler::launch();
  663. }
  664. }
  665. bool tracy_not_connected(void*)
  666. {
  667. return !TracyIsConnected;
  668. }
  669. #endif
  670. void handle_show_notifications_console(void*)
  671. {
  672. LLFloaterNotificationConsole::showInstance();
  673. }
  674. void handle_region_debug_console(void*)
  675. {
  676. LLFloaterRegionDebugConsole::showInstance();
  677. }
  678. void handle_region_dump_settings(void*)
  679. {
  680. LLViewerRegion* regionp = gAgent.getRegion();
  681. if (regionp)
  682. {
  683. regionp->dumpSettings();
  684. }
  685. }
  686. void handle_dump_capabilities_info(void*)
  687. {
  688. LLViewerRegion* regionp = gAgent.getRegion();
  689. if (regionp)
  690. {
  691. regionp->logActiveCapabilities();
  692. }
  693. }
  694. void handle_dump_group_info(void*)
  695. {
  696. llinfos << "Group: " << gAgent.mGroupName << llendl;
  697. llinfos << "Id: " << gAgent.mGroupID << llendl;
  698. llinfos << "Powers: " << gAgent.mGroupPowers << llendl;
  699. llinfos << "Title: " << gAgent.mGroupTitle << llendl;
  700. }
  701. void handle_dump_focus(void*)
  702. {
  703. LLUICtrl* ctrl = gFocusMgr.getKeyboardFocusUICtrl();
  704. llinfos << "Keyboard focus " << (ctrl ? ctrl->getName() : "(none)")
  705. << llendl;
  706. }
  707. void print_packets_lost(void*)
  708. {
  709. gWorld.printPacketsLost();
  710. }
  711. void print_object_info(void*)
  712. {
  713. gSelectMgr.selectionDump();
  714. }
  715. void dump_select_mgr(void*)
  716. {
  717. gSelectMgr.dump();
  718. }
  719. void dump_cmd_handlers(void*)
  720. {
  721. LLCommandHandler::dump();
  722. }
  723. void dump_stale_images(void*)
  724. {
  725. LLImageGL::dumpStaleList();
  726. }
  727. void dump_inventory(void*)
  728. {
  729. gInventory.dumpInventory();
  730. }
  731. void print_agent_nvpairs(void*)
  732. {
  733. llinfos << "Agent name-value pairs:" << llendl;
  734. LLViewerObject* objectp = gObjectList.findObject(gAgentID);
  735. if (objectp)
  736. {
  737. objectp->printNameValuePairs();
  738. }
  739. else
  740. {
  741. llinfos << "Cannot find agent object" << llendl;
  742. }
  743. llinfos << "Camera at " << gAgent.getCameraPositionGlobal() << llendl;
  744. }
  745. void velocity_interpolate(void* data)
  746. {
  747. bool toggle = gSavedSettings.getBool("VelocityInterpolate");
  748. LLMessageSystem* msg = gMessageSystemp;
  749. if (!toggle)
  750. {
  751. msg->newMessageFast(_PREHASH_VelocityInterpolateOn);
  752. msg->nextBlockFast(_PREHASH_AgentData);
  753. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  754. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  755. gAgent.sendReliableMessage();
  756. llinfos << "Velocity Interpolation On" << llendl;
  757. }
  758. else
  759. {
  760. msg->newMessageFast(_PREHASH_VelocityInterpolateOff);
  761. msg->nextBlockFast(_PREHASH_AgentData);
  762. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  763. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  764. gAgent.sendReliableMessage();
  765. llinfos << "Velocity Interpolation Off" << llendl;
  766. }
  767. if (data)
  768. {
  769. gSavedSettings.setBool((char*)data, !toggle);
  770. }
  771. }
  772. bool check_admin_override(void*)
  773. {
  774. return gAgent.getAdminOverride();
  775. }
  776. void handle_admin_override_toggle(void*)
  777. {
  778. gAgent.setAdminOverride(!gAgent.getAdminOverride());
  779. // The above may have affected which debug menus are visible
  780. show_debug_menus();
  781. if (gStatusBarp)
  782. {
  783. gStatusBarp->setDirty();
  784. }
  785. }
  786. void handle_god_mode(void*)
  787. {
  788. gAgent.requestEnterGodMode();
  789. }
  790. void handle_leave_god_mode(void*)
  791. {
  792. gAgent.requestLeaveGodMode();
  793. }
  794. bool enable_god_options(void*)
  795. {
  796. bool may_be_linden = true; // Linden or OpenSim admin
  797. if (isAgentAvatarValid() && gIsInSecondLife)
  798. {
  799. LLNameValue* lastname = gAgentAvatarp->getNVPair("LastName");
  800. if (lastname)
  801. {
  802. std::string name = lastname->getString();
  803. may_be_linden = name == "Linden";
  804. }
  805. }
  806. return may_be_linden;
  807. }
  808. bool enable_non_faked_god(void*)
  809. {
  810. return gAgent.isGodlikeWithoutAdminMenuFakery();
  811. }
  812. bool enable_god_customer_service(void*)
  813. {
  814. return gAgent.getGodLevel() >= GOD_CUSTOMER_SERVICE &&
  815. enable_god_options(NULL);
  816. }
  817. void handle_god_tools(void*)
  818. {
  819. LLFloaterGodTools::showInstance();
  820. }
  821. bool enable_god_basic(void*)
  822. {
  823. return gAgent.getGodLevel() > GOD_NOT;
  824. }
  825. bool check_message_logging(void*)
  826. {
  827. return gMessageSystemp->mVerboseLog;
  828. }
  829. void handle_viewer_toggle_message_log(void*)
  830. {
  831. LLMessageSystem* msg = gMessageSystemp;
  832. if (msg->mVerboseLog)
  833. {
  834. msg->stopLogging();
  835. }
  836. else
  837. {
  838. msg->startLogging();
  839. }
  840. }
  841. void save_settings_to_xml_callback(HBFileSelector::ESaveFilter filter,
  842. std::string& filename,
  843. void* user_data)
  844. {
  845. S32 type = (S32)(intptr_t)user_data;
  846. if (!filename.empty())
  847. {
  848. if (type < 2)
  849. {
  850. gSavedSettings.saveToFile(filename, false, type == 1);
  851. }
  852. else
  853. {
  854. gSavedPerAccountSettings.saveToFile(filename, false, type == 3);
  855. }
  856. }
  857. }
  858. void handle_save_settings_to_xml(void* user_data)
  859. {
  860. S32 type = (S32)(intptr_t)user_data;
  861. std::string suggestion;
  862. switch (type)
  863. {
  864. case 0:
  865. suggestion = "settings_coolvlviewer.xml";
  866. break;
  867. case 1:
  868. suggestion = "settings.xml";
  869. break;
  870. case 2:
  871. suggestion = "settings_per_account_coolvlviewer.xml";
  872. break;
  873. case 3:
  874. suggestion = "settings_per_account.xml";
  875. break;
  876. default:
  877. llwarns << "Bad type: " << type << llendl;
  878. return;
  879. }
  880. // Open the file save dialog
  881. HBFileSelector::saveFile(HBFileSelector::FFSAVE_XML, suggestion,
  882. save_settings_to_xml_callback, user_data);
  883. }
  884. bool object_cache_enabled(void*)
  885. {
  886. return LLVOCache::getInstance()->isEnabled();
  887. }
  888. bool object_cache_read_checked(void*)
  889. {
  890. static LLCachedControl<bool> reads(gSavedSettings, "ObjectDiskCacheReads");
  891. return reads && object_cache_enabled(NULL);
  892. }
  893. bool object_cache_threaded_reads_checked(void*)
  894. {
  895. static LLCachedControl<bool> threaded(gSavedSettings,
  896. "ThreadedObjectCacheReads");
  897. return threaded && object_cache_enabled(NULL);
  898. }
  899. bool object_cache_write_enabled(void*)
  900. {
  901. LLVOCache* cachep = LLVOCache::getInstance();
  902. return cachep->isEnabled() && !cachep->isReadOnly();
  903. }
  904. bool object_cache_write_checked(void*)
  905. {
  906. static LLCachedControl<bool> writes(gSavedSettings,
  907. "ObjectDiskCacheWrites");
  908. return writes && object_cache_write_enabled(NULL);
  909. }
  910. bool object_cache_threaded_writes_checked(void*)
  911. {
  912. static LLCachedControl<bool> threaded(gSavedSettings,
  913. "ThreadedObjectCacheWrites");
  914. return threaded && object_cache_write_enabled(NULL);
  915. }
  916. bool in_sl(void*)
  917. {
  918. return gIsInSecondLife;
  919. }
  920. bool not_in_sl(void*)
  921. {
  922. return !gIsInSecondLife;
  923. }
  924. bool large_bakes_checked(void*)
  925. {
  926. static LLCachedControl<bool> large_bakes(gSavedPerAccountSettings,
  927. "OSUseLargeAvatarBakes");
  928. return !gIsInSecondLife && large_bakes;
  929. }
  930. void toggle_large_bakes(void*)
  931. {
  932. bool b = gSavedPerAccountSettings.getBool("OSUseLargeAvatarBakes");
  933. gSavedPerAccountSettings.setBool("OSUseLargeAvatarBakes", !b);
  934. }
  935. bool http_inventory_checked(void*)
  936. {
  937. static LLCachedControl<bool> http_inv(gSavedSettings, "UseHTTPInventory");
  938. return gIsInSecondLife || http_inv;
  939. }
  940. bool getmesh2_checked(void*)
  941. {
  942. static LLCachedControl<bool> getmesh2(gSavedSettings, "UseGetMesh2Cap");
  943. return gIsInSecondLife || getmesh2;
  944. }
  945. bool viewerasset_checked(void*)
  946. {
  947. static LLCachedControl<bool> viewerasset(gSavedSettings,
  948. "UseViewerAssetCap");
  949. return gIsInSecondLife || viewerasset;
  950. }
  951. bool ais3_enabled(void*)
  952. {
  953. return http_inventory_checked(NULL) &&
  954. gAgent.hasRegionCapability("InventoryAPIv3");
  955. }
  956. bool ais3_checked(void*)
  957. {
  958. static LLCachedControl<bool> use_ais(gSavedSettings, "UseAISForInventory");
  959. return use_ais && ais3_enabled(NULL);
  960. }
  961. bool ais3_fetch_checked(void*)
  962. {
  963. static LLCachedControl<bool> use_ais(gSavedSettings, "UseAISForFetching");
  964. return use_ais && ais3_checked(NULL);
  965. }
  966. bool ais3_links_enabled(void*)
  967. {
  968. static LLCachedControl<bool> use_ais(gSavedSettings, "UseAISForInventory");
  969. return gIsInSecondLife && !use_ais && ais3_enabled(NULL);
  970. }
  971. bool ais3_links_checked(void*)
  972. {
  973. static LLCachedControl<bool> ais_links(gSavedSettings, "UseAISForLinksInSL");
  974. return gIsInSecondLife && ais_links && ais3_enabled(NULL);
  975. }
  976. bool agent_profile_enabled(void*)
  977. {
  978. return gAgent.hasRegionCapability("AgentProfile");
  979. }
  980. bool agent_profile_checked(void*)
  981. {
  982. static LLCachedControl<bool> use_cap(gSavedSettings, "UseAgentProfileCap");
  983. return use_cap && agent_profile_enabled(NULL);
  984. }
  985. #if LIBCURL_VERSION_MAJOR > 7 || LIBCURL_VERSION_MINOR >= 54
  986. bool pipelining_enabled(void*)
  987. {
  988. if (gIsInSecondLife)
  989. {
  990. static LLCachedControl<bool> sl_ok(gSavedSettings, "HttpPipeliningSL");
  991. return sl_ok;
  992. }
  993. static LLCachedControl<bool> os_ok(gSavedSettings, "HttpPipeliningOS");
  994. return os_ok;
  995. }
  996. bool http2_checked(void*)
  997. {
  998. static LLCachedControl<bool> http2(gSavedSettings, "EnableHTTP2");
  999. return http2 && pipelining_enabled(NULL);
  1000. }
  1001. #endif
  1002. void restart_audio_engine(void*)
  1003. {
  1004. gSavedSettings.setBool("NoAudio", false);
  1005. LLStartUp::startAudioEngine();
  1006. }
  1007. #if LL_LINUX && LL_FMOD
  1008. bool fmod_enabled(void*)
  1009. {
  1010. static LLCachedControl<bool> no_fmod(gSavedSettings, "AudioDisableFMOD");
  1011. return !no_fmod;
  1012. }
  1013. #endif
  1014. void clear_asset_cache(void*)
  1015. {
  1016. gSavedSettings.setBool("ClearAssetCache", true);
  1017. gNotifications.add("AssetCacheWillClear");
  1018. }
  1019. void clear_inventory_cache(void*)
  1020. {
  1021. gSavedPerAccountSettings.setBool("ClearInventoryCache", true);
  1022. gNotifications.add("InventoryCacheWillClear");
  1023. }
  1024. void clear_texture_cache(void*)
  1025. {
  1026. gSavedSettings.setBool("ClearTextureCache", true);
  1027. gNotifications.add("TextureCacheWillClear");
  1028. }
  1029. void clear_object_cache(void*)
  1030. {
  1031. gSavedSettings.setBool("ClearObjectCache", true);
  1032. gNotifications.add("ObjectCacheWillClear");
  1033. }
  1034. bool can_write_caches(void*)
  1035. {
  1036. return gAppViewerp && !gAppViewerp->isSecondInstanceSiblingViewer();
  1037. }
  1038. void load_automation_script_callback(HBFileSelector::ELoadFilter,
  1039. std::string& filename, void*)
  1040. {
  1041. if (!filename.empty())
  1042. {
  1043. HBViewerAutomation::start(filename);
  1044. }
  1045. }
  1046. void load_automation_script(void*)
  1047. {
  1048. HBFileSelector::loadFile(HBFileSelector::FFLOAD_LUA,
  1049. load_automation_script_callback);
  1050. }
  1051. void reload_automation_script(void*)
  1052. {
  1053. HBViewerAutomation::start();
  1054. }
  1055. void stop_automation(void*)
  1056. {
  1057. HBViewerAutomation::cleanup();
  1058. }
  1059. void open_lua_console(void*)
  1060. {
  1061. HBLuaConsole::showInstance();
  1062. }
  1063. void execute_lua_script_callback(HBFileSelector::ELoadFilter,
  1064. std::string& filename, void*)
  1065. {
  1066. if (!filename.empty())
  1067. {
  1068. HBViewerAutomation::execute(filename);
  1069. }
  1070. }
  1071. void execute_lua_script(void*)
  1072. {
  1073. HBFileSelector::loadFile(HBFileSelector::FFLOAD_LUA,
  1074. execute_lua_script_callback);
  1075. }
  1076. void edit_automation_script(void*)
  1077. {
  1078. // A simple editor launcher, without live file tracking. Declaring it here
  1079. // as a static object will allow for self-cleaning on viewer exit.
  1080. static HBExternalEditor editor(NULL);
  1081. editor.kill();
  1082. std::string error = "No Lua automation script found/configured.";
  1083. std::string lua_script = gSavedSettings.getString("LuaAutomationScript");
  1084. if (!lua_script.empty())
  1085. {
  1086. lua_script = gDirUtil.getFullPath(LL_PATH_USER_SETTINGS, lua_script);
  1087. if (LLFile::exists(lua_script))
  1088. {
  1089. if (editor.open(lua_script))
  1090. {
  1091. return;
  1092. }
  1093. error = editor.getErrorMessage();
  1094. }
  1095. }
  1096. LLSD args;
  1097. args["MESSAGE"]= error;
  1098. gNotifications.add("GenericAlert", args);
  1099. }
  1100. bool hud_info_bg_enabled(void*)
  1101. {
  1102. return !(gVelocityBarp && gVelocityBarp->getVisible());
  1103. }
  1104. bool hud_info_bg_checked(void*)
  1105. {
  1106. static LLCachedControl<bool> hud_bg(gSavedSettings, "HUDInfoBackground");
  1107. return hud_bg && hud_info_bg_enabled(NULL);
  1108. }
  1109. void handle_dump_followcam(void*)
  1110. {
  1111. LLFollowCamMgr::dump();
  1112. }
  1113. void handle_dump_region_object_cache(void*)
  1114. {
  1115. LLViewerRegion* regionp = gAgent.getRegion();
  1116. if (regionp)
  1117. {
  1118. regionp->dumpCache();
  1119. }
  1120. }
  1121. #if LL_ENABLE_CRASH_TEST
  1122. void handle_llerrs_test(void*)
  1123. {
  1124. llerrs << "This is a voluntary crash test..." << llendl;
  1125. }
  1126. #endif
  1127. void init_debug_console_menu(LLMenuGL* sub)
  1128. {
  1129. sub->append(new LLMenuItemCheckGL("Texture console", toggle_visibility,
  1130. NULL, get_visibility,
  1131. (void*)gTextureViewp,
  1132. '3', MASK_CONTROL|MASK_SHIFT));
  1133. #if LL_FAST_TIMERS_ENABLED
  1134. sub->append(new LLMenuItemCheckGL("Fast timers view", toggle_visibility,
  1135. NULL, get_visibility,
  1136. (void*)gFastTimerViewp,
  1137. '9', MASK_CONTROL|MASK_SHIFT));
  1138. sub->append(new LLMenuItemCheckGL("Fast timers always enabled",
  1139. menu_toggle_control, NULL,
  1140. menu_check_control,
  1141. (void*)"FastTimersAlwaysEnabled"));
  1142. #endif
  1143. #if TRACY_ENABLE
  1144. sub->append(new LLMenuItemCallGL("Launch Tracy profiler",
  1145. handle_tracy_profiler,
  1146. tracy_not_connected, NULL,
  1147. '8', MASK_CONTROL|MASK_SHIFT));
  1148. #endif
  1149. sub->appendSeparator();
  1150. LLView* debugview = gDebugViewp ? gDebugViewp->mDebugConsolep : NULL;
  1151. sub->append(new LLMenuItemCheckGL("Debug console", toggle_visibility,
  1152. NULL, get_visibility, debugview,
  1153. '4', MASK_CONTROL|MASK_SHIFT));
  1154. sub->append(new LLMenuItemToggleGL("Allow DEBUG messages",
  1155. &LLError::Log::sDebugMessages));
  1156. sub->append(new LLMenuItemCheckGL("Precise timestamps in log file",
  1157. menu_toggle_control, NULL,
  1158. menu_check_control,
  1159. (void*)"PreciseLogTimestamps"));
  1160. sub->append(new LLMenuItemCallGL("Debug tags", handle_debug_tags, NULL));
  1161. LLMenuGL* sub2 = new LLMenuGL("Info to debug console");
  1162. sub->appendMenu(sub2);
  1163. sub2->append(new LLMenuItemCallGL("Region info",
  1164. handle_region_dump_settings));
  1165. sub2->append(new LLMenuItemCallGL("Region object cache stats",
  1166. handle_dump_region_object_cache, NULL));
  1167. sub2->append(new LLMenuItemCallGL("Capabilities info",
  1168. handle_dump_capabilities_info));
  1169. sub2->append(new LLMenuItemCallGL("Group Info", handle_dump_group_info));
  1170. sub2->append(new LLMenuItemCallGL("Packets lost info",
  1171. print_packets_lost));
  1172. sub2->append(new LLMenuItemCallGL("Dump inventory", dump_inventory));
  1173. sub2->append(new LLMenuItemCallGL("Dump selection manager",
  1174. dump_select_mgr));
  1175. sub2->append(new LLMenuItemCallGL("Dump focus holder",
  1176. handle_dump_focus, NULL, NULL, 'F',
  1177. MASK_ALT | MASK_CONTROL | MASK_SHIFT));
  1178. sub2->append(new LLMenuItemCallGL("Dump scripted camera",
  1179. handle_dump_followcam, NULL));
  1180. sub2->append(new LLMenuItemCallGL("Selected object info",
  1181. print_object_info, NULL, NULL, 'P',
  1182. MASK_CONTROL | MASK_SHIFT));
  1183. sub2->append(new LLMenuItemCallGL("Agent info", print_agent_nvpairs));
  1184. sub2->append(new LLMenuItemCallGL("Registered command handlers",
  1185. dump_cmd_handlers));
  1186. sub2->append(new LLMenuItemCallGL("Memory stats", output_statistics));
  1187. sub2->append(new LLMenuItemCheckGL("Server UDP messages (spammy)",
  1188. &handle_viewer_toggle_message_log, NULL,
  1189. &check_message_logging, NULL));
  1190. sub2->append(new LLMenuItemCallGL("Stale images list", dump_stale_images));
  1191. sub2->createJumpKeys();
  1192. sub->appendSeparator();
  1193. // Debugging view for unified notifications
  1194. sub->append(new LLMenuItemCallGL("Notifications console...",
  1195. handle_show_notifications_console, NULL, NULL, '5',
  1196. MASK_CONTROL | MASK_SHIFT));
  1197. sub->append(new LLMenuItemCallGL("Region debug console",
  1198. handle_region_debug_console, NULL, NULL, 'C',
  1199. MASK_CONTROL | MASK_SHIFT));
  1200. sub->createJumpKeys();
  1201. }
  1202. void init_hud_info_menu(LLMenuGL* sub)
  1203. {
  1204. sub->append(new LLMenuItemCheckGL("Show velocity info", toggle_visibility,
  1205. NULL, get_visibility,
  1206. (void*)gVelocityBarp));
  1207. sub->append(new LLMenuItemCheckGL("Show mesh queue", menu_toggle_control,
  1208. NULL, menu_check_control,
  1209. (void*)"DebugShowMeshQueue"));
  1210. sub->append(new LLMenuItemToggleGL("Show camera info",
  1211. &gDisplayCameraPos));
  1212. sub->append(new LLMenuItemToggleGL("Show FOV Info", &gDisplayFOV));
  1213. sub->append(new LLMenuItemCheckGL("Show matrices", menu_toggle_control,
  1214. NULL, menu_check_control,
  1215. (void*)"DebugShowRenderMatrices"));
  1216. sub->append(new LLMenuItemCheckGL("Show avatars render info",
  1217. menu_toggle_control, NULL,
  1218. menu_check_control,
  1219. (void*)"DebugShowAvatarRenderInfo"));
  1220. sub->append(new LLMenuItemCheckGL("Show render info", menu_toggle_control,
  1221. NULL, menu_check_control,
  1222. (void*)"DebugShowRenderInfo"));
  1223. sub->append(new LLMenuItemToggleGL("Show wind info", &gDisplayWindInfo));
  1224. sub->append(new LLMenuItemCheckGL("Show time", menu_toggle_control, NULL,
  1225. menu_check_control,
  1226. (void*)"DebugShowTime"));
  1227. sub->append(new LLMenuItemCheckGL("Show poll request age",
  1228. menu_toggle_control, NULL,
  1229. menu_check_control,
  1230. (void*)"DebugShowPollRequestAge"));
  1231. sub->append(new LLMenuItemCheckGL("Show frame rate", menu_toggle_control,
  1232. NULL, menu_check_control,
  1233. (void*)"DebugShowFPS"));
  1234. sub->append(new LLMenuItemCheckGL("Show color under cursor",
  1235. menu_toggle_control, NULL,
  1236. menu_check_control,
  1237. (void*)"DebugShowColor"));
  1238. sub->appendSeparator();
  1239. sub->append(new LLMenuItemCheckGL("Show info HUD background",
  1240. menu_toggle_control, hud_info_bg_enabled,
  1241. hud_info_bg_checked,
  1242. (void*)"HUDInfoBackground"));
  1243. sub->createJumpKeys();
  1244. }
  1245. void init_lua_scripting_menu(LLMenuGL* sub)
  1246. {
  1247. sub->append(new LLMenuItemCallGL("Load new automation script...",
  1248. load_automation_script));
  1249. sub->append(new LLMenuItemCallGL("Re-load current automation script",
  1250. reload_automation_script));
  1251. sub->append(new LLMenuItemCallGL("Stop current automation script",
  1252. stop_automation));
  1253. sub->append(new LLMenuItemCallGL("Edit the automation script",
  1254. edit_automation_script));
  1255. sub->append(new LLMenuItemCallGL("Execute a Lua script file...",
  1256. execute_lua_script));
  1257. sub->appendSeparator();
  1258. sub->append(new LLMenuItemCheckGL("Accept Lua from LSL scripts",
  1259. menu_toggle_control, NULL,
  1260. menu_check_control,
  1261. (void*)"LuaAcceptScriptCommands"));
  1262. # if LL_LINUX
  1263. sub->append(new LLMenuItemCheckGL("Accept Lua commands from D-Bus",
  1264. menu_toggle_control, NULL,
  1265. menu_check_control,
  1266. (void*)"LuaAcceptDbusCommands"));
  1267. # endif
  1268. sub->appendSeparator();
  1269. sub->append(new LLMenuItemCallGL("Open the Lua console",
  1270. open_lua_console, NULL, NULL,
  1271. 'L', MASK_CONTROL|MASK_ALT));
  1272. sub->createJumpKeys();
  1273. }
  1274. bool tp_race_checked(void*)
  1275. {
  1276. static LLCachedControl<bool> enabled(gSavedSettings,
  1277. "TPRaceWorkAroundInSL");
  1278. return gIsInSecondLife && enabled;
  1279. }
  1280. void init_network_menu(LLMenuGL* sub)
  1281. {
  1282. sub->append(new LLMenuItemCheckGL("Use web map tiles", menu_toggle_control,
  1283. NULL, menu_check_control,
  1284. (void*)"UseWebMapTiles"));
  1285. sub->append(new LLMenuItemCheckGL("Use HTTP inventory fetches",
  1286. menu_toggle_control, not_in_sl,
  1287. http_inventory_checked,
  1288. (void*)"UseHTTPInventory"));
  1289. sub->append(new LLMenuItemCheckGL("Use AISv3 protocol for inventory",
  1290. menu_toggle_control, ais3_enabled,
  1291. ais3_checked,
  1292. (void*)"UseAISForInventory"));
  1293. sub->append(new LLMenuItemCheckGL("Use AISv3 for inventory fetches",
  1294. menu_toggle_control, ais3_checked,
  1295. ais3_fetch_checked,
  1296. (void*)"UseAISForFetching"));
  1297. sub->append(new LLMenuItemCheckGL("Always use AISv3 to create links",
  1298. menu_toggle_control, ais3_links_enabled,
  1299. ais3_links_checked,
  1300. (void*)"UseAISForLinksInSL"));
  1301. sub->append(new LLMenuItemCheckGL("Use HTTP group data fetches",
  1302. menu_toggle_control, NULL,
  1303. menu_check_control,
  1304. (void*)"UseHTTPGroupDataFetch"));
  1305. sub->append(new LLMenuItemCheckGL("Use the AgentProfile capability",
  1306. menu_toggle_control,
  1307. agent_profile_enabled,
  1308. agent_profile_checked,
  1309. (void*)"UseAgentProfileCap"));
  1310. sub->append(new LLMenuItemCheckGL("Use offline IMs fetch capability",
  1311. menu_toggle_control, NULL,
  1312. menu_check_control,
  1313. (void*)"UseOfflineIMsCapability"));
  1314. sub->append(new LLMenuItemCheckGL("Use GetMesh2 capability for meshes",
  1315. menu_toggle_control, not_in_sl,
  1316. getmesh2_checked,
  1317. (void*)"UseGetMesh2Cap"));
  1318. sub->append(new LLMenuItemCheckGL("Use ViewerAsset capability for assets",
  1319. menu_toggle_control, not_in_sl,
  1320. viewerasset_checked,
  1321. (void*)"UseViewerAssetCap"));
  1322. sub->append(new LLMenuItemCheckGL("Get meshes retry delay from HTTP header",
  1323. menu_toggle_control, NULL,
  1324. menu_check_control,
  1325. (void*)"MeshUseHttpRetryAfter"));
  1326. sub->append(new LLMenuItemCheckGL("Get textures retry delay from HTTP header",
  1327. menu_toggle_control, NULL,
  1328. menu_check_control,
  1329. (void*)"TextureRetryDelayFromHeader"));
  1330. #if LIBCURL_VERSION_MAJOR > 7 || LIBCURL_VERSION_MINOR >= 54
  1331. sub->append(new LLMenuItemCheckGL("Use the HTTP/2 protocol",
  1332. menu_toggle_control, pipelining_enabled,
  1333. http2_checked, (void*)"EnableHTTP2"));
  1334. #endif
  1335. sub->append(new LLMenuItemCheckGL("Disable HTTP range requests",
  1336. menu_toggle_control, NULL,
  1337. menu_check_control,
  1338. (void*)"HttpRangeRequestsDisable"));
  1339. sub->appendSeparator();
  1340. sub->append(new LLMenuItemCheckGL("Staged sim disabling",
  1341. menu_toggle_control, NULL,
  1342. menu_check_control,
  1343. (void*)"StagedSimDisabling"));
  1344. sub->append(new LLMenuItemCheckGL("Clear stale texture fetches on TP",
  1345. menu_toggle_control, NULL,
  1346. menu_check_control,
  1347. (void*)"ClearStaleTextureFetchesOnTP"));
  1348. #if !LL_PENDING_MESH_REQUEST_SORTING
  1349. sub->append(new LLMenuItemCheckGL("Delay pending mesh fetches on TP",
  1350. menu_toggle_control, NULL,
  1351. menu_check_control,
  1352. (void*)"DelayPendingMeshFetchesOnTP"));
  1353. #endif
  1354. sub->append(new LLMenuItemCheckGL("TP race workaround",
  1355. menu_toggle_control, in_sl,
  1356. tp_race_checked,
  1357. (void*)"TPRaceWorkAroundInSL"));
  1358. sub->appendSeparator();
  1359. sub->append(new LLMenuItemCheckGL("Velocity interpolate objects",
  1360. velocity_interpolate, NULL,
  1361. menu_check_control,
  1362. (void*)"VelocityInterpolate"));
  1363. sub->append(new LLMenuItemCheckGL("Ping interpolate object positions",
  1364. menu_toggle_control, NULL,
  1365. menu_check_control,
  1366. (void*)"PingInterpolate"));
  1367. sub->append(new LLMenuItemCheckGL("Auto-kill bogus objects",
  1368. menu_toggle_control, NULL,
  1369. menu_check_control,
  1370. (void*)"KillBogusObjects"));
  1371. sub->append(new LLMenuItemCheckGL("Ignore bogus kill-attachment messages",
  1372. menu_toggle_control,
  1373. NULL, menu_check_control,
  1374. (void*)"IgnoreOuterRegionAttachKill"));
  1375. sub->appendSeparator();
  1376. sub->append(new LLMenuItemToggleGL("Show object updates",
  1377. &gShowObjectUpdates));
  1378. sub->createJumpKeys();
  1379. }
  1380. void init_caches_menu(LLMenuGL* sub)
  1381. {
  1382. sub->append(new LLMenuItemCallGL("Clear group cache",
  1383. LLGroupMgr::debugClearAllGroups));
  1384. sub->append(new LLMenuItemCallGL("Clear texture cache (after restart)",
  1385. clear_texture_cache, can_write_caches));
  1386. sub->append(new LLMenuItemCallGL("Clear object cache (after restart)",
  1387. clear_object_cache, can_write_caches));
  1388. sub->append(new LLMenuItemCallGL("Clear asset cache (after restart)",
  1389. clear_asset_cache, can_write_caches));
  1390. sub->append(new LLMenuItemCallGL("Clear inventory cache (after restart)",
  1391. clear_inventory_cache));
  1392. sub->appendSeparator();
  1393. sub->append(new LLMenuItemCheckGL("Time-sliced texture cache purges",
  1394. menu_toggle_control, NULL,
  1395. menu_check_control,
  1396. (void*)"CachePurgeTimeSliced"));
  1397. sub->appendSeparator();
  1398. sub->append(new LLMenuItemCheckGL("Full region caching (after restart)",
  1399. menu_toggle_control, NULL,
  1400. menu_check_control,
  1401. (void*)"RequestFullRegionCache"));
  1402. sub->append(new LLMenuItemCheckGL("Use object cache occlusion",
  1403. menu_toggle_control, NULL,
  1404. menu_check_control,
  1405. (void*)"UseObjectCacheOcclusion"));
  1406. sub->append(new LLMenuItemCheckGL("Evict objects based on visibility",
  1407. menu_toggle_control, NULL,
  1408. menu_check_control,
  1409. (void*)"UseObjectCacheVisibility"));
  1410. #if HB_AJUSTED_VOCACHE_PARAMETERS
  1411. sub->append(new LLMenuItemCheckGL("Bias objects retention",
  1412. menu_toggle_control, NULL,
  1413. menu_check_control,
  1414. (void*)"BiasedObjectRetention"));
  1415. #endif
  1416. sub->append(new LLMenuItemToggleGL("Balance object cache",
  1417. &gBalanceObjectCache));
  1418. sub->append(new LLMenuItemCheckGL("Force 360 degrees interest list",
  1419. menu_toggle_control, NULL,
  1420. menu_check_control,
  1421. (void*)"Use360InterestList"));
  1422. sub->append(new LLMenuItemCheckGL("Object cache (after restart)",
  1423. menu_toggle_control, NULL,
  1424. menu_check_control,
  1425. (void*)"ObjectDiskCacheEnabled"));
  1426. sub->append(new LLMenuItemCheckGL("Object cache disk reads",
  1427. menu_toggle_control,
  1428. object_cache_enabled,
  1429. object_cache_read_checked,
  1430. (void*)"ObjectDiskCacheReads"));
  1431. sub->append(new LLMenuItemCheckGL("Threaded object cache reads",
  1432. menu_toggle_control,
  1433. object_cache_enabled,
  1434. object_cache_threaded_reads_checked,
  1435. (void*)"ThreadedObjectCacheReads"));
  1436. sub->append(new LLMenuItemCheckGL("Object cache disk writes",
  1437. menu_toggle_control,
  1438. object_cache_write_enabled,
  1439. object_cache_write_checked,
  1440. (void*)"ObjectDiskCacheWrites"));
  1441. sub->append(new LLMenuItemCheckGL("Threaded object cache writes",
  1442. menu_toggle_control,
  1443. object_cache_write_enabled,
  1444. object_cache_threaded_writes_checked,
  1445. (void*)"ThreadedObjectCacheWrites"));
  1446. #if LL_WINDOWS
  1447. sub->appendSeparator();
  1448. sub->append(new LLMenuItemCheckGL("Flush on asset write (for Wine)",
  1449. menu_toggle_control, NULL,
  1450. menu_check_control,
  1451. (void*)"FSFlushOnWrite"));
  1452. #endif
  1453. sub->createJumpKeys();
  1454. }
  1455. void restart_voice(void*)
  1456. {
  1457. gSavedSettings.setBool("EnableVoiceChat", false);
  1458. doAfterInterval([] { gSavedSettings.setBool("EnableVoiceChat", true); },
  1459. 2.f);
  1460. }
  1461. bool voice_enabled(void*)
  1462. {
  1463. static LLCachedControl<bool> voice(gSavedSettings, "EnableVoiceChat");
  1464. return voice;
  1465. }
  1466. void init_media_menu(LLMenuGL* sub)
  1467. {
  1468. sub->append(new LLMenuItemCallGL("Restart audio engine",
  1469. &restart_audio_engine));
  1470. #if LL_OPENAL && LL_FMOD
  1471. sub->append(new LLMenuItemCheckGL("Disable OpenAL", menu_toggle_control,
  1472. NULL, menu_check_control,
  1473. (void*)"AudioDisableOpenAL"));
  1474. sub->append(new LLMenuItemCheckGL("Disable FMOD", menu_toggle_control,
  1475. NULL, menu_check_control,
  1476. (void*)"AudioDisableFMOD"));
  1477. #endif
  1478. #if LL_LINUX && LL_FMOD
  1479. sub->append(new LLMenuItemCheckGL("Disable ALSA for FMOD",
  1480. menu_toggle_control, fmod_enabled,
  1481. menu_check_control,
  1482. (void*)"FMODDisableALSA"));
  1483. sub->append(new LLMenuItemCheckGL("Disable PulseAudio for FMOD",
  1484. menu_toggle_control, fmod_enabled,
  1485. menu_check_control,
  1486. (void*)"FMODDisablePulseAudio"));
  1487. #endif
  1488. sub->appendSeparator();
  1489. sub->append(new LLMenuItemCallGL("Reload MIME types",
  1490. LLMIMETypes::reload));
  1491. sub->appendSeparator();
  1492. sub->append(new LLMenuItemCheckGL("Use a read thread for plugins",
  1493. menu_toggle_control, NULL,
  1494. menu_check_control,
  1495. (void*)"PluginUseReadThread"));
  1496. sub->appendSeparator();
  1497. sub->append(new LLMenuItemCheckGL("Voice enabled",
  1498. menu_toggle_control, NULL,
  1499. menu_check_control,
  1500. (void*)"EnableVoiceChat"));
  1501. sub->append(new LLMenuItemCallGL("Restart voice", restart_voice,
  1502. voice_enabled));
  1503. sub->createJumpKeys();
  1504. }
  1505. void init_debug_world_menu(LLMenuGL* sub)
  1506. {
  1507. sub->append(new LLMenuItemCheckGL("Sparse classic clouds updates",
  1508. menu_toggle_control, NULL,
  1509. menu_check_control,
  1510. (void*)"SparseClassicClouds"));
  1511. sub->append(new LLMenuItemCheckGL("Show wind vectors",
  1512. LLPipeline::toggleRenderDebug, NULL,
  1513. LLPipeline::toggleRenderDebugControl,
  1514. (void*)LLPipeline::RENDER_DEBUG_WIND_VECTORS));
  1515. sub->createJumpKeys();
  1516. }
  1517. //MK
  1518. void handle_rlv_status(void*)
  1519. {
  1520. HBFloaterRLV::showInstance();
  1521. }
  1522. void toggle_rlv_focus(void* user_data)
  1523. {
  1524. if (isAgentAvatarValid())
  1525. {
  1526. LLJoint* joint;
  1527. S32 joint_code = (intptr_t)user_data;
  1528. switch (joint_code)
  1529. {
  1530. case 1:
  1531. joint = gAgentAvatarp->mTorsop;
  1532. break;
  1533. case 2:
  1534. joint = gAgentAvatarp->mWristLeftp;
  1535. break;
  1536. case 3:
  1537. joint = gAgentAvatarp->mWristRightp;
  1538. break;
  1539. case 4:
  1540. joint = gAgentAvatarp->mFootLeftp;
  1541. break;
  1542. case 5:
  1543. joint = gAgentAvatarp->mFootRightp;
  1544. break;
  1545. default:
  1546. joint = gAgentAvatarp->mHeadp;
  1547. }
  1548. gRLInterface.setCamDistDrawFromJoint(joint);
  1549. }
  1550. }
  1551. bool check_rlv_focus(void* user_data)
  1552. {
  1553. if (isAgentAvatarValid())
  1554. {
  1555. LLJoint* joint = gRLInterface.getCamDistDrawFromJoint();
  1556. S32 joint_code = (intptr_t)user_data;
  1557. switch (joint_code)
  1558. {
  1559. case 0:
  1560. return joint == gAgentAvatarp->mHeadp;
  1561. case 1:
  1562. return joint == gAgentAvatarp->mTorsop;
  1563. case 2:
  1564. return joint == gAgentAvatarp->mWristLeftp;
  1565. case 3:
  1566. return joint == gAgentAvatarp->mWristRightp;
  1567. case 4:
  1568. return joint == gAgentAvatarp->mFootLeftp;
  1569. case 5:
  1570. return joint == gAgentAvatarp->mFootRightp;
  1571. default:
  1572. break;
  1573. }
  1574. }
  1575. return false;
  1576. }
  1577. void init_restrained_love_menu(LLMenuGL* menu)
  1578. {
  1579. menu->append(new LLMenuItemCallGL("Restrictions and commands log",
  1580. handle_rlv_status, NULL));
  1581. menu->appendSeparator();
  1582. menu->append(new LLMenuItemCheckGL("Show '...' for muted text when deafened",
  1583. menu_toggle_control, NULL,
  1584. menu_check_control,
  1585. (void*)"RestrainedLoveShowEllipsis"));
  1586. menu->append(new LLMenuItemCheckGL("Allow 'Wear' & 'Add to/Replace outfit'",
  1587. menu_toggle_control, NULL,
  1588. menu_check_control,
  1589. (void*)"RestrainedLoveAllowWear"));
  1590. menu->append(new LLMenuItemCheckGL("Forbid give to #RLV/",
  1591. menu_toggle_control, NULL,
  1592. menu_check_control,
  1593. (void*)"RestrainedLoveForbidGiveToRLV"));
  1594. menu->append(new LLMenuItemCheckGL("Add joint name to attachments in #RLV/",
  1595. menu_toggle_control, NULL,
  1596. menu_check_control,
  1597. (void*)"RestrainedLoveAutomaticRenameItems"));
  1598. menu->append(new LLMenuItemCheckGL("@acceptpermission allows temp-attachments",
  1599. menu_toggle_control, NULL,
  1600. menu_check_control,
  1601. (void*)"RestrainedLoveRelaxedTempAttach"));
  1602. menu->append(new LLMenuItemCheckGL("Skip blacklist checks for Lua scripts",
  1603. menu_toggle_control, NULL,
  1604. menu_check_control,
  1605. (void*)"RestrainedLoveLuaNoBlacklist"));
  1606. LLMenuGL* sub = new LLMenuGL("Blindfold point of view");
  1607. sub->append(new LLMenuItemCheckGL("Head",
  1608. toggle_rlv_focus, NULL,
  1609. check_rlv_focus,
  1610. (void*)0));
  1611. sub->append(new LLMenuItemCheckGL("Pelvis",
  1612. toggle_rlv_focus, NULL,
  1613. check_rlv_focus,
  1614. (void*)1));
  1615. sub->append(new LLMenuItemCheckGL("Left hand",
  1616. toggle_rlv_focus, NULL,
  1617. check_rlv_focus,
  1618. (void*)2));
  1619. sub->append(new LLMenuItemCheckGL("Right hand",
  1620. toggle_rlv_focus, NULL,
  1621. check_rlv_focus,
  1622. (void*)3));
  1623. sub->append(new LLMenuItemCheckGL("Left foot",
  1624. toggle_rlv_focus, NULL,
  1625. check_rlv_focus,
  1626. (void*)4));
  1627. sub->append(new LLMenuItemCheckGL("Right foot",
  1628. toggle_rlv_focus, NULL,
  1629. check_rlv_focus,
  1630. (void*)5));
  1631. sub->createJumpKeys();
  1632. menu->appendMenu(sub);
  1633. }
  1634. //mk
  1635. #if 0 // Does not work particularly well at the moment
  1636. void reload_ui(void*)
  1637. {
  1638. LLUICtrlFactory::getInstance()->rebuild();
  1639. }
  1640. void handle_reload_settings(void*)
  1641. {
  1642. gSavedSettings.resetToDefaults();
  1643. gSavedSettings.loadFromFile(gSavedSettings.getString("ClientSettingsFile"));
  1644. llinfos << "Loading colors from colors_base.xml" << llendl;
  1645. std::string color_file = gDirUtil.getFullPath(LL_PATH_APP_SETTINGS,
  1646. "colors_base.xml");
  1647. gColors.resetToDefaults();
  1648. gColors.loadFromFileLegacy(color_file, false, TYPE_COL4U);
  1649. }
  1650. #endif
  1651. void fit_all_open_floaters(void*)
  1652. {
  1653. gFloaterViewp->fitAllToScreen();
  1654. }
  1655. void decode_ui_sounds(void*)
  1656. {
  1657. audio_preload_ui_sounds(true);
  1658. }
  1659. void clear_ui_sounds(void*)
  1660. {
  1661. gSavedSettings.setBool("ClearSavedUISounds", true);
  1662. gNotifications.add("SoundsWillClear");
  1663. }
  1664. void handle_font_test_floater(void*)
  1665. {
  1666. LLFloater* floater = new LLFloater("font test");
  1667. LLUICtrlFactory::getInstance()->buildFloater(floater,
  1668. "floater_font_test.xml");
  1669. floater->center();
  1670. }
  1671. void handle_skin_preview_floater(void*)
  1672. {
  1673. LLFloater* floater = new LLFloater("skin preview");
  1674. LLUICtrlFactory* factoryp = LLUICtrlFactory::getInstance();
  1675. factoryp->buildFloater(floater, "floater_skin_preview_template.xml");
  1676. }
  1677. void toggle_show_xui_names(void*)
  1678. {
  1679. gSavedSettings.setBool("ShowXUINames",
  1680. !gSavedSettings.getBool("ShowXUINames"));
  1681. }
  1682. bool check_show_xui_names(void*)
  1683. {
  1684. static LLCachedControl<bool> show_names(gSavedSettings, "ShowXUINames");
  1685. return show_names;
  1686. }
  1687. void export_menus_to_xml_callback(HBFileSelector::ESaveFilter type,
  1688. std::string& filename, void* user_data)
  1689. {
  1690. if (!filename.empty())
  1691. {
  1692. llofstream out(filename.c_str());
  1693. if (out.is_open())
  1694. {
  1695. LLXMLNodePtr node = gMenuBarViewp->getXML();
  1696. node->writeToOstream(out);
  1697. out.close();
  1698. }
  1699. else
  1700. {
  1701. llwarns << "Could not open file '" << filename << "' for wirting."
  1702. << llendl;
  1703. }
  1704. }
  1705. }
  1706. void handle_export_menus_to_xml(void*)
  1707. {
  1708. // Open the file save dialog
  1709. HBFileSelector::saveFile(HBFileSelector::FFSAVE_XUI, "menu_bar.xml",
  1710. export_menus_to_xml_callback);
  1711. }
  1712. void save_to_xml_callback(HBFileSelector::ESaveFilter type,
  1713. std::string& filename,
  1714. void* user_data)
  1715. {
  1716. LLFloater* frontmost = (LLFloater*)user_data;
  1717. if (!filename.empty())
  1718. {
  1719. if (gFloaterViewp->bringToFront(frontmost))
  1720. {
  1721. LLUICtrlFactory::getInstance()->saveToXML(frontmost, filename);
  1722. }
  1723. else
  1724. {
  1725. gNotifications.add("NoFrontmostFloater");
  1726. }
  1727. }
  1728. }
  1729. void handle_save_to_xml(void*)
  1730. {
  1731. LLFloater* frontmost = gFloaterViewp->getFrontmost();
  1732. if (!frontmost)
  1733. {
  1734. gNotifications.add("NoFrontmostFloater");
  1735. return;
  1736. }
  1737. std::string default_name = "floater_";
  1738. default_name += frontmost->getTitle();
  1739. default_name += ".xml";
  1740. LLStringUtil::toLower(default_name);
  1741. LLStringUtil::replaceChar(default_name, ' ', '_');
  1742. LLStringUtil::replaceChar(default_name, '/', '_');
  1743. LLStringUtil::replaceChar(default_name, ':', '_');
  1744. LLStringUtil::replaceChar(default_name, '"', '_');
  1745. // Open the file save dialog
  1746. HBFileSelector::saveFile(HBFileSelector::FFSAVE_XUI, default_name,
  1747. save_to_xml_callback, frontmost);
  1748. }
  1749. bool buy_currency_enabled(void*)
  1750. {
  1751. static LLCachedControl<bool> show_balance(gSavedSettings, "ShowBalance");
  1752. return !show_balance;
  1753. }
  1754. bool buy_currency_checked(void*)
  1755. {
  1756. static LLCachedControl<bool> checked(gSavedSettings, "ShowBuyCurrency");
  1757. return checked && buy_currency_enabled(NULL);
  1758. }
  1759. bool script_anti_spam_enabled(void*)
  1760. {
  1761. static LLCachedControl<bool> no_spam(gSavedSettings,
  1762. "ScriptDialogAntiSpam");
  1763. return no_spam;
  1764. }
  1765. bool script_dialog_uniq_checked(void*)
  1766. {
  1767. static LLCachedControl<bool> unique(gSavedSettings, "ScriptDialogUnique");
  1768. return unique && script_anti_spam_enabled(NULL);
  1769. }
  1770. void init_debug_ui_menu(LLMenuGL* menu)
  1771. {
  1772. #if 0 // Neither of these works particularly well at the moment
  1773. menu->append(new LLMenuItemCallGL("Reload UI XML", reload_ui, NULL, NULL));
  1774. menu->append(new LLMenuItemCallGL("Reload settings/colors",
  1775. handle_reload_settings, NULL, NULL));
  1776. #endif
  1777. menu->append(new LLMenuItemCallGL("Fit all open floaters in screen",
  1778. fit_all_open_floaters));
  1779. menu->append(new LLMenuItemCheckGL("Show floater size while resizing",
  1780. menu_toggle_control, NULL,
  1781. menu_check_control,
  1782. (void*)"DebugShowResizing"));
  1783. menu->appendSeparator();
  1784. menu->append(new LLMenuItemCheckGL("Allow colored fonts in UI",
  1785. menu_toggle_control, NULL,
  1786. menu_check_control,
  1787. (void*)"AllowColoredFonts"));
  1788. menu->appendSeparator();
  1789. menu->append(new LLMenuItemCallGL("Decode all UI sounds",
  1790. decode_ui_sounds));
  1791. menu->append(new LLMenuItemCallGL("Save decoded UI sounds",
  1792. copy_pre_decoded_ui_sounds));
  1793. menu->append(new LLMenuItemCallGL("Clear saved UI sounds (after restart)",
  1794. clear_ui_sounds));
  1795. menu->appendSeparator();
  1796. menu->append(new LLMenuItemCheckGL("Search input field in status bar",
  1797. menu_toggle_control, NULL,
  1798. menu_check_control,
  1799. (void*)"ShowSearchBar"));
  1800. menu->append(new LLMenuItemCheckGL("Money balance in status bar",
  1801. menu_toggle_control, NULL,
  1802. menu_check_control,
  1803. (void*)"ShowBalance"));
  1804. menu->append(new LLMenuItemCheckGL("Buy currency button in status bar",
  1805. menu_toggle_control,
  1806. buy_currency_enabled,
  1807. buy_currency_checked,
  1808. (void*)"ShowBuyCurrency"));
  1809. menu->appendSeparator();
  1810. menu->append(new LLMenuItemCheckGL("Zoom dependent resize handles",
  1811. menu_toggle_control, NULL,
  1812. menu_check_control,
  1813. (void*)"ZoomDependentResizeHandles"));
  1814. menu->appendSeparator();
  1815. menu->append(new LLMenuItemCheckGL("Script dialogs anti-spam",
  1816. menu_toggle_control, NULL,
  1817. menu_check_control,
  1818. (void*)"ScriptDialogAntiSpam"));
  1819. menu->append(new LLMenuItemCheckGL("Only one script dialog per object",
  1820. menu_toggle_control,
  1821. script_anti_spam_enabled,
  1822. script_dialog_uniq_checked,
  1823. (void*)"ScriptDialogUnique"));
  1824. menu->appendSeparator();
  1825. menu->append(new LLMenuItemCheckGL("Lua side-bar on left",
  1826. menu_toggle_control, NULL,
  1827. menu_check_control,
  1828. (void*)"LuaSideBarOnLeft"));
  1829. menu->appendSeparator();
  1830. menu->append(new LLMenuItemCheckGL("Hide TP-related floaters on TP success",
  1831. menu_toggle_control, NULL, menu_check_control,
  1832. (void*)"HideFloatersOnTPSuccess"));
  1833. menu->appendSeparator();
  1834. menu->append(new LLMenuItemCheckGL("Persistent file selector paths",
  1835. menu_toggle_control, NULL,
  1836. menu_check_control,
  1837. (void*)"SaveFileSelectorPaths"));
  1838. menu->appendSeparator();
  1839. LLMenuGL* sub = new LLMenuGL("Debug");
  1840. sub->append(new LLMenuItemCheckGL("Selection manager", menu_toggle_control,
  1841. NULL, menu_check_control,
  1842. (void*)"DebugSelectMgr"));
  1843. sub->append(new LLMenuItemToggleGL("Clicks", &gDebugClicks));
  1844. sub->append(new LLMenuItemToggleGL("Views", &LLView::sDebugRects));
  1845. sub->append(new LLMenuItemToggleGL("Mouse events",
  1846. &LLView::sDebugMouseHandling));
  1847. sub->append(new LLMenuItemToggleGL("Keys", &LLView::sDebugKeys));
  1848. sub->append(new LLMenuItemToggleGL("WindowProc", &gDebugWindowProc));
  1849. sub->createJumpKeys();
  1850. menu->appendMenu(sub);
  1851. sub = new LLMenuGL("XUI");
  1852. sub->append(new LLMenuItemCallGL("Font test...",
  1853. handle_font_test_floater));
  1854. sub->append(new LLMenuItemCallGL("Skin preview...",
  1855. handle_skin_preview_floater));
  1856. sub->append(new LLMenuItemCallGL("Export menus to XML...",
  1857. handle_export_menus_to_xml,
  1858. enable_picker_actions, NULL));
  1859. sub->append(new LLMenuItemCallGL("Edit UI...", LLFloaterEditUI::show));
  1860. sub->append(new LLMenuItemCallGL("Load floater/panel from XML...",
  1861. handle_load_from_xml,
  1862. enable_picker_actions, NULL));
  1863. sub->append(new LLMenuItemCallGL("Save frontmost floater to XML...",
  1864. handle_save_to_xml, enable_picker_actions,
  1865. NULL));
  1866. sub->append(new LLMenuItemCheckGL("Show XUI names", toggle_show_xui_names,
  1867. NULL, check_show_xui_names, NULL));
  1868. sub->createJumpKeys();
  1869. menu->appendMenu(sub);
  1870. menu->createJumpKeys();
  1871. }
  1872. bool in_pbr_mode(void*)
  1873. {
  1874. return gUsePBRShaders;
  1875. }
  1876. bool not_in_pbr_mode(void*)
  1877. {
  1878. return !gUsePBRShaders;
  1879. }
  1880. bool deferred_rendering_enabled(void*)
  1881. {
  1882. return LLPipeline::sRenderDeferred;
  1883. }
  1884. bool deferred_check_control(void*)
  1885. {
  1886. return LLPipeline::sRenderDeferred;
  1887. }
  1888. bool wireframe_enabled(void*)
  1889. {
  1890. return !gRLenabled || !gRLInterface.mContainsDetach;
  1891. }
  1892. bool wireframe_check(void*)
  1893. {
  1894. return gUseWireframe;
  1895. }
  1896. void handle_toggle_wireframe(void*)
  1897. {
  1898. //MK
  1899. if (!gUseWireframe && gRLenabled &&
  1900. (gRLInterface.mHasLockedHuds || gRLInterface.mVisionRestricted))
  1901. {
  1902. // Do not toggle on !
  1903. return;
  1904. }
  1905. //mk
  1906. gUseWireframe = !gUseWireframe;
  1907. LLPipeline::refreshCachedSettings();
  1908. gPipeline.resetVertexBuffers();
  1909. // Rebuild objects to make sure all will properly show up... HB
  1910. handle_objects_visibility(NULL);
  1911. }
  1912. void reset_vertex_buffers(void*)
  1913. {
  1914. gPipeline.clearRebuildGroups();
  1915. gPipeline.resetVertexBuffers();
  1916. }
  1917. bool reset_vb_after_login_enabled(void*)
  1918. {
  1919. static LLCachedControl<U32> login_delay(gSavedSettings,
  1920. "VisibilityAutoRefreshLogin");
  1921. return login_delay > 0;
  1922. }
  1923. bool reset_vb_after_login_check(void*)
  1924. {
  1925. static LLCachedControl<bool> do_reset(gSavedSettings, "ResetVBAfterLogin");
  1926. return do_reset && reset_vb_after_login_enabled(NULL);
  1927. }
  1928. void force_restart_gl(void*)
  1929. {
  1930. if (gViewerWindowp)
  1931. {
  1932. gViewerWindowp->restartDisplay();
  1933. }
  1934. }
  1935. bool force_restart_enabled(void*)
  1936. {
  1937. static LLCachedControl<bool> allow(gSavedSettings,
  1938. "AllowGLRestartInCoreProfile");
  1939. return !LLRender::sGLCoreProfile || allow;
  1940. }
  1941. void clear_derendered(void*)
  1942. {
  1943. gObjectList.mBlackListedObjects.clear();
  1944. // Update the derendered status in the radar.
  1945. HBFloaterRadar::setRenderStatusDirty();
  1946. }
  1947. void boost_texture_fetches_now(void*)
  1948. {
  1949. LLViewerTexture::resetLowMemCondition();
  1950. LLViewerTextureList::sLastTeleportTime = gFrameTimeSeconds;
  1951. LLSD args;
  1952. args["DURATION"] =
  1953. llformat("%d", gSavedSettings.getU32("TextureFetchBoostTimeAfterTP"));
  1954. gNotifications.add("TextureFetchesBoosted", args);
  1955. }
  1956. static bool got_proper_rights(LLSelectNode* nodep)
  1957. {
  1958. if (gAgent.isGodlikeWithoutAdminMenuFakery())
  1959. {
  1960. return true;
  1961. }
  1962. if (nodep->mPermissions->getOwner() != gAgentID)
  1963. {
  1964. return false;
  1965. }
  1966. if (gIsInSecondLife)
  1967. {
  1968. return nodep->mPermissions->getCreator() == gAgentID;
  1969. }
  1970. U32 perm_owner = nodep->mPermissions->getMaskOwner();
  1971. return (perm_owner & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED;
  1972. }
  1973. static void emit_chat_text(const std::string& msg)
  1974. {
  1975. LLChat chat(msg);
  1976. LLFloaterChat::addChat(chat);
  1977. }
  1978. void handle_selected_texture_info(void*)
  1979. {
  1980. for (LLObjectSelection::valid_iterator
  1981. iter = gSelectMgr.getSelection()->valid_begin(),
  1982. end = gSelectMgr.getSelection()->valid_end();
  1983. iter != end; ++iter)
  1984. {
  1985. LLSelectNode* nodep = *iter;
  1986. bool can_see_id = got_proper_rights(nodep);
  1987. std::string msg = "Texture info for primitive \"" + nodep->mName;
  1988. msg += "\" (UUID: " + nodep->getObject()->getID().asString() + "):";
  1989. emit_chat_text(msg);
  1990. U8 te_count = nodep->getObject()->getNumTEs();
  1991. // map from texture ID to list of faces using it
  1992. typedef std::map< LLUUID, std::vector<U8> > map_t;
  1993. map_t faces_per_texture;
  1994. for (U8 i = 0; i < te_count; ++i)
  1995. {
  1996. if (!nodep->isTESelected(i)) continue;
  1997. LLViewerTexture* texp = nodep->getObject()->getTEImage(i);
  1998. LLUUID image_id = texp->getID();
  1999. faces_per_texture[image_id].push_back(i);
  2000. }
  2001. // Per-texture, dump which faces are using it.
  2002. std::string image_id_string;
  2003. for (map_t::iterator it = faces_per_texture.begin(),
  2004. end = faces_per_texture.end(); it != end; ++it)
  2005. {
  2006. LLUUID image_id = it->first;
  2007. U8 te = it->second[0];
  2008. LLViewerTexture* texp = nodep->getObject()->getTEImage(te);
  2009. S32 height = texp->getHeight();
  2010. S32 width = texp->getWidth();
  2011. S32 components = texp->getComponents();
  2012. if (can_see_id)
  2013. {
  2014. image_id_string = image_id.asString();
  2015. }
  2016. else
  2017. {
  2018. image_id_string = "texture";
  2019. }
  2020. msg = llformat("%s %dx%d %s on face ", image_id_string.c_str(),
  2021. width, height,
  2022. (components == 4 ? "(alpha)" : "(opaque)"));
  2023. for (U8 i = 0, count = it->second.size(); i < count; ++i)
  2024. {
  2025. msg += llformat("%d ", (S32)(it->second[i]));
  2026. }
  2027. emit_chat_text(msg);
  2028. }
  2029. }
  2030. }
  2031. void handle_selected_material_info(void*)
  2032. {
  2033. // Map from material ID to list of faces using it
  2034. typedef fast_hmap<LLMaterialID, std::vector<U8> > te_map_t;
  2035. typedef fast_hmap<LLMaterialID, LLMaterial*> mat_map_t;
  2036. mat_map_t materials;
  2037. std::string msg;
  2038. for (LLObjectSelection::valid_iterator
  2039. iter = gSelectMgr.getSelection()->valid_begin(),
  2040. end = gSelectMgr.getSelection()->valid_end();
  2041. iter != end; ++iter)
  2042. {
  2043. LLSelectNode* nodep = *iter;
  2044. if (!nodep) continue; // Paranoia
  2045. LLViewerObject* object = nodep->getObject();
  2046. if (!object) continue; // Paranoia
  2047. bool can_see_id = got_proper_rights(nodep);
  2048. U8 te_count = object->getNumTEs();
  2049. te_map_t faces_per_material;
  2050. for (U8 i = 0; i < te_count; ++i)
  2051. {
  2052. if (!nodep->isTESelected(i)) continue;
  2053. LLTextureEntry* tep = object->getTE(i);
  2054. if (!tep) continue;
  2055. const LLMaterialID& mat_id = tep->getMaterialID();
  2056. if (mat_id.isNull()) continue; // No material
  2057. faces_per_material[mat_id].push_back(i);
  2058. if (can_see_id)
  2059. {
  2060. materials.emplace(mat_id, tep->getMaterialParams().get());
  2061. }
  2062. }
  2063. if (faces_per_material.empty())
  2064. {
  2065. msg = "No material on primitive: " + nodep->mName;
  2066. emit_chat_text(msg);
  2067. continue;
  2068. }
  2069. // Per-material, dump which faces are using it.
  2070. msg = "Material info for primitive: " + nodep->mName;
  2071. emit_chat_text(msg);
  2072. for (te_map_t::iterator it = faces_per_material.begin(),
  2073. end = faces_per_material.end();
  2074. it != end; ++it)
  2075. {
  2076. const LLMaterialID& mat_id = it->first;
  2077. // Note: the material Id does not give any useful information to
  2078. // find out what is the actual composition of the material, so we
  2079. // can give it up without any copyright issue. HB
  2080. msg = mat_id.asString() + " on face ";
  2081. for (U8 i = 0; i < it->second.size(); ++i)
  2082. {
  2083. msg += llformat("%d ", (S32)(it->second[i]));
  2084. }
  2085. emit_chat_text(msg);
  2086. }
  2087. }
  2088. if (materials.empty())
  2089. {
  2090. return;
  2091. }
  2092. emit_chat_text("List of legacy materials:");
  2093. for (mat_map_t::iterator it = materials.begin(), end = materials.end();
  2094. it != end; ++it)
  2095. {
  2096. LLMaterial* matp = it->second;
  2097. const LLUUID& norm_id = matp->getNormalID();
  2098. const LLUUID& spec_id = matp->getSpecularID();
  2099. msg = "Material " + it->first.asString() + " got ";
  2100. msg += norm_id.notNull() ? norm_id.asString() + " as" : "no";
  2101. msg += " normal map and ";
  2102. msg += spec_id.notNull() ? spec_id.asString() + " as" : "no";
  2103. msg += " specular map.";
  2104. emit_chat_text(msg);
  2105. }
  2106. emit_chat_text("End of legacy materials list.");
  2107. }
  2108. void handle_selected_pbr_info(void*)
  2109. {
  2110. // Map from material ID to list of faces using it
  2111. typedef fast_hmap<LLUUID, std::vector<U8> > te_map_t;
  2112. typedef fast_hmap<LLUUID, LLGLTFMaterial*> mat_map_t;
  2113. mat_map_t materials;
  2114. std::string msg;
  2115. for (LLObjectSelection::valid_iterator
  2116. iter = gSelectMgr.getSelection()->valid_begin(),
  2117. end = gSelectMgr.getSelection()->valid_end();
  2118. iter != end; ++iter)
  2119. {
  2120. LLSelectNode* nodep = *iter;
  2121. if (!nodep) continue; // Paranoia
  2122. LLViewerObject* object = nodep->getObject();
  2123. if (!object) continue; // Paranoia
  2124. bool can_see_id = got_proper_rights(nodep);
  2125. U8 te_count = object->getNumTEs();
  2126. te_map_t faces_per_material;
  2127. for (U8 i = 0; i < te_count; ++i)
  2128. {
  2129. if (!nodep->isTESelected(i)) continue;
  2130. LLTextureEntry* tep = object->getTE(i);
  2131. if (!tep) continue;
  2132. LLGLTFMaterial* matp = tep->getGLTFMaterial();
  2133. if (!matp) continue; // No material
  2134. const LLUUID& mat_id = matp->getHash();
  2135. faces_per_material[mat_id].push_back(i);
  2136. if (can_see_id)
  2137. {
  2138. materials.emplace(mat_id, matp);
  2139. }
  2140. }
  2141. if (faces_per_material.empty())
  2142. {
  2143. msg = "No PBR material on primitive: " + nodep->mName;
  2144. emit_chat_text(msg);
  2145. continue;
  2146. }
  2147. // Per-material, dump which faces are using it.
  2148. msg = "GLTF material info for primitive: " + nodep->mName;
  2149. emit_chat_text(msg);
  2150. for (te_map_t::iterator it = faces_per_material.begin(),
  2151. end = faces_per_material.end();
  2152. it != end; ++it)
  2153. {
  2154. const LLUUID& mat_id = it->first;
  2155. // Note: the hash does not give any useful information to find out
  2156. // what is the actual composition of the GLTF material, so we can
  2157. // give it up without any copyright issue. HB
  2158. msg = mat_id.asString() + " on face ";
  2159. for (U8 i = 0; i < it->second.size(); ++i)
  2160. {
  2161. msg += llformat("%d ", (S32)(it->second[i]));
  2162. }
  2163. emit_chat_text(msg);
  2164. }
  2165. }
  2166. if (materials.empty())
  2167. {
  2168. return;
  2169. }
  2170. emit_chat_text("List of PBR materials:");
  2171. static const char base_str[] =
  2172. " base color map with color <%.2f, %.2f, %.2f> and alpha %.2f ";
  2173. static const char mrough_str[] =
  2174. " metallic/roughness map with m/r factors %.2f/%.2f and ";
  2175. static const char emisive_str[] =
  2176. " emissive map with color <%.2f, %.2f, %.2f>.";
  2177. for (mat_map_t::iterator it = materials.begin(), end = materials.end();
  2178. it != end; ++it)
  2179. {
  2180. LLGLTFMaterial* matp = it->second;
  2181. const LLGLTFMaterial::uuid_array_t& textures = matp->mTextureId;
  2182. const LLUUID& basecol = textures[BASECOLIDX];
  2183. const LLUUID& normal = textures[NORMALIDX];
  2184. const LLUUID& mrough = textures[MROUGHIDX];
  2185. const LLUUID& emissive = textures[EMISSIVEIDX];
  2186. const LLColor4& bcolor = matp->mBaseColor;
  2187. const LLColor3& ecolor = matp->mEmissiveColor;
  2188. msg = "Material " + it->first.asString() + " got ";
  2189. msg += basecol.notNull() ? basecol.asString() + " as" : "no";
  2190. msg += llformat(base_str, bcolor.mV[VX], bcolor.mV[VY], bcolor.mV[VZ],
  2191. bcolor.mV[VW]);
  2192. switch (matp->mAlphaMode)
  2193. {
  2194. case 0:
  2195. msg += "(opaque), ";
  2196. break;
  2197. case 1:
  2198. msg += "(blend), ";
  2199. break;
  2200. case 2:
  2201. msg += llformat("(mask, cutoff = %.2f), ", matp->mAlphaCutoff);
  2202. break;
  2203. default:
  2204. msg += "(INVALID), ";
  2205. }
  2206. msg += normal.notNull() ? normal.asString() + " as" : "no";
  2207. msg += " normal map, ";
  2208. msg += mrough.notNull() ? mrough.asString() + " as" : "no";
  2209. msg += llformat(mrough_str, matp->mMetallicFactor,
  2210. matp->mRoughnessFactor);
  2211. msg += emissive.notNull() ? emissive.asString() + " as" : "no";
  2212. msg += llformat(emisive_str, ecolor.mV[VX], ecolor.mV[VY],
  2213. ecolor.mV[VZ]);
  2214. emit_chat_text(msg);
  2215. }
  2216. emit_chat_text("End of PBR materials list.");
  2217. }
  2218. void reload_selected_texture(void*)
  2219. {
  2220. uuid_list_t reloaded;
  2221. LLViewerTexture* default_texp =
  2222. (LLViewerTexture*)LLViewerFetchedTexture::sDefaultImagep;
  2223. LLViewerFetchedTexture* texp;
  2224. for (LLObjectSelection::valid_iterator iter =
  2225. gSelectMgr.getSelection()->valid_begin();
  2226. iter != gSelectMgr.getSelection()->valid_end(); ++iter)
  2227. {
  2228. LLSelectNode* nodep = *iter;
  2229. LLViewerObject* objectp = nodep->getObject();
  2230. if (!objectp) continue;
  2231. // Allow to reload linden trees' texture. HB
  2232. LLVOTree* treevobjp = dynamic_cast<LLVOTree*>(objectp);
  2233. if (treevobjp)
  2234. {
  2235. texp = treevobjp->getTreeTexture();
  2236. if (texp)
  2237. {
  2238. const LLUUID& texid = texp->getID();
  2239. if (!reloaded.count(texid))
  2240. {
  2241. // Force a reload of the raw image
  2242. texp->forceRefetch();
  2243. reloaded.emplace(texid); // Mark as reloaded
  2244. }
  2245. }
  2246. continue; // Nothing else needed for Linden trees.
  2247. }
  2248. // Does this object have a sculpt map texture ?
  2249. const LLSculptParams* sculptp = objectp->getSculptParams();
  2250. if (sculptp &&
  2251. (sculptp->getSculptType() &
  2252. LL_SCULPT_TYPE_MASK) != LL_SCULPT_TYPE_MESH)
  2253. {
  2254. const LLUUID& texid = sculptp->getSculptTexture();
  2255. if (texid.notNull())
  2256. {
  2257. if (!reloaded.count(texid))
  2258. {
  2259. texp =
  2260. LLViewerTextureManager::getFetchedTexture(texid,
  2261. FTT_DEFAULT,
  2262. true,
  2263. LLGLTexture::BOOST_NONE,
  2264. LLViewerTexture::LOD_TEXTURE);
  2265. if (texp)
  2266. {
  2267. S32 count = texp->getNumVolumes(LLRender::SCULPT_TEX);
  2268. const LLViewerTexture::ll_volume_list_t* volumesp =
  2269. texp->getVolumeList(LLRender::SCULPT_TEX);
  2270. // Force a reload of the raw image
  2271. texp->forceRefetch();
  2272. for (S32 i = 0; i < count; ++i)
  2273. {
  2274. LLVOVolume* volp = (*volumesp)[i];
  2275. if (volp)
  2276. {
  2277. volp->notifyMeshLoaded();
  2278. }
  2279. }
  2280. }
  2281. reloaded.emplace(texid); // Mark as reloaded
  2282. }
  2283. // Force an object geometry rebuild
  2284. objectp->markForUpdate();
  2285. }
  2286. }
  2287. if (gUsePBRShaders)
  2288. {
  2289. // Re-apply object cache overrides if any.
  2290. LLViewerRegion* regionp = objectp->getRegion();
  2291. if (regionp)
  2292. {
  2293. regionp->loadCacheMiscExtras(objectp);
  2294. objectp->markForUpdate(false);
  2295. }
  2296. }
  2297. // Now deal with the other textures, per face.
  2298. for (U8 i = 0, count = objectp->getNumTEs(); i < count; ++i)
  2299. {
  2300. if (!nodep->isTESelected(i)) continue;
  2301. LLViewerTexture* imgp = objectp->getTEImage(i);
  2302. if (imgp)
  2303. {
  2304. const LLUUID& texid = imgp->getID();
  2305. if (texid.notNull())
  2306. {
  2307. // To flag as texture changed:
  2308. objectp->setTETexture(i, IMG_DEFAULT);
  2309. if (!reloaded.count(texid))
  2310. {
  2311. LLViewerFetchedTexture* tex =
  2312. LLViewerTextureManager::staticCast(imgp);
  2313. if (tex)
  2314. {
  2315. // Force a reload of the raw image
  2316. tex->forceRefetch();
  2317. }
  2318. reloaded.emplace(texid); // Mark as reloaded
  2319. }
  2320. // Will rebind the texture in GL:
  2321. objectp->setTETexture(i, texid);
  2322. }
  2323. }
  2324. imgp = objectp->getTENormalMap(i);
  2325. if (imgp && imgp != default_texp)
  2326. {
  2327. const LLUUID& texid = imgp->getID();
  2328. if (!reloaded.count(texid))
  2329. {
  2330. texp =
  2331. LLViewerTextureManager::staticCast(imgp);
  2332. if (texp)
  2333. {
  2334. // Force a reload of the raw image
  2335. texp->forceRefetch();
  2336. }
  2337. reloaded.emplace(texid); // Mark as reloaded
  2338. }
  2339. }
  2340. imgp = objectp->getTESpecularMap(i);
  2341. if (imgp && imgp != default_texp)
  2342. {
  2343. const LLUUID& texid = imgp->getID();
  2344. if (!reloaded.count(texid))
  2345. {
  2346. texp =
  2347. LLViewerTextureManager::staticCast(imgp);
  2348. if (texp)
  2349. {
  2350. // Force a reload of the raw image
  2351. texp->forceRefetch();
  2352. }
  2353. reloaded.emplace(texid); // Mark as reloaded
  2354. }
  2355. }
  2356. if (!gUsePBRShaders) continue; // Skip any GLTF material textures
  2357. // We also need to reload any GLTF render material textures. HB
  2358. LLTextureEntry* tep = objectp->getTE(i);
  2359. if (!tep) continue; // Paranoia
  2360. LLFetchedGLTFMaterial* gltfp =
  2361. (LLFetchedGLTFMaterial*)tep->getGLTFRenderMaterial();
  2362. if (!gltfp) continue; // No GLTF material on this face.
  2363. texp = gltfp->mBaseColorTexture;
  2364. if (texp)
  2365. {
  2366. const LLUUID& texid = texp->getID();
  2367. if (!reloaded.count(texid))
  2368. {
  2369. // Force a reload of the raw image
  2370. texp->forceRefetch();
  2371. reloaded.emplace(texid); // Mark as reloaded
  2372. }
  2373. }
  2374. texp = gltfp->mNormalTexture;
  2375. if (texp)
  2376. {
  2377. const LLUUID& texid = texp->getID();
  2378. if (!reloaded.count(texid))
  2379. {
  2380. // Force a reload of the raw image
  2381. texp->forceRefetch();
  2382. reloaded.emplace(texid); // Mark as reloaded
  2383. }
  2384. }
  2385. texp = gltfp->mMetallicRoughnessTexture;
  2386. if (texp)
  2387. {
  2388. const LLUUID& texid = texp->getID();
  2389. if (!reloaded.count(texid))
  2390. {
  2391. // Force a reload of the raw image
  2392. texp->forceRefetch();
  2393. reloaded.emplace(texid); // Mark as reloaded
  2394. }
  2395. }
  2396. texp = gltfp->mEmissiveTexture;
  2397. if (texp)
  2398. {
  2399. const LLUUID& texid = texp->getID();
  2400. if (!reloaded.count(texid))
  2401. {
  2402. // Force a reload of the raw image
  2403. texp->forceRefetch();
  2404. reloaded.emplace(texid); // Mark as reloaded
  2405. }
  2406. }
  2407. }
  2408. }
  2409. }
  2410. void handle_dump_image_list(void*)
  2411. {
  2412. gTextureList.dump();
  2413. }
  2414. void meshopt_toggle(void* userdata)
  2415. {
  2416. U32 method = (U32)(intptr_t)userdata;
  2417. gSavedSettings.setU32("RenderMeshVertexCacheOptimize", method);
  2418. }
  2419. bool meshopt_check_control(void* userdata)
  2420. {
  2421. static LLCachedControl<U32> method(gSavedSettings,
  2422. "RenderMeshVertexCacheOptimize");
  2423. U32 check = (U32)(intptr_t)userdata;
  2424. return check == method;
  2425. }
  2426. void menu_toggle_attached_lights(void* user_data)
  2427. {
  2428. menu_toggle_control(user_data);
  2429. LLPipeline::sRenderAttachedLights =
  2430. gSavedSettings.getBool("RenderAttachedLights");
  2431. }
  2432. void menu_toggle_attached_particles(void* user_data)
  2433. {
  2434. menu_toggle_control(user_data);
  2435. LLPipeline::sRenderAttachedParticles =
  2436. gSavedSettings.getBool("RenderAttachedParticles");
  2437. }
  2438. void frame_render_profile(void*)
  2439. {
  2440. gShaderProfileFrame = true;
  2441. }
  2442. void use_basecolor_toggle(void* userdata)
  2443. {
  2444. gSavedSettings.setU32("RenderUseBasecolorAsDiffuse",
  2445. (U32)(intptr_t)userdata);
  2446. }
  2447. bool use_basecolor_check_control(void* userdata)
  2448. {
  2449. static LLCachedControl<U32> basecol(gSavedSettings,
  2450. "RenderUseBasecolorAsDiffuse");
  2451. return !gUsePBRShaders && (U32)basecol == (U32)(intptr_t)userdata;
  2452. }
  2453. void shadows_toggle(void* userdata)
  2454. {
  2455. gSavedSettings.setU32("RenderShadowDetail", (U32)(intptr_t)userdata);
  2456. }
  2457. bool shadows_check_control(void* userdata)
  2458. {
  2459. if (!LLPipeline::sRenderDeferred)
  2460. {
  2461. return !userdata;
  2462. }
  2463. static LLCachedControl<U32> shadows(gSavedSettings, "RenderShadowDetail");
  2464. return (U32)shadows == (U32)(intptr_t)userdata;
  2465. }
  2466. bool shadows_enabled(void* userdata)
  2467. {
  2468. static LLCachedControl<U32> shadows(gSavedSettings, "RenderShadowDetail");
  2469. return LLPipeline::sRenderDeferred && shadows;
  2470. }
  2471. bool soften_check_control(void* userdata)
  2472. {
  2473. static LLCachedControl<bool> soften(gSavedSettings, "RenderShadowSoften");
  2474. return soften && shadows_enabled(NULL);
  2475. }
  2476. bool got_reflection_probes(void*)
  2477. {
  2478. return gUsePBRShaders && LLViewerShaderMgr::sHasRP;
  2479. }
  2480. bool screen_space_refl_check_control(void* userdata)
  2481. {
  2482. static LLCachedControl<bool> ssr(gSavedSettings,
  2483. "RenderScreenSpaceReflections");
  2484. return ssr && gUsePBRShaders && LLViewerShaderMgr::sHasRP;
  2485. }
  2486. void ssao_toggle(void* userdata)
  2487. {
  2488. gSavedSettings.setU32("RenderDeferredSSAO", (U32)(intptr_t)userdata);
  2489. }
  2490. bool ssao_check_control(void* userdata)
  2491. {
  2492. if (!LLPipeline::sRenderDeferred)
  2493. {
  2494. return !userdata;
  2495. }
  2496. static LLCachedControl<U32> ssao(gSavedSettings, "RenderDeferredSSAO");
  2497. return (U32)ssao == (U32)(intptr_t)userdata;
  2498. }
  2499. bool invisprim_enabled(void*)
  2500. {
  2501. return LLPipeline::sRenderDeferred && !gUsePBRShaders;
  2502. }
  2503. bool invisprim_check_control(void*)
  2504. {
  2505. static LLCachedControl<bool> invisiprims(gSavedSettings,
  2506. "RenderDeferredInvisible");
  2507. return !gUsePBRShaders && (invisiprims || !LLPipeline::sRenderDeferred);
  2508. }
  2509. void handle_objects_visibility(void* userdata)
  2510. {
  2511. if (LLApp::isExiting())
  2512. {
  2513. return;
  2514. }
  2515. U32 type = (U32)((intptr_t)userdata);
  2516. llinfos << "Refreshing objects visibility";
  2517. switch (type)
  2518. {
  2519. case AFTER_LOGIN:
  2520. llcont << " after login";
  2521. break;
  2522. case AFTER_CROSS_BORDER:
  2523. llcont << " after sim border crossing";
  2524. break;
  2525. case AFTER_FAR_TP:
  2526. llcont << " after far TP";
  2527. break;
  2528. default:
  2529. break;
  2530. }
  2531. llcont << llendl;
  2532. for (S32 i = 0, count = gObjectList.getNumObjects(); i < count; ++i)
  2533. {
  2534. LLViewerObject* objectp = gObjectList.getObject(i);
  2535. if (objectp && !objectp->isDead())
  2536. {
  2537. objectp->markForUpdate(true);
  2538. // With PBR, something fishy happens with spatial partitions and
  2539. // some objects find themselves in the wrong one, causing non-
  2540. // rezzing objects that only reappear after a LOD change (the
  2541. // latter triggering a call to markPartitionMove()). So we must
  2542. // also refresh the partition ownership for each object ! HB
  2543. if (gUsePBRShaders && objectp->mDrawable)
  2544. {
  2545. gPipeline.markPartitionMove(objectp->mDrawable);
  2546. }
  2547. }
  2548. }
  2549. static LLCachedControl<bool> reset_vb(gSavedSettings, "ResetVBAfterLogin");
  2550. if (type == AFTER_LOGIN && reset_vb)
  2551. {
  2552. // Post-login refresh: also trigger a vertex buffers reset to work
  2553. // around slower fps rates sometimes seen at login (likely an occlusion
  2554. // culling race condition issue).
  2555. doAfterInterval(boost::bind(reset_vertex_buffers, nullptr), 1.f);
  2556. }
  2557. }
  2558. void handle_refresh_probes(void*)
  2559. {
  2560. if (LLApp::isExiting())
  2561. {
  2562. return;
  2563. }
  2564. llinfos << "Refreshing reflection probes" << llendl;
  2565. gPipeline.mReflectionMapManager.reset();
  2566. gPipeline.mHeroProbeManager.reset();
  2567. for (S32 i = 0, count = gObjectList.getNumObjects(); i < count; ++i)
  2568. {
  2569. LLViewerObject* objectp = gObjectList.getObject(i);
  2570. if (objectp && !objectp->isDead() && objectp->isReflectionProbe())
  2571. {
  2572. LLVOVolume* vovolp = objectp->asVolume();
  2573. if (vovolp && vovolp->getVolume())
  2574. {
  2575. vovolp->updateReflectionProbePtr(true);
  2576. }
  2577. }
  2578. }
  2579. }
  2580. bool debuggl_checked(void*)
  2581. {
  2582. return gDebugGL;
  2583. }
  2584. void handle_debug_gl(void*)
  2585. {
  2586. gDebugGL = !gDebugGL;
  2587. clear_glerror();
  2588. llinfos << "GL debugging turned " << (gDebugGL ? "on." : "off.") << llendl;
  2589. }
  2590. // *HACK: called from llagent.cpp and llstartup.cpp, each time we need to
  2591. // ensure that all objects will properly rez after the agent moved into a new
  2592. // region or TPed beyond draw distance in the same region. 'type' is 1 for
  2593. // refresh on login, 2 for refresh on sim border crossing, and 4 for refresh
  2594. // after a TP.
  2595. void schedule_objects_visibility_refresh(U32 type)
  2596. {
  2597. static LLCachedControl<U32> login_delay(gSavedSettings,
  2598. "VisibilityAutoRefreshLogin");
  2599. static LLCachedControl<U32> cross_delay(gSavedSettings,
  2600. "VisibilityAutoRefreshBorder");
  2601. static LLCachedControl<U32> tp_delay(gSavedSettings,
  2602. "VisibilityAutoRefreshFarTP");
  2603. F32 delay;
  2604. switch (type)
  2605. {
  2606. case AFTER_LOGIN: delay = login_delay; break;
  2607. case AFTER_CROSS_BORDER: delay = cross_delay; break;
  2608. case AFTER_FAR_TP: delay = tp_delay; break;
  2609. default: delay = 0.f;
  2610. }
  2611. // Skip if purposely disabled, or when not yet rendering the world.
  2612. if (delay <= 0.f || !LLStartUp::isLoggedIn())
  2613. {
  2614. return;
  2615. }
  2616. doAfterInterval(boost::bind(handle_objects_visibility, (void*)((U64)type)),
  2617. // Clamp to a reasonnable delay...
  2618. llmin((F32)delay, 10.f));
  2619. }
  2620. bool vb_cache_check_control(void*)
  2621. {
  2622. static LLCachedControl<bool> vbcache(gSavedSettings, "RenderGLUseVBCache");
  2623. return gUsePBRShaders || vbcache;
  2624. }
  2625. void textures_size_toggle(void* userdata)
  2626. {
  2627. gSavedSettings.setU32("TextureMaxResLevel", (U32)(intptr_t)userdata);
  2628. }
  2629. bool textures_size_check_control(void* userdata)
  2630. {
  2631. static LLCachedControl<U32> level(gSavedSettings, "TextureMaxResLevel");
  2632. return (U32)level == (U32)(intptr_t)userdata;
  2633. }
  2634. void init_debug_rendering_menu(LLMenuGL* menu)
  2635. {
  2636. ///////////////////////////
  2637. // Debug menu for types/pools
  2638. LLMenuGL* sub = new LLMenuGL("Types");
  2639. sub->append(new LLMenuItemCheckGL("Simple",
  2640. &LLPipeline::toggleRenderTypeControl, NULL,
  2641. &LLPipeline::hasRenderTypeControl,
  2642. (void*)LLPipeline::RENDER_TYPE_SIMPLE,
  2643. '1', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
  2644. sub->append(new LLMenuItemCheckGL("Alpha",
  2645. &LLPipeline::toggleRenderTypeControl, NULL,
  2646. &LLPipeline::hasRenderTypeControl,
  2647. (void*)LLPipeline::RENDER_TYPE_ALPHA,
  2648. '2', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
  2649. sub->append(new LLMenuItemCheckGL("Tree",
  2650. &LLPipeline::toggleRenderTypeControl, NULL,
  2651. &LLPipeline::hasRenderTypeControl,
  2652. (void*)LLPipeline::RENDER_TYPE_TREE,
  2653. '3', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
  2654. sub->append(new LLMenuItemCheckGL("Avatar",
  2655. &LLPipeline::toggleRenderTypeControl, NULL,
  2656. &LLPipeline::hasRenderTypeControl,
  2657. (void*)LLPipeline::RENDER_TYPE_AVATAR,
  2658. '4', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
  2659. sub->append(new LLMenuItemCheckGL("Animesh",
  2660. &LLPipeline::toggleRenderTypeControl, NULL,
  2661. &LLPipeline::hasRenderTypeControl,
  2662. (void*)LLPipeline::RENDER_TYPE_PUPPET,
  2663. '+', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
  2664. sub->append(new LLMenuItemCheckGL("SurfacePatch",
  2665. &LLPipeline::toggleRenderTypeControl, NULL,
  2666. &LLPipeline::hasRenderTypeControl,
  2667. (void*)LLPipeline::RENDER_TYPE_TERRAIN,
  2668. '5', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
  2669. sub->append(new LLMenuItemCheckGL("Sky",
  2670. &LLPipeline::toggleRenderTypeControl, NULL,
  2671. &LLPipeline::hasRenderTypeControl,
  2672. (void*)LLPipeline::RENDER_TYPE_SKY,
  2673. '6', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
  2674. sub->append(new LLMenuItemCheckGL("Water",
  2675. &LLPipeline::toggleRenderTypeControl, NULL,
  2676. &LLPipeline::hasRenderTypeControl,
  2677. (void*)LLPipeline::RENDER_TYPE_WATER,
  2678. '7', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
  2679. sub->append(new LLMenuItemCheckGL("Volume",
  2680. &LLPipeline::toggleRenderTypeControl, NULL,
  2681. &LLPipeline::hasRenderTypeControl,
  2682. (void*)LLPipeline::RENDER_TYPE_VOLUME,
  2683. '9', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
  2684. sub->append(new LLMenuItemCheckGL("Grass",
  2685. &LLPipeline::toggleRenderTypeControl, NULL,
  2686. &LLPipeline::hasRenderTypeControl,
  2687. (void*)LLPipeline::RENDER_TYPE_GRASS,
  2688. '0', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
  2689. sub->append(new LLMenuItemCheckGL("Clouds",
  2690. &LLPipeline::toggleRenderTypeControl, NULL,
  2691. &LLPipeline::hasRenderTypeControl,
  2692. (void*)LLPipeline::RENDER_TYPE_CLOUDS,
  2693. '-', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
  2694. sub->append(new LLMenuItemCheckGL("Particles",
  2695. &LLPipeline::toggleRenderTypeControl, NULL,
  2696. &LLPipeline::hasRenderTypeControl,
  2697. (void*)LLPipeline::RENDER_TYPE_PARTICLES,
  2698. '*', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
  2699. sub->append(new LLMenuItemCheckGL("Bump",
  2700. &LLPipeline::toggleRenderTypeControl, NULL,
  2701. &LLPipeline::hasRenderTypeControl,
  2702. (void*)LLPipeline::RENDER_TYPE_BUMP,
  2703. '/', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
  2704. sub->append(new LLMenuItemCheckGL("Materials",
  2705. &LLPipeline::toggleRenderTypeControl, NULL,
  2706. &LLPipeline::hasRenderTypeControl,
  2707. (void*)LLPipeline::RENDER_TYPE_MATERIALS));
  2708. sub->append(new LLMenuItemCheckGL("PBR materials",
  2709. &LLPipeline::toggleRenderTypeControl, NULL,
  2710. &LLPipeline::hasRenderTypeControl,
  2711. (void*)LLPipeline::RENDER_TYPE_MAT_PBR));
  2712. sub->append(new LLMenuItemCheckGL("Alpha mask",
  2713. &LLPipeline::toggleRenderTypeControl, NULL,
  2714. &LLPipeline::hasRenderTypeControl,
  2715. (void*)LLPipeline::RENDER_TYPE_ALPHA_MASK));
  2716. sub->append(new LLMenuItemCheckGL("Alpha mask (full bright)",
  2717. &LLPipeline::toggleRenderTypeControl, NULL,
  2718. &LLPipeline::hasRenderTypeControl,
  2719. (void*)LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK));
  2720. sub->append(new LLMenuItemCheckGL("Full bright",
  2721. &LLPipeline::toggleRenderTypeControl, NULL,
  2722. &LLPipeline::hasRenderTypeControl,
  2723. (void*)LLPipeline::RENDER_TYPE_FULLBRIGHT));
  2724. sub->append(new LLMenuItemCheckGL("Glow",
  2725. &LLPipeline::toggleRenderTypeControl, NULL,
  2726. &LLPipeline::hasRenderTypeControl,
  2727. (void*)LLPipeline::RENDER_TYPE_GLOW));
  2728. sub->createJumpKeys();
  2729. menu->appendMenu(sub);
  2730. sub = new LLMenuGL("Features");
  2731. sub->append(new LLMenuItemCheckGL("UI",
  2732. LLPipeline::toggleRenderDebugFeature, NULL,
  2733. LLPipeline::toggleRenderDebugFeatureControl,
  2734. (void*)LLPipeline::RENDER_DEBUG_FEATURE_UI,
  2735. KEY_F1, MASK_SHIFT|MASK_CONTROL));
  2736. sub->append(new LLMenuItemCheckGL("Selected",
  2737. LLPipeline::toggleRenderDebugFeature, NULL,
  2738. LLPipeline::toggleRenderDebugFeatureControl,
  2739. (void*)LLPipeline::RENDER_DEBUG_FEATURE_SELECTED,
  2740. KEY_F2, MASK_SHIFT|MASK_CONTROL));
  2741. sub->append(new LLMenuItemCheckGL("Dynamic textures",
  2742. LLPipeline::toggleRenderDebugFeature, NULL,
  2743. LLPipeline::toggleRenderDebugFeatureControl,
  2744. (void*)LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES,
  2745. KEY_F3, MASK_SHIFT|MASK_CONTROL));
  2746. sub->append(new LLMenuItemCheckGL("Water fog",
  2747. LLPipeline::toggleRenderDebugFeature, NULL,
  2748. LLPipeline::toggleRenderDebugFeatureControl,
  2749. (void*)LLPipeline::RENDER_DEBUG_FEATURE_FOG,
  2750. KEY_F4, MASK_SHIFT|MASK_CONTROL));
  2751. sub->append(new LLMenuItemCheckGL("Flexible objects",
  2752. LLPipeline::toggleRenderDebugFeature, NULL,
  2753. LLPipeline::toggleRenderDebugFeatureControl,
  2754. (void*)LLPipeline::RENDER_DEBUG_FEATURE_FLEXIBLE,
  2755. KEY_F5, MASK_SHIFT|MASK_CONTROL));
  2756. sub->createJumpKeys();
  2757. menu->appendMenu(sub);
  2758. /////////////////////////////
  2759. // Debug menu for info displays
  2760. sub = new LLMenuGL("Info displays");
  2761. sub->append(new LLMenuItemCheckGL("World axes", menu_toggle_control, NULL,
  2762. menu_check_control, (void*)"ShowAxes"));
  2763. sub->append(new LLMenuItemCheckGL("Hit boxes", menu_toggle_control, NULL,
  2764. menu_check_control,
  2765. (void*)"RenderDebugHitBox"));
  2766. sub->append(new LLMenuItemCheckGL("Bounding boxes",
  2767. LLPipeline::toggleRenderDebug, NULL,
  2768. LLPipeline::toggleRenderDebugControl,
  2769. (void*)LLPipeline::RENDER_DEBUG_BBOXES));
  2770. sub->append(new LLMenuItemCheckGL("Normals",
  2771. LLPipeline::toggleRenderDebug, NULL,
  2772. LLPipeline::toggleRenderDebugControl,
  2773. (void*)LLPipeline::RENDER_DEBUG_NORMALS));
  2774. sub->append(new LLMenuItemCheckGL("Points",
  2775. LLPipeline::toggleRenderDebug, NULL,
  2776. LLPipeline::toggleRenderDebugControl,
  2777. (void*)LLPipeline::RENDER_DEBUG_POINTS));
  2778. sub->append(new LLMenuItemCheckGL("Octree",
  2779. LLPipeline::toggleRenderDebug, NULL,
  2780. LLPipeline::toggleRenderDebugControl,
  2781. (void*)LLPipeline::RENDER_DEBUG_OCTREE));
  2782. sub->append(new LLMenuItemCheckGL("Shadow frusta",
  2783. LLPipeline::toggleRenderDebug, NULL,
  2784. LLPipeline::toggleRenderDebugControl,
  2785. (void*)LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA));
  2786. sub->append(new LLMenuItemCheckGL("Reflection probes",
  2787. LLPipeline::toggleRenderDebug, NULL,
  2788. LLPipeline::toggleRenderDebugControl,
  2789. (void*)LLPipeline::RENDER_DEBUG_REFLECTION_PROBES));
  2790. sub->append(new LLMenuItemCheckGL("Physics shapes",
  2791. LLPipeline::toggleRenderDebug, NULL,
  2792. LLPipeline::toggleRenderDebugControl,
  2793. (void*)LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES));
  2794. sub->append(new LLMenuItemCheckGL("Occlusion",
  2795. LLPipeline::toggleRenderDebug, NULL,
  2796. LLPipeline::toggleRenderDebugControl,
  2797. (void*)LLPipeline::RENDER_DEBUG_OCCLUSION));
  2798. sub->append(new LLMenuItemCheckGL("Render batches",
  2799. LLPipeline::toggleRenderDebug, NULL,
  2800. LLPipeline::toggleRenderDebugControl,
  2801. (void*)LLPipeline::RENDER_DEBUG_BATCH_SIZE));
  2802. sub->append(new LLMenuItemCheckGL("Update type",
  2803. LLPipeline::toggleRenderDebug, NULL,
  2804. LLPipeline::toggleRenderDebugControl,
  2805. (void*)LLPipeline::RENDER_DEBUG_UPDATE_TYPE));
  2806. sub->append(new LLMenuItemCheckGL("Animated textures",
  2807. LLPipeline::toggleRenderDebug, NULL,
  2808. LLPipeline::toggleRenderDebugControl,
  2809. (void*)LLPipeline::RENDER_DEBUG_TEXTURE_ANIM));
  2810. sub->append(new LLMenuItemCheckGL("Texture priority",
  2811. LLPipeline::toggleRenderDebug, NULL,
  2812. LLPipeline::toggleRenderDebugControl,
  2813. (void*)LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY));
  2814. sub->append(new LLMenuItemCheckGL("Avatar complexity/visibility rank",
  2815. LLPipeline::toggleRenderDebug, NULL,
  2816. LLPipeline::toggleRenderDebugControl,
  2817. (void*)LLPipeline::RENDER_DEBUG_AVATAR_DRAW_INFO,
  2818. 'C', MASK_CONTROL|MASK_ALT));
  2819. sub->append(new LLMenuItemCheckGL("Attachments memory/area",
  2820. LLPipeline::toggleRenderDebug, NULL,
  2821. LLPipeline::toggleRenderDebugControl,
  2822. (void*)LLPipeline::RENDER_DEBUG_ATTACHMENT_INFO,
  2823. 'A', MASK_CONTROL|MASK_ALT));
  2824. sub->append(new LLMenuItemCheckGL("Texture area (sqrt(A))",
  2825. LLPipeline::toggleRenderDebug, NULL,
  2826. LLPipeline::toggleRenderDebugControl,
  2827. (void*)LLPipeline::RENDER_DEBUG_TEXTURE_AREA));
  2828. sub->append(new LLMenuItemCheckGL("Texture size",
  2829. LLPipeline::toggleRenderDebug, NULL,
  2830. LLPipeline::toggleRenderDebugControl,
  2831. (void*)LLPipeline::RENDER_DEBUG_TEXTURE_SIZE));
  2832. sub->append(new LLMenuItemCheckGL("Face area (sqrt(A))",
  2833. LLPipeline::toggleRenderDebug, NULL,
  2834. LLPipeline::toggleRenderDebugControl,
  2835. (void*)LLPipeline::RENDER_DEBUG_FACE_AREA));
  2836. sub->append(new LLMenuItemCheckGL("LOD info",
  2837. LLPipeline::toggleRenderDebug, NULL,
  2838. LLPipeline::toggleRenderDebugControl,
  2839. (void*)LLPipeline::RENDER_DEBUG_LOD_INFO));
  2840. sub->append(new LLMenuItemCheckGL("Lights",
  2841. LLPipeline::toggleRenderDebug, NULL,
  2842. LLPipeline::toggleRenderDebugControl,
  2843. (void*)LLPipeline::RENDER_DEBUG_LIGHTS));
  2844. sub->append(new LLMenuItemCheckGL("Particles",
  2845. LLPipeline::toggleRenderDebug, NULL,
  2846. LLPipeline::toggleRenderDebugControl,
  2847. (void*)LLPipeline::RENDER_DEBUG_PARTICLES));
  2848. sub->append(new LLMenuItemCheckGL("Composition",
  2849. LLPipeline::toggleRenderDebug, NULL,
  2850. LLPipeline::toggleRenderDebugControl,
  2851. (void*)LLPipeline::RENDER_DEBUG_COMPOSITION));
  2852. sub->append(new LLMenuItemCheckGL("Raycasting",
  2853. LLPipeline::toggleRenderDebug, NULL,
  2854. LLPipeline::toggleRenderDebugControl,
  2855. (void*)LLPipeline::RENDER_DEBUG_RAYCAST));
  2856. sub->append(new LLMenuItemCheckGL("Sculpt",
  2857. LLPipeline::toggleRenderDebug, NULL,
  2858. LLPipeline::toggleRenderDebugControl,
  2859. (void*)LLPipeline::RENDER_DEBUG_SCULPTED));
  2860. sub->append(new LLMenuItemCheckGL("Verify",
  2861. LLPipeline::toggleRenderDebug, NULL,
  2862. LLPipeline::toggleRenderDebugControl,
  2863. (void*)LLPipeline::RENDER_DEBUG_VERIFY));
  2864. sub->append(new LLMenuItemCheckGL("gLTF preview nodes",
  2865. LLPipeline::toggleRenderDebug, NULL,
  2866. LLPipeline::toggleRenderDebugControl,
  2867. (void*)LLPipeline::RENDER_DEBUG_NODES));
  2868. menu->appendMenu(sub);
  2869. /////////////////////////////
  2870. // Render tests sub-menu
  2871. sub = new LLMenuGL("Render tests");
  2872. sub->append(new LLMenuItemCheckGL("Camera offset", menu_toggle_control,
  2873. NULL, menu_check_control,
  2874. (void*)"CameraOffset"));
  2875. sub->append(new LLMenuItemToggleGL("Frame test",
  2876. &LLPipeline::sRenderFrameTest));
  2877. sub->append(new LLMenuItemCallGL("Frame profile", frame_render_profile));
  2878. sub->append(new LLMenuItemCheckGL("Debug GL", handle_debug_gl, NULL,
  2879. debuggl_checked, NULL));
  2880. sub->createJumpKeys();
  2881. menu->appendMenu(sub);
  2882. /////////////////////////////
  2883. // Deferred rendering sub-menu
  2884. sub = new LLMenuGL("Deferred rendering");
  2885. sub->append(new LLMenuItemCheckGL("PBR enabled",
  2886. menu_toggle_control, NULL,
  2887. menu_check_control,
  2888. (void*)"RenderUsePBR",
  2889. 'P', MASK_CONTROL|MASK_ALT));
  2890. sub->append(new LLMenuItemCheckGL("Always use diffuse texture",
  2891. use_basecolor_toggle, not_in_pbr_mode,
  2892. use_basecolor_check_control, NULL));
  2893. sub->append(new LLMenuItemCheckGL("Use base color for missing diffuse",
  2894. use_basecolor_toggle, not_in_pbr_mode,
  2895. use_basecolor_check_control, (void*)1));
  2896. sub->append(new LLMenuItemCheckGL("Always use base color with texture",
  2897. use_basecolor_toggle, not_in_pbr_mode,
  2898. use_basecolor_check_control, (void*)2));
  2899. sub->append(new LLMenuItemCheckGL("Always use base color",
  2900. use_basecolor_toggle, not_in_pbr_mode,
  2901. use_basecolor_check_control, (void*)3));
  2902. sub->appendSeparator();
  2903. sub->append(new LLMenuItemCheckGL("Deferred rendering",
  2904. menu_toggle_control, not_in_pbr_mode,
  2905. deferred_check_control,
  2906. (void*)"RenderDeferred",
  2907. 'D', MASK_CONTROL|MASK_ALT));
  2908. sub->append(new LLMenuItemCheckGL("Render invisiprims",
  2909. menu_toggle_control,
  2910. invisprim_enabled,
  2911. invisprim_check_control,
  2912. (void*)"RenderDeferredInvisible"));
  2913. sub->appendSeparator();
  2914. sub->append(new LLMenuItemCheckGL("No shadow", shadows_toggle,
  2915. deferred_rendering_enabled,
  2916. shadows_check_control, NULL));
  2917. sub->append(new LLMenuItemCheckGL("Sun and Moon shadows",
  2918. shadows_toggle,
  2919. deferred_rendering_enabled,
  2920. shadows_check_control, (void*)1));
  2921. sub->append(new LLMenuItemCheckGL("All lights shadows", shadows_toggle,
  2922. deferred_rendering_enabled,
  2923. shadows_check_control, (void*)2));
  2924. sub->append(new LLMenuItemCheckGL("Soften shadows", menu_toggle_control,
  2925. shadows_enabled, soften_check_control,
  2926. (void*)"RenderShadowSoften"));
  2927. sub->appendSeparator();
  2928. sub->append(new LLMenuItemCheckGL("Screen space reflections (broken)",
  2929. menu_toggle_control,
  2930. got_reflection_probes,
  2931. screen_space_refl_check_control,
  2932. (void*)"RenderScreenSpaceReflections"));
  2933. sub->appendSeparator();
  2934. sub->append(new LLMenuItemCheckGL("Never use SSAO", ssao_toggle,
  2935. deferred_rendering_enabled,
  2936. ssao_check_control, NULL));
  2937. sub->append(new LLMenuItemCheckGL("SSAO only with shadows", ssao_toggle,
  2938. deferred_rendering_enabled,
  2939. ssao_check_control, (void*)1));
  2940. sub->append(new LLMenuItemCheckGL("Always use SSAO", ssao_toggle,
  2941. deferred_rendering_enabled,
  2942. ssao_check_control, (void*)2));
  2943. sub->appendSeparator();
  2944. sub->append(new LLMenuItemCheckGL("Depth of field", menu_toggle_control,
  2945. deferred_rendering_enabled,
  2946. menu_check_control,
  2947. (void*)"RenderDepthOfField"));
  2948. sub->createJumpKeys();
  2949. menu->appendMenu(sub);
  2950. /////////////////////////////
  2951. // Textures rendering sub-menu
  2952. sub = new LLMenuGL("Textures");
  2953. sub->append(new LLMenuItemToggleGL("Animate textures",
  2954. &LLVOVolume::sAnimateTextures));
  2955. sub->append(new LLMenuItemToggleGL("Disable textures",
  2956. &LLViewerTexture::sDontLoadVolumeTextures));
  2957. sub->append(new LLMenuItemCheckGL("Scale down fetched textures",
  2958. menu_toggle_control, NULL,
  2959. menu_check_control,
  2960. (void*)"TextureRescaleFetched"));
  2961. sub->append(new LLMenuItemCheckGL("Load boosted textures at full res",
  2962. menu_toggle_control, NULL,
  2963. menu_check_control,
  2964. (void*)"FullResBoostedTextures"));
  2965. sub->appendSeparator();
  2966. sub->append(new LLMenuItemCheckGL("Boost fetches with speed",
  2967. menu_toggle_control, NULL,
  2968. menu_check_control,
  2969. (void*)"TextureFetchBoostWithSpeed",
  2970. 'B', MASK_CONTROL|MASK_SHIFT));
  2971. sub->append(new LLMenuItemCheckGL("Boost proportional to active fetches",
  2972. menu_toggle_control, NULL,
  2973. menu_check_control,
  2974. (void*)"TextureFetchBoostWithFetches"));
  2975. sub->append(new LLMenuItemCallGL("Boost textures fetches now",
  2976. boost_texture_fetches_now, NULL, NULL,
  2977. 'B', MASK_CONTROL));
  2978. sub->appendSeparator();
  2979. sub->append(new LLMenuItemCheckGL("Fetch/render at 512x512 pixels max",
  2980. textures_size_toggle, NULL,
  2981. textures_size_check_control,
  2982. NULL));
  2983. sub->append(new LLMenuItemCheckGL("Fetch/render at 1024x1024 pixels max",
  2984. textures_size_toggle, NULL,
  2985. textures_size_check_control,
  2986. (void*)1));
  2987. sub->append(new LLMenuItemCheckGL("Fetch/render at 2048x2048 pixels max",
  2988. textures_size_toggle, NULL,
  2989. textures_size_check_control,
  2990. (void*)2));
  2991. sub->appendSeparator();
  2992. sub->append(new LLMenuItemCheckGL("Delay GL textures deletion",
  2993. menu_toggle_control, NULL,
  2994. menu_check_control,
  2995. (void*)"DelayGLTextureDelete"));
  2996. sub->createJumpKeys();
  2997. menu->appendMenu(sub);
  2998. /////////////////////////////
  2999. //
  3000. // Miscellaenous
  3001. //
  3002. menu->appendSeparator();
  3003. menu->append(new LLMenuItemCheckGL("Animate trees", menu_toggle_control,
  3004. NULL, menu_check_control,
  3005. (void*)"RenderAnimateTrees"));
  3006. menu->appendSeparator();
  3007. menu->append(new LLMenuItemCheckGL("Hide selected objects",
  3008. menu_toggle_control, NULL,
  3009. menu_check_control,
  3010. (void*)"HideSelectedObjects"));
  3011. menu->append(new LLMenuItemCallGL("Clear derendered objects list",
  3012. clear_derendered, NULL, NULL));
  3013. menu->append(new LLMenuItemCallGL("Refresh visibility of objects",
  3014. handle_objects_visibility, NULL, NULL,
  3015. 'R', MASK_SHIFT|MASK_ALT));
  3016. menu->append(new LLMenuItemCallGL("Refresh reflection probes",
  3017. handle_refresh_probes, in_pbr_mode,
  3018. NULL));
  3019. menu->appendSeparator();
  3020. menu->append(new LLMenuItemCheckGL("Tangent basis", menu_toggle_control,
  3021. NULL, menu_check_control,
  3022. (void*)"ShowTangentBasis"));
  3023. menu->append(new LLMenuItemCallGL("Selected texture info",
  3024. handle_selected_texture_info, NULL, NULL,
  3025. 'T', MASK_CONTROL|MASK_SHIFT|MASK_ALT));
  3026. menu->append(new LLMenuItemCallGL("Selected legacy material info",
  3027. handle_selected_material_info, NULL,
  3028. NULL, 'A',
  3029. MASK_CONTROL|MASK_SHIFT|MASK_ALT));
  3030. menu->append(new LLMenuItemCallGL("Selected GLTF material info",
  3031. handle_selected_pbr_info, NULL,
  3032. NULL, 'G',
  3033. MASK_CONTROL|MASK_SHIFT|MASK_ALT));
  3034. menu->append(new LLMenuItemCallGL("Reload selected texture",
  3035. reload_selected_texture, NULL, NULL, 'U',
  3036. MASK_CONTROL|MASK_SHIFT));
  3037. #if 0
  3038. menu->append(new LLMenuItemCallGL("Dump image list",
  3039. handle_dump_image_list, NULL, NULL, 'I',
  3040. MASK_CONTROL|MASK_SHIFT));
  3041. #endif
  3042. menu->append(new LLMenuItemCallGL("Reset vertex buffers",
  3043. reset_vertex_buffers, NULL, NULL));
  3044. menu->append(new LLMenuItemCheckGL("Reset vertex buffers at login",
  3045. menu_toggle_control,
  3046. reset_vb_after_login_enabled,
  3047. reset_vb_after_login_check,
  3048. (void*)"ResetVBAfterLogin"));
  3049. menu->append(new LLMenuItemCheckGL("Cache vertex buffers",
  3050. menu_toggle_control, not_in_pbr_mode,
  3051. vb_cache_check_control,
  3052. (void*)"RenderGLUseVBCache"));
  3053. menu->append(new LLMenuItemCheckGL("Optimize mesh vertex cache",
  3054. menu_toggle_control, NULL,
  3055. menu_check_control,
  3056. (void*)"RenderOptimizeMeshVertexCache"));
  3057. // Note: disabled when core GL profile is enabled, because then terrain
  3058. // fails to render properly after GL restart... HB
  3059. menu->append(new LLMenuItemCallGL("Force-restart GL", force_restart_gl,
  3060. force_restart_enabled, NULL));
  3061. menu->appendSeparator();
  3062. menu->append(new LLMenuItemCheckGL("Wireframe", handle_toggle_wireframe,
  3063. wireframe_enabled, wireframe_check,
  3064. NULL, 'R', MASK_CONTROL|MASK_SHIFT));
  3065. menu->append(new LLMenuItemCheckGL("Automatic alpha masks (non-deferred)",
  3066. menu_toggle_control, NULL,
  3067. menu_check_control,
  3068. (void*)"RenderAutoMaskAlphaNonDeferred"));
  3069. menu->append(new LLMenuItemCheckGL("Automatic alpha masks (deferred)",
  3070. menu_toggle_control, NULL,
  3071. menu_check_control,
  3072. (void*)"RenderAutoMaskAlphaDeferred"));
  3073. menu->append(new LLMenuItemCheckGL("Cheesy beacon", menu_toggle_control,
  3074. NULL, menu_check_control,
  3075. (void*)"CheesyBeacon"));
  3076. menu->appendSeparator();
  3077. menu->append(new LLMenuItemCheckGL("Attached lights",
  3078. menu_toggle_attached_lights, NULL,
  3079. menu_check_control,
  3080. (void*)"RenderAttachedLights"));
  3081. menu->append(new LLMenuItemCheckGL("Attached particles",
  3082. menu_toggle_attached_particles, NULL,
  3083. menu_check_control,
  3084. (void*)"RenderAttachedParticles"));
  3085. menu->createJumpKeys();
  3086. }
  3087. void handle_rebuild_avatar(void*)
  3088. {
  3089. if (isAgentAvatarValid())
  3090. {
  3091. uuid_vec_t anim_ids;
  3092. for (LLVOAvatar::anim_it_t
  3093. it = gAgentAvatarp->mPlayingAnimations.begin(),
  3094. end = gAgentAvatarp->mPlayingAnimations.end();
  3095. it != end; ++it)
  3096. {
  3097. const LLUUID& id = it->first;
  3098. // Do not cancel a ground-sit anim, as viewers use this animation's
  3099. // status in determining whether we are sitting.
  3100. if (id != ANIM_AGENT_SIT_GROUND_CONSTRAINED)
  3101. {
  3102. // Stop this animation locally
  3103. gAgentAvatarp->stopMotion(id, true);
  3104. // ...and tell the server to tell everyone.
  3105. anim_ids.emplace_back(id);
  3106. }
  3107. }
  3108. gAgent.sendAnimationRequests(anim_ids, ANIM_REQUEST_STOP);
  3109. gAgentAvatarp->resetSkeleton();
  3110. gPipeline.resetVertexBuffers();
  3111. gAgentAvatarp->startMotion(ANIM_AGENT_STAND, 5.f);
  3112. gAgentAvatarp->startDefaultMotions();
  3113. // Dirty all attachments' spatial groups to force a rebuild.
  3114. gAgentAvatarp->refreshAttachments();
  3115. gNotifications.add("CharacterRebuilt");
  3116. }
  3117. }
  3118. // This entry should not be enabled if the customize appearance floater is
  3119. // visible
  3120. bool local_appearance_enabled(void*)
  3121. {
  3122. return isAgentAvatarValid() && !LLFloaterCustomize::isVisible();
  3123. }
  3124. bool local_appearance_check(void*)
  3125. {
  3126. return isAgentAvatarValid() && gAgentAvatarp->isEditingAppearance();
  3127. }
  3128. void handle_toggle_local_appearance(void*)
  3129. {
  3130. if (isAgentAvatarValid() && !LLFloaterCustomize::isVisible())
  3131. {
  3132. if (gAgentAvatarp->isEditingAppearance())
  3133. {
  3134. LLVOAvatarSelf::onCustomizeEnd();
  3135. }
  3136. else
  3137. {
  3138. LLVOAvatarSelf::onCustomizeStart();
  3139. }
  3140. }
  3141. }
  3142. bool outfit_from_cof_enabled(void*)
  3143. {
  3144. static LLCachedControl<bool> os_use_cof(gSavedSettings, "OSUseCOF");
  3145. return gIsInSecondLife || os_use_cof;
  3146. }
  3147. bool outfit_from_cof_check(void*)
  3148. {
  3149. static LLCachedControl<bool> from_cof(gSavedSettings,
  3150. "RestoreOutfitFromCOF");
  3151. return from_cof && outfit_from_cof_enabled(NULL);
  3152. }
  3153. void handle_toggle_outfit_from_cof(void*)
  3154. {
  3155. bool enabled = gSavedSettings.getBool("RestoreOutfitFromCOF");
  3156. if (enabled)
  3157. {
  3158. gNotifications.add("DisablingRestoreFromCOF");
  3159. }
  3160. gSavedSettings.setBool("RestoreOutfitFromCOF", !enabled);
  3161. }
  3162. // *HACK for easily testing new avatar geometry
  3163. void handle_god_request_avatar_geometry(void*)
  3164. {
  3165. if (gAgent.isGodlike())
  3166. {
  3167. gSelectMgr.sendGodlikeRequest("avatar toggle", NULL);
  3168. }
  3169. }
  3170. void set_all_animation_time_factors(F32 time_factor)
  3171. {
  3172. LLMotionController::setTimeFactorMultiplier(time_factor);
  3173. for (S32 i = 0, count = LLCharacter::sInstances.size(); i < count; ++i)
  3174. {
  3175. LLCharacter* charp = LLCharacter::sInstances[i];
  3176. if (charp) // Paranoia
  3177. {
  3178. charp->setAnimTimeFactorMultiplier(time_factor);
  3179. }
  3180. }
  3181. }
  3182. bool is_slow_mo_animations(void*)
  3183. {
  3184. if (!isAgentAvatarValid()) return false;
  3185. return gAgentAvatarp->getAnimTimeFactorMultiplier() == 0.2f;
  3186. }
  3187. void slow_mo_animations(void*)
  3188. {
  3189. if (!isAgentAvatarValid()) return;
  3190. if (is_slow_mo_animations(NULL))
  3191. {
  3192. gAgentAvatarp->setAnimTimeFactorMultiplier(1.f);
  3193. }
  3194. else
  3195. {
  3196. gAgentAvatarp->setAnimTimeFactorMultiplier(0.2f);
  3197. }
  3198. }
  3199. void handle_reset_animations_speed(void*)
  3200. {
  3201. set_all_animation_time_factors(1.f);
  3202. }
  3203. void handle_slower_animations(void*)
  3204. {
  3205. F32 time_factor = LLMotionController::getTimeFactorMultiplier();
  3206. // Lower limit is at 10% of normal speed
  3207. time_factor = llmax(time_factor - 0.1f, 0.1f);
  3208. set_all_animation_time_factors(time_factor);
  3209. }
  3210. void handle_faster_animations(void*)
  3211. {
  3212. F32 time_factor = LLMotionController::getTimeFactorMultiplier();
  3213. // Upper limit is 200% speed
  3214. time_factor = llmin(time_factor + 0.1f, 2.f);
  3215. set_all_animation_time_factors(time_factor);
  3216. }
  3217. void handle_reset_avatars_animations(void*)
  3218. {
  3219. // Get the list of avatars from the characters list which is much smaller
  3220. // than the objects list. HB
  3221. for (S32 i = 0, count = LLCharacter::sInstances.size(); i < count; ++i)
  3222. {
  3223. LLVOAvatar* avatarp = (LLVOAvatar*)LLCharacter::sInstances[i];
  3224. if (avatarp && !avatarp->isDead() && !avatarp->mIsDummy &&
  3225. !avatarp->isOrphaned())
  3226. {
  3227. for (LLVOAvatar::anim_it_t
  3228. it = avatarp->mPlayingAnimations.begin(),
  3229. end = avatarp->mPlayingAnimations.end();
  3230. it != end; ++it)
  3231. {
  3232. const LLUUID& anim_id = it->first;
  3233. avatarp->stopMotion(anim_id, true);
  3234. avatarp->startMotion(anim_id);
  3235. }
  3236. }
  3237. }
  3238. }
  3239. void handle_test_male(void*)
  3240. {
  3241. //MK
  3242. if (gRLenabled &&
  3243. (gRLInterface.mContainsDetach || gRLInterface.contains("remoutfit") ||
  3244. gRLInterface.contains("addoutfit")))
  3245. {
  3246. return;
  3247. }
  3248. //mk
  3249. gAppearanceMgr.wearOutfitByName("Male Shape & Outfit");
  3250. #if 0
  3251. gGestureList.requestResetFromServer(true);
  3252. #endif
  3253. }
  3254. void handle_test_female(void*)
  3255. {
  3256. //MK
  3257. if (gRLenabled &&
  3258. (gRLInterface.mContainsDetach || gRLInterface.contains("remoutfit") ||
  3259. gRLInterface.contains("addoutfit")))
  3260. {
  3261. return;
  3262. }
  3263. //mk
  3264. gAppearanceMgr.wearOutfitByName("Female Shape & Outfit");
  3265. #if 0
  3266. gGestureList.requestResetFromServer(false);
  3267. #endif
  3268. }
  3269. void handle_toggle_pg(void*)
  3270. {
  3271. gAgent.setTeen(!gAgent.isTeen());
  3272. LLFloaterWorldMap::reloadIcons(NULL);
  3273. llinfos << "PG status set to " << (S32)gAgent.isTeen() << llendl;
  3274. }
  3275. void handle_dump_attachments(void*)
  3276. {
  3277. if (!isAgentAvatarValid())
  3278. {
  3279. return;
  3280. }
  3281. LLViewerJointAttachment* attachment;
  3282. LLViewerObject* object;
  3283. for (S32 i = 0, count = gAgentAvatarp->mAttachedObjectsVector.size();
  3284. i < count; ++i)
  3285. {
  3286. attachment = gAgentAvatarp->mAttachedObjectsVector[i].second;
  3287. if (!attachment)
  3288. {
  3289. llwarns << "NULL attachment point detected !" << llendl;
  3290. continue;
  3291. }
  3292. object = gAgentAvatarp->mAttachedObjectsVector[i].first;
  3293. if (!object)
  3294. {
  3295. llwarns << attachment->getName() << ": NULL object attached"
  3296. << llendl;
  3297. }
  3298. else if (object->mDrawable.isNull())
  3299. {
  3300. llwarns << attachment->getName() << ": "
  3301. << object->getAttachmentItemID() << " got a NULL drawable"
  3302. << " - object position = " << object->getPosition()
  3303. << llendl;
  3304. }
  3305. else
  3306. {
  3307. llinfos << attachment->getName() << ": "
  3308. << object->getAttachmentItemID()
  3309. << (object->mDrawable->isRenderType(0) ? " - invisible"
  3310. : " - visible")
  3311. << " - drawable position = "
  3312. << object->mDrawable->getPosition()
  3313. << " - object position = " << object->getPosition()
  3314. << llendl;
  3315. }
  3316. }
  3317. }
  3318. void handle_dump_avatar_local_textures(void*)
  3319. {
  3320. if (isAgentAvatarValid())
  3321. {
  3322. gAgentAvatarp->dumpLocalTextures();
  3323. }
  3324. }
  3325. void handle_avatar_textures(void*)
  3326. {
  3327. LLFloaterAvatarTextures::show(gAgentID);
  3328. }
  3329. bool enable_avatar_textures(void*)
  3330. {
  3331. if (gAgent.isGodlikeWithoutAdminMenuFakery())
  3332. {
  3333. return true;
  3334. }
  3335. // Only allow to examine textures if every worn wearable can be exported
  3336. // by the agent. We reuse HBObjectBackup's logic which implements both the
  3337. // "created by agent" condition for Second Life and the "exportable" (or
  3338. // full perm) condition for OpenSIM grids.
  3339. for (S32 t = (S32)LLWearableType::WT_SKIN;
  3340. t < (S32)LLWearableType::WT_COUNT; ++t)
  3341. {
  3342. LLWearableType::EType type = (LLWearableType::EType)t;
  3343. U32 count = gAgentWearables.getWearableCount(type);
  3344. for (U32 index = 0; index < count; ++index)
  3345. {
  3346. LLViewerWearable* wearable =
  3347. gAgentWearables.getViewerWearable(type, index);
  3348. if (!wearable) continue;
  3349. LLViewerInventoryItem* itemp =
  3350. gInventory.getItem(wearable->getItemID());
  3351. if (itemp &&
  3352. !HBObjectBackup::validatePerms(&itemp->getPermissions()))
  3353. {
  3354. return false;
  3355. }
  3356. }
  3357. }
  3358. return true;
  3359. }
  3360. void dump_avatar_xml_callback(HBFileSelector::ESaveFilter,
  3361. std::string& filename, void* userdata)
  3362. {
  3363. if (isAgentAvatarValid())
  3364. {
  3365. gAgentAvatarp->dumpArchetypeXML(filename);
  3366. }
  3367. }
  3368. void handle_dump_avatar_xml(void*)
  3369. {
  3370. // Open the file save dialog
  3371. HBFileSelector::saveFile(HBFileSelector::FFSAVE_XML, "archetype.xml",
  3372. dump_avatar_xml_callback);
  3373. }
  3374. #if LL_EXPORT_AVATAR_OBJ
  3375. void handle_export_avatar(void*)
  3376. {
  3377. ALWavefrontSaver::exportAvatar();
  3378. }
  3379. void handle_export_avatar_with_attachments(void*)
  3380. {
  3381. ALWavefrontSaver::exportAvatar(true);
  3382. }
  3383. #endif
  3384. bool enable_autopilot_begin_record(void*)
  3385. {
  3386. return !gAgentPilot.isRecording();
  3387. }
  3388. bool enable_autopilot_end_record(void*)
  3389. {
  3390. return gAgentPilot.isRecording();
  3391. }
  3392. bool enable_autopilot_start_playback(void*)
  3393. {
  3394. return gAgentPilot.hasRecord() && !gAgentPilot.isPlaying() &&
  3395. !gAgentPilot.isRecording();
  3396. }
  3397. bool enable_autopilot_stop_playback(void*)
  3398. {
  3399. return gAgentPilot.isPlaying();
  3400. }
  3401. #if LL_PUPPETRY
  3402. // Puppetry sub-menu
  3403. bool enable_launch_puppetry(void*)
  3404. {
  3405. return !HBFileSelector::isInUse() && LLPuppetMotion::enabled() &&
  3406. !LLPuppetModule::getInstance()->havePuppetModule();
  3407. }
  3408. void launch_leap_callback(HBFileSelector::ELoadFilter,
  3409. std::string& filename, void*)
  3410. {
  3411. if (!filename.empty())
  3412. {
  3413. LLPuppetModule::getInstance()->launchLeapPlugin(filename);
  3414. }
  3415. }
  3416. void handle_launch_puppetry(void*)
  3417. {
  3418. if (enable_launch_puppetry(NULL))
  3419. {
  3420. HBFileSelector::loadFile(HBFileSelector::FFLOAD_ALL,
  3421. launch_leap_callback);
  3422. }
  3423. }
  3424. bool enable_launch_prev_puppetry(void*)
  3425. {
  3426. LLCachedControl<std::string> cmd(gSavedSettings, "PuppetryLastCommand");
  3427. return LLPuppetMotion::enabled() &&
  3428. !LLPuppetModule::getInstance()->havePuppetModule() &&
  3429. !std::string(cmd).empty();
  3430. }
  3431. void handle_launch_prev_puppetry(void*)
  3432. {
  3433. std::string command = gSavedSettings.getString("PuppetryLastCommand");
  3434. if (!command.empty() && LLPuppetMotion::enabled())
  3435. {
  3436. LLPuppetModule* modulep = LLPuppetModule::getInstance();
  3437. if (!modulep->havePuppetModule() &&
  3438. !modulep->launchLeapCommand(command))
  3439. {
  3440. // Clear the command, since it is obviously invalid... HB
  3441. gSavedSettings.setString("PuppetryLastCommand", "");
  3442. }
  3443. }
  3444. }
  3445. bool enable_puppetry_actions(void*)
  3446. {
  3447. return LLPuppetMotion::enabled() &&
  3448. LLPuppetModule::getInstance()->havePuppetModule();
  3449. }
  3450. void handle_stop_puppetry(void*)
  3451. {
  3452. if (enable_puppetry_actions(NULL))
  3453. {
  3454. LLPuppetModule* modulep = LLPuppetModule::getInstance();
  3455. modulep->setSending(false);
  3456. modulep->setEcho(false);
  3457. modulep->clearLeapModule();
  3458. }
  3459. }
  3460. void handle_puppetry_toggle_send(void*)
  3461. {
  3462. if (enable_puppetry_actions(NULL))
  3463. {
  3464. LLPuppetModule* modulep = LLPuppetModule::getInstance();
  3465. modulep->setSending(!modulep->isSending());
  3466. }
  3467. }
  3468. bool puppetry_send_check(void*)
  3469. {
  3470. return enable_puppetry_actions(NULL) &&
  3471. LLPuppetModule::getInstance()->isSending();
  3472. }
  3473. bool enable_puppetry_receive(void*)
  3474. {
  3475. return LLPuppetMotion::enabled();
  3476. }
  3477. void handle_puppetry_toggle_receive(void*)
  3478. {
  3479. if (LLPuppetMotion::enabled())
  3480. {
  3481. LLPuppetModule* modulep = LLPuppetModule::getInstance();
  3482. modulep->setReceiving(!modulep->isReceiving());
  3483. }
  3484. }
  3485. bool puppetry_receive_check(void*)
  3486. {
  3487. return LLPuppetMotion::enabled() &&
  3488. LLPuppetModule::getInstance()->isReceiving();
  3489. }
  3490. bool puppetry_echo_check(void*)
  3491. {
  3492. return enable_puppetry_actions(NULL) &&
  3493. LLPuppetModule::getInstance()->getEcho();
  3494. }
  3495. void puppetry_toggle_part(void* user_data)
  3496. {
  3497. if (enable_puppetry_actions(NULL))
  3498. {
  3499. S32 part = S32(intptr_t(user_data));
  3500. LLPuppetModule* modulep = LLPuppetModule::getInstance();
  3501. modulep->setEnabledPart(part, !modulep->getEnabledPart(part));
  3502. }
  3503. }
  3504. bool puppetry_check_part(void* user_data)
  3505. {
  3506. S32 part = S32(intptr_t(user_data));
  3507. return enable_puppetry_actions(NULL) &&
  3508. LLPuppetModule::getInstance()->getEnabledPart(part);
  3509. }
  3510. void init_puppetry_menu(LLMenuGL* menu)
  3511. {
  3512. menu->append(new LLMenuItemCheckGL("Use puppetry when available",
  3513. menu_toggle_control, NULL,
  3514. menu_check_control,
  3515. (void*)"PuppetryAllowed"));
  3516. menu->appendSeparator();
  3517. menu->append(new LLMenuItemCallGL("Launch plug-in...",
  3518. handle_launch_puppetry,
  3519. enable_launch_puppetry));
  3520. menu->append(new LLMenuItemCallGL("Launch previous plug-in",
  3521. handle_launch_prev_puppetry,
  3522. enable_launch_prev_puppetry));
  3523. menu->append(new LLMenuItemCallGL("Stop running plug-in",
  3524. handle_stop_puppetry,
  3525. enable_puppetry_actions));
  3526. menu->append(new LLMenuItemCheckGL("Send data",
  3527. handle_puppetry_toggle_send,
  3528. enable_puppetry_actions,
  3529. puppetry_send_check, NULL));
  3530. menu->append(new LLMenuItemCheckGL("Receive data",
  3531. handle_puppetry_toggle_receive,
  3532. enable_puppetry_receive,
  3533. puppetry_receive_check, NULL));
  3534. menu->append(new LLMenuItemCheckGL("Use server echo on self",
  3535. menu_toggle_control,
  3536. enable_puppetry_actions,
  3537. puppetry_echo_check,
  3538. (void*)"PuppetryUseServerEcho"));
  3539. menu->append(new LLMenuItemCheckGL("Send binary LLSD data to plugin",
  3540. menu_toggle_control,
  3541. enable_launch_puppetry,
  3542. menu_check_control,
  3543. (void*)"PuppetryBinaryOutputStream"));
  3544. #if LL_USE_NEW_DESERIALIZE
  3545. menu->append(new LLMenuItemCheckGL("Get binary LLSD data from plugin (BROKEN)",
  3546. menu_toggle_control,
  3547. enable_launch_puppetry,
  3548. menu_check_control,
  3549. (void*)"PuppetryBinaryInputStream"));
  3550. #endif
  3551. menu->append(new LLMenuItemCheckGL("Send attachments data to server",
  3552. menu_toggle_control, NULL,
  3553. menu_check_control,
  3554. (void*)"PuppetrySendAttachmentsData"));
  3555. LLMenuGL* sub = new LLMenuGL("Puppeteered parts");
  3556. sub->append(new LLMenuItemCheckGL("Head", puppetry_toggle_part,
  3557. enable_puppetry_actions,
  3558. puppetry_check_part, (void*)1));
  3559. sub->append(new LLMenuItemCheckGL("Face", puppetry_toggle_part,
  3560. enable_puppetry_actions,
  3561. puppetry_check_part, (void*)2));
  3562. sub->append(new LLMenuItemCheckGL("Left hand", puppetry_toggle_part,
  3563. enable_puppetry_actions,
  3564. puppetry_check_part, (void*)4));
  3565. sub->append(new LLMenuItemCheckGL("Right hand", puppetry_toggle_part,
  3566. enable_puppetry_actions,
  3567. puppetry_check_part, (void*)8));
  3568. sub->append(new LLMenuItemCheckGL("Fingers", puppetry_toggle_part,
  3569. enable_puppetry_actions,
  3570. puppetry_check_part, (void*)16));
  3571. sub->createJumpKeys();
  3572. menu->appendMenu(sub);
  3573. menu->createJumpKeys();
  3574. }
  3575. // End of puppetry sub-menu
  3576. #endif
  3577. void handle_grab_baked_texture(void* data)
  3578. {
  3579. EBakedTextureIndex index = (EBakedTextureIndex)((intptr_t)data);
  3580. if (isAgentAvatarValid())
  3581. {
  3582. const LLUUID& asset_id = gAgentAvatarp->grabBakedTexture(index);
  3583. llinfos << "Adding baked texture " << asset_id << " to inventory."
  3584. << llendl;
  3585. LLAssetType::EType asset_type = LLAssetType::AT_TEXTURE;
  3586. LLInventoryType::EType inv_type = LLInventoryType::IT_TEXTURE;
  3587. LLUUID folder_id(gInventory.findChoosenCategoryUUIDForType(LLFolderType::FT_TEXTURE));
  3588. if (folder_id.notNull())
  3589. {
  3590. std::string name;
  3591. name = "Baked " +
  3592. gAvatarAppDictp->getBakedTexture(index)->mNameCapitalized +
  3593. " Texture";
  3594. LLUUID item_id;
  3595. item_id.generate();
  3596. LLPermissions perm;
  3597. perm.init(gAgentID, gAgentID, LLUUID::null, LLUUID::null);
  3598. U32 next_owner_perm = PERM_MOVE | PERM_TRANSFER;
  3599. perm.initMasks(PERM_ALL, PERM_ALL, PERM_NONE, PERM_NONE,
  3600. next_owner_perm);
  3601. time_t creation_date_now = time_corrected();
  3602. LLPointer<LLViewerInventoryItem> item =
  3603. new LLViewerInventoryItem(item_id, folder_id, perm, asset_id,
  3604. asset_type, inv_type, name,
  3605. LLStringUtil::null,
  3606. LLSaleInfo::DEFAULT,
  3607. LLInventoryItem::II_FLAGS_NONE,
  3608. creation_date_now);
  3609. item->updateServer(true);
  3610. gInventory.updateItem(item);
  3611. gInventory.notifyObservers();
  3612. // Show the preview panel for textures to let user know that the
  3613. // image is now in inventory.
  3614. LLFloaterInventory* inv = LLFloaterInventory::getActiveFloater();
  3615. if (inv)
  3616. {
  3617. // Save focused element
  3618. LLFocusableElement* focus_ctrl = gFocusMgr.getKeyboardFocus();
  3619. inv->getPanel()->setSelection(item_id, TAKE_FOCUS_NO);
  3620. inv->getPanel()->openSelected();
  3621. // Restore keyboard focus
  3622. gFocusMgr.setKeyboardFocus(focus_ctrl);
  3623. }
  3624. }
  3625. else
  3626. {
  3627. llwarns << "Cannot find a folder to put the texture in" << llendl;
  3628. }
  3629. }
  3630. }
  3631. bool enable_grab_baked_texture(void* data)
  3632. {
  3633. if (isAgentAvatarValid())
  3634. {
  3635. EBakedTextureIndex index = (EBakedTextureIndex)((intptr_t)data);
  3636. return gAgentAvatarp->canGrabBakedTexture(index);
  3637. }
  3638. else
  3639. {
  3640. return false;
  3641. }
  3642. }
  3643. void init_debug_baked_texture_menu(LLMenuGL* menu)
  3644. {
  3645. menu->append(new LLMenuItemCallGL("Hair", handle_grab_baked_texture,
  3646. enable_grab_baked_texture,
  3647. (void*)BAKED_HAIR));
  3648. menu->append(new LLMenuItemCallGL("Iris", handle_grab_baked_texture,
  3649. enable_grab_baked_texture,
  3650. (void*)BAKED_EYES));
  3651. menu->append(new LLMenuItemCallGL("Head", handle_grab_baked_texture,
  3652. enable_grab_baked_texture,
  3653. (void*)BAKED_HEAD));
  3654. menu->append(new LLMenuItemCallGL("Upper body", handle_grab_baked_texture,
  3655. enable_grab_baked_texture,
  3656. (void*)BAKED_UPPER));
  3657. menu->append(new LLMenuItemCallGL("Lower body", handle_grab_baked_texture,
  3658. enable_grab_baked_texture,
  3659. (void*)BAKED_LOWER));
  3660. menu->append(new LLMenuItemCallGL("Skirt", handle_grab_baked_texture,
  3661. enable_grab_baked_texture,
  3662. (void*)BAKED_SKIRT));
  3663. menu->createJumpKeys();
  3664. }
  3665. void init_debug_character_menu(LLMenuGL* menu)
  3666. {
  3667. LLMenuGL* sub = new LLMenuGL("Auto-pilot recorder");
  3668. sub->append(new LLMenuItemCallGL("Begin record", LLAgentPilot::beginRecord,
  3669. enable_autopilot_begin_record));
  3670. sub->append(new LLMenuItemCallGL("End record", LLAgentPilot::endRecord,
  3671. enable_autopilot_end_record));
  3672. sub->append(new LLMenuItemCallGL("Forget record",
  3673. LLAgentPilot::forgetRecord,
  3674. enable_autopilot_start_playback));
  3675. sub->appendSeparator();
  3676. sub->append(new LLMenuItemCallGL("Start playback",
  3677. LLAgentPilot::startPlayback,
  3678. enable_autopilot_start_playback));
  3679. sub->append(new LLMenuItemCallGL("Stop playback",
  3680. LLAgentPilot::stopPlayback,
  3681. enable_autopilot_stop_playback));
  3682. sub->append(new LLMenuItemToggleGL("Loop playback", &LLAgentPilot::sLoop));
  3683. sub->append(new LLMenuItemToggleGL("Allow flying",
  3684. &LLAgentPilot::sAllowFlying));
  3685. sub->createJumpKeys();
  3686. menu->appendMenu(sub);
  3687. sub = new LLMenuGL("Character tests");
  3688. // HACK for easy testing of avatar geometry
  3689. sub->append(new LLMenuItemCallGL("Toggle character geometry",
  3690. handle_god_request_avatar_geometry,
  3691. enable_god_customer_service, NULL));
  3692. sub->append(new LLMenuItemCallGL("Test male", handle_test_male));
  3693. sub->append(new LLMenuItemCallGL("Test female", handle_test_female));
  3694. sub->append(new LLMenuItemCallGL("Force visual params to default",
  3695. LLAgent::clearVisualParams, NULL));
  3696. sub->append(new LLMenuItemCallGL("Toggle PG", handle_toggle_pg));
  3697. #if 0 // This does not work at all...
  3698. sub->append(new LLMenuItemCheckGL("Allow select avatar",
  3699. menu_toggle_control, NULL,
  3700. menu_check_control,
  3701. (void*)"AllowSelectAvatar"));
  3702. #endif
  3703. sub->createJumpKeys();
  3704. menu->appendMenu(sub);
  3705. sub = new LLMenuGL("Character debugging");
  3706. sub->append(new LLMenuItemCheckGL("Show collision skeleton",
  3707. LLPipeline::toggleRenderDebug, NULL,
  3708. LLPipeline::toggleRenderDebugControl,
  3709. (void*)LLPipeline::RENDER_DEBUG_AVATAR_VOLUME));
  3710. sub->append(new LLMenuItemCheckGL("Show avatar joints",
  3711. LLPipeline::toggleRenderDebug, NULL,
  3712. LLPipeline::toggleRenderDebugControl,
  3713. (void*)LLPipeline::RENDER_DEBUG_AVATAR_JOINTS));
  3714. sub->append(new LLMenuItemCheckGL("Show agent target",
  3715. LLPipeline::toggleRenderDebug, NULL,
  3716. LLPipeline::toggleRenderDebugControl,
  3717. (void*)LLPipeline::RENDER_DEBUG_AGENT_TARGET));
  3718. sub->append(new LLMenuItemCheckGL("Show above for self only",
  3719. menu_toggle_control, NULL,
  3720. menu_check_control,
  3721. (void*)"ShowAvatarDebugForSelfOnly"));
  3722. #if 0 // This does not seem to produce any visible result...
  3723. sub->appendSeparator();
  3724. sub->append(new LLMenuItemToggleGL("Show attachment points",
  3725. &LLVOAvatar::sShowAttachmentPoints));
  3726. #endif
  3727. sub->appendSeparator();
  3728. sub->append(new LLMenuItemToggleGL("Debug joint updates",
  3729. &LLVOAvatar::sJointDebug));
  3730. sub->append(new LLMenuItemToggleGL("Debug character visibility",
  3731. &LLVOAvatar::sDebugInvisible));
  3732. sub->append(new LLMenuItemCallGL("Dump attachments",
  3733. handle_dump_attachments));
  3734. sub->append(new LLMenuItemCallGL("Dump local textures",
  3735. handle_dump_avatar_local_textures,
  3736. enable_non_faked_god, NULL));
  3737. sub->createJumpKeys();
  3738. menu->appendMenu(sub);
  3739. menu->appendSeparator();
  3740. menu->append(new LLMenuItemCallGL("Appearance to XML...",
  3741. handle_dump_avatar_xml,
  3742. enable_picker_actions, NULL));
  3743. #if LL_EXPORT_AVATAR_OBJ
  3744. menu->append(new LLMenuItemCallGL("Export as a Wavefront OBJ file...",
  3745. handle_export_avatar,
  3746. enable_picker_actions, NULL));
  3747. menu->append(new LLMenuItemCallGL("Export with attachments as OBJ...",
  3748. handle_export_avatar_with_attachments,
  3749. enable_picker_actions, NULL));
  3750. #endif
  3751. menu->append(new LLMenuItemCallGL("Reset avatar skeleton",
  3752. handle_rebuild_avatar));
  3753. menu->append(new LLMenuItemCheckGL("Restore outfit from COF",
  3754. handle_toggle_outfit_from_cof,
  3755. outfit_from_cof_enabled,
  3756. outfit_from_cof_check, NULL));
  3757. menu->appendSeparator();
  3758. menu->append(new LLMenuItemCallGL("Rebake textures",
  3759. handle_rebake_textures, NULL, NULL, 'R',
  3760. MASK_ALT | MASK_CONTROL));
  3761. menu->append(new LLMenuItemCheckGL("Aggressive avatar rebakes",
  3762. menu_toggle_control, NULL,
  3763. menu_check_control,
  3764. (void*)"AvatarAggressiveRebake"));
  3765. menu->append(new LLMenuItemCheckGL("Local baking/appearance",
  3766. handle_toggle_local_appearance,
  3767. local_appearance_enabled,
  3768. local_appearance_check, NULL, 'L',
  3769. MASK_CONTROL | MASK_ALT| MASK_SHIFT));
  3770. menu->append(new LLMenuItemCheckGL("Use large bakes (after restart)",
  3771. toggle_large_bakes, not_in_sl,
  3772. large_bakes_checked, NULL));
  3773. sub = new LLMenuGL("Grab baked texture");
  3774. init_debug_baked_texture_menu(sub);
  3775. menu->appendMenu(sub);
  3776. menu->append(new LLMenuItemCallGL("View avatar textures",
  3777. handle_avatar_textures,
  3778. enable_avatar_textures, NULL));
  3779. menu->append(new LLMenuItemCheckGL("Report complexity changes",
  3780. menu_toggle_control, NULL,
  3781. menu_check_control,
  3782. (void*)"ShowMyComplexityChanges"));
  3783. menu->append(new LLMenuItemCheckGL("Customize appearance lighting",
  3784. menu_toggle_control, NULL,
  3785. menu_check_control,
  3786. (void*)"AvatarCustomizeLighting"));
  3787. menu->appendSeparator();
  3788. menu->append(new LLMenuItemToggleGL("Tap-tap-hold to run",
  3789. &gAllowTapTapHoldRun));
  3790. menu->append(new LLMenuItemCheckGL("Spoof mouse-look mode",
  3791. menu_toggle_control, NULL,
  3792. menu_check_control,
  3793. (void*)"SpoofMouseLook",
  3794. 'M',
  3795. MASK_SHIFT | MASK_ALT | MASK_CONTROL));
  3796. menu->appendSeparator();
  3797. menu->append(new LLMenuItemToggleGL("Animation info",
  3798. &LLVOAvatar::sShowAnimationDebug));
  3799. menu->append(new LLMenuItemCheckGL("Use new walk and run animations",
  3800. menu_toggle_control, NULL,
  3801. menu_check_control,
  3802. (void*)"UseNewWalkRun"));
  3803. menu->append(new LLMenuItemCheckGL("Slow motion animations (self)",
  3804. &slow_mo_animations, NULL,
  3805. &is_slow_mo_animations, NULL));
  3806. sub = new LLMenuGL("All avatars' animations speed");
  3807. sub->append(new LLMenuItemCallGL("10% slower",
  3808. handle_slower_animations));
  3809. sub->append(new LLMenuItemCallGL("10% faster",
  3810. handle_faster_animations));
  3811. sub->append(new LLMenuItemCallGL("Reset to normal speed",
  3812. handle_reset_animations_speed));
  3813. sub->createJumpKeys();
  3814. menu->appendMenu(sub);
  3815. menu->append(new LLMenuItemCallGL("Reset visible avatars' animations",
  3816. handle_reset_avatars_animations));
  3817. #if LL_PUPPETRY
  3818. sub = new LLMenuGL("Puppetry");
  3819. init_puppetry_menu(sub);
  3820. menu->appendMenu(sub);
  3821. #endif
  3822. menu->appendSeparator();
  3823. menu->append(new LLMenuItemToggleGL("Show look at",
  3824. &LLHUDEffectLookAt::sDebugLookAt));
  3825. menu->append(new LLMenuItemToggleGL("Show point at",
  3826. &LLHUDEffectPointAt::sDebugPointAt));
  3827. menu->appendSeparator();
  3828. menu->append(new LLMenuItemToggleGL("Disable LOD",
  3829. &LLAvatarJoint::sDisableLOD));
  3830. menu->createJumpKeys();
  3831. }
  3832. void handle_region_dump_temp_asset_data(void*)
  3833. {
  3834. llinfos << "Dumping temporary asset data to simulator logs" << llendl;
  3835. std::vector<std::string> strings;
  3836. LLUUID invoice;
  3837. send_generic_message("dumptempassetdata", strings, invoice);
  3838. }
  3839. #if 0
  3840. void handle_region_clear_temp_asset_data(void*)
  3841. {
  3842. llinfos << "Clearing temporary asset data" << llendl;
  3843. std::vector<std::string> strings;
  3844. LLUUID invoice;
  3845. send_generic_message("cleartempassetdata", strings, invoice);
  3846. }
  3847. #endif
  3848. void handle_object_owner_permissive(void*)
  3849. {
  3850. // only send this if they're a god.
  3851. if (gAgent.isGodlike())
  3852. {
  3853. // do the objects.
  3854. gSelectMgr.selectionSetObjectPermissions(PERM_BASE, true, PERM_ALL,
  3855. true);
  3856. gSelectMgr.selectionSetObjectPermissions(PERM_OWNER, true, PERM_ALL,
  3857. true);
  3858. }
  3859. }
  3860. void handle_object_owner_self(void*)
  3861. {
  3862. // only send this if they're a god.
  3863. if (gAgent.isGodlike())
  3864. {
  3865. gSelectMgr.sendOwner(gAgentID, gAgent.getGroupID(), true);
  3866. }
  3867. }
  3868. // Shortcut to set owner permissions to not editable.
  3869. void handle_object_lock(void*)
  3870. {
  3871. gSelectMgr.selectionSetObjectPermissions(PERM_OWNER, false, PERM_MODIFY);
  3872. }
  3873. void handle_object_asset_ids(void*)
  3874. {
  3875. // only send this if they're a god.
  3876. if (gAgent.isGodlike())
  3877. {
  3878. gSelectMgr.sendGodlikeRequest("objectinfo", "assetids");
  3879. }
  3880. }
  3881. void derez_objects(EDeRezDestination dest, const LLUUID& dest_id)
  3882. {
  3883. if (gAgent.cameraMouselook())
  3884. {
  3885. gAgent.changeCameraToDefault();
  3886. }
  3887. std::string error;
  3888. std::vector<LLViewerObject*> objects_list;
  3889. // Check conditions that we can't deal with, building a list of
  3890. // everything that we'll actually be derezzing.
  3891. LLViewerRegion* first_region = NULL;
  3892. for (LLObjectSelection::valid_root_iterator
  3893. iter = gSelectMgr.getSelection()->valid_root_begin(),
  3894. end = gSelectMgr.getSelection()->valid_root_end();
  3895. iter != end; ++iter)
  3896. {
  3897. LLSelectNode* node = *iter;
  3898. if (!node) continue; // Paranoia
  3899. LLViewerObject* object = node->getObject();
  3900. if (!object) continue; // Paranoia
  3901. LLViewerRegion* region = object->getRegion();
  3902. if (!first_region)
  3903. {
  3904. first_region = region;
  3905. }
  3906. else if (region != first_region)
  3907. {
  3908. // Derez does not work at all if the some of the objects are in
  3909. // regions besides the first object selected.
  3910. // ...crosses region boundaries
  3911. error = "AcquireErrorObjectSpan";
  3912. break;
  3913. }
  3914. if (object->isAvatar())
  3915. {
  3916. // ...Do not acquire avatars
  3917. continue;
  3918. }
  3919. if (object->getNVPair("AssetContainer") && dest != DRD_RETURN_TO_OWNER)
  3920. {
  3921. llwarns << "Attempt to derez deprecated AssetContainer object type not supported."
  3922. << llendl;
  3923. continue;
  3924. }
  3925. bool can_derez_current = false;
  3926. switch (dest)
  3927. {
  3928. case DRD_TAKE_INTO_AGENT_INVENTORY:
  3929. case DRD_TRASH:
  3930. if (!object->isPermanentEnforced() &&
  3931. ((node->mPermissions->allowTransferTo(gAgentID) &&
  3932. object->permModify()) ||
  3933. node->allowOperationOnNode(PERM_OWNER,
  3934. GP_OBJECT_MANIPULATE)))
  3935. {
  3936. can_derez_current = true;
  3937. }
  3938. break;
  3939. case DRD_RETURN_TO_OWNER:
  3940. can_derez_current = true;
  3941. break;
  3942. default:
  3943. if (gAgent.isGodlike() ||
  3944. (object->permCopy() &&
  3945. node->mPermissions->allowTransferTo(gAgentID)))
  3946. {
  3947. can_derez_current = true;
  3948. }
  3949. }
  3950. if (can_derez_current)
  3951. {
  3952. objects_list.push_back(object);
  3953. }
  3954. }
  3955. // This constant is based on (1200 - HEADER_SIZE) / 4 bytes per
  3956. // root. I lopped off a few (33) to provide a bit
  3957. // pad. HEADER_SIZE is currently 67 bytes, most of which is UUIDs.
  3958. // This gives us a maximum of 63500 root objects - which should
  3959. // satisfy anybody.
  3960. constexpr S32 MAX_ROOTS_PER_PACKET = 250;
  3961. constexpr S32 MAX_PACKET_COUNT = 254;
  3962. F32 packets = ceil((F32)objects_list.size() / (F32)MAX_ROOTS_PER_PACKET);
  3963. if (packets > (F32)MAX_PACKET_COUNT)
  3964. {
  3965. error = "AcquireErrorTooManyObjects";
  3966. }
  3967. if (error.empty() && objects_list.size() > 0)
  3968. {
  3969. U8 d = (U8)dest;
  3970. LLUUID tid;
  3971. tid.generate();
  3972. U8 packet_count = (U8)packets;
  3973. S32 object_index = 0;
  3974. S32 objects_in_packet = 0;
  3975. LLMessageSystem* msg = gMessageSystemp;
  3976. for (U8 packet_number = 0; packet_number < packet_count; ++packet_number)
  3977. {
  3978. msg->newMessageFast(_PREHASH_DeRezObject);
  3979. msg->nextBlockFast(_PREHASH_AgentData);
  3980. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  3981. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  3982. msg->nextBlockFast(_PREHASH_AgentBlock);
  3983. msg->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupID());
  3984. msg->addU8Fast(_PREHASH_Destination, d);
  3985. msg->addUUIDFast(_PREHASH_DestinationID, dest_id);
  3986. msg->addUUIDFast(_PREHASH_TransactionID, tid);
  3987. msg->addU8Fast(_PREHASH_PacketCount, packet_count);
  3988. msg->addU8Fast(_PREHASH_PacketNumber, packet_number);
  3989. objects_in_packet = 0;
  3990. while (object_index < (S32)objects_list.size() &&
  3991. objects_in_packet++ < MAX_ROOTS_PER_PACKET)
  3992. {
  3993. LLViewerObject* objectp = objects_list[object_index++];
  3994. msg->nextBlockFast(_PREHASH_ObjectData);
  3995. msg->addU32Fast(_PREHASH_ObjectLocalID, objectp->getLocalID());
  3996. // VEFFECT: DerezObject
  3997. LLHUDEffectSpiral::swirlAtPosition(objectp->getPositionGlobal());
  3998. }
  3999. msg->sendReliable(first_region->getHost());
  4000. }
  4001. make_ui_sound("UISndObjectRezOut");
  4002. // Busy count decremented by inventory update, so only increment
  4003. // if will be causing an update.
  4004. if (dest != DRD_RETURN_TO_OWNER)
  4005. {
  4006. gWindowp->incBusyCount();
  4007. }
  4008. }
  4009. else if (!error.empty())
  4010. {
  4011. gNotifications.add(error);
  4012. }
  4013. }
  4014. void force_take_copy(void*)
  4015. {
  4016. if (gSelectMgr.getSelection()->isEmpty()) return;
  4017. const LLUUID& category_id =
  4018. gInventory.findCategoryUUIDForType(LLFolderType::FT_OBJECT);
  4019. derez_objects(DRD_FORCE_TO_GOD_INVENTORY, category_id);
  4020. }
  4021. void handle_force_parcel_owner_to_me(void*)
  4022. {
  4023. gViewerParcelMgr.sendParcelGodForceOwner(gAgentID);
  4024. }
  4025. void handle_force_parcel_to_content(void*)
  4026. {
  4027. gViewerParcelMgr.sendParcelGodForceToContent();
  4028. }
  4029. void handle_claim_public_land(void*)
  4030. {
  4031. if (gViewerParcelMgr.getSelectionRegion() != gAgent.getRegion())
  4032. {
  4033. gNotifications.add("ClaimPublicLand");
  4034. return;
  4035. }
  4036. LLVector3d west_south_global;
  4037. LLVector3d east_north_global;
  4038. gViewerParcelMgr.getSelection(west_south_global, east_north_global);
  4039. LLVector3 west_south = gAgent.getPosAgentFromGlobal(west_south_global);
  4040. LLVector3 east_north = gAgent.getPosAgentFromGlobal(east_north_global);
  4041. LLMessageSystem* msg = gMessageSystemp;
  4042. msg->newMessage("GodlikeMessage");
  4043. msg->nextBlock("AgentData");
  4044. msg->addUUID("AgentID", gAgentID);
  4045. msg->addUUID("SessionID", gAgentSessionID);
  4046. msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
  4047. msg->nextBlock("MethodData");
  4048. msg->addString("Method", "claimpublicland");
  4049. msg->addUUID("Invoice", LLUUID::null);
  4050. std::string buffer;
  4051. buffer = llformat("%f", west_south.mV[VX]);
  4052. msg->nextBlock("ParamList");
  4053. msg->addString("Parameter", buffer);
  4054. buffer = llformat("%f", west_south.mV[VY]);
  4055. msg->nextBlock("ParamList");
  4056. msg->addString("Parameter", buffer);
  4057. buffer = llformat("%f", east_north.mV[VX]);
  4058. msg->nextBlock("ParamList");
  4059. msg->addString("Parameter", buffer);
  4060. buffer = llformat("%f", east_north.mV[VY]);
  4061. msg->nextBlock("ParamList");
  4062. msg->addString("Parameter", buffer);
  4063. gAgent.sendReliableMessage();
  4064. }
  4065. void handle_force_delete(void*)
  4066. {
  4067. gSelectMgr.selectForceDelete();
  4068. }
  4069. void init_server_menu(LLMenuGL* menu)
  4070. {
  4071. LLMenuGL* sub = new LLMenuGL("Object");
  4072. sub->append(new LLMenuItemCallGL("Take copy", force_take_copy,
  4073. enable_god_customer_service, NULL, 'O',
  4074. MASK_SHIFT | MASK_ALT | MASK_CONTROL));
  4075. sub->append(new LLMenuItemCallGL("Force owner to me",
  4076. handle_object_owner_self,
  4077. enable_god_customer_service));
  4078. sub->append(new LLMenuItemCallGL("Force owner permissive",
  4079. handle_object_owner_permissive,
  4080. enable_god_customer_service));
  4081. sub->append(new LLMenuItemCallGL("Delete", handle_force_delete,
  4082. enable_god_customer_service, NULL,
  4083. KEY_DELETE,
  4084. MASK_SHIFT | MASK_ALT | MASK_CONTROL));
  4085. sub->append(new LLMenuItemCallGL("Lock", handle_object_lock,
  4086. enable_god_customer_service, NULL, 'L',
  4087. MASK_SHIFT | MASK_ALT | MASK_CONTROL));
  4088. sub->append(new LLMenuItemCallGL("Get asset IDs", handle_object_asset_ids,
  4089. enable_god_customer_service, NULL, 'I',
  4090. MASK_SHIFT | MASK_ALT | MASK_CONTROL));
  4091. sub->createJumpKeys();
  4092. menu->appendMenu(sub);
  4093. sub = new LLMenuGL("Parcel");
  4094. sub->append(new LLMenuItemCallGL("Owner to me",
  4095. handle_force_parcel_owner_to_me,
  4096. enable_god_customer_service, NULL));
  4097. sub->append(new LLMenuItemCallGL("Set to Linden contents",
  4098. handle_force_parcel_to_content,
  4099. enable_god_customer_service, NULL, 'C',
  4100. MASK_SHIFT | MASK_ALT | MASK_CONTROL));
  4101. sub->appendSeparator();
  4102. sub->append(new LLMenuItemCallGL("Claim public land",
  4103. handle_claim_public_land,
  4104. enable_god_customer_service));
  4105. sub->createJumpKeys();
  4106. menu->appendMenu(sub);
  4107. sub = new LLMenuGL("Region");
  4108. sub->append(new LLMenuItemCallGL("Dump temp asset data",
  4109. handle_region_dump_temp_asset_data,
  4110. enable_god_customer_service, NULL));
  4111. sub->createJumpKeys();
  4112. menu->appendMenu(sub);
  4113. menu->append(new LLMenuItemCallGL("God tools...", handle_god_tools,
  4114. enable_god_basic, NULL));
  4115. menu->appendSeparator();
  4116. menu->append(new LLMenuItemCallGL("Save region state",
  4117. LLPanelRegionTools::onSaveState,
  4118. enable_god_customer_service, NULL));
  4119. menu->createJumpKeys();
  4120. }
  4121. bool can_toggle_snapshot_post_proc(void*)
  4122. {
  4123. return gUsePBRShaders;
  4124. }
  4125. bool no_post_proc_check_control(void*)
  4126. {
  4127. static LLCachedControl<bool> no_post(gSavedSettings,
  4128. "RenderSnapshotNoPost");
  4129. return gUsePBRShaders && no_post;
  4130. }
  4131. void init_client_menu(LLMenuGL* menu)
  4132. {
  4133. LLMenuGL* sub = new LLMenuGL("Consoles");
  4134. init_debug_console_menu(sub);
  4135. menu->appendMenu(sub);
  4136. sub = new LLMenuGL("HUD info");
  4137. init_hud_info_menu(sub);
  4138. menu->appendMenu(sub);
  4139. sub = new LLMenuGL("User interface");
  4140. init_debug_ui_menu(sub);
  4141. menu->appendMenu(sub);
  4142. sub = new LLMenuGL("Rendering");
  4143. init_debug_rendering_menu(sub);
  4144. menu->appendMenu(sub);
  4145. sub = new LLMenuGL("World");
  4146. init_debug_world_menu(sub);
  4147. menu->appendMenu(sub);
  4148. sub = new LLMenuGL("Character");
  4149. init_debug_character_menu(sub);
  4150. menu->appendMenu(sub);
  4151. //MK
  4152. if (gRLenabled)
  4153. {
  4154. sub = new LLMenuGL("RestrainedLove");
  4155. init_restrained_love_menu(sub);
  4156. menu->appendMenu(sub);
  4157. }
  4158. //mk
  4159. sub = new LLMenuGL("Lua scripting");
  4160. init_lua_scripting_menu(sub);
  4161. menu->appendMenu(sub);
  4162. sub = new LLMenuGL("Network");
  4163. init_network_menu(sub);
  4164. menu->appendMenu(sub);
  4165. sub = new LLMenuGL("Caches");
  4166. init_caches_menu(sub);
  4167. menu->appendMenu(sub);
  4168. sub = new LLMenuGL("Media");
  4169. init_media_menu(sub);
  4170. menu->appendMenu(sub);
  4171. menu->appendSeparator();
  4172. menu->append(new LLMenuItemCheckGL("High-res snapshot",
  4173. menu_toggle_control, NULL,
  4174. menu_check_control,
  4175. (void*)"HighResSnapshot"));
  4176. menu->append(new LLMenuItemCheckGL("No post-processing for snapshots",
  4177. menu_toggle_control,
  4178. can_toggle_snapshot_post_proc,
  4179. no_post_proc_check_control,
  4180. (void*)"RenderSnapshotNoPost"));
  4181. menu->append(new LLMenuItemCheckGL("Quiet snapshots to disk",
  4182. menu_toggle_control, NULL,
  4183. menu_check_control,
  4184. (void*)"QuietSnapshotsToDisk"));
  4185. menu->append(new LLMenuItemCallGL("Compress images to JPEG2000...",
  4186. handle_compress_image,
  4187. enable_picker_actions, NULL));
  4188. menu->append(new LLMenuItemCheckGL("Debug permissions",
  4189. menu_toggle_control, NULL,
  4190. menu_check_control,
  4191. (void*)"DebugPermissions"));
  4192. menu->appendSeparator();
  4193. #if LL_WINDOWS
  4194. menu->append(new LLMenuItemCheckGL("Console window (after restart)",
  4195. menu_toggle_control, NULL,
  4196. menu_check_control,
  4197. (void*)"ShowConsoleWindow"));
  4198. menu->appendSeparator();
  4199. #endif
  4200. menu->append(new LLMenuItemCallGL("Debug settings...",
  4201. handle_show_debug_settings, NULL, NULL,
  4202. 'S', MASK_ALT | MASK_CONTROL));
  4203. menu->append(new LLMenuItemCallGL("Save current settings to file...",
  4204. handle_save_settings_to_xml,
  4205. enable_picker_actions, NULL));
  4206. menu->append(new LLMenuItemCallGL("Save default settings to file...",
  4207. handle_save_settings_to_xml,
  4208. enable_picker_actions, (void*)1));
  4209. menu->append(new LLMenuItemCallGL("Save current account settings to...",
  4210. handle_save_settings_to_xml,
  4211. enable_picker_actions, (void*)2));
  4212. menu->append(new LLMenuItemCallGL("Save default account settings to...",
  4213. handle_save_settings_to_xml,
  4214. enable_picker_actions, (void*)3));
  4215. menu->appendSeparator();
  4216. menu->append(new LLMenuItemCheckGL("View admin options",
  4217. handle_admin_override_toggle, NULL,
  4218. check_admin_override, NULL,
  4219. 'V', MASK_CONTROL | MASK_ALT));
  4220. menu->append(new LLMenuItemCallGL("Request admin status",
  4221. handle_god_mode,
  4222. enable_god_options, NULL,
  4223. 'G', MASK_ALT | MASK_CONTROL));
  4224. menu->append(new LLMenuItemCallGL("Leave admin status",
  4225. handle_leave_god_mode,
  4226. enable_god_options, NULL, 'G',
  4227. MASK_ALT | MASK_SHIFT | MASK_CONTROL));
  4228. #if LL_ENABLE_CRASH_TEST
  4229. menu->appendSeparator();
  4230. menu->append(new LLMenuItemCallGL("Test llerrs crash",
  4231. handle_llerrs_test));
  4232. #endif
  4233. menu->createJumpKeys();
  4234. }
  4235. static std::vector<LLPointer<view_listener_t> > sMenus;
  4236. void cleanup_menus()
  4237. {
  4238. delete sMenuParcelObserverp;
  4239. sMenuParcelObserverp = NULL;
  4240. delete gMenuHolderp;
  4241. gMenuHolderp = NULL;
  4242. LLMenuGL::sMenuContainer = NULL;
  4243. // NULLifiy menu and menu children pointers (all got deleted automatically
  4244. // as children of gMenuHolderp).
  4245. gPieSelfp = NULL;
  4246. gPieAvatarp = NULL;
  4247. gPieObjectp = NULL;
  4248. gPieAttachmentp = NULL;
  4249. gPieLandp = NULL;
  4250. gPieParticlep = NULL;
  4251. gLoginMenuBarViewp = NULL;
  4252. gMenuBarViewp = NULL;
  4253. gDetachScreenPieMenup = NULL;
  4254. gDetachPieMenup = NULL;
  4255. gAttachScreenPieMenup = NULL;
  4256. gAttachPieMenup = NULL;
  4257. gMutesPieMenup = NULL;
  4258. gPieObjectMutep = NULL;
  4259. sMenus.clear();
  4260. }
  4261. //-----------------------------------------------------------------------------
  4262. // Object pie menu
  4263. //-----------------------------------------------------------------------------
  4264. class LLObjectReportAbuse final : public view_listener_t
  4265. {
  4266. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4267. {
  4268. LLViewerObject* objectp = gSelectMgr.getSelection()->getPrimaryObject();
  4269. if (objectp)
  4270. {
  4271. LLFloaterReporter::showFromObject(objectp->getID());
  4272. }
  4273. return true;
  4274. }
  4275. };
  4276. // Enabled it you clicked an object
  4277. class LLObjectEnableReportAbuse final : public view_listener_t
  4278. {
  4279. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4280. {
  4281. bool new_value = gSelectMgr.getSelection()->getObjectCount() != 0;
  4282. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  4283. return true;
  4284. }
  4285. };
  4286. class LLObjectTouch final : public view_listener_t
  4287. {
  4288. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4289. {
  4290. LLViewerObject* object = gSelectMgr.getSelection()->getPrimaryObject();
  4291. if (!object) return true;
  4292. LLPickInfo pick = gToolPie.getPick();
  4293. //MK
  4294. if (gRLenabled && !gRLInterface.canTouch(object, pick.mIntersection))
  4295. {
  4296. return true;
  4297. }
  4298. //mk
  4299. LLMessageSystem* msg = gMessageSystemp;
  4300. msg->newMessageFast(_PREHASH_ObjectGrab);
  4301. msg->nextBlockFast(_PREHASH_AgentData);
  4302. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  4303. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  4304. msg->nextBlockFast(_PREHASH_ObjectData);
  4305. msg->addU32Fast(_PREHASH_LocalID, object->mLocalID);
  4306. msg->addVector3Fast(_PREHASH_GrabOffset, LLVector3::zero);
  4307. msg->nextBlock("SurfaceInfo");
  4308. msg->addVector3("UVCoord", LLVector3(pick.mUVCoords));
  4309. msg->addVector3("STCoord", LLVector3(pick.mSTCoords));
  4310. msg->addS32Fast(_PREHASH_FaceIndex, pick.mObjectFace);
  4311. msg->addVector3("Position", pick.mIntersection);
  4312. msg->addVector3("Normal", pick.mNormal);
  4313. msg->addVector3("Binormal", pick.mBinormal);
  4314. msg->sendMessage(object->getRegion()->getHost());
  4315. // *NOTE: Hope the packets arrive safely and in order or else
  4316. // there will be some problems.
  4317. // *TODO: Just fix this bad assumption.
  4318. msg->newMessageFast(_PREHASH_ObjectDeGrab);
  4319. msg->nextBlockFast(_PREHASH_AgentData);
  4320. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  4321. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  4322. msg->nextBlockFast(_PREHASH_ObjectData);
  4323. msg->addU32Fast(_PREHASH_LocalID, object->mLocalID);
  4324. msg->nextBlock("SurfaceInfo");
  4325. msg->addVector3("UVCoord", LLVector3(pick.mUVCoords));
  4326. msg->addVector3("STCoord", LLVector3(pick.mSTCoords));
  4327. msg->addS32Fast(_PREHASH_FaceIndex, pick.mObjectFace);
  4328. msg->addVector3("Position", pick.mIntersection);
  4329. msg->addVector3("Normal", pick.mNormal);
  4330. msg->addVector3("Binormal", pick.mBinormal);
  4331. msg->sendMessage(object->getRegion()->getHost());
  4332. return true;
  4333. }
  4334. };
  4335. // One object must have touch sensor
  4336. class LLObjectEnableTouch final : public view_listener_t
  4337. {
  4338. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4339. {
  4340. // Do not run this before the menu are fully initialized because the
  4341. // static LLView pointer to attachment_touch cannot be properly
  4342. // initialized while the pie menus are built which happens before the
  4343. // main menu items are defined.
  4344. if (!gMenusInitialized) return true;
  4345. bool new_value = false;
  4346. LLViewerObject* obj = gSelectMgr.getSelection()->getPrimaryObject();
  4347. if (obj)
  4348. {
  4349. new_value |= obj->flagHandleTouch() || !obj->flagsLoaded();
  4350. LLViewerObject* parent = (LLViewerObject*)obj->getParent();
  4351. if (parent)
  4352. {
  4353. new_value |= parent->flagHandleTouch() ||
  4354. !parent->flagsLoaded();
  4355. }
  4356. }
  4357. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  4358. // Update label based on the node touch name if available.
  4359. LLSelectNode* node = gSelectMgr.getSelection()->getFirstRootNode();
  4360. LLSD label;
  4361. if (node && node->mValid && !node->mTouchName.empty())
  4362. {
  4363. label = LLSD(node->mTouchName);
  4364. }
  4365. else
  4366. {
  4367. label = userdata["data"];
  4368. }
  4369. // Using static pointers prevents thousands of recursive calls to
  4370. // getChild<T>() each time a menu is pulled down !
  4371. static LLView* object_touch =
  4372. gMenuHolderp->getChild<LLView>("Object Touch");
  4373. object_touch->setValue(label);
  4374. static LLView* attachment_touch =
  4375. gMenuHolderp->getChild<LLView>("Attachment Object Touch");
  4376. attachment_touch->setValue(label);
  4377. return true;
  4378. }
  4379. };
  4380. bool handle_object_open()
  4381. {
  4382. LLViewerObject* objp = gSelectMgr.getSelection()->getPrimaryObject();
  4383. if (!objp) return true;
  4384. //MK
  4385. if (gRLenabled)
  4386. {
  4387. if (!gRLInterface.canEdit(objp))
  4388. {
  4389. return true;
  4390. }
  4391. if (!gRLInterface.canTouchFar(objp, gToolPie.getPick().mIntersection))
  4392. {
  4393. return true;
  4394. }
  4395. }
  4396. //mk
  4397. LLFloaterOpenObject::show();
  4398. return true;
  4399. }
  4400. class LLObjectOpen final : public view_listener_t
  4401. {
  4402. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4403. {
  4404. return handle_object_open();
  4405. }
  4406. };
  4407. class LLObjectEnableOpen final : public view_listener_t
  4408. {
  4409. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4410. {
  4411. // Look for contents in root object, which is all the
  4412. // LLFloaterOpenObject understands.
  4413. LLViewerObject* objp = gSelectMgr.getSelection()->getPrimaryObject();
  4414. bool new_value = objp != NULL;
  4415. if (new_value)
  4416. {
  4417. LLViewerObject* rootp = objp->getRootEdit();
  4418. if (!rootp)
  4419. {
  4420. new_value = false;
  4421. }
  4422. else
  4423. {
  4424. new_value = rootp->allowOpen();
  4425. }
  4426. //MK
  4427. if (new_value && gRLenabled)
  4428. {
  4429. if (!gRLInterface.canEdit(objp))
  4430. {
  4431. new_value = false;
  4432. }
  4433. else
  4434. {
  4435. new_value =
  4436. gRLInterface.canTouchFar(objp,
  4437. gToolPie.getPick().mIntersection);
  4438. }
  4439. }
  4440. //mk
  4441. }
  4442. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  4443. return true;
  4444. }
  4445. };
  4446. static LLUUID sHandleObjectId;
  4447. void load_gltf_scene_callback(HBFileSelector::ELoadFilter,
  4448. std::string& filename, void*)
  4449. {
  4450. std::string error;
  4451. if (gUsePBRShaders)
  4452. {
  4453. error = LLGLTFSceneManager::load(filename, sHandleObjectId);
  4454. }
  4455. // Note: an empty filename will just cause any existing GLTF scene
  4456. // associated with this object/handle to be removed: not a problem,
  4457. // even if the user switched PBR rendering off in the interval. HB
  4458. else if (!filename.empty())
  4459. {
  4460. error = "Not in PBR rendering mode.";
  4461. }
  4462. if (!error.empty())
  4463. {
  4464. LLSD args;
  4465. args["FILENAME"] = filename;
  4466. args["REASON"] = error;
  4467. gNotifications.add("GLTFPreviewLoadFailed", args);
  4468. }
  4469. }
  4470. void load_gltf_scene()
  4471. {
  4472. if (!gUsePBRShaders || HBFileSelector::isInUse() ||
  4473. !gSelectMgr.getSelection()->getFirstRootObject())
  4474. {
  4475. return;
  4476. }
  4477. LLViewerObject* objectp = gSelectMgr.getSelection()->getFirstRootObject();
  4478. if (!objectp || objectp->isDead() || objectp->isAttachment())
  4479. {
  4480. gNotifications.add("GLTFPreviewSelection");
  4481. return;
  4482. }
  4483. sHandleObjectId = objectp->getID();
  4484. HBFileSelector::loadFile(HBFileSelector::FFLOAD_GLTF,
  4485. load_gltf_scene_callback);
  4486. }
  4487. class LLObjectLoadGltfScene final : public view_listener_t
  4488. {
  4489. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4490. {
  4491. load_gltf_scene();
  4492. return true;
  4493. }
  4494. };
  4495. class LLObjectCanLoadGltfScene final : public view_listener_t
  4496. {
  4497. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4498. {
  4499. bool new_value = gUsePBRShaders && !HBFileSelector::isInUse();
  4500. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  4501. return true;
  4502. }
  4503. };
  4504. class LLViewCheckCameraFrontView final : public view_listener_t
  4505. {
  4506. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4507. {
  4508. ECameraMode mode = gAgent.getCameraMode();
  4509. bool new_value = mode != CAMERA_MODE_MOUSELOOK &&
  4510. mode != CAMERA_MODE_CUSTOMIZE_AVATAR;
  4511. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  4512. return true;
  4513. }
  4514. };
  4515. class LLToolsCheckBuildMode final : public view_listener_t
  4516. {
  4517. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4518. {
  4519. bool new_value = gToolMgr.inEdit();
  4520. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  4521. return true;
  4522. }
  4523. };
  4524. class LLToolsBuildMode final : public view_listener_t
  4525. {
  4526. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4527. {
  4528. gToolMgr.toggleBuildMode();
  4529. return true;
  4530. }
  4531. };
  4532. //MK
  4533. void handle_toggle_flycam()
  4534. {
  4535. LLViewerJoystick* joystick = LLViewerJoystick::getInstance();
  4536. joystick->toggleFlycam();
  4537. // Do not allow it if our camera distance is restricted
  4538. if (gRLenabled && gRLInterface.mCamDistMax < EXTREMUM * 0.75f &&
  4539. joystick->getOverrideCamera())
  4540. {
  4541. joystick->toggleFlycam();
  4542. }
  4543. }
  4544. //mk
  4545. class LLViewJoystickFlycam final : public view_listener_t
  4546. {
  4547. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4548. {
  4549. handle_toggle_flycam();
  4550. return true;
  4551. }
  4552. };
  4553. class LLViewCheckJoystickFlycam final : public view_listener_t
  4554. {
  4555. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4556. {
  4557. bool new_val = LLViewerJoystick::getInstance()->getOverrideCamera();
  4558. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_val);
  4559. return true;
  4560. }
  4561. };
  4562. bool handle_object_edit()
  4563. {
  4564. //MK
  4565. if (gRLenabled)
  4566. {
  4567. if (gRLInterface.mContainsRez)
  4568. {
  4569. return false;
  4570. }
  4571. if (gRLInterface.mContainsEdit)
  4572. {
  4573. LLViewerObject* objp = gSelectMgr.getSelection()->getFirstObject();
  4574. if (!gRLInterface.canEdit(objp))
  4575. {
  4576. return false;
  4577. }
  4578. }
  4579. }
  4580. //mk
  4581. gToolMgr.setCurrentToolset(gBasicToolset);
  4582. gBasicToolset->selectTool(&gToolCompTranslate);
  4583. // Could be first use
  4584. LLFirstUse::useBuild();
  4585. return true;
  4586. }
  4587. class LLObjectBuild final : public view_listener_t
  4588. {
  4589. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4590. {
  4591. //MK
  4592. if (gRLenabled)
  4593. {
  4594. if (gRLInterface.mContainsRez)
  4595. {
  4596. return false;
  4597. }
  4598. if (gRLInterface.mContainsEdit)
  4599. {
  4600. LLViewerObject* objp =
  4601. gSelectMgr.getSelection()->getFirstObject();
  4602. if (!gRLInterface.canEdit(objp))
  4603. {
  4604. return false;
  4605. }
  4606. }
  4607. }
  4608. //mk
  4609. if (gAgent.getFocusOnAvatar() && !gToolMgr.inEdit() &&
  4610. gSavedSettings.getBool("EditCameraMovement"))
  4611. {
  4612. // Zoom in if we are looking at the avatar
  4613. gAgent.setFocusOnAvatar(false);
  4614. gAgent.setFocusGlobal(gToolPie.getPick());
  4615. gAgent.cameraZoomIn(0.666f);
  4616. gAgent.cameraOrbitOver(30.f * DEG_TO_RAD);
  4617. gViewerWindowp->moveCursorToCenter();
  4618. }
  4619. else if (gSavedSettings.getBool("EditCameraMovement"))
  4620. {
  4621. gAgent.setFocusGlobal(gToolPie.getPick());
  4622. gViewerWindowp->moveCursorToCenter();
  4623. }
  4624. gToolMgr.setCurrentToolset(gBasicToolset);
  4625. gBasicToolset->selectTool(&gToolCompCreate);
  4626. LLViewerJoystick* joystick = LLViewerJoystick::getInstance();
  4627. joystick->moveObjects(true);
  4628. joystick->setNeedsReset(true);
  4629. // Could be first use
  4630. LLFirstUse::useBuild();
  4631. return true;
  4632. }
  4633. };
  4634. class LLObjectEdit final : public view_listener_t
  4635. {
  4636. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4637. {
  4638. if (!gFloaterToolsp) return false;
  4639. //MK
  4640. if (gRLenabled)
  4641. {
  4642. if (gRLInterface.mContainsRez)
  4643. {
  4644. return false;
  4645. }
  4646. LLViewerObject* objp = gSelectMgr.getSelection()->getFirstObject();
  4647. if (!gRLInterface.canEdit(objp))
  4648. {
  4649. return false;
  4650. }
  4651. if (!gRLInterface.canTouchFar(objp,
  4652. gToolPie.getPick().mIntersection))
  4653. {
  4654. return false;
  4655. }
  4656. }
  4657. //mk
  4658. gViewerParcelMgr.deselectLand();
  4659. if (gAgent.getFocusOnAvatar() && !gToolMgr.inEdit())
  4660. {
  4661. LLObjectSelectionHandle selection = gSelectMgr.getSelection();
  4662. if (selection->getSelectType() == SELECT_TYPE_HUD ||
  4663. !gSavedSettings.getBool("EditCameraMovement"))
  4664. {
  4665. // Always freeze camera in space, even if camera does not move
  4666. // so, for example, follow-cam scripts cannot affect you when
  4667. // in build mode
  4668. gAgent.setFocusGlobal(gAgent.calcFocusPositionTargetGlobal(),
  4669. LLUUID::null);
  4670. gAgent.setFocusOnAvatar(false);
  4671. }
  4672. else
  4673. {
  4674. gAgent.setFocusOnAvatar(false);
  4675. LLViewerObject* selected_objectp = selection->getFirstRootObject();
  4676. if (selected_objectp)
  4677. {
  4678. // zoom in on object center instead of where we clicked, as
  4679. // we need to see the manipulator handles
  4680. gAgent.setFocusGlobal(selected_objectp->getPositionGlobal(),
  4681. selected_objectp->getID());
  4682. gAgent.cameraZoomIn(0.666f);
  4683. gAgent.cameraOrbitOver(30.f * DEG_TO_RAD);
  4684. gViewerWindowp->moveCursorToCenter();
  4685. }
  4686. }
  4687. }
  4688. gFloaterToolsp->open();
  4689. gToolMgr.setCurrentToolset(gBasicToolset);
  4690. gFloaterToolsp->setEditTool(&gToolCompTranslate);
  4691. LLViewerJoystick* joystick = LLViewerJoystick::getInstance();
  4692. joystick->moveObjects(true);
  4693. joystick->setNeedsReset(true);
  4694. // Could be first use
  4695. LLFirstUse::useBuild();
  4696. return true;
  4697. }
  4698. };
  4699. bool handle_object_inspect()
  4700. {
  4701. //MK
  4702. if (gRLenabled)
  4703. {
  4704. if (gRLInterface.mContainsShownames ||
  4705. gRLInterface.mContainsShownametags)
  4706. {
  4707. return false;
  4708. }
  4709. LLViewerObject* objp = gSelectMgr.getSelection()->getPrimaryObject();
  4710. if (!gRLInterface.canTouchFar(objp))
  4711. {
  4712. return false;
  4713. }
  4714. }
  4715. //mk
  4716. LLViewerObject* vobj = gSelectMgr.getSelection()->getFirstRootObject(true);
  4717. if (vobj)
  4718. {
  4719. LLVOAvatar* avatar = vobj->asAvatar();
  4720. if (avatar && !avatar->mIsDummy)
  4721. {
  4722. HBFloaterInspectAvatar::show(avatar->getID());
  4723. return true;
  4724. }
  4725. }
  4726. LLFloaterInspect::show();
  4727. return true;
  4728. }
  4729. class LLObjectInspect final : public view_listener_t
  4730. {
  4731. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4732. {
  4733. return handle_object_inspect();
  4734. }
  4735. };
  4736. class LLSelfInspect final : public view_listener_t
  4737. {
  4738. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4739. {
  4740. HBFloaterInspectAvatar::show(gAgentID);
  4741. return true;
  4742. }
  4743. };
  4744. class LLObjectToggleMaxLOD final : public view_listener_t
  4745. {
  4746. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4747. {
  4748. LLViewerObject* vobj =
  4749. gSelectMgr.getSelection()->getFirstRootObject(true);
  4750. if (vobj)
  4751. {
  4752. vobj->recursiveSetMaxLOD(!vobj->isLockedAtMaxLOD());
  4753. }
  4754. return true;
  4755. }
  4756. };
  4757. class LLObjectEnableMaxLOD final : public view_listener_t
  4758. {
  4759. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4760. {
  4761. LLViewerObject* vobj = gSelectMgr.getSelection()->getPrimaryObject();
  4762. bool new_value = vobj && !vobj->isLockedAtMaxLOD();
  4763. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  4764. return true;
  4765. }
  4766. };
  4767. class LLObjectEnableNormalLOD final : public view_listener_t
  4768. {
  4769. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4770. {
  4771. LLViewerObject* vobj = gSelectMgr.getSelection()->getPrimaryObject();
  4772. bool new_value = vobj && vobj->isLockedAtMaxLOD();
  4773. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  4774. return true;
  4775. }
  4776. };
  4777. bool derender_object(const LLUUID& object_id)
  4778. {
  4779. if (object_id.isNull()) return false;
  4780. LLViewerObject* vobj = gObjectList.findObject(object_id);
  4781. //MK
  4782. LLViewerObject* root = vobj ? vobj->getRootEdit() : NULL;
  4783. //mk
  4784. // Do not derender ourselves neither our attachments
  4785. if (find_avatar_from_object(vobj) == gAgentAvatarp ||
  4786. //MK
  4787. // Do not derender seats when prevented to unsit
  4788. (gRLenabled && gRLInterface.mContainsUnsit &&
  4789. ((vobj && vobj->isAgentSeat()) || (root && root->isAgentSeat()))))
  4790. //mk
  4791. {
  4792. return false;
  4793. }
  4794. // Remove object from selection, if part of it.
  4795. gSelectMgr.removeObjectFromSelections(object_id);
  4796. // Insert the object into the black list.
  4797. gObjectList.mBlackListedObjects.emplace(object_id);
  4798. // Update the derendered status in the radar.
  4799. if (!vobj || vobj->asAvatar())
  4800. {
  4801. HBFloaterRadar::setRenderStatusDirty(object_id);
  4802. }
  4803. if (vobj)
  4804. {
  4805. // Derender by killing the object.
  4806. gObjectList.killObject(vobj);
  4807. }
  4808. return true;
  4809. }
  4810. class LLObjectDerender final : public view_listener_t
  4811. {
  4812. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4813. {
  4814. struct LLGetSelectedObjectsId final : public LLSelectedObjectFunctor
  4815. {
  4816. LLGetSelectedObjectsId(uuid_vec_t& ids)
  4817. : mIDs(ids)
  4818. {
  4819. }
  4820. bool apply(LLViewerObject* objectp) override
  4821. {
  4822. if (objectp)
  4823. {
  4824. mIDs.emplace_back(objectp->getID());
  4825. }
  4826. return true;
  4827. }
  4828. uuid_vec_t& mIDs;
  4829. };
  4830. // Note: we cannot derender from inside the functor: this would
  4831. // invalidate objects in the iterated selection and cause a crash. HB
  4832. uuid_vec_t ids;
  4833. LLGetSelectedObjectsId func(ids);
  4834. gSelectMgr.getSelection()->applyToObjects(&func);
  4835. for (U32 i = 0, count = ids.size(); i < count; ++i)
  4836. {
  4837. derender_object(ids[i]);
  4838. }
  4839. return true;
  4840. }
  4841. };
  4842. class LLObjectEnableDerender final : public view_listener_t
  4843. {
  4844. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4845. {
  4846. bool enable = true;
  4847. //MK
  4848. if (gRLenabled && gRLInterface.mContainsUnsit &&
  4849. gRLInterface.isSittingOnAnySelectedObject())
  4850. {
  4851. // Do not allow to derender an object we are sitting on when
  4852. // RestrainedLove is enabled and we are forbidden to unsit.
  4853. enable = false;
  4854. }
  4855. else
  4856. //mk
  4857. {
  4858. struct f final : public LLSelectedObjectFunctor
  4859. {
  4860. bool apply(LLViewerObject* objectp) override
  4861. {
  4862. // Do not allow to derender our own attachments
  4863. return objectp &&
  4864. find_avatar_from_object(objectp) != gAgentAvatarp;
  4865. }
  4866. } func;
  4867. enable = gSelectMgr.getSelection()->applyToObjects(&func);
  4868. }
  4869. gMenuHolderp->findControl(userdata["control"].asString())->setValue(enable);
  4870. return true;
  4871. }
  4872. };
  4873. bool handle_go_to()
  4874. {
  4875. //MK
  4876. if (gRLenabled && gAgent.forwardGrabbed())
  4877. {
  4878. // When llTakeControls() has been performed on CONTROL_FWD, do not
  4879. // allow the go to action to prevent overriding any speed limitation or
  4880. // movement restriction.
  4881. return true;
  4882. }
  4883. //mk
  4884. // JAMESDEBUG try simulator autopilot
  4885. std::vector<std::string> strings;
  4886. std::string val;
  4887. LLVector3d pos = gToolPie.getPick().mPosGlobal;
  4888. val = llformat("%g", pos.mdV[VX]);
  4889. strings.emplace_back(val);
  4890. val = llformat("%g", pos.mdV[VY]);
  4891. strings.emplace_back(val);
  4892. val = llformat("%g", pos.mdV[VZ]);
  4893. strings.emplace_back(val);
  4894. send_generic_message("autopilot", strings);
  4895. gViewerParcelMgr.deselectLand();
  4896. if (isAgentAvatarValid() &&
  4897. !gSavedSettings.getBool("AutoPilotLocksCamera"))
  4898. {
  4899. gAgent.setFocusGlobal(gAgent.getFocusTargetGlobal(),
  4900. gAgentAvatarp->getID());
  4901. }
  4902. else
  4903. {
  4904. // Snap camera back to behind avatar
  4905. gAgent.setFocusOnAvatar();
  4906. }
  4907. return true;
  4908. }
  4909. class LLGoToObject final : public view_listener_t
  4910. {
  4911. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4912. {
  4913. return handle_go_to();
  4914. }
  4915. };
  4916. //---------------------------------------------------------------------------
  4917. // Land pie menu
  4918. //---------------------------------------------------------------------------
  4919. class LLLandBuild final : public view_listener_t
  4920. {
  4921. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4922. {
  4923. //MK
  4924. if (gRLenabled && gRLInterface.mContainsEdit)
  4925. {
  4926. return false;
  4927. }
  4928. //mk
  4929. gViewerParcelMgr.deselectLand();
  4930. if (gAgent.getFocusOnAvatar() && !gToolMgr.inEdit() &&
  4931. gSavedSettings.getBool("EditCameraMovement"))
  4932. {
  4933. // zoom in if we're looking at the avatar
  4934. gAgent.setFocusOnAvatar(false);
  4935. gAgent.setFocusGlobal(gToolPie.getPick());
  4936. gAgent.cameraZoomIn(0.666f);
  4937. gAgent.cameraOrbitOver(30.f * DEG_TO_RAD);
  4938. gViewerWindowp->moveCursorToCenter();
  4939. }
  4940. else if (gSavedSettings.getBool("EditCameraMovement"))
  4941. {
  4942. // otherwise just move focus
  4943. gAgent.setFocusGlobal(gToolPie.getPick());
  4944. gViewerWindowp->moveCursorToCenter();
  4945. }
  4946. gToolMgr.setCurrentToolset(gBasicToolset);
  4947. gBasicToolset->selectTool(&gToolCompCreate);
  4948. // Could be first use
  4949. LLFirstUse::useBuild();
  4950. return true;
  4951. }
  4952. };
  4953. class LLLandBuyPass final : public view_listener_t
  4954. {
  4955. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4956. {
  4957. LLPanelLandGeneral::onClickBuyPass((void*)false);
  4958. return true;
  4959. }
  4960. };
  4961. class LLLandEnableBuyPass final : public view_listener_t
  4962. {
  4963. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4964. {
  4965. bool new_value = LLPanelLandGeneral::enableBuyPass(NULL);
  4966. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  4967. return true;
  4968. }
  4969. };
  4970. class LLEnableEdit final : public view_listener_t
  4971. {
  4972. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4973. {
  4974. bool enable = false;
  4975. LLViewerObject* objp = gSelectMgr.getSelection()->getPrimaryObject();
  4976. if (objp)
  4977. {
  4978. enable = true;
  4979. //MK
  4980. if (gRLenabled && !gRLInterface.canEdit(objp))
  4981. {
  4982. enable = false;
  4983. }
  4984. //mk
  4985. }
  4986. else
  4987. {
  4988. // *HACK: See LLViewerParcelMgr::allowAgentBuild() for the "false"
  4989. // flag.
  4990. enable = gViewerParcelMgr.allowAgentBuild(false);
  4991. }
  4992. gMenuHolderp->findControl(userdata["control"].asString())->setValue(enable);
  4993. return true;
  4994. }
  4995. };
  4996. class LLSelfRemoveAllAttachments final : public view_listener_t
  4997. {
  4998. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  4999. {
  5000. //MK
  5001. if (gRLenabled && gRLInterface.mContainsDetach)
  5002. {
  5003. return false;
  5004. }
  5005. //mk
  5006. LLAgentWearables::userRemoveAllAttachments();
  5007. return true;
  5008. }
  5009. };
  5010. class LLSelfEnableRemoveAllAttachments final : public view_listener_t
  5011. {
  5012. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5013. {
  5014. //MK
  5015. if (gRLenabled && gRLInterface.mContainsDetach)
  5016. {
  5017. return false;
  5018. }
  5019. //mk
  5020. bool new_value = isAgentAvatarValid() &&
  5021. gAgentAvatarp->mAttachedObjectsVector.size() > 0;
  5022. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  5023. return true;
  5024. }
  5025. };
  5026. class LLRemoveAllTempAttachments final : public view_listener_t
  5027. {
  5028. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5029. {
  5030. //MK
  5031. if (gRLenabled && gRLInterface.mContainsDetach)
  5032. {
  5033. return false;
  5034. }
  5035. //mk
  5036. LLAgentWearables::userRemoveAllAttachments(true);
  5037. return true;
  5038. }
  5039. };
  5040. class LLEnableRemoveAllTempAttachments final : public view_listener_t
  5041. {
  5042. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5043. {
  5044. //MK
  5045. if (gRLenabled && gRLInterface.mContainsDetach)
  5046. {
  5047. return false;
  5048. }
  5049. //mk
  5050. bool new_value = false;
  5051. if (isAgentAvatarValid())
  5052. {
  5053. for (S32 i = 0,
  5054. count = gAgentAvatarp->mAttachedObjectsVector.size();
  5055. i < count; ++i)
  5056. {
  5057. LLViewerObject* object =
  5058. gAgentAvatarp->mAttachedObjectsVector[i].first;
  5059. if (object && object->isTempAttachment())
  5060. {
  5061. new_value = true;
  5062. break;
  5063. }
  5064. }
  5065. }
  5066. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  5067. return true;
  5068. }
  5069. };
  5070. //---------------------------------------------------------------------------
  5071. // Avatar pie menu
  5072. //---------------------------------------------------------------------------
  5073. class LLObjectEnableMute final : public view_listener_t
  5074. {
  5075. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5076. {
  5077. //MK
  5078. if (gRLenabled &&
  5079. (gRLInterface.mContainsShownames ||
  5080. gRLInterface.mContainsShownametags))
  5081. {
  5082. return false;
  5083. }
  5084. //mk
  5085. LLViewerObject* object = gSelectMgr.getSelection()->getPrimaryObject();
  5086. // Do not mute our own objects
  5087. bool new_value = object && !object->permYouOwner();
  5088. if (new_value)
  5089. {
  5090. LLVOAvatar* avatar = find_avatar_from_object(object);
  5091. if (avatar)
  5092. {
  5093. // It is an avatar
  5094. LLNameValue* lastname = avatar->getNVPair("LastName");
  5095. bool is_linden = lastname &&
  5096. !LLStringUtil::compareStrings(lastname->getString(),
  5097. "Linden");
  5098. bool is_self = avatar->isSelf();
  5099. new_value = !is_linden && !is_self;
  5100. }
  5101. }
  5102. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  5103. return true;
  5104. }
  5105. };
  5106. class LLObjectMute final : public view_listener_t
  5107. {
  5108. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5109. {
  5110. LLViewerObject* object = gSelectMgr.getSelection()->getPrimaryObject();
  5111. if (!object) return true;
  5112. std::string data = userdata.asString();
  5113. LLUUID id;
  5114. std::string name;
  5115. LLMute::EType type;
  5116. U32 flags = 0;
  5117. LLVOAvatar* avatar = find_avatar_from_object(object);
  5118. if (avatar)
  5119. {
  5120. //MK
  5121. if (gRLenabled &&
  5122. (gRLInterface.mContainsShownames ||
  5123. gRLInterface.mContainsShownametags))
  5124. {
  5125. return false;
  5126. }
  5127. //mk
  5128. if (data == "chat")
  5129. {
  5130. flags = LLMute::flagTextChat;
  5131. }
  5132. else if (data == "voice")
  5133. {
  5134. flags = LLMute::flagVoiceChat;
  5135. }
  5136. else if (data == "sounds")
  5137. {
  5138. flags = LLMute::flagObjectSounds;
  5139. }
  5140. else if (data == "particles")
  5141. {
  5142. flags = LLMute::flagParticles;
  5143. }
  5144. id = avatar->getID();
  5145. LLNameValue* firstname = avatar->getNVPair("FirstName");
  5146. LLNameValue* lastname = avatar->getNVPair("LastName");
  5147. if (firstname && lastname)
  5148. {
  5149. name = firstname->getString();
  5150. name += " ";
  5151. name += lastname->getString();
  5152. }
  5153. type = LLMute::AGENT;
  5154. }
  5155. else // It is an object
  5156. {
  5157. if (data == "by_name")
  5158. {
  5159. type = LLMute::BY_NAME;
  5160. }
  5161. else
  5162. {
  5163. type = LLMute::OBJECT;
  5164. id = object->getID();
  5165. }
  5166. LLSelectNode* node = gSelectMgr.getSelection()->getFirstRootNode();
  5167. if (node)
  5168. {
  5169. name = node->mName;
  5170. }
  5171. }
  5172. LLMute mute(id, name, type);
  5173. if (LLMuteList::isMuted(mute.mID, mute.mName, flags))
  5174. {
  5175. LLMuteList::remove(mute, flags);
  5176. }
  5177. else if (LLMuteList::add(mute, flags))
  5178. {
  5179. LLFloaterMute::selectMute(mute.mID);
  5180. }
  5181. return true;
  5182. }
  5183. };
  5184. class LLAvatarToggleMaxLOD final : public view_listener_t
  5185. {
  5186. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5187. {
  5188. LLViewerObject* vobj = gSelectMgr.getSelection()->getPrimaryObject();
  5189. if (!vobj) return true;
  5190. LLVOAvatar* avatarp = find_avatar_from_object(vobj);
  5191. if (!avatarp) return true;
  5192. bool lock = false;
  5193. for (S32 i = 0, count = avatarp->mAttachedObjectsVector.size();
  5194. i < count; ++i)
  5195. {
  5196. vobj = avatarp->mAttachedObjectsVector[i].first;
  5197. if (!vobj) continue; // Paranoia
  5198. if (i == 0)
  5199. {
  5200. lock = !vobj->isLockedAtMaxLOD();
  5201. }
  5202. vobj->recursiveSetMaxLOD(lock);
  5203. }
  5204. return true;
  5205. }
  5206. };
  5207. class LLAvatarEnableMaxLOD final : public view_listener_t
  5208. {
  5209. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5210. {
  5211. bool new_value = false;
  5212. LLViewerObject* vobj = gSelectMgr.getSelection()->getPrimaryObject();
  5213. if (vobj)
  5214. {
  5215. LLVOAvatar* avatarp = find_avatar_from_object(vobj);
  5216. if (avatarp && avatarp->mAttachedObjectsVector.size())
  5217. {
  5218. vobj = avatarp->mAttachedObjectsVector[0].first;
  5219. new_value = !vobj->isLockedAtMaxLOD();
  5220. }
  5221. }
  5222. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  5223. return true;
  5224. }
  5225. };
  5226. class LLAvatarEnableNormalLOD final : public view_listener_t
  5227. {
  5228. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5229. {
  5230. bool new_value = false;
  5231. LLViewerObject* vobj = gSelectMgr.getSelection()->getPrimaryObject();
  5232. if (vobj)
  5233. {
  5234. LLVOAvatar* avatarp = find_avatar_from_object(vobj);
  5235. if (avatarp && avatarp->mAttachedObjectsVector.size())
  5236. {
  5237. vobj = avatarp->mAttachedObjectsVector[0].first;
  5238. new_value = vobj->isLockedAtMaxLOD();
  5239. }
  5240. }
  5241. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  5242. return true;
  5243. }
  5244. };
  5245. //---------------------------------------------------------------------------
  5246. // Particles pie menu
  5247. //---------------------------------------------------------------------------
  5248. class LLParticleEnableEntry final : public view_listener_t
  5249. {
  5250. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5251. {
  5252. std::string data = userdata.asString();
  5253. const LLPickInfo& pick = gToolPie.getPick();
  5254. bool new_value = pick.mParticleOwnerID.notNull() &&
  5255. pick.mParticleOwnerID != gAgentID &&
  5256. (data == "owner" || pick.mParticleSourceID.notNull());
  5257. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  5258. return true;
  5259. }
  5260. };
  5261. class LLMuteParticle final : public view_listener_t
  5262. {
  5263. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5264. {
  5265. std::string data = userdata.asString();
  5266. LLUUID id = gToolPie.getPick().mParticleOwnerID;
  5267. if (!data.empty() && id.notNull() && id != gAgentID)
  5268. {
  5269. std::string name;
  5270. if (gCacheNamep)
  5271. {
  5272. gCacheNamep->getFullName(id, name);
  5273. }
  5274. LLMute::EType type;
  5275. U32 flags = 0;
  5276. const LLUUID& source_id = gToolPie.getPick().mParticleSourceID;
  5277. if (data == "object" && source_id.notNull())
  5278. {
  5279. id = source_id;
  5280. name += "'s object";
  5281. type = LLMute::OBJECT;
  5282. }
  5283. else if (data == "owner")
  5284. {
  5285. flags = LLMute::flagParticles;
  5286. type = LLMute::AGENT;
  5287. }
  5288. else
  5289. {
  5290. return true;
  5291. }
  5292. bool muted = true;
  5293. LLMute mute(id, name, type);
  5294. if (!LLMuteList::isMuted(mute.mID, mute.mName, flags))
  5295. {
  5296. muted = LLMuteList::add(mute, flags);
  5297. }
  5298. if (muted)
  5299. {
  5300. LLFloaterMute::selectMute(mute.mID);
  5301. }
  5302. }
  5303. return true;
  5304. }
  5305. };
  5306. class LLReportParticleAbuse final : public view_listener_t
  5307. {
  5308. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5309. {
  5310. const LLUUID& owner_id = gToolPie.getPick().mParticleOwnerID;
  5311. const LLUUID& source_id = gToolPie.getPick().mParticleSourceID;
  5312. if (source_id.notNull() && owner_id.notNull() && owner_id != gAgentID)
  5313. {
  5314. LLFloaterReporter::showFromObject(source_id);
  5315. }
  5316. return true;
  5317. }
  5318. };
  5319. class LLParticleRefreshTexture final : public view_listener_t
  5320. {
  5321. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5322. {
  5323. const LLUUID& source_id = gToolPie.getPick().mParticleSourceID;
  5324. if (source_id.isNull())
  5325. {
  5326. return true;
  5327. }
  5328. LLViewerObject* objectp = gObjectList.findObject(source_id);
  5329. if (!objectp)
  5330. {
  5331. return true;
  5332. }
  5333. LLViewerPartSource* psrcp = objectp->getPartSource();
  5334. if (!psrcp)
  5335. {
  5336. return true;
  5337. }
  5338. LLViewerTexture* imagep = psrcp->getImage();
  5339. if (!imagep)
  5340. {
  5341. return true;
  5342. }
  5343. LLViewerFetchedTexture* texp =
  5344. LLViewerTextureManager::staticCast(imagep);
  5345. if (texp)
  5346. {
  5347. // Force a reload of the raw image
  5348. texp->forceRefetch();
  5349. }
  5350. return true;
  5351. }
  5352. };
  5353. //---------------------------------------------------------------------------
  5354. // Lua pie menu
  5355. //---------------------------------------------------------------------------
  5356. class LLPieLuaCall final : public view_listener_t
  5357. {
  5358. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5359. {
  5360. S32 slice = userdata.asInteger();
  5361. const LLPickInfo& pick = gToolPie.getPick();
  5362. if (gLuaPiep)
  5363. {
  5364. gLuaPiep->onPieSliceClick(slice, pick);
  5365. }
  5366. return true;
  5367. }
  5368. };
  5369. //---------------------------------------------------------------------------
  5370. // Formerly defined in the now removed llmenucommands.cpp
  5371. //---------------------------------------------------------------------------
  5372. void handle_chat(void*)
  5373. {
  5374. if (!gChatBarp) return;
  5375. // Give focus to chatbar if it is open but not focused
  5376. if (gSavedSettings.getBool("ChatVisible") &&
  5377. gFocusMgr.childHasKeyboardFocus(gChatBarp))
  5378. {
  5379. LLChatBar::stopChat();
  5380. }
  5381. else
  5382. {
  5383. LLChatBar::startChat(NULL);
  5384. }
  5385. }
  5386. void handle_inventory(void*)
  5387. {
  5388. LLFirstUse::useInventory();
  5389. LLFloaterInventory::toggleVisibility(NULL);
  5390. }
  5391. //---------------------------------------------------------------------------
  5392. class LLAvatarEnableDebug final : public view_listener_t
  5393. {
  5394. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5395. {
  5396. bool new_value = false;
  5397. if (gMenuHolderp->getChild<LLView>("Debug", true, false))
  5398. {
  5399. // Allow true admins to debug avatars (when admin overrides is on),
  5400. // but also to refresh avatars (when admin overrides is off)
  5401. std::string label =
  5402. gAgent.isGodlikeWithoutAdminMenuFakery() &&
  5403. gAgent.getAdminOverride() ? "Debug" : "Refresh";
  5404. gMenuHolderp->childSetText("Debug", label);
  5405. new_value = true;
  5406. }
  5407. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  5408. return true;
  5409. }
  5410. };
  5411. void reload_avatar_texture(LLVOAvatar* avatar, ETextureIndex idx)
  5412. {
  5413. LLTextureEntry* tep = avatar->getTE(idx);
  5414. if (!tep) return; // Paranoia
  5415. LLViewerFetchedTexture* tex =
  5416. LLViewerTextureManager::getFetchedTexture(tep->getID());
  5417. if (tex)
  5418. {
  5419. // Force a reload of the raw image
  5420. tex->forceRefetch();
  5421. }
  5422. }
  5423. // static
  5424. void handle_refresh_avatar(LLVOAvatar* avatar, bool refresh_all)
  5425. {
  5426. if (refresh_all)
  5427. {
  5428. avatar->resetSkeleton();
  5429. }
  5430. // Force-reload the avatar's known baked textures
  5431. reload_avatar_texture(avatar, TEX_HAIR_BAKED);
  5432. reload_avatar_texture(avatar, TEX_EYES_BAKED);
  5433. reload_avatar_texture(avatar, TEX_HEAD_BAKED);
  5434. reload_avatar_texture(avatar, TEX_UPPER_BAKED);
  5435. reload_avatar_texture(avatar, TEX_LOWER_BAKED);
  5436. reload_avatar_texture(avatar, TEX_SKIRT_BAKED);
  5437. // Request again the baked textures in case we would have missed a refresh
  5438. // (new baked texture UUID missed due to a lost packet, for example).
  5439. avatar->sendAvatarTexturesRequest(true);
  5440. if (!refresh_all) return;
  5441. avatar->updateVisualComplexity();
  5442. // Set all mesh attachments LOD to a different LOD than the current one
  5443. // (this will only stay at this LOD till the next LLVOVolume::updateLOD()
  5444. // call for each mesh), so to force the mesh refresh.
  5445. for (S32 i = 0, count = avatar->mAttachedObjectsVector.size();
  5446. i < count; ++i)
  5447. {
  5448. LLViewerObject* objectp = avatar->mAttachedObjectsVector[i].first;
  5449. if (!objectp) continue; // Paranoia
  5450. if (objectp->getPCode() == LL_PCODE_VOLUME)
  5451. {
  5452. LLVOVolume* volp = objectp->asVolume();
  5453. if (volp)
  5454. {
  5455. if (volp->getLOD() == LLModel::LOD_HIGH)
  5456. {
  5457. volp->tempSetLOD(LLModel::LOD_MEDIUM);
  5458. }
  5459. else
  5460. {
  5461. volp->tempSetLOD(LLModel::LOD_HIGH);
  5462. }
  5463. }
  5464. }
  5465. // Process all children
  5466. LLViewerObject::const_child_list_t& children = objectp->getChildren();
  5467. for (LLViewerObject::const_child_list_t::const_iterator
  5468. it = children.begin(), end = children.end();
  5469. it != end; ++it)
  5470. {
  5471. LLViewerObject* childp = *it;
  5472. if (childp && childp->getPCode() == LL_PCODE_VOLUME)
  5473. {
  5474. LLVOVolume* volp = childp->asVolume();
  5475. if (volp)
  5476. {
  5477. if (volp->getLOD() == LLModel::LOD_HIGH)
  5478. {
  5479. volp->tempSetLOD(LLModel::LOD_MEDIUM);
  5480. }
  5481. else
  5482. {
  5483. volp->tempSetLOD(LLModel::LOD_HIGH);
  5484. }
  5485. }
  5486. }
  5487. }
  5488. }
  5489. // Also restart the avatar's animations
  5490. for (LLVOAvatar::anim_it_t it = avatar->mPlayingAnimations.begin(),
  5491. end = avatar->mPlayingAnimations.end();
  5492. it != end; ++it)
  5493. {
  5494. const LLUUID& anim_id = it->first;
  5495. avatar->stopMotion(anim_id, true);
  5496. avatar->startMotion(anim_id);
  5497. }
  5498. }
  5499. class LLAvatarDebug final : public view_listener_t
  5500. {
  5501. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5502. {
  5503. LLVOAvatar* avatar =
  5504. find_avatar_from_object(gSelectMgr.getSelection()->getPrimaryObject());
  5505. if (avatar)
  5506. {
  5507. // Allow true admins to debug avatars (when admin overrides is on),
  5508. // but also to refresh avatars (when admin overrides is off)
  5509. if (gAgent.isGodlikeWithoutAdminMenuFakery() &&
  5510. gAgent.getAdminOverride())
  5511. {
  5512. ((LLVOAvatarSelf*)avatar)->dumpLocalTextures();
  5513. llinfos << "Dumping temporary asset data to simulator logs for avatar "
  5514. << avatar->getID() << llendl;
  5515. std::vector<std::string> strings;
  5516. strings.emplace_back(avatar->getID().asString());
  5517. LLUUID invoice;
  5518. send_generic_message("dumptempassetdata", strings, invoice);
  5519. LLFloaterAvatarTextures::show(avatar->getID());
  5520. }
  5521. else
  5522. {
  5523. handle_refresh_avatar(avatar, true);
  5524. }
  5525. }
  5526. return true;
  5527. }
  5528. };
  5529. //---------------------------------------------------------------------------
  5530. // Parcel freeze, eject, etc.
  5531. //---------------------------------------------------------------------------
  5532. bool callback_freeze(const LLSD& notification, const LLSD& response)
  5533. {
  5534. S32 option = LLNotification::getSelectedOption(notification, response);
  5535. if (option == 0 || option == 1)
  5536. {
  5537. LLUUID avatar_id = notification["payload"]["avatar_id"].asUUID();
  5538. LLAvatarActions::sendFreeze(avatar_id, option == 0);
  5539. }
  5540. return false;
  5541. }
  5542. class LLAvatarFreeze final : public view_listener_t
  5543. {
  5544. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5545. {
  5546. LLVOAvatar* avatarp =
  5547. find_avatar_from_object(gSelectMgr.getSelection()->getPrimaryObject());
  5548. if (!avatarp)
  5549. {
  5550. return true;
  5551. }
  5552. LLSD payload;
  5553. payload["avatar_id"] = avatarp->getID();
  5554. std::string fullname = avatarp->getFullname();
  5555. //MK
  5556. if (gRLenabled &&
  5557. (gRLInterface.mContainsShownames ||
  5558. gRLInterface.mContainsShownametags))
  5559. {
  5560. fullname = gRLInterface.getDummyName(fullname);
  5561. }
  5562. //mk
  5563. if (fullname.empty())
  5564. {
  5565. fullname = LLTrans::getString("this_resident");
  5566. }
  5567. LLSD args;
  5568. args["AVATAR_NAME"] = fullname;
  5569. gNotifications.add("FreezeAvatarFullname", args, payload,
  5570. callback_freeze);
  5571. return true;
  5572. }
  5573. };
  5574. bool callback_eject(const LLSD& notification, const LLSD& response)
  5575. {
  5576. S32 option = LLNotification::getSelectedOption(notification, response);
  5577. if (option == 2)
  5578. {
  5579. // Cancel button.
  5580. return false;
  5581. }
  5582. LLUUID avatar_id = notification["payload"]["avatar_id"].asUUID();
  5583. if (option == 0)
  5584. {
  5585. // Eject button
  5586. LLAvatarActions::sendEject(avatar_id, false);
  5587. }
  5588. else if (notification["payload"]["ban_enabled"].asBoolean())
  5589. {
  5590. // This is tricky. It is similar to say if it is not an 'Eject' button,
  5591. // and it is also not an 'Cancel' button, and ban_enabled is true, it
  5592. // should be the 'Eject and Ban' button.
  5593. LLAvatarActions::sendEject(avatar_id, true);
  5594. }
  5595. return false;
  5596. }
  5597. class LLAvatarEject final : public view_listener_t
  5598. {
  5599. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5600. {
  5601. LLVOAvatar* avatarp =
  5602. find_avatar_from_object(gSelectMgr.getSelection()->getPrimaryObject());
  5603. if (!avatarp)
  5604. {
  5605. return true;
  5606. }
  5607. LLSD payload;
  5608. payload["avatar_id"] = avatarp->getID();
  5609. std::string fullname = avatarp->getFullname();
  5610. //MK
  5611. if (gRLenabled &&
  5612. (gRLInterface.mContainsShownames ||
  5613. gRLInterface.mContainsShownametags))
  5614. {
  5615. fullname = gRLInterface.getDummyName(fullname);
  5616. }
  5617. //mk
  5618. if (fullname.empty())
  5619. {
  5620. fullname = LLTrans::getString("this_resident");
  5621. }
  5622. LLSD args;
  5623. args["AVATAR_NAME"] = fullname;
  5624. const LLVector3d& pos = avatarp->getPositionGlobal();
  5625. LLParcel* parcelp = gViewerParcelMgr.selectParcelAt(pos)->getParcel();
  5626. if (parcelp &&
  5627. gViewerParcelMgr.isParcelOwnedByAgent(parcelp,
  5628. GP_LAND_MANAGE_BANNED))
  5629. {
  5630. payload["ban_enabled"] = true;
  5631. gNotifications.add("EjectAvatarFullname", args, payload,
  5632. callback_eject);
  5633. }
  5634. else
  5635. {
  5636. payload["ban_enabled"] = false;
  5637. gNotifications.add("EjectAvatarFullnameNoBan", args, payload,
  5638. callback_eject);
  5639. }
  5640. return true;
  5641. }
  5642. };
  5643. class LLAvatarEnableFreezeEject final : public view_listener_t
  5644. {
  5645. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5646. {
  5647. LLVOAvatar* avatarp =
  5648. find_avatar_from_object(gSelectMgr.getSelection()->getPrimaryObject());
  5649. bool new_value = avatarp &&
  5650. LLAvatarActions::canEjectOrFreeze(avatarp->getID());
  5651. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  5652. return true;
  5653. }
  5654. };
  5655. //---------------------------------------------------------------------------
  5656. class LLAvatarGiveCard final : public view_listener_t
  5657. {
  5658. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5659. {
  5660. //MK
  5661. if (gRLenabled &&
  5662. (gRLInterface.mContainsShownames ||
  5663. gRLInterface.mContainsShownametags))
  5664. {
  5665. return false;
  5666. }
  5667. //mk
  5668. llinfos << "handle_give_card()" << llendl;
  5669. LLViewerObject* dest = gSelectMgr.getSelection()->getPrimaryObject();
  5670. if (dest && dest->isAvatar())
  5671. {
  5672. bool found_name = false;
  5673. LLSD args;
  5674. LLNameValue* nvfirst = dest->getNVPair("FirstName");
  5675. LLNameValue* nvlast = dest->getNVPair("LastName");
  5676. if (nvfirst && nvlast)
  5677. {
  5678. args["NAME"] = LLCacheName::buildFullName(nvfirst->getString(),
  5679. nvlast->getString());
  5680. found_name = true;
  5681. }
  5682. LLViewerRegion* region = dest->getRegion();
  5683. LLHost dest_host;
  5684. if (region)
  5685. {
  5686. dest_host = region->getHost();
  5687. }
  5688. if (found_name && dest_host.isOk())
  5689. {
  5690. LLMessageSystem* msg = gMessageSystemp;
  5691. msg->newMessage(_PREHASH_OfferCallingCard);
  5692. msg->nextBlockFast(_PREHASH_AgentData);
  5693. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  5694. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  5695. msg->nextBlockFast(_PREHASH_AgentBlock);
  5696. msg->addUUIDFast(_PREHASH_DestID, dest->getID());
  5697. LLUUID transaction_id;
  5698. transaction_id.generate();
  5699. msg->addUUIDFast(_PREHASH_TransactionID, transaction_id);
  5700. msg->sendReliable(dest_host);
  5701. gNotifications.add("OfferedCard", args);
  5702. }
  5703. else
  5704. {
  5705. gNotifications.add("CantOfferCallingCard", args);
  5706. }
  5707. }
  5708. return true;
  5709. }
  5710. };
  5711. void login_done(S32 which, void *user)
  5712. {
  5713. llinfos << "Login done " << which << llendl;
  5714. LLPanelLogin::close();
  5715. }
  5716. bool enable_buy()
  5717. {
  5718. // In order to buy, there must only be 1 purchaseable object in the
  5719. // selection manger.
  5720. if (gSelectMgr.getSelection()->getRootObjectCount() != 1)
  5721. {
  5722. return false;
  5723. }
  5724. LLViewerObject* obj = NULL;
  5725. LLSelectNode* node = gSelectMgr.getSelection()->getFirstRootNode();
  5726. if (node)
  5727. {
  5728. obj = node->getObject();
  5729. if (obj && obj->permAnyOwner() && node->mSaleInfo.isForSale() &&
  5730. (node->mPermissions->getMaskOwner() & PERM_TRANSFER) &&
  5731. ((node->mPermissions->getMaskOwner() & PERM_COPY) ||
  5732. node->mSaleInfo.getSaleType() != LLSaleInfo::FS_COPY))
  5733. {
  5734. return true;
  5735. }
  5736. }
  5737. return false;
  5738. }
  5739. class LLObjectEnableBuy final : public view_listener_t
  5740. {
  5741. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5742. {
  5743. bool new_value = enable_buy();
  5744. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  5745. return true;
  5746. }
  5747. };
  5748. // Note: This will only work if the data of the selected object has already
  5749. // been received by the viewer and cached in the selection manager.
  5750. void handle_buy_object(LLSaleInfo sale_info)
  5751. {
  5752. if (!gSelectMgr.selectGetAllRootsValid())
  5753. {
  5754. gNotifications.add("UnableToBuyWhileDownloading");
  5755. return;
  5756. }
  5757. LLUUID owner_id;
  5758. std::string owner_name;
  5759. bool owners_identical = gSelectMgr.selectGetOwner(owner_id, owner_name);
  5760. if (!owners_identical)
  5761. {
  5762. gNotifications.add("CannotBuyObjectsFromDifferentOwners");
  5763. return;
  5764. }
  5765. LLPermissions perm;
  5766. LLAggregatePermissions ag_perm;
  5767. bool valid = gSelectMgr.selectGetPermissions(perm) &&
  5768. gSelectMgr.selectGetAggregatePermissions(ag_perm);
  5769. if (!valid || !sale_info.isForSale() || !perm.allowTransferTo(gAgentID))
  5770. {
  5771. gNotifications.add("ObjectNotForSale");
  5772. return;
  5773. }
  5774. S32 price = sale_info.getSalePrice();
  5775. if (can_afford_transaction(price))
  5776. {
  5777. LLFloaterBuy::show(sale_info);
  5778. }
  5779. else
  5780. {
  5781. LLFloaterBuyCurrency::buyCurrency("This object costs", price);
  5782. }
  5783. }
  5784. class HBSelfGroupTitles final : public view_listener_t
  5785. {
  5786. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5787. {
  5788. HBFloaterGroupTitles::showInstance();
  5789. return true;
  5790. }
  5791. };
  5792. bool stand_up()
  5793. {
  5794. if (isAgentAvatarValid() && gAgentAvatarp->mIsSitting)
  5795. {
  5796. //MK
  5797. if (gRLenabled && gRLInterface.mContainsUnsit)
  5798. {
  5799. // Set it to false because we are currently prevented from standing
  5800. // up and we do not want to force a sit ground once the restriction
  5801. // is lifted later on.
  5802. gRLInterface.mSitGroundOnStandUp = false;
  5803. return false;
  5804. }
  5805. //mk
  5806. LL_DEBUGS("AgentSit") << "Sending agent unsit request" << LL_ENDL;
  5807. gAgent.setControlFlags(AGENT_CONTROL_STAND_UP);
  5808. //MK
  5809. if (gRLenabled && gRLInterface.mContainsStandtp)
  5810. {
  5811. gRLInterface.backToLastStandingLoc();
  5812. }
  5813. //mk
  5814. }
  5815. return true;
  5816. }
  5817. bool sit_on_ground()
  5818. {
  5819. //MK
  5820. if (gRLenabled &&
  5821. (gRLInterface.contains("sit") || gRLInterface.mContainsInteract))
  5822. {
  5823. return false;
  5824. }
  5825. //mk
  5826. if (isAgentAvatarValid() && !gAgentAvatarp->mIsSitting)
  5827. {
  5828. gAgent.setFlying(false);
  5829. LL_DEBUGS("AgentSit") << "Sending agent sit on ground request"
  5830. << LL_ENDL;
  5831. gAgent.clearControlFlags(AGENT_CONTROL_STAND_UP);
  5832. gAgent.setControlFlags(AGENT_CONTROL_SIT_ON_GROUND);
  5833. //MK
  5834. if (gRLenabled)
  5835. {
  5836. // Store our current location so that we can snap back here
  5837. // when we stand up, if under @standtp
  5838. gRLInterface.storeLastStandingLoc(true);
  5839. }
  5840. //mk
  5841. // Might be our first sit
  5842. LLFirstUse::useSit();
  5843. return true;
  5844. }
  5845. return false;
  5846. }
  5847. bool sit_on_object(LLViewerObject* object, const LLVector3& offset)
  5848. {
  5849. if (!object || object->getPCode() != LL_PCODE_VOLUME ||
  5850. !object->getRegion())
  5851. {
  5852. return false;
  5853. }
  5854. //MK
  5855. if (gRLenabled)
  5856. {
  5857. if (gRLInterface.contains("sit") || gRLInterface.mContainsInteract)
  5858. {
  5859. return false;
  5860. }
  5861. if (gRLInterface.mSittpMax < EXTREMUM)
  5862. {
  5863. LLVector3 pos = object->getPositionRegion() + offset;
  5864. pos -= gAgent.getPositionAgent();
  5865. if (pos.length () >= gRLInterface.mSittpMax)
  5866. {
  5867. return false;
  5868. }
  5869. }
  5870. // We are now standing, and we want to sit down => store our current
  5871. // location so that we can snap back here when we stand up, if under
  5872. // @standtp
  5873. gRLInterface.storeLastStandingLoc();
  5874. }
  5875. //mk
  5876. LL_DEBUGS("AgentSit") << "Sending agent sit on object request" << LL_ENDL;
  5877. LLMessageSystem* msg = gMessageSystemp;
  5878. msg->newMessageFast(_PREHASH_AgentRequestSit);
  5879. msg->nextBlockFast(_PREHASH_AgentData);
  5880. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  5881. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  5882. msg->nextBlockFast(_PREHASH_TargetObject);
  5883. msg->addUUIDFast(_PREHASH_TargetID, object->mID);
  5884. msg->addVector3Fast(_PREHASH_Offset, offset);
  5885. object->getRegion()->sendReliableMessage();
  5886. return true;
  5887. }
  5888. class LLSelfSitOrStand final : public view_listener_t
  5889. {
  5890. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5891. {
  5892. if (!isAgentAvatarValid()) return true;
  5893. if (gAgentAvatarp->mIsSitting)
  5894. {
  5895. stand_up();
  5896. }
  5897. else
  5898. {
  5899. sit_on_ground();
  5900. }
  5901. return true;
  5902. }
  5903. };
  5904. class LLSelfEnableSitOrStand final : public view_listener_t
  5905. {
  5906. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5907. {
  5908. bool new_value = isAgentAvatarValid() && !gAgent.getFlying();
  5909. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  5910. return true;
  5911. }
  5912. };
  5913. // Enable a menu item when you don't have someone's card.
  5914. class LLAvatarEnableAddFriend final : public view_listener_t
  5915. {
  5916. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5917. {
  5918. //MK
  5919. if (gRLenabled &&
  5920. (gRLInterface.mContainsShownames ||
  5921. gRLInterface.mContainsShownametags))
  5922. {
  5923. return false;
  5924. }
  5925. //mk
  5926. LLVOAvatar* avatar =
  5927. find_avatar_from_object(gSelectMgr.getSelection()->getPrimaryObject());
  5928. bool new_value = avatar && !LLAvatarTracker::isAgentFriend(avatar->getID());
  5929. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  5930. return true;
  5931. }
  5932. };
  5933. class LLEditEnableCustomizeAvatar final : public view_listener_t
  5934. {
  5935. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5936. {
  5937. bool new_value = (isAgentAvatarValid() &&
  5938. gAgentAvatarp->isFullyLoaded() &&
  5939. gAgentWearables.areWearablesLoaded());
  5940. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  5941. return true;
  5942. }
  5943. };
  5944. class LLEditEnableOutfitPicker final : public view_listener_t
  5945. {
  5946. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5947. {
  5948. gMenuHolderp->findControl(userdata["control"].asString())->setValue(gIsInSecondLife);
  5949. return true;
  5950. }
  5951. };
  5952. class LLEditEnableDisplayName final : public view_listener_t
  5953. {
  5954. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  5955. {
  5956. bool new_value = (LLAvatarNameCache::useDisplayNames() != 0);
  5957. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  5958. return true;
  5959. }
  5960. };
  5961. bool sitting_on_selection()
  5962. {
  5963. LLSelectNode* node = gSelectMgr.getSelection()->getFirstRootNode();
  5964. if (!node || !node->mValid)
  5965. {
  5966. return false;
  5967. }
  5968. LLViewerObject* root_object = node->getObject();
  5969. if (!root_object)
  5970. {
  5971. return false;
  5972. }
  5973. // Need to determine if avatar is sitting on this object
  5974. if (!isAgentAvatarValid())
  5975. {
  5976. return false;
  5977. }
  5978. return gAgentAvatarp->mIsSitting &&
  5979. gAgentAvatarp->getRoot() == root_object;
  5980. }
  5981. // only works on pie menu
  5982. bool handle_sit_or_stand()
  5983. {
  5984. LLPickInfo pick = gToolPie.getPick();
  5985. LLViewerObject* object = pick.getObject();;
  5986. if (!object || pick.mPickType == LLPickInfo::PICK_FLORA)
  5987. {
  5988. return true;
  5989. }
  5990. //MK
  5991. if (gRLenabled && gRLInterface.mContainsUnsit &&
  5992. isAgentAvatarValid() && gAgentAvatarp->mIsSitting)
  5993. {
  5994. return true;
  5995. }
  5996. //mk
  5997. if (sitting_on_selection())
  5998. {
  5999. stand_up();
  6000. return true;
  6001. }
  6002. sit_on_object(object, pick.mObjectOffset);
  6003. return true;
  6004. }
  6005. class LLObjectSitOrStand final : public view_listener_t
  6006. {
  6007. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6008. {
  6009. return handle_sit_or_stand();
  6010. }
  6011. };
  6012. void near_sit_down_point(bool success, void*)
  6013. {
  6014. if (success)
  6015. {
  6016. sit_on_ground();
  6017. }
  6018. }
  6019. class LLLandSit final : public view_listener_t
  6020. {
  6021. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6022. {
  6023. if (!stand_up())
  6024. {
  6025. return true;
  6026. }
  6027. gViewerParcelMgr.deselectLand();
  6028. LLVector3d pos = gToolPie.getPick().mPosGlobal;
  6029. LLQuaternion target_rot;
  6030. if (isAgentAvatarValid())
  6031. {
  6032. target_rot = gAgentAvatarp->getRotation();
  6033. }
  6034. else
  6035. {
  6036. target_rot = gAgent.getFrameAgent().getQuaternion();
  6037. }
  6038. gAgentPilot.startAutoPilotGlobal(pos, "Sit", &target_rot,
  6039. near_sit_down_point, NULL, 0.7f,
  6040. gAgent.getFlying());
  6041. return true;
  6042. }
  6043. };
  6044. class LLLandCanSit final : public view_listener_t
  6045. {
  6046. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6047. {
  6048. LLVector3d pos = gToolPie.getPick().mPosGlobal;
  6049. // Can sit only if the position is valid (not beyond draw distance)
  6050. return !pos.isExactlyZero();
  6051. }
  6052. };
  6053. class LLCreateLandmarkCallback final : public LLInventoryCallback
  6054. {
  6055. public:
  6056. void fire(const LLUUID& inv_item) override
  6057. {
  6058. llinfos << "Created landmark with inventory Id: " << inv_item
  6059. << llendl;
  6060. }
  6061. };
  6062. class LLWorldFly final : public view_listener_t
  6063. {
  6064. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6065. {
  6066. gAgent.toggleFlying();
  6067. return true;
  6068. }
  6069. };
  6070. class LLWorldEnableFly final : public view_listener_t
  6071. {
  6072. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6073. {
  6074. bool sitting = false;
  6075. if (isAgentAvatarValid())
  6076. {
  6077. sitting = gAgentAvatarp->mIsSitting;
  6078. }
  6079. gMenuHolderp->findControl(userdata["control"].asString())->setValue(!sitting);
  6080. return true;
  6081. }
  6082. };
  6083. //
  6084. // Major mode switching
  6085. //
  6086. // Note: extra parameters allow this function to be called from dialog.
  6087. void reset_view_final(bool proceed, void*)
  6088. {
  6089. if (proceed)
  6090. {
  6091. gAgent.resetView(true, true);
  6092. }
  6093. }
  6094. bool handle_reset_view()
  6095. {
  6096. if (gFloaterCustomizep &&
  6097. gAgent.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR)
  6098. {
  6099. // Show dialog box if needed.
  6100. gFloaterCustomizep->askToSaveIfDirty(reset_view_final, NULL);
  6101. return false;
  6102. }
  6103. //MK
  6104. // We should not have to do this here, but when we hit SHIFT ESC, we need
  6105. // to prevent exiting mouselook if the max cam distance is zero.
  6106. else if (gRLenabled && gAgent.cameraMouselook() &&
  6107. gRLInterface.mCamDistMax <= 0.f)
  6108. {
  6109. return false;
  6110. }
  6111. //mk
  6112. gAgent.resetView(true, true);
  6113. return true;
  6114. }
  6115. class LLViewResetView final : public view_listener_t
  6116. {
  6117. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6118. {
  6119. handle_reset_view();
  6120. return true;
  6121. }
  6122. };
  6123. class LLViewReleaseCamera final : public view_listener_t
  6124. {
  6125. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6126. {
  6127. // WARNING: should this method get modified to do anything else than
  6128. // removing all follow-camera constraints data, it would be necessary
  6129. // to make a new method for calling it from here.
  6130. LLFollowCamMgr::cleanupClass();
  6131. return true;
  6132. }
  6133. };
  6134. class LLViewEnableReleaseCamera final : public view_listener_t
  6135. {
  6136. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6137. {
  6138. bool followcam = LLFollowCamMgr::getActiveFollowCamParams() != NULL;
  6139. gMenuHolderp->findControl(userdata["control"].asString())->setValue(followcam);
  6140. return true;
  6141. }
  6142. };
  6143. class LLViewLookAtLastChatter final : public view_listener_t
  6144. {
  6145. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6146. {
  6147. gAgent.lookAtLastChat();
  6148. return true;
  6149. }
  6150. };
  6151. class LLViewMouselook final : public view_listener_t
  6152. {
  6153. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6154. {
  6155. if (!gAgent.cameraMouselook())
  6156. {
  6157. gAgent.changeCameraToMouselook();
  6158. }
  6159. else
  6160. {
  6161. gAgent.changeCameraToDefault();
  6162. }
  6163. return true;
  6164. }
  6165. };
  6166. class LLViewDefaultUISize final : public view_listener_t
  6167. {
  6168. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6169. {
  6170. gSavedSettings.setF32("UIScaleFactor", 1.0f);
  6171. gSavedSettings.setBool("UIAutoScale", false);
  6172. gViewerWindowp->reshape(gViewerWindowp->getWindowDisplayWidth(),
  6173. gViewerWindowp->getWindowDisplayHeight());
  6174. return true;
  6175. }
  6176. };
  6177. class LLEditDuplicate final : public view_listener_t
  6178. {
  6179. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6180. {
  6181. //MK
  6182. if (gRLenabled && gRLInterface.mContainsRez)
  6183. {
  6184. return true;
  6185. }
  6186. //mk
  6187. if (gEditMenuHandlerp && gEditMenuHandlerp->canDuplicate())
  6188. {
  6189. gEditMenuHandlerp->duplicate();
  6190. }
  6191. return true;
  6192. }
  6193. };
  6194. class LLEditEnableDuplicate final : public view_listener_t
  6195. {
  6196. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6197. {
  6198. bool new_value = gEditMenuHandlerp &&
  6199. gEditMenuHandlerp->canDuplicate();
  6200. //MK
  6201. if (gRLenabled && gRLInterface.mContainsRez)
  6202. {
  6203. new_value = false;
  6204. }
  6205. //mk
  6206. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  6207. return true;
  6208. }
  6209. };
  6210. // Also called in llfloaterpathfindingobjects.
  6211. void handle_take_copy()
  6212. {
  6213. if (gSelectMgr.getSelection()->isEmpty()) return;
  6214. const LLUUID category_id =
  6215. gInventory.findCategoryUUIDForType(LLFolderType::FT_OBJECT);
  6216. derez_objects(DRD_ACQUIRE_TO_AGENT_INVENTORY, category_id);
  6217. }
  6218. class LLToolsTakeCopy final : public view_listener_t
  6219. {
  6220. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6221. {
  6222. handle_take_copy();
  6223. return true;
  6224. }
  6225. };
  6226. static void return_objects(const LLSD& notification,
  6227. const LLSD& response)
  6228. {
  6229. if (LLNotification::getSelectedOption(notification, response) == 0)
  6230. {
  6231. // Ignore category ID for this derez destination.
  6232. derez_objects(DRD_RETURN_TO_OWNER, LLUUID::null);
  6233. }
  6234. }
  6235. // Also called in llfloaterpathfindingobjects.
  6236. void handle_object_return()
  6237. {
  6238. if (gSelectMgr.getSelection()->isEmpty()) return;
  6239. //MK
  6240. if (gRLenabled &&
  6241. (gRLInterface.mContainsRez ||
  6242. (gRLInterface.mContainsUnsit &&
  6243. gRLInterface.isSittingOnAnySelectedObject())))
  6244. {
  6245. return;
  6246. }
  6247. //mk
  6248. gNotifications.add("ReturnToOwner", LLSD(), LLSD(), return_objects);
  6249. }
  6250. // You can return an object to its owner if it is on your land.
  6251. class LLObjectReturn final : public view_listener_t
  6252. {
  6253. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6254. {
  6255. handle_object_return();
  6256. return true;
  6257. }
  6258. };
  6259. // Also called in llfloaterpathfindingobjects.
  6260. bool enable_object_return()
  6261. {
  6262. //MK
  6263. if (gRLenabled &&
  6264. (gRLInterface.mContainsRez ||
  6265. (gRLInterface.mContainsUnsit &&
  6266. gRLInterface.isSittingOnAnySelectedObject())))
  6267. {
  6268. return false;
  6269. }
  6270. //mk
  6271. bool can_return = false;
  6272. if (gAgent.isGodlike())
  6273. {
  6274. can_return = true;
  6275. }
  6276. else
  6277. {
  6278. LLViewerRegion* region = gAgent.getRegion();
  6279. if (region)
  6280. {
  6281. // Estate owners and managers can always return objects.
  6282. if (region->canManageEstate())
  6283. {
  6284. can_return = true;
  6285. }
  6286. else
  6287. {
  6288. struct f final : public LLSelectedObjectFunctor
  6289. {
  6290. bool apply(LLViewerObject* obj) override
  6291. {
  6292. //MK
  6293. if (gRLenabled && gRLInterface.mContainsUnsit &&
  6294. obj->isAgentSeat())
  6295. {
  6296. return false;
  6297. }
  6298. //mk
  6299. return obj->permModify() || obj->isReturnable();
  6300. }
  6301. } func;
  6302. can_return = gSelectMgr.getSelection()->applyToRootObjects(&func, true);
  6303. }
  6304. }
  6305. }
  6306. return can_return;
  6307. }
  6308. // Allow return to owner if one or more of the selected items is
  6309. // over land you own.
  6310. class LLObjectEnableReturn final : public view_listener_t
  6311. {
  6312. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6313. {
  6314. bool new_value = enable_object_return();
  6315. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  6316. return true;
  6317. }
  6318. };
  6319. // You can take an item when it is public and transferrable, or when you own
  6320. // it. We error out on the side of enabling the item when at least one item
  6321. // selected can be copied to inventory.
  6322. bool enable_take()
  6323. {
  6324. if (sitting_on_selection())
  6325. {
  6326. return false;
  6327. }
  6328. //MK
  6329. if (gRLenabled && gRLInterface.mContainsRez)
  6330. {
  6331. return false;
  6332. }
  6333. //mk
  6334. for (LLObjectSelection::valid_root_iterator
  6335. iter = gSelectMgr.getSelection()->valid_root_begin(),
  6336. end = gSelectMgr.getSelection()->valid_root_end();
  6337. iter != end; ++iter)
  6338. {
  6339. LLSelectNode* node = *iter;
  6340. if (!node) continue; // Paranoia
  6341. LLViewerObject* object = node->getObject();
  6342. if (!object || object->isAvatar())
  6343. {
  6344. // ...don't acquire avatars
  6345. continue;
  6346. }
  6347. if (!object->isPermanentEnforced() &&
  6348. (node->mPermissions->getOwner() == gAgentID ||
  6349. (object->permModify() &&
  6350. node->mPermissions->allowTransferTo(gAgentID))))
  6351. {
  6352. return true;
  6353. }
  6354. }
  6355. return false;
  6356. }
  6357. bool confirm_take(const LLSD& notification, const LLSD& response)
  6358. {
  6359. if (LLNotification::getSelectedOption(notification, response) == 0 &&
  6360. enable_take())
  6361. {
  6362. derez_objects(DRD_TAKE_INTO_AGENT_INVENTORY,
  6363. notification["payload"]["folder_id"].asUUID());
  6364. }
  6365. return false;
  6366. }
  6367. void handle_take()
  6368. {
  6369. // We want to use the folder this was derezzed from if it is available.
  6370. // Otherwise, derez to the normal place.
  6371. if (gSelectMgr.getSelection()->isEmpty())
  6372. {
  6373. return;
  6374. }
  6375. //MK
  6376. if (gRLenabled &&
  6377. (gRLInterface.mContainsRez ||
  6378. (gRLInterface.mContainsUnsit &&
  6379. gRLInterface.isSittingOnAnySelectedObject())))
  6380. {
  6381. return;
  6382. }
  6383. //mk
  6384. bool you_own_everything = true;
  6385. bool locked_but_takeable_object = false;
  6386. bool ambiguous_destination = false;
  6387. LLUUID category_id, new_cat_id;
  6388. const LLUUID& trash = gInventory.getTrashID();
  6389. const LLUUID& library = gInventory.getLibraryRootFolderID();
  6390. for (LLObjectSelection::root_iterator
  6391. iter = gSelectMgr.getSelection()->root_begin(),
  6392. end = gSelectMgr.getSelection()->root_end();
  6393. iter != end; ++iter)
  6394. {
  6395. LLSelectNode* node = *iter;
  6396. if (!node) continue; // Paranoia
  6397. LLViewerObject* object = node->getObject();
  6398. if (object)
  6399. {
  6400. if (!object->permYouOwner())
  6401. {
  6402. you_own_everything = false;
  6403. }
  6404. if (!object->permMove())
  6405. {
  6406. locked_but_takeable_object = true;
  6407. }
  6408. }
  6409. new_cat_id = node->mFolderID;
  6410. // Check that the category exists and is not inside the trash
  6411. // neither inside the library...
  6412. if (!ambiguous_destination && new_cat_id.notNull() &&
  6413. gInventory.getCategory(new_cat_id) && new_cat_id != trash &&
  6414. !gInventory.isObjectDescendentOf(new_cat_id, trash) &&
  6415. !gInventory.isObjectDescendentOf(new_cat_id, library))
  6416. {
  6417. if (category_id.isNull())
  6418. {
  6419. category_id = new_cat_id;
  6420. }
  6421. else if (category_id != new_cat_id)
  6422. {
  6423. // We have found two potential destinations.
  6424. ambiguous_destination = true;
  6425. }
  6426. }
  6427. }
  6428. if (ambiguous_destination || category_id.isNull())
  6429. {
  6430. // Use the default "Objects" category.
  6431. category_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_OBJECT);
  6432. }
  6433. LLSD payload;
  6434. payload["folder_id"] = category_id;
  6435. LLNotification::Params params("ConfirmObjectTakeLock");
  6436. params.payload(payload).functor(confirm_take);
  6437. if (locked_but_takeable_object || !you_own_everything)
  6438. {
  6439. if (locked_but_takeable_object && you_own_everything)
  6440. {
  6441. params.name("ConfirmObjectTakeLock");
  6442. }
  6443. else if (!locked_but_takeable_object && !you_own_everything)
  6444. {
  6445. params.name("ConfirmObjectTakeNoOwn");
  6446. }
  6447. else
  6448. {
  6449. params.name("ConfirmObjectTakeLockNoOwn");
  6450. }
  6451. gNotifications.add(params);
  6452. }
  6453. else
  6454. {
  6455. gNotifications.forceResponse(params, 0);
  6456. }
  6457. }
  6458. // This is a small helper function to determine if we have a buy or a take in
  6459. // the selection. This method is to help with the aliasing problems of putting
  6460. // buy and take in the same pie menu space. After a fair amont of discussion,
  6461. // it was determined to prefer buy over take. The reasoning follows from the
  6462. // fact that when users walk up to buy something, they will click on one or
  6463. // more items. Thus, if anything is for sale, it becomes a buy operation, and
  6464. // the server will group all of the buy items, and copyable/modifiable items
  6465. // into one package and give the end user as much as the permissions will
  6466. // allow. If the user wanted to take something, they will select fewer and
  6467. // fewer items until only 'takeable' items are left. The one exception is if
  6468. // you own everything in the selection that is for sale, in this case, you
  6469. // cannot buy stuff from yourself, so you can take it.
  6470. // Returns true if selection is a 'buy', false if selection is a 'take'
  6471. bool is_selection_buy_not_take()
  6472. {
  6473. for (LLObjectSelection::root_iterator
  6474. iter = gSelectMgr.getSelection()->root_begin(),
  6475. end = gSelectMgr.getSelection()->root_end();
  6476. iter != end; ++iter)
  6477. {
  6478. LLSelectNode* node = *iter;
  6479. if (!node) continue; // Paranoia
  6480. LLViewerObject* obj = node->getObject();
  6481. if (obj && !obj->permYouOwner() && node->mSaleInfo.isForSale())
  6482. {
  6483. // You do not own the object and it is for sale thus, it is a buy
  6484. return true;
  6485. }
  6486. }
  6487. return false;
  6488. }
  6489. S32 selection_price()
  6490. {
  6491. S32 total_price = 0;
  6492. for (LLObjectSelection::root_iterator
  6493. iter = gSelectMgr.getSelection()->root_begin(),
  6494. end = gSelectMgr.getSelection()->root_end();
  6495. iter != end; ++iter)
  6496. {
  6497. LLSelectNode* node = *iter;
  6498. if (!node) continue; // Paranoia
  6499. LLViewerObject* obj = node->getObject();
  6500. if (obj && !(obj->permYouOwner()) && (node->mSaleInfo.isForSale()))
  6501. {
  6502. // you do not own the object and it is for sale.
  6503. // Add its price.
  6504. total_price += node->mSaleInfo.getSalePrice();
  6505. }
  6506. }
  6507. return total_price;
  6508. }
  6509. void handle_buy_contents(LLSaleInfo sale_info)
  6510. {
  6511. LLFloaterBuyContents::show(sale_info);
  6512. }
  6513. // Also called from lltoolpie.cpp
  6514. void handle_buy(void*)
  6515. {
  6516. if (gSelectMgr.getSelection()->isEmpty()) return;
  6517. LLSaleInfo sale_info;
  6518. if (!gSelectMgr.selectGetSaleInfo(sale_info))
  6519. {
  6520. return;
  6521. }
  6522. if (sale_info.getSaleType() == LLSaleInfo::FS_CONTENTS)
  6523. {
  6524. handle_buy_contents(sale_info);
  6525. }
  6526. else
  6527. {
  6528. handle_buy_object(sale_info);
  6529. }
  6530. }
  6531. class LLToolsBuyOrTake final : public view_listener_t
  6532. {
  6533. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6534. {
  6535. if (gSelectMgr.getSelection()->isEmpty())
  6536. {
  6537. return true;
  6538. }
  6539. if (is_selection_buy_not_take())
  6540. {
  6541. S32 total_price = selection_price();
  6542. if (can_afford_transaction(total_price))
  6543. {
  6544. handle_buy(NULL);
  6545. }
  6546. else
  6547. {
  6548. LLFloaterBuyCurrency::buyCurrency("Buying this costs",
  6549. total_price);
  6550. }
  6551. }
  6552. else
  6553. {
  6554. handle_take();
  6555. }
  6556. return true;
  6557. }
  6558. };
  6559. // Also called in llfloaterpathfindingobjects.cpp
  6560. bool visible_take_object()
  6561. {
  6562. return !is_selection_buy_not_take() && enable_take();
  6563. }
  6564. class LLToolsEnableBuyOrTake final : public view_listener_t
  6565. {
  6566. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6567. {
  6568. // Do not run this before the menu are fully initialized because the
  6569. // static LLView pointer to menu_object_take can't be properly
  6570. // initialized while the pie menus are built which happens before the
  6571. // main menu items are defined.
  6572. if (!gMenusInitialized) return true;
  6573. bool is_buy = is_selection_buy_not_take();
  6574. bool new_value = is_buy ? enable_buy() : enable_take();
  6575. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  6576. // Update label
  6577. LLSD label;
  6578. std::string buy_text;
  6579. std::string take_text;
  6580. std::string param = userdata["data"].asString();
  6581. std::string::size_type offset = param.find(",");
  6582. if (offset != param.npos)
  6583. {
  6584. buy_text = param.substr(0, offset);
  6585. take_text = param.substr(offset + 1);
  6586. }
  6587. if (is_buy)
  6588. {
  6589. label = LLSD(buy_text);
  6590. }
  6591. else
  6592. {
  6593. label = LLSD(take_text);
  6594. }
  6595. // Using static pointers prevents thousands of recursive calls to
  6596. // getChild<T>() each time a menu is pulled down !
  6597. static LLView* pie_object_take =
  6598. gMenuHolderp->getChild<LLView>("Pie Object Take");
  6599. pie_object_take->setValue(label);
  6600. static LLView* menu_object_take =
  6601. gMenuHolderp->getChild<LLView>("Menu Object Take");
  6602. menu_object_take->setValue(label);
  6603. return true;
  6604. }
  6605. };
  6606. bool callback_show_buy_currency(const LLSD& notification, const LLSD& response)
  6607. {
  6608. if (LLNotification::getSelectedOption(notification, response) == 0)
  6609. {
  6610. llinfos << "Loading page " << BUY_CURRENCY_URL << llendl;
  6611. LLWeb::loadURL(BUY_CURRENCY_URL);
  6612. }
  6613. return false;
  6614. }
  6615. void show_buy_currency(const char* extra)
  6616. {
  6617. std::ostringstream mesg;
  6618. if (extra)
  6619. {
  6620. mesg << extra << "\n \n";
  6621. }
  6622. mesg << "Go to " << BUY_CURRENCY_URL
  6623. << "\nfor information on purchasing currency ?";
  6624. LLSD args;
  6625. if (extra)
  6626. {
  6627. args["EXTRA"] = extra;
  6628. }
  6629. args["URL"] = BUY_CURRENCY_URL;
  6630. gNotifications.add("PromptGoToCurrencyPage", args, LLSD(),
  6631. callback_show_buy_currency);
  6632. }
  6633. class LLObjectBuy final : public view_listener_t
  6634. {
  6635. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6636. {
  6637. handle_buy(NULL);
  6638. return true;
  6639. }
  6640. };
  6641. class LLToolsSaveToObjectInventory final : public view_listener_t
  6642. {
  6643. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6644. {
  6645. LLSelectNode* node = gSelectMgr.getSelection()->getFirstRootNode();
  6646. if (node && node->mValid && node->mFromTaskID.notNull())
  6647. {
  6648. // *TODO: check to see if the fromtaskid object exists.
  6649. derez_objects(DRD_SAVE_INTO_TASK_INVENTORY, node->mFromTaskID);
  6650. }
  6651. return true;
  6652. }
  6653. };
  6654. // Round the position of all root objects to the grid
  6655. class LLToolsSnapObjectXY final : public view_listener_t
  6656. {
  6657. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6658. {
  6659. F64 snap_size = (F64)gSavedSettings.getF32("GridResolution");
  6660. for (LLObjectSelection::root_iterator
  6661. iter = gSelectMgr.getSelection()->root_begin(),
  6662. end = gSelectMgr.getSelection()->root_end();
  6663. iter != end; ++iter)
  6664. {
  6665. LLSelectNode* node = *iter;
  6666. if (!node) continue; // Paranoia
  6667. LLViewerObject* obj = node->getObject();
  6668. if (obj->permModify())
  6669. {
  6670. LLVector3d pos_global = obj->getPositionGlobal();
  6671. F64 round_x = fmod(pos_global.mdV[VX], snap_size);
  6672. if (round_x < snap_size * 0.5)
  6673. {
  6674. // closer to round down
  6675. pos_global.mdV[VX] -= round_x;
  6676. }
  6677. else
  6678. {
  6679. // closer to round up
  6680. pos_global.mdV[VX] -= round_x;
  6681. pos_global.mdV[VX] += snap_size;
  6682. }
  6683. F64 round_y = fmod(pos_global.mdV[VY], snap_size);
  6684. if (round_y < snap_size * 0.5)
  6685. {
  6686. pos_global.mdV[VY] -= round_y;
  6687. }
  6688. else
  6689. {
  6690. pos_global.mdV[VY] -= round_y;
  6691. pos_global.mdV[VY] += snap_size;
  6692. }
  6693. obj->setPositionGlobal(pos_global, false);
  6694. }
  6695. }
  6696. gSelectMgr.sendMultipleUpdate(UPD_POSITION);
  6697. return true;
  6698. }
  6699. };
  6700. // Determine if the option to cycle between linked prims is shown
  6701. class LLToolsEnableSelectNextPart final : public view_listener_t
  6702. {
  6703. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6704. {
  6705. bool new_value = (!gSelectMgr.getSelection()->isEmpty() &&
  6706. gSavedSettings.getBool("EditLinkedParts")) ||
  6707. gToolMgr.isCurrentTool(&gToolFace);
  6708. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  6709. return true;
  6710. }
  6711. };
  6712. void select_face_or_linked_prim(const std::string& action)
  6713. {
  6714. bool cycle_faces = gToolMgr.isCurrentTool(&gToolFace);
  6715. bool cycle_linked = gSavedSettings.getBool("EditLinkedParts");
  6716. if (!cycle_faces && !cycle_linked) return;
  6717. bool fwd = action == "next";
  6718. bool prev = action == "previous";
  6719. bool ifwd = action == "includenext";
  6720. bool iprev = action == "includeprevious";
  6721. LLViewerObject* to_select = NULL;
  6722. bool restart_face_on_part = !cycle_faces;
  6723. S32 new_te = 0;
  6724. if (cycle_faces)
  6725. {
  6726. // Cycle through faces of current selection, if end is reached, switch
  6727. // to next part (if present)
  6728. LLSelectNode* nodep = gSelectMgr.getSelection()->getFirstNode();
  6729. if (!nodep) return;
  6730. to_select = nodep->getObject();
  6731. if (!to_select) return;
  6732. S32 te_count = to_select->getNumTEs();
  6733. S32 selected_te = nodep->getLastOperatedTE();
  6734. if (fwd || ifwd)
  6735. {
  6736. if (selected_te < 0)
  6737. {
  6738. new_te = 0;
  6739. }
  6740. else if (selected_te + 1 < te_count)
  6741. {
  6742. // Select next face
  6743. new_te = selected_te + 1;
  6744. }
  6745. else
  6746. {
  6747. // Restart from first face on next part
  6748. restart_face_on_part = true;
  6749. }
  6750. }
  6751. else if (prev || iprev)
  6752. {
  6753. if (selected_te > te_count)
  6754. {
  6755. new_te = te_count - 1;
  6756. }
  6757. else if (selected_te > 0)
  6758. {
  6759. // Select previous face
  6760. new_te = selected_te - 1;
  6761. }
  6762. else
  6763. {
  6764. // Restart from last face on next part
  6765. restart_face_on_part = true;
  6766. }
  6767. }
  6768. }
  6769. S32 object_count = gSelectMgr.getSelection()->getObjectCount();
  6770. if (cycle_linked && object_count && restart_face_on_part)
  6771. {
  6772. LLViewerObject* selected = gSelectMgr.getSelection()->getFirstObject();
  6773. if (selected && selected->getRootEdit())
  6774. {
  6775. LLViewerObject::child_list_t children =
  6776. selected->getRootEdit()->getChildren();
  6777. // We need root in the list too
  6778. children.push_front(selected->getRootEdit());
  6779. for (LLViewerObject::child_list_t::iterator iter = children.begin();
  6780. iter != children.end(); ++iter)
  6781. {
  6782. if ((*iter)->isSelected())
  6783. {
  6784. if (object_count > 1 && (fwd || prev))
  6785. {
  6786. // Multiple selection, find first or last selected if
  6787. // not include
  6788. to_select = *iter;
  6789. if (fwd)
  6790. {
  6791. // Stop searching if going forward; repeat to get
  6792. // last hit if backward
  6793. break;
  6794. }
  6795. }
  6796. else if (object_count == 1 || ifwd || iprev)
  6797. {
  6798. // Single selection or include
  6799. if (fwd || ifwd)
  6800. {
  6801. ++iter;
  6802. while (iter != children.end() &&
  6803. ((*iter)->isAvatar() ||
  6804. (ifwd && (*iter)->isSelected())))
  6805. {
  6806. // Skip sitting avatars and selected if include
  6807. ++iter;
  6808. }
  6809. }
  6810. else // Backward
  6811. {
  6812. if (iter == children.begin())
  6813. {
  6814. iter = children.end();
  6815. }
  6816. --iter;
  6817. while (iter != children.begin() &&
  6818. ((*iter)->isAvatar() ||
  6819. (iprev && (*iter)->isSelected())))
  6820. {
  6821. // Skip sitting avatars and selected if include
  6822. --iter;
  6823. }
  6824. }
  6825. if (iter == children.end())
  6826. {
  6827. iter = children.begin();
  6828. }
  6829. to_select = *iter;
  6830. break;
  6831. }
  6832. }
  6833. }
  6834. }
  6835. }
  6836. if (to_select)
  6837. {
  6838. if (gFloaterToolsp && gFocusMgr.childHasKeyboardFocus(gFloaterToolsp))
  6839. {
  6840. // Force edit toolbox to commit any changes
  6841. gFocusMgr.setKeyboardFocus(NULL);
  6842. }
  6843. if (fwd || prev)
  6844. {
  6845. gSelectMgr.deselectAll();
  6846. }
  6847. if (cycle_faces)
  6848. {
  6849. if (restart_face_on_part)
  6850. {
  6851. new_te = fwd || ifwd ? 0 : to_select->getNumTEs() - 1;
  6852. }
  6853. gSelectMgr.addAsIndividual(to_select, new_te, false);
  6854. }
  6855. else
  6856. {
  6857. gSelectMgr.selectObjectOnly(to_select);
  6858. }
  6859. }
  6860. }
  6861. // Cycle selection through linked children in selected object.
  6862. // *FIXME: Order of children list is not always the same as sim's idea of link
  6863. // order. Need link position added to sim messages to address this.
  6864. class LLToolsSelectNextPartFace final : public view_listener_t
  6865. {
  6866. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6867. {
  6868. select_face_or_linked_prim(userdata.asString());
  6869. return true;
  6870. }
  6871. };
  6872. class LLToolsEnableLink final : public view_listener_t
  6873. {
  6874. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6875. {
  6876. bool new_value = gSelectMgr.enableLinkObjects();
  6877. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  6878. return true;
  6879. }
  6880. };
  6881. class LLToolsLink final : public view_listener_t
  6882. {
  6883. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6884. {
  6885. gSelectMgr.linkObjects();
  6886. return true;
  6887. }
  6888. };
  6889. class LLToolsEnableUnlink final : public view_listener_t
  6890. {
  6891. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6892. {
  6893. bool new_value = gSelectMgr.enableUnlinkObjects();
  6894. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  6895. return true;
  6896. }
  6897. };
  6898. class LLToolsUnlink final : public view_listener_t
  6899. {
  6900. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6901. {
  6902. gSelectMgr.unlinkObjects();
  6903. return true;
  6904. }
  6905. };
  6906. class LLToolsEnablePathfinding final : public view_listener_t
  6907. {
  6908. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6909. {
  6910. bool newvalue =
  6911. LLPathfindingManager::getInstance()->isPathfindingEnabledForCurrentRegion();
  6912. //MK
  6913. if (gRLenabled && gRLInterface.mContainsEdit)
  6914. {
  6915. newvalue = false;
  6916. }
  6917. //mk
  6918. gMenuHolderp->findControl(userdata["control"].asString())->setValue(newvalue);
  6919. return true;
  6920. }
  6921. };
  6922. class LLWorldStopAllAnimations final : public view_listener_t
  6923. {
  6924. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6925. {
  6926. gAgent.stopCurrentAnimations();
  6927. return true;
  6928. }
  6929. };
  6930. class LLWorldReleaseKeys final : public view_listener_t
  6931. {
  6932. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6933. {
  6934. //MK
  6935. if (gRLenabled && gRLInterface.mContainsDetach)
  6936. {
  6937. return false;
  6938. }
  6939. //mk
  6940. gAgent.forceReleaseControls();
  6941. return true;
  6942. }
  6943. };
  6944. class LLWorldEnableReleaseKeys final : public view_listener_t
  6945. {
  6946. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6947. {
  6948. gMenuHolderp->findControl(userdata["control"].asString())->setValue(gAgent.anyControlGrabbed());
  6949. return true;
  6950. }
  6951. };
  6952. #ifdef SEND_HINGES
  6953. void handle_hinge(void*)
  6954. {
  6955. gSelectMgr.sendHinge(1);
  6956. }
  6957. void handle_ptop(void*)
  6958. {
  6959. gSelectMgr.sendHinge(2);
  6960. }
  6961. void handle_lptop(void*)
  6962. {
  6963. gSelectMgr.sendHinge(3);
  6964. }
  6965. void handle_wheel(void*)
  6966. {
  6967. gSelectMgr.sendHinge(4);
  6968. }
  6969. void handle_dehinge(void*)
  6970. {
  6971. gSelectMgr.sendDehinge();
  6972. }
  6973. bool enable_dehinge(void*)
  6974. {
  6975. LLViewerObject* obj = gSelectMgr.getSelection()->getFirstEditableObject();
  6976. return obj && !obj->isAttachment();
  6977. }
  6978. #endif
  6979. class LLEditEnableCut final : public view_listener_t
  6980. {
  6981. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6982. {
  6983. bool new_value = gEditMenuHandlerp && gEditMenuHandlerp->canCut();
  6984. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  6985. return true;
  6986. }
  6987. };
  6988. class LLEditCut final : public view_listener_t
  6989. {
  6990. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  6991. {
  6992. if (gEditMenuHandlerp && gEditMenuHandlerp->canCut())
  6993. {
  6994. gEditMenuHandlerp->cut();
  6995. }
  6996. return true;
  6997. }
  6998. };
  6999. class LLEditEnableCopy final : public view_listener_t
  7000. {
  7001. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7002. {
  7003. bool new_value = gEditMenuHandlerp && gEditMenuHandlerp->canCopy();
  7004. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  7005. return true;
  7006. }
  7007. };
  7008. class LLEditCopy final : public view_listener_t
  7009. {
  7010. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7011. {
  7012. if (gEditMenuHandlerp && gEditMenuHandlerp->canCopy())
  7013. {
  7014. gEditMenuHandlerp->copy();
  7015. }
  7016. return true;
  7017. }
  7018. };
  7019. class LLEditEnablePaste final : public view_listener_t
  7020. {
  7021. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7022. {
  7023. bool new_value = gEditMenuHandlerp && gEditMenuHandlerp->canPaste();
  7024. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  7025. return true;
  7026. }
  7027. };
  7028. class LLEditPaste final : public view_listener_t
  7029. {
  7030. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7031. {
  7032. if (gEditMenuHandlerp && gEditMenuHandlerp->canPaste())
  7033. {
  7034. gEditMenuHandlerp->paste();
  7035. }
  7036. return true;
  7037. }
  7038. };
  7039. class LLEditEnableDelete final : public view_listener_t
  7040. {
  7041. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7042. {
  7043. bool new_value = gEditMenuHandlerp && gEditMenuHandlerp->canDoDelete();
  7044. //MK
  7045. if (gRLenabled && gRLInterface.mContainsRez &&
  7046. // the Delete key must not be inhibited for text:
  7047. gEditMenuHandlerp == &gSelectMgr)
  7048. {
  7049. new_value = false;
  7050. }
  7051. //mk
  7052. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  7053. return true;
  7054. }
  7055. };
  7056. class LLEditDelete final : public view_listener_t
  7057. {
  7058. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7059. {
  7060. // If a text field can do a deletion, it gets precedence over deleting
  7061. // an object in the world.
  7062. if (gEditMenuHandlerp && gEditMenuHandlerp->canDoDelete())
  7063. {
  7064. gEditMenuHandlerp->doDelete();
  7065. }
  7066. // Close any pie/context menus when done
  7067. gMenuHolderp->hideMenus();
  7068. // When deleting an object we may not actually be done. Keep selection
  7069. // so we know what to delete when confirmation is needed about the
  7070. // delete.
  7071. gPieObjectp->hide(true);
  7072. return true;
  7073. }
  7074. };
  7075. // Also called in llfloaterpathfindingobjects.
  7076. bool enable_object_delete()
  7077. {
  7078. bool can_delete = gSelectMgr.canDoDelete();
  7079. //MK
  7080. if (gRLenabled && gRLInterface.mContainsRez)
  7081. {
  7082. can_delete = false;
  7083. }
  7084. //mk
  7085. return can_delete;
  7086. }
  7087. class LLObjectEnableDelete final : public view_listener_t
  7088. {
  7089. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7090. {
  7091. bool new_value = enable_object_delete();
  7092. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  7093. return true;
  7094. }
  7095. };
  7096. class LLEditSearch final : public view_listener_t
  7097. {
  7098. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7099. {
  7100. HBFloaterSearch::toggle();
  7101. return true;
  7102. }
  7103. };
  7104. // Also called in llfloaterpathfindingobjects.
  7105. void handle_object_delete()
  7106. {
  7107. gSelectMgr.doDelete();
  7108. // and close any pie/context menus when done
  7109. gMenuHolderp->hideMenus();
  7110. // When deleting an object we may not actually be done. Keep selection so
  7111. // we know what to delete when confirmation is needed about the delete
  7112. gPieObjectp->hide(true);
  7113. return;
  7114. }
  7115. class LLObjectDelete final : public view_listener_t
  7116. {
  7117. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7118. {
  7119. handle_object_delete();
  7120. return true;
  7121. }
  7122. };
  7123. class LLViewEnableJoystickFlycam final : public view_listener_t
  7124. {
  7125. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7126. {
  7127. bool new_value = gSavedSettings.getBool("JoystickEnabled") &&
  7128. gSavedSettings.getBool("JoystickFlycamEnabled");
  7129. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  7130. return true;
  7131. }
  7132. };
  7133. class LLViewEnableLastChatter final : public view_listener_t
  7134. {
  7135. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7136. {
  7137. // *TODO: add check that last chatter is in range
  7138. bool new_value = gAgent.cameraThirdPerson() &&
  7139. gAgent.getLastChatter().notNull();
  7140. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  7141. return true;
  7142. }
  7143. };
  7144. class LLViewEnableNearbyMedia final : public view_listener_t
  7145. {
  7146. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7147. {
  7148. static LLCachedControl<bool> media_on(gSavedSettings,
  7149. "EnableStreamingMedia");
  7150. static LLCachedControl<bool> music_on(gSavedSettings,
  7151. "EnableStreamingMusic");
  7152. bool new_value = media_on || music_on;
  7153. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  7154. return true;
  7155. }
  7156. };
  7157. class LLWorldToggleRadar: public view_listener_t
  7158. {
  7159. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7160. {
  7161. HBFloaterRadar::toggleInstance();
  7162. return true;
  7163. }
  7164. };
  7165. //MK
  7166. class LLViewEnableBeacons final : public view_listener_t
  7167. {
  7168. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7169. {
  7170. bool new_value = !gRLenabled || !gRLInterface.mContainsEdit;
  7171. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  7172. return true;
  7173. }
  7174. };
  7175. //mk
  7176. class LLEditEnableDeselect final : public view_listener_t
  7177. {
  7178. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7179. {
  7180. bool new_value = gEditMenuHandlerp &&
  7181. gEditMenuHandlerp->canDeselect();
  7182. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  7183. return true;
  7184. }
  7185. };
  7186. class LLEditDeselect final : public view_listener_t
  7187. {
  7188. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7189. {
  7190. if (gEditMenuHandlerp && gEditMenuHandlerp->canDeselect())
  7191. {
  7192. gEditMenuHandlerp->deselect();
  7193. }
  7194. return true;
  7195. }
  7196. };
  7197. class LLEditEnableSelectAll final : public view_listener_t
  7198. {
  7199. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7200. {
  7201. bool new_value = gEditMenuHandlerp &&
  7202. gEditMenuHandlerp->canSelectAll();
  7203. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  7204. return true;
  7205. }
  7206. };
  7207. class LLEditSelectAll final : public view_listener_t
  7208. {
  7209. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7210. {
  7211. if (gEditMenuHandlerp && gEditMenuHandlerp->canSelectAll())
  7212. {
  7213. gEditMenuHandlerp->selectAll();
  7214. }
  7215. return true;
  7216. }
  7217. };
  7218. class LLEditEnableUndo final : public view_listener_t
  7219. {
  7220. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7221. {
  7222. bool new_value = gEditMenuHandlerp && gEditMenuHandlerp->canUndo();
  7223. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  7224. return true;
  7225. }
  7226. };
  7227. class LLEditUndo final : public view_listener_t
  7228. {
  7229. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7230. {
  7231. if (gEditMenuHandlerp && gEditMenuHandlerp->canUndo())
  7232. {
  7233. gEditMenuHandlerp->undo();
  7234. }
  7235. return true;
  7236. }
  7237. };
  7238. class LLEditEnableRedo final : public view_listener_t
  7239. {
  7240. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7241. {
  7242. bool new_value = gEditMenuHandlerp && gEditMenuHandlerp->canRedo();
  7243. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  7244. return true;
  7245. }
  7246. };
  7247. class LLEditRedo final : public view_listener_t
  7248. {
  7249. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7250. {
  7251. if (gEditMenuHandlerp && gEditMenuHandlerp->canRedo())
  7252. {
  7253. gEditMenuHandlerp->redo();
  7254. }
  7255. return true;
  7256. }
  7257. };
  7258. void show_debug_menus()
  7259. {
  7260. // This can get called at login screen where there is no menu so only
  7261. // toggle it if one exists
  7262. if (gMenuBarViewp)
  7263. {
  7264. gMenuBarViewp->setItemVisible(CLIENT_MENU_NAME, true);
  7265. gMenuBarViewp->setItemEnabled(CLIENT_MENU_NAME, true);
  7266. // Server ('Admin') menu hidden when not in godmode.
  7267. bool show_server_menu = gAgent.getGodLevel() > GOD_NOT;
  7268. gMenuBarViewp->setItemVisible(SERVER_MENU_NAME, show_server_menu);
  7269. gMenuBarViewp->setItemEnabled(SERVER_MENU_NAME, show_server_menu);
  7270. gMenuBarViewp->arrange(); // clean-up positioning
  7271. }
  7272. }
  7273. #if 0
  7274. LLUUID gExporterRequestID;
  7275. std::string gExportDirectory;
  7276. LLUploadDialog* gExportDialog = NULL;
  7277. void handle_export_selected(void*)
  7278. {
  7279. LLObjectSelectionHandle selection = gSelectMgr.getSelection();
  7280. if (selection->isEmpty() || !gAgent.getRegion())
  7281. {
  7282. return;
  7283. }
  7284. llinfos << "Exporting selected objects:" << llendl;
  7285. gExporterRequestID.generate();
  7286. gExportDirectory = "";
  7287. LLMessageSystem* msg = gMessageSystemp;
  7288. msg->newMessageFast(_PREHASH_ObjectExportSelected);
  7289. msg->nextBlockFast(_PREHASH_AgentData);
  7290. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  7291. msg->addUUIDFast(_PREHASH_RequestID, gExporterRequestID);
  7292. msg->addS16Fast(_PREHASH_VolumeDetail, 4);
  7293. for (LLObjectSelection::root_iterator
  7294. iter = gSelectMgr.getSelection()->root_begin(),
  7295. end = gSelectMgr.getSelection()->root_end();
  7296. iter != end; ++iter)
  7297. {
  7298. LLSelectNode* node = *iter;
  7299. if (!node) continue; // Paranoia
  7300. LLViewerObject* object = node->getObject();
  7301. msg->nextBlockFast(_PREHASH_ObjectData);
  7302. msg->addUUIDFast(_PREHASH_ObjectID, object->getID());
  7303. llinfos << "Object: " << object->getID() << llendl;
  7304. }
  7305. msg->sendReliable(gAgent.getRegionHost());
  7306. gExportDialog =
  7307. LLUploadDialog::modalUploadDialog("Exporting selected objects...");
  7308. }
  7309. #endif
  7310. class LLWorldSetHomeLocation final : public view_listener_t
  7311. {
  7312. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7313. {
  7314. // We just send the message and let the server check for failure cases
  7315. // server will echo back a "Home position set." alert if it succeeds
  7316. // and the home location screencapture happens when that alert is
  7317. // received
  7318. gAgent.setStartPosition(START_LOCATION_ID_HOME);
  7319. return true;
  7320. }
  7321. };
  7322. class LLWorldTeleportHome final : public view_listener_t
  7323. {
  7324. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7325. {
  7326. gAgent.teleportHome();
  7327. return true;
  7328. }
  7329. };
  7330. class LLWorldTPtoGround final : public view_listener_t
  7331. {
  7332. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7333. {
  7334. if (isAgentAvatarValid() && gAgent.getRegion())
  7335. {
  7336. LLVector3 pos = gAgent.getPositionAgent();
  7337. pos.mV[VZ] = gWorld.resolveLandHeightAgent(pos);
  7338. LLVector3d pos_global =
  7339. from_region_handle(gAgent.getRegionHandle());
  7340. pos_global += LLVector3d((F64)pos.mV[VX], (F64)pos.mV[VY],
  7341. (F64)pos.mV[VZ]);
  7342. gAgent.teleportViaLocation(pos_global);
  7343. }
  7344. return true;
  7345. }
  7346. };
  7347. class LLWorldAlwaysRun final : public view_listener_t
  7348. {
  7349. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7350. {
  7351. // as well as altering the default walk-vs-run state,
  7352. // we also change the *current* walk-vs-run state.
  7353. if (gAgent.getAlwaysRun())
  7354. {
  7355. gAgent.clearAlwaysRun();
  7356. gAgent.clearRunning();
  7357. }
  7358. //MK
  7359. else if (!gRLenabled || !gRLInterface.mContainsAlwaysRun)
  7360. //mk
  7361. //// else
  7362. {
  7363. gAgent.setAlwaysRun();
  7364. gAgent.setRunning();
  7365. }
  7366. // tell the simulator.
  7367. gAgent.sendWalkRun(gAgent.getAlwaysRun());
  7368. return true;
  7369. }
  7370. };
  7371. class LLWorldCheckAlwaysRun final : public view_listener_t
  7372. {
  7373. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7374. {
  7375. bool new_value = gAgent.getAlwaysRun();
  7376. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  7377. return true;
  7378. }
  7379. };
  7380. class LLWorldSitOnGround final : public view_listener_t
  7381. {
  7382. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7383. {
  7384. sit_on_ground();
  7385. return true;
  7386. }
  7387. };
  7388. class LLWorldEnableSitOnGround final : public view_listener_t
  7389. {
  7390. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7391. {
  7392. bool new_value = isAgentAvatarValid() && !gAgentAvatarp->mIsSitting;
  7393. //MK
  7394. if (gRLenabled &&
  7395. (gRLInterface.contains("sit") || gRLInterface.mContainsInteract))
  7396. {
  7397. new_value = false;
  7398. }
  7399. //mk
  7400. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  7401. return true;
  7402. }
  7403. };
  7404. class LLWorldSetAway final : public view_listener_t
  7405. {
  7406. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7407. {
  7408. if (gAgent.getAFK())
  7409. {
  7410. gAgent.clearAFK();
  7411. }
  7412. else
  7413. {
  7414. gAgent.setAFK();
  7415. }
  7416. return true;
  7417. }
  7418. };
  7419. class LLWorldSetBusy final : public view_listener_t
  7420. {
  7421. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7422. {
  7423. if (gAgent.getBusy())
  7424. {
  7425. gAgent.clearBusy();
  7426. }
  7427. else
  7428. {
  7429. gAgent.setBusy();
  7430. gNotifications.add("BusyModeSet");
  7431. }
  7432. return true;
  7433. }
  7434. };
  7435. class LLWorldSetAutoReply final : public view_listener_t
  7436. {
  7437. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7438. {
  7439. if (gAgent.getAutoReply())
  7440. {
  7441. gAgent.clearAutoReply();
  7442. }
  7443. else
  7444. {
  7445. gAgent.setAutoReply();
  7446. }
  7447. return true;
  7448. }
  7449. };
  7450. class LLWorldCreateLandmark final : public view_listener_t
  7451. {
  7452. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7453. {
  7454. //MK
  7455. if (gRLenabled && gRLInterface.mContainsShowloc)
  7456. {
  7457. return true;
  7458. }
  7459. //mk
  7460. LLViewerRegion* agent_region = gAgent.getRegion();
  7461. if (!agent_region)
  7462. {
  7463. llwarns << "No agent region" << llendl;
  7464. return true;
  7465. }
  7466. LLParcel* agent_parcel = gViewerParcelMgr.getAgentParcel();
  7467. if (!agent_parcel)
  7468. {
  7469. llwarns << "No agent parcel" << llendl;
  7470. return true;
  7471. }
  7472. if (!agent_parcel->getAllowLandmark() &&
  7473. !LLViewerParcelMgr::isParcelOwnedByAgent(agent_parcel,
  7474. GP_LAND_ALLOW_LANDMARK))
  7475. {
  7476. gNotifications.add("CannotCreateLandmarkNotOwner");
  7477. return true;
  7478. }
  7479. LLUUID folder_id;
  7480. folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LANDMARK);
  7481. std::string pos_string;
  7482. gAgent.buildLocationString(pos_string);
  7483. create_inventory_item(folder_id, LLTransactionID::tnull,
  7484. pos_string, pos_string, // name, desc
  7485. LLAssetType::AT_LANDMARK,
  7486. LLInventoryType::IT_LANDMARK,
  7487. NO_INV_SUBTYPE, PERM_ALL,
  7488. new LLCreateLandmarkCallback);
  7489. return true;
  7490. }
  7491. };
  7492. class LLToolsLookAtSelection final : public view_listener_t
  7493. {
  7494. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7495. {
  7496. constexpr F32 PADDING_FACTOR = 2.f;
  7497. bool zoom = userdata.asString() == "zoom";
  7498. if (!gSelectMgr.getSelection()->isEmpty())
  7499. {
  7500. gAgent.setFocusOnAvatar(false);
  7501. LLBBox selection_bbox = gSelectMgr.getBBoxOfSelection();
  7502. F32 cam_wiew = gViewerCamera.getView();
  7503. F32 cam_aspect = gViewerCamera.getAspect();
  7504. F32 angle_of_view = llmax(0.1f,
  7505. cam_aspect > 1.f ? cam_wiew * cam_aspect
  7506. : cam_wiew);
  7507. F32 distance = selection_bbox.getExtentLocal().length() *
  7508. PADDING_FACTOR / atanf(angle_of_view);
  7509. LLVector3 obj_to_cam = gViewerCamera.getOrigin() -
  7510. selection_bbox.getCenterAgent();
  7511. obj_to_cam.normalize();
  7512. LLUUID object_id;
  7513. if (gSelectMgr.getSelection()->getPrimaryObject())
  7514. {
  7515. object_id = gSelectMgr.getSelection()->getPrimaryObject()->mID;
  7516. }
  7517. if (zoom)
  7518. {
  7519. gAgent.setCameraPosAndFocusGlobal(gSelectMgr.getSelectionCenterGlobal() +
  7520. LLVector3d(obj_to_cam * distance),
  7521. gSelectMgr.getSelectionCenterGlobal(),
  7522. object_id);
  7523. }
  7524. else
  7525. {
  7526. gAgent.setFocusGlobal(gSelectMgr.getSelectionCenterGlobal(),
  7527. object_id);
  7528. }
  7529. }
  7530. return true;
  7531. }
  7532. };
  7533. void callback_invite_to_group(LLUUID group_id, void *user_data)
  7534. {
  7535. std::vector<LLUUID> agent_ids;
  7536. agent_ids.emplace_back(*(LLUUID *)user_data);
  7537. LLFloaterGroupInvite::showForGroup(group_id, &agent_ids);
  7538. }
  7539. void invite_to_group(const LLUUID& dest_id)
  7540. {
  7541. LLVOAvatar* dest = gObjectList.findAvatar(dest_id);
  7542. if (dest)
  7543. {
  7544. LLFloaterGroupPicker* widget;
  7545. widget = LLFloaterGroupPicker::show(callback_invite_to_group,
  7546. (void*)&dest_id);
  7547. if (widget)
  7548. {
  7549. widget->center();
  7550. widget->setPowersMask(GP_MEMBER_INVITE);
  7551. }
  7552. }
  7553. }
  7554. class LLAvatarInviteToGroup final : public view_listener_t
  7555. {
  7556. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7557. {
  7558. //MK
  7559. if (gRLenabled &&
  7560. (gRLInterface.mContainsShownames ||
  7561. gRLInterface.mContainsShownametags))
  7562. {
  7563. return false;
  7564. }
  7565. //mk
  7566. LLVOAvatar* avatar =
  7567. find_avatar_from_object(gSelectMgr.getSelection()->getPrimaryObject());
  7568. if (avatar)
  7569. {
  7570. invite_to_group(avatar->getID());
  7571. }
  7572. return true;
  7573. }
  7574. };
  7575. class LLAvatarRender final : public view_listener_t
  7576. {
  7577. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7578. {
  7579. std::string data = userdata.asString();
  7580. LLViewerObject* object = gSelectMgr.getSelection()->getPrimaryObject();
  7581. LLVOAvatar* avatar = find_avatar_from_object(object);
  7582. if (avatar)
  7583. {
  7584. if (data == "normal")
  7585. {
  7586. avatar->setVisualMuteSettings(LLVOAvatar::AV_RENDER_NORMALLY);
  7587. }
  7588. else if (data == "never")
  7589. {
  7590. avatar->setVisualMuteSettings(LLVOAvatar::AV_DO_NOT_RENDER);
  7591. }
  7592. else if (data == "always")
  7593. {
  7594. avatar->setVisualMuteSettings(LLVOAvatar::AV_ALWAYS_RENDER);
  7595. }
  7596. }
  7597. #if 0 // Avatar puppets "jelly-dollifying" does not work anyway...
  7598. LLVOAvatarPuppet* puppet = object->getPuppetAvatar();
  7599. if (puppet)
  7600. {
  7601. if (data == "normal")
  7602. {
  7603. puppet->setVisualMuteSettings(LLVOAvatar::AV_RENDER_NORMALLY);
  7604. }
  7605. else if (data == "never")
  7606. {
  7607. puppet->setVisualMuteSettings(LLVOAvatar::AV_DO_NOT_RENDER);
  7608. }
  7609. else if (data == "always")
  7610. {
  7611. puppet->setVisualMuteSettings(LLVOAvatar::AV_ALWAYS_RENDER);
  7612. }
  7613. }
  7614. #endif
  7615. return true;
  7616. }
  7617. };
  7618. class LLAvatarAddFriend final : public view_listener_t
  7619. {
  7620. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7621. {
  7622. //MK
  7623. if (gRLenabled &&
  7624. (gRLInterface.mContainsShownames ||
  7625. gRLInterface.mContainsShownametags))
  7626. {
  7627. return false;
  7628. }
  7629. //mk
  7630. LLVOAvatar* avatar =
  7631. find_avatar_from_object(gSelectMgr.getSelection()->getPrimaryObject());
  7632. if (avatar && !LLAvatarTracker::isAgentFriend(avatar->getID()))
  7633. {
  7634. LLAvatarActions::requestFriendshipDialog(avatar->getID());
  7635. }
  7636. return true;
  7637. }
  7638. };
  7639. bool complete_give_money(const LLSD& notification, const LLSD& response,
  7640. LLObjectSelectionHandle handle)
  7641. {
  7642. if (LLNotification::getSelectedOption(notification, response) == 0)
  7643. {
  7644. gAgent.clearBusy();
  7645. }
  7646. LLViewerObject* objectp = handle->getPrimaryObject();
  7647. // Show avatar's name if paying attachment
  7648. if (objectp && objectp->isAttachment())
  7649. {
  7650. while (objectp && !objectp->isAvatar())
  7651. {
  7652. objectp = (LLViewerObject*)objectp->getParent();
  7653. }
  7654. }
  7655. if (objectp)
  7656. {
  7657. if (objectp->isAvatar())
  7658. {
  7659. //MK
  7660. if (gRLenabled &&
  7661. (gRLInterface.mContainsShownames ||
  7662. gRLInterface.mContainsShownametags))
  7663. {
  7664. return false;
  7665. }
  7666. //mk
  7667. LLFloaterPay::payDirectly(&give_money, objectp->getID(), false);
  7668. }
  7669. else
  7670. {
  7671. LLFloaterPay::payViaObject(&give_money, objectp->getID());
  7672. }
  7673. }
  7674. return false;
  7675. }
  7676. bool handle_give_money_dialog()
  7677. {
  7678. LLNotification::Params params("BusyModePay");
  7679. params.functor(boost::bind(complete_give_money, _1, _2,
  7680. gSelectMgr.getSelection()));
  7681. if (gAgent.getBusy())
  7682. {
  7683. // warn users of being in busy mode during a transaction
  7684. gNotifications.add(params);
  7685. }
  7686. else
  7687. {
  7688. gNotifications.forceResponse(params, 1);
  7689. }
  7690. return true;
  7691. }
  7692. class LLPayObject final : public view_listener_t
  7693. {
  7694. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7695. {
  7696. return handle_give_money_dialog();
  7697. }
  7698. };
  7699. class LLEnablePayObject final : public view_listener_t
  7700. {
  7701. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7702. {
  7703. LLVOAvatar* avatar =
  7704. find_avatar_from_object(gSelectMgr.getSelection()->getPrimaryObject());
  7705. bool new_value = (avatar != NULL);
  7706. if (!new_value)
  7707. {
  7708. LLViewerObject* object =
  7709. gSelectMgr.getSelection()->getPrimaryObject();
  7710. if (object)
  7711. {
  7712. LLViewerObject* parent = (LLViewerObject*)object->getParent();
  7713. if (object->flagTakesMoney() ||
  7714. (parent && parent->flagTakesMoney()))
  7715. {
  7716. new_value = true;
  7717. }
  7718. }
  7719. }
  7720. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  7721. return true;
  7722. }
  7723. };
  7724. class LLObjectEnableSitOrStand final : public view_listener_t
  7725. {
  7726. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7727. {
  7728. // Do not run this before the menu are fully initialized because the
  7729. // static LLView pointer to object_sit can't be properly initialized
  7730. // while the pie menus are built which happens before the main menu
  7731. // items are defined.
  7732. if (!gMenusInitialized) return true;
  7733. bool new_value = false;
  7734. LLViewerObject* dest_object =
  7735. gSelectMgr.getSelection()->getPrimaryObject();
  7736. if (dest_object)
  7737. {
  7738. if (dest_object->getPCode() == LL_PCODE_VOLUME)
  7739. {
  7740. new_value = true;
  7741. }
  7742. //MK
  7743. if (gRLenabled)
  7744. {
  7745. if (gRLInterface.contains("sit") ||
  7746. gRLInterface.mContainsInteract)
  7747. {
  7748. new_value = false;
  7749. }
  7750. if (gRLInterface.mSittpMax < EXTREMUM)
  7751. {
  7752. LLPickInfo pick = gToolPie.getPick();
  7753. LLVector3 pos = dest_object->getPositionRegion() + pick.mObjectOffset;
  7754. pos -= gAgent.getPositionAgent();
  7755. if (pos.length() >= gRLInterface.mSittpMax)
  7756. {
  7757. new_value = false;
  7758. }
  7759. }
  7760. }
  7761. //mk
  7762. }
  7763. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  7764. // Update label
  7765. LLSD label;
  7766. std::string sit_text;
  7767. std::string stand_text;
  7768. std::string param = userdata["data"].asString();
  7769. std::string::size_type offset = param.find(",");
  7770. if (offset != param.npos)
  7771. {
  7772. sit_text = param.substr(0, offset);
  7773. stand_text = param.substr(offset + 1);
  7774. }
  7775. if (sitting_on_selection())
  7776. {
  7777. label = LLSD(stand_text);
  7778. }
  7779. else
  7780. {
  7781. LLSelectNode* node = gSelectMgr.getSelection()->getFirstRootNode();
  7782. if (node && node->mValid && !node->mSitName.empty())
  7783. {
  7784. label = LLSD(node->mSitName);
  7785. }
  7786. else
  7787. {
  7788. label = LLSD(sit_text);
  7789. }
  7790. }
  7791. // Using a static pointer prevents thousands of recursive calls to
  7792. // getChild<T>() each time a menu is pulled down !
  7793. static LLView* object_sit =
  7794. gMenuHolderp->getChild<LLView>("Object Sit");
  7795. object_sit->setValue(label);
  7796. return true;
  7797. }
  7798. };
  7799. class LLShowFloater final : public view_listener_t
  7800. {
  7801. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  7802. {
  7803. std::string floater_name = userdata.asString();
  7804. if (floater_name == "gestures")
  7805. {
  7806. LLFloaterGesture::toggleInstance();
  7807. }
  7808. else if (floater_name == "appearance")
  7809. {
  7810. if (gAgentWearables.areWearablesLoaded())
  7811. {
  7812. gAgent.changeCameraToCustomizeAvatar();
  7813. }
  7814. }
  7815. else if (floater_name == "outfitpicker")
  7816. {
  7817. if (gIsInSecondLife && gAgentWearables.areWearablesLoaded())
  7818. {
  7819. std::string url = gSavedSettings.getString("OutfitPickerURL");
  7820. if (!url.empty())
  7821. {
  7822. std::string grid = gIsInSecondLifeProductionGrid ? "agni"
  7823. : "aditi";
  7824. LLStringUtil::replaceString(url, "[GRID_LOWERCASE]", grid);
  7825. LLFloaterMediaBrowser::showInstance(url, true);
  7826. }
  7827. }
  7828. }
  7829. else if (floater_name == "friends")
  7830. {
  7831. LLFloaterFriends::toggleInstance();
  7832. }
  7833. else if (floater_name == "groups")
  7834. {
  7835. LLFloaterGroups::toggleInstance();
  7836. }
  7837. else if (floater_name == "preferences")
  7838. {
  7839. LLFloaterPreference::showInstance();
  7840. }
  7841. else if (floater_name == "toolbar")
  7842. {
  7843. LLToolBar::toggle();
  7844. }
  7845. else if (floater_name == "displayname")
  7846. {
  7847. LLFloaterDisplayName::showInstance();
  7848. }
  7849. else if (floater_name == "chat history")
  7850. {
  7851. LLFloaterChat::toggleInstance();
  7852. }
  7853. else if (floater_name == "teleport history")
  7854. {
  7855. gFloaterTeleportHistoryp->toggle();
  7856. }
  7857. else if (floater_name == "im")
  7858. {
  7859. LLIMMgr::toggle(NULL);
  7860. }
  7861. else if (floater_name == "inventory")
  7862. {
  7863. LLFloaterInventory::toggleVisibility();
  7864. }
  7865. else if (floater_name == "mute list")
  7866. {
  7867. LLFloaterMute::toggleInstance();
  7868. }
  7869. else if (floater_name == "media filter")
  7870. {
  7871. SLFloaterMediaFilter::toggleInstance();
  7872. }
  7873. else if (floater_name == "nearby media")
  7874. {
  7875. LLFloaterNearByMedia::toggleInstance();
  7876. }
  7877. else if (floater_name == "camera controls")
  7878. {
  7879. LLFloaterCamera::toggleInstance();
  7880. }
  7881. else if (floater_name == "movement controls")
  7882. {
  7883. LLFloaterMove::toggleInstance();
  7884. }
  7885. else if (floater_name == "world map")
  7886. {
  7887. LLFloaterWorldMap::toggle(NULL);
  7888. }
  7889. else if (floater_name == "mini map")
  7890. {
  7891. LLFloaterMiniMap::toggleInstance();
  7892. }
  7893. else if (floater_name == "stat bar")
  7894. {
  7895. LLFloaterStats::toggleInstance();
  7896. }
  7897. else if (floater_name == "my land")
  7898. {
  7899. LLFloaterLandHoldings::showInstance();
  7900. }
  7901. else if (floater_name == "about land")
  7902. {
  7903. if (gViewerParcelMgr.selectionEmpty())
  7904. {
  7905. gViewerParcelMgr.selectParcelAt(gAgent.getPositionGlobal());
  7906. }
  7907. //MK
  7908. if (!gRLenabled || !gRLInterface.mContainsShowloc)
  7909. {
  7910. //mk
  7911. LLFloaterLand::showInstance();
  7912. //MK
  7913. }
  7914. //mk
  7915. }
  7916. else if (floater_name == "buy land")
  7917. {
  7918. if (gViewerParcelMgr.selectionEmpty())
  7919. {
  7920. gViewerParcelMgr.selectParcelAt(gAgent.getPositionGlobal());
  7921. }
  7922. //MK
  7923. if (!gRLenabled || !gRLInterface.mContainsShowloc)
  7924. {
  7925. //mk
  7926. gViewerParcelMgr.startBuyLand();
  7927. //MK
  7928. }
  7929. //mk
  7930. }
  7931. else if (floater_name == "about region")
  7932. {
  7933. //MK
  7934. if (!gRLenabled || !gRLInterface.mContainsShowloc)
  7935. {
  7936. //mk
  7937. LLFloaterRegionInfo::showInstance();
  7938. //MK
  7939. }
  7940. //mk
  7941. }
  7942. else if (floater_name == "experiences")
  7943. {
  7944. LLFloaterExperiences::showInstance();
  7945. }
  7946. else if (floater_name == "areasearch")
  7947. {
  7948. HBFloaterAreaSearch::toggleInstance();
  7949. }
  7950. else if (floater_name == "soundslist")
  7951. {
  7952. HBFloaterSoundsList::toggleInstance();
  7953. }
  7954. else if (floater_name == "grid options")
  7955. {
  7956. LLFloaterBuildOptions::showInstance();
  7957. }
  7958. else if (floater_name == "characters")
  7959. {
  7960. LLFloaterPathfindingCharacters::openCharactersWithSelectedObjects();
  7961. }
  7962. else if (floater_name == "linksets")
  7963. {
  7964. LLFloaterPathfindingLinksets::openLinksetsWithSelectedObjects();
  7965. }
  7966. else if (floater_name == "script errors")
  7967. {
  7968. LLFloaterScriptDebug::show(LLUUID::null);
  7969. }
  7970. else if (floater_name == "help f1")
  7971. {
  7972. llinfos << "Spawning HTML help window" << llendl;
  7973. gViewerHtmlHelp.show();
  7974. }
  7975. else if (floater_name == "complaint reporter")
  7976. {
  7977. // Prevent menu from appearing in screen shot.
  7978. gMenuHolderp->hideMenus();
  7979. LLFloaterReporter::showFromMenu();
  7980. }
  7981. else if (floater_name == "mean events")
  7982. {
  7983. HBFloaterBump::showInstance();
  7984. }
  7985. else if (floater_name == "lag meter")
  7986. {
  7987. LLFloaterLagMeter::toggleInstance();
  7988. }
  7989. else if (floater_name == "buy currency")
  7990. {
  7991. LLFloaterBuyCurrency::buyCurrency();
  7992. }
  7993. else if (floater_name == "about")
  7994. {
  7995. LLFloaterAbout::showInstance();
  7996. }
  7997. else if (floater_name == "active speakers")
  7998. {
  7999. LLFloaterActiveSpeakers::toggleInstance();
  8000. }
  8001. else if (floater_name == "beacons")
  8002. {
  8003. LLFloaterBeacons::toggleInstance();
  8004. }
  8005. else if (floater_name == "perm prefs")
  8006. {
  8007. LLFloaterPerms::toggleInstance();
  8008. }
  8009. else if (floater_name == "debug settings")
  8010. {
  8011. LLFloaterDebugSettings::showInstance();
  8012. }
  8013. else if (floater_name == "debug tags")
  8014. {
  8015. HBFloaterDebugTags::showInstance();
  8016. }
  8017. return true;
  8018. }
  8019. };
  8020. class LLFloaterVisible final : public view_listener_t
  8021. {
  8022. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8023. {
  8024. std::string control_name = userdata["control"].asString();
  8025. std::string floater_name = userdata["data"].asString();
  8026. bool new_value = false;
  8027. if (floater_name == "friends")
  8028. {
  8029. new_value = LLFloaterFriends::instanceVisible();
  8030. }
  8031. else if (floater_name == "groups")
  8032. {
  8033. new_value = LLFloaterGroups::instanceVisible();
  8034. }
  8035. else if (floater_name == "communicate")
  8036. {
  8037. new_value = LLFloaterChatterBox::instanceVisible();
  8038. }
  8039. else if (floater_name == "toolbar")
  8040. {
  8041. new_value = LLToolBar::isVisible();
  8042. }
  8043. else if (floater_name == "chat history")
  8044. {
  8045. new_value = LLFloaterChat::instanceVisible();
  8046. }
  8047. else if (floater_name == "teleport history")
  8048. {
  8049. new_value = gFloaterTeleportHistoryp->getVisible();
  8050. }
  8051. else if (floater_name == "im")
  8052. {
  8053. new_value = LLFloaterChatterBox::instanceVisible(0);
  8054. }
  8055. else if (floater_name == "mute list")
  8056. {
  8057. new_value = LLFloaterMute::instanceVisible();
  8058. }
  8059. else if (floater_name == "media filter")
  8060. {
  8061. new_value = SLFloaterMediaFilter::instanceVisible();
  8062. }
  8063. else if (floater_name == "nearby media")
  8064. {
  8065. new_value = LLFloaterNearByMedia::instanceVisible();
  8066. }
  8067. else if (floater_name == "camera controls")
  8068. {
  8069. new_value = LLFloaterCamera::instanceVisible();
  8070. }
  8071. else if (floater_name == "movement controls")
  8072. {
  8073. new_value = LLFloaterMove::instanceVisible();
  8074. }
  8075. else if (floater_name == "stat bar")
  8076. {
  8077. new_value = LLFloaterStats::instanceVisible();
  8078. }
  8079. else if (floater_name == "lag meter")
  8080. {
  8081. new_value = LLFloaterLagMeter::instanceVisible();
  8082. }
  8083. else if (floater_name == "active speakers")
  8084. {
  8085. new_value = LLFloaterActiveSpeakers::instanceVisible();
  8086. }
  8087. else if (floater_name == "beacons")
  8088. {
  8089. new_value = LLFloaterBeacons::instanceVisible();
  8090. }
  8091. else if (floater_name == "inventory")
  8092. {
  8093. LLFloaterInventory* inv = LLFloaterInventory::getActiveFloater();
  8094. new_value = inv && inv->getVisible();
  8095. }
  8096. else if (floater_name == "radar")
  8097. {
  8098. new_value = HBFloaterRadar::instanceVisible();
  8099. }
  8100. else if (floater_name == "areasearch")
  8101. {
  8102. new_value = HBFloaterAreaSearch::instanceVisible();
  8103. }
  8104. else if (floater_name == "soundslist")
  8105. {
  8106. new_value = HBFloaterSoundsList::instanceVisible();
  8107. }
  8108. gMenuHolderp->findControl(control_name)->setValue(new_value);
  8109. return true;
  8110. }
  8111. };
  8112. bool callback_show_url(const LLSD& notification, const LLSD& response)
  8113. {
  8114. if (LLNotification::getSelectedOption(notification, response) == 0)
  8115. {
  8116. LLWeb::loadURL(notification["payload"]["url"].asString());
  8117. }
  8118. return false;
  8119. }
  8120. class LLPromptShowURL final : public view_listener_t
  8121. {
  8122. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8123. {
  8124. std::string param = userdata.asString();
  8125. std::string::size_type offset = param.find(",");
  8126. if (offset == std::string::npos)
  8127. {
  8128. llwarns << "PromptShowURL invalid parameters ! Expecting \"ALERT,URL\"."
  8129. << llendl;
  8130. return true;
  8131. }
  8132. std::string alert = param.substr(0, offset);
  8133. std::string url = param.substr(offset + 1);
  8134. LLSD payload;
  8135. payload["url"] = url;
  8136. gNotifications.add(alert, LLSD(), payload, callback_show_url);
  8137. return true;
  8138. }
  8139. };
  8140. class LLPromptShowOneOfURLs final : public view_listener_t
  8141. {
  8142. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8143. {
  8144. std::string params = userdata.asString();
  8145. typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
  8146. boost::char_separator<char> sep(",");
  8147. tokenizer tokens(params, sep);
  8148. if (std::distance(tokens.begin(), tokens.end()) != 4)
  8149. {
  8150. llwarns << "PromptShowOneOfURLs invalid parameters ! Expecting \"ALERT,BooleanDebugSettingName,URLWhenSettingTrue,URLWhenSettingFalse\"."
  8151. << llendl;
  8152. return true;
  8153. }
  8154. tokenizer::iterator it = tokens.begin();
  8155. ++it;
  8156. // Under Windoze, the internal representation of the boost token string
  8157. // is not a standard string, but a wide characters string, and there is
  8158. // an implicit conversion done on iterator pointer affectation to a
  8159. // std::string; so for Windows we cannot prevent a string copy and use
  8160. // 'const std::string& setting = *it++;' here, like I first implemented
  8161. // it for Linux, and I am not too sure for macOS either... It is not a
  8162. // time-critical operation anyway, so let's always copy the string. HB
  8163. std::string setting = *it++;
  8164. // Plugins support has been entirely gutted out from CEF 100, and the
  8165. // PDF viewer is now part of the browser (it is not considered a plugin
  8166. // any more). *TODO: remove entirely LLPromptShowOneOfURLs once all
  8167. // viewer builds (i.e. macOS and Windows ones) will use CEF 100 or
  8168. // newer. HB
  8169. #if CHROME_VERSION_MAJOR >= 100
  8170. if (setting != "BrowserPluginsEnabled")
  8171. #endif
  8172. {
  8173. LLControlVariable* ctrlp =
  8174. gSavedSettings.getControl(setting.c_str());
  8175. if (!ctrlp)
  8176. {
  8177. llwarns << "Could not find any setting named: " << setting
  8178. << llendl;
  8179. return true;
  8180. }
  8181. if (!ctrlp->getValue().asBoolean())
  8182. {
  8183. ++it;
  8184. }
  8185. }
  8186. LLSD payload;
  8187. payload["url"] = *it;
  8188. gNotifications.add(*tokens.begin(), LLSD(), payload,
  8189. callback_show_url);
  8190. return true;
  8191. }
  8192. };
  8193. bool callback_show_url_internal(const LLSD& notification, const LLSD& response)
  8194. {
  8195. if (LLNotification::getSelectedOption(notification, response) == 0)
  8196. {
  8197. LLWeb::loadURLInternal(notification["payload"]["url"].asString());
  8198. }
  8199. return false;
  8200. }
  8201. class LLPromptShowURLInternal final : public view_listener_t
  8202. {
  8203. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8204. {
  8205. std::string param = userdata.asString();
  8206. std::string::size_type offset = param.find(",");
  8207. if (offset == std::string::npos)
  8208. {
  8209. llwarns << "PromptShowURLInternal invalid parameters ! Expecting \"ALERT,URL\"."
  8210. << llendl;
  8211. return true;
  8212. }
  8213. std::string alert = param.substr(0, offset);
  8214. std::string url = param.substr(offset + 1);
  8215. LLSD payload;
  8216. payload["url"] = url;
  8217. gNotifications.add(alert, LLSD(), payload, callback_show_url_internal);
  8218. return true;
  8219. }
  8220. };
  8221. bool callback_show_file(const LLSD& notification, const LLSD& response)
  8222. {
  8223. if (LLNotification::getSelectedOption(notification, response) == 0)
  8224. {
  8225. LLWeb::loadURL(notification["payload"]["url"]);
  8226. }
  8227. return false;
  8228. }
  8229. class LLShowAgentProfile final : public view_listener_t
  8230. {
  8231. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8232. {
  8233. LLUUID agent_id;
  8234. if (userdata.asString() == "agent")
  8235. {
  8236. agent_id = gAgentID;
  8237. }
  8238. else if (userdata.asString() == "hit object")
  8239. {
  8240. //MK
  8241. if (gRLenabled &&
  8242. (gRLInterface.mContainsShownames ||
  8243. gRLInterface.mContainsShownametags))
  8244. {
  8245. return false;
  8246. }
  8247. //mk
  8248. LLViewerObject* objectp =
  8249. gSelectMgr.getSelection()->getPrimaryObject();
  8250. if (objectp)
  8251. {
  8252. agent_id = objectp->getID();
  8253. }
  8254. }
  8255. else
  8256. {
  8257. agent_id = userdata.asUUID();
  8258. }
  8259. LLVOAvatar* avatar = find_avatar_from_object(agent_id);
  8260. if (avatar)
  8261. {
  8262. LLFloaterAvatarInfo::show(avatar->getID());
  8263. }
  8264. return true;
  8265. }
  8266. };
  8267. class LLLandEdit final : public view_listener_t
  8268. {
  8269. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8270. {
  8271. if (!gFloaterToolsp) return false;
  8272. //MK
  8273. if (gRLenabled &&
  8274. (gRLInterface.mContainsRez || gRLInterface.mContainsEdit))
  8275. {
  8276. return false;
  8277. }
  8278. //mk
  8279. if (gAgent.getFocusOnAvatar() &&
  8280. gSavedSettings.getBool("EditCameraMovement"))
  8281. {
  8282. // Zoom in if we are looking at the avatar
  8283. gAgent.setFocusOnAvatar(false);
  8284. gAgent.setFocusGlobal(gToolPie.getPick());
  8285. gAgent.cameraOrbitOver(F_PI * 0.25f);
  8286. gViewerWindowp->moveCursorToCenter();
  8287. }
  8288. else if (gSavedSettings.getBool("EditCameraMovement"))
  8289. {
  8290. gAgent.setFocusGlobal(gToolPie.getPick());
  8291. gViewerWindowp->moveCursorToCenter();
  8292. }
  8293. gViewerParcelMgr.selectParcelAt(gToolPie.getPick().mPosGlobal);
  8294. gFloaterViewp->bringToFront(gFloaterToolsp);
  8295. // Switch to land edit toolset
  8296. gToolMgr.getCurrentToolset()->selectTool(&gToolSelectLand);
  8297. return true;
  8298. }
  8299. };
  8300. class LLWorldEnableBuyLand final : public view_listener_t
  8301. {
  8302. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8303. {
  8304. bool new_value =
  8305. gViewerParcelMgr.canAgentBuyParcel(gViewerParcelMgr.selectionEmpty() ?
  8306. gViewerParcelMgr.getAgentParcel() :
  8307. gViewerParcelMgr.getParcelSelection()->getParcel(),
  8308. false);
  8309. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  8310. return true;
  8311. }
  8312. };
  8313. class LLWorldEnableAvatarList final : public view_listener_t
  8314. {
  8315. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8316. {
  8317. bool new_value = !gRLenabled ||
  8318. (!gRLInterface.mContainsShownames &&
  8319. !gRLInterface.mContainsShownametags);
  8320. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  8321. return true;
  8322. }
  8323. };
  8324. class LLWorldEnableExperiences final : public view_listener_t
  8325. {
  8326. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8327. {
  8328. bool new_value = gAgent.hasRegionCapability("GetExperiences");
  8329. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  8330. return true;
  8331. }
  8332. };
  8333. class LLWorldEnableIfInSL final : public view_listener_t
  8334. {
  8335. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8336. {
  8337. gMenuHolderp->findControl(userdata["control"].asString())->setValue(gIsInSecondLife);
  8338. return true;
  8339. }
  8340. };
  8341. class LLWorldEnableIfNotInSL final : public view_listener_t
  8342. {
  8343. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8344. {
  8345. gMenuHolderp->findControl(userdata["control"].asString())->setValue(!gIsInSecondLife);
  8346. return true;
  8347. }
  8348. };
  8349. class LLWorldEnableWindlightRegionTime final : public view_listener_t
  8350. {
  8351. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8352. {
  8353. // Case of OpenSim (no EE)
  8354. bool ok = !gAgent.hasExtendedEnvironment();
  8355. gMenuHolderp->findControl(userdata["control"].asString())->setValue(ok);
  8356. return true;
  8357. }
  8358. };
  8359. class LLWorldEnableParcelEnv final : public view_listener_t
  8360. {
  8361. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8362. {
  8363. bool ok = !gWLSkyParamMgr.mHasLightshareOverride &&
  8364. !LLFloaterWindlight::instanceVisible() &&
  8365. gAgent.hasExtendedEnvironment();
  8366. gMenuHolderp->findControl(userdata["control"].asString())->setValue(ok);
  8367. return true;
  8368. }
  8369. };
  8370. class LLWorldEnableLocalEnv final : public view_listener_t
  8371. {
  8372. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8373. {
  8374. static LLCachedControl<bool>local_env(gSavedSettings,
  8375. "UseLocalEnvironment");
  8376. bool ok = local_env &&
  8377. !gWLSkyParamMgr.mHasLightshareOverride &&
  8378. !LLFloaterWindlight::instanceVisible() &&
  8379. gAgent.hasExtendedEnvironment();
  8380. gMenuHolderp->findControl(userdata["control"].asString())->setValue(ok);
  8381. return true;
  8382. }
  8383. };
  8384. class LLWorldSetSkySunlightScale final : public view_listener_t
  8385. {
  8386. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8387. {
  8388. F32 value = (F32)userdata.asReal();
  8389. gSavedSettings.setF32("RenderSkySunlightScale", value);
  8390. return true;
  8391. }
  8392. };
  8393. class LLWorldShowSkySunlightScale final : public view_listener_t
  8394. {
  8395. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8396. {
  8397. static LLCachedControl<F32> scale(gSavedSettings,
  8398. "RenderSkySunlightScale");
  8399. F32 setting = (F32)userdata["data"].asReal();
  8400. bool b = gUsePBRShaders && fabsf((F32)scale - setting) <= 0.05f;
  8401. gMenuHolderp->findControl(userdata["control"].asString())->setValue(b);
  8402. return true;
  8403. }
  8404. };
  8405. class LLWorldHasSkySunlightScale final : public view_listener_t
  8406. {
  8407. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8408. {
  8409. gMenuHolderp->findControl(userdata["control"].asString())->setValue(gUsePBRShaders);
  8410. return true;
  8411. }
  8412. };
  8413. class LLWorldHasAdjustHDR final : public view_listener_t
  8414. {
  8415. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8416. {
  8417. static LLCachedControl<bool>auto_hdr(gSavedSettings,
  8418. "RenderSkyAutoAdjustLegacy");
  8419. static LLCachedControl<U32>reflections(gSavedSettings,
  8420. "RenderReflectionProbes");
  8421. bool new_value = gUsePBRShaders && auto_hdr && reflections;
  8422. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  8423. return true;
  8424. }
  8425. };
  8426. void load_from_exr_callback(HBFileSelector::ELoadFilter,
  8427. std::string& filename, void*)
  8428. {
  8429. if (filename.empty() || !gUsePBRShaders)
  8430. {
  8431. return;
  8432. }
  8433. std::string error = LLDrawPoolWLSky::loadHDRISky(filename);
  8434. if (error.empty())
  8435. {
  8436. gSavedSettings.setBool("RenderHDRIEnabled", true);
  8437. }
  8438. else
  8439. {
  8440. LLSD args;
  8441. args["FILENAME"] = filename;
  8442. args["REASON"] = error;
  8443. gNotifications.add("FailedToLoadEXR", args);
  8444. }
  8445. }
  8446. void load_hdri_sky(bool force)
  8447. {
  8448. if (!gUsePBRShaders || HBFileSelector::isInUse())
  8449. {
  8450. return;
  8451. }
  8452. if (!force && LLDrawPoolWLSky::getHDRISky())
  8453. {
  8454. return;
  8455. }
  8456. HBFileSelector::loadFile(HBFileSelector::FFLOAD_HDRI,
  8457. load_from_exr_callback);
  8458. }
  8459. class LLWorldLoadHDRISky final : public view_listener_t
  8460. {
  8461. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8462. {
  8463. load_hdri_sky(true);
  8464. return true;
  8465. }
  8466. };
  8467. class LLWorldCanLoadHDRISky final : public view_listener_t
  8468. {
  8469. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8470. {
  8471. bool new_value = gUsePBRShaders && !HBFileSelector::isInUse();
  8472. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  8473. return true;
  8474. }
  8475. };
  8476. class LLWorldUseHDRISky final : public view_listener_t
  8477. {
  8478. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8479. {
  8480. static LLCachedControl<bool> hdri(gSavedSettings, "RenderHDRIEnabled");
  8481. bool new_value = hdri && gUsePBRShaders &&
  8482. LLDrawPoolWLSky::getHDRISky();
  8483. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  8484. return true;
  8485. }
  8486. };
  8487. class LLWorldHasHDRISky final : public view_listener_t
  8488. {
  8489. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8490. {
  8491. bool new_value = gUsePBRShaders && LLDrawPoolWLSky::getHDRISky();
  8492. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  8493. return true;
  8494. }
  8495. };
  8496. class LLWorldReflectionsEnabled final : public view_listener_t
  8497. {
  8498. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8499. {
  8500. static LLCachedControl<U32>reflections(gSavedSettings,
  8501. "RenderReflectionProbes");
  8502. bool enable = reflections && gUsePBRShaders;
  8503. gMenuHolderp->findControl(userdata["control"].asString())->setValue(enable);
  8504. return true;
  8505. }
  8506. };
  8507. class LLWorldHasDesaturate final : public view_listener_t
  8508. {
  8509. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8510. {
  8511. static LLCachedControl<bool>desaturate(gSavedSettings,
  8512. "RenderSkyReflectionDesaturate");
  8513. static LLCachedControl<U32>reflections(gSavedSettings,
  8514. "RenderReflectionProbes");
  8515. bool new_value = gUsePBRShaders && desaturate && reflections;
  8516. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  8517. return true;
  8518. }
  8519. };
  8520. class LLObjectAttachToAvatar final : public view_listener_t
  8521. {
  8522. public:
  8523. static void setObjectSelection(LLObjectSelectionHandle selection)
  8524. {
  8525. sObjectSelection = selection;
  8526. }
  8527. private:
  8528. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8529. {
  8530. //MK
  8531. if (gRLenabled && gRLInterface.mContainsRez)
  8532. {
  8533. return false; // we can't take objects when unable to rez
  8534. }
  8535. //mk
  8536. setObjectSelection(gSelectMgr.getSelection());
  8537. LLViewerObject* object = sObjectSelection->getFirstRootObject();
  8538. if (object)
  8539. {
  8540. S32 index = userdata.asInteger();
  8541. LLViewerJointAttachment* attachment_point = NULL;
  8542. if (index > 0)
  8543. {
  8544. attachment_point =
  8545. get_ptr_in_map(gAgentAvatarp->mAttachmentPoints, index);
  8546. }
  8547. //MK
  8548. if (gRLenabled)
  8549. {
  8550. if (index == 0 && gRLInterface.mContainsDetach)
  8551. {
  8552. // Something is locked and we are attempting a "Wear"
  8553. // in-world
  8554. setObjectSelection(NULL);
  8555. return false;
  8556. }
  8557. if (attachment_point &&
  8558. !gRLInterface.canAttach(NULL, attachment_point->getName()))
  8559. {
  8560. setObjectSelection(NULL);
  8561. return false;
  8562. }
  8563. }
  8564. //mk
  8565. confirm_replace_attachment(0, attachment_point);
  8566. }
  8567. return true;
  8568. }
  8569. protected:
  8570. static LLObjectSelectionHandle sObjectSelection;
  8571. };
  8572. LLObjectSelectionHandle LLObjectAttachToAvatar::sObjectSelection;
  8573. void near_attach_object(bool success, void* user_data)
  8574. {
  8575. LLViewerJointAttachment* attachment = (LLViewerJointAttachment*)user_data;
  8576. #if 0 // We do not care if we got close "enough", just attach the object !
  8577. if (success)
  8578. #endif
  8579. {
  8580. #if 0 // Stay in whatever state the auto-pilot left us...
  8581. gAgent.setFlying(false);
  8582. #endif
  8583. U8 attachment_id = 0;
  8584. if (attachment)
  8585. {
  8586. for (LLVOAvatar::attachment_map_t::iterator
  8587. iter = gAgentAvatarp->mAttachmentPoints.begin();
  8588. iter != gAgentAvatarp->mAttachmentPoints.end(); ++iter)
  8589. {
  8590. if (iter->second == attachment)
  8591. {
  8592. attachment_id = iter->first;
  8593. break;
  8594. }
  8595. }
  8596. }
  8597. else
  8598. {
  8599. // interpret 0 as "default location"
  8600. attachment_id = 0;
  8601. }
  8602. gSelectMgr.sendAttach(attachment_id);
  8603. }
  8604. LLObjectAttachToAvatar::setObjectSelection(NULL);
  8605. }
  8606. void confirm_replace_attachment(S32 option, void* user_data)
  8607. {
  8608. if (option != 0) // Not yes
  8609. {
  8610. return;
  8611. }
  8612. LLViewerObject* object = gSelectMgr.getSelection()->getFirstRootObject();
  8613. if (!object)
  8614. {
  8615. llwarns << "Object is gone..." << llendl;
  8616. return;
  8617. }
  8618. // Distances in meters
  8619. constexpr F32 MIN_STOP_DISTANCE = 1.f;
  8620. constexpr F32 ARM_LENGTH = 0.5f;
  8621. constexpr F32 SCALE_FUDGE = 1.5f;
  8622. F32 stop_dist = SCALE_FUDGE * object->getMaxScale() + ARM_LENGTH;
  8623. if (stop_dist < MIN_STOP_DISTANCE)
  8624. {
  8625. stop_dist = MIN_STOP_DISTANCE;
  8626. }
  8627. LLVector3 dest = object->getPositionAgent();
  8628. // Make sure we stop in front of the object
  8629. LLVector3 delta = dest - gAgent.getPositionAgent();
  8630. delta.normalize();
  8631. delta = delta * 0.5f;
  8632. dest -= delta;
  8633. gAgentPilot.startAutoPilotGlobal(gAgent.getPosGlobalFromAgent(dest),
  8634. "Attach", NULL, near_attach_object,
  8635. user_data, stop_dist, 0.1f,
  8636. gAgent.getFlying());
  8637. gAgent.clearFocusObject();
  8638. }
  8639. class LLAttachmentDrop final : public view_listener_t
  8640. {
  8641. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8642. {
  8643. // Called when the user clicked on an object attached to them
  8644. // and selected "Drop".
  8645. LLViewerObject* object = gSelectMgr.getSelection()->getPrimaryObject();
  8646. if (!object)
  8647. {
  8648. llwarns << "No object to drop" << llendl;
  8649. return true;
  8650. }
  8651. LLViewerObject* parent = (LLViewerObject*)object->getParent();
  8652. while (parent)
  8653. {
  8654. if (parent->isAvatar())
  8655. {
  8656. break;
  8657. }
  8658. object = parent;
  8659. parent = (LLViewerObject*)parent->getParent();
  8660. }
  8661. if (!object || object->isAvatar())
  8662. {
  8663. llwarns << "No object to detach" << llendl;
  8664. return true;
  8665. }
  8666. // The sendDropAttachment() method works on the list of selected
  8667. // objects. Thus we need to clear the list, make sure it only contains
  8668. // the object the user clicked, send the message, then clear the list.
  8669. gSelectMgr.sendDropAttachment();
  8670. return true;
  8671. }
  8672. };
  8673. // Called from avatar pie menu and Edit menu
  8674. void handle_detach_from_avatar(void* user_data)
  8675. {
  8676. LLViewerJointAttachment* attachment = (LLViewerJointAttachment*)user_data;
  8677. if (attachment && attachment->getNumObjects() > 0)
  8678. {
  8679. //MK
  8680. if (gRLenabled &&
  8681. !gRLInterface.canDetachAllObjectsFromAttachment(attachment))
  8682. {
  8683. return;
  8684. }
  8685. //mk
  8686. LLMessageSystem* msg = gMessageSystemp;
  8687. msg->newMessage("ObjectDetach");
  8688. msg->nextBlockFast(_PREHASH_AgentData);
  8689. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  8690. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  8691. for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator
  8692. iter = attachment->mAttachedObjects.begin(),
  8693. end = attachment->mAttachedObjects.end();
  8694. iter != end; ++iter)
  8695. {
  8696. LLViewerObject* object = iter->get();
  8697. if (object)
  8698. {
  8699. msg->nextBlockFast(_PREHASH_ObjectData);
  8700. msg->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
  8701. }
  8702. }
  8703. msg->sendReliable(gAgent.getRegionHost());
  8704. }
  8705. }
  8706. void attach_label(std::string& label, void* user_data)
  8707. {
  8708. LLViewerJointAttachment* attachment = (LLViewerJointAttachment*)user_data;
  8709. if (attachment)
  8710. {
  8711. label = LLTrans::getString(attachment->getName());
  8712. for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator
  8713. iter = attachment->mAttachedObjects.begin(),
  8714. end = attachment->mAttachedObjects.end();
  8715. iter != end; ++iter)
  8716. {
  8717. const LLViewerObject* object = iter->get();
  8718. if (object)
  8719. {
  8720. LLViewerInventoryItem* itemp =
  8721. gInventory.getItem(object->getAttachmentItemID());
  8722. if (itemp)
  8723. {
  8724. label += " (" + itemp->getName() + ")";
  8725. break;
  8726. }
  8727. }
  8728. }
  8729. }
  8730. }
  8731. void detach_label(std::string& label, void* user_data)
  8732. {
  8733. LLViewerJointAttachment* attachment = (LLViewerJointAttachment*)user_data;
  8734. if (attachment)
  8735. {
  8736. label = LLTrans::getString(attachment->getName());
  8737. for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator
  8738. iter = attachment->mAttachedObjects.begin(),
  8739. end = attachment->mAttachedObjects.end();
  8740. iter != end; ++iter)
  8741. {
  8742. const LLViewerObject* object = iter->get();
  8743. if (object)
  8744. {
  8745. LLViewerInventoryItem* itemp;
  8746. itemp = gInventory.getItem(object->getAttachmentItemID());
  8747. if (itemp)
  8748. {
  8749. label += " (" + itemp->getName() + ")";
  8750. break;
  8751. }
  8752. }
  8753. }
  8754. }
  8755. }
  8756. class LLAttachmentDetach final : public view_listener_t
  8757. {
  8758. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8759. {
  8760. // Called when the user clicked on an object attached to them
  8761. // and selected "Detach".
  8762. LLViewerObject* object = gSelectMgr.getSelection()->getPrimaryObject();
  8763. if (!object)
  8764. {
  8765. llwarns << "No object to detach" << llendl;
  8766. return true;
  8767. }
  8768. //MK
  8769. if (gRLenabled && !gRLInterface.canDetachAllSelectedObjects())
  8770. {
  8771. return true;
  8772. }
  8773. //mk
  8774. LLViewerObject* parent = (LLViewerObject*)object->getParent();
  8775. while (parent)
  8776. {
  8777. if (parent->isAvatar())
  8778. {
  8779. break;
  8780. }
  8781. object = parent;
  8782. parent = (LLViewerObject*)parent->getParent();
  8783. }
  8784. if (!object || object->isAvatar())
  8785. {
  8786. llwarns << "No object to detach" << llendl;
  8787. return true;
  8788. }
  8789. // The sendDetach() method works on the list of selected objects. Thus
  8790. // we need to clear the list, make sure it only contains the object the
  8791. // user clicked, send the message, then clear the list.
  8792. // We use deselectAll to update the simulator's notion of what is
  8793. // selected, and removeAll just to change things locally.
  8794. // RN: I thought it was more useful to detach everything that was
  8795. // selected.
  8796. if (gSelectMgr.getSelection()->isAttachment())
  8797. {
  8798. gSelectMgr.sendDetach();
  8799. }
  8800. return true;
  8801. }
  8802. };
  8803. // Adding an observer for a JIRA-2422 and needs to be a fetch observer for
  8804. // JIRA-3119
  8805. class LLWornItemFetchedObserver final : public LLInventoryFetchObserver
  8806. {
  8807. public:
  8808. LLWornItemFetchedObserver() {}
  8809. ~LLWornItemFetchedObserver() override {}
  8810. protected:
  8811. void done() override
  8812. {
  8813. gPieAttachmentp->buildDrawLabels();
  8814. gInventory.removeObserver(this);
  8815. delete this;
  8816. }
  8817. };
  8818. bool enable_detach(void*)
  8819. {
  8820. LLViewerObject* object = gSelectMgr.getSelection()->getPrimaryObject();
  8821. if (!object || !object->isAttachment())
  8822. {
  8823. return false;
  8824. }
  8825. //MK
  8826. if (gRLenabled)
  8827. {
  8828. if (!gRLInterface.canDetach(object))
  8829. {
  8830. return false;
  8831. }
  8832. // Prevent a clever workaround that allowed to detach several objects
  8833. // at the same time by selecting them
  8834. if (gRLInterface.mContainsDetach &&
  8835. gSelectMgr.getSelection()->getRootObjectCount() > 1)
  8836. {
  8837. return false;
  8838. }
  8839. }
  8840. //mk
  8841. // Find the avatar who owns this attachment
  8842. LLViewerObject* avatar = object;
  8843. while (avatar)
  8844. {
  8845. // ...if it is you, good to detach
  8846. if (avatar->getID() == gAgentID)
  8847. {
  8848. return true;
  8849. }
  8850. avatar = (LLViewerObject*)avatar->getParent();
  8851. }
  8852. return false;
  8853. }
  8854. // You can only drop items on parcels where you can build.
  8855. class LLAttachmentEnableDrop final : public view_listener_t
  8856. {
  8857. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8858. {
  8859. // Add an inventory observer to only allow dropping the newly attached
  8860. // item once it exists in your inventory. Look at JIRA-2422. -jwolk
  8861. // A bug occurs when you wear/drop an item before it actively is added
  8862. // to your inventory if this is the case (you're on a slow sim, etc),
  8863. // a copy of the object, well, a newly created object with the same
  8864. // properties, is placed in your inventory. Therefore, we disable the
  8865. // drop option until the item is in your inventory
  8866. LLViewerObject* object = gSelectMgr.getSelection()->getPrimaryObject();
  8867. LLViewerJointAttachment* attachment_pt = NULL;
  8868. LLInventoryItem* item = NULL;
  8869. if (object)
  8870. {
  8871. S32 attach_id =
  8872. ATTACHMENT_ID_FROM_STATE(object->getAttachmentState());
  8873. attachment_pt = get_ptr_in_map(gAgentAvatarp->mAttachmentPoints,
  8874. attach_id);
  8875. if (attachment_pt)
  8876. {
  8877. for (LLViewerJointAttachment::attachedobjs_vec_t::iterator
  8878. iter = attachment_pt->mAttachedObjects.begin(),
  8879. end = attachment_pt->mAttachedObjects.end();
  8880. iter != end; ++iter)
  8881. {
  8882. LLViewerObject* attached_object = iter->get();
  8883. if (!attached_object) break;
  8884. // Make sure item is in your inventory (it could be a
  8885. // delayed attach message being sent from the sim) so check
  8886. // to see if the item is in the inventory already
  8887. item = gInventory.getItem(attached_object->getAttachmentItemID());
  8888. if (!item)
  8889. {
  8890. #if 0 // Disabled code, because, when applied on temporary
  8891. // attachments (that never appear in inventory), it
  8892. // causes an infinite number of observers to be added,
  8893. // causing memory exhaustion and crash ! - HB
  8894. // Item does not exist, make an observer to enable the
  8895. // pie menu when the item finishes fetching worst case
  8896. // scenario if a fetch is already out there (being sent
  8897. // from a slow sim) we refetch and there are 2 fetches
  8898. LLWornItemFetchedObserver* worn_item_fetched =
  8899. new LLWornItemFetchedObserver();
  8900. // Add item to the inventory item to be fetched:
  8901. uuid_vec_t items;
  8902. items.emplace_back((*iter)->getAttachmentItemID());
  8903. worn_item_fetched->fetchItems(items);
  8904. gInventory.addObserver(worn_item_fetched);
  8905. #else
  8906. // Just exit with item == NULL, which disables the pie
  8907. // slice (and is appropriate for temporary attachments
  8908. // too).
  8909. break;
  8910. #endif
  8911. }
  8912. }
  8913. }
  8914. }
  8915. // Now check to make sure that the item is actually in the inventory
  8916. // before we enable dropping it
  8917. bool new_value = enable_detach(NULL) && item &&
  8918. gViewerParcelMgr.allowAgentBuild();
  8919. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  8920. return true;
  8921. }
  8922. };
  8923. class LLAttachmentEnableDetach final : public view_listener_t
  8924. {
  8925. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8926. {
  8927. bool new_value = enable_detach(NULL);
  8928. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  8929. return true;
  8930. }
  8931. };
  8932. // Used to tell if the selected object can be attached to your avatar.
  8933. bool object_selected_and_point_valid(void*)
  8934. {
  8935. LLObjectSelectionHandle selection = gSelectMgr.getSelection();
  8936. for (LLObjectSelection::root_iterator iter = selection->root_begin(),
  8937. end = selection->root_end();
  8938. iter != end; ++iter)
  8939. {
  8940. LLSelectNode* node = *iter;
  8941. if (!node) continue; // Paranoia
  8942. LLViewerObject* object = node->getObject();
  8943. if (!object) continue; // Paranoia
  8944. LLViewerObject::const_child_list_t& child_list = object->getChildren();
  8945. for (LLViewerObject::child_list_t::const_iterator
  8946. iter2 = child_list.begin(), end2 = child_list.end();
  8947. iter2 != end2; ++iter2)
  8948. {
  8949. LLViewerObject* child = *iter2;
  8950. if (child->isAvatar())
  8951. {
  8952. return false;
  8953. }
  8954. }
  8955. }
  8956. return selection->getRootObjectCount() == 1 &&
  8957. selection->getFirstRootObject()->getPCode() == LL_PCODE_VOLUME &&
  8958. selection->getFirstRootObject()->permYouOwner() &&
  8959. !selection->getFirstRootObject()->flagObjectPermanent() &&
  8960. !((LLViewerObject*)selection->getFirstRootObject()->getRoot())->isAvatar() &&
  8961. selection->getFirstRootObject()->getNVPair("AssetContainer") == NULL;
  8962. }
  8963. // Also for seeing if object can be attached. See above.
  8964. class LLObjectEnableWear final : public view_listener_t
  8965. {
  8966. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8967. {
  8968. //MK
  8969. if (gRLenabled && gRLInterface.mContainsDetach)
  8970. {
  8971. return false;
  8972. }
  8973. //mk
  8974. bool is_wearable = object_selected_and_point_valid(NULL);
  8975. gMenuHolderp->findControl(userdata["control"].asString())->setValue(is_wearable);
  8976. return true;
  8977. }
  8978. };
  8979. bool object_attached(void* user_data)
  8980. {
  8981. LLViewerJointAttachment* attachment = (LLViewerJointAttachment*)user_data;
  8982. return attachment && attachment->getNumObjects() > 0;
  8983. }
  8984. class LLAvatarSendIM final : public view_listener_t
  8985. {
  8986. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  8987. {
  8988. //MK
  8989. if (gRLenabled &&
  8990. (gRLInterface.mContainsShownames ||
  8991. gRLInterface.mContainsShownametags))
  8992. {
  8993. return false;
  8994. }
  8995. //mk
  8996. LLVOAvatar* avatar =
  8997. find_avatar_from_object(gSelectMgr.getSelection()->getPrimaryObject());
  8998. if (avatar)
  8999. {
  9000. LLAvatarActions::startIM(avatar->getID());
  9001. }
  9002. return true;
  9003. }
  9004. };
  9005. namespace
  9006. {
  9007. struct QueueObjects final : public LLSelectedObjectFunctor
  9008. {
  9009. bool scripted;
  9010. bool modifiable;
  9011. LLFloaterScriptQueue* mQueue;
  9012. QueueObjects(LLFloaterScriptQueue* q)
  9013. : mQueue(q),
  9014. scripted(false),
  9015. modifiable(false)
  9016. {
  9017. }
  9018. bool apply(LLViewerObject* obj) override
  9019. {
  9020. scripted = obj->flagScripted();
  9021. modifiable = obj->permModify();
  9022. return !(scripted && modifiable);
  9023. }
  9024. };
  9025. }
  9026. void queue_actions(LLFloaterScriptQueue* q, const std::string& noscriptmsg,
  9027. const std::string& nomodmsg)
  9028. {
  9029. QueueObjects func(q);
  9030. bool fail = gSelectMgr.getSelection()->applyToObjects(&func);
  9031. if (fail)
  9032. {
  9033. if (!func.scripted)
  9034. {
  9035. gNotifications.add(noscriptmsg);
  9036. }
  9037. else if (!func.modifiable)
  9038. {
  9039. gNotifications.add(nomodmsg);
  9040. }
  9041. else
  9042. {
  9043. llerrs << "Bad logic." << llendl;
  9044. }
  9045. }
  9046. else if (!q || !q->start())
  9047. {
  9048. llwarns << "Unexpected script compile failure." << llendl;
  9049. }
  9050. }
  9051. void handle_compile_queue(std::string to_lang)
  9052. {
  9053. LLFloaterCompileQueue* queue;
  9054. if (to_lang == "mono")
  9055. {
  9056. queue = LLFloaterCompileQueue::create(true);
  9057. }
  9058. else
  9059. {
  9060. queue = LLFloaterCompileQueue::create(false);
  9061. }
  9062. queue_actions(queue, "CannotRecompileSelectObjectsNoScripts",
  9063. "CannotRecompileSelectObjectsNoPermission");
  9064. }
  9065. void handle_reset_selection()
  9066. {
  9067. LLFloaterResetQueue* queue = LLFloaterResetQueue::create();
  9068. queue_actions(queue, "CannotResetSelectObjectsNoScripts",
  9069. "CannotResetSelectObjectsNoPermission");
  9070. }
  9071. void handle_set_run_selection()
  9072. {
  9073. LLFloaterRunQueue* queue = LLFloaterRunQueue::create();
  9074. queue_actions(queue, "CannotSetRunningSelectObjectsNoScripts",
  9075. "CannotSerRunningSelectObjectsNoPermission");
  9076. }
  9077. void handle_set_not_run_selection()
  9078. {
  9079. LLFloaterStopQueue* queue = LLFloaterStopQueue::create();
  9080. queue_actions(queue, "CannotSetRunningNotSelectObjectsNoScripts",
  9081. "CannotSerRunningNotSelectObjectsNoPermission");
  9082. }
  9083. class LLToolsSelectedScriptAction final : public view_listener_t
  9084. {
  9085. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9086. {
  9087. //MK
  9088. // If there is at least one object locked in the selection, don't allow
  9089. // anything
  9090. if (gRLenabled && !gRLInterface.canDetachAllSelectedObjects())
  9091. {
  9092. return true;
  9093. }
  9094. //mk
  9095. std::string action = userdata.asString();
  9096. if (action == "compile mono")
  9097. {
  9098. handle_compile_queue("mono");
  9099. }
  9100. if (action == "compile lsl")
  9101. {
  9102. handle_compile_queue("lsl");
  9103. }
  9104. else if (action == "reset")
  9105. {
  9106. handle_reset_selection();
  9107. }
  9108. else if (action == "start")
  9109. {
  9110. handle_set_run_selection();
  9111. }
  9112. else if (action == "stop")
  9113. {
  9114. handle_set_not_run_selection();
  9115. }
  9116. return true;
  9117. }
  9118. };
  9119. //---------------------------------------------------------------------
  9120. // Callbacks for enabling/disabling items
  9121. //---------------------------------------------------------------------
  9122. // This is used in the GL menus to set control values.
  9123. class LLToggleControl final : public view_listener_t
  9124. {
  9125. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9126. {
  9127. std::string control_name = userdata.asString();
  9128. bool checked = gSavedSettings.getBool(control_name.c_str());
  9129. if (control_name == "HighResSnapshot" && !checked)
  9130. {
  9131. // High Res Snapshot active, must uncheck RenderUIInSnapshot
  9132. gSavedSettings.setBool("RenderUIInSnapshot", false);
  9133. }
  9134. gSavedSettings.setBool(control_name.c_str(), !checked);
  9135. return true;
  9136. }
  9137. };
  9138. // This is used in the GL menus to set control values.
  9139. class LLToggleControlPerAccount final : public view_listener_t
  9140. {
  9141. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9142. {
  9143. std::string control_name = userdata.asString();
  9144. bool checked = gSavedPerAccountSettings.getBool(control_name.c_str());
  9145. gSavedPerAccountSettings.setBool(control_name.c_str(), !checked);
  9146. return true;
  9147. }
  9148. };
  9149. class LLSomethingSelected final : public view_listener_t
  9150. {
  9151. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9152. {
  9153. bool new_value = !(gSelectMgr.getSelection()->isEmpty());
  9154. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9155. return true;
  9156. }
  9157. };
  9158. class LLSomethingSelectedNoHUD final : public view_listener_t
  9159. {
  9160. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9161. {
  9162. LLObjectSelectionHandle selection = gSelectMgr.getSelection();
  9163. bool new_value = selection && !selection->isEmpty() &&
  9164. selection->getSelectType() != SELECT_TYPE_HUD;
  9165. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9166. return true;
  9167. }
  9168. };
  9169. static bool is_editable_selected()
  9170. {
  9171. return gSelectMgr.getSelection()->getFirstEditableObject() != NULL;
  9172. }
  9173. class LLEditableSelected final : public view_listener_t
  9174. {
  9175. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9176. {
  9177. gMenuHolderp->findControl(userdata["control"].asString())->setValue(is_editable_selected());
  9178. return true;
  9179. }
  9180. };
  9181. class LLEditableSelectedMono final : public view_listener_t
  9182. {
  9183. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9184. {
  9185. if (gMenuHolderp &&
  9186. gMenuHolderp->findControl(userdata["control"].asString()))
  9187. {
  9188. bool selected = is_editable_selected() &&
  9189. !gAgent.getRegionCapability("UpdateScriptTask").empty();
  9190. gMenuHolderp->findControl(userdata["control"].asString())->setValue(selected);
  9191. return true;
  9192. }
  9193. return false;
  9194. }
  9195. };
  9196. // Also called in llfloaterpathfindingobjects.
  9197. bool enable_object_take_copy()
  9198. {
  9199. bool success = false;
  9200. if (!gSelectMgr.getSelection()->isEmpty())
  9201. {
  9202. struct f final : public LLSelectedObjectFunctor
  9203. {
  9204. bool apply(LLViewerObject* obj) override
  9205. {
  9206. //MK
  9207. if (gRLenabled && gRLInterface.mContainsUnsit &&
  9208. obj->isAgentSeat())
  9209. {
  9210. return true;
  9211. }
  9212. //mk
  9213. return !obj->permCopy() || obj->isAttachment();
  9214. }
  9215. } func;
  9216. success = !gSelectMgr.getSelection()->applyToRootObjects(&func, true);
  9217. }
  9218. return success;
  9219. }
  9220. class LLToolsEnableTakeCopy final : public view_listener_t
  9221. {
  9222. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9223. {
  9224. bool new_value = enable_object_take_copy();
  9225. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9226. return true;
  9227. }
  9228. };
  9229. bool enable_save_into_task_inventory(void*)
  9230. {
  9231. LLSelectNode* node = gSelectMgr.getSelection()->getFirstRootNode();
  9232. if (node && node->mValid && node->mFromTaskID.notNull())
  9233. {
  9234. // *TODO: check to see if the fromtaskid object exists.
  9235. LLViewerObject* obj = node->getObject();
  9236. if (obj && !obj->isAttachment())
  9237. {
  9238. return true;
  9239. }
  9240. }
  9241. return false;
  9242. }
  9243. class LLToolsEnableSaveToObjectInventory final : public view_listener_t
  9244. {
  9245. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9246. {
  9247. bool new_value = enable_save_into_task_inventory(NULL);
  9248. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9249. return true;
  9250. }
  9251. };
  9252. class LLViewEnableMouselook final : public view_listener_t
  9253. {
  9254. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9255. {
  9256. // You cannot go directly from customize avatar to mouselook.
  9257. // *TODO: write code with appropriate dialogs to handle this
  9258. // transition.
  9259. bool new_value = !LLPipeline::sFreezeTime &&
  9260. gAgent.getCameraMode() != CAMERA_MODE_CUSTOMIZE_AVATAR;
  9261. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9262. return true;
  9263. }
  9264. };
  9265. class LLToolsEnableToolNotPie final : public view_listener_t
  9266. {
  9267. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9268. {
  9269. bool new_value = gToolMgr.getBaseTool() != &gToolPie;
  9270. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9271. return true;
  9272. }
  9273. };
  9274. class LLWorldEnableCreateLandmark final : public view_listener_t
  9275. {
  9276. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9277. {
  9278. //MK
  9279. if (gRLenabled && gRLInterface.mContainsShowloc)
  9280. {
  9281. return false;
  9282. }
  9283. //mk
  9284. bool new_value = gAgent.isGodlike() ||
  9285. (gAgent.getRegion() &&
  9286. gAgent.getRegion()->getAllowLandmark());
  9287. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9288. return true;
  9289. }
  9290. };
  9291. class LLWorldEnableSetHomeLocation final : public view_listener_t
  9292. {
  9293. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9294. {
  9295. bool new_value = gAgent.isGodlike() ||
  9296. (gAgent.getRegion() &&
  9297. gAgent.getRegion()->getAllowSetHome());
  9298. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9299. return true;
  9300. }
  9301. };
  9302. class LLWorldEnableTeleportHome final : public view_listener_t
  9303. {
  9304. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9305. {
  9306. LLViewerRegion* regionp = gAgent.getRegion();
  9307. bool agent_on_prelude = regionp && regionp->isPrelude();
  9308. bool enable_teleport_home = gAgent.isGodlike() || !agent_on_prelude;
  9309. gMenuHolderp->findControl(userdata["control"].asString())->setValue(enable_teleport_home);
  9310. return true;
  9311. }
  9312. };
  9313. class LLToolsSetSelectionsPolicy final : public view_listener_t
  9314. {
  9315. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9316. {
  9317. U32 policy = userdata.asInteger();
  9318. gSavedSettings.setU32("RenderHighlightSelectionsPolicy", policy);
  9319. return true;
  9320. }
  9321. };
  9322. class LLToolsShowSelectionsPolicy final : public view_listener_t
  9323. {
  9324. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9325. {
  9326. static LLCachedControl<U32> policy(gSavedSettings,
  9327. "RenderHighlightSelectionsPolicy");
  9328. bool checked = (U32)policy == (U32)userdata["data"].asInteger();
  9329. gMenuHolderp->findControl(userdata["control"].asString())->setValue(checked);
  9330. return true;
  9331. }
  9332. };
  9333. class LLToolsEditLinkedParts final : public view_listener_t
  9334. {
  9335. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9336. {
  9337. bool select_individuals = gSavedSettings.getBool("EditLinkedParts");
  9338. if (select_individuals)
  9339. {
  9340. gSelectMgr.demoteSelectionToIndividuals();
  9341. }
  9342. else
  9343. {
  9344. gSelectMgr.promoteSelectionToRoot();
  9345. }
  9346. return true;
  9347. }
  9348. };
  9349. class LLToolsUseSelectionForGrid final : public view_listener_t
  9350. {
  9351. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9352. {
  9353. gSelectMgr.clearGridObjects();
  9354. struct f final : public LLSelectedObjectFunctor
  9355. {
  9356. bool apply(LLViewerObject* objectp) override
  9357. {
  9358. gSelectMgr.addGridObject(objectp);
  9359. return true;
  9360. }
  9361. } func;
  9362. gSelectMgr.getSelection()->applyToRootObjects(&func);
  9363. gSelectMgr.setGridMode(GRID_MODE_REF_OBJECT);
  9364. if (gFloaterToolsp)
  9365. {
  9366. gFloaterToolsp->setGridMode((S32)GRID_MODE_REF_OBJECT);
  9367. }
  9368. return true;
  9369. }
  9370. };
  9371. //
  9372. // LLViewerMenuHolderGL
  9373. //
  9374. LLViewerMenuHolderGL::LLViewerMenuHolderGL() : LLMenuHolderGL()
  9375. {
  9376. }
  9377. bool LLViewerMenuHolderGL::hideMenus()
  9378. {
  9379. bool handled = LLMenuHolderGL::hideMenus();
  9380. // Drop pie menu selection
  9381. mParcelSelection = NULL;
  9382. mObjectSelection = NULL;
  9383. gMenuBarViewp->clearHoverItem();
  9384. gMenuBarViewp->resetMenuTrigger();
  9385. return handled;
  9386. }
  9387. void LLViewerMenuHolderGL::setParcelSelection(LLSafeHandle<LLParcelSelection> selection)
  9388. {
  9389. mParcelSelection = selection;
  9390. }
  9391. void LLViewerMenuHolderGL::setObjectSelection(LLSafeHandle<LLObjectSelection> selection)
  9392. {
  9393. mObjectSelection = selection;
  9394. }
  9395. const LLRect LLViewerMenuHolderGL::getMenuRect() const
  9396. {
  9397. return LLRect(0, getRect().getHeight() - gMenuBarHeight,
  9398. getRect().getWidth(), gStatusBarHeight);
  9399. }
  9400. // TomY TODO: Get rid of these?
  9401. class LLViewShowHoverTips final : public view_listener_t
  9402. {
  9403. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9404. {
  9405. LLHoverView::sShowHoverTips = !LLHoverView::sShowHoverTips;
  9406. return true;
  9407. }
  9408. };
  9409. class LLViewCheckShowHoverTips final : public view_listener_t
  9410. {
  9411. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9412. {
  9413. bool new_value = LLHoverView::sShowHoverTips;
  9414. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9415. return true;
  9416. }
  9417. };
  9418. class LLViewHighlightTransparent final : public view_listener_t
  9419. {
  9420. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9421. {
  9422. //MK
  9423. if (gRLenabled && gRLInterface.mContainsEdit)
  9424. {
  9425. return true;
  9426. }
  9427. //mk
  9428. LLDrawPoolAlpha::sShowDebugAlpha = !LLDrawPoolAlpha::sShowDebugAlpha;
  9429. if (LLDrawPoolAlpha::sShowDebugAlpha)
  9430. {
  9431. // Invisible objects skip building their render batches unless
  9432. // sShowDebugAlpha is true, so rebuild batches whenever toggling
  9433. // this flag on.
  9434. gPipeline.rebuildDrawInfo();
  9435. // Needed too (the above rebuilds *visible* groups, but we also
  9436. // need to rebuild individual objects since they might be part
  9437. // of a group only containing render-skipped objects). HB
  9438. handle_objects_visibility(NULL);
  9439. }
  9440. return true;
  9441. }
  9442. };
  9443. class LLViewCheckHighlightTransparent final : public view_listener_t
  9444. {
  9445. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9446. {
  9447. bool new_value = LLDrawPoolAlpha::sShowDebugAlpha;
  9448. //MK
  9449. if (gRLenabled && gRLInterface.mContainsEdit)
  9450. {
  9451. new_value = false;
  9452. }
  9453. //mk
  9454. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9455. return true;
  9456. }
  9457. };
  9458. class LLViewToggleRenderType final : public view_listener_t
  9459. {
  9460. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9461. {
  9462. std::string type = userdata.asString();
  9463. if (type == "hideparticles")
  9464. {
  9465. LLPipeline::toggleRenderType(LLPipeline::RENDER_TYPE_PARTICLES);
  9466. }
  9467. return true;
  9468. }
  9469. };
  9470. class LLViewCheckRenderType final : public view_listener_t
  9471. {
  9472. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9473. {
  9474. std::string type = userdata["data"].asString();
  9475. bool new_value = false;
  9476. if (type == "hideparticles")
  9477. {
  9478. new_value =
  9479. LLPipeline::toggleRenderTypeControlNegated((void*)LLPipeline::RENDER_TYPE_PARTICLES);
  9480. }
  9481. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9482. return true;
  9483. }
  9484. };
  9485. class LLViewShowHUDAttachments final : public view_listener_t
  9486. {
  9487. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9488. {
  9489. LLPipeline::sShowHUDAttachments = !LLPipeline::sShowHUDAttachments ||
  9490. //MK
  9491. (gRLenabled &&
  9492. gRLInterface.mHasLockedHuds);
  9493. //mk
  9494. return true;
  9495. }
  9496. };
  9497. class LLViewCheckHUDAttachments final : public view_listener_t
  9498. {
  9499. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9500. {
  9501. bool new_value = LLPipeline::sShowHUDAttachments ||
  9502. //MK
  9503. (gRLenabled && gRLInterface.mHasLockedHuds);
  9504. //mk
  9505. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9506. return true;
  9507. }
  9508. };
  9509. //MK
  9510. class LLViewEnableHUDAttachments final : public view_listener_t
  9511. {
  9512. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9513. {
  9514. bool new_value = !gRLenabled || !gRLInterface.mHasLockedHuds;
  9515. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9516. return true;
  9517. }
  9518. };
  9519. //mk
  9520. class LLEditEnableTakeOff final : public view_listener_t
  9521. {
  9522. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9523. {
  9524. std::string control_name = userdata["control"].asString();
  9525. std::string clothing = userdata["data"].asString();
  9526. bool new_value = false;
  9527. //MK
  9528. if (gRLenabled && (gRLInterface.contains("remoutfit") ||
  9529. gRLInterface.contains("remoutfit:" + clothing)))
  9530. {
  9531. return false;
  9532. }
  9533. //mk
  9534. LLWearableType::EType type = LLWearableType::typeNameToType(clothing);
  9535. if (type >= LLWearableType::WT_SHAPE &&
  9536. type < LLWearableType::WT_COUNT)
  9537. {
  9538. new_value = LLAgentWearables::selfHasWearable(type);
  9539. }
  9540. gMenuHolderp->findControl(control_name)->setValue(new_value);
  9541. return true;
  9542. }
  9543. };
  9544. class LLEditTakeOff final : public view_listener_t
  9545. {
  9546. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9547. {
  9548. std::string clothing = userdata.asString();
  9549. if (clothing == "all")
  9550. {
  9551. LLAgentWearables::userRemoveAllClothes();
  9552. }
  9553. else
  9554. {
  9555. LLWearableType::EType type =
  9556. LLWearableType::typeNameToType(clothing);
  9557. LLAgentWearables::userRemoveWearablesOfType(type);
  9558. }
  9559. return true;
  9560. }
  9561. };
  9562. class LLWorldChat final : public view_listener_t
  9563. {
  9564. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9565. {
  9566. handle_chat(NULL);
  9567. return true;
  9568. }
  9569. };
  9570. class LLToolsSelectTool final : public view_listener_t
  9571. {
  9572. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9573. {
  9574. std::string tool_name = userdata.asString();
  9575. //MK
  9576. if (gRLenabled && gRLInterface.mContainsEdit)
  9577. {
  9578. LLViewerObject* objp =
  9579. gSelectMgr.getSelection()->getPrimaryObject();
  9580. if (!gRLInterface.canEdit(objp))
  9581. {
  9582. return true;
  9583. }
  9584. }
  9585. //mk
  9586. if (tool_name == "focus")
  9587. {
  9588. gToolMgr.getCurrentToolset()->selectToolByIndex(1);
  9589. }
  9590. else if (tool_name == "move")
  9591. {
  9592. gToolMgr.getCurrentToolset()->selectToolByIndex(2);
  9593. }
  9594. else if (tool_name == "edit")
  9595. {
  9596. gToolMgr.getCurrentToolset()->selectToolByIndex(3);
  9597. }
  9598. else if (tool_name == "create")
  9599. {
  9600. gToolMgr.getCurrentToolset()->selectToolByIndex(4);
  9601. }
  9602. else if (tool_name == "land")
  9603. {
  9604. gToolMgr.getCurrentToolset()->selectToolByIndex(5);
  9605. }
  9606. else
  9607. {
  9608. llwarns << "Invalid tool name: " << tool_name << llendl;
  9609. }
  9610. return true;
  9611. }
  9612. };
  9613. // Environment callbacks
  9614. class LLWorldEnvSettings final : public view_listener_t
  9615. {
  9616. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9617. {
  9618. //MK
  9619. if (gRLenabled && gRLInterface.mContainsSetenv)
  9620. {
  9621. return true;
  9622. }
  9623. //mk
  9624. std::string tod = userdata.asString();
  9625. if (tod == "editor")
  9626. {
  9627. LLFloaterWindlight::showInstance();
  9628. tod.clear();
  9629. }
  9630. else if (tod == "sunrise")
  9631. {
  9632. LLEnvironment::setSunrise();
  9633. }
  9634. else if (tod == "noon")
  9635. {
  9636. LLEnvironment::setMidday();
  9637. }
  9638. else if (tod == "noon_pbr")
  9639. {
  9640. LLEnvironment::setMiddayPBR();
  9641. }
  9642. else if (tod == "sunset")
  9643. {
  9644. LLEnvironment::setSunset();
  9645. }
  9646. else if (tod == "midnight")
  9647. {
  9648. LLEnvironment::setMidnight();
  9649. }
  9650. else if (tod == "local")
  9651. {
  9652. HBFloaterLocalEnv::showInstance();
  9653. }
  9654. else // "animate"
  9655. {
  9656. // The onWindlightChange() automation call will be done from
  9657. // the proper callback in llviewercontrol.cpp...
  9658. tod.clear();
  9659. LLEnvironment::setRegion();
  9660. }
  9661. if (gAutomationp && !tod.empty())
  9662. {
  9663. gAutomationp->onWindlightChange(tod, "", "");
  9664. }
  9665. return true;
  9666. }
  9667. };
  9668. ///////////////////////////////////////////////////////////////////////////////
  9669. // Code formerly held in llviewermenufile.cpp
  9670. ///////////////////////////////////////////////////////////////////////////////
  9671. typedef LLMemberListener<LLView> view_listener_t;
  9672. class LLFileEnableSaveAs final : public view_listener_t
  9673. {
  9674. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9675. {
  9676. bool new_value = !HBFileSelector::isInUse() &&
  9677. gFloaterViewp->getFrontmost() &&
  9678. gFloaterViewp->getFrontmost()->canSaveAs();
  9679. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9680. return true;
  9681. }
  9682. };
  9683. class LLFileEnableUpload final : public view_listener_t
  9684. {
  9685. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9686. {
  9687. S32 cost = LLEconomy::getInstance()->getPriceUpload();
  9688. bool new_value = !HBFileSelector::isInUse() &&
  9689. can_afford_transaction(cost);
  9690. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9691. return true;
  9692. }
  9693. };
  9694. class LLFileEnableUploadAnim final : public view_listener_t
  9695. {
  9696. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9697. {
  9698. S32 cost = LLEconomy::getInstance()->getAnimationUploadCost();
  9699. bool new_value = !HBFileSelector::isInUse() &&
  9700. can_afford_transaction(cost);
  9701. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9702. return true;
  9703. }
  9704. };
  9705. class LLFileEnableUploadSound final : public view_listener_t
  9706. {
  9707. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9708. {
  9709. S32 cost = LLEconomy::getInstance()->getSoundUploadCost();
  9710. bool new_value = !HBFileSelector::isInUse() &&
  9711. can_afford_transaction(cost);
  9712. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9713. return true;
  9714. }
  9715. };
  9716. class LLFileEnableUploadImage final : public view_listener_t
  9717. {
  9718. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9719. {
  9720. S32 cost = LLEconomy::getInstance()->getTextureUploadCost();
  9721. bool new_value = !HBFileSelector::isInUse() &&
  9722. can_afford_transaction(cost);
  9723. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9724. return true;
  9725. }
  9726. };
  9727. class LLFileCheckUploadBulk2K final : public view_listener_t
  9728. {
  9729. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9730. {
  9731. static LLCachedControl<bool> upload_2k(gSavedPerAccountSettings,
  9732. "BulkUpload2KTextures");
  9733. bool checked = !s2KTextureCost || upload_2k;
  9734. if (checked && s2KTextureCost)
  9735. {
  9736. checked = can_afford_transaction(s2KTextureCost);
  9737. }
  9738. gMenuHolderp->findControl(userdata["control"].asString())->setValue(checked);
  9739. return true;
  9740. }
  9741. };
  9742. class LLFileEnableUploadBulk2K final : public view_listener_t
  9743. {
  9744. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9745. {
  9746. bool enabled = gMaxImageSizeDefault > 1024 && s2KTextureCost &&
  9747. can_afford_transaction(s2KTextureCost);
  9748. gMenuHolderp->findControl(userdata["control"].asString())->setValue(enabled);
  9749. return true;
  9750. }
  9751. };
  9752. class LLFileEnableUploadMaterial final : public view_listener_t
  9753. {
  9754. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9755. {
  9756. bool new_value =
  9757. !HBFileSelector::isInUse() &&
  9758. gAgent.hasRegionCapability("UpdateMaterialAgentInventory");
  9759. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9760. return true;
  9761. }
  9762. };
  9763. class LLFileEnableUploadModel final : public view_listener_t
  9764. {
  9765. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9766. {
  9767. bool new_value = !HBFileSelector::isInUse() &&
  9768. gMeshRepo.meshUploadEnabled() &&
  9769. LLFloaterModelPreview::findInstance() == NULL;
  9770. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  9771. return true;
  9772. }
  9773. };
  9774. void upload_bulk_callback(HBFileSelector::ELoadFilter,
  9775. std::deque<std::string>& files, void*)
  9776. {
  9777. if (files.empty())
  9778. {
  9779. return;
  9780. }
  9781. gUploadQueueMutex.lock();
  9782. // First remember if there are ongoing uploads already in progress
  9783. bool no_upload = gUploadQueue.empty();
  9784. while (!files.empty())
  9785. {
  9786. gUploadQueue.emplace_back(files.front());
  9787. files.pop_front();
  9788. }
  9789. gUploadQueueMutex.unlock();
  9790. if (no_upload)
  9791. {
  9792. // Initiate bulk uploads.
  9793. process_bulk_upload_queue();
  9794. }
  9795. }
  9796. static std::string TEXT_EXTENSIONS = "txt";
  9797. static std::string SOUND_EXTENSIONS = "wav dsf";
  9798. static std::string IMAGE_EXTENSIONS = "tga png jpg jpeg bmp";
  9799. static std::string MATERIAL_EXTENSIONS = "gltf glb";
  9800. static std::string ANIM_EXTENSIONS = "bvh anim";
  9801. static std::string XML_EXTENSIONS = "xml";
  9802. static std::string LSL_EXTENSIONS = "lsl";
  9803. static std::string MODEL_EXTENSIONS = "dae";
  9804. static std::string ALL_FILE_EXTENSIONS = "*.*";
  9805. std::string build_extensions_string(HBFileSelector::ELoadFilter filter)
  9806. {
  9807. switch (filter)
  9808. {
  9809. case HBFileSelector::FFLOAD_ALL:
  9810. default:
  9811. return ALL_FILE_EXTENSIONS;
  9812. case HBFileSelector::FFLOAD_TEXT:
  9813. return TEXT_EXTENSIONS;
  9814. case HBFileSelector::FFLOAD_XML:
  9815. case HBFileSelector::FFLOAD_XUI:
  9816. return XML_EXTENSIONS;
  9817. case HBFileSelector::FFLOAD_SCRIPT:
  9818. return LSL_EXTENSIONS;
  9819. case HBFileSelector::FFLOAD_SOUND:
  9820. return SOUND_EXTENSIONS;
  9821. case HBFileSelector::FFLOAD_ANIM:
  9822. return ANIM_EXTENSIONS;
  9823. case HBFileSelector::FFLOAD_MODEL:
  9824. return MODEL_EXTENSIONS;
  9825. case HBFileSelector::FFLOAD_IMAGE:
  9826. return IMAGE_EXTENSIONS;
  9827. case HBFileSelector::FFLOAD_GLTF:
  9828. return MATERIAL_EXTENSIONS;
  9829. }
  9830. }
  9831. bool callback_anim_upload(const LLSD& notification, const LLSD& response)
  9832. {
  9833. if (LLNotification::getSelectedOption(notification, response) == 0) // OK
  9834. {
  9835. std::deque<std::string> files;
  9836. files.emplace_back(notification["payload"]["filename"].asString());
  9837. upload_bulk_callback(HBFileSelector::FFLOAD_ANIM, files, NULL);
  9838. }
  9839. return false;
  9840. }
  9841. void upload_pick_callback(HBFileSelector::ELoadFilter type,
  9842. std::string& filename, void*)
  9843. {
  9844. if (filename.empty())
  9845. {
  9846. return;
  9847. }
  9848. std::string ext = gDirUtil.getExtension(filename);
  9849. // strincmp() does not like NULL pointers
  9850. if (ext.empty())
  9851. {
  9852. std::string short_name = gDirUtil.getBaseFileName(filename);
  9853. // No extension
  9854. LLSD args;
  9855. args["FILE"] = short_name;
  9856. gNotifications.add("NoFileExtension", args);
  9857. return;
  9858. }
  9859. else
  9860. {
  9861. // There is an extension: loop over the valid extensions and compare
  9862. // to see if the extension is valid
  9863. // Now grab the set of valid file extensions
  9864. std::string valid_extensions = build_extensions_string(type);
  9865. typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
  9866. boost::char_separator<char> sep(" ");
  9867. tokenizer tokens(valid_extensions, sep);
  9868. tokenizer::iterator token_iter;
  9869. // Now loop over all valid file extensions and compare them to the
  9870. // extension of the file to be uploaded
  9871. bool ext_valid = false;
  9872. for (token_iter = tokens.begin();
  9873. token_iter != tokens.end() && !ext_valid;
  9874. ++token_iter)
  9875. {
  9876. const std::string& cur_token = *token_iter;
  9877. if (cur_token == ext || cur_token == "*.*")
  9878. {
  9879. // Valid extension or the acceptable extension is any
  9880. ext_valid = true;
  9881. }
  9882. }
  9883. if (!ext_valid)
  9884. {
  9885. // Should only get here if the extension exists but is invalid
  9886. LLSD args;
  9887. args["EXTENSION"] = ext;
  9888. args["VALIDS"] = valid_extensions;
  9889. gNotifications.add("InvalidFileExtension", args);
  9890. return;
  9891. }
  9892. }
  9893. if (type == HBFileSelector::FFLOAD_IMAGE)
  9894. {
  9895. new LLFloaterImagePreview(filename);
  9896. }
  9897. else if (type == HBFileSelector::FFLOAD_GLTF)
  9898. {
  9899. LLPreviewMaterial::loadFromFile(filename);
  9900. }
  9901. else if (type == HBFileSelector::FFLOAD_SOUND)
  9902. {
  9903. // Pre-qualify the wav file to make sure the format is acceptable
  9904. F32 max_duration = LLVORBIS_CLIP_MAX_TIME; // SL default (30s)
  9905. if (!gIsInSecondLife)
  9906. {
  9907. max_duration = llmax(LLVORBIS_CLIP_MAX_TIME,
  9908. gSavedSettings.getU32("OSMaxSoundDuration"));
  9909. }
  9910. std::string error_msg;
  9911. if (check_for_invalid_wav_formats(filename, error_msg,
  9912. max_duration) != LLVORBISENC_NOERR)
  9913. {
  9914. LLSD args;
  9915. args["FILE"] = filename;
  9916. args["LENGTH"] = llformat("%d", (S32)max_duration);
  9917. gNotifications.add(error_msg, args);
  9918. return;
  9919. }
  9920. new HBFloaterUploadSound(filename);
  9921. }
  9922. else if (type == HBFileSelector::FFLOAD_ANIM)
  9923. {
  9924. if (ext == "bvh")
  9925. {
  9926. new LLFloaterAnimPreview(filename);
  9927. }
  9928. else // *.anim files can only be bulk-uploaded...
  9929. {
  9930. LLSD payload;
  9931. payload["filename"] = filename;
  9932. LLSD args;
  9933. args["FILE"] = filename;
  9934. args["COST"] = LLEconomy::getInstance()->getAnimationUploadCost();
  9935. gNotifications.add("ConfirmAnimUpload", args, payload,
  9936. callback_anim_upload);
  9937. }
  9938. }
  9939. }
  9940. void upload_pick(HBFileSelector::ELoadFilter type)
  9941. {
  9942. if (gAgent.cameraMouselook())
  9943. {
  9944. gAgent.changeCameraToDefault();
  9945. }
  9946. HBFileSelector::loadFile(type, upload_pick_callback);
  9947. }
  9948. class LLFileUploadImage final : public view_listener_t
  9949. {
  9950. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9951. {
  9952. upload_pick(HBFileSelector::FFLOAD_IMAGE);
  9953. return true;
  9954. }
  9955. };
  9956. class LLFileUploadMaterial final : public view_listener_t
  9957. {
  9958. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9959. {
  9960. if (gAgent.hasRegionCapability("UpdateMaterialAgentInventory"))
  9961. {
  9962. upload_pick(HBFileSelector::FFLOAD_GLTF);
  9963. }
  9964. return true;
  9965. }
  9966. };
  9967. class LLFileUploadSound final : public view_listener_t
  9968. {
  9969. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9970. {
  9971. upload_pick(HBFileSelector::FFLOAD_SOUND);
  9972. return true;
  9973. }
  9974. };
  9975. class LLFileUploadAnim final : public view_listener_t
  9976. {
  9977. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9978. {
  9979. upload_pick(HBFileSelector::FFLOAD_ANIM);
  9980. return true;
  9981. }
  9982. };
  9983. class LLFileUploadBulk final : public view_listener_t
  9984. {
  9985. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9986. {
  9987. if (gAgent.cameraMouselook())
  9988. {
  9989. gAgent.changeCameraToDefault();
  9990. }
  9991. HBFileSelector::loadFiles(HBFileSelector::FFLOAD_ALL,
  9992. upload_bulk_callback);
  9993. return true;
  9994. }
  9995. };
  9996. class LLFileUploadModel final : public view_listener_t
  9997. {
  9998. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  9999. {
  10000. LLFloaterModelPreview* fmp = LLFloaterModelPreview::getInstance();
  10001. if (fmp)
  10002. {
  10003. fmp->loadModel(3);
  10004. }
  10005. return true;
  10006. }
  10007. };
  10008. class LLFileEnableCloseWindow final : public view_listener_t
  10009. {
  10010. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10011. {
  10012. // *HACK: before STATE_LOGIN_WAIT, the code below can cause an infinite
  10013. // loop (for example when a "Display settings have been set to
  10014. // recommended..." dialog is shown), thus the reason for enabling
  10015. // the close option always before STATE_LOGIN_WAIT... Note that before
  10016. // STATE_LOGIN_WAIT, the user got no chance whatsoever to see and
  10017. // select the File -> Quit menu item anyway (it is not yet drawn)... HB
  10018. bool new_value = LLStartUp::getStartupState() < STATE_LOGIN_WAIT ||
  10019. LLFloater::getClosableFloaterFromFocus() != NULL;
  10020. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  10021. return true;
  10022. }
  10023. };
  10024. class LLFileCloseWindow final : public view_listener_t
  10025. {
  10026. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10027. {
  10028. LLFloater::closeFocusedFloater();
  10029. return true;
  10030. }
  10031. };
  10032. class LLFileEnableCloseAllWindows final : public view_listener_t
  10033. {
  10034. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10035. {
  10036. bool open_children = gFloaterViewp->allChildrenClosed();
  10037. gMenuHolderp->findControl(userdata["control"].asString())->setValue(!open_children);
  10038. return true;
  10039. }
  10040. };
  10041. class LLFileCloseAllWindows final : public view_listener_t
  10042. {
  10043. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10044. {
  10045. bool app_quitting = false;
  10046. gFloaterViewp->closeAllChildren(app_quitting);
  10047. return true;
  10048. }
  10049. };
  10050. class LLFileSaveTexture final : public view_listener_t
  10051. {
  10052. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10053. {
  10054. LLFloater* top = gFloaterViewp->getFrontmost();
  10055. if (top)
  10056. {
  10057. top->saveAs();
  10058. }
  10059. return true;
  10060. }
  10061. };
  10062. class LLFileTakeSnapshot final : public view_listener_t
  10063. {
  10064. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10065. {
  10066. LLFloaterSnapshot::show(NULL);
  10067. return true;
  10068. }
  10069. };
  10070. void snapshot_to_disk(HBFileSelector::ESaveFilter type, std::string& filename,
  10071. void*)
  10072. {
  10073. if (filename.empty()) return;
  10074. if (!gViewerWindowp->isSnapshotLocSet())
  10075. {
  10076. gViewerWindowp->setSnapshotLoc(filename);
  10077. }
  10078. LLPointer<LLImageRaw> raw = new LLImageRaw;
  10079. S32 width = gViewerWindowp->getWindowDisplayWidth();
  10080. S32 height = gViewerWindowp->getWindowDisplayHeight();
  10081. if (gSavedSettings.getBool("HighResSnapshot"))
  10082. {
  10083. width *= 2;
  10084. height *= 2;
  10085. }
  10086. if (gViewerWindowp->rawSnapshot(raw, width, height, true, false,
  10087. gSavedSettings.getBool("RenderUIInSnapshot"),
  10088. false))
  10089. {
  10090. gViewerWindowp->playSnapshotAnimAndSound();
  10091. LLImageBase::setSizeOverride(true);
  10092. LLPointer<LLImageFormatted> formatted;
  10093. switch (type)
  10094. {
  10095. case HBFileSelector::FFSAVE_JPG:
  10096. formatted = new LLImageJPEG(gSavedSettings.getS32("SnapshotQuality"));
  10097. break;
  10098. case HBFileSelector::FFSAVE_PNG:
  10099. formatted = new LLImagePNG;
  10100. break;
  10101. case HBFileSelector::FFSAVE_BMP:
  10102. formatted = new LLImageBMP;
  10103. break;
  10104. default:
  10105. llwarns << "Unknown local snapshot format" << llendl;
  10106. LLImageBase::setSizeOverride(false);
  10107. return;
  10108. }
  10109. formatted->encode(raw);
  10110. LLImageBase::setSizeOverride(false);
  10111. gViewerWindowp->saveImageNumbered(formatted);
  10112. }
  10113. }
  10114. class LLFileTakeSnapshotToDisk final : public view_listener_t
  10115. {
  10116. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10117. {
  10118. HBFileSelector::ESaveFilter type;
  10119. switch (gSavedSettings.getU32("SnapshotFormat"))
  10120. {
  10121. case LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG:
  10122. type = HBFileSelector::FFSAVE_JPG;
  10123. break;
  10124. case LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG:
  10125. type = HBFileSelector::FFSAVE_PNG;
  10126. break;
  10127. case LLFloaterSnapshot::SNAPSHOT_FORMAT_BMP:
  10128. type = HBFileSelector::FFSAVE_BMP;
  10129. break;
  10130. default:
  10131. llwarns << "Unknown Local Snapshot format" << llendl;
  10132. return true;
  10133. }
  10134. std::string suggestion = gViewerWindowp->getSnapshotBaseName();
  10135. if (gViewerWindowp->isSnapshotLocSet())
  10136. {
  10137. snapshot_to_disk(type, suggestion, NULL);
  10138. }
  10139. else
  10140. {
  10141. HBFileSelector::saveFile(type, suggestion, snapshot_to_disk);
  10142. }
  10143. return true;
  10144. }
  10145. };
  10146. class LLFileQuit final : public view_listener_t
  10147. {
  10148. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10149. {
  10150. gAppViewerp->userQuit();
  10151. return true;
  10152. }
  10153. };
  10154. void compress_image_callback(HBFileSelector::ELoadFilter type,
  10155. std::deque<std::string>& files, void*)
  10156. {
  10157. if (files.empty())
  10158. {
  10159. return;
  10160. }
  10161. LLSD args;
  10162. std::string infile, extension, outfile, report;
  10163. while (!files.empty())
  10164. {
  10165. infile = files.front();
  10166. extension = gDirUtil.getExtension(infile);
  10167. EImageCodec codec = LLImageBase::getCodecFromExtension(extension);
  10168. if (codec == IMG_CODEC_INVALID)
  10169. {
  10170. llinfos << "Error compressing image: " << infile
  10171. << " - Unknown codec !" << llendl;
  10172. }
  10173. outfile = gDirUtil.getDirName(infile) + LL_DIR_DELIM_STR +
  10174. gDirUtil.getBaseFileName(infile, true) + ".j2c";
  10175. llinfos << "Compressing image... Input: " << infile << " - Output: "
  10176. << outfile << llendl;
  10177. if (LLViewerTextureList::createUploadFile(infile, outfile, codec))
  10178. {
  10179. llinfos << "Compression complete" << llendl;
  10180. report = infile + " successfully compressed to " + outfile;
  10181. }
  10182. else
  10183. {
  10184. report = LLImage::getLastError();
  10185. llinfos << "Compression failed: " << report << llendl;
  10186. report = " Failed to compress " + infile + " - " + report;
  10187. }
  10188. args["MESSAGE"] = report;
  10189. gNotifications.add("SystemMessageTip", args);
  10190. files.pop_front();
  10191. }
  10192. }
  10193. void handle_compress_image(void*)
  10194. {
  10195. HBFileSelector::loadFiles(HBFileSelector::FFLOAD_IMAGE,
  10196. compress_image_callback);
  10197. }
  10198. //---------------------------------------------------------------------------
  10199. // Object backup/import and export functions.
  10200. //---------------------------------------------------------------------------
  10201. // When using the file selector, we open the build floater to be sure that the
  10202. // object(s) to export will stay selected during the file selection since the
  10203. // export methods return just after the file selector is opened and the right-
  10204. // clicked object gets auto-deselected while the file selector callback is
  10205. // still to come...
  10206. void open_tools_floater()
  10207. {
  10208. if (gFloaterToolsp)
  10209. {
  10210. gFloaterToolsp->open();
  10211. gToolMgr.setCurrentToolset(gBasicToolset);
  10212. gFloaterToolsp->setEditTool(&gToolCompTranslate);
  10213. }
  10214. }
  10215. class LLFileEnableBackupObject final : public view_listener_t
  10216. {
  10217. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10218. {
  10219. LLViewerObject* object = gSelectMgr.getSelection()->getPrimaryObject();
  10220. bool new_value = object && !HBFileSelector::isInUse() &&
  10221. !HBObjectBackup::findInstance();
  10222. //MK
  10223. if (new_value && gRLenabled)
  10224. {
  10225. new_value = !gRLInterface.mContainsRez &&
  10226. !gRLInterface.mContainsEdit;
  10227. }
  10228. //mk
  10229. if (new_value)
  10230. {
  10231. struct ff final : public LLSelectedNodeFunctor
  10232. {
  10233. ff(const LLSD& data)
  10234. : LLSelectedNodeFunctor(),
  10235. userdata(data)
  10236. {
  10237. }
  10238. bool apply(LLSelectNode* node) override
  10239. {
  10240. // Note: the actual permission checking algorithm depends
  10241. // on the grid TOS and must be performed for each prim and
  10242. // texture. This is done later in hbobjectbackup.cpp.
  10243. // This means that even if the item is enabled in the menu,
  10244. // the export may fail should the permissions not be met
  10245. // for each exported asset. The permissions check below
  10246. // therefore only corresponds to the minimal permissions
  10247. // requirement common to all grids.
  10248. // Edited out to experimen with permissions (gwyneth 20240818)
  10249. /* LLPermissions *item_permissions = node->mPermissions;
  10250. return (gAgentID == item_permissions->getOwner() &&
  10251. (gAgentID == item_permissions->getCreator() ||
  10252. (item_permissions->getMaskOwner() &
  10253. PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)); */
  10254. return true;
  10255. }
  10256. const LLSD& userdata;
  10257. };
  10258. ff* the_ff = new ff(userdata);
  10259. new_value = gSelectMgr.getSelection()->applyToNodes(the_ff, false);
  10260. }
  10261. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  10262. return true;
  10263. }
  10264. };
  10265. class LLFileBackupObject final : public view_listener_t
  10266. {
  10267. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10268. {
  10269. LLViewerObject* object = gSelectMgr.getSelection()->getPrimaryObject();
  10270. if (object)
  10271. {
  10272. open_tools_floater();
  10273. HBObjectBackup::exportObject();
  10274. }
  10275. return true;
  10276. }
  10277. };
  10278. class LLFileEnableImportObject final : public view_listener_t
  10279. {
  10280. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10281. {
  10282. bool new_value = !HBFileSelector::isInUse() &&
  10283. gViewerParcelMgr.allowAgentBuild() &&
  10284. !HBObjectBackup::findInstance();
  10285. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  10286. return true;
  10287. }
  10288. };
  10289. class LLFileImportObject final : public view_listener_t
  10290. {
  10291. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10292. {
  10293. HBObjectBackup::importObject(false);
  10294. return true;
  10295. }
  10296. };
  10297. class LLFileUpLoadImportObject final : public view_listener_t
  10298. {
  10299. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10300. {
  10301. HBObjectBackup::importObject(true);
  10302. return true;
  10303. }
  10304. };
  10305. class LLFileExportOBJ final : public view_listener_t
  10306. {
  10307. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10308. {
  10309. LLViewerObject* object = gSelectMgr.getSelection()->getPrimaryObject();
  10310. if (object)
  10311. {
  10312. open_tools_floater();
  10313. ALWavefrontSaver::exportSelection();
  10314. }
  10315. return true;
  10316. }
  10317. };
  10318. class LLFileExportDAE final : public view_listener_t
  10319. {
  10320. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10321. {
  10322. LLViewerObject* object = gSelectMgr.getSelection()->getPrimaryObject();
  10323. if (object)
  10324. {
  10325. //open_tools_floater();
  10326. LKFloaterColladaExport::showInstance();
  10327. }
  10328. return true;
  10329. }
  10330. };
  10331. class LLFileImportSettings final : public view_listener_t
  10332. {
  10333. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10334. {
  10335. LLSettingsType::EType type = LLSettingsType::ST_NONE;
  10336. std::string param = userdata.asString();
  10337. if (param == "sky")
  10338. {
  10339. type = LLSettingsType::ST_SKY;
  10340. }
  10341. else if (param == "water")
  10342. {
  10343. type = LLSettingsType::ST_WATER;
  10344. }
  10345. else if (param == "day")
  10346. {
  10347. type = LLSettingsType::ST_DAYCYCLE;
  10348. }
  10349. if (type != LLSettingsType::ST_NONE)
  10350. {
  10351. HBFloaterEditEnvSettings* floaterp =
  10352. HBFloaterEditEnvSettings::create(type);
  10353. if (floaterp)
  10354. {
  10355. floaterp->setEditContextInventory();
  10356. floaterp->loadDefaultSettings();
  10357. }
  10358. }
  10359. return true;
  10360. }
  10361. };
  10362. class LLFileEnableImportSettings final : public view_listener_t
  10363. {
  10364. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10365. {
  10366. bool new_value = !HBFileSelector::isInUse() &&
  10367. gAgent.hasInventorySettings();
  10368. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  10369. return true;
  10370. }
  10371. };
  10372. class LLAdvancedEnableLoadFromXML final : public view_listener_t
  10373. {
  10374. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10375. {
  10376. bool new_value = !HBFileSelector::isInUse();
  10377. gMenuHolderp->findControl(userdata["control"].asString())->setValue(new_value);
  10378. return true;
  10379. }
  10380. };
  10381. class LLAdvancedLoadFromXML final : public view_listener_t
  10382. {
  10383. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10384. {
  10385. handle_load_from_xml(NULL);
  10386. return true;
  10387. }
  10388. };
  10389. // A parameterized event handler used as ctrl-8/9/0 zoom controls below.
  10390. class LLZoomer final : public view_listener_t
  10391. {
  10392. public:
  10393. // The "mult" parameter says whether "val" is a multiplier or used to
  10394. // set the value.
  10395. LLZoomer(F32 val, bool mult = true)
  10396. : mVal(val),
  10397. mMult(mult)
  10398. {
  10399. }
  10400. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10401. {
  10402. F32 new_fov_rad = mMult ? gViewerCamera.getDefaultFOV() * mVal : mVal;
  10403. gViewerCamera.setDefaultFOV(new_fov_rad);
  10404. // setView may have clamped it.
  10405. gSavedSettings.setF32("CameraAngle", gViewerCamera.getView());
  10406. return true;
  10407. }
  10408. private:
  10409. F32 mVal;
  10410. bool mMult;
  10411. };
  10412. class LLAvatarReportAbuse final : public view_listener_t
  10413. {
  10414. bool handleEvent(LLPointer<LLEvent>, const LLSD& userdata) override
  10415. {
  10416. LLVOAvatar* avatarp =
  10417. find_avatar_from_object(gSelectMgr.getSelection()->getPrimaryObject());
  10418. if (avatarp)
  10419. {
  10420. LLFloaterReporter::showFromObject(avatarp->getID());
  10421. }
  10422. return true;
  10423. }
  10424. };
  10425. ///////////////////////////////////////////////////////////////////////////////
  10426. static void addMenu(view_listener_t* menup, const std::string& name)
  10427. {
  10428. sMenus.push_back(menup);
  10429. menup->registerListener(gMenuHolderp, name);
  10430. }
  10431. void initialize_menus()
  10432. {
  10433. // File menu
  10434. addMenu(new LLFileBackupObject(), "File.BackupObject");
  10435. addMenu(new LLFileExportOBJ(), "File.ExportOBJ");
  10436. addMenu(new LLFileExportDAE(), "File.ExportDAE");
  10437. addMenu(new LLFileEnableBackupObject(), "File.EnableBackupObject");
  10438. addMenu(new LLFileImportObject(), "File.ImportObject");
  10439. addMenu(new LLFileUpLoadImportObject(), "File.UploadImportObject");
  10440. addMenu(new LLFileEnableImportObject(), "File.EnableImportObject");
  10441. addMenu(new LLFileImportSettings(), "File.ImportSettings");
  10442. addMenu(new LLFileEnableImportSettings(), "File.EnableImportSettings");
  10443. addMenu(new LLFileUploadImage(), "File.UploadImage");
  10444. addMenu(new LLFileUploadMaterial(), "File.UploadMaterial");
  10445. addMenu(new LLFileUploadSound(), "File.UploadSound");
  10446. addMenu(new LLFileUploadAnim(), "File.UploadAnim");
  10447. addMenu(new LLFileUploadBulk(), "File.UploadBulk");
  10448. addMenu(new LLFileEnableUpload(), "File.EnableUpload");
  10449. addMenu(new LLFileEnableUploadAnim(), "File.EnableUploadAnim");
  10450. addMenu(new LLFileEnableUploadSound(), "File.EnableUploadSound");
  10451. addMenu(new LLFileEnableUploadImage(), "File.EnableUploadImage");
  10452. addMenu(new LLFileCheckUploadBulk2K(), "File.CheckUploadBulk2K");
  10453. addMenu(new LLFileEnableUploadBulk2K(), "File.EnableUploadBulk2K");
  10454. addMenu(new LLFileEnableUploadMaterial(), "File.EnableUploadMaterial");
  10455. addMenu(new LLFileUploadModel(), "File.UploadModel");
  10456. addMenu(new LLFileEnableUploadModel(), "File.EnableUploadModel");
  10457. addMenu(new LLFileEnableSaveAs(), "File.EnableSaveAs");
  10458. addMenu(new LLFileSaveTexture(), "File.SaveTexture");
  10459. addMenu(new LLFileTakeSnapshot(), "File.TakeSnapshot");
  10460. addMenu(new LLFileTakeSnapshotToDisk(), "File.TakeSnapshotToDisk");
  10461. addMenu(new LLFileCloseWindow(), "File.CloseWindow");
  10462. addMenu(new LLFileEnableCloseWindow(), "File.EnableCloseWindow");
  10463. addMenu(new LLFileCloseAllWindows(), "File.CloseAllWindows");
  10464. addMenu(new LLFileEnableCloseAllWindows(), "File.EnableCloseAllWindows");
  10465. addMenu(new LLFileQuit(), "File.Quit");
  10466. // Edit menu
  10467. addMenu(new LLEditUndo(), "Edit.Undo");
  10468. addMenu(new LLEditRedo(), "Edit.Redo");
  10469. addMenu(new LLEditCut(), "Edit.Cut");
  10470. addMenu(new LLEditCopy(), "Edit.Copy");
  10471. addMenu(new LLEditPaste(), "Edit.Paste");
  10472. addMenu(new LLEditDelete(), "Edit.Delete");
  10473. addMenu(new LLEditSearch(), "Edit.Search");
  10474. addMenu(new LLEditSelectAll(), "Edit.SelectAll");
  10475. addMenu(new LLEditDeselect(), "Edit.Deselect");
  10476. addMenu(new LLEditDuplicate(), "Edit.Duplicate");
  10477. addMenu(new LLEditTakeOff(), "Edit.TakeOff");
  10478. addMenu(new LLRemoveAllTempAttachments(), "Edit.RemoveAllTempAttachments");
  10479. addMenu(new LLEditEnableUndo(), "Edit.EnableUndo");
  10480. addMenu(new LLEditEnableRedo(), "Edit.EnableRedo");
  10481. addMenu(new LLEditEnableCut(), "Edit.EnableCut");
  10482. addMenu(new LLEditEnableCopy(), "Edit.EnableCopy");
  10483. addMenu(new LLEditEnablePaste(), "Edit.EnablePaste");
  10484. addMenu(new LLEditEnableDelete(), "Edit.EnableDelete");
  10485. addMenu(new LLEditEnableSelectAll(), "Edit.EnableSelectAll");
  10486. addMenu(new LLEditEnableDeselect(), "Edit.EnableDeselect");
  10487. addMenu(new LLEditEnableDuplicate(), "Edit.EnableDuplicate");
  10488. addMenu(new LLEditEnableTakeOff(), "Edit.EnableTakeOff");
  10489. addMenu(new LLEditEnableCustomizeAvatar(), "Edit.EnableCustomizeAvatar");
  10490. addMenu(new LLEditEnableOutfitPicker(), "Edit.EditEnableOutfitPicker");
  10491. addMenu(new LLEditEnableDisplayName(), "Edit.EnableDisplayName");
  10492. addMenu(new LLEnableRemoveAllTempAttachments(),
  10493. "Edit.EnableRemoveAllTempAttachments");
  10494. // View menu
  10495. addMenu(new LLViewMouselook(), "View.Mouselook");
  10496. addMenu(new LLViewJoystickFlycam(), "View.JoystickFlycam");
  10497. addMenu(new LLViewResetView(), "View.ResetView");
  10498. addMenu(new LLViewReleaseCamera(), "View.ReleaseCamera");
  10499. addMenu(new LLViewEnableReleaseCamera(), "View.EnableReleaseCamera");
  10500. addMenu(new LLViewLookAtLastChatter(), "View.LookAtLastChatter");
  10501. addMenu(new LLViewShowHoverTips(), "View.ShowHoverTips");
  10502. addMenu(new LLViewHighlightTransparent(), "View.HighlightTransparent");
  10503. addMenu(new LLViewToggleRenderType(), "View.ToggleRenderType");
  10504. addMenu(new LLViewShowHUDAttachments(), "View.ShowHUDAttachments");
  10505. addMenu(new LLZoomer(1.2f), "View.ZoomOut");
  10506. addMenu(new LLZoomer(1.f / 1.2f), "View.ZoomIn");
  10507. addMenu(new LLZoomer(DEFAULT_FIELD_OF_VIEW, false), "View.ZoomDefault");
  10508. addMenu(new LLViewDefaultUISize(), "View.DefaultUISize");
  10509. addMenu(new LLViewEnableMouselook(), "View.EnableMouselook");
  10510. addMenu(new LLViewEnableJoystickFlycam(), "View.EnableJoystickFlycam");
  10511. addMenu(new LLViewEnableLastChatter(), "View.EnableLastChatter");
  10512. addMenu(new LLViewEnableNearbyMedia(), "View.EnableNearbyMedia");
  10513. //MK
  10514. addMenu(new LLViewEnableBeacons(), "View.EnableBeacons");
  10515. addMenu(new LLViewEnableHUDAttachments(), "View.EnableHUDAttachments");
  10516. //mk
  10517. addMenu(new LLViewCheckCameraFrontView(), "View.CheckCameraFrontView");
  10518. addMenu(new LLViewCheckJoystickFlycam(), "View.CheckJoystickFlycam");
  10519. addMenu(new LLViewCheckShowHoverTips(), "View.CheckShowHoverTips");
  10520. addMenu(new LLViewCheckShowHoverTips(), "View.CheckShowHoverTips");
  10521. addMenu(new LLViewCheckHighlightTransparent(),
  10522. "View.CheckHighlightTransparent");
  10523. addMenu(new LLViewCheckRenderType(), "View.CheckRenderType");
  10524. addMenu(new LLViewCheckHUDAttachments(), "View.CheckHUDAttachments");
  10525. // World menu
  10526. addMenu(new LLWorldChat(), "World.Chat");
  10527. addMenu(new LLWorldAlwaysRun(), "World.AlwaysRun");
  10528. addMenu(new LLWorldSitOnGround(), "World.SitOnGround");
  10529. addMenu(new LLWorldEnableSitOnGround(), "World.EnableSitOnGround");
  10530. addMenu(new LLWorldFly(), "World.Fly");
  10531. addMenu(new LLWorldEnableFly(), "World.EnableFly");
  10532. addMenu(new LLWorldCreateLandmark(), "World.CreateLandmark");
  10533. addMenu(new LLWorldSetHomeLocation(), "World.SetHomeLocation");
  10534. addMenu(new LLWorldTeleportHome(), "World.TeleportHome");
  10535. addMenu(new LLWorldTPtoGround(), "World.TPtoGround");
  10536. addMenu(new LLWorldToggleRadar(), "World.ToggleAvatarList");
  10537. addMenu(new LLWorldSetAway(), "World.SetAway");
  10538. addMenu(new LLWorldSetBusy(), "World.SetBusy");
  10539. addMenu(new LLWorldSetAutoReply(), "World.SetAutoReply");
  10540. addMenu(new LLWorldStopAllAnimations(), "World.StopAllAnimations");
  10541. addMenu(new LLWorldReleaseKeys(), "World.ReleaseKeys");
  10542. addMenu(new LLWorldEnableReleaseKeys(), "World.EnableReleaseKeys");
  10543. addMenu(new LLWorldEnableCreateLandmark(), "World.EnableCreateLandmark");
  10544. addMenu(new LLWorldEnableSetHomeLocation(), "World.EnableSetHomeLocation");
  10545. addMenu(new LLWorldEnableTeleportHome(), "World.EnableTeleportHome");
  10546. addMenu(new LLWorldEnableBuyLand(), "World.EnableBuyLand");
  10547. addMenu(new LLWorldEnableAvatarList(), "World.EnableAvatarList");
  10548. addMenu(new LLWorldEnableExperiences(), "World.EnableExperiences");
  10549. addMenu(new LLWorldEnableIfInSL(), "World.EnableInSL");
  10550. addMenu(new LLWorldEnableIfNotInSL(), "World.EnableNotInSL");
  10551. addMenu(new LLWorldEnableWindlightRegionTime(),
  10552. "World.EnableWindlightRegionTime");
  10553. addMenu(new LLWorldEnableParcelEnv(), "World.EnableParcelEnv");
  10554. addMenu(new LLWorldEnableLocalEnv(), "World.EnableLocalEnv");
  10555. addMenu(new LLWorldSetSkySunlightScale(), "World.SetSkySunlightScale");
  10556. addMenu(new LLWorldShowSkySunlightScale(), "World.ShowSkySunlightScale");
  10557. addMenu(new LLWorldHasSkySunlightScale(), "World.HasSkySunlightScale");
  10558. addMenu(new LLWorldHasAdjustHDR(), "World.HasAdjustHDR");
  10559. addMenu(new LLWorldHasDesaturate(), "World.HasDesaturate");
  10560. addMenu(new LLWorldReflectionsEnabled(), "World.ReflectionsEnabled");
  10561. addMenu(new LLWorldLoadHDRISky(), "World.LoadHDRISky");
  10562. addMenu(new LLWorldCanLoadHDRISky(), "World.CanLoadHDRISky");
  10563. addMenu(new LLWorldUseHDRISky(), "World.UseHDRISky");
  10564. addMenu(new LLWorldHasHDRISky(), "World.HasHDRISky");
  10565. addMenu(new LLWorldCheckAlwaysRun(), "World.CheckAlwaysRun");
  10566. (new LLWorldEnvSettings())->registerListener(gMenuHolderp,
  10567. "World.EnvSettings");
  10568. // Tools menu
  10569. addMenu(new LLToolsBuildMode(), "Tools.BuildMode");
  10570. addMenu(new LLToolsSelectTool(), "Tools.SelectTool");
  10571. addMenu(new LLToolsSetSelectionsPolicy(), "Tools.SetSelectionsPolicy");
  10572. addMenu(new LLToolsShowSelectionsPolicy(), "Tools.ShowSelectionsPolicy");
  10573. addMenu(new LLToolsEditLinkedParts(), "Tools.EditLinkedParts");
  10574. addMenu(new LLToolsSnapObjectXY(), "Tools.SnapObjectXY");
  10575. addMenu(new LLToolsUseSelectionForGrid(), "Tools.UseSelectionForGrid");
  10576. addMenu(new LLToolsSelectNextPartFace(), "Tools.SelectNextPart");
  10577. addMenu(new LLToolsLink(), "Tools.Link");
  10578. addMenu(new LLToolsUnlink(), "Tools.Unlink");
  10579. addMenu(new LLToolsLookAtSelection(), "Tools.LookAtSelection");
  10580. addMenu(new LLToolsBuyOrTake(), "Tools.BuyOrTake");
  10581. addMenu(new LLToolsTakeCopy(), "Tools.TakeCopy");
  10582. addMenu(new LLToolsSaveToObjectInventory(), "Tools.SaveToObjectInventory");
  10583. addMenu(new LLToolsSelectedScriptAction(), "Tools.SelectedScriptAction");
  10584. addMenu(new LLToolsEnablePathfinding(), "Tools.EnablePathfinding");
  10585. addMenu(new LLToolsCheckBuildMode(), "Tools.CheckBuildMode");
  10586. addMenu(new LLToolsEnableToolNotPie(), "Tools.EnableToolNotPie");
  10587. addMenu(new LLToolsEnableSelectNextPart(), "Tools.EnableSelectNextPart");
  10588. addMenu(new LLToolsEnableLink(), "Tools.EnableLink");
  10589. addMenu(new LLToolsEnableUnlink(), "Tools.EnableUnlink");
  10590. addMenu(new LLToolsEnableBuyOrTake(), "Tools.EnableBuyOrTake");
  10591. addMenu(new LLToolsEnableTakeCopy(), "Tools.EnableTakeCopy");
  10592. addMenu(new LLToolsEnableSaveToObjectInventory(),
  10593. "Tools.SaveToObjectInventory");
  10594. // Help menu
  10595. // most items use the ShowFloater method
  10596. // Advanced menu
  10597. addMenu(new LLAdvancedLoadFromXML(), "Advanced.LoadFromXML");
  10598. addMenu(new LLAdvancedEnableLoadFromXML(), "Advanced.EnableLoadFromXML");
  10599. // Self pie menu
  10600. addMenu(new HBSelfGroupTitles(), "Self.GroupTitles");
  10601. addMenu(new LLSelfSitOrStand(), "Self.SitOrStand");
  10602. addMenu(new LLSelfRemoveAllAttachments(), "Self.RemoveAllAttachments");
  10603. addMenu(new LLRemoveAllTempAttachments(), "Self.RemoveAllTempAttachments");
  10604. addMenu(new LLSelfEnableSitOrStand(), "Self.EnableSitOrStand");
  10605. addMenu(new LLSelfEnableRemoveAllAttachments(),
  10606. "Self.EnableRemoveAllAttachments");
  10607. addMenu(new LLEnableRemoveAllTempAttachments(),
  10608. "Self.EnableRemoveAllTempAttachments");
  10609. // Avatar pie menu
  10610. addMenu(new LLObjectMute(), "Avatar.Mute");
  10611. addMenu(new LLAvatarRender(), "Avatar.Render");
  10612. addMenu(new LLAvatarToggleMaxLOD(), "Avatar.ToggleMaxLOD");
  10613. addMenu(new LLAvatarEnableMaxLOD(), "Avatar.EnableMaxLOD");
  10614. addMenu(new LLAvatarEnableNormalLOD(), "Avatar.EnableNormalLOD");
  10615. addMenu(new LLAvatarAddFriend(), "Avatar.AddFriend");
  10616. addMenu(new LLAvatarFreeze(), "Avatar.Freeze");
  10617. addMenu(new LLAvatarDebug(), "Avatar.Debug");
  10618. addMenu(new LLAvatarEnableDebug(), "Avatar.EnableDebug");
  10619. addMenu(new LLAvatarInviteToGroup(), "Avatar.InviteToGroup");
  10620. addMenu(new LLAvatarGiveCard(), "Avatar.GiveCard");
  10621. addMenu(new LLAvatarEject(), "Avatar.Eject");
  10622. addMenu(new LLAvatarSendIM(), "Avatar.SendIM");
  10623. addMenu(new LLAvatarReportAbuse(), "Avatar.ReportAbuse");
  10624. addMenu(new LLObjectEnableMute(), "Avatar.EnableMute");
  10625. addMenu(new LLAvatarEnableAddFriend(), "Avatar.EnableAddFriend");
  10626. addMenu(new LLAvatarEnableFreezeEject(), "Avatar.EnableFreezeEject");
  10627. // Object pie menu
  10628. addMenu(new LLObjectOpen(), "Object.Open");
  10629. addMenu(new LLObjectBuild(), "Object.Build");
  10630. addMenu(new LLObjectTouch(), "Object.Touch");
  10631. addMenu(new LLObjectSitOrStand(), "Object.SitOrStand");
  10632. addMenu(new LLObjectDelete(), "Object.Delete");
  10633. addMenu(new LLObjectAttachToAvatar(), "Object.AttachToAvatar");
  10634. addMenu(new LLObjectReturn(), "Object.Return");
  10635. addMenu(new LLObjectReportAbuse(), "Object.ReportAbuse");
  10636. addMenu(new LLObjectMute(), "Object.Mute");
  10637. addMenu(new LLObjectToggleMaxLOD(), "Object.ToggleMaxLOD");
  10638. addMenu(new LLObjectEnableMaxLOD(), "Object.EnableMaxLOD");
  10639. addMenu(new LLObjectEnableNormalLOD(), "Object.EnableNormalLOD");
  10640. addMenu(new LLObjectDerender(), "Object.Derender");
  10641. addMenu(new LLObjectEnableDerender(), "Object.EnableDerender");
  10642. addMenu(new LLObjectBuy(), "Object.Buy");
  10643. addMenu(new LLObjectEdit(), "Object.Edit");
  10644. addMenu(new LLObjectInspect(), "Object.Inspect");
  10645. addMenu(new LLSelfInspect(), "Self.Inspect");
  10646. addMenu(new LLObjectLoadGltfScene(), "Object.LoadGLTF");
  10647. addMenu(new LLObjectCanLoadGltfScene(), "Object.CanLoadGLTF");
  10648. addMenu(new LLObjectEnableOpen(), "Object.EnableOpen");
  10649. addMenu(new LLObjectEnableTouch(), "Object.EnableTouch");
  10650. addMenu(new LLObjectEnableSitOrStand(), "Object.EnableSitOrStand");
  10651. addMenu(new LLObjectEnableDelete(), "Object.EnableDelete");
  10652. addMenu(new LLObjectEnableWear(), "Object.EnableWear");
  10653. addMenu(new LLObjectEnableReturn(), "Object.EnableReturn");
  10654. addMenu(new LLObjectEnableReportAbuse(), "Object.EnableReportAbuse");
  10655. addMenu(new LLObjectEnableMute(), "Object.EnableMute");
  10656. addMenu(new LLObjectEnableBuy(), "Object.EnableBuy");
  10657. // Attachment pie menu
  10658. addMenu(new LLAttachmentDrop(), "Attachment.Drop");
  10659. addMenu(new LLAttachmentDetach(), "Attachment.Detach");
  10660. addMenu(new LLAttachmentEnableDrop(), "Attachment.EnableDrop");
  10661. addMenu(new LLAttachmentEnableDetach(), "Attachment.EnableDetach");
  10662. // Land pie menu
  10663. addMenu(new LLLandBuild(), "Land.Build");
  10664. addMenu(new LLLandSit(), "Land.Sit");
  10665. addMenu(new LLLandBuyPass(), "Land.BuyPass");
  10666. addMenu(new LLLandEdit(), "Land.Edit");
  10667. addMenu(new LLLandEnableBuyPass(), "Land.EnableBuyPass");
  10668. addMenu(new LLLandCanSit(), "Land.CanSit");
  10669. // Particle pie menu
  10670. addMenu(new LLMuteParticle(), "Particle.Mute");
  10671. addMenu(new LLReportParticleAbuse(), "Particle.ReportAbuse");
  10672. addMenu(new LLParticleRefreshTexture(), "Particle.RefreshTexture");
  10673. addMenu(new LLParticleEnableEntry(), "Particle.EnableEntry");
  10674. // Lua pie menu
  10675. addMenu(new LLPieLuaCall(), "PieLua.Call");
  10676. // Generic actions
  10677. addMenu(new LLShowFloater(), "ShowFloater");
  10678. addMenu(new LLPromptShowURL(), "PromptShowURL");
  10679. addMenu(new LLPromptShowOneOfURLs(), "PromptShowOneOfURLs");
  10680. addMenu(new LLPromptShowURLInternal(), "PromptShowURLInternal");
  10681. addMenu(new LLShowAgentProfile(), "ShowAgentProfile");
  10682. addMenu(new LLToggleControl(), "ToggleControl");
  10683. addMenu(new LLToggleControlPerAccount(), "ToggleControlPerAccount");
  10684. addMenu(new LLGoToObject(), "GoToObject");
  10685. addMenu(new LLPayObject(), "PayObject");
  10686. addMenu(new LLEnablePayObject(), "EnablePayObject");
  10687. addMenu(new LLEnableEdit(), "EnableEdit");
  10688. addMenu(new LLFloaterVisible(), "FloaterVisible");
  10689. addMenu(new LLSomethingSelected(), "SomethingSelected");
  10690. addMenu(new LLSomethingSelectedNoHUD(), "SomethingSelectedNoHUD");
  10691. addMenu(new LLEditableSelected(), "EditableSelected");
  10692. addMenu(new LLEditableSelectedMono(), "EditableSelectedMono");
  10693. }