MainFrm.cpp 161 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : LevelEdit *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/LevelEdit/MainFrm.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 3/12/02 4:01p $*
  29. * *
  30. * $Revision:: 140 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "stdafx.h"
  36. #include "leveledit.h"
  37. #include "mainfrm.h"
  38. #include "leveleditview.h"
  39. #include "deviceselectiondialog.h"
  40. #include "utils.h"
  41. #include "outputform.h"
  42. #include "cameramgr.h"
  43. #include "mousemgr.h"
  44. #include "lightambientform.h"
  45. #include "camerasettingsform.h"
  46. #include "ww3d.h"
  47. #include "filemgr.h"
  48. #include "sceneeditor.h"
  49. #include "editorassetmgr.h"
  50. #include "_assetmgr.h"
  51. #include "welcomedialog.h"
  52. #include "regkeys.h"
  53. #include "icons.h"
  54. #include "part_ldr.h"
  55. #include "includefilesdialog.h"
  56. #include "_wwaudio.h"
  57. #include "soundscene.h"
  58. #include "sunlightdialog.h"
  59. #include "generatevisdialog.h"
  60. #include "visualoptionsdialog.h"
  61. #include "filelocations.h"
  62. #include "viserrorreportdialog.h"
  63. #include "mesh.h"
  64. #include "pathdebugplotter.h"
  65. #include "pathfind.h"
  66. #include "path.h"
  67. #include "chunkio.h"
  68. #include "saveload.h"
  69. #include "definitionfactory.h"
  70. #include "definitionfactorymgr.h"
  71. #include "definitionmgr.h"
  72. #include "definition.h"
  73. #include "definitionclassids.h"
  74. #include "presetslibform.h"
  75. #include "presetmgr.h"
  76. #include "groupmgr.h"
  77. #include "mover.h"
  78. #include "node.h"
  79. #include "combatsaveload.h"
  80. #include "combat.h"
  81. #include "assets.h"
  82. #include "export.h"
  83. #include "timemgr.h"
  84. #include "scriptmgr.h"
  85. #include "scripts.h"
  86. #include "gameobjmanager.h"
  87. #include "nodemgr.h"
  88. #include "editorsaveload.h"
  89. #include "surfaceeffects.h"
  90. #include "progressui.h"
  91. #include "DefinitionUtils.h"
  92. #include "physstaticsavesystem.h"
  93. #include "PathfindPortal.h"
  94. #include "objectnode.h"
  95. #include "vehicle.h"
  96. #include "staticphys.h"
  97. #include "GotoLocationDialog.h"
  98. #include "VisStatsDialog.h"
  99. #include "NodeIDStartDialog.h"
  100. #include "PathfindSectorBuilder.h"
  101. #include "vismgr.h"
  102. #include "optimizingvisdialog.h"
  103. #include "stringlibrarydialog.h"
  104. #include "stringsmgr.h"
  105. #include "heightdb.h"
  106. #include "editconversationlistdialog.h"
  107. #include "pathmgr.h"
  108. #include "pathsolve.h"
  109. #include "generictextdialog.h"
  110. #include "musicproppage.h"
  111. #include "skyproppage.h"
  112. #include "weatherproppage.h"
  113. #include "memlogdialog.h"
  114. #include "translatedb.h"
  115. #include "gotoobjectbyiddialog.h"
  116. #include "exportpresetsdialog.h"
  117. #include "presetexport.h"
  118. #include "dazzle.h"
  119. #include "sphereobj.h"
  120. #include "ringobj.h"
  121. #include "soundrobj.h"
  122. #include "levelsettingsdialog.h"
  123. #include "ffactorylist.h"
  124. #include "importtranslationdialog.h"
  125. #include "reportmgr.h"
  126. #include "missingtranslationreportdialog.h"
  127. #include "translationexportdialog.h"
  128. #include "ccamera.h"
  129. #include "rcstringextractor.h"
  130. #include "dialogmgr.h"
  131. #include "mixfiledatabase.h"
  132. #include "assetpackagemgr.h"
  133. #include "lightsolveoptionsdialog.h"
  134. #ifdef _DEBUG
  135. #define new DEBUG_NEW
  136. #undef THIS_FILE
  137. static char THIS_FILE[] = __FILE__;
  138. #endif
  139. /////////////////////////////////////////////////////////////////////////////
  140. // Constants
  141. /////////////////////////////////////////////////////////////////////////////
  142. const int CAMERA_MENU_INDEX = 8;
  143. /////////////////////////////////////////////////////////////////////////////
  144. // Globals
  145. /////////////////////////////////////////////////////////////////////////////
  146. EditorFileFactoryClass _TheEditorFileFactory;
  147. /////////////////////////////////////////////////////////////////////////////
  148. // CMainFrame
  149. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  150. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  151. //{{AFX_MSG_MAP(CMainFrame)
  152. ON_WM_CREATE()
  153. ON_WM_CLOSE()
  154. ON_COMMAND(IDM_OBJECT_MANIPULATE, OnObjectManipulate)
  155. ON_UPDATE_COMMAND_UI(IDM_OBJECT_MANIPULATE, OnUpdateObjectManipulate)
  156. ON_COMMAND(IDM_MODE_CAMERA, OnModeCamera)
  157. ON_UPDATE_COMMAND_UI(IDM_MODE_CAMERA, OnUpdateModeCamera)
  158. ON_COMMAND(IDM_DELETE_SELECTION, OnDeleteSelection)
  159. ON_COMMAND(IDM_MODE_ORBIT, OnModeOrbit)
  160. ON_UPDATE_COMMAND_UI(IDM_MODE_ORBIT, OnUpdateModeOrbit)
  161. ON_COMMAND(IDM_COORD_WORLD, OnCoordWorld)
  162. ON_UPDATE_COMMAND_UI(IDM_COORD_WORLD, OnUpdateCoordWorld)
  163. ON_COMMAND(IDM_COORD_VIEW, OnCoordView)
  164. ON_UPDATE_COMMAND_UI(IDM_COORD_VIEW, OnUpdateCoordView)
  165. ON_COMMAND(IDM_COORD_OBJECT, OnCoordObject)
  166. ON_UPDATE_COMMAND_UI(IDM_COORD_OBJECT, OnUpdateCoordObject)
  167. ON_COMMAND(IDM_RESTRICT_X, OnRestrictX)
  168. ON_COMMAND(IDM_RESTRICT_Y, OnRestrictY)
  169. ON_COMMAND(IDM_RESTRICT_Z, OnRestrictZ)
  170. ON_UPDATE_COMMAND_UI(IDM_RESTRICT_Z, OnUpdateRestrictZ)
  171. ON_UPDATE_COMMAND_UI(IDM_RESTRICT_Y, OnUpdateRestrictY)
  172. ON_UPDATE_COMMAND_UI(IDM_RESTRICT_X, OnUpdateRestrictX)
  173. ON_COMMAND(IDM_CAMERA_FRONT, OnCameraFront)
  174. ON_COMMAND(IDM_CAMERA_BACK, OnCameraBack)
  175. ON_COMMAND(IDM_CAMERA_LEFT, OnCameraLeft)
  176. ON_COMMAND(IDM_CAMERA_RIGHT, OnCameraRight)
  177. ON_COMMAND(IDM_CAMERA_TOP, OnCameraTop)
  178. ON_COMMAND(IDM_CAMERA_BOTTOM, OnCameraBottom)
  179. ON_COMMAND(IDM_DROP_TO_GROUND, OnDropToGround)
  180. ON_UPDATE_COMMAND_UI(IDM_DROP_TO_GROUND, OnUpdateDropToGround)
  181. ON_COMMAND(IDM_MODE_WALKTHROUGH, OnModeWalkthrough)
  182. ON_UPDATE_COMMAND_UI(IDM_MODE_WALKTHROUGH, OnUpdateModeWalkthrough)
  183. ON_COMMAND(IDM_VIEW_CHANGE_DEVICE, OnViewChangeDevice)
  184. ON_COMMAND(IDM_LEVEL_EXPORT, OnLevelExport)
  185. ON_COMMAND(IDM_VIEW_FULLSCREEN, OnViewFullscreen)
  186. ON_UPDATE_COMMAND_UI(IDM_VIEW_FULLSCREEN, OnUpdateViewFullscreen)
  187. ON_COMMAND(IDM_VIEW_AMBIENT_LIGHT_DLG, OnViewAmbientLightDlg)
  188. ON_UPDATE_COMMAND_UI(IDM_VIEW_AMBIENT_LIGHT_DLG, OnUpdateViewAmbientLightDlg)
  189. ON_UPDATE_COMMAND_UI(IDM_VIEW_TOOLBAR_CAMERA_SETTINGS, OnUpdateViewToolbarCameraSettings)
  190. ON_COMMAND(IDM_VIEW_TOOLBAR_CAMERA_SETTINGS, OnViewToolbarCameraSettings)
  191. ON_COMMAND(IDM_CAMERA_DEPTH_LESS, OnCameraDepthLess)
  192. ON_COMMAND(IDM_CAMERA_DEPTH_MORE, OnCameraDepthMore)
  193. ON_COMMAND(IDM_SAVE_PRESETS, OnSavePresets)
  194. ON_UPDATE_COMMAND_UI(IDM_SAVE_PRESETS, OnUpdateSavePresets)
  195. ON_COMMAND(IDM_TOGGLE_SNAPPOINTS, OnToggleSnappoints)
  196. ON_UPDATE_COMMAND_UI(IDM_TOGGLE_SNAPPOINTS, OnUpdateToggleSnappoints)
  197. ON_COMMAND(IDM_ALWAYS_EXPORT, OnAlwaysExport)
  198. ON_WM_DESTROY()
  199. ON_COMMAND(IDM_CHANGE_BASE, OnChangeBase)
  200. ON_COMMAND(IDM_CAM_SPEED_INCREASE, OnCamSpeedIncrease)
  201. ON_COMMAND(IDM_CAM_SPEED_DECREASE, OnCamSpeedDecrease)
  202. ON_COMMAND(IDM_CAM_RESET, OnCamReset)
  203. ON_WM_KEYDOWN()
  204. ON_COMMAND(IDM_GEN_VIS, OnGenVis)
  205. ON_COMMAND(IDM_TOGGLE_VIS_WINDOW, OnToggleVisWindow)
  206. ON_COMMAND(IDM_ANI_BACK_FRAME, OnAniBackFrame)
  207. ON_COMMAND(IDM_ANI_FIRST_FRAME, OnAniFirstFrame)
  208. ON_COMMAND(IDM_ANI_FWD_FRAME, OnAniFwdFrame)
  209. ON_COMMAND(IDM_ANI_LAST_FRAME, OnAniLastFrame)
  210. ON_COMMAND(IDM_ANI_PAUSE, OnAniPause)
  211. ON_COMMAND(IDM_ANI_PLAY, OnAniPlay)
  212. ON_COMMAND(IDM_ANI_STOP, OnAniStop)
  213. ON_COMMAND(ID_EDIT_UNDO, OnEditUndo)
  214. ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo)
  215. ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
  216. ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateEditCopy)
  217. ON_COMMAND(ID_EDIT_CUT, OnEditCut)
  218. ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, OnUpdateEditCut)
  219. ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
  220. ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdateEditPaste)
  221. ON_COMMAND(IDM_CREATE_GROUP, OnCreateGroup)
  222. ON_UPDATE_COMMAND_UI(IDM_CREATE_GROUP, OnUpdateCreateGroup)
  223. ON_COMMAND(IDM_TOGGLE_LIGHTS, OnToggleLights)
  224. ON_UPDATE_COMMAND_UI(IDM_TOGGLE_LIGHTS, OnUpdateToggleLights)
  225. ON_COMMAND(IDM_REPARTITION, OnRepartition)
  226. ON_COMMAND(IDM_ALLOW_AUTO_UPDATES, OnAllowAutoUpdates)
  227. ON_UPDATE_COMMAND_UI(IDM_ALLOW_AUTO_UPDATES, OnUpdateAllowAutoUpdates)
  228. ON_COMMAND(IDM_ROTATE_LEFT, OnRotateLeft)
  229. ON_COMMAND(IDM_ROTATE_RIGHT, OnRotateRight)
  230. ON_COMMAND(IDM_CALC_ALL_LIGHTS, OnCalcAllLights)
  231. ON_COMMAND(IDM_CALC_SEL_LIGHTS, OnCalcSelLights)
  232. ON_UPDATE_COMMAND_UI(IDM_CALC_SEL_LIGHTS, OnUpdateCalcSelLights)
  233. ON_COMMAND(IDM_LOCK_OBJECTS, OnLockObjects)
  234. ON_COMMAND(IDM_UNLOCK_OBJECTS, OnUnlockObjects)
  235. ON_UPDATE_COMMAND_UI(IDM_LOCK_OBJECTS, OnUpdateLockObjects)
  236. ON_UPDATE_COMMAND_UI(IDM_UNLOCK_OBJECTS, OnUpdateUnlockObjects)
  237. ON_COMMAND(IDM_EDIT_INCLUDES, OnEditIncludes)
  238. ON_COMMAND(IDM_VOL_DEC, OnVolDec)
  239. ON_COMMAND(IDM_VOL_INC, OnVolInc)
  240. ON_COMMAND(IDM_BACKGROUND_SETTINGS, OnBackgroundSettings)
  241. ON_COMMAND(IDM_TOGGLE_MUSIC, OnToggleMusic)
  242. ON_UPDATE_COMMAND_UI(IDM_TOGGLE_MUSIC, OnUpdateToggleMusic)
  243. ON_COMMAND(IDM_TOGGLE_SOUNDS, OnToggleSounds)
  244. ON_UPDATE_COMMAND_UI(IDM_TOGGLE_SOUNDS, OnUpdateToggleSounds)
  245. ON_COMMAND(IDM_VIEW_AGGREGATE_CHILDREN, OnViewAggregateChildren)
  246. ON_UPDATE_COMMAND_UI(IDM_VIEW_AGGREGATE_CHILDREN, OnUpdateViewAggregateChildren)
  247. ON_COMMAND(IDM_TOGGLE_SUNLIGHT, OnToggleSunlight)
  248. ON_UPDATE_COMMAND_UI(IDM_TOGGLE_SUNLIGHT, OnUpdateToggleSunlight)
  249. ON_COMMAND(IDM_EDIT_SUNLIGHT, OnEditSunlight)
  250. ON_COMMAND(IDM_AUTO_GEN_VIS, OnAutoGenVis)
  251. ON_COMMAND(IDM_VISUAL_OPTIONS, OnVisualOptions)
  252. ON_COMMAND(IDM_VIS_INVERT, OnVisInvert)
  253. ON_COMMAND(IDM_VIEW_VIS_POINTS, OnViewVisPoints)
  254. ON_UPDATE_COMMAND_UI(IDM_VIEW_VIS_POINTS, OnUpdateViewVisPoints)
  255. ON_COMMAND(IDM_SPECIFY_ASSET_DATABASE, OnSpecifyAssetDatabase)
  256. ON_UPDATE_COMMAND_UI(IDM_VIS_INVERT, OnUpdateVisInvert)
  257. ON_COMMAND(IDM_TOGGLE_BACKFACES, OnToggleBackfaces)
  258. ON_UPDATE_COMMAND_UI(IDM_TOGGLE_BACKFACES, OnUpdateToggleBackfaces)
  259. ON_COMMAND(IDM_TOGGLE_WIREFRAME_MODE, OnToggleWireframeMode)
  260. ON_UPDATE_COMMAND_UI(IDM_TOGGLE_WIREFRAME_MODE, OnUpdateToggleWireframeMode)
  261. ON_COMMAND(IDM_VIEW_VIS_ERRORS, OnViewVisErrors)
  262. ON_COMMAND(IDM_USE_VIS_CAMERA, OnUseVisCamera)
  263. ON_UPDATE_COMMAND_UI(IDM_USE_VIS_CAMERA, OnUpdateUseVisCamera)
  264. ON_COMMAND(IDM_GENERATE_OBSTACLE_VOLUMES, OnGenerateObstacleVolumes)
  265. ON_COMMAND(IDM_VIS_DISABLE, OnVisDisable)
  266. ON_UPDATE_COMMAND_UI(IDM_VIS_DISABLE, OnUpdateVisDisable)
  267. ON_COMMAND(IDM_DISPLAY_PATHS, OnDisplayPaths)
  268. ON_UPDATE_COMMAND_UI(IDM_DISPLAY_PATHS, OnUpdateDisplayPaths)
  269. ON_COMMAND(IDM_TEST_PATHFIND, OnTestPathfind)
  270. ON_COMMAND(IDM_DISPLAY_PATHFIND_SECTORS, OnDisplayPathfindSectors)
  271. ON_UPDATE_COMMAND_UI(IDM_DISPLAY_PATHFIND_SECTORS, OnUpdateDisplayPathfindSectors)
  272. ON_COMMAND(IDM_DISPLAY_PATHFIND_PORTALS, OnDisplayPathfindPortals)
  273. ON_UPDATE_COMMAND_UI(IDM_DISPLAY_PATHFIND_PORTALS, OnUpdateDisplayPathfindPortals)
  274. ON_COMMAND(IDM_DISPLAY_PATHFIND_RAW_DATA, OnDisplayPathfindRawData)
  275. ON_UPDATE_COMMAND_UI(IDM_DISPLAY_PATHFIND_RAW_DATA, OnUpdateDisplayPathfindRawData)
  276. ON_COMMAND(IDM_EXPORT_PATHFIND, OnExportPathfind)
  277. ON_COMMAND(IDM_IMPORT_PATHFIND, OnImportPathfind)
  278. ON_COMMAND(IDM_IMPORT_VIS, OnImportVis)
  279. ON_COMMAND(IDM_EXPORT_VIS, OnExportVis)
  280. ON_COMMAND(IDM_VIEW_VIS_WINDOW, OnViewVisWindow)
  281. ON_UPDATE_COMMAND_UI(IDM_VIEW_VIS_WINDOW, OnUpdateViewVisWindow)
  282. ON_COMMAND(IDM_TOGGLE_MAN_VIS_POINTS, OnToggleManVisPoints)
  283. ON_UPDATE_COMMAND_UI(IDM_TOGGLE_MAN_VIS_POINTS, OnUpdateToggleManVisPoints)
  284. ON_COMMAND(IDM_DISCARD_PATHFIND, OnDiscardPathfind)
  285. ON_COMMAND(IDM_EXPORT_SOUNDS, OnDoDebug1)
  286. ON_COMMAND(IDM_IMPORT_SOUNDS, OnDoDebug2)
  287. ON_COMMAND(IDM_IMPORT_DYN_OBJS, OnImportDynObjs)
  288. ON_COMMAND(IDM_EXPORT_DYN_OBJS, OnExportDynObjs)
  289. ON_COMMAND(IDM_TEST_GOTO, OnTestGoto)
  290. ON_COMMAND(IDM_IMPORT_STATIC, OnImportStatic)
  291. ON_COMMAND(IDM_EXPORT_STATIC, OnExportStatic)
  292. ON_COMMAND(IDM_DISPLAY_WEB, OnDisplayWeb)
  293. ON_UPDATE_COMMAND_UI(IDM_DISPLAY_WEB, OnUpdateDisplayWeb)
  294. ON_UPDATE_COMMAND_UI(IDM_DISPLAY_FULL_PATHS, OnUpdateDisplayFullPaths)
  295. ON_COMMAND(IDM_DISPLAY_FULL_PATHS, OnDisplayFullPaths)
  296. ON_COMMAND(IDM_ESCAPE, OnEscape)
  297. ON_COMMAND(IDM_DISPLAY_VIS_GRID, OnDisplayVisGrid)
  298. ON_UPDATE_COMMAND_UI(IDM_DISPLAY_VIS_GRID, OnUpdateDisplayVisGrid)
  299. ON_COMMAND(IDM_DISPLAY_VIS_SECTORS, OnDisplayVisSectors)
  300. ON_UPDATE_COMMAND_UI(IDM_DISPLAY_VIS_SECTORS, OnUpdateDisplayVisSectors)
  301. ON_COMMAND(IDM_PRELIT_MULTIPASS, OnPrelitMultipass)
  302. ON_UPDATE_COMMAND_UI(IDM_PRELIT_MULTIPASS, OnUpdatePrelitMultipass)
  303. ON_COMMAND(IDM_PRELIT_MULTITEX, OnPrelitMultitex)
  304. ON_UPDATE_COMMAND_UI(IDM_PRELIT_MULTITEX, OnUpdatePrelitMultitex)
  305. ON_COMMAND(IDM_PRELIT_VERTEX, OnPrelitVertex)
  306. ON_UPDATE_COMMAND_UI(IDM_PRELIT_VERTEX, OnUpdatePrelitVertex)
  307. ON_COMMAND(IDM_DEBUG_SCRIPTS_MODE, OnDebugScriptsMode)
  308. ON_UPDATE_COMMAND_UI(IDM_DEBUG_SCRIPTS_MODE, OnUpdateDebugScriptsMode)
  309. ON_COMMAND(IDM_IMPORT_LIGHTS, OnImportLights)
  310. ON_COMMAND(IDM_VIEW_SOUND_SPHERES, OnViewSoundSpheres)
  311. ON_UPDATE_COMMAND_UI(IDM_VIEW_SOUND_SPHERES, OnUpdateViewSoundSpheres)
  312. ON_COMMAND(IDM_VIEW_LIGHT_SPHERES, OnViewLightSpheres)
  313. ON_UPDATE_COMMAND_UI(IDM_VIEW_LIGHT_SPHERES, OnUpdateViewLightSpheres)
  314. ON_COMMAND(IDM_IMPORT_SUNLIGHT, OnImportSunlight)
  315. ON_COMMAND(IDM_DISCARD_VIS, OnDiscardVis)
  316. ON_COMMAND(IDM_INCREASE_SPHERE, OnIncreaseSphere)
  317. ON_UPDATE_COMMAND_UI(IDM_INCREASE_SPHERE, OnUpdateIncreaseSphere)
  318. ON_COMMAND(IDM_DECREASE_SPHERE, OnDecreaseSphere)
  319. ON_UPDATE_COMMAND_UI(IDM_DECREASE_SPHERE, OnUpdateDecreaseSphere)
  320. ON_COMMAND(IDM_RUN_JOB, OnRunJob)
  321. ON_COMMAND(IDM_GOTO_LOCATION, OnGotoLocation)
  322. ON_COMMAND(IDM_EXPORT_THUMBNAILS, OnExportThumbnails)
  323. ON_COMMAND(IDM_VIS_STATS, OnVisStats)
  324. ON_COMMAND(IDM_SET_NODE_ID_START, OnSetNodeIdStart)
  325. ON_COMMAND(IDM_BUILD_DYNA_CULLSYS, OnBuildDynaCullsys)
  326. ON_COMMAND(IDM_IMPORT_VIS_REMAP_DATA, OnImportVisRemapData)
  327. ON_COMMAND(IDM_EXPORT_VIS_REMAP_DATA, OnExportVisRemapData)
  328. ON_UPDATE_COMMAND_UI(IDM_BULK_REPLACE, OnUpdateBulkReplace)
  329. ON_COMMAND(IDM_BULK_REPLACE, OnBulkReplace)
  330. ON_COMMAND(IDM_CHECK_IDS, OnCheckIds)
  331. ON_COMMAND(IDM_EXPORT_LIGHTS, OnExportLights)
  332. ON_COMMAND(IDM_OPTIMIZE_VIS_DATA, OnOptimizeVisData)
  333. ON_COMMAND(IDM_DISPLAY_VIS_GRID_LITTLE_BOXES, OnDisplayVisGridLittleBoxes)
  334. ON_UPDATE_COMMAND_UI(IDM_DISPLAY_VIS_GRID_LITTLE_BOXES, OnUpdateDisplayVisGridLittleBoxes)
  335. ON_COMMAND(IDM_EDIT_STRINGS_TABLE, OnEditStringsTable)
  336. ON_COMMAND(IDM_EXPORT_STRING_IDS, OnExportStringIds)
  337. ON_COMMAND(IDM_IMPORT_STRING_IDS, OnImportStringIds)
  338. ON_COMMAND(IDM_BUILD_FLIGHT_INFO, OnBuildFlightInfo)
  339. ON_COMMAND(IDM_TOGGLE_ATTENUATION_SPHERES, OnToggleAttenuationSpheres)
  340. ON_UPDATE_COMMAND_UI(IDM_TOGGLE_ATTENUATION_SPHERES, OnUpdateToggleAttenuationSpheres)
  341. ON_COMMAND(IDM_FIX_ID_COLLISIONS, OnFixIdCollisions)
  342. ON_COMMAND(IDM_RESET_DYNA_CULL_SYSTEM, OnResetDynaCullSystem)
  343. ON_COMMAND(IDM_DISPLAY_LIGHT_VECTORS, OnDisplayLightVectors)
  344. ON_UPDATE_COMMAND_UI(IDM_DISPLAY_LIGHT_VECTORS, OnUpdateDisplayLightVectors)
  345. ON_COMMAND(IDM_DISPLAY_STATIC_ANIM_OBJECTS, OnDisplayStaticAnimObjects)
  346. ON_UPDATE_COMMAND_UI(IDM_DISPLAY_STATIC_ANIM_OBJECTS, OnUpdateDisplayStaticAnimObjects)
  347. ON_COMMAND(IDM_EDIT_CONVERSATIONS, OnEditConversations)
  348. ON_COMMAND(IDM_BUILDING_POWER_ON, OnBuildingPowerOn)
  349. ON_UPDATE_COMMAND_UI(IDM_BUILDING_POWER_ON, OnUpdateBuildingPowerOn)
  350. ON_COMMAND(IDM_CREATE_PROXIES, OnCreateProxies)
  351. ON_UPDATE_COMMAND_UI(IDM_CREATE_PROXIES, OnUpdateCreateProxies)
  352. ON_COMMAND(IDM_CHECK_IN_PRESET_CHANGES, OnCheckInPresetChanges)
  353. ON_UPDATE_COMMAND_UI(IDM_CHECK_IN_PRESET_CHANGES, OnUpdateCheckInPresetChanges)
  354. ON_COMMAND(IDM_IMMEDIATE_PRESET_CHECKIN, OnImmediatePresetCheckin)
  355. ON_UPDATE_COMMAND_UI(IDM_IMMEDIATE_PRESET_CHECKIN, OnUpdateImmediatePresetCheckin)
  356. ON_COMMAND(IDM_REMAP_IDS, OnRemapIds)
  357. ON_UPDATE_COMMAND_UI(IDM_REMAP_IDS, OnUpdateRemapIds)
  358. ON_COMMAND(IDM_VERIFY_CULLING, OnVerifyCulling)
  359. ON_COMMAND(IDM_ENABLE_VIS_SECTOR_FALLBACK, OnEnableVisSectorFallback)
  360. ON_UPDATE_COMMAND_UI(IDM_ENABLE_VIS_SECTOR_FALLBACK, OnUpdateEnableVisSectorFallback)
  361. ON_COMMAND(IDM_RUN_MANUAL_VIS_POINTS, OnRunManualVisPoints)
  362. ON_COMMAND(IDM_SHOW_EDITOR_OBJECTS, OnShowEditorObjects)
  363. ON_UPDATE_COMMAND_UI(IDM_SHOW_EDITOR_OBJECTS, OnUpdateShowEditorObjects)
  364. ON_COMMAND(IDM_ADD_CHILD_NODE, OnAddChildNode)
  365. ON_UPDATE_COMMAND_UI(IDM_ADD_CHILD_NODE, OnUpdateAddChildNode)
  366. ON_COMMAND(IDM_CHECK_MEMLOG, OnCheckMemlog)
  367. ON_COMMAND(IDM_MAKE_VIS_POINT, OnMakeVisPoint)
  368. ON_COMMAND(IDM_EXPORT_STRING_TABLE, OnExportStringTable)
  369. ON_COMMAND(IDM_GOTO_OBJECT, OnGotoObject)
  370. ON_COMMAND(IDM_EXPORT_PRESETS, OnExportPresets)
  371. ON_COMMAND(IDM_IMPORT_PRESETS, OnImportPresets)
  372. ON_COMMAND(IDM_BATCH_EXPORT, OnBatchExport)
  373. ON_COMMAND(IDM_LOCK_VIS_SAMPLE_POINT, OnLockVisSamplePoint)
  374. ON_UPDATE_COMMAND_UI(IDM_LOCK_VIS_SAMPLE_POINT, OnUpdateLockVisSamplePoint)
  375. ON_COMMAND(IDM_TOGGLE_TERRAIN_SELECTION, OnToggleTerrainSelection)
  376. ON_UPDATE_COMMAND_UI(IDM_TOGGLE_TERRAIN_SELECTION, OnUpdateToggleTerrainSelection)
  377. ON_COMMAND(IDM_EXPORT_PRESET_FILE_DEPENDENCIES, OnExportPresetFileDependencies)
  378. ON_COMMAND(IDM_IMPORT_STRINGS, OnImportStrings)
  379. ON_COMMAND(IDM_EXPORT_TILE_LIST, OnExportTileList)
  380. ON_COMMAND(IDM_REMAP_UNIMPORTANT_IDS, OnRemapUnimportantIds)
  381. ON_COMMAND(IDM_EDIT_LEVEL_SETTINGS, OnEditLevelSettings)
  382. ON_COMMAND(IDM_EXPORT_TRANSLATION_DATA, OnExportTranslationData)
  383. ON_COMMAND(IDM_IMPORT_TRANSLATION_DATA, OnImportTranslationData)
  384. ON_COMMAND(IDM_COMPRESS_TEXTURES, OnCompressTextures)
  385. ON_UPDATE_COMMAND_UI(IDM_COMPRESS_TEXTURES, OnUpdateCompressTextures)
  386. ON_COMMAND(IDM_EXPORT_FILE_USAGE_REPORT, OnExportFileUsageReport)
  387. ON_COMMAND(IDM_EXPORT_MISSING_TRANSLATION_REPORT, OnExportMissingTranslationReport)
  388. ON_COMMAND(IDM_EXPORT_LANGUAGE, OnExportLanguage)
  389. ON_WM_INITMENUPOPUP()
  390. ON_COMMAND(IDM_ALWAYS_LOCAL_EXPORT, OnAlwaysLocalExport)
  391. ON_COMMAND(IDM_EXPORT_INSTALLER_LANGUAGE_VERSION, OnExportInstallerLanguageVersion)
  392. ON_COMMAND(IDM_EXTRACT_INSTALLER_RC_STRINGS, OnExtractInstallerRcStrings)
  393. ON_COMMAND(IDM_EXTRACT_RC_STRINGS, OnExtractRcStrings)
  394. ON_COMMAND(IDM_CAMERA_PERSPECTIVE, OnCameraPerspective)
  395. ON_COMMAND(IDM_CAMERA_ORTHOGRAPHIC, OnCameraOrthographic)
  396. ON_UPDATE_COMMAND_UI(IDM_CAMERA_ORTHOGRAPHIC, OnUpdateCameraOrthographic)
  397. ON_UPDATE_COMMAND_UI(IDM_CAMERA_PERSPECTIVE, OnUpdateCameraPerspective)
  398. ON_COMMAND(IDM_MOD_EXPORT, OnModExport)
  399. ON_COMMAND(IDM_SAVE_LEVEL, OnSaveLevel)
  400. ON_COMMAND(IDM_COMPUTE_VERTEX_SOLVE, OnComputeVertexSolve)
  401. ON_COMMAND(IDM_MODE_HEIGHT_EDIT, OnModeHeightEdit)
  402. ON_UPDATE_COMMAND_UI(IDM_MODE_HEIGHT_EDIT, OnUpdateModeHeightEdit)
  403. //}}AFX_MSG_MAP
  404. END_MESSAGE_MAP()
  405. static UINT indicators[] =
  406. {
  407. ID_SEPARATOR, // status line indicator
  408. IDS_CAM_LOCATION,
  409. IDS_ANIM_FRAMES,
  410. IDS_TEXTURE_MEM,
  411. IDS_POLY_COUNT
  412. };
  413. extern CLevelEditApp theApp;
  414. //////////////////////////////////////////////////////////////////////////
  415. //
  416. // CMainFrame
  417. //
  418. CMainFrame::CMainFrame (void)
  419. : m_UpdateTimer (0),
  420. m_GrowthRate (0.25F),
  421. m_pCurrentDoc (NULL),
  422. m_MaxCamProfiles (0)
  423. {
  424. return ;
  425. }
  426. //////////////////////////////////////////////////////////////////////////
  427. //
  428. // ~CMainFrame
  429. //
  430. CMainFrame::~CMainFrame (void)
  431. {
  432. return ;
  433. }
  434. //////////////////////////////////////////////////////////////////////////
  435. //
  436. // OnCreate
  437. //
  438. //////////////////////////////////////////////////////////////////////////
  439. int
  440. CMainFrame::OnCreate (LPCREATESTRUCT lpCreateStruct)
  441. {
  442. ProgressUIMgrClass::Set_Status_Text ("Initializing User Interface...");
  443. if (CFrameWnd::OnCreate (lpCreateStruct) == -1)
  444. return -1;
  445. if (!m_wndStatusBar.Create(this) ||
  446. !m_wndStatusBar.SetIndicators(indicators,
  447. sizeof(indicators)/sizeof(UINT)))
  448. {
  449. TRACE0("Failed to create status bar\n");
  450. return -1; // fail to create
  451. }
  452. // Reset the status bar text
  453. m_wndStatusBar.SetPaneText (1, "");
  454. m_wndStatusBar.SetPaneText (2, "");
  455. m_wndStatusBar.SetPaneText (3, "");
  456. // Allow docking on any station
  457. EnableDocking (CBRS_ALIGN_ANY);
  458. // Create our global icon imagelist
  459. m_ImageList.Create (16, 16, ILC_COLOR | ILC_MASK, 2, 2);
  460. for (int index = 0; index < ICON_COUNT; index ++) {
  461. // Load this icon and add it to our imagelist
  462. HICON hicon = (HICON)::LoadImage (::AfxGetResourceHandle (),
  463. MAKEINTRESOURCE (ICON_RESOURCE_IDS[index]),
  464. IMAGE_ICON,
  465. 16,
  466. 16,
  467. LR_SHARED);
  468. m_ImageList.Add (hicon);
  469. }
  470. ImageList_SetOverlayImage (m_ImageList, PLUS_OVERLAY_ICON, 1);
  471. //
  472. // Create the application's toolbars
  473. //
  474. Create_Toolbars ();
  475. Create_Camera_Menu ();
  476. // Put the focus on the main view
  477. GetDlgItem (AFX_IDW_PANE_FIRST)->SetFocus ();
  478. Restore_Window_State ();
  479. SetForegroundWindow ();
  480. return 0;
  481. }
  482. ////////////////////////////////////////////////////////////////////////////
  483. //
  484. // Create_Camera_Menu
  485. //
  486. ////////////////////////////////////////////////////////////////////////////
  487. void
  488. CMainFrame::Create_Camera_Menu (void)
  489. {
  490. m_MaxCamProfiles = 0;
  491. //
  492. // Get the path to the camera ini file
  493. //
  494. CString full_path = ::Get_File_Mgr ()->Make_Full_Path (ALWAYS_INI_DIR);
  495. full_path = Make_Path (full_path, "cameras.ini");
  496. CMenu *main_menu = GetMenu ();
  497. CMenu *camera_menu = main_menu->GetSubMenu (CAMERA_MENU_INDEX);
  498. //
  499. // Get the INI file which contains the data for this viewer
  500. //
  501. INIClass *ini_file = ::Get_INI (full_path);
  502. if (ini_file != NULL) {
  503. //
  504. // Enumerate the entries...
  505. //
  506. int count = ini_file->Entry_Count ("Profile_List");
  507. for (int index = 0; index < count; index ++) {
  508. StringClass profile_name (0, true);
  509. ini_file->Get_String (profile_name, "Profile_List", ini_file->Get_Entry ("Profile_List", index));
  510. //
  511. // Add this entry to the menu
  512. //
  513. camera_menu->AppendMenu (MF_STRING | MF_ENABLED, IDM_FIRST_CAM_PROFILE + index, profile_name);
  514. m_CameraProfiles.Add (profile_name);
  515. m_MaxCamProfiles ++;
  516. }
  517. //
  518. // Set the check next to the first entry in the list
  519. //
  520. camera_menu->CheckMenuRadioItem (IDM_FIRST_CAM_PROFILE,
  521. IDM_FIRST_CAM_PROFILE + m_MaxCamProfiles, IDM_FIRST_CAM_PROFILE, MF_BYCOMMAND);
  522. }
  523. return ;
  524. }
  525. ////////////////////////////////////////////////////////////////////////////
  526. //
  527. // Restore_Window_State
  528. //
  529. ////////////////////////////////////////////////////////////////////////////
  530. void
  531. CMainFrame::Restore_Window_State (void)
  532. {
  533. //
  534. // Read the cached window information from the registry
  535. //
  536. /*CRect rect;
  537. rect.left = theApp.GetProfileInt ("Window", "Left", -1);
  538. rect.right = theApp.GetProfileInt ("Window", "Right", -1);
  539. rect.top = theApp.GetProfileInt ("Window", "Top", -1);
  540. rect.bottom = theApp.GetProfileInt ("Window", "Bottom", -1);
  541. bool is_max = (theApp.GetProfileInt ("Window", "Maximized", -1) == 1);
  542. if (is_max) {
  543. ::ShowWindow (m_hWnd, SW_MAXIMIZE);
  544. } else if (rect.left > 0 && rect.right > 0 && rect.top > 0 && rect.bottom > 0) {
  545. ::SetWindowPos (m_hWnd, NULL, rect.left, rect.top, rect.Width (), rect.Height (), SWP_NOZORDER);
  546. }*/
  547. //
  548. // Always show the editor maximized
  549. //
  550. ::ShowWindow (m_hWnd, SW_MAXIMIZE);
  551. return ;
  552. }
  553. //////////////////////////////////////////////////////////////////////////
  554. //
  555. // Create_Toolbars
  556. //
  557. void
  558. CMainFrame::Create_Toolbars (void)
  559. {
  560. //m_DialogBar.Create (this);
  561. //DockableFormClass *new_form = new OutputFormClass;
  562. //new_form->Create (CWnd::FromHandlePermanent (m_DialogBar.GetReBarCtrl ()), 101);
  563. //m_DialogBar.AddBar (new_form);
  564. m_TestBar.Create (this, CBRS_RIGHT, 101);
  565. m_TestBar.SetBarStyle (m_TestBar.GetBarStyle() |
  566. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_GRIPPER);
  567. m_TestBar.EnableDocking (CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
  568. // Create all the application's toolbars
  569. //m_wndToolBar.Create (this);
  570. //m_wndToolBar.LoadToolBar (IDR_MAINFRAME);
  571. m_AniToolbar.Create (this);
  572. m_AniToolbar.LoadToolBar (IDR_ANI_TOOLBAR);
  573. m_AniToolbar.SetWindowText ("Animation");
  574. m_wndBottomToolBar.Create (this);
  575. m_wndBottomToolBar.LoadToolBar (IDR_BOTTOM_TOOLBAR);
  576. m_OutputToolbar.Create (new OutputFormClass, "Output", this, 102);
  577. m_AmbientLightToolbar.Create (new LightAmbientFormClass, "Ambient Light", this, 103);
  578. m_CameraSettingsToolbar.Create (new CameraSettingsFormClass, "Camera Settings", this, 104);
  579. // Set the styles on the main toolbar
  580. /*m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  581. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);*/
  582. m_AniToolbar.SetBarStyle(m_AniToolbar.GetBarStyle() |
  583. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  584. m_wndBottomToolBar.SetBarStyle(m_wndBottomToolBar.GetBarStyle() |
  585. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  586. m_wndBottomToolBar.ModifyStyle(0, TBSTYLE_FLAT);
  587. // Set the allowed docking stations for each toolbar
  588. //m_wndToolBar.EnableDocking(CBRS_ALIGN_TOP);
  589. m_AniToolbar.EnableDocking(CBRS_ALIGN_ANY);
  590. m_wndBottomToolBar.EnableDocking(CBRS_ALIGN_TOP);
  591. m_OutputToolbar.EnableDocking (CBRS_ALIGN_BOTTOM | CBRS_ALIGN_TOP);
  592. m_AmbientLightToolbar.EnableDocking (0L);
  593. m_CameraSettingsToolbar.EnableDocking (0L);
  594. // Dock our dialogs
  595. //DockControlBar (&m_wndToolBar);
  596. DockControlBar (&m_wndBottomToolBar);
  597. DockControlBar (&m_OutputToolbar, AFX_IDW_DOCKBAR_BOTTOM);
  598. // Hide our floating dialog toolbars
  599. ShowControlBar (&m_AmbientLightToolbar, FALSE, FALSE);
  600. ShowControlBar (&m_CameraSettingsToolbar, FALSE, FALSE);
  601. ShowControlBar (&m_AniToolbar, FALSE, FALSE);
  602. CRect window_rect;
  603. GetWindowRect (&window_rect);
  604. //
  605. // Float our hidden dialog toolbars
  606. //
  607. FloatControlBar (&m_AmbientLightToolbar,
  608. CPoint (window_rect.left + ((window_rect.Width () << 1) / 3), window_rect.top + (window_rect.Height () >> 1)),
  609. CBRS_ALIGN_TOP);
  610. FloatControlBar (&m_CameraSettingsToolbar,
  611. CPoint (window_rect.left + ((window_rect.Width () << 1) / 3), window_rect.top + (window_rect.Height () >> 1)),
  612. CBRS_ALIGN_TOP);
  613. FloatControlBar (&m_AniToolbar,
  614. CPoint (window_rect.left + 10, (window_rect.top + window_rect.Height ()) - 10),
  615. CBRS_ALIGN_BOTTOM);
  616. // Allow timer updates while the mouse is hovering over the animation toolbar
  617. ::SetProp (m_AniToolbar, "ALLOW_UPDATE", (HANDLE)1);
  618. RecalcLayout ();
  619. return ;
  620. }
  621. //////////////////////////////////////////////////////////////////////////
  622. //
  623. // PreCreateWindow
  624. //
  625. BOOL
  626. CMainFrame::PreCreateWindow (CREATESTRUCT& cs)
  627. {
  628. // Allow the base class to process this message
  629. return CFrameWnd::PreCreateWindow (cs);
  630. }
  631. /////////////////////////////////////////////////////////////////////////////
  632. // CMainFrame diagnostics
  633. #ifdef _DEBUG
  634. void CMainFrame::AssertValid() const
  635. {
  636. CFrameWnd::AssertValid();
  637. }
  638. void CMainFrame::Dump(CDumpContext& dc) const
  639. {
  640. CFrameWnd::Dump(dc);
  641. }
  642. #endif //_DEBUG
  643. //////////////////////////////////////////////////////////////////////////
  644. //
  645. // OnFinalRelease
  646. //
  647. void
  648. CMainFrame::OnFinalRelease (void)
  649. {
  650. // Allow the base class to process this message
  651. CFrameWnd::OnFinalRelease ();
  652. return ;
  653. }
  654. void CALLBACK
  655. PatsTextCallback (AudibleSoundClass *sound_obj, const StringClass &text, uint32 user_param)
  656. {
  657. CString message;
  658. message.Format ("Got text callback: %s\tUser = %d\r\n", (LPCTSTR)text, user_param);
  659. ::Output_Message (message);
  660. return ;
  661. }
  662. //////////////////////////////////////////////////////////////////////////
  663. //
  664. // OnCreateClient
  665. //
  666. BOOL
  667. CMainFrame::OnCreateClient
  668. (
  669. LPCREATESTRUCT lpcs,
  670. CCreateContext* pContext
  671. )
  672. {
  673. // Let MFC know that we want to be the main window
  674. theApp.m_pMainWnd = this;
  675. // Allow the base class to process this message
  676. BOOL retval = CFrameWnd::OnCreateClient (lpcs, pContext);
  677. // Get the path where this exe was run from
  678. TCHAR filename[MAX_PATH];
  679. ::GetModuleFileName (NULL, filename, sizeof (filename));
  680. // Does this filename have a directory?
  681. LPTSTR pathname = ::strrchr (filename, '\\');
  682. if (pathname) {
  683. //
  684. // Set this directory as the current directory
  685. //
  686. pathname[0] = 0;
  687. ::SetCurrentDirectory (filename);
  688. }
  689. //
  690. // Get a pointer to the current doc
  691. //
  692. m_pCurrentDoc = (CLevelEditDoc *)GetActiveDocument ();
  693. //
  694. // Configure the INI file path for the game engine to use
  695. //
  696. Configure_File_Factories ();
  697. // Get a pointer to the main view
  698. CLevelEditView *pview = (CLevelEditView *)GetActiveView ();
  699. if (pview)
  700. {
  701. ProgressUIMgrClass::Set_Status_Text ("Initializing Render Device...");
  702. // Initialize the WW3D engine using the window handle from
  703. // the main view
  704. BOOL retval = (WW3D::Init ((HWND)*pview) == WW3D_ERROR_OK);
  705. ASSERT (retval);
  706. // Show a dialog to the user asking them which
  707. // device they would like to use.
  708. CDeviceSelectionDialog devicedialog;
  709. if (devicedialog.DoModal () == IDOK) {
  710. // Pass the user's selection from the onto the view
  711. pview->Set_Render_Device_Info (devicedialog.GetDeviceIndex (), devicedialog.GetBitsPerPixel ());
  712. } else {
  713. // Stop the application from running
  714. PostMessage (WM_CLOSE);
  715. retval = FALSE;
  716. }
  717. }
  718. //
  719. // Register a loader for particle emitters
  720. //
  721. WW3DAssetManager::Get_Instance()->Register_Prototype_Loader (&_ParticleEmitterLoader);
  722. WW3DAssetManager::Get_Instance()->Register_Prototype_Loader (&_SphereLoader);
  723. WW3DAssetManager::Get_Instance()->Register_Prototype_Loader (&_RingLoader);
  724. WW3DAssetManager::Get_Instance()->Register_Prototype_Loader (&_SoundRenderObjLoader);
  725. WW3DAssetManager::Get_Instance()->Set_WW3D_Load_On_Demand (true);
  726. // Initialize the render device
  727. ::Get_Main_View ()->Initialize_Render_Device ();
  728. if (m_pCurrentDoc != NULL) {
  729. m_pCurrentDoc->Init_Scene ();
  730. }
  731. //
  732. // Start up the audio system
  733. //
  734. ProgressUIMgrClass::Set_Status_Text ("Initializing Audio Device...");
  735. _pTheAudioManager = new WWAudioClass;
  736. _pTheAudioManager->Initialize ();
  737. _pTheAudioManager->Register_Text_Callback (PatsTextCallback, 1115);
  738. //
  739. // Initialize the game
  740. //
  741. ProgressUIMgrClass::Set_Status_Text ("Initializing Combat Engine...");
  742. DialogMgrClass::Initialize ("stylemgr.ini");
  743. CombatManager::Set_Observers_Active (false);
  744. CombatManager::Init ();
  745. CombatManager::Pre_Load_Level ();
  746. CombatManager::Set_I_Am_Client (true);
  747. CombatManager::Set_I_Am_Server (true);
  748. SurfaceEffectsManager::Enable_Effects (false);
  749. SurfaceEffectsManager::Set_Mode (SurfaceEffectsManager::MODE_OFF);
  750. PathMgrClass::Initialize ();
  751. CString scripts_path = ::Get_File_Mgr ()->Make_Full_Path (SCRIPTS_PATH);
  752. ::SetCurrentDirectory (scripts_path);
  753. ScriptMgrClass::Initialize ();
  754. ScriptManager::Init ();
  755. WW3D::Enable_Static_Sort_Lists(true);
  756. //
  757. // Load the presets
  758. //
  759. ProgressUIMgrClass::Set_Status_Text ("Loading preset library...");
  760. PresetsFormClass::Load_Databases ();
  761. //
  762. // Attach the sound system to the camera
  763. //
  764. SoundSceneClass *sound_scene = _pTheAudioManager->Get_Sound_Scene ();
  765. if (sound_scene != NULL) {
  766. sound_scene->Attach_Listener_To_Obj (::Get_Camera_Mgr ()->Get_Camera ());
  767. }
  768. // Return the TRUE/FALSE result code
  769. return retval;
  770. }
  771. //////////////////////////////////////////////////////////////////////////
  772. //
  773. // Configure_File_Factories
  774. //
  775. //////////////////////////////////////////////////////////////////////////
  776. void
  777. CMainFrame::Configure_File_Factories (void)
  778. {
  779. _TheFileFactory = &_TheEditorFileFactory;
  780. //
  781. // Prime the file factory with the path to INI files
  782. //
  783. CString ini_path = ::Get_File_Mgr ()->Make_Full_Path (ALWAYS_INI_DIR);
  784. Delimit_Path (ini_path);
  785. _TheEditorFileFactory.Add_Search_Path (ini_path);
  786. //
  787. // Configure a file factory that knows where to find INI files while in the editor
  788. //
  789. /*CString ini_path = ::Get_File_Mgr ()->Make_Full_Path (ALWAYS_INI_DIR);
  790. Delimit_Path (ini_path);
  791. _EditorINIFileFactory.Set_Sub_Directory (ini_path);
  792. _EditorINIFileFactory.Set_Strip_Path (true);
  793. //
  794. // Add these file factories to the list of factories
  795. //
  796. _TheEditorFileFactory.Add_FileFactory (&_EditorINIFileFactory);
  797. _TheEditorFileFactory.Add_FileFactory (&_EditorBaseFileFactory);
  798. _TheFileFactory = &_TheEditorFileFactory;*/
  799. return ;
  800. }
  801. //////////////////////////////////////////////////////////////////////////
  802. //
  803. // OnClose
  804. //
  805. //////////////////////////////////////////////////////////////////////////
  806. void
  807. CMainFrame::OnClose (void)
  808. {
  809. if (PresetMgrClass::Are_Presets_Dirty ()) {
  810. //
  811. // Does the user want to save the preset changes?
  812. //
  813. if (::Message_Box (m_hWnd, IDS_SAVE_PRESETS_MSG, IDS_SAVE_PRESETS_TITLE, MB_ICONQUESTION | MB_YESNO) == IDYES) {
  814. PresetMgrClass::Check_In_Presets ();
  815. } else {
  816. PresetMgrClass::Discard_Preset_Changes ();
  817. }
  818. }
  819. // Allow the base class to process this message
  820. CFrameWnd::OnClose ();
  821. return;
  822. }
  823. //////////////////////////////////////////////////////////////////////////
  824. //
  825. // OnObjectManipulate
  826. //
  827. //////////////////////////////////////////////////////////////////////////
  828. void
  829. CMainFrame::OnObjectManipulate (void)
  830. {
  831. // Get a pointer to the mouse manager for the editor
  832. MouseMgrClass *pmousemgr = ::Get_Mouse_Mgr ();
  833. // Were we succesful in getting the mouse manager?
  834. ASSERT (pmousemgr != NULL);
  835. if (pmousemgr != NULL) {
  836. pmousemgr->Set_Mouse_Mode (MouseMgrClass::MODE_OBJECT_MANIPULATE);
  837. }
  838. return ;
  839. }
  840. //////////////////////////////////////////////////////////////////////////
  841. //
  842. // OnUpdateObjectManipulate
  843. //
  844. void
  845. CMainFrame::OnUpdateObjectManipulate (CCmdUI* pCmdUI)
  846. {
  847. // Get a pointer to the mouse manager for the editor
  848. MouseMgrClass *pmousemgr = ::Get_Mouse_Mgr ();
  849. // Were we succesful in getting the mouse manager?
  850. ASSERT (pmousemgr != NULL);
  851. if (pmousemgr != NULL) {
  852. pCmdUI->SetCheck ((BOOL)pmousemgr->Get_Mouse_Mode () == MouseMgrClass::MODE_OBJECT_MANIPULATE);
  853. }
  854. return ;
  855. }
  856. //////////////////////////////////////////////////////////////////////////
  857. //
  858. // OnModeCamera
  859. //
  860. void
  861. CMainFrame::OnModeCamera (void)
  862. {
  863. // Get a pointer to the mouse manager for the editor
  864. MouseMgrClass *pmousemgr = ::Get_Mouse_Mgr ();
  865. // Were we succesful in getting the mouse manager?
  866. ASSERT (pmousemgr != NULL);
  867. if (pmousemgr != NULL) {
  868. pmousemgr->Set_Mouse_Mode (MouseMgrClass::MODE_CAMERA_DEFAULT);
  869. }
  870. return ;
  871. }
  872. //////////////////////////////////////////////////////////////////////////
  873. //
  874. // OnUpdateModeCamera
  875. //
  876. void
  877. CMainFrame::OnUpdateModeCamera (CCmdUI* pCmdUI)
  878. {
  879. // Get a pointer to the mouse manager for the editor
  880. MouseMgrClass *pmousemgr = ::Get_Mouse_Mgr ();
  881. // Were we succesful in getting the mouse manager?
  882. ASSERT (pmousemgr != NULL);
  883. if (pmousemgr != NULL) {
  884. pCmdUI->SetCheck ((BOOL)pmousemgr->Get_Mouse_Mode () == MouseMgrClass::MODE_CAMERA_DEFAULT);
  885. }
  886. return ;
  887. }
  888. //////////////////////////////////////////////////////////////////////////
  889. //
  890. // OnDeleteSelection
  891. //
  892. void
  893. CMainFrame::OnDeleteSelection (void)
  894. {
  895. ::Get_Scene_Editor ()->Delete_Nodes ();
  896. return ;
  897. }
  898. //////////////////////////////////////////////////////////////////////////
  899. //
  900. // OnModeOrbit
  901. //
  902. void
  903. CMainFrame::OnModeOrbit (void)
  904. {
  905. // Get a pointer to the mouse manager for the editor
  906. MouseMgrClass *pmousemgr = ::Get_Mouse_Mgr ();
  907. // Were we succesful in getting the mouse manager?
  908. ASSERT (pmousemgr != NULL);
  909. if (pmousemgr != NULL) {
  910. pmousemgr->Set_Mouse_Mode (MouseMgrClass::MODE_CAMERA_ORBIT);
  911. }
  912. return ;
  913. }
  914. //////////////////////////////////////////////////////////////////////////
  915. //
  916. // OnUpdateModeOrbit
  917. //
  918. void
  919. CMainFrame::OnUpdateModeOrbit (CCmdUI* pCmdUI)
  920. {
  921. // Get a pointer to the mouse manager for the editor
  922. MouseMgrClass *pmousemgr = ::Get_Mouse_Mgr ();
  923. // Were we succesful in getting the mouse manager?
  924. ASSERT (pmousemgr != NULL);
  925. if (pmousemgr != NULL) {
  926. pCmdUI->SetCheck ((BOOL)pmousemgr->Get_Mouse_Mode () == MouseMgrClass::MODE_CAMERA_ORBIT);
  927. }
  928. return ;
  929. }
  930. //////////////////////////////////////////////////////////////////////////
  931. //
  932. // OnCoordWorld
  933. //
  934. void
  935. CMainFrame::OnCoordWorld (void)
  936. {
  937. ::Get_Current_Document ()->Set_Coord_System (CLevelEditDoc::COORD_WORLD);
  938. return ;
  939. }
  940. //////////////////////////////////////////////////////////////////////////
  941. //
  942. // OnUpdateCoordWorld
  943. //
  944. void
  945. CMainFrame::OnUpdateCoordWorld (CCmdUI* pCmdUI)
  946. {
  947. pCmdUI->SetCheck (::Get_Current_Document ()->Get_Coord_System () == CLevelEditDoc::COORD_WORLD);
  948. return ;
  949. }
  950. //////////////////////////////////////////////////////////////////////////
  951. //
  952. // OnCoordView
  953. //
  954. void
  955. CMainFrame::OnCoordView (void)
  956. {
  957. ::Get_Current_Document ()->Set_Coord_System (CLevelEditDoc::COORD_VIEW);
  958. return ;
  959. }
  960. //////////////////////////////////////////////////////////////////////////
  961. //
  962. // OnUpdateCoordView
  963. //
  964. void
  965. CMainFrame::OnUpdateCoordView (CCmdUI* pCmdUI)
  966. {
  967. pCmdUI->SetCheck (::Get_Current_Document ()->Get_Coord_System () == CLevelEditDoc::COORD_VIEW);
  968. return ;
  969. }
  970. //////////////////////////////////////////////////////////////////////////
  971. //
  972. // OnCoordObject
  973. //
  974. void
  975. CMainFrame::OnCoordObject (void)
  976. {
  977. ::Get_Current_Document ()->Set_Coord_System (CLevelEditDoc::COORD_OBJECT);
  978. return ;
  979. }
  980. //////////////////////////////////////////////////////////////////////////
  981. //
  982. // OnUpdateCoordObject
  983. //
  984. void
  985. CMainFrame::OnUpdateCoordObject (CCmdUI* pCmdUI)
  986. {
  987. pCmdUI->SetCheck (::Get_Current_Document ()->Get_Coord_System () == CLevelEditDoc::COORD_OBJECT);
  988. return ;
  989. }
  990. //////////////////////////////////////////////////////////////////////////
  991. //
  992. // OnRestrictX
  993. //
  994. void
  995. CMainFrame::OnRestrictX (void)
  996. {
  997. CLevelEditDoc::AXIS_RESTRICTION restriction = CLevelEditDoc::RESTRICT_X;
  998. // Is we are already resticting to this axis, then turn off restriction
  999. if (::Get_Current_Document ()->Get_Axis_Restriction () == CLevelEditDoc::RESTRICT_X) {
  1000. restriction = CLevelEditDoc::RESTRICT_NONE;
  1001. }
  1002. // Set the new axis restriction
  1003. ::Get_Current_Document ()->Set_Axis_Restriction (restriction);
  1004. return ;
  1005. }
  1006. //////////////////////////////////////////////////////////////////////////
  1007. //
  1008. // OnRestrictY
  1009. //
  1010. void
  1011. CMainFrame::OnRestrictY (void)
  1012. {
  1013. CLevelEditDoc::AXIS_RESTRICTION restriction = CLevelEditDoc::RESTRICT_Y;
  1014. // Is we are already resticting to this axis, then turn off restriction
  1015. if (::Get_Current_Document ()->Get_Axis_Restriction () == CLevelEditDoc::RESTRICT_Y) {
  1016. restriction = CLevelEditDoc::RESTRICT_NONE;
  1017. }
  1018. // Set the new axis restriction
  1019. ::Get_Current_Document ()->Set_Axis_Restriction (restriction);
  1020. return ;
  1021. }
  1022. //////////////////////////////////////////////////////////////////////////
  1023. //
  1024. // OnRestrictZ
  1025. //
  1026. void
  1027. CMainFrame::OnRestrictZ (void)
  1028. {
  1029. CLevelEditDoc::AXIS_RESTRICTION restriction = CLevelEditDoc::RESTRICT_Z;
  1030. // Is we are already resticting to this axis, then turn off restriction
  1031. if (::Get_Current_Document ()->Get_Axis_Restriction () == CLevelEditDoc::RESTRICT_Z) {
  1032. restriction = CLevelEditDoc::RESTRICT_NONE;
  1033. }
  1034. // Set the new axis restriction
  1035. ::Get_Current_Document ()->Set_Axis_Restriction (restriction);
  1036. return ;
  1037. }
  1038. //////////////////////////////////////////////////////////////////////////
  1039. //
  1040. // OnUpdateRestrictZ
  1041. //
  1042. void
  1043. CMainFrame::OnUpdateRestrictZ (CCmdUI* pCmdUI)
  1044. {
  1045. pCmdUI->SetCheck (::Get_Current_Document ()->Get_Axis_Restriction () == CLevelEditDoc::RESTRICT_Z);
  1046. return ;
  1047. }
  1048. //////////////////////////////////////////////////////////////////////////
  1049. //
  1050. // OnUpdateRestrictY
  1051. //
  1052. void
  1053. CMainFrame::OnUpdateRestrictY (CCmdUI* pCmdUI)
  1054. {
  1055. pCmdUI->SetCheck (::Get_Current_Document ()->Get_Axis_Restriction () == CLevelEditDoc::RESTRICT_Y);
  1056. return ;
  1057. }
  1058. //////////////////////////////////////////////////////////////////////////
  1059. //
  1060. // OnUpdateRestrictX
  1061. //
  1062. void
  1063. CMainFrame::OnUpdateRestrictX (CCmdUI* pCmdUI)
  1064. {
  1065. pCmdUI->SetCheck (::Get_Current_Document ()->Get_Axis_Restriction () == CLevelEditDoc::RESTRICT_X);
  1066. return ;
  1067. }
  1068. //////////////////////////////////////////////////////////////////////////
  1069. //
  1070. // OnCameraFront
  1071. //
  1072. void
  1073. CMainFrame::OnCameraFront (void)
  1074. {
  1075. // Move the camera to this new position
  1076. ::Get_Camera_Mgr ()->Set_Camera_Pos (CameraMgr::CAMERA_FRONT);
  1077. return ;
  1078. }
  1079. //////////////////////////////////////////////////////////////////////////
  1080. //
  1081. // OnCameraBack
  1082. //
  1083. void
  1084. CMainFrame::OnCameraBack (void)
  1085. {
  1086. // Move the camera to this new position
  1087. ::Get_Camera_Mgr ()->Set_Camera_Pos (CameraMgr::CAMERA_BACK);
  1088. return ;
  1089. }
  1090. //////////////////////////////////////////////////////////////////////////
  1091. //
  1092. // OnCameraLeft
  1093. //
  1094. void
  1095. CMainFrame::OnCameraLeft (void)
  1096. {
  1097. // Move the camera to this new position
  1098. ::Get_Camera_Mgr ()->Set_Camera_Pos (CameraMgr::CAMERA_LEFT);
  1099. return ;
  1100. }
  1101. //////////////////////////////////////////////////////////////////////////
  1102. //
  1103. // OnCameraRight
  1104. //
  1105. void
  1106. CMainFrame::OnCameraRight (void)
  1107. {
  1108. // Move the camera to this new position
  1109. ::Get_Camera_Mgr ()->Set_Camera_Pos (CameraMgr::CAMERA_RIGHT);
  1110. return ;
  1111. }
  1112. //////////////////////////////////////////////////////////////////////////
  1113. //
  1114. // OnCameraTop
  1115. //
  1116. void
  1117. CMainFrame::OnCameraTop (void)
  1118. {
  1119. // Move the camera to this new position
  1120. ::Get_Camera_Mgr ()->Set_Camera_Pos (CameraMgr::CAMERA_TOP);
  1121. return ;
  1122. }
  1123. //////////////////////////////////////////////////////////////////////////
  1124. //
  1125. // OnCameraBottom
  1126. //
  1127. void
  1128. CMainFrame::OnCameraBottom (void)
  1129. {
  1130. // Move the camera to this new position
  1131. ::Get_Camera_Mgr ()->Set_Camera_Pos (CameraMgr::CAMERA_BOTTOM);
  1132. return ;
  1133. }
  1134. //////////////////////////////////////////////////////////////////////////
  1135. //
  1136. // OnDropToGround
  1137. //
  1138. void
  1139. CMainFrame::OnDropToGround (void)
  1140. {
  1141. int mods = ::Get_Current_Document ()->Get_Mode_Modifiers ();
  1142. ::Get_Current_Document ()->Set_Mode_Modifiers (mods ^ MODE_MOD_DROP_TO_GROUND);
  1143. return ;
  1144. }
  1145. //////////////////////////////////////////////////////////////////////////
  1146. //
  1147. // OnUpdateDropToGround
  1148. //
  1149. void
  1150. CMainFrame::OnUpdateDropToGround (CCmdUI* pCmdUI)
  1151. {
  1152. pCmdUI->SetCheck (::Get_Current_Document ()->Get_Mode_Modifiers () & MODE_MOD_DROP_TO_GROUND);
  1153. return ;
  1154. }
  1155. //////////////////////////////////////////////////////////////////////////
  1156. //
  1157. // OnModeWalkthrough
  1158. //
  1159. void
  1160. CMainFrame::OnModeWalkthrough (void)
  1161. {
  1162. // Get a pointer to the mouse manager for the editor
  1163. MouseMgrClass *pmousemgr = ::Get_Mouse_Mgr ();
  1164. // Were we succesful in getting the mouse manager?
  1165. ASSERT (pmousemgr != NULL);
  1166. if (pmousemgr != NULL) {
  1167. pmousemgr->Set_Mouse_Mode (MouseMgrClass::MODE_CAMERA_WALK);
  1168. }
  1169. return ;
  1170. }
  1171. //////////////////////////////////////////////////////////////////////////
  1172. //
  1173. // OnUpdateModeWalkthrough
  1174. //
  1175. void
  1176. CMainFrame::OnUpdateModeWalkthrough (CCmdUI* pCmdUI)
  1177. {
  1178. // Get a pointer to the mouse manager for the editor
  1179. MouseMgrClass *pmousemgr = ::Get_Mouse_Mgr ();
  1180. // Were we succesful in getting the mouse manager?
  1181. ASSERT (pmousemgr != NULL);
  1182. if (pmousemgr != NULL) {
  1183. pCmdUI->SetCheck ((BOOL)pmousemgr->Get_Mouse_Mode () == MouseMgrClass::MODE_CAMERA_WALK);
  1184. }
  1185. return ;
  1186. }
  1187. //////////////////////////////////////////////////////////////////////////
  1188. //
  1189. // OnUpdateModeWalkthrough
  1190. //
  1191. void
  1192. CMainFrame::OnViewChangeDevice (void)
  1193. {
  1194. CDeviceSelectionDialog devicedialog (false);
  1195. if (devicedialog.DoModal () == IDOK) {
  1196. // Pass the user's selection from the onto the view
  1197. ::Get_Main_View ()->Set_Render_Device_Info (devicedialog.GetDeviceIndex (), devicedialog.GetBitsPerPixel ());
  1198. ::Get_Main_View ()->Initialize_Render_Device ();
  1199. }
  1200. return ;
  1201. }
  1202. //////////////////////////////////////////////////////////////////////////
  1203. //
  1204. // OnLevelExport
  1205. //
  1206. void
  1207. CMainFrame::OnLevelExport (void)
  1208. {
  1209. // Determine which directory we should use as a default for the export
  1210. CString full_path = theApp.GetProfileString (CONFIG_KEY, LAST_EXPORT_DIR_VALUE);
  1211. if (full_path.GetLength () == 0) {
  1212. full_path = ::Get_File_Mgr ()->Make_Full_Path (LEVELS_ASSET_DIR);
  1213. }
  1214. _pThe3DAssetManager->Set_Current_Directory (full_path);
  1215. // Use the level's filename to generate a default INI filename
  1216. CString default_name = ::Get_Current_Document ()->GetPathName ();
  1217. if (default_name.GetLength () > 0) {
  1218. default_name = ::Get_Filename_From_Path (default_name);
  1219. default_name = ::Asset_Name_From_Filename (default_name);
  1220. default_name += ".mix";
  1221. }
  1222. CFileDialog saveFileDialog (FALSE,
  1223. ".mix",
  1224. default_name,
  1225. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  1226. "Renegade Mix (*.mix)|*.mix||",
  1227. this);
  1228. // Set the path, so it opens in the correct directory
  1229. saveFileDialog.m_ofn.lpstrInitialDir = full_path;
  1230. // Ask the user what commando level file they wish to save to
  1231. if (saveFileDialog.DoModal () == IDOK) {
  1232. ExporterClass exporter;
  1233. exporter.Export_Level (saveFileDialog.GetPathName ());
  1234. }
  1235. return ;
  1236. }
  1237. //////////////////////////////////////////////////////////////////////////
  1238. //
  1239. // OnViewFullscreen
  1240. //
  1241. void
  1242. CMainFrame::OnViewFullscreen (void)
  1243. {
  1244. // Toggle the fullscreen view
  1245. ::Get_Main_View ()->Set_Windowed (!::Get_Main_View ()->Is_Windowed ());
  1246. return ;
  1247. }
  1248. //////////////////////////////////////////////////////////////////////////
  1249. //
  1250. // OnUpdateViewFullscreen
  1251. //
  1252. void
  1253. CMainFrame::OnUpdateViewFullscreen (CCmdUI* pCmdUI)
  1254. {
  1255. // Check or uncheck the menu item based on the current windowed mode
  1256. pCmdUI->SetCheck (!::Get_Main_View ()->Is_Windowed ());
  1257. return ;
  1258. }
  1259. //////////////////////////////////////////////////////////////////////////
  1260. //
  1261. // OnViewAmbientLightDlg
  1262. //
  1263. void
  1264. CMainFrame::OnViewAmbientLightDlg (void)
  1265. {
  1266. // Toggle the visiblity state of the toolbar
  1267. BOOL show_dlg = !m_AmbientLightToolbar.IsWindowVisible ();
  1268. ShowControlBar (&m_AmbientLightToolbar, show_dlg, FALSE);
  1269. return ;
  1270. }
  1271. //////////////////////////////////////////////////////////////////////////
  1272. //
  1273. // OnUpdateViewAmbientLightDlg
  1274. //
  1275. void
  1276. CMainFrame::OnUpdateViewAmbientLightDlg (CCmdUI* pCmdUI)
  1277. {
  1278. // Check the menu option if the toolbar is currently displayed
  1279. pCmdUI->SetCheck (m_AmbientLightToolbar.IsWindowVisible ());
  1280. return ;
  1281. }
  1282. //////////////////////////////////////////////////////////////////////////
  1283. //
  1284. // OnViewToolbarCameraSettings
  1285. //
  1286. void
  1287. CMainFrame::OnViewToolbarCameraSettings (void)
  1288. {
  1289. // Toggle the visiblity state of the toolbar
  1290. BOOL show_dlg = !m_CameraSettingsToolbar.IsWindowVisible ();
  1291. ShowControlBar (&m_CameraSettingsToolbar, show_dlg, FALSE);
  1292. // Get a pointer to the camera settings dialog
  1293. CameraSettingsFormClass *pform = (CameraSettingsFormClass *)m_CameraSettingsToolbar.Get_Form ();
  1294. if (pform != NULL) {
  1295. pform->Update_Controls ();
  1296. }
  1297. return ;
  1298. }
  1299. //////////////////////////////////////////////////////////////////////////
  1300. //
  1301. // OnUpdateViewToolbarCameraSettings
  1302. //
  1303. void
  1304. CMainFrame::OnUpdateViewToolbarCameraSettings (CCmdUI* pCmdUI)
  1305. {
  1306. // Check the menu option if the toolbar is currently displayed
  1307. pCmdUI->SetCheck (m_CameraSettingsToolbar.IsWindowVisible ());
  1308. return ;
  1309. }
  1310. //////////////////////////////////////////////////////////////////////////
  1311. //
  1312. // OnCameraDepthLess
  1313. //
  1314. void
  1315. CMainFrame::OnCameraDepthLess (void)
  1316. {
  1317. CameraMgr *pcamera_mgr = ::Get_Camera_Mgr ();
  1318. if (pcamera_mgr != NULL) {
  1319. // Get the current 'near' clip plane
  1320. float near_plane = 0;
  1321. float far_plane = 0;
  1322. pcamera_mgr->Get_Camera ()->Get_Clip_Planes (near_plane, far_plane);
  1323. if (far_plane - 50 > 20) {
  1324. // Set the new 'far' clip plane
  1325. pcamera_mgr->Get_Camera ()->Set_Clip_Planes (near_plane, far_plane - 50);
  1326. }
  1327. // Make sure the scene is painted
  1328. ::Refresh_Main_View ();
  1329. }
  1330. return ;
  1331. }
  1332. //////////////////////////////////////////////////////////////////////////
  1333. //
  1334. // OnCameraDepthMore
  1335. //
  1336. void
  1337. CMainFrame::OnCameraDepthMore (void)
  1338. {
  1339. CameraMgr *pcamera_mgr = ::Get_Camera_Mgr ();
  1340. if (pcamera_mgr != NULL) {
  1341. // Get the current 'near' clip plane
  1342. float near_plane = 0;
  1343. float far_plane = 0;
  1344. pcamera_mgr->Get_Camera ()->Get_Clip_Planes (near_plane, far_plane);
  1345. if (far_plane + 50 < 4000) {
  1346. // Set the new 'far' clip plane
  1347. pcamera_mgr->Get_Camera ()->Set_Clip_Planes (near_plane, far_plane + 50);
  1348. }
  1349. // Make sure the scene is painted
  1350. ::Refresh_Main_View ();
  1351. }
  1352. return ;
  1353. }
  1354. //////////////////////////////////////////////////////////////////////////
  1355. //
  1356. // OnSavePresets
  1357. //
  1358. //////////////////////////////////////////////////////////////////////////
  1359. void
  1360. CMainFrame::OnSavePresets (void)
  1361. {
  1362. //
  1363. // Reload the presets into the form
  1364. //
  1365. /*PresetsFormClass *presets_form = ::Get_Presets_Form ();
  1366. if (presets_form != NULL) {
  1367. presets_form->Save_Presets ();
  1368. }*/
  1369. return ;
  1370. }
  1371. //////////////////////////////////////////////////////////////////////////
  1372. //
  1373. // OnUpdateSavePresets
  1374. //
  1375. //////////////////////////////////////////////////////////////////////////
  1376. void
  1377. CMainFrame::OnUpdateSavePresets (CCmdUI *pCmdUI)
  1378. {
  1379. pCmdUI->Enable (false);
  1380. return ;
  1381. }
  1382. //////////////////////////////////////////////////////////////////////////
  1383. //
  1384. // OnCommand
  1385. //
  1386. BOOL
  1387. CMainFrame::OnCommand
  1388. (
  1389. WPARAM wParam,
  1390. LPARAM lParam
  1391. )
  1392. {
  1393. if ((LOWORD (wParam) == ID_FILE_SAVE_AS) ||
  1394. (LOWORD (wParam) == ID_FILE_SAVE) ||
  1395. (LOWORD (wParam) == ID_FILE_OPEN)) {
  1396. // Set the current working directory to point to the last directory where
  1397. // we saved a file...
  1398. CString full_path = theApp.GetProfileString (CONFIG_KEY, LAST_SAVE_DIR_VALUE);
  1399. if (full_path.GetLength () != 0) {
  1400. ::SetCurrentDirectory (full_path);
  1401. _pThe3DAssetManager->Set_Current_Directory (full_path);
  1402. if (LOWORD (wParam) != ID_FILE_OPEN) {
  1403. //
  1404. // Compose a default save name
  1405. //
  1406. Delimit_Path (full_path);
  1407. full_path += ::Get_Current_Document ()->GetTitle ();
  1408. CString temp_path = full_path;
  1409. temp_path.MakeLower ();
  1410. if (temp_path.Find (".lvl") == -1) {
  1411. full_path += ".lvl";
  1412. }
  1413. ::Get_Current_Document ()->Set_Current_Path (full_path);
  1414. }
  1415. }
  1416. } else if (LOWORD (wParam) >= IDM_FIRST_CAM_PROFILE && LOWORD (wParam) <= IDM_LAST_CAM_PROFILE) {
  1417. CMenu *main_menu = GetMenu ();
  1418. CMenu *camera_menu = main_menu->GetSubMenu (CAMERA_MENU_INDEX);
  1419. //
  1420. // Switch to the new camera profile
  1421. //
  1422. int index = LOWORD (wParam) - IDM_FIRST_CAM_PROFILE;
  1423. CombatManager::Get_Camera()->Use_Profile (m_CameraProfiles[index]);
  1424. //
  1425. // Set the check next to the first entry in the list
  1426. //
  1427. camera_menu->CheckMenuRadioItem (IDM_FIRST_CAM_PROFILE,
  1428. IDM_FIRST_CAM_PROFILE + m_MaxCamProfiles, LOWORD (wParam), MF_BYCOMMAND);
  1429. }
  1430. // Allow the base class to process this message
  1431. return CFrameWnd::OnCommand(wParam, lParam);
  1432. }
  1433. //////////////////////////////////////////////////////////////////////////
  1434. //
  1435. // OnUpdateToggleSnappoints
  1436. //
  1437. void
  1438. CMainFrame::OnToggleSnappoints()
  1439. {
  1440. // Toggle the snap points setting
  1441. CLevelEditDoc *pdoc = ::Get_Current_Document ();
  1442. pdoc->Activate_Snap_Points (!pdoc->Are_Snap_Points_Active ());
  1443. return ;
  1444. }
  1445. //////////////////////////////////////////////////////////////////////////
  1446. //
  1447. // OnUpdateToggleSnappoints
  1448. //
  1449. void
  1450. CMainFrame::OnUpdateToggleSnappoints (CCmdUI* pCmdUI)
  1451. {
  1452. pCmdUI->SetCheck (::Get_Current_Document ()->Are_Snap_Points_Active ());
  1453. return ;
  1454. }
  1455. //////////////////////////////////////////////////////////////////////////
  1456. //
  1457. // OnAlwaysExport
  1458. //
  1459. //////////////////////////////////////////////////////////////////////////
  1460. void
  1461. CMainFrame::OnAlwaysExport (void)
  1462. {
  1463. //
  1464. // Ask the user to pick a path
  1465. //
  1466. CString path;
  1467. if (::Browse_For_Folder (path,
  1468. NULL,
  1469. NULL,
  1470. "Select a directory where the core file set will be copied.")) {
  1471. //
  1472. // Copy the always files to the specified directory
  1473. //
  1474. CWaitCursor wait_cursor;
  1475. ExporterClass exporter;
  1476. exporter.Export_Always_Files (path);
  1477. //
  1478. // Cache this path in the registry
  1479. //
  1480. theApp.WriteProfileString (CONFIG_KEY, LAST_EXPORT_DIR_VALUE, path);
  1481. }
  1482. return ;
  1483. }
  1484. //////////////////////////////////////////////////////////////////////////
  1485. //
  1486. // OnDestroy
  1487. //
  1488. void
  1489. CMainFrame::OnDestroy (void)
  1490. {
  1491. // Don't allow any more repaints
  1492. CLevelEditView::Allow_Repaint (false);
  1493. CRect rect;
  1494. WINDOWPLACEMENT wnd_info = { sizeof (WINDOWPLACEMENT), 0 };
  1495. ::GetWindowPlacement (m_hWnd, &wnd_info);
  1496. ::GetWindowRect (m_hWnd, &rect);
  1497. //
  1498. // Cache this information in the registry
  1499. //
  1500. theApp.WriteProfileInt ("Window", "Left", rect.left);
  1501. theApp.WriteProfileInt ("Window", "Right", rect.right);
  1502. theApp.WriteProfileInt ("Window", "Top", rect.top);
  1503. theApp.WriteProfileInt ("Window", "Bottom", rect.bottom);
  1504. theApp.WriteProfileInt ("Window", "Maximized", int(wnd_info.showCmd == SW_SHOWMAXIMIZED));
  1505. // We're closing the application so cleanup resources
  1506. CLevelEditDoc *pCDoc = (CLevelEditDoc *)GetActiveDocument ();
  1507. if (pCDoc) {
  1508. // Ask the Doc to free its resources
  1509. pCDoc->CleanupResources ();
  1510. }
  1511. //
  1512. // Shutdown the different systems
  1513. //
  1514. CombatManager::Unload_Level ();
  1515. CombatManager::Shutdown ();
  1516. ScriptMgrClass::Shutdown ();
  1517. PresetMgrClass::Free_Presets ();
  1518. DazzleRenderObjClass::Deinit ();
  1519. DefinitionMgrClass::Free_Definitions ();
  1520. DialogMgrClass::Shutdown ();
  1521. WWAudioClass::Get_Instance ()->Shutdown ();
  1522. PathMgrClass::Shutdown ();
  1523. //
  1524. // Free any resources the WW3D engine allocated
  1525. //
  1526. WW3DAssetManager::Get_Instance()->Free_Assets ();
  1527. //WW3D::Flush_Texture_Cache ();
  1528. WW3D::Shutdown ();
  1529. SAFE_DELETE (_pThe3DAssetManager);
  1530. ::RemoveProp (m_AniToolbar, "ALLOW_UPDATE");
  1531. CFrameWnd::OnDestroy ();
  1532. return ;
  1533. }
  1534. //////////////////////////////////////////////////////////////////////////
  1535. //
  1536. // OnChangeBase
  1537. //
  1538. void
  1539. CMainFrame::OnChangeBase (void)
  1540. {
  1541. ::Get_Current_Document ()->Change_Base_Path ();
  1542. return ;
  1543. }
  1544. //////////////////////////////////////////////////////////////////////////
  1545. //
  1546. // WindowProc
  1547. //
  1548. LRESULT
  1549. CMainFrame::WindowProc
  1550. (
  1551. UINT message,
  1552. WPARAM wParam,
  1553. LPARAM lParam
  1554. )
  1555. {
  1556. if (message == WM_USER+109) {
  1557. // Show the welcome dialog
  1558. WelcomeDialogClass welcome_dialog (this);
  1559. welcome_dialog.DoModal ();
  1560. }
  1561. return CFrameWnd::WindowProc(message, wParam, lParam);
  1562. }
  1563. //////////////////////////////////////////////////////////////////////////
  1564. //
  1565. // OnCamSpeedIncrease
  1566. //
  1567. void CMainFrame::OnCamSpeedIncrease (void)
  1568. {
  1569. ::Get_Camera_Mgr ()->Increase_Speed ();
  1570. return ;
  1571. }
  1572. //////////////////////////////////////////////////////////////////////////
  1573. //
  1574. // OnCamSpeedDecrease
  1575. //
  1576. void CMainFrame::OnCamSpeedDecrease (void)
  1577. {
  1578. ::Get_Camera_Mgr ()->Decrease_Speed ();
  1579. return ;
  1580. }
  1581. //////////////////////////////////////////////////////////////////////////
  1582. //
  1583. // OnCamReset
  1584. //
  1585. void CMainFrame::OnCamReset (void)
  1586. {
  1587. ::Get_Camera_Mgr ()->Level_Camera ();
  1588. return ;
  1589. }
  1590. //////////////////////////////////////////////////////////////////////////
  1591. //
  1592. // OnKeyDown
  1593. //
  1594. void
  1595. CMainFrame::OnKeyDown
  1596. (
  1597. UINT nChar,
  1598. UINT nRepCnt,
  1599. UINT nFlags
  1600. )
  1601. {
  1602. // Allow the base class to process this message
  1603. CFrameWnd::OnKeyDown(nChar, nRepCnt, nFlags);
  1604. return ;
  1605. }
  1606. //////////////////////////////////////////////////////////////////////////
  1607. //
  1608. // OnGenVis
  1609. //
  1610. void
  1611. CMainFrame::OnGenVis (void)
  1612. {
  1613. // Get a pointer to the mouse manager for the editor
  1614. MouseMgrClass *pmousemgr = ::Get_Mouse_Mgr ();
  1615. // Were we succesful in getting the mouse manager?
  1616. /*ASSERT (pmousemgr != NULL);
  1617. if ((pmousemgr != NULL) &&
  1618. (pmousemgr->Get_Mouse_Mode () == MouseMgrClass::MODE_CAMERA_WALK)) {
  1619. ::Get_Scene_Editor ()->Record_Vis_Info ();
  1620. }*/
  1621. return ;
  1622. }
  1623. //////////////////////////////////////////////////////////////////////////
  1624. //
  1625. // OnToggleVisWindow
  1626. //
  1627. void
  1628. CMainFrame::OnToggleVisWindow (void)
  1629. {
  1630. HWND hchild = ::GetDlgItem (::GetDesktopWindow (), 777);
  1631. if (::IsWindow (hchild)) {
  1632. UINT vis = ::IsWindowVisible (hchild) ? SW_HIDE : SW_SHOW;
  1633. ::ShowWindow (hchild, vis);
  1634. }
  1635. return ;
  1636. }
  1637. //////////////////////////////////////////////////////////////////////////
  1638. //
  1639. // Show_Ani_Toolbar
  1640. //
  1641. void
  1642. CMainFrame::Show_Ani_Toolbar (bool bshow)
  1643. {
  1644. ShowControlBar (&m_AniToolbar, (BOOL)bshow, FALSE);
  1645. return ;
  1646. }
  1647. //////////////////////////////////////////////////////////////////////////
  1648. //
  1649. // OnAniBackFrame
  1650. //
  1651. //////////////////////////////////////////////////////////////////////////
  1652. void
  1653. CMainFrame::OnAniBackFrame (void)
  1654. {
  1655. /*NodeInstanceClass *pnode = Get_Selection_Mgr ().Get_First ();
  1656. if ((pnode != NULL) &&
  1657. (pnode->Get_Type () == NODE_TYPE_TRANSITION_CHARACTER)) {
  1658. TransitionCharacterClass *pcharacter = (TransitionCharacterClass *)pnode;
  1659. pcharacter->Send_Animation_Message (TransitionCharacterClass::ANIM_BACK_FRAME);
  1660. }*/
  1661. return ;
  1662. }
  1663. //////////////////////////////////////////////////////////////////////////
  1664. //
  1665. // OnAniFirstFrame
  1666. //
  1667. //////////////////////////////////////////////////////////////////////////
  1668. void
  1669. CMainFrame::OnAniFirstFrame (void)
  1670. {
  1671. /*NodeInstanceClass *pnode = Get_Selection_Mgr ().Get_First ();
  1672. if ((pnode != NULL) &&
  1673. (pnode->Get_Type () == NODE_TYPE_TRANSITION_CHARACTER)) {
  1674. TransitionCharacterClass *pcharacter = (TransitionCharacterClass *)pnode;
  1675. pcharacter->Send_Animation_Message (TransitionCharacterClass::ANIM_FIRST_FRAME);
  1676. }*/
  1677. return ;
  1678. }
  1679. //////////////////////////////////////////////////////////////////////////
  1680. //
  1681. // OnAniFwdFrame
  1682. //
  1683. //////////////////////////////////////////////////////////////////////////
  1684. void
  1685. CMainFrame::OnAniFwdFrame (void)
  1686. {
  1687. /*NodeInstanceClass *pnode = Get_Selection_Mgr ().Get_First ();
  1688. if ((pnode != NULL) &&
  1689. (pnode->Get_Type () == NODE_TYPE_TRANSITION_CHARACTER)) {
  1690. TransitionCharacterClass *pcharacter = (TransitionCharacterClass *)pnode;
  1691. pcharacter->Send_Animation_Message (TransitionCharacterClass::ANIM_ADVANCE_FRAME);
  1692. }*/
  1693. return ;
  1694. }
  1695. //////////////////////////////////////////////////////////////////////////
  1696. //
  1697. // OnAniLastFrame
  1698. //
  1699. //////////////////////////////////////////////////////////////////////////
  1700. void
  1701. CMainFrame::OnAniLastFrame (void)
  1702. {
  1703. /*NodeInstanceClass *pnode = Get_Selection_Mgr ().Get_First ();
  1704. if ((pnode != NULL) &&
  1705. (pnode->Get_Type () == NODE_TYPE_TRANSITION_CHARACTER)) {
  1706. TransitionCharacterClass *pcharacter = (TransitionCharacterClass *)pnode;
  1707. pcharacter->Send_Animation_Message (TransitionCharacterClass::ANIM_LAST_FRAME);
  1708. }*/
  1709. return ;
  1710. }
  1711. //////////////////////////////////////////////////////////////////////////
  1712. //
  1713. // OnAniPause
  1714. //
  1715. //////////////////////////////////////////////////////////////////////////
  1716. void
  1717. CMainFrame::OnAniPause (void)
  1718. {
  1719. /*NodeInstanceClass *pnode = Get_Selection_Mgr ().Get_First ();
  1720. if ((pnode != NULL) &&
  1721. (pnode->Get_Type () == NODE_TYPE_TRANSITION_CHARACTER)) {
  1722. TransitionCharacterClass *pcharacter = (TransitionCharacterClass *)pnode;
  1723. pcharacter->Send_Animation_Message (TransitionCharacterClass::ANIM_PAUSE);
  1724. }*/
  1725. return ;
  1726. }
  1727. //////////////////////////////////////////////////////////////////////////
  1728. //
  1729. // OnAniPlay
  1730. //
  1731. //////////////////////////////////////////////////////////////////////////
  1732. void
  1733. CMainFrame::OnAniPlay (void)
  1734. {
  1735. /*NodeInstanceClass *pnode = Get_Selection_Mgr ().Get_First ();
  1736. if ((pnode != NULL) &&
  1737. (pnode->Get_Type () == NODE_TYPE_TRANSITION_CHARACTER)) {
  1738. TransitionCharacterClass *pcharacter = (TransitionCharacterClass *)pnode;
  1739. pcharacter->Send_Animation_Message (TransitionCharacterClass::ANIM_PLAY);
  1740. }*/
  1741. return ;
  1742. }
  1743. //////////////////////////////////////////////////////////////////////////
  1744. //
  1745. // OnAniStop
  1746. //
  1747. //////////////////////////////////////////////////////////////////////////
  1748. void
  1749. CMainFrame::OnAniStop (void)
  1750. {
  1751. /*NodeInstanceClass *pnode = Get_Selection_Mgr ().Get_First ();
  1752. if ((pnode != NULL) &&
  1753. (pnode->Get_Type () == NODE_TYPE_TRANSITION_CHARACTER)) {
  1754. TransitionCharacterClass *pcharacter = (TransitionCharacterClass *)pnode;
  1755. pcharacter->Send_Animation_Message (TransitionCharacterClass::ANIM_STOP);
  1756. }*/
  1757. return ;
  1758. }
  1759. //////////////////////////////////////////////////////////////////////////
  1760. //
  1761. // Update_Poly_Count
  1762. //
  1763. void
  1764. CMainFrame::Update_Poly_Count (void)
  1765. {
  1766. static DWORD last_update = ::GetTickCount ();
  1767. DWORD current_ticks = ::GetTickCount ();
  1768. if ((current_ticks - last_update) > 500) {
  1769. CString message;
  1770. message.Format ("Polys %d", WW3D::Get_Last_Frame_Poly_Count());
  1771. m_wndStatusBar.SetPaneText (4, message);
  1772. last_update = current_ticks;
  1773. }
  1774. return ;
  1775. }
  1776. //////////////////////////////////////////////////////////////////////////
  1777. //
  1778. // Update_Texture_Mem
  1779. //
  1780. //////////////////////////////////////////////////////////////////////////
  1781. void
  1782. CMainFrame::Update_Texture_Mem (void)
  1783. {
  1784. static DWORD last_update = ::GetTickCount ();
  1785. DWORD current_ticks = ::GetTickCount ();
  1786. if ((current_ticks - last_update) > 500) {
  1787. /*srGERD::Statistics stats = { 0 };
  1788. WW3D::Get_GERD ()->getStatistics (stats);
  1789. CString message;
  1790. message.Format ("Tex Upload: %dKB", int(float(stats.texDataTransfer / stats.frames) / 1024.0F));
  1791. m_wndStatusBar.SetPaneText (3, message);
  1792. last_update = current_ticks;
  1793. WW3D::Get_GERD ()->resetStatistics ();
  1794. */
  1795. }
  1796. return ;
  1797. }
  1798. //////////////////////////////////////////////////////////////////////////
  1799. //
  1800. // Update_Ani_Frame
  1801. //
  1802. void
  1803. CMainFrame::Update_Ani_Frame
  1804. (
  1805. int frame,
  1806. int max_frames
  1807. )
  1808. {
  1809. CString message;
  1810. message.Format ("Frame %d / %d", frame + 1, max_frames);
  1811. m_wndStatusBar.SetPaneText (2, message);
  1812. return ;
  1813. }
  1814. //////////////////////////////////////////////////////////////////////////
  1815. //
  1816. // Update_Camera_Location
  1817. //
  1818. void
  1819. CMainFrame::Update_Camera_Location (const Vector3 &position)
  1820. {
  1821. if (::IsWindow (m_wndStatusBar)) {
  1822. CString message;
  1823. message.Format ("Camera (%.2f,%.2f,%.2f)", position.X, position.Y, position.Z);
  1824. m_wndStatusBar.SetPaneText (1, message);
  1825. }
  1826. return ;
  1827. }
  1828. //////////////////////////////////////////////////////////////////////////
  1829. //
  1830. // OnUpdateEditUndo
  1831. //
  1832. void
  1833. CMainFrame::OnEditUndo (void)
  1834. {
  1835. ::Get_Scene_Editor ()->Undo ();
  1836. return ;
  1837. }
  1838. //////////////////////////////////////////////////////////////////////////
  1839. //
  1840. // OnUpdateEditUndo
  1841. //
  1842. void
  1843. CMainFrame::OnUpdateEditUndo (CCmdUI *pCmdUI)
  1844. {
  1845. // Enable/disable the menu option
  1846. pCmdUI->Enable (BOOL(::Get_Scene_Editor ()->Get_Undo_Mgr ().Get_Possible_Undo_Count () > 0));
  1847. // Determine what text to display for the undo operation
  1848. CString text;
  1849. if (::Get_Scene_Editor ()->Get_Undo_Mgr ().Get_Possible_Undo_Count () > 0) {
  1850. text.Format ("Undo (%s)\tAlt+Backspace", ::Get_Scene_Editor ()->Get_Undo_Mgr ().Get_Next_Undo_Name ());
  1851. } else {
  1852. text.Format ("Undo\tAlt+Backspace");
  1853. }
  1854. // Change the text of the menu option
  1855. pCmdUI->SetText (text);
  1856. return ;
  1857. }
  1858. //////////////////////////////////////////////////////////////////////////
  1859. //
  1860. // OnEditCopy
  1861. //
  1862. void
  1863. CMainFrame::OnEditCopy (void)
  1864. {
  1865. ::Get_Scene_Editor ()->Copy_Objects ();
  1866. return ;
  1867. }
  1868. //////////////////////////////////////////////////////////////////////////
  1869. //
  1870. // OnUpdateEditCopy
  1871. //
  1872. void
  1873. CMainFrame::OnUpdateEditCopy (CCmdUI* pCmdUI)
  1874. {
  1875. pCmdUI->Enable (::Get_Selection_Mgr ().Get_Count () > 0);
  1876. return ;
  1877. }
  1878. //////////////////////////////////////////////////////////////////////////
  1879. //
  1880. // OnEditCut
  1881. //
  1882. void
  1883. CMainFrame::OnEditCut (void)
  1884. {
  1885. ::Get_Scene_Editor ()->Cut_Objects ();
  1886. return ;
  1887. }
  1888. //////////////////////////////////////////////////////////////////////////
  1889. //
  1890. // OnUpdateEditCut
  1891. //
  1892. void
  1893. CMainFrame::OnUpdateEditCut (CCmdUI* pCmdUI)
  1894. {
  1895. pCmdUI->Enable (::Get_Scene_Editor ()->Get_Selection_Mgr ().Get_Count () > 0);
  1896. return ;
  1897. }
  1898. //////////////////////////////////////////////////////////////////////////
  1899. //
  1900. // OnEditPaste
  1901. //
  1902. void
  1903. CMainFrame::OnEditPaste (void)
  1904. {
  1905. ::Get_Scene_Editor ()->Paste_Objects ();
  1906. return ;
  1907. }
  1908. //////////////////////////////////////////////////////////////////////////
  1909. //
  1910. // OnUpdateEditPaste
  1911. //
  1912. void
  1913. CMainFrame::OnUpdateEditPaste (CCmdUI* pCmdUI)
  1914. {
  1915. pCmdUI->Enable (::Get_Scene_Editor ()->Can_Paste ());
  1916. return ;
  1917. }
  1918. //////////////////////////////////////////////////////////////////////////
  1919. //
  1920. // OnCreateGroup
  1921. //
  1922. void
  1923. CMainFrame::OnCreateGroup (void)
  1924. {
  1925. return ;
  1926. }
  1927. //////////////////////////////////////////////////////////////////////////
  1928. //
  1929. // OnUpdateCreateGroup
  1930. //
  1931. void
  1932. CMainFrame::OnUpdateCreateGroup (CCmdUI *pCmdUI)
  1933. {
  1934. pCmdUI->Enable (Get_Selection_Mgr ().Get_Count () > 0);
  1935. return ;
  1936. }
  1937. //////////////////////////////////////////////////////////////////////////
  1938. //
  1939. // OnToggleLights
  1940. //
  1941. void CMainFrame::OnToggleLights (void)
  1942. {
  1943. // Toggle the lights on/off
  1944. bool blights_on = ::Get_Scene_Editor ()->Are_Lights_On ();
  1945. ::Get_Scene_Editor ()->Turn_Lights_On (!blights_on);
  1946. return ;
  1947. }
  1948. //////////////////////////////////////////////////////////////////////////
  1949. //
  1950. // OnUpdateToggleLights
  1951. //
  1952. void
  1953. CMainFrame::OnUpdateToggleLights (CCmdUI *pCmdUI)
  1954. {
  1955. pCmdUI->SetCheck (::Get_Scene_Editor ()->Are_Lights_On ());
  1956. return ;
  1957. }
  1958. //////////////////////////////////////////////////////////////////////////
  1959. //
  1960. // OnRepartition
  1961. //
  1962. void
  1963. CMainFrame::OnRepartition (void)
  1964. {
  1965. CWaitCursor wait_cursor;
  1966. //
  1967. // Force a repartition for the scene...
  1968. //
  1969. ::Get_Scene_Editor ()->Re_Partition_Static_Objects ();
  1970. ::Get_Scene_Editor ()->Re_Partition_Static_Lights ();
  1971. ::Get_Scene_Editor ()->Re_Partition_Audio_System ();
  1972. return ;
  1973. }
  1974. //////////////////////////////////////////////////////////////////////////
  1975. //
  1976. // OnUpdateToggleLights
  1977. //
  1978. void
  1979. CMainFrame::OnAllowAutoUpdates (void)
  1980. {
  1981. // Toggle the state
  1982. FileMgrClass::_bAutoUpdateOn = !FileMgrClass::_bAutoUpdateOn;
  1983. return ;
  1984. }
  1985. //////////////////////////////////////////////////////////////////////////
  1986. //
  1987. // OnUpdateToggleLights
  1988. //
  1989. void
  1990. CMainFrame::OnUpdateAllowAutoUpdates (CCmdUI *pCmdUI)
  1991. {
  1992. pCmdUI->SetCheck (FileMgrClass::_bAutoUpdateOn);
  1993. return ;
  1994. }
  1995. //////////////////////////////////////////////////////////////////////////
  1996. //
  1997. // OnRotateLeft
  1998. //
  1999. //////////////////////////////////////////////////////////////////////////
  2000. void
  2001. CMainFrame::OnRotateLeft (void)
  2002. {
  2003. MoverClass::Rotate_Nodes_Z (-1.0F);
  2004. return ;
  2005. }
  2006. //////////////////////////////////////////////////////////////////////////
  2007. //
  2008. // OnRotateRight
  2009. //
  2010. //////////////////////////////////////////////////////////////////////////
  2011. void
  2012. CMainFrame::OnRotateRight (void)
  2013. {
  2014. MoverClass::Rotate_Nodes_Z (1.0F);
  2015. return ;
  2016. }
  2017. //////////////////////////////////////////////////////////////////////////
  2018. //
  2019. // OnCalcAllLights
  2020. //
  2021. //////////////////////////////////////////////////////////////////////////
  2022. void
  2023. CMainFrame::OnCalcAllLights (void)
  2024. {
  2025. //::Get_Scene_Editor ()->Update_Lighting ();
  2026. return ;
  2027. }
  2028. //////////////////////////////////////////////////////////////////////////
  2029. //
  2030. // OnCalcSelLights
  2031. //
  2032. //////////////////////////////////////////////////////////////////////////
  2033. void
  2034. CMainFrame::OnCalcSelLights (void)
  2035. {
  2036. /*PhysListClass list;
  2037. for (int index = 0; index < Get_Selection_Mgr ().Get_Count (); index ++) {
  2038. NodeClass *node = Get_Selection_Mgr ().Get_At (index);
  2039. if (node->Is_Static ()) {
  2040. list.Add (node->Peek_Physics_Obj ());
  2041. }
  2042. }
  2043. ::Get_Scene_Editor ()->Update_Lighting (&list);*/
  2044. return;
  2045. }
  2046. //////////////////////////////////////////////////////////////////////////
  2047. //
  2048. // OnUpdateCalcSelLights
  2049. //
  2050. //////////////////////////////////////////////////////////////////////////
  2051. void
  2052. CMainFrame::OnUpdateCalcSelLights (CCmdUI *pCmdUI)
  2053. {
  2054. pCmdUI->Enable (Get_Selection_Mgr ().Get_Count () > 0);
  2055. return ;
  2056. }
  2057. //////////////////////////////////////////////////////////////////////////
  2058. //
  2059. // OnLockObjects
  2060. //
  2061. void
  2062. CMainFrame::OnLockObjects (void)
  2063. {
  2064. ::Get_Scene_Editor ()->Lock_Nodes (true);
  2065. return ;
  2066. }
  2067. //////////////////////////////////////////////////////////////////////////
  2068. //
  2069. // OnUnlockObjects
  2070. //
  2071. void
  2072. CMainFrame::OnUnlockObjects (void)
  2073. {
  2074. ::Get_Scene_Editor ()->Lock_Nodes (false);
  2075. return ;
  2076. }
  2077. //////////////////////////////////////////////////////////////////////////
  2078. //
  2079. // OnUpdateLockObjects
  2080. //
  2081. //////////////////////////////////////////////////////////////////////////
  2082. void
  2083. CMainFrame::OnUpdateLockObjects (CCmdUI *pCmdUI)
  2084. {
  2085. pCmdUI->Enable (Get_Selection_Mgr ().Get_Count () > 0);
  2086. return ;
  2087. }
  2088. //////////////////////////////////////////////////////////////////////////
  2089. //
  2090. // OnUpdateUnlockObjects
  2091. //
  2092. //////////////////////////////////////////////////////////////////////////
  2093. void
  2094. CMainFrame::OnUpdateUnlockObjects (CCmdUI *pCmdUI)
  2095. {
  2096. pCmdUI->Enable (Get_Selection_Mgr ().Get_Count () > 0);
  2097. return ;
  2098. }
  2099. //////////////////////////////////////////////////////////////////////////
  2100. //
  2101. // OnEditIncludes
  2102. //
  2103. void
  2104. CMainFrame::OnEditIncludes (void)
  2105. {
  2106. IncludeFilesDialogClass dialog (this);
  2107. dialog.DoModal ();
  2108. return ;
  2109. }
  2110. //////////////////////////////////////////////////////////////////////////
  2111. //
  2112. // OnVolDec
  2113. //
  2114. void
  2115. CMainFrame::OnVolDec (void)
  2116. {
  2117. float vol = WWAudioClass::Get_Instance ()->Get_Sound_Effects_Volume ();
  2118. vol -= 0.05F;
  2119. WWAudioClass::Get_Instance ()->Set_Sound_Effects_Volume (vol);
  2120. return ;
  2121. }
  2122. //////////////////////////////////////////////////////////////////////////
  2123. //
  2124. // OnVolInc
  2125. //
  2126. void
  2127. CMainFrame::OnVolInc (void)
  2128. {
  2129. float vol = WWAudioClass::Get_Instance ()->Get_Sound_Effects_Volume ();
  2130. vol += 0.05F;
  2131. WWAudioClass::Get_Instance ()->Set_Sound_Effects_Volume (vol);
  2132. return ;
  2133. }
  2134. //////////////////////////////////////////////////////////////////////////
  2135. //
  2136. // OnBackgroundSettings
  2137. //
  2138. void
  2139. CMainFrame::OnBackgroundSettings (void)
  2140. {
  2141. const char *title = "Background Settings";
  2142. CPropertySheet backgroundsettingspropsheet (title);
  2143. MusicPropPageClass *musicproppageptr;
  2144. SkyPropPageClass *skyproppageptr;
  2145. WeatherPropPageClass *weatherproppageptr;
  2146. musicproppageptr = new MusicPropPageClass;
  2147. skyproppageptr = new SkyPropPageClass;
  2148. weatherproppageptr = new WeatherPropPageClass;
  2149. backgroundsettingspropsheet.AddPage (musicproppageptr);
  2150. backgroundsettingspropsheet.AddPage (skyproppageptr);
  2151. backgroundsettingspropsheet.AddPage (weatherproppageptr);
  2152. backgroundsettingspropsheet.DoModal();
  2153. // Clean-up.
  2154. delete musicproppageptr;
  2155. delete skyproppageptr;
  2156. delete weatherproppageptr;
  2157. }
  2158. //////////////////////////////////////////////////////////////////////////
  2159. //
  2160. // OnToggleMusic
  2161. //
  2162. void
  2163. CMainFrame::OnToggleMusic (void)
  2164. {
  2165. bool is_on = WWAudioClass::Get_Instance ()->Is_Music_On ();
  2166. WWAudioClass::Get_Instance ()->Allow_Music (!is_on);
  2167. return ;
  2168. }
  2169. //////////////////////////////////////////////////////////////////////////
  2170. //
  2171. // OnUpdateToggleMusic
  2172. //
  2173. void
  2174. CMainFrame::OnUpdateToggleMusic (CCmdUI *pCmdUI)
  2175. {
  2176. pCmdUI->SetCheck (WWAudioClass::Get_Instance ()->Is_Music_On ());
  2177. return ;
  2178. }
  2179. //////////////////////////////////////////////////////////////////////////
  2180. //
  2181. // OnToggleSounds
  2182. //
  2183. void
  2184. CMainFrame::OnToggleSounds (void)
  2185. {
  2186. bool is_on = WWAudioClass::Get_Instance ()->Are_Sound_Effects_On ();
  2187. WWAudioClass::Get_Instance ()->Allow_Sound_Effects (!is_on);
  2188. return ;
  2189. }
  2190. //////////////////////////////////////////////////////////////////////////
  2191. //
  2192. // OnUpdateToggleSounds
  2193. //
  2194. void
  2195. CMainFrame::OnUpdateToggleSounds (CCmdUI *pCmdUI)
  2196. {
  2197. pCmdUI->SetCheck (WWAudioClass::Get_Instance ()->Are_Sound_Effects_On ());
  2198. return ;
  2199. }
  2200. //////////////////////////////////////////////////////////////////////////
  2201. //
  2202. // OnViewAggregateChildren
  2203. //
  2204. void CMainFrame::OnViewAggregateChildren (void)
  2205. {
  2206. CWaitCursor wait_cursor;
  2207. // Toggle the view state of aggregate children
  2208. bool view = ::Get_Scene_Editor ()->Are_Aggregate_Children_Visible ();
  2209. ::Get_Scene_Editor ()->View_Aggregate_Children (!view);
  2210. return ;
  2211. }
  2212. //////////////////////////////////////////////////////////////////////////
  2213. //
  2214. // OnUpdateViewAggregateChildren
  2215. //
  2216. void
  2217. CMainFrame::OnUpdateViewAggregateChildren (CCmdUI *pCmdUI)
  2218. {
  2219. pCmdUI->SetCheck (::Get_Scene_Editor ()->Are_Aggregate_Children_Visible ());
  2220. return ;
  2221. }
  2222. //////////////////////////////////////////////////////////////////////////
  2223. //
  2224. // OnToggleSunlight
  2225. //
  2226. void
  2227. CMainFrame::OnToggleSunlight (void)
  2228. {
  2229. bool enabled = ::Get_Scene_Editor ()->Is_Sun_Light_Enabled ();
  2230. ::Get_Scene_Editor ()->Enable_Sun_Light (!enabled);
  2231. ::Get_Scene_Editor ()->Update_Lighting ();
  2232. return ;
  2233. }
  2234. //////////////////////////////////////////////////////////////////////////
  2235. //
  2236. // OnUpdateToggleSunlight
  2237. //
  2238. void
  2239. CMainFrame::OnUpdateToggleSunlight (CCmdUI *pCmdUI)
  2240. {
  2241. pCmdUI->SetCheck (::Get_Scene_Editor ()->Is_Sun_Light_Enabled ());
  2242. return ;
  2243. }
  2244. //////////////////////////////////////////////////////////////////////////
  2245. //
  2246. // OnEditSunlight
  2247. //
  2248. void
  2249. CMainFrame::OnEditSunlight (void)
  2250. {
  2251. SunlightDialogClass dialog (this);
  2252. dialog.DoModal ();
  2253. return ;
  2254. }
  2255. //////////////////////////////////////////////////////////////////////////
  2256. //
  2257. // OnAutoGenVis
  2258. //
  2259. void
  2260. CMainFrame::OnAutoGenVis (void)
  2261. {
  2262. GenerateVisDialogClass dialog (this);
  2263. dialog.DoModal ();
  2264. return ;
  2265. }
  2266. //////////////////////////////////////////////////////////////////////////
  2267. //
  2268. // OnVisualOptions
  2269. //
  2270. //////////////////////////////////////////////////////////////////////////
  2271. void
  2272. CMainFrame::OnVisualOptions (void)
  2273. {
  2274. VisualOptionsDialogClass dialog (this);
  2275. dialog.DoModal ();
  2276. return ;
  2277. }
  2278. //////////////////////////////////////////////////////////////////////////
  2279. //
  2280. // OnVisInvert
  2281. //
  2282. //////////////////////////////////////////////////////////////////////////
  2283. void CMainFrame::OnVisInvert()
  2284. {
  2285. ::Get_Scene_Editor()->Invert_Vis(!::Get_Scene_Editor()->Is_Vis_Inverted());
  2286. ::Refresh_Main_View ();
  2287. return ;
  2288. }
  2289. //////////////////////////////////////////////////////////////////////////
  2290. //
  2291. // OnViewVisPoints
  2292. //
  2293. //////////////////////////////////////////////////////////////////////////
  2294. void
  2295. CMainFrame::OnViewVisPoints (void)
  2296. {
  2297. bool enabled = ::Get_Scene_Editor ()->Are_Vis_Points_Displayed ();
  2298. ::Get_Scene_Editor ()->Display_Vis_Points (!enabled);
  2299. return ;
  2300. }
  2301. //////////////////////////////////////////////////////////////////////////
  2302. //
  2303. // OnUpdateViewVisPoints
  2304. //
  2305. //////////////////////////////////////////////////////////////////////////
  2306. void
  2307. CMainFrame::OnUpdateViewVisPoints (CCmdUI *pCmdUI)
  2308. {
  2309. pCmdUI->SetCheck (::Get_Scene_Editor ()->Are_Vis_Points_Displayed ());
  2310. return ;
  2311. }
  2312. //////////////////////////////////////////////////////////////////////////
  2313. //
  2314. // OnSpecifyAssetDatabase
  2315. //
  2316. //////////////////////////////////////////////////////////////////////////
  2317. void
  2318. CMainFrame::OnSpecifyAssetDatabase (void)
  2319. {
  2320. CFileDialog dialog (TRUE,
  2321. NULL,//"srcsafe.ini",
  2322. "srcsafe.ini",
  2323. OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_SHAREAWARE,
  2324. "Sourcesafe Databases|srcsafe.ini||",
  2325. this);
  2326. //
  2327. // Set the default path so the dialog opens to the correct location
  2328. //
  2329. CString default_path = theApp.GetProfileString (CONFIG_KEY, VSSDB_VALUE, DEF_VSS_DB);
  2330. default_path = ::Strip_Filename_From_Path (default_path);
  2331. dialog.m_ofn.lpstrInitialDir = default_path;
  2332. //
  2333. // Prompt the user for a new asset database location
  2334. //
  2335. if (dialog.DoModal () == IDOK) {
  2336. CString new_path = dialog.GetPathName ();
  2337. theApp.WriteProfileString (CONFIG_KEY, VSSDB_VALUE, (LPCTSTR)new_path);
  2338. //
  2339. // Let the user know they must exit and restart
  2340. //
  2341. MessageBox ("You must exit and restart the level editor for your changes to take effect.", "Database Change", MB_OK | MB_ICONINFORMATION);
  2342. }
  2343. return ;
  2344. }
  2345. //////////////////////////////////////////////////////////////////////////
  2346. //
  2347. // OnUpdateVisInvert
  2348. //
  2349. //////////////////////////////////////////////////////////////////////////
  2350. void
  2351. CMainFrame::OnUpdateVisInvert (CCmdUI *pCmdUI)
  2352. {
  2353. pCmdUI->SetCheck (::Get_Scene_Editor()->Is_Vis_Inverted());
  2354. return ;
  2355. }
  2356. //////////////////////////////////////////////////////////////////////////
  2357. //
  2358. // OnToggleBackfaces
  2359. //
  2360. //////////////////////////////////////////////////////////////////////////
  2361. void
  2362. CMainFrame::OnToggleBackfaces (void)
  2363. {
  2364. SceneEditorClass *scene = ::Get_Scene_Editor ();
  2365. if (scene != NULL) {
  2366. //
  2367. // Toggle the backface debug setting
  2368. //
  2369. bool enable = scene->Is_Backface_Occluder_Debug_Enabled ();
  2370. scene->Enable_Backface_Occluder_Debug (!enable);
  2371. ::Refresh_Main_View ();
  2372. }
  2373. return ;
  2374. }
  2375. //////////////////////////////////////////////////////////////////////////
  2376. //
  2377. // OnUpdateToggleBackfaces
  2378. //
  2379. //////////////////////////////////////////////////////////////////////////
  2380. void
  2381. CMainFrame::OnUpdateToggleBackfaces (CCmdUI *pCmdUI)
  2382. {
  2383. SceneEditorClass *scene = ::Get_Scene_Editor ();
  2384. if (scene != NULL) {
  2385. //
  2386. // Update the menu's checkmark
  2387. //
  2388. pCmdUI->SetCheck (scene->Is_Backface_Occluder_Debug_Enabled ());
  2389. }
  2390. return ;
  2391. }
  2392. //////////////////////////////////////////////////////////////////////////
  2393. //
  2394. // OnToggleWireframeMode
  2395. //
  2396. //////////////////////////////////////////////////////////////////////////
  2397. void
  2398. CMainFrame::OnToggleWireframeMode (void)
  2399. {
  2400. bool enable = (::Get_Scene_Editor()->Get_Polygon_Mode () != SceneClass::LINE);
  2401. ::Get_Scene_Editor()->Set_Polygon_Mode (enable ? SceneClass::LINE : SceneClass::FILL);
  2402. ::Refresh_Main_View ();
  2403. return ;
  2404. }
  2405. //////////////////////////////////////////////////////////////////////////
  2406. //
  2407. // OnUpdateToggleWireframeMode
  2408. //
  2409. //////////////////////////////////////////////////////////////////////////
  2410. void
  2411. CMainFrame::OnUpdateToggleWireframeMode (CCmdUI *pCmdUI)
  2412. {
  2413. pCmdUI->SetCheck (::Get_Scene_Editor()->Get_Polygon_Mode () == SceneClass::LINE);
  2414. return ;
  2415. }
  2416. //////////////////////////////////////////////////////////////////////////
  2417. //
  2418. // OnUpdateToggleWireframeMode
  2419. //
  2420. //////////////////////////////////////////////////////////////////////////
  2421. void
  2422. CMainFrame::OnViewVisErrors (void)
  2423. {
  2424. VisErrorReportDialogClass dialog (this);
  2425. dialog.DoModal ();
  2426. return ;
  2427. }
  2428. //////////////////////////////////////////////////////////////////////////
  2429. //
  2430. // OnUseVisCamera
  2431. //
  2432. //////////////////////////////////////////////////////////////////////////
  2433. void
  2434. CMainFrame::OnUseVisCamera (void)
  2435. {
  2436. return ;
  2437. }
  2438. //////////////////////////////////////////////////////////////////////////
  2439. //
  2440. // OnUpdateUseVisCamera
  2441. //
  2442. //////////////////////////////////////////////////////////////////////////
  2443. void
  2444. CMainFrame::OnUpdateUseVisCamera (CCmdUI *pCmdUI)
  2445. {
  2446. return ;
  2447. }
  2448. //////////////////////////////////////////////////////////////////////////
  2449. //
  2450. // OnVisDisable
  2451. //
  2452. //////////////////////////////////////////////////////////////////////////
  2453. void CMainFrame::OnVisDisable()
  2454. {
  2455. SceneEditorClass *scene = ::Get_Scene_Editor ();
  2456. bool enabled = scene->Is_Vis_Enabled();
  2457. scene->Enable_Vis(!enabled);
  2458. ::Refresh_Main_View ();
  2459. return ;
  2460. }
  2461. //////////////////////////////////////////////////////////////////////////
  2462. //
  2463. // OnGenerateObstacleVolumes
  2464. //
  2465. //////////////////////////////////////////////////////////////////////////
  2466. void
  2467. CMainFrame::OnGenerateObstacleVolumes (void)
  2468. {
  2469. ::Get_Scene_Editor ()->Generate_Pathfind_Portals ();
  2470. return ;
  2471. }
  2472. //////////////////////////////////////////////////////////////////////////
  2473. //
  2474. // OnUpdateVisDisable
  2475. //
  2476. //////////////////////////////////////////////////////////////////////////
  2477. void
  2478. CMainFrame::OnUpdateVisDisable (CCmdUI *pCmdUI)
  2479. {
  2480. SceneEditorClass *scene = ::Get_Scene_Editor ();
  2481. pCmdUI->SetCheck (!scene->Is_Vis_Enabled());
  2482. return ;
  2483. }
  2484. //////////////////////////////////////////////////////////////////////////
  2485. //
  2486. // OnDisplayPaths
  2487. //
  2488. //////////////////////////////////////////////////////////////////////////
  2489. void
  2490. CMainFrame::OnDisplayPaths (void)
  2491. {
  2492. bool enabled = PathDebugPlotterClass::Get_Instance ()->Is_Displayed ();
  2493. PathDebugPlotterClass::Get_Instance ()->Display (!enabled);
  2494. return ;
  2495. }
  2496. //////////////////////////////////////////////////////////////////////////
  2497. //
  2498. // OnUpdateDisplayPaths
  2499. //
  2500. //////////////////////////////////////////////////////////////////////////
  2501. void
  2502. CMainFrame::OnUpdateDisplayPaths (CCmdUI *pCmdUI)
  2503. {
  2504. pCmdUI->SetCheck (PathDebugPlotterClass::Get_Instance ()->Is_Displayed ());
  2505. return ;
  2506. }
  2507. //////////////////////////////////////////////////////////////////////////
  2508. //
  2509. // OnTestPathfind
  2510. //
  2511. //////////////////////////////////////////////////////////////////////////
  2512. void
  2513. CMainFrame::OnTestPathfind (void)
  2514. {
  2515. CWaitCursor wait_cursor;
  2516. PathDebugPlotterClass::Get_Instance ()->Reset ();
  2517. NodeClass *node1 = NodeMgrClass::Find_Node ("PathStart");
  2518. NodeClass *node2 = NodeMgrClass::Find_Node ("PathEnd");
  2519. if ((node1 == NULL) || (node2 == NULL)) {
  2520. node1 = NodeMgrClass::Find_Node ("GotoStart");
  2521. node2 = NodeMgrClass::Find_Node ("GotoEnd");
  2522. }
  2523. if ((node1 != NULL) && (node2 != NULL)) {
  2524. //
  2525. // Register all the waypaths with the pathfinding system
  2526. //
  2527. for ( NodeClass *node = NodeMgrClass::Get_First (NODE_TYPE_WAYPATH);
  2528. node != NULL;
  2529. node = NodeMgrClass::Get_Next (node, NODE_TYPE_WAYPATH))
  2530. {
  2531. node->Pre_Export ();
  2532. }
  2533. //
  2534. // Force the pathfind system to use any available waypath data
  2535. // in its evaluation
  2536. //
  2537. PathfindClass::Get_Instance ()->Generate_Waypath_Sectors_And_Portals ();
  2538. //
  2539. // Find the path
  2540. //
  2541. Vector3 start_pos = node1->Get_Transform ().Get_Translation ();
  2542. Vector3 end_pos = node2->Get_Transform ().Get_Translation ();
  2543. PathObjectClass path_obj;
  2544. path_obj.Initialize (*(node1->Peek_Physics_Obj ()));
  2545. path_obj.Set_Max_Speed (10);
  2546. //
  2547. // Determine the turn radius for the starting object...
  2548. //
  2549. float turn_radius = 0;
  2550. if (node1->Get_Type () == NODE_TYPE_OBJECT) {
  2551. PhysicalGameObj *game_obj = ((ObjectNodeClass *)node1)->Peek_Game_Obj ();
  2552. if (game_obj != NULL) {
  2553. VehicleGameObj *vehicle_obj = game_obj->As_VehicleGameObj ();
  2554. if (vehicle_obj != NULL) {
  2555. turn_radius = vehicle_obj->Get_Turn_Radius ();
  2556. }
  2557. path_obj.Set_Flag (PathObjectClass::IS_VEHICLE, bool(vehicle_obj != NULL));
  2558. }
  2559. }
  2560. path_obj.Set_Turn_Radius (turn_radius);
  2561. PathSolveClass *path = PathMgrClass::Request_Path_Object ();
  2562. path->Set_Path_Object (path_obj);
  2563. path->Reset (start_pos, end_pos, 3);
  2564. Vector3 curr_pos = start_pos;
  2565. Vector3 new_pos (0, 0, 0);
  2566. path->Process_Initial_Sector ();
  2567. //
  2568. // Solve the path
  2569. //
  2570. while (path->Timestep () == PathSolveClass::THINKING) ;
  2571. path->Unlink_Pathfind_Hooks ();
  2572. //
  2573. // Did we find a path?
  2574. //
  2575. if (path->Get_State () == PathSolveClass::SOLVED_PATH) {
  2576. //
  2577. // Display the path
  2578. //
  2579. PathClass *solved_path = new PathClass;
  2580. solved_path->Set_Path_Object (path_obj);
  2581. solved_path->Initialize (*path);
  2582. solved_path->Display_Path (true);
  2583. REF_PTR_RELEASE (solved_path);
  2584. }
  2585. PathMgrClass::Return_Path_Object (path);
  2586. //
  2587. // Unregister all the waypaths with the pathfinding system
  2588. //
  2589. for ( node = NodeMgrClass::Get_First (NODE_TYPE_WAYPATH);
  2590. node != NULL;
  2591. node = NodeMgrClass::Get_Next (node, NODE_TYPE_WAYPATH))
  2592. {
  2593. node->Post_Export ();
  2594. }
  2595. }
  2596. return ;
  2597. }
  2598. //////////////////////////////////////////////////////////////////////////
  2599. //
  2600. // OnDisplayPathfindSectors
  2601. //
  2602. //////////////////////////////////////////////////////////////////////////
  2603. void
  2604. CMainFrame::OnDisplayPathfindSectors (void)
  2605. {
  2606. bool displayed = PathfindClass::Get_Instance ()->Are_Sectors_Displayed ();
  2607. PathfindClass::Get_Instance ()->Display_Sectors (!displayed);
  2608. return ;
  2609. }
  2610. //////////////////////////////////////////////////////////////////////////
  2611. //
  2612. // OnUpdateDisplayPathfindSectors
  2613. //
  2614. //////////////////////////////////////////////////////////////////////////
  2615. void
  2616. CMainFrame::OnUpdateDisplayPathfindSectors (CCmdUI *pCmdUI)
  2617. {
  2618. bool displayed = PathfindClass::Get_Instance ()->Are_Sectors_Displayed ();
  2619. pCmdUI->SetCheck (displayed);
  2620. return ;
  2621. }
  2622. //////////////////////////////////////////////////////////////////////////
  2623. //
  2624. // OnDisplayPathfindPortals
  2625. //
  2626. //////////////////////////////////////////////////////////////////////////
  2627. void
  2628. CMainFrame::OnDisplayPathfindPortals (void)
  2629. {
  2630. bool displayed = PathfindClass::Get_Instance ()->Are_Portals_Displayed ();
  2631. PathfindClass::Get_Instance ()->Display_Portals (!displayed);
  2632. return ;
  2633. }
  2634. //////////////////////////////////////////////////////////////////////////
  2635. //
  2636. // OnDisplayPathfindPortals
  2637. //
  2638. //////////////////////////////////////////////////////////////////////////
  2639. void
  2640. CMainFrame::OnUpdateDisplayPathfindPortals (CCmdUI *pCmdUI)
  2641. {
  2642. bool displayed = PathfindClass::Get_Instance ()->Are_Portals_Displayed ();
  2643. pCmdUI->SetCheck (displayed);
  2644. return ;
  2645. }
  2646. //////////////////////////////////////////////////////////////////////////
  2647. //
  2648. // OnDisplayPathfindRawData
  2649. //
  2650. //////////////////////////////////////////////////////////////////////////
  2651. void
  2652. CMainFrame::OnDisplayPathfindRawData (void)
  2653. {
  2654. return ;
  2655. }
  2656. //////////////////////////////////////////////////////////////////////////
  2657. //
  2658. // OnUpdateDisplayPathfindRawData
  2659. //
  2660. //////////////////////////////////////////////////////////////////////////
  2661. void
  2662. CMainFrame::OnUpdateDisplayPathfindRawData (CCmdUI *pCmdUI)
  2663. {
  2664. return ;
  2665. }
  2666. //////////////////////////////////////////////////////////////////////////
  2667. //
  2668. // OnExportPathfind
  2669. //
  2670. //////////////////////////////////////////////////////////////////////////
  2671. void
  2672. CMainFrame::OnExportPathfind (void)
  2673. {
  2674. // Use the level's filename to generate a default filename
  2675. CString default_name = ::Get_Current_Document ()->GetPathName ();
  2676. if (default_name.GetLength () > 0) {
  2677. default_name = ::Get_Filename_From_Path (default_name);
  2678. default_name = ::Asset_Name_From_Filename (default_name);
  2679. default_name += ".pth";
  2680. }
  2681. CFileDialog dialog ( FALSE,
  2682. ".pth",
  2683. default_name,
  2684. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  2685. "Pathfind database (*.pth)|*.pth||",
  2686. this);
  2687. //
  2688. // Ask the user what commando level file they wish to save to
  2689. //
  2690. if (dialog.DoModal () == IDOK) {
  2691. //
  2692. // Export the pathfind data
  2693. //
  2694. CString filename = dialog.GetPathName ();
  2695. PathfindImportExportSaveLoadClass::Export_Pathfind (filename);
  2696. }
  2697. return ;
  2698. }
  2699. //////////////////////////////////////////////////////////////////////////
  2700. //
  2701. // OnImportPathfind
  2702. //
  2703. //////////////////////////////////////////////////////////////////////////
  2704. void
  2705. CMainFrame::OnImportPathfind (void)
  2706. {
  2707. //
  2708. // Use the level's filename to generate a default filename
  2709. //
  2710. CString default_name = ::Get_Current_Document ()->GetPathName ();
  2711. if (default_name.GetLength () > 0) {
  2712. default_name = ::Get_Filename_From_Path (default_name);
  2713. default_name = ::Asset_Name_From_Filename (default_name);
  2714. default_name += ".pth";
  2715. }
  2716. CFileDialog dialog ( TRUE,
  2717. ".pth",
  2718. default_name,
  2719. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  2720. "Pathfind database (*.pth)|*.pth||",
  2721. this);
  2722. //
  2723. // Ask the user what file they wish to load from
  2724. //
  2725. if (dialog.DoModal () == IDOK) {
  2726. //
  2727. // Import the pathfind data
  2728. //
  2729. CString filename = dialog.GetPathName ();
  2730. PathfindImportExportSaveLoadClass::Import_Pathfind (filename);
  2731. }
  2732. return ;
  2733. }
  2734. //////////////////////////////////////////////////////////////////////////
  2735. //
  2736. // OnImportVis
  2737. //
  2738. //////////////////////////////////////////////////////////////////////////
  2739. void
  2740. CMainFrame::OnImportVis (void)
  2741. {
  2742. // Use the level's filename to generate a default filename
  2743. CString default_name = ::Get_Current_Document ()->GetPathName ();
  2744. if (default_name.GetLength () > 0) {
  2745. default_name = ::Get_Filename_From_Path (default_name);
  2746. default_name = ::Asset_Name_From_Filename (default_name);
  2747. default_name += ".vis";
  2748. }
  2749. CFileDialog dialog ( TRUE,
  2750. ".vis",
  2751. default_name,
  2752. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ALLOWMULTISELECT,
  2753. "Vis Data Files (*.vis)|*.vis||",
  2754. this);
  2755. TCHAR szFileNameList[MAX_PATH*10] = { 0 };
  2756. dialog.m_ofn.lpstrFile = szFileNameList;
  2757. dialog.m_ofn.nMaxFile = sizeof (szFileNameList);
  2758. // Ask the user what commando level file they wish to save to
  2759. if (dialog.DoModal () == IDOK) {
  2760. // Loop through all the selected files
  2761. POSITION pos = dialog.GetStartPosition ();
  2762. while (pos != NULL) {
  2763. // Is the filename OK?
  2764. CString filename = dialog.GetNextPathName (pos);
  2765. HANDLE hfile = ::CreateFile (filename,
  2766. GENERIC_READ,
  2767. FILE_SHARE_READ,
  2768. NULL,
  2769. OPEN_EXISTING,
  2770. 0L,
  2771. NULL);
  2772. ASSERT (hfile != INVALID_HANDLE_VALUE);
  2773. if (hfile != INVALID_HANDLE_VALUE) {
  2774. //
  2775. // Create a chunk-loader for use with the vis data file
  2776. //
  2777. RawFileClass file_obj;
  2778. file_obj.Attach (hfile);
  2779. ChunkLoadClass chunk_load (&file_obj);
  2780. //
  2781. // Load the vis data
  2782. //
  2783. ::Get_Scene_Editor ()->Import_Vis_Data (chunk_load);
  2784. }
  2785. }
  2786. }
  2787. return ;
  2788. }
  2789. //////////////////////////////////////////////////////////////////////////
  2790. //
  2791. // OnExportVis
  2792. //
  2793. //////////////////////////////////////////////////////////////////////////
  2794. void
  2795. CMainFrame::OnExportVis (void)
  2796. {
  2797. // Use the level's filename to generate a default filename
  2798. CString default_name = ::Get_Current_Document ()->GetPathName ();
  2799. if (default_name.GetLength () > 0) {
  2800. default_name = ::Get_Filename_From_Path (default_name);
  2801. default_name = ::Asset_Name_From_Filename (default_name);
  2802. default_name += ".vis";
  2803. }
  2804. CFileDialog dialog ( FALSE,
  2805. ".vis",
  2806. default_name,
  2807. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  2808. "Vis Data File (*.vis)|*.vis||",
  2809. this);
  2810. // Ask the user what file they want to save to
  2811. if (dialog.DoModal () == IDOK) {
  2812. CString filename = dialog.GetPathName ();
  2813. // Is the filename OK?
  2814. HANDLE hfile = ::CreateFile (filename,
  2815. GENERIC_WRITE,
  2816. 0,
  2817. NULL,
  2818. CREATE_ALWAYS,
  2819. 0L,
  2820. NULL);
  2821. ASSERT (hfile != INVALID_HANDLE_VALUE);
  2822. if (hfile != INVALID_HANDLE_VALUE) {
  2823. //
  2824. // Create a chunk-saver
  2825. //
  2826. RawFileClass file_obj;
  2827. file_obj.Attach (hfile);
  2828. ChunkSaveClass chunk_save (&file_obj);
  2829. //
  2830. // Save the vis data to file
  2831. //
  2832. ::Get_Scene_Editor ()->Export_Vis_Data (chunk_save);
  2833. }
  2834. }
  2835. return ;
  2836. }
  2837. //////////////////////////////////////////////////////////////////////////
  2838. //
  2839. // OnViewVisWindow
  2840. //
  2841. //////////////////////////////////////////////////////////////////////////
  2842. void
  2843. CMainFrame::OnViewVisWindow (void)
  2844. {
  2845. SceneEditorClass *scene = ::Get_Scene_Editor ();
  2846. if (scene != NULL) {
  2847. bool show = !scene->Is_Vis_Window_Visible ();
  2848. scene->Show_Vis_Window (show);
  2849. }
  2850. return ;
  2851. }
  2852. //////////////////////////////////////////////////////////////////////////
  2853. //
  2854. // OnViewVisWindow
  2855. //
  2856. //////////////////////////////////////////////////////////////////////////
  2857. void
  2858. CMainFrame::OnUpdateViewVisWindow (CCmdUI *pCmdUI)
  2859. {
  2860. SceneEditorClass *scene = ::Get_Scene_Editor ();
  2861. if (scene != NULL) {
  2862. pCmdUI->SetCheck (scene->Is_Vis_Window_Visible ());
  2863. }
  2864. return ;
  2865. }
  2866. //////////////////////////////////////////////////////////////////////////
  2867. //
  2868. // OnToggleManVisPoints
  2869. //
  2870. //////////////////////////////////////////////////////////////////////////
  2871. void
  2872. CMainFrame::OnToggleManVisPoints (void)
  2873. {
  2874. bool points_visible = ::Get_Scene_Editor ()->Are_Manual_Vis_Points_Visible ();
  2875. ::Get_Scene_Editor ()->Show_Manual_Vis_Points (!points_visible);
  2876. return ;
  2877. }
  2878. //////////////////////////////////////////////////////////////////////////
  2879. //
  2880. // OnUpdateToggleManVisPoints
  2881. //
  2882. //////////////////////////////////////////////////////////////////////////
  2883. void
  2884. CMainFrame::OnUpdateToggleManVisPoints (CCmdUI *pCmdUI)
  2885. {
  2886. pCmdUI->SetCheck (::Get_Scene_Editor ()->Are_Manual_Vis_Points_Visible ());
  2887. return ;
  2888. }
  2889. //////////////////////////////////////////////////////////////////////////
  2890. //
  2891. // OnDiscardPathfind
  2892. //
  2893. //////////////////////////////////////////////////////////////////////////
  2894. void
  2895. CMainFrame::OnDiscardPathfind (void)
  2896. {
  2897. PathfindClass::Get_Instance ()->Reset_Sectors ();
  2898. PathfindClass::Get_Instance ()->Reset_Portals ();
  2899. return ;
  2900. }
  2901. //////////////////////////////////////////////////////////////////////////
  2902. //
  2903. // OnDoDebug1
  2904. //
  2905. //////////////////////////////////////////////////////////////////////////
  2906. void
  2907. CMainFrame::OnDoDebug1 (void)
  2908. {
  2909. return ;
  2910. }
  2911. //////////////////////////////////////////////////////////////////////////
  2912. //
  2913. // OnDoDebug2
  2914. //
  2915. //////////////////////////////////////////////////////////////////////////
  2916. void
  2917. CMainFrame::OnDoDebug2 (void)
  2918. {
  2919. /*const char *filename = "c:\\projects\\renegade\\code\\commando\\chat.rc";
  2920. const char *output_filename = "c:\\projects\\renegade\\code\\commando\\chat2.rc";
  2921. if (StringsMgrClass::Check_Out ()) {
  2922. //
  2923. // Try to open the .RC file
  2924. //
  2925. TextFileClass file (filename);
  2926. TextFileClass output_file (output_filename);
  2927. if (file.Open (RawFileClass::READ) && output_file.Open (RawFileClass::WRITE)) {
  2928. int current_index = 1;
  2929. //
  2930. // Read each line from the file
  2931. //
  2932. StringClass curr_line;
  2933. while (file.Read_Line (curr_line)) {
  2934. Process_Line (curr_line, current_index);
  2935. curr_line += "\r\n";
  2936. output_file.Write (curr_line, ::lstrlen (curr_line));
  2937. //output_file.Write_Line (curr_line);
  2938. }
  2939. //
  2940. // Close the files
  2941. //
  2942. file.Close ();
  2943. output_file.Close ();
  2944. }
  2945. StringsMgrClass::Save_Translation_Database ();
  2946. StringsMgrClass::Check_In ();
  2947. }*/
  2948. //
  2949. // Loop over all the definitions
  2950. //
  2951. /*for ( PresetClass *preset = PresetMgrClass::Get_First ();
  2952. preset != NULL;
  2953. preset = PresetMgrClass::Get_Next (preset))
  2954. {
  2955. if (preset->Get_IsTemporary () == false) {
  2956. DEFINITION_LIST definition_list;
  2957. ::Build_Embedded_Definition_List (definition_list, preset->Get_Definition ());
  2958. for (int index = 0; index < definition_list.Count (); index ++) {
  2959. DefinitionClass *definition = definition_list[index];
  2960. //
  2961. // Loop over all the parameters contained in the definitions
  2962. //
  2963. int count = definition->Get_Parameter_Count ();
  2964. for (int index = 0; index < count; index ++) {
  2965. ParameterClass *param = definition->Lock_Parameter (index);
  2966. if (param->Get_Type () == ParameterClass::TYPE_ZONE) {
  2967. ZoneParameterClass *zone_param = (ZoneParameterClass *)param;
  2968. const OBBoxClass &old_zone = zone_param->Get_Zone ();
  2969. OBBoxClass new_zone = old_zone;
  2970. new_zone.Extent = (old_zone.Extent * 0.5F);
  2971. zone_param->Set_Zone (new_zone);
  2972. }
  2973. definition->Unlock_Parameter (index);
  2974. }
  2975. }
  2976. }
  2977. }
  2978. //
  2979. // Get the list of all static objects from the physics scene
  2980. //
  2981. for (int index = 0; index < door_def_list.Count (); index ++) {
  2982. DoorPhysDefClass *definition = door_def_list[index];
  2983. const OBBoxClass &box1 = definition->Get_Trigger_Zone1 ();
  2984. const OBBoxClass &box2 = definition->Get_Trigger_Zone2 ();
  2985. definition->Set_Trigger_Zone2 (box1);
  2986. }
  2987. PresetsFormClass *form = ::Get_Presets_Form ();
  2988. form->Save_Preset_Libraries ();*/
  2989. /*PresetsFormClass *presets_form = ::Get_Presets_Form ();
  2990. CString message = "Presets with invalid IDs:\n\n";
  2991. //
  2992. // Loop over all the definitions
  2993. //
  2994. for ( PresetClass *preset = PresetMgrClass::Get_First ();
  2995. preset != NULL;
  2996. preset = PresetMgrClass::Get_Next (preset))
  2997. {
  2998. if (preset->Get_IsTemporary () == false) {
  2999. DEFINITION_LIST definition_list;
  3000. ::Build_Embedded_Definition_List (definition_list, preset->Get_Definition ());
  3001. for (int index = 0; index < definition_list.Count (); index ++) {
  3002. DefinitionClass *definition = definition_list[index];
  3003. if (definition != NULL && definition->Get_ID () >= TEMP_DEF_ID_START) {
  3004. message += "Preset Name: ";
  3005. message += preset->Get_Name ();
  3006. message += "\tDefinition Name: ";
  3007. message += definition->Get_Name ();
  3008. message += "\n";
  3009. }
  3010. }
  3011. }
  3012. }
  3013. MessageBox (message, "Validate Preset IDs", MB_ICONINFORMATION | MB_OK);*/
  3014. return ;
  3015. }
  3016. //////////////////////////////////////////////////////////////////////////
  3017. //
  3018. // OnImportDynObjs
  3019. //
  3020. //////////////////////////////////////////////////////////////////////////
  3021. void
  3022. CMainFrame::OnImportDynObjs (void)
  3023. {
  3024. // Use the level's filename to generate a default filename
  3025. CString default_name = ::Get_Current_Document ()->GetPathName ();
  3026. if (default_name.GetLength () > 0) {
  3027. default_name = ::Get_Filename_From_Path (default_name);
  3028. default_name = ::Asset_Name_From_Filename (default_name);
  3029. default_name += ".dyn";
  3030. }
  3031. CFileDialog dialog ( TRUE,
  3032. ".dyn",
  3033. default_name,
  3034. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  3035. "Dynamic Objects (*.dyn)|*.dyn||",
  3036. this);
  3037. if (dialog.DoModal () == IDOK) {
  3038. EditorSaveLoadClass::Import_Dynamic_Objects (dialog.GetPathName ());
  3039. }
  3040. return ;
  3041. }
  3042. //////////////////////////////////////////////////////////////////////////
  3043. //
  3044. // OnExportDynObjs
  3045. //
  3046. //////////////////////////////////////////////////////////////////////////
  3047. void
  3048. CMainFrame::OnExportDynObjs (void)
  3049. {
  3050. // Use the level's filename to generate a default filename
  3051. CString default_name = ::Get_Current_Document ()->GetPathName ();
  3052. if (default_name.GetLength () > 0) {
  3053. default_name = ::Get_Filename_From_Path (default_name);
  3054. default_name = ::Asset_Name_From_Filename (default_name);
  3055. default_name += ".dyn";
  3056. }
  3057. CFileDialog dialog ( FALSE,
  3058. ".dyn",
  3059. default_name,
  3060. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  3061. "Dynamic Objects (*.dyn)|*.dyn||",
  3062. this);
  3063. if (dialog.DoModal () == IDOK) {
  3064. EditorSaveLoadClass::Export_Dynamic_Objects (dialog.GetPathName ());
  3065. }
  3066. return ;
  3067. }
  3068. //////////////////////////////////////////////////////////////////////////
  3069. //
  3070. // OnTestGoto
  3071. //
  3072. //////////////////////////////////////////////////////////////////////////
  3073. void
  3074. CMainFrame::OnTestGoto (void)
  3075. {
  3076. CWaitCursor wait_cursor;
  3077. PathDebugPlotterClass::Get_Instance ()->Reset ();
  3078. NodeClass *node1 = NodeMgrClass::Find_Node ("GotoStart");
  3079. NodeClass *node2 = NodeMgrClass::Find_Node ("GotoEnd");
  3080. if ((node1 != NULL) && (node2 != NULL)) {
  3081. ::Get_Scene_Editor ()->DoObjectGoto (node1, node2);
  3082. }
  3083. return ;
  3084. }
  3085. //////////////////////////////////////////////////////////////////////////
  3086. //
  3087. // OnImportStatic
  3088. //
  3089. //////////////////////////////////////////////////////////////////////////
  3090. void
  3091. CMainFrame::OnImportStatic (void)
  3092. {
  3093. // Use the level's filename to generate a default filename
  3094. CString default_name = ::Get_Current_Document ()->GetPathName ();
  3095. if (default_name.GetLength () > 0) {
  3096. default_name = ::Get_Filename_From_Path (default_name);
  3097. default_name = ::Asset_Name_From_Filename (default_name);
  3098. default_name += ".sta";
  3099. }
  3100. CFileDialog dialog ( TRUE,
  3101. ".sta",
  3102. default_name,
  3103. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  3104. "Static Data (*.sta)|*.sta||",
  3105. this);
  3106. if (dialog.DoModal () == IDOK) {
  3107. CString filename = dialog.GetPathName ();
  3108. // Is the filename OK?
  3109. HANDLE hfile = ::CreateFile (filename,
  3110. GENERIC_READ,
  3111. 0,
  3112. NULL,
  3113. OPEN_EXISTING,
  3114. 0L,
  3115. NULL);
  3116. ASSERT (hfile != INVALID_HANDLE_VALUE);
  3117. if (hfile != INVALID_HANDLE_VALUE) {
  3118. //
  3119. // Create a chunk-loader for use with the pathfind database
  3120. //
  3121. RawFileClass file_obj;
  3122. file_obj.Attach (hfile);
  3123. ChunkLoadClass cload (&file_obj);
  3124. //
  3125. // Remove all static nodes from the level
  3126. //
  3127. NODE_LIST obj_list;
  3128. NodeMgrClass::Remove_Static_Objects (obj_list);
  3129. for (int index = 0; index < obj_list.Count (); index ++) {
  3130. NodeClass *node = obj_list[index];
  3131. MEMBER_RELEASE (node);
  3132. }
  3133. //
  3134. // Load the scene data, then import the node's list...
  3135. //
  3136. EditorSaveLoadClass::Set_Loaded_Vis_Valid (true);
  3137. SaveLoadSystemClass::Load (cload);
  3138. //
  3139. // Repartition the static culling systems
  3140. //
  3141. // ::Get_Scene_Editor ()->Re_Partition_Static_Objects ();
  3142. ::Get_Scene_Editor ()->Re_Partition_Static_Lights ();
  3143. ::Get_Scene_Editor ()->Re_Partition_Audio_System ();
  3144. if (EditorSaveLoadClass::Is_Loaded_Vis_Valid ()) {
  3145. ::Get_Scene_Editor ()->Validate_Vis ();
  3146. }
  3147. //
  3148. // Reset the IDs of all the static nodes
  3149. //
  3150. for ( NodeClass *node = NodeMgrClass::Get_First ();
  3151. node != NULL;
  3152. node = NodeMgrClass::Get_Next (node))
  3153. {
  3154. if (node->Is_Static ()) {
  3155. node->Set_ID (NodeMgrClass::Get_Node_ID (node->Get_Type ()));
  3156. NodeMgrClass::Setup_Node_Identity (*node);
  3157. }
  3158. }
  3159. }
  3160. }
  3161. return ;
  3162. }
  3163. //////////////////////////////////////////////////////////////////////////
  3164. //
  3165. // OnExportStatic
  3166. //
  3167. //////////////////////////////////////////////////////////////////////////
  3168. void
  3169. CMainFrame::OnExportStatic (void)
  3170. {
  3171. // Use the level's filename to generate a default filename
  3172. CString default_name = ::Get_Current_Document ()->GetPathName ();
  3173. if (default_name.GetLength () > 0) {
  3174. default_name = ::Get_Filename_From_Path (default_name);
  3175. default_name = ::Asset_Name_From_Filename (default_name);
  3176. default_name += ".sta";
  3177. }
  3178. CFileDialog dialog ( FALSE,
  3179. ".sta",
  3180. default_name,
  3181. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  3182. "Static Data (*.sta)|*.sta||",
  3183. this);
  3184. // Ask the user what commando level file they wish to save to
  3185. if (dialog.DoModal () == IDOK) {
  3186. CString filename = dialog.GetPathName ();
  3187. // Is the filename OK?
  3188. HANDLE hfile = ::CreateFile (filename,
  3189. GENERIC_WRITE,
  3190. 0,
  3191. NULL,
  3192. CREATE_ALWAYS,
  3193. 0L,
  3194. NULL);
  3195. ASSERT (hfile != INVALID_HANDLE_VALUE);
  3196. if (hfile != INVALID_HANDLE_VALUE) {
  3197. //
  3198. // Create a chunk-saver for use with the pathfind database
  3199. //
  3200. RawFileClass file_obj;
  3201. file_obj.Attach (hfile);
  3202. ChunkSaveClass csave (&file_obj);
  3203. //
  3204. // Repartition the static culling systems
  3205. // (gth) cannot re-partition the object culling systems because they
  3206. // now contain hierarchical visibility data...
  3207. //
  3208. ::Get_Scene_Editor ()->Re_Partition_Static_Lights ();
  3209. ::Get_Scene_Editor ()->Re_Partition_Audio_System ();
  3210. //
  3211. // Export the culling system, vis, etc
  3212. //
  3213. SaveLoadSystemClass::Save (csave, _PhysStaticDataSaveSystem);
  3214. //
  3215. // Export the static node list
  3216. //
  3217. NODE_LIST obj_list;
  3218. NodeMgrClass::Remove_Dynamic_Objects (obj_list);
  3219. SaveLoadSystemClass::Save (csave, _TheNodeMgr);
  3220. NodeMgrClass::Put_Objects_Back (obj_list);
  3221. }
  3222. }
  3223. return ;
  3224. }
  3225. //////////////////////////////////////////////////////////////////////////
  3226. //
  3227. // OnDisplayWeb
  3228. //
  3229. //////////////////////////////////////////////////////////////////////////
  3230. void
  3231. CMainFrame::OnDisplayWeb (void)
  3232. {
  3233. bool enable = !::Get_Current_Document ()->Is_Path_Web_Displayed ();
  3234. ::Get_Current_Document ()->Display_Path_Web (enable);
  3235. PathDebugPlotterClass::Get_Instance ()->Reset ();
  3236. PathDebugPlotterClass::Get_Instance ()->Display (enable);
  3237. if (enable) {
  3238. PathfindSectorClass *sector = NULL;
  3239. int sector_index = 0;
  3240. while ((sector = PathfindClass::Get_Instance ()->Peek_Sector (sector_index++)) != NULL) {
  3241. Vector3 center = sector->Get_Bounding_Box ().Center;
  3242. int portal_index = sector->Get_Portal_Count ();
  3243. while (portal_index --) {
  3244. PathfindPortalClass *portal = sector->Peek_Portal (portal_index);
  3245. AABoxClass portal_box;
  3246. portal->Get_Bounding_Box (portal_box);
  3247. PathDebugPlotterClass::Get_Instance ()->Add (center, portal_box.Center, Vector3 (1, 0, 0));
  3248. }
  3249. }
  3250. }
  3251. return ;
  3252. }
  3253. //////////////////////////////////////////////////////////////////////////
  3254. //
  3255. // OnUpdateDisplayWeb
  3256. //
  3257. //////////////////////////////////////////////////////////////////////////
  3258. void
  3259. CMainFrame::OnUpdateDisplayWeb (CCmdUI* pCmdUI)
  3260. {
  3261. pCmdUI->SetCheck (::Get_Current_Document ()->Is_Path_Web_Displayed ());
  3262. return ;
  3263. }
  3264. //////////////////////////////////////////////////////////////////////////
  3265. //
  3266. // OnUpdateDisplayFullPaths
  3267. //
  3268. //////////////////////////////////////////////////////////////////////////
  3269. void
  3270. CMainFrame::OnUpdateDisplayFullPaths (CCmdUI* pCmdUI)
  3271. {
  3272. pCmdUI->SetCheck (::Get_Current_Document ()->Are_Full_Paths_Displayed ());
  3273. return ;
  3274. }
  3275. //////////////////////////////////////////////////////////////////////////
  3276. //
  3277. // OnDisplayFullPaths
  3278. //
  3279. //////////////////////////////////////////////////////////////////////////
  3280. void
  3281. CMainFrame::OnDisplayFullPaths (void)
  3282. {
  3283. bool enable = !::Get_Current_Document ()->Are_Full_Paths_Displayed ();
  3284. ::Get_Current_Document ()->Display_Full_Paths (enable);
  3285. return ;
  3286. }
  3287. //////////////////////////////////////////////////////////////////////////
  3288. //
  3289. // OnEscape
  3290. //
  3291. //////////////////////////////////////////////////////////////////////////
  3292. void CMainFrame::OnEscape (void)
  3293. {
  3294. //
  3295. // Force the mode back to the default...
  3296. //
  3297. ::Get_Mouse_Mgr ()->Set_Mouse_Mode (MouseMgrClass::MODE_OBJECT_MANIPULATE);
  3298. return ;
  3299. }
  3300. //////////////////////////////////////////////////////////////////////////
  3301. //
  3302. // OnDisplayVisSectors
  3303. //
  3304. //////////////////////////////////////////////////////////////////////////
  3305. void
  3306. CMainFrame::OnDisplayVisSectors (void)
  3307. {
  3308. bool enabled = ::Get_Scene_Editor ()->Is_Vis_Sector_Display_Enabled ();
  3309. ::Get_Scene_Editor ()->Enable_Vis_Sector_Display (!enabled);
  3310. return ;
  3311. }
  3312. //////////////////////////////////////////////////////////////////////////
  3313. //
  3314. // OnUpdateDisplayVisSectors
  3315. //
  3316. //////////////////////////////////////////////////////////////////////////
  3317. void
  3318. CMainFrame::OnUpdateDisplayVisSectors (CCmdUI *pCmdUI)
  3319. {
  3320. bool enabled = ::Get_Scene_Editor ()->Is_Vis_Sector_Display_Enabled ();
  3321. pCmdUI->SetCheck (enabled);
  3322. return ;
  3323. }
  3324. //////////////////////////////////////////////////////////////////////////
  3325. //
  3326. // OnPrelitMultipass
  3327. //
  3328. //////////////////////////////////////////////////////////////////////////
  3329. void
  3330. CMainFrame::OnPrelitMultipass (void)
  3331. {
  3332. if (WW3D::Get_Prelit_Mode () != WW3D::PRELIT_MODE_LIGHTMAP_MULTI_PASS) {
  3333. WW3D::Set_Prelit_Mode (WW3D::PRELIT_MODE_LIGHTMAP_MULTI_PASS);
  3334. ::Get_Scene_Editor ()->Reload_Lightmap_Models ();
  3335. }
  3336. return ;
  3337. }
  3338. //////////////////////////////////////////////////////////////////////////
  3339. //
  3340. // OnUpdatePrelitMultipass
  3341. //
  3342. //////////////////////////////////////////////////////////////////////////
  3343. void
  3344. CMainFrame::OnUpdatePrelitMultipass (CCmdUI *pCmdUI)
  3345. {
  3346. bool enable = (WW3D::Get_Prelit_Mode () == WW3D::PRELIT_MODE_LIGHTMAP_MULTI_PASS);
  3347. pCmdUI->SetRadio (enable);
  3348. return ;
  3349. }
  3350. //////////////////////////////////////////////////////////////////////////
  3351. //
  3352. // OnPrelitMultitex
  3353. //
  3354. //////////////////////////////////////////////////////////////////////////
  3355. void
  3356. CMainFrame::OnPrelitMultitex (void)
  3357. {
  3358. if (WW3D::Get_Prelit_Mode () != WW3D::PRELIT_MODE_LIGHTMAP_MULTI_TEXTURE) {
  3359. WW3D::Set_Prelit_Mode (WW3D::PRELIT_MODE_LIGHTMAP_MULTI_TEXTURE);
  3360. ::Get_Scene_Editor ()->Reload_Lightmap_Models ();
  3361. }
  3362. return ;
  3363. }
  3364. //////////////////////////////////////////////////////////////////////////
  3365. //
  3366. // OnUpdatePrelitMultitex
  3367. //
  3368. //////////////////////////////////////////////////////////////////////////
  3369. void
  3370. CMainFrame::OnUpdatePrelitMultitex (CCmdUI *pCmdUI)
  3371. {
  3372. bool enable = (WW3D::Get_Prelit_Mode () == WW3D::PRELIT_MODE_LIGHTMAP_MULTI_TEXTURE);
  3373. pCmdUI->SetRadio (enable);
  3374. return ;
  3375. }
  3376. //////////////////////////////////////////////////////////////////////////
  3377. //
  3378. // OnPrelitVertex
  3379. //
  3380. //////////////////////////////////////////////////////////////////////////
  3381. void
  3382. CMainFrame::OnPrelitVertex (void)
  3383. {
  3384. if (WW3D::Get_Prelit_Mode () != WW3D::PRELIT_MODE_VERTEX) {
  3385. WW3D::Set_Prelit_Mode (WW3D::PRELIT_MODE_VERTEX);
  3386. ::Get_Scene_Editor ()->Reload_Lightmap_Models ();
  3387. }
  3388. return ;
  3389. }
  3390. //////////////////////////////////////////////////////////////////////////
  3391. //
  3392. // OnUpdatePrelitVertex
  3393. //
  3394. //////////////////////////////////////////////////////////////////////////
  3395. void
  3396. CMainFrame::OnUpdatePrelitVertex (CCmdUI *pCmdUI)
  3397. {
  3398. bool enable = (WW3D::Get_Prelit_Mode () == WW3D::PRELIT_MODE_VERTEX);
  3399. pCmdUI->SetRadio (enable);
  3400. return ;
  3401. }
  3402. //////////////////////////////////////////////////////////////////////////
  3403. //
  3404. // OnDebugScriptsMode
  3405. //
  3406. //////////////////////////////////////////////////////////////////////////
  3407. void
  3408. CMainFrame::OnDebugScriptsMode (void)
  3409. {
  3410. bool enabled = ::Get_Current_Document ()->Get_Debug_Script_Mode ();
  3411. ::Get_Current_Document ()->Set_Debug_Script_Mode (!enabled);
  3412. return ;
  3413. }
  3414. //////////////////////////////////////////////////////////////////////////
  3415. //
  3416. // OnUpdateDebugScriptsMode
  3417. //
  3418. //////////////////////////////////////////////////////////////////////////
  3419. void
  3420. CMainFrame::OnUpdateDebugScriptsMode (CCmdUI *pCmdUI)
  3421. {
  3422. pCmdUI->SetCheck (::Get_Current_Document ()->Get_Debug_Script_Mode ());
  3423. return ;
  3424. }
  3425. //////////////////////////////////////////////////////////////////////////
  3426. //
  3427. // OnImportLights
  3428. //
  3429. //////////////////////////////////////////////////////////////////////////
  3430. void
  3431. CMainFrame::OnImportLights (void)
  3432. {
  3433. CFileDialog dialog ( TRUE,
  3434. ".wlt",
  3435. NULL,
  3436. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT | OFN_EXPLORER,
  3437. "Westwood Light Database (*.wlt)|*.wlt||",
  3438. this);
  3439. TCHAR filename_list[MAX_PATH*20] = { 0 };
  3440. dialog.m_ofn.lpstrFile = filename_list;
  3441. dialog.m_ofn.nMaxFile = sizeof (filename_list);
  3442. //
  3443. // Ask the user what files they wish to import
  3444. //
  3445. if (dialog.DoModal () == IDOK) {
  3446. //
  3447. // Loop through all the selected files
  3448. //
  3449. DynamicVectorClass<StringClass> filename_list;
  3450. POSITION pos = dialog.GetStartPosition ();
  3451. while (pos != NULL) {
  3452. //
  3453. // Add this filename to the list
  3454. //
  3455. filename_list.Add ((LPCTSTR)dialog.GetNextPathName (pos));
  3456. }
  3457. ::Get_Scene_Editor ()->Import_Lights (filename_list);
  3458. }
  3459. return ;
  3460. }
  3461. //////////////////////////////////////////////////////////////////////////
  3462. //
  3463. // OnViewSoundSpheres
  3464. //
  3465. //////////////////////////////////////////////////////////////////////////
  3466. void
  3467. CMainFrame::OnViewSoundSpheres (void)
  3468. {
  3469. bool enabled = ::Get_Scene_Editor ()->Are_Sound_Spheres_Displayed ();
  3470. ::Get_Scene_Editor ()->Display_Sound_Spheres (!enabled);
  3471. return ;
  3472. }
  3473. //////////////////////////////////////////////////////////////////////////
  3474. //
  3475. // OnUpdateViewSoundSpheres
  3476. //
  3477. //////////////////////////////////////////////////////////////////////////
  3478. void
  3479. CMainFrame::OnUpdateViewSoundSpheres (CCmdUI *pCmdUI)
  3480. {
  3481. bool enabled = ::Get_Scene_Editor ()->Are_Sound_Spheres_Displayed ();
  3482. pCmdUI->SetCheck (enabled);
  3483. return ;
  3484. }
  3485. //////////////////////////////////////////////////////////////////////////
  3486. //
  3487. // OnViewLightSpheres
  3488. //
  3489. //////////////////////////////////////////////////////////////////////////
  3490. void
  3491. CMainFrame::OnViewLightSpheres (void)
  3492. {
  3493. bool enabled = ::Get_Scene_Editor ()->Are_Light_Spheres_Displayed ();
  3494. ::Get_Scene_Editor ()->Display_Light_Spheres (!enabled);
  3495. return ;
  3496. }
  3497. //////////////////////////////////////////////////////////////////////////
  3498. //
  3499. // OnUpdateViewLightSpheres
  3500. //
  3501. //////////////////////////////////////////////////////////////////////////
  3502. void
  3503. CMainFrame::OnUpdateViewLightSpheres (CCmdUI *pCmdUI)
  3504. {
  3505. bool enabled = ::Get_Scene_Editor ()->Are_Light_Spheres_Displayed ();
  3506. pCmdUI->SetCheck (enabled);
  3507. return ;
  3508. }
  3509. //////////////////////////////////////////////////////////////////////////
  3510. //
  3511. // OnImportSunlight
  3512. //
  3513. //////////////////////////////////////////////////////////////////////////
  3514. void
  3515. CMainFrame::OnImportSunlight (void)
  3516. {
  3517. CFileDialog dialog ( TRUE,
  3518. ".wlt",
  3519. NULL,
  3520. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  3521. "Westwood Light Database (*.wlt)|*.wlt||",
  3522. this);
  3523. //
  3524. // Ask the user what file they wish to import
  3525. //
  3526. if (dialog.DoModal () == IDOK) {
  3527. //
  3528. // Load the sunlight's settings from this file
  3529. //
  3530. ::Get_Scene_Editor ()->Import_Sunlight (dialog.GetPathName ());
  3531. }
  3532. return ;
  3533. }
  3534. //////////////////////////////////////////////////////////////////////////
  3535. //
  3536. // OnDiscardVis
  3537. //
  3538. //////////////////////////////////////////////////////////////////////////
  3539. void
  3540. CMainFrame::OnDiscardVis (void)
  3541. {
  3542. ::Get_Scene_Editor ()->Reset_Vis (true);
  3543. return ;
  3544. }
  3545. //////////////////////////////////////////////////////////////////////////
  3546. //
  3547. // Expand_Attenuation_Spheres
  3548. //
  3549. //////////////////////////////////////////////////////////////////////////
  3550. void
  3551. CMainFrame::Expand_Attenuation_Spheres (float amount)
  3552. {
  3553. SelectionMgrClass &sel_mgr = ::Get_Scene_Editor ()->Get_Selection_Mgr ();
  3554. //
  3555. // Loop over the currently selected nodes
  3556. //
  3557. for (int index = 0; index < sel_mgr.Get_Count (); index ++) {
  3558. NodeClass *node = sel_mgr.Get_At (index);
  3559. if (node != NULL) {
  3560. //
  3561. // Increment this node's radius and pass it back
  3562. // to the node...
  3563. //
  3564. float radius = node->Get_Attenuation_Radius ();
  3565. radius += amount;
  3566. if (radius > 0) {
  3567. node->Set_Attenuation_Radius (radius);
  3568. }
  3569. }
  3570. }
  3571. return ;
  3572. }
  3573. //////////////////////////////////////////////////////////////////////////
  3574. //
  3575. // OnIncreaseSphere
  3576. //
  3577. //////////////////////////////////////////////////////////////////////////
  3578. void
  3579. CMainFrame::OnIncreaseSphere (void)
  3580. {
  3581. Adjust_Growth_Rate ();
  3582. Expand_Attenuation_Spheres (m_GrowthRate);
  3583. return ;
  3584. }
  3585. //////////////////////////////////////////////////////////////////////////
  3586. //
  3587. // OnUpdateIncreaseSphere
  3588. //
  3589. //////////////////////////////////////////////////////////////////////////
  3590. void
  3591. CMainFrame::OnUpdateIncreaseSphere (CCmdUI *pCmdUI)
  3592. {
  3593. pCmdUI->Enable (::Get_Selection_Mgr ().Get_Count () > 0);
  3594. return ;
  3595. }
  3596. //////////////////////////////////////////////////////////////////////////
  3597. //
  3598. // OnDecreaseSphere
  3599. //
  3600. //////////////////////////////////////////////////////////////////////////
  3601. void
  3602. CMainFrame::OnDecreaseSphere (void)
  3603. {
  3604. Adjust_Growth_Rate ();
  3605. Expand_Attenuation_Spheres (-m_GrowthRate);
  3606. return ;
  3607. }
  3608. //////////////////////////////////////////////////////////////////////////
  3609. //
  3610. // OnDecreaseSphere
  3611. //
  3612. //////////////////////////////////////////////////////////////////////////
  3613. void
  3614. CMainFrame::OnUpdateDecreaseSphere (CCmdUI *pCmdUI)
  3615. {
  3616. pCmdUI->Enable (::Get_Selection_Mgr ().Get_Count () > 0);
  3617. return ;
  3618. }
  3619. //////////////////////////////////////////////////////////////////////////
  3620. //
  3621. // Adjust_Growth_Rate
  3622. //
  3623. //////////////////////////////////////////////////////////////////////////
  3624. void
  3625. CMainFrame::Adjust_Growth_Rate (void)
  3626. {
  3627. DWORD curr_time = ::GetTickCount ();
  3628. //
  3629. // Reset the growth rate if too much time has elapsed
  3630. //
  3631. if ((curr_time - m_UpdateTimer) > 800) {
  3632. m_GrowthRate = 0.25F;
  3633. }
  3634. m_UpdateTimer = curr_time;
  3635. //
  3636. // Clamp the growth rate to ensure things don't get out of hand
  3637. //
  3638. m_GrowthRate = WWMath::Clamp (m_GrowthRate + 0.005F, 0.25F, 5.0F);
  3639. return ;
  3640. }
  3641. //////////////////////////////////////////////////////////////////////////
  3642. //
  3643. // OnRunJob
  3644. //
  3645. //////////////////////////////////////////////////////////////////////////
  3646. void
  3647. CMainFrame::OnRunJob (void)
  3648. {
  3649. CFileDialog dialog ( TRUE,
  3650. ".job",
  3651. "farm01.job",
  3652. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  3653. "Vis Farm Job (*.job)|*.job||",
  3654. this);
  3655. //
  3656. // Ask the user which job they want to load
  3657. //
  3658. if (dialog.DoModal () == IDOK) {
  3659. ::Perform_Job (dialog.GetPathName (), false);
  3660. }
  3661. return ;
  3662. }
  3663. //////////////////////////////////////////////////////////////////////////
  3664. //
  3665. // OnGotoLocation
  3666. //
  3667. //////////////////////////////////////////////////////////////////////////
  3668. void
  3669. CMainFrame::OnGotoLocation (void)
  3670. {
  3671. GotoLocationDialogClass dialog (this);
  3672. dialog.DoModal ();
  3673. return ;
  3674. }
  3675. //////////////////////////////////////////////////////////////////////////
  3676. //
  3677. // OnExportThumbnails
  3678. //
  3679. //////////////////////////////////////////////////////////////////////////
  3680. void
  3681. CMainFrame::OnExportThumbnails (void)
  3682. {
  3683. //
  3684. // Determine which directory we should use as a default for the export
  3685. //
  3686. CString full_path = theApp.GetProfileString (CONFIG_KEY, LAST_EXPORT_DIR_VALUE);
  3687. if (full_path.GetLength () == 0) {
  3688. full_path = ::Get_File_Mgr ()->Make_Full_Path (LEVELS_ASSET_DIR);
  3689. }
  3690. _pThe3DAssetManager->Set_Current_Directory (full_path);
  3691. return ;
  3692. }
  3693. //////////////////////////////////////////////////////////////////////////
  3694. //
  3695. // OnVisStats
  3696. //
  3697. //////////////////////////////////////////////////////////////////////////
  3698. void
  3699. CMainFrame::OnVisStats (void)
  3700. {
  3701. VisStatsDialogClass dialog (this);
  3702. dialog.DoModal ();
  3703. return ;
  3704. }
  3705. //////////////////////////////////////////////////////////////////////////
  3706. //
  3707. // OnSetNodeIdStart
  3708. //
  3709. //////////////////////////////////////////////////////////////////////////
  3710. void
  3711. CMainFrame::OnSetNodeIdStart (void)
  3712. {
  3713. NodeIDStartDialogClass dialog (this);
  3714. dialog.DoModal ();
  3715. return ;
  3716. }
  3717. //////////////////////////////////////////////////////////////////////////
  3718. //
  3719. // OnBuildDynaCullsys
  3720. //
  3721. //////////////////////////////////////////////////////////////////////////
  3722. void
  3723. CMainFrame::OnBuildDynaCullsys (void)
  3724. {
  3725. CWaitCursor wait_cursor;
  3726. //
  3727. // Create a pathfind floodfiller object
  3728. //
  3729. PathfindSectorBuilderClass builder;
  3730. //builder.Allow_Water_Floodfill (true);
  3731. builder.Initialize ();
  3732. //
  3733. // Find all the pathfind start-points in the level and add
  3734. // them to the floodfiller
  3735. //
  3736. NodeClass *node = NULL;
  3737. for ( node = NodeMgrClass::Get_First ();
  3738. node != NULL;
  3739. node = NodeMgrClass::Get_Next (node))
  3740. {
  3741. if (node->Get_Type () == NODE_TYPE_PATHFIND_START) {
  3742. builder.Add_Start_Point (node->Get_Transform ().Get_Translation ());
  3743. }
  3744. }
  3745. //
  3746. // Perform the floodfill from each of the start locations
  3747. //
  3748. builder.Generate_Sectors ();
  3749. builder.Compress_Sectors_For_Dyna_Culling ();
  3750. //
  3751. // Cleanup
  3752. //
  3753. builder.Shutdown ();
  3754. ::Get_Scene_Editor ()->Reset_Dynamic_Object_Visibility_Status ();
  3755. return ;
  3756. }
  3757. //////////////////////////////////////////////////////////////////////////
  3758. //
  3759. // OnImportVisRemapData
  3760. //
  3761. //////////////////////////////////////////////////////////////////////////
  3762. void
  3763. CMainFrame::OnImportVisRemapData (void)
  3764. {
  3765. //
  3766. // Use the level's filename to generate a default filename
  3767. //
  3768. CString default_name = ::Get_Current_Document ()->GetPathName ();
  3769. if (default_name.GetLength () > 0) {
  3770. default_name = ::Get_Filename_From_Path (default_name);
  3771. default_name = ::Asset_Name_From_Filename (default_name);
  3772. default_name += ".vrt";
  3773. }
  3774. CFileDialog dialog ( TRUE,
  3775. ".vrt",
  3776. default_name,
  3777. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  3778. "Vis remap table (*.vrt)|*.vrt||",
  3779. this);
  3780. //
  3781. // Ask the user what file they wish to load from
  3782. //
  3783. if (dialog.DoModal () == IDOK) {
  3784. CString filename = dialog.GetPathName ();
  3785. //
  3786. // Is the filename OK?
  3787. //
  3788. HANDLE hfile = ::CreateFile (filename,
  3789. GENERIC_READ,
  3790. 0,
  3791. NULL,
  3792. OPEN_EXISTING,
  3793. 0L,
  3794. NULL);
  3795. ASSERT (hfile != INVALID_HANDLE_VALUE);
  3796. if (hfile != INVALID_HANDLE_VALUE) {
  3797. //
  3798. // Create a chunk-loader for use with the vis-importer
  3799. //
  3800. RawFileClass file_obj;
  3801. file_obj.Attach (hfile);
  3802. ChunkLoadClass chunk_load (&file_obj);
  3803. //
  3804. // Import the data
  3805. //
  3806. VisMgrClass::Import_Remap_Data (chunk_load);
  3807. }
  3808. }
  3809. return ;
  3810. }
  3811. //////////////////////////////////////////////////////////////////////////
  3812. //
  3813. // OnExportVisRemapData
  3814. //
  3815. //////////////////////////////////////////////////////////////////////////
  3816. void
  3817. CMainFrame::OnExportVisRemapData (void)
  3818. {
  3819. //
  3820. // Use the level's filename to generate a default filename
  3821. //
  3822. CString default_name = ::Get_Current_Document ()->GetPathName ();
  3823. if (default_name.GetLength () > 0) {
  3824. default_name = ::Get_Filename_From_Path (default_name);
  3825. default_name = ::Asset_Name_From_Filename (default_name);
  3826. default_name += ".vrt";
  3827. }
  3828. CFileDialog dialog ( FALSE,
  3829. ".vrt",
  3830. default_name,
  3831. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  3832. "Vis remap table (*.vrt)|*.vrt||",
  3833. this);
  3834. //
  3835. // Ask the user what commando level file they wish to save to
  3836. //
  3837. if (dialog.DoModal () == IDOK) {
  3838. CString filename = dialog.GetPathName ();
  3839. //
  3840. // Is the filename OK?
  3841. //
  3842. HANDLE hfile = ::CreateFile (filename,
  3843. GENERIC_WRITE,
  3844. 0,
  3845. NULL,
  3846. CREATE_ALWAYS,
  3847. 0L,
  3848. NULL);
  3849. ASSERT (hfile != INVALID_HANDLE_VALUE);
  3850. if (hfile != INVALID_HANDLE_VALUE) {
  3851. //
  3852. // Create a chunk-saver for use with the pathfind database
  3853. //
  3854. RawFileClass file_obj;
  3855. file_obj.Attach (hfile);
  3856. ChunkSaveClass chunk_save (&file_obj);
  3857. //
  3858. // Export the data
  3859. //
  3860. VisMgrClass::Export_Remap_Data (chunk_save);
  3861. }
  3862. }
  3863. return ;
  3864. }
  3865. //////////////////////////////////////////////////////////////////////////
  3866. //
  3867. // OnUpdateBulkReplace
  3868. //
  3869. //////////////////////////////////////////////////////////////////////////
  3870. void
  3871. CMainFrame::OnUpdateBulkReplace (CCmdUI *pCmdUI)
  3872. {
  3873. pCmdUI->Enable (::Get_Selection_Mgr ().Get_Count () > 0);
  3874. return ;
  3875. }
  3876. //////////////////////////////////////////////////////////////////////////
  3877. //
  3878. // OnBulkReplace
  3879. //
  3880. //////////////////////////////////////////////////////////////////////////
  3881. void
  3882. CMainFrame::OnBulkReplace (void)
  3883. {
  3884. ::Get_Scene_Editor ()->Replace_Selection ();
  3885. return ;
  3886. }
  3887. //////////////////////////////////////////////////////////////////////////
  3888. //
  3889. // OnCheckIds
  3890. //
  3891. //////////////////////////////////////////////////////////////////////////
  3892. void
  3893. CMainFrame::OnCheckIds (void)
  3894. {
  3895. NODE_LIST node_list;
  3896. NodeMgrClass::Build_ID_Collision_List (node_list);
  3897. if (node_list.Count () > 0) {
  3898. CString message = "ID collision detected in the following objects:\r\n\r\n";
  3899. //
  3900. // Build an error log of all the offending nodes
  3901. //
  3902. for (int index = 0; index < node_list.Count (); index ++) {
  3903. NodeClass *node = node_list[index];
  3904. //
  3905. // Add information about this entry to the log
  3906. //
  3907. CString entry;
  3908. entry.Format ("%s, ID = %d\r\n", node->Get_Name (), node->Get_ID ());
  3909. message += entry;
  3910. }
  3911. //
  3912. // Display the log to the user
  3913. //
  3914. GenericTextDialogClass dialog (this);
  3915. dialog.Set_Title ("ID Validation");
  3916. dialog.Set_Description ("ID Collisions listed below.");
  3917. dialog.Set_Text (message);
  3918. dialog.DoModal ();
  3919. } else {
  3920. //
  3921. // Let the user know there were no problems
  3922. //
  3923. MessageBox ("No ID collision detected in this level.", "ID Validation", MB_ICONINFORMATION | MB_OK);
  3924. }
  3925. return ;
  3926. }
  3927. //////////////////////////////////////////////////////////////////////////
  3928. //
  3929. // OnExportLights
  3930. //
  3931. //////////////////////////////////////////////////////////////////////////
  3932. void
  3933. CMainFrame::OnExportLights (void)
  3934. {
  3935. //
  3936. // Use the level's filename to generate a default WLT filename
  3937. //
  3938. CString default_name = ::Get_Current_Document ()->GetPathName ();
  3939. if (default_name.GetLength () > 0) {
  3940. default_name = ::Get_Filename_From_Path (default_name);
  3941. default_name = ::Asset_Name_From_Filename (default_name);
  3942. default_name += ".wlt";
  3943. }
  3944. CFileDialog dialog ( FALSE,
  3945. ".wlt",
  3946. NULL,
  3947. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  3948. "Westwood Light Database (*.wlt)|*.wlt||",
  3949. this);
  3950. //
  3951. // Ask the user what file they wish to export to
  3952. //
  3953. if (dialog.DoModal () == IDOK) {
  3954. ::Get_Scene_Editor ()->Export_Lights (dialog.GetPathName ());
  3955. }
  3956. return ;
  3957. }
  3958. //////////////////////////////////////////////////////////////////////////
  3959. //
  3960. // OnOptimizeVisData
  3961. //
  3962. //////////////////////////////////////////////////////////////////////////
  3963. void
  3964. CMainFrame::OnOptimizeVisData (void)
  3965. {
  3966. OptimizingVisDialogClass::Optimize ();
  3967. /*
  3968. StringClass message;
  3969. message.Format("Starting Bit Count: %d\nEnding Bit Count: %d\nDynamic Object Cells Removed: %d\nObjects Merged: %d\nSectors Merged: %d\nTotal Bits Removed: %d\nFinal Vis Sector Count: %d\nFinal Vis Object Count: %d\n",
  3970. stats.InitialBitCount,
  3971. stats.FinalBitCount,
  3972. stats.DynCellsRemoved,
  3973. stats.ObjectsMerged,
  3974. stats.SectorsMerged,
  3975. stats.TotalBitsRemoved,
  3976. vis_sector_count,
  3977. vis_object_count);
  3978. MessageBox(message,"Results");
  3979. */
  3980. return ;
  3981. }
  3982. //////////////////////////////////////////////////////////////////////////
  3983. //
  3984. // OnDisplayVisGridLittleBoxes
  3985. //
  3986. //////////////////////////////////////////////////////////////////////////
  3987. void
  3988. CMainFrame::OnDisplayVisGridLittleBoxes (void)
  3989. {
  3990. bool enabled = ::Get_Scene_Editor ()->Get_Vis_Grid_Display_Mode () == PhysicsSceneClass::VIS_GRID_DISPLAY_CENTERS;
  3991. if (!enabled) {
  3992. ::Get_Scene_Editor ()->Set_Vis_Grid_Display_Mode (PhysicsSceneClass::VIS_GRID_DISPLAY_CENTERS);
  3993. } else {
  3994. ::Get_Scene_Editor ()->Set_Vis_Grid_Display_Mode (PhysicsSceneClass::VIS_GRID_DISPLAY_NONE);
  3995. }
  3996. return ;
  3997. }
  3998. //////////////////////////////////////////////////////////////////////////
  3999. //
  4000. // OnUpdateDisplayVisGridLittleBoxes
  4001. //
  4002. //////////////////////////////////////////////////////////////////////////
  4003. void
  4004. CMainFrame::OnUpdateDisplayVisGridLittleBoxes (CCmdUI *pCmdUI)
  4005. {
  4006. pCmdUI->SetCheck (::Get_Scene_Editor ()->Get_Vis_Grid_Display_Mode () == PhysicsSceneClass::VIS_GRID_DISPLAY_CENTERS);
  4007. return ;
  4008. }
  4009. //////////////////////////////////////////////////////////////////////////
  4010. //
  4011. // OnDisplayVisGrid
  4012. //
  4013. //////////////////////////////////////////////////////////////////////////
  4014. void
  4015. CMainFrame::OnDisplayVisGrid (void)
  4016. {
  4017. bool enabled = ::Get_Scene_Editor ()->Get_Vis_Grid_Display_Mode () == PhysicsSceneClass::VIS_GRID_DISPLAY_ACTUAL_BOXES;
  4018. if (!enabled) {
  4019. ::Get_Scene_Editor ()->Set_Vis_Grid_Display_Mode (PhysicsSceneClass::VIS_GRID_DISPLAY_ACTUAL_BOXES);
  4020. } else {
  4021. ::Get_Scene_Editor ()->Set_Vis_Grid_Display_Mode (PhysicsSceneClass::VIS_GRID_DISPLAY_NONE);
  4022. }
  4023. return ;
  4024. }
  4025. //////////////////////////////////////////////////////////////////////////
  4026. //
  4027. // OnUpdateDisplayVisGrid
  4028. //
  4029. //////////////////////////////////////////////////////////////////////////
  4030. void
  4031. CMainFrame::OnUpdateDisplayVisGrid (CCmdUI *pCmdUI)
  4032. {
  4033. pCmdUI->SetCheck (::Get_Scene_Editor ()->Get_Vis_Grid_Display_Mode () == PhysicsSceneClass::VIS_GRID_DISPLAY_ACTUAL_BOXES);
  4034. return ;
  4035. }
  4036. //////////////////////////////////////////////////////////////////////////
  4037. //
  4038. // OnEditStringsTable
  4039. //
  4040. //////////////////////////////////////////////////////////////////////////
  4041. void
  4042. CMainFrame::OnEditStringsTable (void)
  4043. {
  4044. StringsMgrClass::Edit_Database (m_hWnd);
  4045. return ;
  4046. }
  4047. //////////////////////////////////////////////////////////////////////////
  4048. //
  4049. // OnExportStringIds
  4050. //
  4051. //////////////////////////////////////////////////////////////////////////
  4052. void
  4053. CMainFrame::OnExportStringIds (void)
  4054. {
  4055. CWaitCursor wait_cursor;
  4056. StringsMgrClass::Export_IDs ();
  4057. return ;
  4058. }
  4059. //////////////////////////////////////////////////////////////////////////
  4060. //
  4061. // OnImportStringIds
  4062. //
  4063. //////////////////////////////////////////////////////////////////////////
  4064. void
  4065. CMainFrame::OnImportStringIds (void)
  4066. {
  4067. CWaitCursor wait_cursor;
  4068. StringsMgrClass::Import_IDs ();
  4069. return ;
  4070. }
  4071. //////////////////////////////////////////////////////////////////////////
  4072. //
  4073. // OnBuildFlightInfo
  4074. //
  4075. //////////////////////////////////////////////////////////////////////////
  4076. void
  4077. CMainFrame::OnBuildFlightInfo (void)
  4078. {
  4079. CWaitCursor wait_cursor;
  4080. HeightDBClass::Generate ();
  4081. return ;
  4082. }
  4083. //////////////////////////////////////////////////////////////////////////
  4084. //
  4085. // OnToggleAttenuationSpheres
  4086. //
  4087. //////////////////////////////////////////////////////////////////////////
  4088. void
  4089. CMainFrame::OnToggleAttenuationSpheres (void)
  4090. {
  4091. SelectionMgrClass &sel_mgr = ::Get_Scene_Editor ()->Get_Selection_Mgr ();
  4092. //
  4093. // Loop over the currently selected nodes
  4094. //
  4095. for (int index = 0; index < sel_mgr.Get_Count (); index ++) {
  4096. NodeClass *node = sel_mgr.Get_At (index);
  4097. if (node != NULL) {
  4098. //
  4099. // Toggle the sphere display...
  4100. //
  4101. bool show_sphere = node->Is_Attenuation_Sphere_Shown ();
  4102. node->Show_Attenuation_Spheres (!show_sphere);
  4103. }
  4104. }
  4105. return ;
  4106. }
  4107. //////////////////////////////////////////////////////////////////////////
  4108. //
  4109. // OnUpdateToggleAttenuationSpheres
  4110. //
  4111. //////////////////////////////////////////////////////////////////////////
  4112. void
  4113. CMainFrame::OnUpdateToggleAttenuationSpheres (CCmdUI *pCmdUI)
  4114. {
  4115. pCmdUI->Enable (::Get_Selection_Mgr ().Get_Count () > 0);
  4116. return ;
  4117. }
  4118. //////////////////////////////////////////////////////////////////////////
  4119. //
  4120. // OnFixIdCollisions
  4121. //
  4122. //////////////////////////////////////////////////////////////////////////
  4123. void
  4124. CMainFrame::OnFixIdCollisions (void)
  4125. {
  4126. NODE_LIST node_list;
  4127. NodeMgrClass::Build_ID_Collision_List (node_list);
  4128. if (node_list.Count () > 0) {
  4129. //
  4130. // Remap all the IDs
  4131. //
  4132. int count = 0;
  4133. for (int index = 0; index < node_list.Count (); index ++) {
  4134. NodeClass *node = node_list[index];
  4135. if (node != NULL) {
  4136. node->Set_ID (NodeMgrClass::Get_Node_ID (node->Get_Type ()));
  4137. count ++;
  4138. }
  4139. }
  4140. CString message;
  4141. message.Format ("Remapped %d object IDs.", count);
  4142. MessageBox (message, "ID Repair", MB_ICONINFORMATION | MB_OK);
  4143. } else {
  4144. //
  4145. // Let the user know there were no problems
  4146. //
  4147. MessageBox ("No ID collision detected in this level.", "ID Validation", MB_ICONINFORMATION | MB_OK);
  4148. }
  4149. return ;
  4150. }
  4151. //////////////////////////////////////////////////////////////////////////
  4152. //
  4153. // OnResetDynaCullSystem
  4154. //
  4155. //////////////////////////////////////////////////////////////////////////
  4156. void
  4157. CMainFrame::OnResetDynaCullSystem (void)
  4158. {
  4159. ::Get_Scene_Editor ()->Re_Partition_Dynamic_Culling_System ();
  4160. return ;
  4161. }
  4162. //////////////////////////////////////////////////////////////////////////
  4163. //
  4164. // OnDisplayLightVectors
  4165. //
  4166. //////////////////////////////////////////////////////////////////////////
  4167. void
  4168. CMainFrame::OnDisplayLightVectors (void)
  4169. {
  4170. bool enabled = ::Get_Scene_Editor ()->Is_Lighting_Debug_Display_Enabled ();
  4171. ::Get_Scene_Editor ()->Enable_Lighting_Debug_Display (!enabled);
  4172. return ;
  4173. }
  4174. //////////////////////////////////////////////////////////////////////////
  4175. //
  4176. // OnUpdateDisplayLightVectors
  4177. //
  4178. //////////////////////////////////////////////////////////////////////////
  4179. void
  4180. CMainFrame::OnUpdateDisplayLightVectors (CCmdUI *pCmdUI)
  4181. {
  4182. bool enabled = ::Get_Scene_Editor ()->Is_Lighting_Debug_Display_Enabled ();
  4183. pCmdUI->SetCheck (enabled);
  4184. return ;
  4185. }
  4186. //////////////////////////////////////////////////////////////////////////
  4187. //
  4188. // OnDisplayStaticAnimObjects
  4189. //
  4190. //////////////////////////////////////////////////////////////////////////
  4191. void
  4192. CMainFrame::OnDisplayStaticAnimObjects (void)
  4193. {
  4194. bool enabled = ::Get_Scene_Editor ()->Are_Static_Anim_Phys_Displayed ();
  4195. ::Get_Scene_Editor ()->Display_Static_Anim_Phys (!enabled);
  4196. return ;
  4197. }
  4198. //////////////////////////////////////////////////////////////////////////
  4199. //
  4200. // OnUpdateDisplayStaticAnimObjects
  4201. //
  4202. //////////////////////////////////////////////////////////////////////////
  4203. void
  4204. CMainFrame::OnUpdateDisplayStaticAnimObjects (CCmdUI *pCmdUI)
  4205. {
  4206. bool enabled = ::Get_Scene_Editor ()->Are_Static_Anim_Phys_Displayed ();
  4207. pCmdUI->SetCheck (enabled);
  4208. return ;
  4209. }
  4210. //////////////////////////////////////////////////////////////////////////
  4211. //
  4212. // OnEditConversations
  4213. //
  4214. //////////////////////////////////////////////////////////////////////////
  4215. void
  4216. CMainFrame::OnEditConversations (void)
  4217. {
  4218. EditConversationListDialogClass dialog (this);
  4219. dialog.DoModal ();
  4220. return ;
  4221. }
  4222. //////////////////////////////////////////////////////////////////////////
  4223. //
  4224. // OnBuildingPowerOn
  4225. //
  4226. //////////////////////////////////////////////////////////////////////////
  4227. void
  4228. CMainFrame::OnBuildingPowerOn (void)
  4229. {
  4230. bool enabled = ::Get_Scene_Editor ()->Is_Building_Power_Enabled ();
  4231. ::Get_Scene_Editor ()->Enable_Building_Power (!enabled);
  4232. return ;
  4233. }
  4234. //////////////////////////////////////////////////////////////////////////
  4235. //
  4236. // OnUpdateBuildingPowerOn
  4237. //
  4238. //////////////////////////////////////////////////////////////////////////
  4239. void
  4240. CMainFrame::OnUpdateBuildingPowerOn (CCmdUI *pCmdUI)
  4241. {
  4242. bool enabled = ::Get_Scene_Editor ()->Is_Building_Power_Enabled ();
  4243. pCmdUI->SetCheck (enabled);
  4244. return ;
  4245. }
  4246. //////////////////////////////////////////////////////////////////////////
  4247. //
  4248. // OnCreateProxies
  4249. //
  4250. //////////////////////////////////////////////////////////////////////////
  4251. void
  4252. CMainFrame::OnCreateProxies (void)
  4253. {
  4254. bool enabled = ::Get_Scene_Editor ()->Is_Proxy_Creation_Enabled ();
  4255. ::Get_Scene_Editor ()->Enable_Proxy_Creation (!enabled);
  4256. return ;
  4257. }
  4258. //////////////////////////////////////////////////////////////////////////
  4259. //
  4260. // OnUpdateCreateProxies
  4261. //
  4262. //////////////////////////////////////////////////////////////////////////
  4263. void
  4264. CMainFrame::OnUpdateCreateProxies (CCmdUI *pCmdUI)
  4265. {
  4266. bool enabled = ::Get_Scene_Editor ()->Is_Proxy_Creation_Enabled ();
  4267. pCmdUI->SetCheck (enabled);
  4268. return ;
  4269. }
  4270. //////////////////////////////////////////////////////////////////////////
  4271. //
  4272. // OnCheckInPresetChanges
  4273. //
  4274. //////////////////////////////////////////////////////////////////////////
  4275. void
  4276. CMainFrame::OnCheckInPresetChanges (void)
  4277. {
  4278. PresetMgrClass::Check_In_Presets ();
  4279. return ;
  4280. }
  4281. //////////////////////////////////////////////////////////////////////////
  4282. //
  4283. // OnUpdateCheckInPresetChanges
  4284. //
  4285. //////////////////////////////////////////////////////////////////////////
  4286. void
  4287. CMainFrame::OnUpdateCheckInPresetChanges (CCmdUI *pCmdUI)
  4288. {
  4289. pCmdUI->Enable (PresetMgrClass::Are_Presets_Dirty ());
  4290. return ;
  4291. }
  4292. //////////////////////////////////////////////////////////////////////////
  4293. //
  4294. // OnImmediatePresetCheckin
  4295. //
  4296. //////////////////////////////////////////////////////////////////////////
  4297. void
  4298. CMainFrame::OnImmediatePresetCheckin (void)
  4299. {
  4300. bool enabled = PresetMgrClass::Get_Immediate_Check_In_Mode ();
  4301. PresetMgrClass::Set_Immediate_Check_In_Mode (!enabled);
  4302. return ;
  4303. }
  4304. //////////////////////////////////////////////////////////////////////////
  4305. //
  4306. // OnUpdateImmediatePresetCheckin
  4307. //
  4308. //////////////////////////////////////////////////////////////////////////
  4309. void
  4310. CMainFrame::OnUpdateImmediatePresetCheckin (CCmdUI *pCmdUI)
  4311. {
  4312. pCmdUI->SetCheck (PresetMgrClass::Get_Immediate_Check_In_Mode ());
  4313. return ;
  4314. }
  4315. //////////////////////////////////////////////////////////////////////////
  4316. //
  4317. // OnRemapIds
  4318. //
  4319. //////////////////////////////////////////////////////////////////////////
  4320. void
  4321. CMainFrame::OnRemapIds (void)
  4322. {
  4323. if (::MessageBox (NULL, "Are you sure you want to remap the IDs of the currently selected objects into the current ID range?", "ID Remap", MB_ICONQUESTION | MB_YESNO) == IDYES) {
  4324. SelectionMgrClass &sel_mgr = ::Get_Scene_Editor ()->Get_Selection_Mgr ();
  4325. //
  4326. // Loop over the currently selected nodes
  4327. //
  4328. for (int index = 0; index < sel_mgr.Get_Count (); index ++) {
  4329. NodeClass *node = sel_mgr.Get_At (index);
  4330. if (node != NULL) {
  4331. //
  4332. // Remap this node's ID
  4333. //
  4334. node->Set_ID (NodeMgrClass::Get_Node_ID (node->Get_Type ()));
  4335. }
  4336. }
  4337. }
  4338. return ;
  4339. }
  4340. //////////////////////////////////////////////////////////////////////////
  4341. //
  4342. // OnUpdateRemapIds
  4343. //
  4344. //////////////////////////////////////////////////////////////////////////
  4345. void
  4346. CMainFrame::OnUpdateRemapIds (CCmdUI *pCmdUI)
  4347. {
  4348. pCmdUI->Enable (::Get_Selection_Mgr ().Get_Count () > 0);
  4349. return ;
  4350. }
  4351. //////////////////////////////////////////////////////////////////////////
  4352. //
  4353. // OnVerifyCulling
  4354. //
  4355. //////////////////////////////////////////////////////////////////////////
  4356. void
  4357. CMainFrame::OnVerifyCulling (void)
  4358. {
  4359. StringClass errors;
  4360. errors.Format("Errors Detected:\r\n");
  4361. bool result = ::Get_Scene_Editor()->Verify_Culling_Systems(errors);
  4362. if (result == true) {
  4363. ::MessageBox (NULL, "Culling Systems Verified!\n", "Results", MB_OK);
  4364. } else {
  4365. GenericTextDialogClass dialog (this);
  4366. dialog.Set_Title ("Results");
  4367. dialog.Set_Description ("Culling system errors listed below.");
  4368. dialog.Set_Text (errors);
  4369. dialog.DoModal ();
  4370. }
  4371. return ;
  4372. }
  4373. //////////////////////////////////////////////////////////////////////////
  4374. //
  4375. // OnEnableVisSectorFallback
  4376. //
  4377. //////////////////////////////////////////////////////////////////////////
  4378. void
  4379. CMainFrame::OnEnableVisSectorFallback (void)
  4380. {
  4381. ::Get_Scene_Editor()->Enable_Vis_Sector_Fallback(!::Get_Scene_Editor()->Is_Vis_Sector_Fallback_Enabled());
  4382. return ;
  4383. }
  4384. //////////////////////////////////////////////////////////////////////////
  4385. //
  4386. // OnUpdateEnableVisSectorFallback
  4387. //
  4388. //////////////////////////////////////////////////////////////////////////
  4389. void
  4390. CMainFrame::OnUpdateEnableVisSectorFallback(CCmdUI* pCmdUI)
  4391. {
  4392. pCmdUI->SetCheck(::Get_Scene_Editor()->Is_Vis_Sector_Fallback_Enabled());
  4393. return ;
  4394. }
  4395. //////////////////////////////////////////////////////////////////////////
  4396. //
  4397. // OnRunManualVisPoints
  4398. //
  4399. //////////////////////////////////////////////////////////////////////////
  4400. void
  4401. CMainFrame::OnRunManualVisPoints (void)
  4402. {
  4403. CWaitCursor wait_cursor ();
  4404. VisMgrClass::Render_Manual_Vis_Points ();
  4405. return ;
  4406. }
  4407. //////////////////////////////////////////////////////////////////////////
  4408. //
  4409. // OnShowEditorObjects
  4410. //
  4411. //////////////////////////////////////////////////////////////////////////
  4412. void
  4413. CMainFrame::OnShowEditorObjects (void)
  4414. {
  4415. bool enabled = ::Get_Scene_Editor ()->Are_Editor_Objects_Displayed ();
  4416. ::Get_Scene_Editor ()->Display_Editor_Objects (!enabled);
  4417. return ;
  4418. }
  4419. //////////////////////////////////////////////////////////////////////////
  4420. //
  4421. // OnUpdateShowEditorObjects
  4422. //
  4423. //////////////////////////////////////////////////////////////////////////
  4424. void
  4425. CMainFrame::OnUpdateShowEditorObjects (CCmdUI *pCmdUI)
  4426. {
  4427. bool enabled = ::Get_Scene_Editor ()->Are_Editor_Objects_Displayed ();
  4428. pCmdUI->SetCheck (enabled);
  4429. return ;
  4430. }
  4431. //////////////////////////////////////////////////////////////////////////
  4432. //
  4433. // OnAddChildNode
  4434. //
  4435. //////////////////////////////////////////////////////////////////////////
  4436. void
  4437. CMainFrame::OnAddChildNode (void)
  4438. {
  4439. SelectionMgrClass &sel_mgr = ::Get_Scene_Editor ()->Get_Selection_Mgr ();
  4440. //
  4441. // Ensure we only have one selected node
  4442. //
  4443. if (sel_mgr.Get_Count () == 1) {
  4444. NodeClass *node = sel_mgr.Get_At (0);
  4445. if (node != NULL) {
  4446. //
  4447. // If this node is a child node already, then
  4448. // create a new child from its parent
  4449. //
  4450. NodeClass *parent_node = node->Get_Parent_Node ();
  4451. if (parent_node != NULL) {
  4452. node = parent_node;
  4453. }
  4454. //
  4455. // Add a child node and start moving it around
  4456. //
  4457. NodeClass *child_node = node->Add_Child_Node (Matrix3D(1));
  4458. if (child_node != NULL) {
  4459. ::Get_Mouse_Mgr ()->Move_Node (child_node);
  4460. }
  4461. }
  4462. }
  4463. return ;
  4464. }
  4465. //////////////////////////////////////////////////////////////////////////
  4466. //
  4467. // OnUpdateAddChildNode
  4468. //
  4469. //////////////////////////////////////////////////////////////////////////
  4470. void
  4471. CMainFrame::OnUpdateAddChildNode (CCmdUI *pCmdUI)
  4472. {
  4473. bool enable = false;
  4474. SelectionMgrClass &sel_mgr = ::Get_Scene_Editor ()->Get_Selection_Mgr ();
  4475. //
  4476. // Ensure we only have one selected node and its the right type
  4477. //
  4478. if (sel_mgr.Get_Count () == 1) {
  4479. NodeClass *node = sel_mgr.Get_At (0);
  4480. if (node != NULL) {
  4481. //
  4482. // If we are only a child node, then use our parent
  4483. //
  4484. if (node->Get_Parent_Node () != NULL) {
  4485. node = node->Get_Parent_Node ();
  4486. }
  4487. if (node->Can_Add_Child_Nodes ()) {
  4488. enable = true;
  4489. }
  4490. }
  4491. }
  4492. pCmdUI->Enable (enable);
  4493. return ;
  4494. }
  4495. //////////////////////////////////////////////////////////////////////////
  4496. //
  4497. // OnCheckMemlog
  4498. //
  4499. //////////////////////////////////////////////////////////////////////////
  4500. void
  4501. CMainFrame::OnCheckMemlog (void)
  4502. {
  4503. MemLogDialogClass dialog (this);
  4504. dialog.DoModal ();
  4505. return ;
  4506. }
  4507. //////////////////////////////////////////////////////////////////////////
  4508. //
  4509. // OnMakeVisPoint
  4510. //
  4511. //////////////////////////////////////////////////////////////////////////
  4512. void
  4513. CMainFrame::OnMakeVisPoint (void)
  4514. {
  4515. const Matrix3D &tm = ::Get_Camera_Mgr ()->Get_Camera ()->Get_Transform ();
  4516. ::Get_Scene_Editor ()->Record_Vis_Info (tm, tm.Get_Translation ());
  4517. return ;
  4518. }
  4519. //////////////////////////////////////////////////////////////////////////
  4520. //
  4521. // OnExportStringTable
  4522. //
  4523. //////////////////////////////////////////////////////////////////////////
  4524. void
  4525. CMainFrame::OnExportStringTable (void)
  4526. {
  4527. CFileDialog dialog (FALSE, ".txt", "strings_table.txt",
  4528. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  4529. "Text Files (*.txt)|*.txt||", ::AfxGetMainWnd ());
  4530. //
  4531. // Ask the user what file they want to create
  4532. //
  4533. if (dialog.DoModal () == IDOK) {
  4534. //
  4535. // Check to make sure the destination filename is not read-only
  4536. //
  4537. CString path = dialog.GetPathName ();
  4538. DWORD file_attributes = ::GetFileAttributes (path);
  4539. if (file_attributes != 0xFFFFFFFF && file_attributes & FILE_ATTRIBUTE_READONLY) {
  4540. ::MessageBox (::AfxGetMainWnd ()->m_hWnd, "File is read-only, export operation can not complete.", "File Error", MB_ICONERROR | MB_ICONEXCLAMATION);
  4541. } else {
  4542. TranslateDBClass::Export_Table (path);
  4543. }
  4544. }
  4545. return ;
  4546. }
  4547. //////////////////////////////////////////////////////////////////////////
  4548. //
  4549. // OnGotoObject
  4550. //
  4551. //////////////////////////////////////////////////////////////////////////
  4552. void
  4553. CMainFrame::OnGotoObject (void)
  4554. {
  4555. GotoObjectByIDDialogClass dialog (this);
  4556. dialog.DoModal ();
  4557. return ;
  4558. }
  4559. //////////////////////////////////////////////////////////////////////////
  4560. //
  4561. // OnExportPresets
  4562. //
  4563. //////////////////////////////////////////////////////////////////////////
  4564. void
  4565. CMainFrame::OnExportPresets (void)
  4566. {
  4567. ExportPresetsDialogClass dialog (this);
  4568. dialog.DoModal ();
  4569. return ;
  4570. }
  4571. //////////////////////////////////////////////////////////////////////////
  4572. //
  4573. // OnImportPresets
  4574. //
  4575. //////////////////////////////////////////////////////////////////////////
  4576. void
  4577. CMainFrame::OnImportPresets (void)
  4578. {
  4579. CFileDialog dialog (TRUE, ".txt", "presets.txt",
  4580. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  4581. "Text Files (*.txt)|*.txt||", ::AfxGetMainWnd ());
  4582. //
  4583. // Ask the user what file they want to import
  4584. //
  4585. if (dialog.DoModal () == IDOK) {
  4586. //
  4587. // Import the data
  4588. //
  4589. CString path = dialog.GetPathName ();
  4590. PresetExportClass::Import (path);
  4591. }
  4592. return ;
  4593. }
  4594. //////////////////////////////////////////////////////////////////////////
  4595. //
  4596. // OnBatchExport
  4597. //
  4598. //////////////////////////////////////////////////////////////////////////
  4599. void
  4600. CMainFrame::OnBatchExport (void)
  4601. {
  4602. CFileDialog dialog ( TRUE,
  4603. ".lvl",
  4604. NULL,
  4605. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ALLOWMULTISELECT,
  4606. "Level Editor Files (*.lvl)|*.lvl||",
  4607. this);
  4608. TCHAR filename_list[MAX_PATH * 10] = { 0 };
  4609. dialog.m_ofn.lpstrFile = filename_list;
  4610. dialog.m_ofn.nMaxFile = sizeof (filename_list);
  4611. //
  4612. // Ask the user what commando level file they wish to save to
  4613. //
  4614. if (dialog.DoModal () == IDOK) {
  4615. //
  4616. // Get the destination for the export
  4617. //
  4618. CString destination_dir;
  4619. if (::Browse_For_Folder (destination_dir, m_hWnd, "", "Select the destination directory for the export process.")) {
  4620. //
  4621. // Ask the user if they want to create a subdir for each level
  4622. // or not
  4623. //
  4624. bool create_subdirs = false;
  4625. if (::MessageBox (m_hWnd, "Would you like to export each level to its own sub-directory?", "Batch Export", MB_ICONQUESTION | MB_YESNO) == IDYES) {
  4626. create_subdirs = true;
  4627. }
  4628. //
  4629. // Turn off rendering
  4630. //
  4631. ::Get_Main_View ()->Allow_Repaint (false);
  4632. CLevelEditDoc::Set_Is_Batch_Export_Mode (true);
  4633. //
  4634. // Loop through all the selected files
  4635. //
  4636. POSITION pos = dialog.GetStartPosition ();
  4637. while (pos != NULL) {
  4638. //
  4639. // Start fresh
  4640. //
  4641. ::Get_Current_Document ()->OnNewDocument ();
  4642. //
  4643. // Load the level
  4644. //
  4645. CString lvl_filename = dialog.GetNextPathName (pos);
  4646. EditorSaveLoadClass::Load_Level (lvl_filename);
  4647. ::Get_Current_Document ()->SetModifiedFlag (false);
  4648. //
  4649. // Build the full path of the destination file
  4650. //
  4651. CString filename_base;
  4652. filename_base = ::Get_Filename_From_Path (lvl_filename);
  4653. filename_base = ::Asset_Name_From_Filename (filename_base);
  4654. CString export_path = destination_dir;
  4655. if (create_subdirs) {
  4656. export_path = Make_Path (destination_dir, filename_base);
  4657. }
  4658. //
  4659. // Make sure the directory exists
  4660. //
  4661. ::Create_Dir_If_Necessary (export_path);
  4662. //
  4663. // Add the filename onto the path
  4664. //
  4665. CString full_path = Make_Path (export_path, filename_base);
  4666. full_path += ".mix";
  4667. //
  4668. // Export the level
  4669. //
  4670. ExporterClass exporter;
  4671. exporter.Export_Level (full_path);
  4672. }
  4673. //
  4674. // Turn on rendering
  4675. //
  4676. ::Get_Main_View ()->Allow_Repaint (true);
  4677. CLevelEditDoc::Set_Is_Batch_Export_Mode (false);
  4678. }
  4679. }
  4680. return ;
  4681. }
  4682. //////////////////////////////////////////////////////////////////////////
  4683. //
  4684. // OnLockVisSamplePoint
  4685. //
  4686. //////////////////////////////////////////////////////////////////////////
  4687. void
  4688. CMainFrame::OnLockVisSamplePoint (void)
  4689. {
  4690. ::Get_Scene_Editor()->Lock_Vis_Sample_Point(!::Get_Scene_Editor()->Is_Vis_Sample_Point_Locked());
  4691. return ;
  4692. }
  4693. //////////////////////////////////////////////////////////////////////////
  4694. //
  4695. // OnUpdateLockVisSamplePoint
  4696. //
  4697. //////////////////////////////////////////////////////////////////////////
  4698. void
  4699. CMainFrame::OnUpdateLockVisSamplePoint (CCmdUI *pCmdUI)
  4700. {
  4701. pCmdUI->SetCheck (::Get_Scene_Editor ()->Is_Vis_Sample_Point_Locked());
  4702. return ;
  4703. }
  4704. //////////////////////////////////////////////////////////////////////////
  4705. //
  4706. // OnToggleTerrainSelection
  4707. //
  4708. //////////////////////////////////////////////////////////////////////////
  4709. void
  4710. CMainFrame::OnToggleTerrainSelection (void)
  4711. {
  4712. if (::Get_Scene_Editor ()->Do_Groups_Collide (MOUSE_CLICK_COLLISION_GROUP, 15)) {
  4713. ::Get_Scene_Editor ()->Disable_Collision_Detection (MOUSE_CLICK_COLLISION_GROUP, 15);
  4714. } else {
  4715. ::Get_Scene_Editor ()->Enable_Collision_Detection (MOUSE_CLICK_COLLISION_GROUP, 15);
  4716. }
  4717. return ;
  4718. }
  4719. //////////////////////////////////////////////////////////////////////////
  4720. //
  4721. // OnUpdateToggleTerrainSelection
  4722. //
  4723. //////////////////////////////////////////////////////////////////////////
  4724. void
  4725. CMainFrame::OnUpdateToggleTerrainSelection (CCmdUI *pCmdUI)
  4726. {
  4727. pCmdUI->SetCheck (::Get_Scene_Editor ()->Do_Groups_Collide (MOUSE_CLICK_COLLISION_GROUP, 15));
  4728. return ;
  4729. }
  4730. //////////////////////////////////////////////////////////////////////////
  4731. //
  4732. // OnExportPresetFileDependencies
  4733. //
  4734. //////////////////////////////////////////////////////////////////////////
  4735. void
  4736. CMainFrame::OnExportPresetFileDependencies (void)
  4737. {
  4738. PresetsFormClass *presets_form = ::Get_Presets_Form ();
  4739. if (presets_form != NULL) {
  4740. CFileDialog dialog ( FALSE,
  4741. ".txt",
  4742. "presets.txt",
  4743. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  4744. "Text file (*.txt)|*.txt||",
  4745. this);
  4746. //
  4747. // Ask the user where they want to export this data
  4748. //
  4749. if (dialog.DoModal () == IDOK) {
  4750. CString filename = dialog.GetPathName ();
  4751. presets_form->Export_File_Dependencies (filename);
  4752. }
  4753. }
  4754. return ;
  4755. }
  4756. //////////////////////////////////////////////////////////////////////////
  4757. //
  4758. // OnImportStrings
  4759. //
  4760. //////////////////////////////////////////////////////////////////////////
  4761. void
  4762. CMainFrame::OnImportStrings (void)
  4763. {
  4764. CWaitCursor wait_cursor;
  4765. StringsMgrClass::Import_Strings ();
  4766. return ;
  4767. }
  4768. //////////////////////////////////////////////////////////////////////////
  4769. //
  4770. // OnExportTileList
  4771. //
  4772. //////////////////////////////////////////////////////////////////////////
  4773. void
  4774. CMainFrame::OnExportTileList (void)
  4775. {
  4776. //
  4777. // Use the level's filename to generate a default filename
  4778. //
  4779. CString default_name = ::Get_Current_Document ()->GetPathName ();
  4780. if (default_name.GetLength () > 0) {
  4781. default_name = ::Get_Filename_From_Path (default_name);
  4782. default_name = ::Asset_Name_From_Filename (default_name);
  4783. default_name += ".txt";
  4784. }
  4785. CFileDialog dialog ( FALSE,
  4786. ".txt",
  4787. default_name,
  4788. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  4789. "Text Files (*.txt)|*.txt||",
  4790. this);
  4791. if (dialog.DoModal () == IDOK) {
  4792. //
  4793. // Open the file
  4794. //
  4795. StringClass filename = dialog.GetPathName ();
  4796. TextFileClass text_file (filename);
  4797. if (text_file.Open (FileClass::WRITE)) {
  4798. DynamicVectorClass<NodeClass *> node_list;
  4799. //
  4800. // Ask the user if they want to export all tiles or just the selection set.
  4801. //
  4802. bool do_sel_only = (MessageBox ("Would you like to export tiles that are only in the current selection?", "Export Tile List", MB_ICONQUESTION | MB_YESNO) == IDYES);
  4803. if (do_sel_only) {
  4804. SelectionMgrClass &sel_mgr = ::Get_Scene_Editor ()->Get_Selection_Mgr ();
  4805. //
  4806. // Loop over the currently selected nodes
  4807. //
  4808. for (int index = 0; index < sel_mgr.Get_Count (); index ++) {
  4809. NodeClass *node = sel_mgr.Get_At (index);
  4810. if ( node != NULL &&
  4811. node->Is_Proxied () == false &&
  4812. node->Get_Type () == NODE_TYPE_TILE)
  4813. {
  4814. node_list.Add (node);
  4815. }
  4816. }
  4817. } else {
  4818. //
  4819. // Loop over all the nodes in the scene
  4820. //
  4821. for ( NodeClass *node = NodeMgrClass::Get_First ();
  4822. node != NULL;
  4823. node = NodeMgrClass::Get_Next (node))
  4824. {
  4825. if ( node != NULL &&
  4826. node->Is_Proxied () == false &&
  4827. node->Get_Type () == NODE_TYPE_TILE)
  4828. {
  4829. node_list.Add (node);
  4830. }
  4831. }
  4832. }
  4833. //
  4834. // Write an entry for each node in the list
  4835. //
  4836. for (int index = 0; index < node_list.Count (); index ++) {
  4837. NodeClass *node = node_list[index];
  4838. const char *name = node->Get_Name ();
  4839. const Matrix3D &tm = node->Get_Transform ();
  4840. const Vector3 &pos = tm.Get_Translation ();
  4841. //
  4842. // Build a string containing the tile information
  4843. //
  4844. StringClass text;
  4845. text.Format ("%s:\t(%.3f, %.3f, %.3f), %.2f degrees", name, pos.X, pos.Y, pos.Z, RAD_TO_DEGF (tm.Get_Z_Rotation ()));
  4846. //
  4847. // Write this line to the file
  4848. //
  4849. text_file.Write_Line (text);
  4850. }
  4851. text_file.Close ();
  4852. }
  4853. }
  4854. return ;
  4855. }
  4856. //////////////////////////////////////////////////////////////////////////
  4857. //
  4858. // OnRemapUnimportantIds
  4859. //
  4860. //////////////////////////////////////////////////////////////////////////
  4861. void
  4862. CMainFrame::OnRemapUnimportantIds (void)
  4863. {
  4864. NODE_LIST node_list;
  4865. NodeMgrClass::Build_Unimportant_ID_Collision_List (node_list);
  4866. if (node_list.Count () > 0) {
  4867. //
  4868. // Remap all the IDs
  4869. //
  4870. int count = 0;
  4871. for (int index = 0; index < node_list.Count (); index ++) {
  4872. NodeClass *node = node_list[index];
  4873. if (node != NULL) {
  4874. node->Set_ID (NodeMgrClass::Get_Node_ID (node->Get_Type ()));
  4875. count ++;
  4876. }
  4877. }
  4878. CString message;
  4879. message.Format ("Remapped %d object IDs.", count);
  4880. MessageBox (message, "ID Repair", MB_ICONINFORMATION | MB_OK);
  4881. } else {
  4882. //
  4883. // Let the user know there were no problems
  4884. //
  4885. MessageBox ("No ID collision detected in this level.", "ID Validation", MB_ICONINFORMATION | MB_OK);
  4886. }
  4887. return ;
  4888. }
  4889. //////////////////////////////////////////////////////////////////////////
  4890. //
  4891. // OnEditLevelSettings
  4892. //
  4893. //////////////////////////////////////////////////////////////////////////
  4894. void
  4895. CMainFrame::OnEditLevelSettings (void)
  4896. {
  4897. LevelSettingsDialogClass dialog;
  4898. dialog.DoModal ();
  4899. return ;
  4900. }
  4901. //////////////////////////////////////////////////////////////////////////
  4902. //
  4903. // OnExportTranslationData
  4904. //
  4905. //////////////////////////////////////////////////////////////////////////
  4906. void
  4907. CMainFrame::OnExportTranslationData (void)
  4908. {
  4909. CFileDialog dialog ( FALSE,
  4910. ".xls",
  4911. "strings.xls",
  4912. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  4913. "Excel Spreadsheet (*.xls)|*.xls||",
  4914. this);
  4915. //
  4916. // Ask the user what file they want to save to
  4917. //
  4918. if (dialog.DoModal () == IDOK) {
  4919. ImportTranslationDialogClass import_dialog (this);
  4920. import_dialog.Set_Filename (dialog.GetPathName ());
  4921. import_dialog.Set_Is_For_Export (true);
  4922. import_dialog.DoModal ();
  4923. }
  4924. return ;
  4925. }
  4926. //////////////////////////////////////////////////////////////////////////
  4927. //
  4928. // OnExportTranslationData
  4929. //
  4930. //////////////////////////////////////////////////////////////////////////
  4931. void
  4932. CMainFrame::OnImportTranslationData (void)
  4933. {
  4934. CFileDialog dialog ( TRUE,
  4935. ".xls",
  4936. "strings.xls",
  4937. OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_SHAREAWARE,
  4938. "Excel Spreadsheet (*.xls)|*.xls||",
  4939. this);
  4940. //
  4941. // Ask the user what file they want to import
  4942. //
  4943. if (dialog.DoModal () == IDOK) {
  4944. ImportTranslationDialogClass import_dialog (this);
  4945. import_dialog.Set_Filename (dialog.GetPathName ());
  4946. import_dialog.DoModal ();
  4947. }
  4948. return ;
  4949. }
  4950. //////////////////////////////////////////////////////////////////////////
  4951. //
  4952. // OnCompressTextures
  4953. //
  4954. //////////////////////////////////////////////////////////////////////////
  4955. void
  4956. CMainFrame::OnCompressTextures (void)
  4957. {
  4958. bool enabled = EditorMixFileCreator::Are_Textures_Compressed();
  4959. EditorMixFileCreator::Set_Texture_Compression (!enabled);
  4960. return ;
  4961. }
  4962. //////////////////////////////////////////////////////////////////////////
  4963. //
  4964. // OnUpdateCompressTextures
  4965. //
  4966. //////////////////////////////////////////////////////////////////////////
  4967. void
  4968. CMainFrame::OnUpdateCompressTextures (CCmdUI *pCmdUI)
  4969. {
  4970. bool enabled = EditorMixFileCreator::Are_Textures_Compressed();
  4971. pCmdUI->SetCheck (enabled);
  4972. return ;
  4973. }
  4974. //////////////////////////////////////////////////////////////////////////
  4975. //
  4976. // OnExportFileUsageReport
  4977. //
  4978. //////////////////////////////////////////////////////////////////////////
  4979. void
  4980. CMainFrame::OnExportFileUsageReport (void)
  4981. {
  4982. CFileDialog dialog ( FALSE,
  4983. ".txt",
  4984. "files.txt",
  4985. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  4986. "Text Files (*.txt)|*.txt||",
  4987. this);
  4988. //
  4989. // Ask the user what file they want to save to
  4990. //
  4991. if (dialog.DoModal () == IDOK) {
  4992. ReportMgrClass::Export_File_Usage_Report (dialog.GetPathName ());
  4993. }
  4994. return ;
  4995. }
  4996. //////////////////////////////////////////////////////////////////////////
  4997. //
  4998. // OnExportMissingTranslationReport
  4999. //
  5000. //////////////////////////////////////////////////////////////////////////
  5001. void
  5002. CMainFrame::OnExportMissingTranslationReport (void)
  5003. {
  5004. CFileDialog dialog ( FALSE,
  5005. ".txt",
  5006. "files.txt",
  5007. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  5008. "Text Files (*.txt)|*.txt||",
  5009. this);
  5010. //
  5011. // Ask the user what file they want to save to
  5012. //
  5013. if (dialog.DoModal () == IDOK) {
  5014. MissingTranslationReportDialogClass report_dialog (this);
  5015. report_dialog.Set_Filename (dialog.GetPathName ());
  5016. report_dialog.DoModal ();
  5017. }
  5018. return ;
  5019. }
  5020. //////////////////////////////////////////////////////////////////////////
  5021. //
  5022. // OnExportLanguage
  5023. //
  5024. //////////////////////////////////////////////////////////////////////////
  5025. void
  5026. CMainFrame::OnExportLanguage (void)
  5027. {
  5028. //
  5029. // Determine which directory we should use as a default for the export
  5030. //
  5031. CString full_path = theApp.GetProfileString (CONFIG_KEY, LAST_EXPORT_DIR_VALUE);
  5032. if (full_path.GetLength () == 0) {
  5033. full_path = ::Get_File_Mgr ()->Make_Full_Path (LEVELS_ASSET_DIR);
  5034. }
  5035. _pThe3DAssetManager->Set_Current_Directory (full_path);
  5036. CFileDialog dialog ( FALSE,
  5037. ".dbs",
  5038. "always.dbs",
  5039. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  5040. "Renegade Database (*.dbs)|*.dbs||",
  5041. this);
  5042. //
  5043. // Set the path, so it opens in the correct directory
  5044. //
  5045. dialog.m_ofn.lpstrInitialDir = full_path;
  5046. //
  5047. // Ask the user what file they want to save to
  5048. //
  5049. if (dialog.DoModal () == IDOK) {
  5050. TranslationExportDialogClass export_dialog (this);
  5051. export_dialog.Set_Filename (dialog.GetPathName ());
  5052. export_dialog.DoModal ();
  5053. }
  5054. return ;
  5055. }
  5056. //////////////////////////////////////////////////////////////////////////
  5057. //
  5058. // OnInitMenuPopup
  5059. //
  5060. //////////////////////////////////////////////////////////////////////////
  5061. void
  5062. CMainFrame::OnInitMenuPopup (CMenu *popup_menu, UINT nIndex, BOOL bSysMenu)
  5063. {
  5064. CFrameWnd::OnInitMenuPopup (popup_menu, nIndex, bSysMenu);
  5065. if (nIndex == CAMERA_MENU_INDEX) {
  5066. for (int index = 0; index < m_MaxCamProfiles; index ++) {
  5067. popup_menu->EnableMenuItem (IDM_FIRST_CAM_PROFILE + index, MF_BYCOMMAND | MF_ENABLED);
  5068. }
  5069. }
  5070. return ;
  5071. }
  5072. //////////////////////////////////////////////////////////////////////////
  5073. //
  5074. // OnAlwaysLocalExport
  5075. //
  5076. //////////////////////////////////////////////////////////////////////////
  5077. void
  5078. CMainFrame::OnAlwaysLocalExport (void)
  5079. {
  5080. //
  5081. // Ask the user to pick a path
  5082. //
  5083. CString path;
  5084. if (::Browse_For_Folder (path,
  5085. NULL,
  5086. NULL,
  5087. "Select a directory where the core file set will be copied.")) {
  5088. //
  5089. // Copy the always files to the specified directory
  5090. //
  5091. CWaitCursor wait_cursor;
  5092. ExporterClass exporter;
  5093. exporter.Dont_Get_Latest_Versions (true);
  5094. exporter.Export_Always_Files (path);
  5095. //
  5096. // Cache this path in the registry
  5097. //
  5098. theApp.WriteProfileString (CONFIG_KEY, LAST_EXPORT_DIR_VALUE, path);
  5099. }
  5100. return ;
  5101. }
  5102. //////////////////////////////////////////////////////////////////////////
  5103. //
  5104. // OnExportInstallerLanguageVersion
  5105. //
  5106. //////////////////////////////////////////////////////////////////////////
  5107. void
  5108. CMainFrame::OnExportInstallerLanguageVersion (void)
  5109. {
  5110. //
  5111. // Determine which directory we should use as a default for the export
  5112. //
  5113. CString full_path = theApp.GetProfileString (CONFIG_KEY, LAST_EXPORT_DIR_VALUE);
  5114. if (full_path.GetLength () == 0) {
  5115. full_path = ::Get_File_Mgr ()->Make_Full_Path (LEVELS_ASSET_DIR);
  5116. }
  5117. _pThe3DAssetManager->Set_Current_Directory (full_path);
  5118. CFileDialog dialog ( FALSE,
  5119. ".tdb",
  5120. "istrings.tdb",
  5121. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  5122. "Translation Database(*.tdb)|*.tdb||",
  5123. this);
  5124. //
  5125. // Set the path, so it opens in the correct directory
  5126. //
  5127. dialog.m_ofn.lpstrInitialDir = full_path;
  5128. //
  5129. // Ask the user what file they want to save to
  5130. //
  5131. if (dialog.DoModal () == IDOK) {
  5132. TranslationExportDialogClass export_dialog (this);
  5133. export_dialog.Set_Filename (dialog.GetPathName ());
  5134. export_dialog.Set_Is_Installer (true);
  5135. export_dialog.DoModal ();
  5136. }
  5137. return ;
  5138. }
  5139. //////////////////////////////////////////////////////////////////////////
  5140. //
  5141. // OnExtractInstallerRcStrings
  5142. //
  5143. //////////////////////////////////////////////////////////////////////////
  5144. void
  5145. CMainFrame::OnExtractInstallerRcStrings (void)
  5146. {
  5147. CFileDialog dialog ( TRUE,
  5148. ".rc",
  5149. NULL,
  5150. OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_SHAREAWARE,
  5151. "Resource Files (*.rc)|*.rc||",
  5152. this);
  5153. //
  5154. // Ask the user what file they want to extract strings from
  5155. //
  5156. if (dialog.DoModal () == IDOK) {
  5157. RCStringExtractorClass extractor;
  5158. extractor.Set_Src_RC_Filename (dialog.GetPathName ());
  5159. extractor.Set_TranslationDB_Prefix ("IDS_INSTALLER_TEXT");
  5160. extractor.Set_TranslationDB_Category ("Installer");
  5161. extractor.Extract_Strings ();
  5162. }
  5163. return ;
  5164. }
  5165. //////////////////////////////////////////////////////////////////////////
  5166. //
  5167. // OnExtractRcStrings
  5168. //
  5169. //////////////////////////////////////////////////////////////////////////
  5170. void
  5171. CMainFrame::OnExtractRcStrings (void)
  5172. {
  5173. CFileDialog dialog ( TRUE,
  5174. ".rc",
  5175. NULL,
  5176. OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_SHAREAWARE,
  5177. "Resource Files (*.rc)|*.rc||",
  5178. this);
  5179. //
  5180. // Ask the user what file they want to extract strings from
  5181. //
  5182. if (dialog.DoModal () == IDOK) {
  5183. RCStringExtractorClass extractor;
  5184. extractor.Set_Src_RC_Filename (dialog.GetPathName ());
  5185. extractor.Set_TranslationDB_Prefix ("IDS_MENU_TEXT");
  5186. extractor.Set_TranslationDB_Category ("Menu");
  5187. extractor.Extract_Strings ();
  5188. }
  5189. return ;
  5190. }
  5191. //////////////////////////////////////////////////////////////////////////
  5192. //
  5193. // OnCameraPerspective
  5194. //
  5195. //////////////////////////////////////////////////////////////////////////
  5196. void
  5197. CMainFrame::OnCameraPerspective (void)
  5198. {
  5199. ::Get_Camera_Mgr ()->Get_Camera ()->Set_Projection_Type (CameraClass::PERSPECTIVE);
  5200. return ;
  5201. }
  5202. //////////////////////////////////////////////////////////////////////////
  5203. //
  5204. // OnCameraOrthographic
  5205. //
  5206. //////////////////////////////////////////////////////////////////////////
  5207. void
  5208. CMainFrame::OnCameraOrthographic (void)
  5209. {
  5210. CameraClass *camera = ::Get_Camera_Mgr ()->Get_Camera ();
  5211. camera->Set_Projection_Type (CameraClass::ORTHO);;
  5212. Vector3 world_min;
  5213. Vector3 world_max;
  5214. PhysicsSceneClass::Get_Instance ()->Get_Level_Extents (world_min, world_max);
  5215. Vector3 delta = world_max - world_min;
  5216. float largest_dim = max (delta.X, delta.Y);
  5217. Vector3 world_center = world_min + ((world_max - world_min) * 0.5F);
  5218. world_center.Z = world_max.Z + 100.0F;
  5219. Vector2 view_min;
  5220. Vector2 view_max;
  5221. view_min.X = world_min.X - world_center.X;
  5222. view_min.Y = world_min.Y - world_center.Y;
  5223. view_max.X = world_max.X - world_center.X;
  5224. view_max.Y = world_max.Y - world_center.Y;
  5225. camera->Set_View_Plane (view_min, view_max);
  5226. camera->Set_Clip_Planes (50.0F, 5000.0F);
  5227. Matrix3D tm (1);
  5228. tm.Translate(world_center);
  5229. //tm.Scale (1 / largest_dim);
  5230. camera->Set_Transform (tm);
  5231. return ;
  5232. }
  5233. //////////////////////////////////////////////////////////////////////////
  5234. //
  5235. // OnUpdateCameraOrthographic
  5236. //
  5237. //////////////////////////////////////////////////////////////////////////
  5238. void
  5239. CMainFrame::OnUpdateCameraOrthographic (CCmdUI *pCmdUI)
  5240. {
  5241. bool is_checked = (::Get_Camera_Mgr ()->Get_Camera ()->Get_Projection_Type () == CameraClass::ORTHO);
  5242. pCmdUI->SetCheck (is_checked);
  5243. return ;
  5244. }
  5245. //////////////////////////////////////////////////////////////////////////
  5246. //
  5247. // OnUpdateCameraPerspective
  5248. //
  5249. //////////////////////////////////////////////////////////////////////////
  5250. void
  5251. CMainFrame::OnUpdateCameraPerspective (CCmdUI *pCmdUI)
  5252. {
  5253. bool is_checked = (::Get_Camera_Mgr ()->Get_Camera ()->Get_Projection_Type () == CameraClass::PERSPECTIVE);
  5254. pCmdUI->SetCheck (is_checked);
  5255. return ;
  5256. }
  5257. //////////////////////////////////////////////////////////////////////////
  5258. //
  5259. // OnModExport
  5260. //
  5261. //////////////////////////////////////////////////////////////////////////
  5262. void
  5263. CMainFrame::OnModExport (void)
  5264. {
  5265. //
  5266. // Determine which directory we should use as a default for the export
  5267. //
  5268. CString full_path = MixFileDatabaseClass::Get_Instance ()->Get_Mix_File_Path ();
  5269. _pThe3DAssetManager->Set_Current_Directory (full_path);
  5270. //
  5271. // Use the level's filename to generate a default INI filename
  5272. //
  5273. CString default_name = AssetPackageMgrClass::Get_Current_Package ();
  5274. if (default_name.GetLength () > 0) {
  5275. default_name += ".pkg";
  5276. }
  5277. CFileDialog dialog ( FALSE,
  5278. ".pkg",
  5279. default_name,
  5280. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  5281. "Renegade Mod Package (*.pkg)|*.pkg||",
  5282. this);
  5283. //
  5284. // Set the path, so it opens in the correct directory
  5285. //
  5286. dialog.m_ofn.lpstrInitialDir = full_path;
  5287. //
  5288. // Ask the user where they want to save this package
  5289. //
  5290. if (dialog.DoModal () == IDOK) {
  5291. ExporterClass exporter;
  5292. exporter.Export_Package (dialog.GetPathName ());
  5293. }
  5294. return ;
  5295. }
  5296. //////////////////////////////////////////////////////////////////////////
  5297. //
  5298. // OnSaveLevel
  5299. //
  5300. //////////////////////////////////////////////////////////////////////////
  5301. void
  5302. CMainFrame::OnSaveLevel (void)
  5303. {
  5304. //
  5305. // Determine which directory we should save to
  5306. //
  5307. CString full_path = ::Get_File_Mgr ()->Make_Full_Path (LEVELS_ASSET_DIR);
  5308. _pThe3DAssetManager->Set_Current_Directory (full_path);
  5309. //
  5310. // Make a default filename from the name of the document
  5311. //
  5312. CString default_name = GetActiveDocument ()->GetTitle ();
  5313. if (default_name.GetLength () > 0) {
  5314. default_name += ".lvl";
  5315. }
  5316. CFileDialog dialog ( TRUE,
  5317. ".lvl",
  5318. default_name,
  5319. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  5320. "Level Editor Files (*.lvl)|*.lvl||",
  5321. this);
  5322. //
  5323. // Set the path, so it opens in the correct directory
  5324. //
  5325. dialog.m_ofn.lpstrInitialDir = full_path;
  5326. //
  5327. // Ask the user where they want to save this level
  5328. //
  5329. if (dialog.DoModal () == IDOK) {
  5330. //
  5331. // Save in level editor format
  5332. //
  5333. GetActiveDocument ()->OnSaveDocument (dialog.GetPathName ());
  5334. //
  5335. // Save in game format
  5336. //
  5337. ExporterClass exporter;
  5338. exporter.Export_Level_Only (dialog.GetPathName ());
  5339. }
  5340. return ;
  5341. }
  5342. void CMainFrame::OnComputeVertexSolve()
  5343. {
  5344. LightSolveOptionsDialogClass dialog(this);
  5345. if (dialog.DoModal() == IDOK) {
  5346. SceneEditorClass *scene = ::Get_Scene_Editor ();
  5347. if (scene != NULL) {
  5348. scene->Update_Lighting();
  5349. }
  5350. }
  5351. }
  5352. //////////////////////////////////////////////////////////////////////////
  5353. //
  5354. // OnModeHeightEdit
  5355. //
  5356. //////////////////////////////////////////////////////////////////////////
  5357. void
  5358. CMainFrame::OnModeHeightEdit (void)
  5359. {
  5360. ::Get_Mouse_Mgr ()->Set_Mouse_Mode (MouseMgrClass::MODE_HEIGHTFIELD_EDIT);
  5361. return ;
  5362. }
  5363. //////////////////////////////////////////////////////////////////////////
  5364. //
  5365. // OnUpdateModeHeightEdit
  5366. //
  5367. //////////////////////////////////////////////////////////////////////////
  5368. void
  5369. CMainFrame::OnUpdateModeHeightEdit (CCmdUI *pCmdUI)
  5370. {
  5371. MouseMgrClass *mouse_mgr = ::Get_Mouse_Mgr ();
  5372. //
  5373. // Update the toolbar
  5374. //
  5375. if (mouse_mgr != NULL) {
  5376. pCmdUI->SetCheck ((BOOL)::Get_Mouse_Mgr ()->Get_Mouse_Mode () == MouseMgrClass::MODE_HEIGHTFIELD_EDIT);
  5377. }
  5378. return ;
  5379. }