MainFrm.cpp 143 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1999-2005 Id Software, Inc.
  4. This file is part of Quake III Arena source code.
  5. Quake III Arena source code is free software; you can redistribute it
  6. and/or modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of the License,
  8. or (at your option) any later version.
  9. Quake III Arena source code is distributed in the hope that it will be
  10. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Foobar; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. ===========================================================================
  17. */
  18. // MainFrm.cpp : implementation of the CMainFrame class
  19. //
  20. #include "stdafx.h"
  21. #include "Radiant.h"
  22. #include "qe3.h"
  23. #include "ZWnd.h"
  24. #include "CamWnd.h"
  25. #include "TexWnd.h"
  26. #include "EditWnd.h"
  27. #include "entityw.h"
  28. #include "PrefsDlg.h"
  29. #include "MapInfo.h"
  30. #include "MainFrm.h"
  31. #include "RotateDlg.h"
  32. #include "EntityListDlg.h"
  33. #include "ScriptDlg.h"
  34. #include "NewProjDlg.h"
  35. #include "CommandsDlg.h"
  36. #include "ScaleDialog.h"
  37. #include "FindTextureDlg.h"
  38. #include "SurfaceDlg.h"
  39. #include "shlobj.h"
  40. #include "DialogTextures.h"
  41. #include "PatchDensityDlg.h"
  42. #include "DialogThick.h"
  43. #include "PatchDialog.h"
  44. #include "Undo.h"
  45. #include "NameDlg.h"
  46. #include "../libs/pakstuff.h"
  47. #include "splines/splines.h"
  48. #include "dlgcamera.h"
  49. #ifdef _DEBUG
  50. #define new DEBUG_NEW
  51. #undef THIS_FILE
  52. static char THIS_FILE[] = __FILE__;
  53. #endif
  54. // globals
  55. CString g_strAppPath; // holds the full path of the executable
  56. CEdit* g_pEdit = NULL; // used originally to make qe4 work with mfc.. still used
  57. CMainFrame* g_pParentWnd = NULL; // used to precast to CMainFrame
  58. CPrefsDlg g_Preferences; // global prefs instance
  59. CPrefsDlg& g_PrefsDlg = g_Preferences; // reference used throughout
  60. int g_nUpdateBits = 0; // window update flags
  61. bool g_bScreenUpdates = true; // whether window painting is active, used in a few places
  62. // to disable updates for speed reasons
  63. // both of the above should be made members of CMainFrame
  64. //bool g_bSnapToGrid = true; // early use, no longer in use, clamping pref will be used
  65. CString g_strProject; // holds the active project filename
  66. /////////////////////////////////////////////////////////////////////////////
  67. // CMainFrame
  68. // command mapping stuff
  69. //
  70. // m_strCommand is the command string
  71. // m_nKey is the windows VK_??? equivelant
  72. // m_nModifiers are key states as follows
  73. // bit
  74. // 0 - shift
  75. // 1 - alt
  76. // 2 - control
  77. // 4 - press only
  78. //
  79. #define SPEED_MOVE 32
  80. #define SPEED_TURN 22.5
  81. SCommandInfo g_Commands[] =
  82. {
  83. {"ToggleOutlineDraw", 'J', 0x00, ID_SELECTION_NOOUTLINE},
  84. {"CSGMerge", 'U', 0x04, ID_SELECTION_CSGMERGE},
  85. {"CSGSubtract", 'U', 0x01, ID_SELECTION_CSGSUBTRACT},
  86. {"ViewGroups", 'G', 0x00, ID_VIEW_GROUPS},
  87. {"HideSelected", 'H', 0x00, ID_VIEW_HIDESHOW_HIDESELECTED},
  88. {"ShowHidden", 'H', 0x01, ID_VIEW_HIDESHOW_SHOWHIDDEN},
  89. {"BendMode", 'B', 0x00, ID_PATCH_BEND},
  90. {"FitFace", 'B', 0x04, ID_FITFACE},
  91. {"FitBrush", 'B', 0x01, ID_FITBRUSH},
  92. {"FreezePatchVertices", 'F', 0x00, ID_CURVE_FREEZE},
  93. {"UnFreezePatchVertices", 'F', 0x04, ID_CURVE_UNFREEZE},
  94. {"UnFreezeAllPatchVertices", 'F', 0x05, ID_CURVE_UNFREEZEALL},
  95. {"ViewTextures", 'T', 0, ID_VIEW_TEXTURE},
  96. {"ThickenPatch", 'T', 0x04, ID_CURVE_THICKEN},
  97. {"MakeOverlayPatch", 'Y', 0, ID_CURVE_OVERLAY_SET},
  98. {"ClearPatchOverlays", 'Y', 0x02, ID_CURVE_OVERLAY_CLEAR},
  99. {"SurfaceInspector", 'S', 0, ID_TEXTURES_INSPECTOR},
  100. {"PatchInspector", 'S', 0x01, ID_PATCH_INSPECTOR},
  101. {"ToggleShowPatches", 'P', 0x05, ID_CURVE_CYCLECAP},
  102. {"ToggleShowPatches", 'P', 0x04, ID_VIEW_SHOWCURVES},
  103. {"RedisperseRows", 'E', 0x04, ID_CURVE_REDISPERSE_ROWS},
  104. {"RedisperseCols", 'E', 0x05, ID_CURVE_REDISPERSE_COLS},
  105. {"InvertCurveTextureX", 'I', 0x05, ID_CURVE_NEGATIVETEXTUREY},
  106. {"InvertCurveTextureY", 'I', 0x01, ID_CURVE_NEGATIVETEXTUREX},
  107. {"InvertCurve", 'I', 0x04, ID_CURVE_NEGATIVE},
  108. {"IncPatchColumn", VK_ADD, 0x05, ID_CURVE_INSERTCOLUMN},
  109. {"IncPatchRow", VK_ADD, 0x04, ID_CURVE_INSERTROW},
  110. {"DecPatchColumn", VK_SUBTRACT, 0x05, ID_CURVE_DELETECOLUMN},
  111. {"DecPatchRow", VK_SUBTRACT, 0x04, ID_CURVE_DELETEROW},
  112. {"Patch TAB", VK_TAB, 0x00, ID_PATCH_TAB},
  113. {"Patch TAB", VK_TAB, 0x01, ID_PATCH_TAB},
  114. {"SelectNudgeDown", VK_DOWN, 0x02, ID_SELECTION_SELECT_NUDGEDOWN},
  115. {"EntityColor",'K', 0, ID_MISC_SELECTENTITYCOLOR},
  116. {"CameraForward", VK_UP, 0, ID_CAMERA_FORWARD},
  117. {"CameraBack", VK_DOWN, 0, ID_CAMERA_BACK},
  118. {"CameraLeft", VK_LEFT, 0, ID_CAMERA_LEFT},
  119. {"CameraRight", VK_RIGHT, 0, ID_CAMERA_RIGHT},
  120. {"CameraUp", 'D', 0, ID_CAMERA_UP},
  121. {"CameraDown", 'C', 0, ID_CAMERA_DOWN},
  122. {"CameraAngleUp", 'A', 0, ID_CAMERA_ANGLEUP},
  123. {"CameraAngleDown", 'Z', 0, ID_CAMERA_ANGLEDOWN},
  124. {"CameraStrafeRight", VK_PERIOD, 0, ID_CAMERA_STRAFERIGHT},
  125. {"CameraStrafeLeft", VK_COMMA, 0, ID_CAMERA_STRAFELEFT},
  126. {"ToggleGrid", '0', 0, ID_GRID_TOGGLE},
  127. {"SetGrid1", '1', 0, ID_GRID_1},
  128. {"SetGrid2", '2', 0, ID_GRID_2},
  129. {"SetGrid4", '3', 0, ID_GRID_4},
  130. {"SetGrid8", '4', 0, ID_GRID_8},
  131. {"SetGrid16", '5', 0, ID_GRID_16},
  132. {"SetGrid32", '6', 0, ID_GRID_32},
  133. {"SetGrid64", '7', 0, ID_GRID_64},
  134. {"DragEdges", 'E', 0, ID_SELECTION_DRAGEDGES},
  135. {"DragVertices", 'V', 0, ID_SELECTION_DRAGVERTECIES},
  136. {"ViewEntityInfo", 'N', 0, ID_VIEW_ENTITY},
  137. {"ViewConsole", 'O', 0, ID_VIEW_CONSOLE},
  138. {"CloneSelection", VK_SPACE, 0, ID_SELECTION_CLONE},
  139. {"DeleteSelection", VK_BACK, 0, ID_SELECTION_DELETE},
  140. {"UnSelectSelection", VK_ESCAPE, 0, ID_SELECTION_DESELECT},
  141. {"CenterView", VK_END, 0, ID_VIEW_CENTER},
  142. {"ZoomOut", VK_INSERT, 0, ID_VIEW_ZOOMOUT},
  143. {"ZoomIn", VK_DELETE, 0, ID_VIEW_ZOOMIN},
  144. {"UpFloor", VK_PRIOR, 0, ID_VIEW_UPFLOOR},
  145. {"DownFloor", VK_NEXT, 0, ID_VIEW_DOWNFLOOR},
  146. {"ToggleClipper", 'X', 0, ID_VIEW_CLIPPER},
  147. {"ToggleCrosshairs", 'X', 0x01, ID_VIEW_CROSSHAIR},
  148. {"TogTexLock", 'T', 0x01, ID_TOGGLE_LOCK},
  149. {"TogTexRotLock", 'R', 0x01, ID_TOGGLE_ROTATELOCK},
  150. {"ToggleRealtime", 'R', 0x04, ID_VIEW_CAMERAUPDATE},
  151. {"RaiseLowerTerrain", 'T', 0x06, ID_TERRAIN_RAISELOWERTERRAIN},
  152. {"EntityList", 'L', 0, ID_EDIT_ENTITYINFO},
  153. {"Preferences", 'P', 0, ID_PREFS},
  154. {"ToggleCamera", 'C', 0x05, ID_TOGGLECAMERA},
  155. {"ToggleConsole", 'O', 0, ID_TOGGLECONSOLE},
  156. {"ToggleView", 'V', 0x05, ID_TOGGLEVIEW},
  157. {"ToggleZ", 'Z', 0x05, ID_TOGGLEZ},
  158. {"ConnectSelection", 'K', 0x04, ID_SELECTION_CONNECT},
  159. {"Brush3Sided", '3', 0x04, ID_BRUSH_3SIDED},
  160. {"Brush4Sided", '4', 0x04, ID_BRUSH_4SIDED},
  161. {"Brush5Sided", '5', 0x04, ID_BRUSH_5SIDED},
  162. {"Brush6Sided", '6', 0x04, ID_BRUSH_6SIDED},
  163. {"Brush7Sided", '7', 0x04, ID_BRUSH_7SIDED},
  164. {"Brush8Sided", '8', 0x04, ID_BRUSH_8SIDED},
  165. {"Brush9Sided", '9', 0x04, ID_BRUSH_9SIDED},
  166. {"ShowDetail", 'D', 0x04, ID_VIEW_SHOWDETAIL},
  167. {"MakeDetail", 'M', 0x05, ID_CURVE_MATRIX_TRANSPOSE},
  168. {"MakeDetail", 'M', 0x04, ID_SELECTION_MAKE_DETAIL},
  169. {"MapInfo", 'M', 0, ID_EDIT_MAPINFO},
  170. {"NextLeakSpot", 'K', 0x05, ID_MISC_NEXTLEAKSPOT},
  171. {"PrevLeakSpot", 'L', 0x05, ID_MISC_PREVIOUSLEAKSPOT},
  172. {"FileOpen", 'O', 0x04, ID_FILE_OPEN},
  173. {"FileSave", 'S', 0x04, ID_FILE_SAVE},
  174. {"Exit", 'X', 0x04, ID_FILE_EXIT},
  175. {"NextView", VK_TAB, 0x04, ID_VIEW_NEXTVIEW},
  176. {"ClipSelected", VK_RETURN, 0x00, ID_CLIP_SELECTED},
  177. {"SplitSelected", VK_RETURN, 0x01, ID_SPLIT_SELECTED},
  178. {"FlipClip", VK_RETURN, 0x04, ID_FLIP_CLIP},
  179. {"MouseRotate", 'R', 0x00, ID_SELECT_MOUSEROTATE},
  180. {"Copy", 'C', 0x04, ID_EDIT_COPYBRUSH},
  181. {"Paste", 'V', 0x04, ID_EDIT_PASTEBRUSH},
  182. {"Undo", 'Z', 0x04, ID_EDIT_UNDO},
  183. {"Redo", 'Y', 0x04, ID_EDIT_REDO},
  184. {"ZZoomOut", VK_INSERT, 0x04, ID_VIEW_ZZOOMOUT},
  185. {"ZZoomIn", VK_DELETE, 0x04, ID_VIEW_ZZOOMIN},
  186. {"TexDecrement", VK_SUBTRACT, 0x01, ID_SELECTION_TEXTURE_DEC},
  187. {"TexIncrement", VK_ADD, 0x01, ID_SELECTION_TEXTURE_INC},
  188. {"TextureFit", '5', 0x01, ID_SELECTION_TEXTURE_FIT},
  189. {"TexRotateClock", VK_NEXT, 0x01, ID_SELECTION_TEXTURE_ROTATECLOCK},
  190. {"TexRotateCounter", VK_PRIOR, 0x01, ID_SELECTION_TEXTURE_ROTATECOUNTER},
  191. {"TexScaleUp", VK_UP, 0x04, ID_SELECTION_TEXTURE_SCALEUP},
  192. {"TexScaleDown", VK_DOWN, 0x04, ID_SELECTION_TEXTURE_SCALEDOWN},
  193. {"TexShiftLeft", VK_LEFT, 0x01, ID_SELECTION_TEXTURE_SHIFTLEFT},
  194. {"TexShiftRight", VK_RIGHT, 0x01, ID_SELECTION_TEXTURE_SHIFTRIGHT},
  195. {"TexShiftUp", VK_UP, 0x01, ID_SELECTION_TEXTURE_SHIFTUP},
  196. {"TexShiftDown", VK_DOWN, 0x01, ID_SELECTION_TEXTURE_SHIFTDOWN},
  197. {"GridDown", 219, 0x00, ID_GRID_PREV},
  198. {"GridUp", 221, 0x00, ID_GRID_NEXT},
  199. {"TexScaleLeft", VK_LEFT, 0x04, ID_SELECTION_TEXTURE_SCALELEFT},
  200. {"TexScaleRight", VK_RIGHT, 0x04, ID_SELECTION_TEXTURE_SCALERIGHT},
  201. {"CubicClipZoomOut", 219, 0x04, ID_VIEW_CUBEOUT},
  202. {"CubicClipZoomIn", 221, 0x04, ID_VIEW_CUBEIN},
  203. {"ToggleCubicClip", 220, 0x04, ID_VIEW_CUBICCLIPPING},
  204. // {"ToggleCubicClip", '\\', 0x04, ID_VIEW_CUBICCLIPPING},
  205. {"MoveSelectionDOWN", VK_SUBTRACT, 0x00, ID_SELECTION_MOVEDOWN},
  206. {"MoveSelectionUP", VK_ADD, 0x00, ID_SELECTION_MOVEUP},
  207. {"DumpSelectedBrush", 'D', 0x01, ID_SELECTION_PRINT},
  208. {"ToggleSizePaint", 'Q', 0x08, ID_SELECTION_TOGGLESIZEPAINT},
  209. {"SelectNudgeLeft", VK_LEFT, 0x02, ID_SELECTION_SELECT_NUDGELEFT},
  210. {"SelectNudgeRight", VK_RIGHT, 0x02, ID_SELECTION_SELECT_NUDGERIGHT},
  211. {"SelectNudgeUp", VK_UP, 0x02, ID_SELECTION_SELECT_NUDGEUP},
  212. {"CycleCapTexturePatch", 'N', 0x05, ID_CURVE_CYCLECAP},
  213. {"NaturalizePatch", 'N', 0x04, ID_PATCH_NATURALIZE},
  214. {"SnapPatchToGrid", 'G', 0x04, ID_SELECT_SNAPTOGRID},
  215. {"ShowAllTextures", 'A', 0x04, ID_TEXTURES_SHOWALL},
  216. {"SelectAllOfType", 'A', 0x01, ID_SELECT_ALL},
  217. {"CapCurrentCurve", 'C', 0x01, ID_CURVE_CAP},
  218. {"MakeStructural", 'S', 0x05, ID_SELECTION_MAKE_STRUCTURAL}
  219. //{"ForceCameraWalk", 'Q', 0x08, ID_CAMERA_ACTIVE}
  220. };
  221. int g_nCommandCount = sizeof(g_Commands) / sizeof(SCommandInfo);
  222. SKeyInfo g_Keys[] =
  223. {
  224. {"Space", VK_SPACE},
  225. {"Backspace", VK_BACK},
  226. {"Escape", VK_ESCAPE},
  227. {"End", VK_END},
  228. {"Insert", VK_INSERT},
  229. {"Delete", VK_DELETE},
  230. {"PageUp", VK_PRIOR},
  231. {"PageDown", VK_NEXT},
  232. {"Up", VK_UP},
  233. {"Down", VK_DOWN},
  234. {"Left", VK_LEFT},
  235. {"Right", VK_RIGHT},
  236. {"F1", VK_F1},
  237. {"F2", VK_F2},
  238. {"F3", VK_F3},
  239. {"F4", VK_F4},
  240. {"F5", VK_F5},
  241. {"F6", VK_F6},
  242. {"F7", VK_F7},
  243. {"F8", VK_F8},
  244. {"F9", VK_F9},
  245. {"F10", VK_F10},
  246. {"F11", VK_F11},
  247. {"F12", VK_F12},
  248. {"Tab", VK_TAB},
  249. {"Return", VK_RETURN},
  250. {"Comma", VK_COMMA},
  251. {"Period", VK_PERIOD},
  252. {"Plus", VK_ADD},
  253. {"Multiply", VK_MULTIPLY},
  254. {"Subtract", VK_SUBTRACT},
  255. {"NumPad0", VK_NUMPAD0},
  256. {"NumPad1", VK_NUMPAD1},
  257. {"NumPad2", VK_NUMPAD2},
  258. {"NumPad3", VK_NUMPAD3},
  259. {"NumPad4", VK_NUMPAD4},
  260. {"NumPad5", VK_NUMPAD5},
  261. {"NumPad6", VK_NUMPAD6},
  262. {"NumPad7", VK_NUMPAD7},
  263. {"NumPad8", VK_NUMPAD8},
  264. {"NumPad9", VK_NUMPAD9},
  265. {"[", 219},
  266. {"]", 221},
  267. {"\\", 220}
  268. };
  269. int g_nKeyCount = sizeof(g_Keys) / sizeof(SKeyInfo);
  270. const int CMD_TEXTUREWAD_END = CMD_TEXTUREWAD + 127;
  271. const int CMD_BSPCOMMAND_END = CMD_BSPCOMMAND + 127;
  272. const int IDMRU_END = IDMRU+9;
  273. const int g_msgBSPDone = RegisterWindowMessage("_BSPDone");
  274. const int g_msgBSPStatus = RegisterWindowMessage("_BSPStatus");
  275. IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd)
  276. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  277. //{{AFX_MSG_MAP(CMainFrame)
  278. ON_WM_PARENTNOTIFY()
  279. ON_WM_CREATE()
  280. ON_WM_TIMER()
  281. ON_WM_DESTROY()
  282. ON_WM_CLOSE()
  283. ON_WM_KEYDOWN()
  284. ON_WM_SIZE()
  285. ON_COMMAND(ID_VIEW_CAMERATOGGLE, ToggleCamera)
  286. ON_COMMAND(ID_FILE_CLOSE, OnFileClose)
  287. ON_COMMAND(ID_FILE_EXIT, OnFileExit)
  288. ON_COMMAND(ID_FILE_LOADPROJECT, OnFileLoadproject)
  289. ON_COMMAND(ID_FILE_NEW, OnFileNew)
  290. ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  291. ON_COMMAND(ID_FILE_POINTFILE, OnFilePointfile)
  292. ON_COMMAND(ID_FILE_PRINT, OnFilePrint)
  293. ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview)
  294. ON_COMMAND(ID_FILE_SAVE, OnFileSave)
  295. ON_COMMAND(ID_FILE_SAVEAS, OnFileSaveas)
  296. ON_COMMAND(ID_VIEW_100, OnView100)
  297. ON_COMMAND(ID_VIEW_CENTER, OnViewCenter)
  298. ON_COMMAND(ID_VIEW_CONSOLE, OnViewConsole)
  299. ON_COMMAND(ID_VIEW_DOWNFLOOR, OnViewDownfloor)
  300. ON_COMMAND(ID_VIEW_ENTITY, OnViewEntity)
  301. ON_COMMAND(ID_VIEW_FRONT, OnViewFront)
  302. ON_COMMAND(ID_VIEW_SHOWBLOCKS, OnViewShowblocks)
  303. ON_COMMAND(ID_VIEW_SHOWCLIP, OnViewShowclip)
  304. ON_COMMAND(ID_VIEW_SHOWCOORDINATES, OnViewShowcoordinates)
  305. ON_COMMAND(ID_VIEW_SHOWDETAIL, OnViewShowdetail)
  306. ON_COMMAND(ID_VIEW_SHOWENT, OnViewShowent)
  307. ON_COMMAND(ID_VIEW_SHOWLIGHTS, OnViewShowlights)
  308. ON_COMMAND(ID_VIEW_SHOWNAMES, OnViewShownames)
  309. ON_COMMAND(ID_VIEW_SHOWPATH, OnViewShowpath)
  310. ON_COMMAND(ID_VIEW_SHOWWATER, OnViewShowwater)
  311. ON_COMMAND(ID_VIEW_SHOWWORLD, OnViewShowworld)
  312. ON_COMMAND(ID_VIEW_TEXTURE, OnViewTexture)
  313. ON_COMMAND(ID_VIEW_UPFLOOR, OnViewUpfloor)
  314. ON_COMMAND(ID_VIEW_XY, OnViewXy)
  315. ON_COMMAND(ID_VIEW_Z100, OnViewZ100)
  316. ON_COMMAND(ID_VIEW_ZOOMIN, OnViewZoomin)
  317. ON_COMMAND(ID_VIEW_ZOOMOUT, OnViewZoomout)
  318. ON_COMMAND(ID_VIEW_ZZOOMIN, OnViewZzoomin)
  319. ON_COMMAND(ID_VIEW_ZZOOMOUT, OnViewZzoomout)
  320. ON_COMMAND(ID_VIEW_SIDE, OnViewSide)
  321. ON_COMMAND(ID_TEXTURES_SHOWINUSE, OnTexturesShowinuse)
  322. ON_COMMAND(ID_TEXTURES_INSPECTOR, OnTexturesInspector)
  323. ON_COMMAND(ID_MISC_BENCHMARK, OnMiscBenchmark)
  324. ON_COMMAND(ID_MISC_FINDBRUSH, OnMiscFindbrush)
  325. ON_COMMAND(ID_MISC_GAMMA, OnMiscGamma)
  326. ON_COMMAND(ID_MISC_NEXTLEAKSPOT, OnMiscNextleakspot)
  327. ON_COMMAND(ID_MISC_PREVIOUSLEAKSPOT, OnMiscPreviousleakspot)
  328. ON_COMMAND(ID_MISC_PRINTXY, OnMiscPrintxy)
  329. ON_COMMAND(ID_MISC_SELECTENTITYCOLOR, OnMiscSelectentitycolor)
  330. ON_COMMAND(ID_TEXTUREBK, OnTexturebk)
  331. ON_COMMAND(ID_COLORS_MAJOR, OnColorsMajor)
  332. ON_COMMAND(ID_COLORS_MINOR, OnColorsMinor)
  333. ON_COMMAND(ID_COLORS_XYBK, OnColorsXybk)
  334. ON_COMMAND(ID_BRUSH_3SIDED, OnBrush3sided)
  335. ON_COMMAND(ID_BRUSH_4SIDED, OnBrush4sided)
  336. ON_COMMAND(ID_BRUSH_5SIDED, OnBrush5sided)
  337. ON_COMMAND(ID_BRUSH_6SIDED, OnBrush6sided)
  338. ON_COMMAND(ID_BRUSH_7SIDED, OnBrush7sided)
  339. ON_COMMAND(ID_BRUSH_8SIDED, OnBrush8sided)
  340. ON_COMMAND(ID_BRUSH_9SIDED, OnBrush9sided)
  341. ON_COMMAND(ID_BRUSH_ARBITRARYSIDED, OnBrushArbitrarysided)
  342. ON_COMMAND(ID_BRUSH_FLIPX, OnBrushFlipx)
  343. ON_COMMAND(ID_BRUSH_FLIPY, OnBrushFlipy)
  344. ON_COMMAND(ID_BRUSH_FLIPZ, OnBrushFlipz)
  345. ON_COMMAND(ID_BRUSH_ROTATEX, OnBrushRotatex)
  346. ON_COMMAND(ID_BRUSH_ROTATEY, OnBrushRotatey)
  347. ON_COMMAND(ID_BRUSH_ROTATEZ, OnBrushRotatez)
  348. ON_COMMAND(ID_REGION_OFF, OnRegionOff)
  349. ON_COMMAND(ID_REGION_SETBRUSH, OnRegionSetbrush)
  350. ON_COMMAND(ID_REGION_SETSELECTION, OnRegionSetselection)
  351. ON_COMMAND(ID_REGION_SETTALLBRUSH, OnRegionSettallbrush)
  352. ON_COMMAND(ID_REGION_SETXY, OnRegionSetxy)
  353. ON_COMMAND(ID_SELECTION_ARBITRARYROTATION, OnSelectionArbitraryrotation)
  354. ON_COMMAND(ID_SELECTION_CLONE, OnSelectionClone)
  355. ON_COMMAND(ID_SELECTION_CONNECT, OnSelectionConnect)
  356. ON_COMMAND(ID_SELECTION_CSGSUBTRACT, OnSelectionCsgsubtract)
  357. ON_COMMAND(ID_SELECTION_CSGMERGE, OnSelectionCsgmerge)
  358. ON_COMMAND(ID_SELECTION_NOOUTLINE, OnSelectionNoOutline)
  359. ON_COMMAND(ID_SELECTION_DELETE, OnSelectionDelete)
  360. ON_COMMAND(ID_SELECTION_DESELECT, OnSelectionDeselect)
  361. ON_COMMAND(ID_SELECTION_DRAGEDGES, OnSelectionDragedges)
  362. ON_COMMAND(ID_SELECTION_DRAGVERTECIES, OnSelectionDragvertecies)
  363. ON_COMMAND(ID_SELECTION_MAKE_DETAIL, OnSelectionMakeDetail)
  364. ON_COMMAND(ID_SELECTION_MAKE_STRUCTURAL, OnSelectionMakeStructural)
  365. ON_COMMAND(ID_SELECTION_MAKEHOLLOW, OnSelectionMakehollow)
  366. ON_COMMAND(ID_SELECTION_SELECTCOMPLETETALL, OnSelectionSelectcompletetall)
  367. ON_COMMAND(ID_SELECTION_SELECTINSIDE, OnSelectionSelectinside)
  368. ON_COMMAND(ID_SELECTION_SELECTPARTIALTALL, OnSelectionSelectpartialtall)
  369. ON_COMMAND(ID_SELECTION_SELECTTOUCHING, OnSelectionSelecttouching)
  370. ON_COMMAND(ID_SELECTION_UNGROUPENTITY, OnSelectionUngroupentity)
  371. ON_COMMAND(ID_TEXTURES_POPUP, OnTexturesPopup)
  372. ON_COMMAND(ID_SPLINES_POPUP, OnSplinesPopup)
  373. ON_COMMAND(ID_POPUP_SELECTION, OnPopupSelection)
  374. ON_COMMAND(ID_VIEW_CHANGE, OnViewChange)
  375. ON_COMMAND(ID_VIEW_CAMERAUPDATE, OnViewCameraupdate)
  376. ON_COMMAND(ID_TERRAIN_RAISELOWERTERRAIN, OnRaiseLowerTerrain)
  377. ON_UPDATE_COMMAND_UI(ID_VIEW_CAMERAUPDATE, OnUpdateViewCameraupdate)
  378. ON_WM_SIZING()
  379. ON_COMMAND(ID_HELP_ABOUT, OnHelpAbout)
  380. ON_COMMAND(ID_VIEW_CLIPPER, OnViewClipper)
  381. ON_COMMAND(ID_CAMERA_ANGLEDOWN, OnCameraAngledown)
  382. ON_COMMAND(ID_CAMERA_ANGLEUP, OnCameraAngleup)
  383. ON_COMMAND(ID_CAMERA_BACK, OnCameraBack)
  384. ON_COMMAND(ID_CAMERA_DOWN, OnCameraDown)
  385. ON_COMMAND(ID_CAMERA_FORWARD, OnCameraForward)
  386. ON_COMMAND(ID_CAMERA_LEFT, OnCameraLeft)
  387. ON_COMMAND(ID_CAMERA_RIGHT, OnCameraRight)
  388. ON_COMMAND(ID_CAMERA_STRAFELEFT, OnCameraStrafeleft)
  389. ON_COMMAND(ID_CAMERA_STRAFERIGHT, OnCameraStraferight)
  390. ON_COMMAND(ID_CAMERA_UP, OnCameraUp)
  391. ON_COMMAND(ID_GRID_TOGGLE, OnGridToggle)
  392. ON_COMMAND(ID_PREFS, OnPrefs)
  393. ON_COMMAND(ID_TOGGLECAMERA, OnTogglecamera)
  394. ON_COMMAND(ID_TOGGLECONSOLE, OnToggleconsole)
  395. ON_COMMAND(ID_TOGGLEVIEW, OnToggleview)
  396. ON_COMMAND(ID_TOGGLEZ, OnTogglez)
  397. ON_COMMAND(ID_TOGGLE_LOCK, OnToggleLock)
  398. ON_COMMAND(ID_EDIT_MAPINFO, OnEditMapinfo)
  399. ON_COMMAND(ID_EDIT_ENTITYINFO, OnEditEntityinfo)
  400. ON_COMMAND(ID_BRUSH_SCRIPTS, OnBrushScripts)
  401. ON_COMMAND(ID_VIEW_NEXTVIEW, OnViewNextview)
  402. ON_COMMAND(ID_HELP_COMMANDLIST, OnHelpCommandlist)
  403. ON_COMMAND(ID_FILE_NEWPROJECT, OnFileNewproject)
  404. ON_COMMAND(ID_FLIP_CLIP, OnFlipClip)
  405. ON_COMMAND(ID_CLIP_SELECTED, OnClipSelected)
  406. ON_COMMAND(ID_SPLIT_SELECTED, OnSplitSelected)
  407. ON_COMMAND(ID_TOGGLEVIEW_XZ, OnToggleviewXz)
  408. ON_COMMAND(ID_TOGGLEVIEW_YZ, OnToggleviewYz)
  409. ON_COMMAND(ID_COLORS_BRUSH, OnColorsBrush)
  410. ON_COMMAND(ID_COLORS_CLIPPER, OnColorsClipper)
  411. ON_COMMAND(ID_COLORS_GRIDTEXT, OnColorsGridtext)
  412. ON_COMMAND(ID_COLORS_SELECTEDBRUSH, OnColorsSelectedbrush)
  413. ON_COMMAND(ID_COLORS_GRIDBLOCK, OnColorsGridblock)
  414. ON_COMMAND(ID_COLORS_VIEWNAME, OnColorsViewname)
  415. ON_COMMAND(ID_COLOR_SETORIGINAL, OnColorSetoriginal)
  416. ON_COMMAND(ID_COLOR_SETQER, OnColorSetqer)
  417. ON_COMMAND(ID_COLOR_SETBLACK, OnColorSetblack)
  418. ON_COMMAND(ID_SNAPTOGRID, OnSnaptogrid)
  419. ON_COMMAND(ID_SELECT_SCALE, OnSelectScale)
  420. ON_COMMAND(ID_SELECT_MOUSEROTATE, OnSelectMouserotate)
  421. ON_COMMAND(ID_EDIT_COPYBRUSH, OnEditCopybrush)
  422. ON_COMMAND(ID_EDIT_PASTEBRUSH, OnEditPastebrush)
  423. ON_COMMAND(ID_EDIT_UNDO, OnEditUndo)
  424. ON_COMMAND(ID_EDIT_REDO, OnEditRedo)
  425. ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo)
  426. ON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateEditRedo)
  427. ON_COMMAND(ID_SELECTION_INVERT, OnSelectionInvert)
  428. ON_COMMAND(ID_SELECTION_TEXTURE_DEC, OnSelectionTextureDec)
  429. ON_COMMAND(ID_SELECTION_TEXTURE_FIT, OnSelectionTextureFit)
  430. ON_COMMAND(ID_SELECTION_TEXTURE_INC, OnSelectionTextureInc)
  431. ON_COMMAND(ID_SELECTION_TEXTURE_ROTATECLOCK, OnSelectionTextureRotateclock)
  432. ON_COMMAND(ID_SELECTION_TEXTURE_ROTATECOUNTER, OnSelectionTextureRotatecounter)
  433. ON_COMMAND(ID_SELECTION_TEXTURE_SCALEDOWN, OnSelectionTextureScaledown)
  434. ON_COMMAND(ID_SELECTION_TEXTURE_SCALEUP, OnSelectionTextureScaleup)
  435. ON_COMMAND(ID_SELECTION_TEXTURE_SHIFTDOWN, OnSelectionTextureShiftdown)
  436. ON_COMMAND(ID_SELECTION_TEXTURE_SHIFTLEFT, OnSelectionTextureShiftleft)
  437. ON_COMMAND(ID_SELECTION_TEXTURE_SHIFTRIGHT, OnSelectionTextureShiftright)
  438. ON_COMMAND(ID_SELECTION_TEXTURE_SHIFTUP, OnSelectionTextureShiftup)
  439. ON_COMMAND(ID_GRID_NEXT, OnGridNext)
  440. ON_COMMAND(ID_GRID_PREV, OnGridPrev)
  441. ON_COMMAND(ID_SELECTION_TEXTURE_SCALELEFT, OnSelectionTextureScaleLeft)
  442. ON_COMMAND(ID_SELECTION_TEXTURE_SCALERIGHT, OnSelectionTextureScaleRight)
  443. ON_COMMAND(ID_TEXTURE_REPLACEALL, OnTextureReplaceall)
  444. ON_COMMAND(ID_SCALELOCKX, OnScalelockx)
  445. ON_COMMAND(ID_SCALELOCKY, OnScalelocky)
  446. ON_COMMAND(ID_SCALELOCKZ, OnScalelockz)
  447. ON_COMMAND(ID_SELECT_MOUSESCALE, OnSelectMousescale)
  448. ON_COMMAND(ID_VIEW_CUBICCLIPPING, OnViewCubicclipping)
  449. ON_COMMAND(ID_FILE_IMPORT, OnFileImport)
  450. ON_COMMAND(ID_FILE_PROJECTSETTINGS, OnFileProjectsettings)
  451. ON_UPDATE_COMMAND_UI(ID_FILE_IMPORT, OnUpdateFileImport)
  452. ON_COMMAND(ID_VIEW_CUBEIN, OnViewCubein)
  453. ON_COMMAND(ID_VIEW_CUBEOUT, OnViewCubeout)
  454. ON_COMMAND(ID_FILE_SAVEREGION, OnFileSaveregion)
  455. ON_UPDATE_COMMAND_UI(ID_FILE_SAVEREGION, OnUpdateFileSaveregion)
  456. ON_COMMAND(ID_SELECTION_MOVEDOWN, OnSelectionMovedown)
  457. ON_COMMAND(ID_SELECTION_MOVEUP, OnSelectionMoveup)
  458. ON_COMMAND(ID_TOOLBAR_MAIN, OnToolbarMain)
  459. ON_COMMAND(ID_TOOLBAR_TEXTURE, OnToolbarTexture)
  460. ON_COMMAND(ID_SELECTION_PRINT, OnSelectionPrint)
  461. ON_COMMAND(ID_SELECTION_TOGGLESIZEPAINT, OnSelectionTogglesizepaint)
  462. ON_COMMAND(ID_BRUSH_MAKECONE, OnBrushMakecone)
  463. ON_COMMAND(ID_TEXTURES_LOAD, OnTexturesLoad)
  464. ON_COMMAND(ID_TOGGLE_ROTATELOCK, OnToggleRotatelock)
  465. ON_COMMAND(ID_CURVE_BEVEL, OnCurveBevel)
  466. ON_COMMAND(ID_CURVE_CYLINDER, OnCurveCylinder)
  467. ON_COMMAND(ID_CURVE_EIGHTHSPHERE, OnCurveEighthsphere)
  468. ON_COMMAND(ID_CURVE_ENDCAP, OnCurveEndcap)
  469. ON_COMMAND(ID_CURVE_HEMISPHERE, OnCurveHemisphere)
  470. ON_COMMAND(ID_CURVE_INVERTCURVE, OnCurveInvertcurve)
  471. ON_COMMAND(ID_CURVE_QUARTER, OnCurveQuarter)
  472. ON_COMMAND(ID_CURVE_SPHERE, OnCurveSphere)
  473. ON_COMMAND(ID_FILE_IMPORTMAP, OnFileImportmap)
  474. ON_COMMAND(ID_FILE_EXPORTMAP, OnFileExportmap)
  475. ON_COMMAND(ID_EDIT_LOADPREFAB, OnEditLoadprefab)
  476. ON_COMMAND(ID_VIEW_SHOWCURVES, OnViewShowcurves)
  477. ON_COMMAND(ID_SELECTION_SELECT_NUDGEDOWN, OnSelectionSelectNudgedown)
  478. ON_COMMAND(ID_SELECTION_SELECT_NUDGELEFT, OnSelectionSelectNudgeleft)
  479. ON_COMMAND(ID_SELECTION_SELECT_NUDGERIGHT, OnSelectionSelectNudgeright)
  480. ON_COMMAND(ID_SELECTION_SELECT_NUDGEUP, OnSelectionSelectNudgeup)
  481. ON_WM_SYSKEYDOWN()
  482. ON_COMMAND(ID_TEXTURES_LOADLIST, OnTexturesLoadlist)
  483. ON_COMMAND(ID_DONTSELECTCURVE, OnDontselectcurve)
  484. ON_COMMAND(ID_CONVERTCURVES, OnConvertcurves)
  485. ON_COMMAND(ID_DYNAMIC_LIGHTING, OnDynamicLighting)
  486. ON_COMMAND(ID_CURVE_SIMPLEPATCHMESH, OnCurveSimplepatchmesh)
  487. ON_COMMAND(ID_PATCH_SHOWBOUNDINGBOX, OnPatchToggleBox)
  488. ON_COMMAND(ID_PATCH_WIREFRAME, OnPatchWireframe)
  489. ON_COMMAND(ID_CURVE_PATCHCONE, OnCurvePatchcone)
  490. ON_COMMAND(ID_CURVE_PATCHTUBE, OnCurvePatchtube)
  491. ON_COMMAND(ID_PATCH_WELD, OnPatchWeld)
  492. ON_COMMAND(ID_CURVE_PATCHBEVEL, OnCurvePatchbevel)
  493. ON_COMMAND(ID_CURVE_PATCHENDCAP, OnCurvePatchendcap)
  494. ON_COMMAND(ID_CURVE_PATCHINVERTEDBEVEL, OnCurvePatchinvertedbevel)
  495. ON_COMMAND(ID_CURVE_PATCHINVERTEDENDCAP, OnCurvePatchinvertedendcap)
  496. ON_COMMAND(ID_PATCH_DRILLDOWN, OnPatchDrilldown)
  497. ON_COMMAND(ID_CURVE_INSERTCOLUMN, OnCurveInsertcolumn)
  498. ON_COMMAND(ID_CURVE_INSERTROW, OnCurveInsertrow)
  499. ON_COMMAND(ID_CURVE_DELETECOLUMN, OnCurveDeletecolumn)
  500. ON_COMMAND(ID_CURVE_DELETEROW, OnCurveDeleterow)
  501. ON_COMMAND(ID_CURVE_INSERT_ADDCOLUMN, OnCurveInsertAddcolumn)
  502. ON_COMMAND(ID_CURVE_INSERT_ADDROW, OnCurveInsertAddrow)
  503. ON_COMMAND(ID_CURVE_INSERT_INSERTCOLUMN, OnCurveInsertInsertcolumn)
  504. ON_COMMAND(ID_CURVE_INSERT_INSERTROW, OnCurveInsertInsertrow)
  505. ON_COMMAND(ID_CURVE_NEGATIVE, OnCurveNegative)
  506. ON_COMMAND(ID_CURVE_NEGATIVETEXTUREX, OnCurveNegativeTextureX)
  507. ON_COMMAND(ID_CURVE_NEGATIVETEXTUREY, OnCurveNegativeTextureY)
  508. ON_COMMAND(ID_CURVE_DELETE_FIRSTCOLUMN, OnCurveDeleteFirstcolumn)
  509. ON_COMMAND(ID_CURVE_DELETE_FIRSTROW, OnCurveDeleteFirstrow)
  510. ON_COMMAND(ID_CURVE_DELETE_LASTCOLUMN, OnCurveDeleteLastcolumn)
  511. ON_COMMAND(ID_CURVE_DELETE_LASTROW, OnCurveDeleteLastrow)
  512. ON_COMMAND(ID_PATCH_BEND, OnPatchBend)
  513. ON_COMMAND(ID_PATCH_INSDEL, OnPatchInsdel)
  514. ON_COMMAND(ID_PATCH_ENTER, OnPatchEnter)
  515. ON_COMMAND(ID_PATCH_TAB, OnPatchTab)
  516. ON_COMMAND(ID_CURVE_PATCHDENSETUBE, OnCurvePatchdensetube)
  517. ON_COMMAND(ID_CURVE_PATCHVERYDENSETUBE, OnCurvePatchverydensetube)
  518. ON_COMMAND(ID_CURVE_CAP, OnCurveCap)
  519. ON_COMMAND(ID_CURVE_CAP_INVERTEDBEVEL, OnCurveCapInvertedbevel)
  520. ON_COMMAND(ID_CURVE_CAP_INVERTEDENDCAP, OnCurveCapInvertedendcap)
  521. ON_COMMAND(ID_CURVE_REDISPERSE_COLS, OnCurveRedisperseCols)
  522. ON_COMMAND(ID_CURVE_REDISPERSE_ROWS, OnCurveRedisperseRows)
  523. ON_COMMAND(ID_PATCH_NATURALIZE, OnPatchNaturalize)
  524. ON_COMMAND(ID_SELECT_SNAPTOGRID, OnSnapToGrid)
  525. ON_COMMAND(ID_CURVE_PATCHSQUARE, OnCurvePatchsquare)
  526. ON_COMMAND(ID_TERRAIN_CREATETERRAINFROMBRUSH, OnTerrainCreateFromBrush)
  527. ON_COMMAND(ID_TEXTURES_TEXTUREWINDOWSCALE_10, OnTexturesTexturewindowscale10)
  528. ON_COMMAND(ID_TEXTURES_TEXTUREWINDOWSCALE_100, OnTexturesTexturewindowscale100)
  529. ON_COMMAND(ID_TEXTURES_TEXTUREWINDOWSCALE_200, OnTexturesTexturewindowscale200)
  530. ON_COMMAND(ID_TEXTURES_TEXTUREWINDOWSCALE_25, OnTexturesTexturewindowscale25)
  531. ON_COMMAND(ID_TEXTURES_TEXTUREWINDOWSCALE_50, OnTexturesTexturewindowscale50)
  532. ON_COMMAND(ID_TEXTURES_FLUSH, OnTexturesFlush)
  533. ON_COMMAND(ID_CURVE_OVERLAY_CLEAR, OnCurveOverlayClear)
  534. ON_COMMAND(ID_CURVE_OVERLAY_SET, OnCurveOverlaySet)
  535. ON_COMMAND(ID_CURVE_THICKEN, OnCurveThicken)
  536. ON_COMMAND(ID_CURVE_CYCLECAP, OnCurveCyclecap)
  537. ON_COMMAND(ID_CURVE_MATRIX_TRANSPOSE, OnCurveMatrixTranspose)
  538. ON_COMMAND(ID_TEXTURES_RELOADSHADERS, OnTexturesReloadshaders)
  539. ON_COMMAND(ID_SHOW_ENTITIES, OnShowEntities)
  540. ON_COMMAND(ID_VIEW_ENTITIESAS_BOUNDINGBOX, OnViewEntitiesasBoundingbox)
  541. ON_COMMAND(ID_VIEW_ENTITIESAS_SELECTEDSKINNED, OnViewEntitiesasSelectedskinned)
  542. ON_COMMAND(ID_VIEW_ENTITIESAS_SELECTEDWIREFRAME, OnViewEntitiesasSelectedwireframe)
  543. ON_COMMAND(ID_VIEW_ENTITIESAS_SKINNED, OnViewEntitiesasSkinned)
  544. ON_COMMAND(ID_VIEW_ENTITIESAS_SKINNEDANDBOXED, OnViewEntitiesasSkinnedandboxed)
  545. ON_COMMAND(ID_VIEW_ENTITIESAS_WIREFRAME, OnViewEntitiesasWireframe)
  546. ON_COMMAND(ID_PLUGINS_REFRESH, OnPluginsRefresh)
  547. ON_COMMAND(ID_VIEW_SHOWHINT, OnViewShowhint)
  548. ON_UPDATE_COMMAND_UI(ID_TEXTURES_SHOWINUSE, OnUpdateTexturesShowinuse)
  549. ON_COMMAND(ID_TEXTURES_SHOWALL, OnTexturesShowall)
  550. ON_COMMAND(ID_PATCH_INSPECTOR, OnPatchInspector)
  551. ON_COMMAND(ID_VIEW_OPENGLLIGHTING, OnViewOpengllighting)
  552. ON_COMMAND(ID_SELECT_ALL, OnSelectAll)
  553. ON_COMMAND(ID_VIEW_SHOWCAULK, OnViewShowcaulk)
  554. ON_COMMAND(ID_CURVE_FREEZE, OnCurveFreeze)
  555. ON_COMMAND(ID_CURVE_UNFREEZE, OnCurveUnFreeze)
  556. ON_COMMAND(ID_CURVE_UNFREEZEALL, OnCurveUnFreezeAll)
  557. ON_COMMAND(ID_SELECT_RESELECT, OnSelectReselect)
  558. ON_COMMAND(ID_VIEW_SHOWANGLES, OnViewShowangles)
  559. ON_COMMAND(ID_EDIT_SAVEPREFAB, OnEditSaveprefab)
  560. ON_COMMAND(ID_CURVE_MOREENDCAPSBEVELS_SQUAREBEVEL, OnCurveMoreendcapsbevelsSquarebevel)
  561. ON_COMMAND(ID_CURVE_MOREENDCAPSBEVELS_SQUAREENDCAP, OnCurveMoreendcapsbevelsSquareendcap)
  562. ON_COMMAND(ID_BRUSH_PRIMITIVES_SPHERE, OnBrushPrimitivesSphere)
  563. ON_COMMAND(ID_VIEW_CROSSHAIR, OnViewCrosshair)
  564. ON_COMMAND(ID_VIEW_HIDESHOW_HIDESELECTED, OnViewHideshowHideselected)
  565. ON_COMMAND(ID_VIEW_HIDESHOW_SHOWHIDDEN, OnViewHideshowShowhidden)
  566. ON_COMMAND(ID_TEXTURES_SHADERS_SHOW, OnTexturesShadersShow)
  567. ON_COMMAND(ID_TEXTURES_FLUSH_UNUSED, OnTexturesFlushUnused)
  568. ON_COMMAND(ID_VIEW_GROUPS, OnViewGroups)
  569. ON_COMMAND(ID_DROP_GROUP_ADDTO_WORLD, OnDropGroupAddtoWorld)
  570. ON_COMMAND(ID_DROP_GROUP_NAME, OnDropGroupName)
  571. ON_COMMAND(ID_DROP_GROUP_NEWGROUP, OnDropGroupNewgroup)
  572. ON_COMMAND(ID_DROP_GROUP_REMOVE, OnDropGroupRemove)
  573. ON_COMMAND(ID_SPLINES_MODE, OnSplinesMode)
  574. ON_COMMAND(ID_SPLINES_LOAD, OnSplinesLoad)
  575. ON_COMMAND(ID_SPLINES_SAVE, OnSplinesSave)
  576. ON_COMMAND(ID_SPLINES_EDIT, OnSplinesEdit)
  577. ON_COMMAND(ID_SPLINE_TEST, OnSplineTest)
  578. ON_COMMAND(ID_POPUP_NEWCAMERA_INTERPOLATED, OnPopupNewcameraInterpolated)
  579. ON_COMMAND(ID_POPUP_NEWCAMERA_SPLINE, OnPopupNewcameraSpline)
  580. ON_COMMAND(ID_POPUP_NEWCAMERA_FIXED, OnPopupNewcameraFixed)
  581. //}}AFX_MSG_MAP
  582. ON_COMMAND_RANGE(CMD_TEXTUREWAD, CMD_TEXTUREWAD_END, OnTextureWad)
  583. ON_COMMAND_RANGE(CMD_BSPCOMMAND, CMD_BSPCOMMAND_END, OnBspCommand)
  584. ON_COMMAND_RANGE(IDMRU, IDMRU_END, OnMru)
  585. ON_COMMAND_RANGE(ID_VIEW_NEAREST, ID_TEXTURES_FLATSHADE, OnViewNearest)
  586. ON_COMMAND_RANGE(ID_GRID_1, ID_GRID_64, OnGrid1)
  587. ON_COMMAND_RANGE(ID_PLUGIN_START, ID_PLUGIN_END, OnPlugIn)
  588. ON_REGISTERED_MESSAGE(g_msgBSPDone, OnBSPDone)
  589. ON_REGISTERED_MESSAGE(g_msgBSPStatus, OnBSPStatus)
  590. ON_MESSAGE(WM_DISPLAYCHANGE, OnDisplayChange)
  591. END_MESSAGE_MAP()
  592. static UINT indicators[] =
  593. {
  594. ID_SEPARATOR, // status line indicator
  595. ID_SEPARATOR, // status line indicator
  596. ID_SEPARATOR, // status line indicator
  597. ID_SEPARATOR, // status line indicator
  598. ID_SEPARATOR, // status line indicator
  599. ID_SEPARATOR, // status line indicator
  600. };
  601. LRESULT CMainFrame::OnDisplayChange(UINT wParam, long lParam)
  602. {
  603. int n = wParam;
  604. return 0;
  605. }
  606. LRESULT CMainFrame::OnBSPStatus(UINT wParam, long lParam)
  607. {
  608. return 0;
  609. }
  610. LRESULT CMainFrame::OnBSPDone(UINT wParam, long lParam)
  611. {
  612. DLLBuildDone();
  613. return 0;
  614. }
  615. /////////////////////////////////////////////////////////////////////////////
  616. // CMainFrame construction/destruction
  617. CMainFrame::CMainFrame()
  618. {
  619. m_bDoLoop = false;
  620. m_bSplittersOK = false;
  621. g_pParentWnd = this;
  622. m_pXYWnd = NULL;
  623. m_pCamWnd = NULL;
  624. m_pTexWnd = NULL;
  625. m_pZWnd = NULL;
  626. m_pEditWnd = NULL;
  627. m_pYZWnd = NULL;
  628. m_pXZWnd = NULL;
  629. m_pActiveXY = NULL;
  630. m_bCamPreview = true;
  631. }
  632. CMainFrame::~CMainFrame()
  633. {
  634. }
  635. void HandlePopup(CWnd* pWindow, unsigned int uId)
  636. {
  637. // Get the current position of the mouse
  638. CPoint ptMouse;
  639. GetCursorPos(&ptMouse);
  640. // Load up a menu that has the options we are looking for in it
  641. CMenu mnuPopup;
  642. VERIFY(mnuPopup.LoadMenu(uId));
  643. mnuPopup.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON |
  644. TPM_RIGHTBUTTON, ptMouse.x, ptMouse.y,pWindow);
  645. mnuPopup.DestroyMenu();
  646. // Set focus back to window
  647. pWindow->SetFocus();
  648. }
  649. void CMainFrame::OnParentNotify(UINT message, LPARAM lParam)
  650. {
  651. }
  652. void CMainFrame::SetButtonMenuStates()
  653. {
  654. CMenu* pMenu = GetMenu();
  655. if (pMenu)
  656. {
  657. // by default all of these are checked because that's how they're defined in the menu editor
  658. if ( !g_qeglobals.d_savedinfo.show_names )
  659. pMenu->CheckMenuItem(ID_VIEW_SHOWNAMES, MF_BYCOMMAND | MF_UNCHECKED);
  660. if ( !g_qeglobals.d_savedinfo.show_coordinates )
  661. pMenu->CheckMenuItem(ID_VIEW_SHOWCOORDINATES, MF_BYCOMMAND | MF_UNCHECKED );
  662. if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_LIGHTS )
  663. pMenu->CheckMenuItem(ID_VIEW_SHOWLIGHTS, MF_BYCOMMAND | MF_UNCHECKED );
  664. if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_ENT )
  665. pMenu->CheckMenuItem(ID_VIEW_ENTITY, MF_BYCOMMAND | MF_UNCHECKED );
  666. if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_PATHS )
  667. pMenu->CheckMenuItem(ID_VIEW_SHOWPATH, MF_BYCOMMAND | MF_UNCHECKED );
  668. if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_WATER )
  669. pMenu->CheckMenuItem(ID_VIEW_SHOWWATER, MF_BYCOMMAND | MF_UNCHECKED );
  670. if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_WORLD )
  671. pMenu->CheckMenuItem(ID_VIEW_SHOWWORLD, MF_BYCOMMAND | MF_UNCHECKED );
  672. if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_CLIP )
  673. pMenu->CheckMenuItem(ID_VIEW_SHOWCLIP, MF_BYCOMMAND | MF_UNCHECKED );
  674. if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_HINT )
  675. pMenu->CheckMenuItem(ID_VIEW_SHOWHINT, MF_BYCOMMAND | MF_UNCHECKED );
  676. if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_CAULK )
  677. pMenu->CheckMenuItem(ID_VIEW_SHOWCAULK, MF_BYCOMMAND | MF_UNCHECKED );
  678. if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_ANGLES )
  679. pMenu->CheckMenuItem(ID_VIEW_SHOWANGLES, MF_BYCOMMAND | MF_UNCHECKED );
  680. pMenu->CheckMenuItem(ID_TOGGLE_LOCK, MF_BYCOMMAND | (g_PrefsDlg.m_bTextureLock) ? MF_CHECKED : MF_UNCHECKED);
  681. pMenu->CheckMenuItem(ID_TOGGLE_ROTATELOCK, MF_BYCOMMAND | (g_PrefsDlg.m_bRotateLock) ? MF_CHECKED : MF_UNCHECKED);
  682. pMenu->CheckMenuItem(ID_VIEW_CUBICCLIPPING, MF_BYCOMMAND | (g_PrefsDlg.m_bCubicClipping) ? MF_CHECKED : MF_UNCHECKED);
  683. pMenu->CheckMenuItem (ID_VIEW_OPENGLLIGHTING, MF_BYCOMMAND | (g_PrefsDlg.m_bGLLighting) ? MF_CHECKED : MF_UNCHECKED );
  684. pMenu->CheckMenuItem (ID_SNAPTOGRID, MF_BYCOMMAND | (!g_PrefsDlg.m_bNoClamp) ? MF_CHECKED : MF_UNCHECKED );
  685. if (m_wndToolBar.GetSafeHwnd())
  686. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_VIEW_CUBICCLIPPING, (g_PrefsDlg.m_bCubicClipping) ? TRUE : FALSE);
  687. int n = g_PrefsDlg.m_nTextureScale;
  688. int id;
  689. switch (n)
  690. {
  691. case 10 : id = ID_TEXTURES_TEXTUREWINDOWSCALE_10; break;
  692. case 25 : id = ID_TEXTURES_TEXTUREWINDOWSCALE_25; break;
  693. case 50 : id = ID_TEXTURES_TEXTUREWINDOWSCALE_50; break;
  694. case 200 : id = ID_TEXTURES_TEXTUREWINDOWSCALE_200; break;
  695. default : id = ID_TEXTURES_TEXTUREWINDOWSCALE_100; break;
  696. }
  697. CheckTextureScale(id);
  698. }
  699. if (g_qeglobals.d_project_entity)
  700. {
  701. FillTextureMenu(); // redundant but i'll clean it up later.. yeah right..
  702. FillBSPMenu();
  703. LoadMruInReg(g_qeglobals.d_lpMruMenu,"Software\\id\\QuakeEd4\\MRU");
  704. PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,::GetSubMenu(::GetMenu(GetSafeHwnd()),0), ID_FILE_EXIT);
  705. }
  706. }
  707. void CMainFrame::ShowMenuItemKeyBindings(CMenu *pMenu)
  708. {
  709. int i, j;
  710. char key[1024], *ptr;
  711. MENUITEMINFO MenuItemInfo;
  712. //return;
  713. for (i = 0; i < g_nCommandCount; i++)
  714. {
  715. memset(&MenuItemInfo, 0, sizeof(MENUITEMINFO));
  716. MenuItemInfo.cbSize = sizeof(MENUITEMINFO);
  717. MenuItemInfo.fMask = MIIM_TYPE;
  718. MenuItemInfo.dwTypeData = key;
  719. MenuItemInfo.cch = sizeof(key);
  720. if (!pMenu->GetMenuItemInfo(g_Commands[i].m_nCommand, &MenuItemInfo))
  721. continue;
  722. if (MenuItemInfo.fType != MFT_STRING)
  723. continue;
  724. ptr = strchr(key, '\t');
  725. if (ptr) *ptr = '\0';
  726. strcat(key, "\t");
  727. if (g_Commands[i].m_nModifiers) // are there modifiers present?
  728. {
  729. if (g_Commands[i].m_nModifiers & RAD_SHIFT)
  730. strcat(key, "Shift-");
  731. if (g_Commands[i].m_nModifiers & RAD_ALT)
  732. strcat(key, "Alt-");
  733. if (g_Commands[i].m_nModifiers & RAD_CONTROL)
  734. strcat(key, "Ctrl-");
  735. }
  736. for (j = 0; j < g_nKeyCount; j++)
  737. {
  738. if (g_Commands[i].m_nKey == g_Keys[j].m_nVKKey)
  739. {
  740. strcat(key, g_Keys[j].m_strName);
  741. break;
  742. }
  743. }
  744. if (j >= g_nKeyCount)
  745. {
  746. sprintf(&key[strlen(key)], "%c", g_Commands[i].m_nKey);
  747. }
  748. memset(&MenuItemInfo, 0, sizeof(MENUITEMINFO));
  749. MenuItemInfo.cbSize = sizeof(MENUITEMINFO);
  750. MenuItemInfo.fMask = MIIM_TYPE;
  751. MenuItemInfo.fType = MFT_STRING;
  752. MenuItemInfo.dwTypeData = key;
  753. MenuItemInfo.cch = strlen(key);
  754. SetMenuItemInfo(pMenu->m_hMenu, g_Commands[i].m_nCommand, FALSE, &MenuItemInfo);
  755. }
  756. }
  757. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  758. {
  759. //Init3Dfx();
  760. char* pBuffer = g_strAppPath.GetBufferSetLength(_MAX_PATH + 1);
  761. int nResult = ::GetModuleFileName(NULL, pBuffer, _MAX_PATH);
  762. ASSERT(nResult != 0);
  763. pBuffer[g_strAppPath.ReverseFind('\\') + 1] = '\0';
  764. g_strAppPath.ReleaseBuffer();
  765. InitCommonControls ();
  766. g_qeglobals.d_hInstance = AfxGetInstanceHandle();
  767. MFCCreate(AfxGetInstanceHandle());
  768. //g_PrefsDlg.LoadPrefs();
  769. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  770. return -1;
  771. UINT nStyle;
  772. UINT nID = (g_PrefsDlg.m_bWideToolbar) ? IDR_TOOLBAR_ADVANCED : IDR_TOOLBAR1;
  773. if (!m_wndToolBar.Create(this) ||
  774. !m_wndToolBar.LoadToolBar(nID))
  775. {
  776. TRACE0("Failed to create toolbar\n");
  777. return -1; // fail to create
  778. }
  779. if (!m_wndStatusBar.Create(this) ||
  780. !m_wndStatusBar.SetIndicators(indicators,
  781. sizeof(indicators)/sizeof(UINT)))
  782. {
  783. TRACE0("Failed to create status bar\n");
  784. return -1; // fail to create
  785. }
  786. #if 0
  787. if (!m_wndScaleBar.Create(this) ||
  788. !m_wndScaleBar.LoadToolBar(IDR_TOOLBAR_SCALELOCK))
  789. {
  790. TRACE0("Failed to create scaling toolbar\n");
  791. return -1; // fail to create
  792. }
  793. #endif
  794. // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  795. m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  796. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  797. // TODO: Delete these three lines if you don't want the toolbar to
  798. // be dockable
  799. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  800. EnableDocking(CBRS_ALIGN_ANY);
  801. DockControlBar(&m_wndToolBar);
  802. //m_wndScaleBar.SetBarStyle(m_wndScaleBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  803. //m_wndScaleBar.EnableDocking(CBRS_ALIGN_ANY);
  804. //m_wndScaleBar.ShowWindow(SW_HIDE);
  805. int nImage;
  806. int nIndex = m_wndToolBar.CommandToIndex(ID_VIEW_CAMERATOGGLE);
  807. if (nIndex >= 0)
  808. {
  809. m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
  810. m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
  811. m_wndToolBar.GetToolBarCtrl().CheckButton(nID);
  812. }
  813. m_bCamPreview = true;
  814. nIndex = m_wndToolBar.CommandToIndex(ID_VIEW_CUBICCLIPPING);
  815. if (nIndex >= 0)
  816. {
  817. m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
  818. m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
  819. }
  820. nIndex = m_wndToolBar.CommandToIndex(ID_VIEW_ENTITY);
  821. if (nIndex >= 0)
  822. {
  823. m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
  824. m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
  825. }
  826. nIndex = m_wndToolBar.CommandToIndex(ID_VIEW_CLIPPER);
  827. if (nIndex >= 0)
  828. {
  829. m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
  830. m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
  831. }
  832. nIndex = m_wndToolBar.CommandToIndex(ID_SELECT_MOUSEROTATE);
  833. if (nIndex >= 0)
  834. {
  835. m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
  836. m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
  837. }
  838. nIndex = m_wndToolBar.CommandToIndex(ID_SELECT_MOUSESCALE);
  839. if (nIndex >= 0)
  840. {
  841. m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
  842. m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
  843. }
  844. nIndex = m_wndToolBar.CommandToIndex(ID_SCALELOCKX);
  845. if (nIndex >= 0)
  846. {
  847. m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
  848. m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
  849. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKX, FALSE);
  850. }
  851. nIndex = m_wndToolBar.CommandToIndex(ID_SCALELOCKY);
  852. if (nIndex >= 0)
  853. {
  854. m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
  855. m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
  856. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKY, FALSE);
  857. }
  858. nIndex = m_wndToolBar.CommandToIndex(ID_SCALELOCKZ);
  859. if (nIndex >= 0)
  860. {
  861. m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
  862. m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
  863. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKZ, FALSE);
  864. }
  865. #ifdef QUAKE3
  866. nIndex = m_wndToolBar.CommandToIndex(ID_DONTSELECTCURVE);
  867. if (nIndex >= 0)
  868. {
  869. m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
  870. m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
  871. }
  872. nIndex = m_wndToolBar.CommandToIndex(ID_PATCH_SHOWBOUNDINGBOX);
  873. if (nIndex >= 0)
  874. {
  875. m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
  876. m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
  877. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_SHOWBOUNDINGBOX, TRUE);
  878. }
  879. nIndex = m_wndToolBar.CommandToIndex(ID_PATCH_WELD);
  880. if (nIndex >= 0)
  881. {
  882. m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
  883. m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
  884. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_WELD, TRUE);
  885. }
  886. nIndex = m_wndToolBar.CommandToIndex(ID_PATCH_DRILLDOWN);
  887. if (nIndex >= 0)
  888. {
  889. m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
  890. m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
  891. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_DRILLDOWN, TRUE);
  892. }
  893. nIndex = m_wndToolBar.CommandToIndex(ID_PATCH_BEND);
  894. if (nIndex >= 0)
  895. {
  896. m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
  897. m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
  898. }
  899. nIndex = m_wndToolBar.CommandToIndex(ID_PATCH_INSDEL);
  900. if (nIndex >= 0)
  901. {
  902. m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
  903. m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
  904. }
  905. #else
  906. m_wndToolBar.GetToolBarCtrl().HideButton(ID_DONTSELECTCURVE);
  907. m_wndToolBar.GetToolBarCtrl().HideButton(ID_PATCH_SHOWBOUNDINGBOX);
  908. m_wndToolBar.GetToolBarCtrl().HideButton(ID_PATCH_WELD);
  909. m_wndToolBar.GetToolBarCtrl().HideButton(ID_PATCH_WIREFRAME);
  910. #endif
  911. g_nScaleHow = 0;
  912. #ifdef QUAKE3
  913. g_pParentWnd->GetMenu()->DestroyMenu();
  914. CMenu* pMenu = new CMenu();
  915. pMenu->LoadMenu(IDR_MENU_QUAKE3);
  916. g_pParentWnd->SetMenu(pMenu);
  917. #else
  918. CMenu* pMenu = GetMenu();
  919. #endif
  920. m_wndTextureBar.Create(this, IDD_TEXTUREBAR, CBRS_BOTTOM, 7433);
  921. m_wndTextureBar.EnableDocking(CBRS_ALIGN_ANY);
  922. DockControlBar(&m_wndTextureBar);
  923. g_qeglobals.d_lpMruMenu = CreateMruMenuDefault();
  924. m_bAutoMenuEnable = FALSE;
  925. LoadCommandMap();
  926. ShowMenuItemKeyBindings(pMenu);
  927. CFont* pFont = new CFont();
  928. pFont->CreatePointFont(g_PrefsDlg.m_nStatusSize * 10, "Arial");
  929. m_wndStatusBar.SetFont(pFont);
  930. OnPluginsRefresh();
  931. if (g_PrefsDlg.m_bRunBefore == FALSE)
  932. {
  933. g_PrefsDlg.m_bRunBefore = TRUE;
  934. g_PrefsDlg.SavePrefs();
  935. /*
  936. if (MessageBox("Would you like QERadiant to build and load a default project? If this is the first time you have run QERadiant or you are not familiar with editing QE4 project files directly, this is HIGHLY recommended", "Create a default project?", MB_YESNO) == IDYES)
  937. {
  938. OnFileNewproject();
  939. }
  940. */
  941. }
  942. else
  943. {
  944. // hack that keeps SGI OpenGL from crashing on texture load with no map
  945. #if 0
  946. if (g_PrefsDlg.m_bSGIOpenGL)
  947. {
  948. vec3_t vMin, vMax;
  949. vMin[0] = vMin[1] = vMin[2] = 0;
  950. vMax[0] = vMax[1] = vMax[2] = 8;
  951. brush_t* pBrush = Brush_Create(vMin, vMax, &g_qeglobals.d_texturewin.texdef);
  952. Entity_LinkBrush (world_entity, pBrush);
  953. Brush_Build(pBrush);
  954. Brush_AddToList (pBrush, &active_brushes);
  955. Select_Brush(pBrush);
  956. Sys_UpdateWindows(W_ALL);
  957. PostMessage(WM_COMMAND, ID_SELECTION_DELETE, 0);
  958. }
  959. #endif
  960. // load plugins before the first Map_LoadFile
  961. // required for model plugins
  962. if (g_PrefsDlg.m_bLoadLastMap && g_PrefsDlg.m_strLastMap.GetLength() > 0)
  963. Map_LoadFile(g_PrefsDlg.m_strLastMap.GetBuffer(0));
  964. }
  965. SetGridStatus();
  966. SetTexValStatus();
  967. SetButtonMenuStates();
  968. LoadBarState("RadiantToolBars2");
  969. if (!g_PrefsDlg.m_bTextureBar)
  970. ShowControlBar(&m_wndTextureBar, FALSE, TRUE);
  971. else
  972. ShowControlBar(&m_wndTextureBar, TRUE, TRUE);
  973. ShowControlBar(&m_wndToolBar, (m_wndToolBar.GetStyle() & WS_VISIBLE), TRUE);
  974. SetActiveXY(m_pXYWnd);
  975. m_pXYWnd->SetFocus();
  976. PostMessage(WM_KEYDOWN, 'O', NULL);
  977. return 0;
  978. }
  979. void CMainFrame::LoadCommandMap()
  980. {
  981. CString strINI;
  982. char* pBuff = new char[1024];
  983. if (g_PrefsDlg.m_strUserPath.GetLength() > 0)
  984. strINI = g_PrefsDlg.m_strUserPath;
  985. else
  986. {
  987. strINI = g_strAppPath;
  988. strINI += "\\radiant.ini";
  989. }
  990. for (int i = 0; i < g_nCommandCount; i++)
  991. {
  992. int nLen = GetPrivateProfileString("Commands", g_Commands[i].m_strCommand, "", pBuff, 1024, strINI);
  993. if (nLen > 0)
  994. {
  995. CString strBuff = pBuff;
  996. strBuff.TrimLeft();
  997. strBuff.TrimRight();
  998. int nSpecial = strBuff.Find("+alt");
  999. g_Commands[i].m_nModifiers = 0;
  1000. if (nSpecial >= 0)
  1001. {
  1002. g_Commands[i].m_nModifiers |= RAD_ALT;
  1003. FindReplace(strBuff, "+alt", "");
  1004. }
  1005. nSpecial = strBuff.Find("+ctrl");
  1006. if (nSpecial >= 0)
  1007. {
  1008. g_Commands[i].m_nModifiers |= RAD_CONTROL;
  1009. FindReplace(strBuff, "+ctrl", "");
  1010. }
  1011. nSpecial = strBuff.Find("+shift");
  1012. if (nSpecial >= 0)
  1013. {
  1014. g_Commands[i].m_nModifiers |= RAD_SHIFT;
  1015. FindReplace(strBuff, "+shift", "");
  1016. }
  1017. strBuff.TrimLeft();
  1018. strBuff.TrimRight();
  1019. strBuff.MakeUpper();
  1020. if (nLen == 1) // most often case.. deal with first
  1021. {
  1022. g_Commands[i].m_nKey = __toascii(strBuff.GetAt(0));
  1023. }
  1024. else // special key
  1025. {
  1026. for (int j = 0; j < g_nKeyCount; j++)
  1027. {
  1028. if (strBuff.CompareNoCase(g_Keys[j].m_strName) == 0)
  1029. {
  1030. g_Commands[i].m_nKey = g_Keys[j].m_nVKKey;
  1031. break;
  1032. }
  1033. }
  1034. }
  1035. }
  1036. }
  1037. delete []pBuff;
  1038. }
  1039. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  1040. {
  1041. // TODO: Modify the Window class or styles here by modifying
  1042. // the CREATESTRUCT cs
  1043. return CFrameWnd::PreCreateWindow(cs);
  1044. }
  1045. /////////////////////////////////////////////////////////////////////////////
  1046. // CMainFrame diagnostics
  1047. #ifdef _DEBUG
  1048. void CMainFrame::AssertValid() const
  1049. {
  1050. CFrameWnd::AssertValid();
  1051. }
  1052. void CMainFrame::Dump(CDumpContext& dc) const
  1053. {
  1054. CFrameWnd::Dump(dc);
  1055. }
  1056. #endif //_DEBUG
  1057. /////////////////////////////////////////////////////////////////////////////
  1058. // CMainFrame message handlers
  1059. void CMainFrame::CreateQEChildren()
  1060. {
  1061. // the project file can be specified on the command line,
  1062. // or implicitly found in the scripts directory
  1063. bool bProjectLoaded = false;
  1064. if (AfxGetApp()->m_lpCmdLine && strlen(AfxGetApp()->m_lpCmdLine))
  1065. {
  1066. ParseCommandLine (AfxGetApp()->m_lpCmdLine);
  1067. bProjectLoaded = QE_LoadProject(argv[1]);
  1068. }
  1069. else
  1070. {
  1071. if (g_PrefsDlg.m_bLoadLast && g_PrefsDlg.m_strLastProject.GetLength() > 0)
  1072. {
  1073. bProjectLoaded = QE_LoadProject(g_PrefsDlg.m_strLastProject.GetBuffer(0));
  1074. }
  1075. if (!bProjectLoaded)
  1076. {
  1077. CString str = g_strAppPath;
  1078. AddSlash(str);
  1079. str += "../baseq3/scripts/quake.qe4";
  1080. char cWork[1024];
  1081. char *pFile = NULL;
  1082. GetFullPathName(str, 1024, cWork, &pFile);
  1083. bProjectLoaded = QE_LoadProject(cWork);
  1084. }
  1085. if (!bProjectLoaded)
  1086. {
  1087. bProjectLoaded = QE_LoadProject("scripts/quake.qe4");
  1088. }
  1089. }
  1090. if (!bProjectLoaded)
  1091. {
  1092. #if 0
  1093. // let's try the default project directory..
  1094. char* pBuff = new char[1024];
  1095. ::GetCurrentDirectory(1024, pBuff);
  1096. CString strDefProj = g_strAppPath;
  1097. AddSlash(strDefProj);
  1098. strDefProj += "defproj";
  1099. if (::SetCurrentDirectory(strDefProj))
  1100. {
  1101. bProjectLoaded = QE_LoadProject("scripts/quake.qe4");
  1102. if (bProjectLoaded)
  1103. {
  1104. // setup auto load stuff for the default map
  1105. g_PrefsDlg.m_bLoadLast = TRUE;
  1106. AddSlash(strDefProj);
  1107. strDefProj += "maps\\defproj.map";
  1108. g_PrefsDlg.m_strLastMap = strDefProj;
  1109. g_PrefsDlg.SavePrefs();
  1110. }
  1111. }
  1112. else
  1113. {
  1114. ::SetCurrentDirectory(pBuff);
  1115. }
  1116. delete []pBuff;
  1117. #endif
  1118. if (!bProjectLoaded)
  1119. {
  1120. Sys_Printf ("Using default.qe4. You may experience problems. See the readme.txt\n");
  1121. CString strProj = g_strAppPath;
  1122. strProj += "\\default.qe4";
  1123. bProjectLoaded = QE_LoadProject(strProj.GetBuffer(0));
  1124. if (!bProjectLoaded)
  1125. {
  1126. CFileDialog dlgFile(true, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Q3Radiant Project files (*.qe4, *.prj)|*.qe4|*.prj||", this);
  1127. if (dlgFile.DoModal() == IDOK)
  1128. bProjectLoaded = QE_LoadProject(dlgFile.GetPathName().GetBuffer(0));
  1129. }
  1130. }
  1131. }
  1132. if (!bProjectLoaded)
  1133. Error("Unable to load project file. It was unavailable in the scripts path and the default could not be found");
  1134. if (g_PrefsDlg.m_bPAK == TRUE)
  1135. {
  1136. // FIXME: pay attention to Q3 pref
  1137. //InitPakFile(ValueForKey(g_qeglobals.d_project_entity, "basepath"), g_PrefsDlg.m_strPAKFile);
  1138. InitPakFile(ValueForKey(g_qeglobals.d_project_entity, "basepath"), NULL);
  1139. }
  1140. QE_Init ();
  1141. Sys_Printf ("Entering message loop\n");
  1142. m_bDoLoop = true;
  1143. SetTimer(QE_TIMER0, 1000, NULL);
  1144. }
  1145. BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)
  1146. {
  1147. return CFrameWnd::OnCommand(wParam, lParam);
  1148. }
  1149. LRESULT CMainFrame::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  1150. {
  1151. RoutineProcessing();
  1152. return CFrameWnd::DefWindowProc(message, wParam, lParam);
  1153. }
  1154. void CMainFrame::RoutineProcessing()
  1155. {
  1156. if (m_bDoLoop)
  1157. {
  1158. double time = 0.0;
  1159. double oldtime = 0.0;
  1160. double delta= 0.0;
  1161. CheckBspProcess ();
  1162. time = Sys_DoubleTime ();
  1163. delta = time - oldtime;
  1164. oldtime = time;
  1165. if (delta > 0.2)
  1166. delta = 0.2;
  1167. // run time dependant behavior
  1168. if (m_pCamWnd)
  1169. m_pCamWnd->Cam_MouseControl(delta);
  1170. if (g_PrefsDlg.m_bQE4Painting && g_nUpdateBits)
  1171. {
  1172. int nBits = g_nUpdateBits; // this is done to keep this routine from being
  1173. g_nUpdateBits = 0; // re-entered due to the paint process.. only
  1174. UpdateWindows(nBits); // happens in rare cases but causes a stack overflow
  1175. }
  1176. }
  1177. }
  1178. LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  1179. {
  1180. return CFrameWnd::WindowProc(message, wParam, lParam);
  1181. }
  1182. bool MouseDown()
  1183. {
  1184. if (::GetAsyncKeyState(VK_LBUTTON))
  1185. return true;
  1186. if (::GetAsyncKeyState(VK_RBUTTON))
  1187. return true;
  1188. if (::GetAsyncKeyState(VK_MBUTTON))
  1189. return true;
  1190. return false;
  1191. }
  1192. void CMainFrame::OnTimer(UINT nIDEvent)
  1193. {
  1194. if (!MouseDown())
  1195. {
  1196. QE_CountBrushesAndUpdateStatusBar();
  1197. QE_CheckAutoSave();
  1198. }
  1199. }
  1200. struct SplitInfo
  1201. {
  1202. int m_nMin;
  1203. int m_nCur;
  1204. };
  1205. bool LoadWindowPlacement(HWND hwnd, const char* pName)
  1206. {
  1207. WINDOWPLACEMENT wp;
  1208. wp.length = sizeof(WINDOWPLACEMENT);
  1209. LONG lSize = sizeof(wp);
  1210. if (LoadRegistryInfo(pName, &wp, &lSize))
  1211. {
  1212. ::SetWindowPlacement(hwnd, &wp);
  1213. return true;
  1214. }
  1215. return false;
  1216. }
  1217. void SaveWindowPlacement(HWND hwnd, const char* pName)
  1218. {
  1219. WINDOWPLACEMENT wp;
  1220. wp.length = sizeof(WINDOWPLACEMENT);
  1221. if (::GetWindowPlacement(hwnd, &wp))
  1222. {
  1223. SaveRegistryInfo(pName, &wp, sizeof(wp));
  1224. }
  1225. }
  1226. void CMainFrame::OnDestroy()
  1227. {
  1228. KillTimer(QE_TIMER0);
  1229. SaveBarState("RadiantToolBars2");
  1230. // FIXME
  1231. // original mru stuff needs replaced with mfc stuff
  1232. SaveMruInReg(g_qeglobals.d_lpMruMenu,"Software\\id\\QuakeEd4\\MRU");
  1233. DeleteMruMenu(g_qeglobals.d_lpMruMenu);
  1234. SaveWindowPlacement(GetSafeHwnd(), "Radiant::MainWindowPlace");
  1235. //SaveWindowState(GetSafeHwnd(), "Radiant::MainWindow");
  1236. //if (m_nCurrentStyle == QR_QE4)
  1237. //SaveWindowPlacement(g_qeglobals.d_hwndEntity, "EntityWindowPlace");
  1238. if (m_nCurrentStyle == 0 || m_nCurrentStyle == 3)
  1239. {
  1240. SaveWindowState(m_wndSplit.GetSafeHwnd(), "Radiant::Split");
  1241. SaveWindowState(m_wndSplit2.GetSafeHwnd(), "Radiant::Split2");
  1242. SaveWindowState(m_wndSplit3.GetSafeHwnd(), "Radiant::Split3");
  1243. SplitInfo spinfo;
  1244. m_wndSplit.GetRowInfo(0, spinfo.m_nCur, spinfo.m_nMin);
  1245. SaveRegistryInfo("Radiant::Split::Row_0", &spinfo, sizeof(spinfo));
  1246. m_wndSplit.GetRowInfo(1, spinfo.m_nCur, spinfo.m_nMin);
  1247. SaveRegistryInfo("Radiant::Split::Row_1", &spinfo, sizeof(spinfo));
  1248. m_wndSplit2.GetColumnInfo(0, spinfo.m_nCur, spinfo.m_nMin);
  1249. SaveRegistryInfo("Radiant::Split2::Col_0", &spinfo, sizeof(spinfo));
  1250. m_wndSplit2.GetColumnInfo(1, spinfo.m_nCur, spinfo.m_nMin);
  1251. SaveRegistryInfo("Radiant::Split2::Col_1", &spinfo, sizeof(spinfo));
  1252. m_wndSplit2.GetColumnInfo(2, spinfo.m_nCur, spinfo.m_nMin);
  1253. SaveRegistryInfo("Radiant::Split2::Col_2", &spinfo, sizeof(spinfo));
  1254. m_wndSplit3.GetRowInfo(0, spinfo.m_nCur, spinfo.m_nMin);
  1255. SaveRegistryInfo("Radiant::Split3::Row_0", &spinfo, sizeof(spinfo));
  1256. m_wndSplit3.GetRowInfo(1, spinfo.m_nCur, spinfo.m_nMin);
  1257. SaveRegistryInfo("Radiant::Split3::Row_1", &spinfo, sizeof(spinfo));
  1258. }
  1259. else
  1260. {
  1261. SaveWindowPlacement(m_pXYWnd->GetSafeHwnd(), "xywindow");
  1262. SaveWindowPlacement(m_pXZWnd->GetSafeHwnd(), "xzwindow");
  1263. SaveWindowPlacement(m_pYZWnd->GetSafeHwnd(), "yzwindow");
  1264. SaveWindowPlacement(m_pCamWnd->GetSafeHwnd(), "camerawindow");
  1265. SaveWindowPlacement(m_pZWnd->GetSafeHwnd(), "zwindow");
  1266. SaveWindowState(m_pTexWnd->GetSafeHwnd(), "texwindow");
  1267. SaveWindowState(m_pEditWnd->GetSafeHwnd(), "editwindow");
  1268. }
  1269. if (m_pXYWnd->GetSafeHwnd())
  1270. m_pXYWnd->SendMessage(WM_DESTROY, 0, 0);
  1271. delete m_pXYWnd; m_pXYWnd = NULL;
  1272. if (m_pYZWnd->GetSafeHwnd())
  1273. m_pYZWnd->SendMessage(WM_DESTROY, 0, 0);
  1274. delete m_pYZWnd; m_pYZWnd = NULL;
  1275. if (m_pXZWnd->GetSafeHwnd())
  1276. m_pXZWnd->SendMessage(WM_DESTROY, 0, 0);
  1277. delete m_pXZWnd; m_pXZWnd = NULL;
  1278. if (m_pZWnd->GetSafeHwnd())
  1279. m_pZWnd->SendMessage(WM_DESTROY, 0, 0);
  1280. delete m_pZWnd; m_pZWnd = NULL;
  1281. if (m_pTexWnd->GetSafeHwnd())
  1282. m_pTexWnd->SendMessage(WM_DESTROY, 0, 0);
  1283. delete m_pTexWnd; m_pTexWnd = NULL;
  1284. if (m_pEditWnd->GetSafeHwnd())
  1285. m_pEditWnd->SendMessage(WM_DESTROY, 0, 0);
  1286. delete m_pEditWnd; m_pEditWnd = NULL;
  1287. if (m_pCamWnd->GetSafeHwnd())
  1288. m_pCamWnd->SendMessage(WM_DESTROY, 0, 0);
  1289. delete m_pCamWnd;m_pCamWnd = NULL;
  1290. SaveRegistryInfo("SavedInfo", &g_qeglobals.d_savedinfo, sizeof(g_qeglobals.d_savedinfo));
  1291. if (strcmpi(currentmap, "unnamed.map") != 0)
  1292. {
  1293. g_PrefsDlg.m_strLastMap = currentmap;
  1294. g_PrefsDlg.SavePrefs();
  1295. }
  1296. CleanUpEntities();
  1297. while (active_brushes.next != &active_brushes)
  1298. Brush_Free (active_brushes.next, false);
  1299. while (selected_brushes.next != &selected_brushes)
  1300. Brush_Free (selected_brushes.next, false);
  1301. while (filtered_brushes.next != &filtered_brushes)
  1302. Brush_Free (filtered_brushes.next, false);
  1303. while (entities.next != &entities)
  1304. Entity_Free (entities.next);
  1305. epair_t* pEPair = g_qeglobals.d_project_entity->epairs;
  1306. while (pEPair)
  1307. {
  1308. epair_t* pNextEPair = pEPair->next;
  1309. free (pEPair->key);
  1310. free (pEPair->value);
  1311. free (pEPair);
  1312. pEPair = pNextEPair;
  1313. }
  1314. entity_t* pEntity = g_qeglobals.d_project_entity->next;
  1315. while (pEntity != NULL && pEntity != g_qeglobals.d_project_entity)
  1316. {
  1317. entity_t* pNextEntity = pEntity->next;
  1318. Entity_Free(pEntity);
  1319. pEntity = pNextEntity;
  1320. }
  1321. Texture_Cleanup();
  1322. if (world_entity)
  1323. Entity_Free(world_entity);
  1324. if (notexture)
  1325. {
  1326. // Timo
  1327. // Surface properties plugin
  1328. #ifdef _DEBUG
  1329. if ( !notexture->pData )
  1330. Sys_Printf("WARNING: found a qtexture_t* with no IPluginQTexture\n");
  1331. #endif
  1332. if ( notexture->pData )
  1333. GETPLUGINTEXDEF(notexture)->DecRef();
  1334. free(notexture);
  1335. }
  1336. //if (current_texture)
  1337. // free(current_texture);
  1338. ClosePakFile();
  1339. FreeShaders();
  1340. CFrameWnd::OnDestroy();
  1341. }
  1342. void CMainFrame::OnClose()
  1343. {
  1344. if (ConfirmModified())
  1345. {
  1346. CFrameWnd::OnClose();
  1347. }
  1348. }
  1349. void CMainFrame::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
  1350. {
  1351. // run through our list to see if we have a handler for nChar
  1352. //
  1353. for (int i = 0; i < g_nCommandCount; i++)
  1354. {
  1355. if (g_Commands[i].m_nKey == nChar) // find a match?
  1356. {
  1357. bool bGo = true;
  1358. if (g_Commands[i].m_nModifiers & RAD_PRESS)
  1359. {
  1360. int nModifiers = g_Commands[i].m_nModifiers & ~RAD_PRESS;
  1361. if (nModifiers) // are there modifiers present?
  1362. {
  1363. if (nModifiers & RAD_ALT)
  1364. if (!(GetKeyState(VK_MENU) & 0x8000))
  1365. bGo = false;
  1366. if (nModifiers & RAD_CONTROL)
  1367. if (!(GetKeyState(VK_CONTROL) & 0x8000))
  1368. bGo = false;
  1369. if (nModifiers & RAD_SHIFT)
  1370. if (!(GetKeyState(VK_SHIFT) & 0x8000))
  1371. bGo = false;
  1372. }
  1373. else // no modifiers make sure none of those keys are pressed
  1374. {
  1375. if (GetKeyState(VK_MENU) & 0x8000)
  1376. bGo = false;
  1377. if (GetKeyState(VK_CONTROL) & 0x8000)
  1378. bGo = false;
  1379. if (GetKeyState(VK_SHIFT) & 0x8000)
  1380. bGo = false;
  1381. }
  1382. if (bGo)
  1383. {
  1384. SendMessage(WM_COMMAND, g_Commands[i].m_nCommand, 0);
  1385. break;
  1386. }
  1387. }
  1388. }
  1389. }
  1390. }
  1391. bool CamOK(unsigned int nKey)
  1392. {
  1393. if (nKey == VK_UP || nKey == VK_LEFT || nKey == VK_RIGHT || nKey == VK_DOWN)
  1394. {
  1395. if (::GetAsyncKeyState(nKey))
  1396. return true;
  1397. else
  1398. return false;
  1399. }
  1400. return true;
  1401. }
  1402. void CMainFrame::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
  1403. {
  1404. //OnKeyDown(nChar, nRepCnt, nFlags);
  1405. if (nChar == VK_DOWN)
  1406. {
  1407. OnKeyDown(nChar, nRepCnt, nFlags);
  1408. }
  1409. CFrameWnd::OnSysKeyDown(nChar, nRepCnt, nFlags);
  1410. }
  1411. void CMainFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
  1412. {
  1413. for (int i = 0; i < g_nCommandCount; i++)
  1414. {
  1415. if (g_Commands[i].m_nKey == nChar) // find a match?
  1416. {
  1417. // check modifiers
  1418. unsigned int nState = 0;
  1419. if (GetKeyState(VK_MENU) & 0x8000)
  1420. nState |= RAD_ALT;
  1421. if (GetKeyState(VK_CONTROL) & 0x8000)
  1422. nState |= RAD_CONTROL;
  1423. if (GetKeyState(VK_SHIFT) & 0x8000)
  1424. nState |= RAD_SHIFT;
  1425. if ((g_Commands[i].m_nModifiers & 0x7) == nState)
  1426. {
  1427. SendMessage(WM_COMMAND, g_Commands[i].m_nCommand, 0);
  1428. break;
  1429. }
  1430. }
  1431. }
  1432. CFrameWnd::OnKeyDown(nChar, nRepCnt, nFlags);
  1433. }
  1434. BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
  1435. {
  1436. g_qeglobals.d_hwndMain = GetSafeHwnd();
  1437. g_qeglobals.d_hwndStatus = GetMessageBar()->GetSafeHwnd();
  1438. /*
  1439. if (g_PrefsDlg.m_bRunBefore == FALSE)
  1440. {
  1441. MessageBox("In the following dialog, please make sure the Quake2 .exe information is correct.\nQERadiant will NOT run correctly without this information");
  1442. g_PrefsDlg.DoModal();
  1443. }
  1444. */
  1445. m_nCurrentStyle = g_PrefsDlg.m_nView;
  1446. CreateEntityWindow(AfxGetInstanceHandle());
  1447. g_pGroupDlg->Create( IDD_DLG_GROUP, this);
  1448. g_qeglobals.d_hwndGroup = g_pGroupDlg->GetSafeHwnd();
  1449. ::SetParent(g_qeglobals.d_hwndGroup, g_qeglobals.d_hwndEntity);
  1450. g_pGroupDlg->ShowWindow(SW_SHOW);
  1451. if (!LoadWindowPlacement(GetSafeHwnd(), "Radiant::MainWindowPlace"))
  1452. {
  1453. LoadWindowState(GetSafeHwnd(), "Radiant::MainWindow");
  1454. }
  1455. //if (m_nCurrentStyle == QR_QE4)
  1456. // LoadWindowPlacement(g_qeglobals.d_hwndEntity, "EntityWindowPlace");
  1457. CRect rect(5,25, 100, 100);
  1458. CRect rctParent;
  1459. GetClientRect(rctParent);
  1460. if (g_PrefsDlg.m_nView == 0 || g_PrefsDlg.m_nView == 3)
  1461. {
  1462. m_wndSplit.CreateStatic(this, 2, 1);
  1463. m_wndSplit2.CreateStatic(&m_wndSplit, 1, 3);
  1464. m_wndSplit3.CreateStatic(&m_wndSplit2, 2,1);
  1465. m_wndSplit.CreateView(1,0,RUNTIME_CLASS(CEditWnd), CSize(25, 100), pContext);
  1466. g_pEdit = dynamic_cast<CEdit*>(m_wndSplit.GetPane(1,0));
  1467. if (g_pEdit)
  1468. g_qeglobals.d_hwndEdit = g_pEdit->GetSafeHwnd();
  1469. m_wndSplit3.CreateView(0,0,RUNTIME_CLASS(CCamWnd), CSize(25, 100), pContext);
  1470. m_pCamWnd = dynamic_cast<CCamWnd*>(m_wndSplit3.GetPane(0,0));
  1471. m_wndSplit2.CreateView(0,1,RUNTIME_CLASS(CXYWnd), CSize(25, 100), pContext);
  1472. m_pXYWnd = dynamic_cast<CXYWnd*>(m_wndSplit2.GetPane(0,1));
  1473. m_pXYWnd->SetViewType(XY);
  1474. m_pCamWnd->SetXYFriend(m_pXYWnd);
  1475. m_wndSplit2.CreateView(0,2,RUNTIME_CLASS(CZWnd), CSize(25, 100), pContext);
  1476. m_pZWnd = dynamic_cast<CZWnd*>(m_wndSplit2.GetPane(0,2));
  1477. m_wndSplit3.CreateView(1,0,RUNTIME_CLASS(CTexWnd), CSize(25, 100), pContext);
  1478. m_pTexWnd = dynamic_cast<CTexWnd*>(m_wndSplit3.GetPane(1,0));
  1479. CreateQEChildren();
  1480. if (g_PrefsDlg.m_nView == 0)
  1481. {
  1482. // the following bit switches the left and right views
  1483. CWnd* pRight = m_wndSplit2.GetPane(0,2);
  1484. long lRightID = ::GetWindowLong(pRight->GetSafeHwnd(), GWL_ID);
  1485. long lLeftID = ::GetWindowLong(m_wndSplit3.GetSafeHwnd(), GWL_ID);
  1486. ::SetWindowLong(pRight->GetSafeHwnd(), GWL_ID, lLeftID);
  1487. ::SetWindowLong(m_wndSplit3.GetSafeHwnd(), GWL_ID, lRightID);
  1488. }
  1489. m_wndSplit.SetRowInfo(0, rctParent.Height() * .85, 50);
  1490. m_wndSplit.SetRowInfo(1, rctParent.Height() * .15, 5);
  1491. float fLeft = (g_PrefsDlg.m_nView == 0) ? .05 : .25;
  1492. float fRight = (g_PrefsDlg.m_nView == 0) ? .25 : .05;
  1493. int nMin1 = (g_PrefsDlg.m_nView == 0) ? 10 : 25;
  1494. int nMin2 = (nMin1 == 10) ? 25 : 10;
  1495. m_wndSplit2.SetColumnInfo(0, rctParent.Width() * fLeft, nMin1);
  1496. m_wndSplit2.SetColumnInfo(1, rctParent.Width() * .70, 100);
  1497. m_wndSplit2.SetColumnInfo(2, rctParent.Width() * fRight, nMin2);
  1498. m_wndSplit3.SetRowInfo(1, (rctParent.Height() * .85) * .40, 15);
  1499. m_wndSplit3.SetRowInfo(0, (rctParent.Height() * .85) * .60, 15);
  1500. LoadWindowState(m_wndSplit.GetSafeHwnd(), "Radiant::Split");
  1501. LoadWindowState(m_wndSplit2.GetSafeHwnd(), "Radiant::Split2");
  1502. LoadWindowState(m_wndSplit3.GetSafeHwnd(), "Radiant::Split3");
  1503. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_HIDE);
  1504. SplitInfo spinfo;
  1505. long lSize = sizeof(spinfo);
  1506. if (LoadRegistryInfo("Radiant::Split::Row_0", &spinfo, &lSize))
  1507. m_wndSplit.SetRowInfo(0, spinfo.m_nCur, spinfo.m_nMin);
  1508. if (LoadRegistryInfo("Radiant::Split::Row_1", &spinfo, &lSize))
  1509. m_wndSplit.SetRowInfo(1, spinfo.m_nCur, spinfo.m_nMin);
  1510. if (LoadRegistryInfo("Radiant::Split2::Col_0", &spinfo, &lSize))
  1511. m_wndSplit2.SetColumnInfo(0, spinfo.m_nCur, spinfo.m_nMin);
  1512. if (LoadRegistryInfo("Radiant::Split2::Col_1", &spinfo, &lSize))
  1513. m_wndSplit2.SetColumnInfo(1, spinfo.m_nCur, spinfo.m_nMin);
  1514. if (LoadRegistryInfo("Radiant::Split2::Col_2", &spinfo, &lSize))
  1515. m_wndSplit2.SetColumnInfo(2, spinfo.m_nCur, spinfo.m_nMin);
  1516. if (LoadRegistryInfo("Radiant::Split3::Row_0", &spinfo, &lSize))
  1517. m_wndSplit3.SetRowInfo(0, spinfo.m_nCur, spinfo.m_nMin);
  1518. if (LoadRegistryInfo("Radiant::Split3::Row_1", &spinfo, &lSize))
  1519. m_wndSplit3.SetRowInfo(1, spinfo.m_nCur, spinfo.m_nMin);
  1520. m_wndSplit.RecalcLayout();
  1521. m_wndSplit2.RecalcLayout();
  1522. m_wndSplit3.RecalcLayout();
  1523. }
  1524. else if (g_PrefsDlg.m_nView == 1)
  1525. {
  1526. m_pCamWnd = new CCamWnd();
  1527. m_pCamWnd->Create(CAMERA_WINDOW_CLASS, "", QE3_CHILDSTYLE, rect, this, 1234);
  1528. m_pZWnd = new CZWnd();
  1529. m_pZWnd->Create(Z_WINDOW_CLASS, "", QE3_CHILDSTYLE, rect, this, 1238);
  1530. m_pXYWnd = new CXYWnd();
  1531. m_pXYWnd->Create(XY_WINDOW_CLASS, "", QE3_CHILDSTYLE, rect, this, 1235);
  1532. m_pXYWnd->SetViewType(XY);
  1533. m_pXZWnd = new CXYWnd();
  1534. m_pXZWnd->Create(XY_WINDOW_CLASS, "", QE3_CHILDSTYLE, rect, this, 1236);
  1535. m_pXZWnd->SetViewType(XZ);
  1536. m_pYZWnd = new CXYWnd();
  1537. m_pYZWnd->Create(XY_WINDOW_CLASS, "", QE3_CHILDSTYLE, rect, this, 1237);
  1538. m_pYZWnd->SetViewType(YZ);
  1539. m_pCamWnd->SetXYFriend(m_pXYWnd);
  1540. m_pTexWnd = new CTexWnd();
  1541. m_pTexWnd->Create(TEXTURE_WINDOW_CLASS, "", QE3_SPLITTER_STYLE, rect, this, 1239);
  1542. ::SetParent(m_pTexWnd->GetSafeHwnd(), g_qeglobals.d_hwndEntity);
  1543. CRect rctWork;
  1544. // XY and Z windows are 2 pixels off of the height and one down from top so one pixel spacing vertically
  1545. // Z window takes up 10% of right edge
  1546. // XY window takes up 60% of middle
  1547. // TEX and CAM windows take up 30% of left
  1548. #if 0
  1549. int xTex = 1;
  1550. int xXY = 1 + xTex + ((float)rctParent.Width()) * .30;
  1551. int xZ = 1 + xXY + ((float)rctParent.Width()) * .60;
  1552. int yXY = 1;
  1553. int yTex = 1 + ((float)rctParent.Height()) * .45;
  1554. m_pXYWnd->SetWindowPos(NULL, xXY, yXY, ((float)rctParent.Width()) * .60, rctParent.Height() - 2, SWP_SHOWWINDOW);
  1555. m_pXZWnd->SetWindowPos(NULL, xXY, yXY, ((float)rctParent.Width()) * .60, rctParent.Height() - 2, SWP_SHOWWINDOW);
  1556. m_pYZWnd->SetWindowPos(NULL, xXY, yXY, ((float)rctParent.Width()) * .60, rctParent.Height() - 2, SWP_SHOWWINDOW);
  1557. m_pCamWnd->SetWindowPos(NULL, xTex, yXY, ((float)rctParent.Width()) *.30, ((float)rctParent.Height()) * .45, SWP_SHOWWINDOW);
  1558. m_pTexWnd->SetWindowPos(NULL, xTex, yTex, ((float)rctParent.Width()) *.30, ((float)rctParent.Height()) * .45, SWP_SHOWWINDOW);
  1559. #endif
  1560. LoadWindowPlacement(m_pXYWnd->GetSafeHwnd(), "xywindow");
  1561. LoadWindowPlacement(m_pXZWnd->GetSafeHwnd(), "xzwindow");
  1562. LoadWindowPlacement(m_pYZWnd->GetSafeHwnd(), "yzwindow");
  1563. LoadWindowPlacement(m_pCamWnd->GetSafeHwnd(), "camerawindow");
  1564. LoadWindowPlacement(m_pZWnd->GetSafeHwnd(), "zwindow");
  1565. if (!g_PrefsDlg.m_bXZVis)
  1566. m_pXZWnd->ShowWindow(SW_HIDE);
  1567. if (!g_PrefsDlg.m_bYZVis)
  1568. m_pYZWnd->ShowWindow(SW_HIDE);
  1569. if (!g_PrefsDlg.m_bZVis)
  1570. m_pZWnd->ShowWindow(SW_HIDE);
  1571. CreateQEChildren();
  1572. }
  1573. else // 4 way
  1574. {
  1575. m_wndSplit.CreateStatic(this, 2, 2);
  1576. m_wndSplit.CreateView(0,0,RUNTIME_CLASS(CCamWnd), CSize(25, 100), pContext);
  1577. m_pCamWnd = dynamic_cast<CCamWnd*>(m_wndSplit.GetPane(0,0));
  1578. m_wndSplit.CreateView(0,1,RUNTIME_CLASS(CXYWnd), CSize(25, 100), pContext);
  1579. m_pXYWnd = dynamic_cast<CXYWnd*>(m_wndSplit.GetPane(0,1));
  1580. m_pXYWnd->SetViewType(XY);
  1581. m_wndSplit.CreateView(1,0,RUNTIME_CLASS(CXYWnd), CSize(25, 100), pContext);
  1582. m_pYZWnd = dynamic_cast<CXYWnd*>(m_wndSplit.GetPane(1,0));
  1583. m_pYZWnd->SetViewType(YZ);
  1584. m_wndSplit.CreateView(1,1,RUNTIME_CLASS(CXYWnd), CSize(25, 100), pContext);
  1585. m_pXZWnd = dynamic_cast<CXYWnd*>(m_wndSplit.GetPane(1,1));
  1586. m_pXZWnd->SetViewType(XZ);
  1587. m_pCamWnd->SetXYFriend(m_pXYWnd);
  1588. m_pTexWnd = new CTexWnd();
  1589. m_pTexWnd->Create(TEXTURE_WINDOW_CLASS, "", QE3_SPLITTER_STYLE, rect, this, 1237);
  1590. ::SetParent(m_pTexWnd->GetSafeHwnd(), g_qeglobals.d_hwndEntity);
  1591. m_pZWnd = new CZWnd();
  1592. m_pZWnd->Create(Z_WINDOW_CLASS, "", QE3_CHILDSTYLE, rect, this, 1236);
  1593. m_pZWnd->ShowWindow(SW_HIDE);
  1594. //m_pEditWnd = new CRADEditWnd();
  1595. //m_pEditWnd->Create(NULL, "Console", QE3_STYLE, rect, this, 1238);
  1596. //g_pEdit = m_pEditWnd->GetEditWnd();
  1597. //if (g_pEdit)
  1598. // g_qeglobals.d_hwndEdit = g_pEdit->GetSafeHwnd();
  1599. LoadWindowState(m_pTexWnd->GetSafeHwnd(), "texwindow");
  1600. LoadWindowState(m_pEditWnd->GetSafeHwnd(), "editwindow");
  1601. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_HIDE);
  1602. CreateQEChildren();
  1603. CRect rctParent;
  1604. GetClientRect(rctParent);
  1605. m_wndSplit.SetRowInfo(0, rctParent.Height() * .5, 50);
  1606. m_wndSplit.SetRowInfo(1, rctParent.Height() * .5, 50);
  1607. m_wndSplit.SetColumnInfo(0, rctParent.Width() * .5, 50);
  1608. m_wndSplit.SetColumnInfo(1, rctParent.Width() * .5, 50);
  1609. LoadWindowState(m_wndSplit.GetSafeHwnd(), "Radiant::SplitSPLIT");
  1610. m_wndSplit.RecalcLayout();
  1611. }
  1612. if (g_pEdit)
  1613. g_pEdit->SendMessage(WM_SETFONT, (WPARAM)::GetStockObject(DEFAULT_GUI_FONT), (LPARAM)TRUE);
  1614. if (m_pXYWnd)
  1615. m_pXYWnd->SetActive(true);
  1616. m_bSplittersOK = true;
  1617. Texture_SetMode(g_qeglobals.d_savedinfo.iTexMenu);
  1618. return TRUE;
  1619. }
  1620. CRect g_rctOld(0,0,0,0);
  1621. void CMainFrame::OnSize(UINT nType, int cx, int cy)
  1622. {
  1623. CFrameWnd::OnSize(nType, cx, cy);
  1624. CRect rctParent;
  1625. GetClientRect(rctParent);
  1626. UINT nID;
  1627. UINT nStyle;
  1628. int nWidth;
  1629. if (m_wndStatusBar.GetSafeHwnd())
  1630. {
  1631. m_wndStatusBar.GetPaneInfo(0, nID, nStyle, nWidth);
  1632. m_wndStatusBar.SetPaneInfo(0, nID, nStyle, rctParent.Width() * .19);
  1633. m_wndStatusBar.GetPaneInfo(1, nID, nStyle, nWidth);
  1634. m_wndStatusBar.SetPaneInfo(1, nID, nStyle, rctParent.Width() * .19);
  1635. m_wndStatusBar.GetPaneInfo(2, nID, nStyle, nWidth);
  1636. m_wndStatusBar.SetPaneInfo(2, nID, nStyle, rctParent.Width() * .19);
  1637. m_wndStatusBar.GetPaneInfo(3, nID, nStyle, nWidth);
  1638. m_wndStatusBar.SetPaneInfo(3, nID, nStyle, rctParent.Width() * .19);
  1639. m_wndStatusBar.GetPaneInfo(4, nID, nStyle, nWidth);
  1640. m_wndStatusBar.SetPaneInfo(4, nID, nStyle, rctParent.Width() * .13);
  1641. m_wndStatusBar.GetPaneInfo(5, nID, nStyle, nWidth);
  1642. m_wndStatusBar.SetPaneInfo(5, nID, nStyle, rctParent.Width() * .01);
  1643. }
  1644. if (nType == SIZE_RESTORED && m_bSplittersOK && g_rctOld.Width() > 0)
  1645. {
  1646. if (m_nCurrentStyle == 0 || m_nCurrentStyle == 3)
  1647. {
  1648. SplitInfo spinfo;
  1649. m_wndSplit.GetRowInfo(0, spinfo.m_nCur, spinfo.m_nMin);
  1650. float fpc1 = (float)spinfo.m_nCur / g_rctOld.Height();
  1651. m_wndSplit.GetRowInfo(1, spinfo.m_nCur, spinfo.m_nMin);
  1652. float fpc2 = (float)spinfo.m_nCur / g_rctOld.Height();
  1653. m_wndSplit2.GetColumnInfo(0, spinfo.m_nCur, spinfo.m_nMin);
  1654. float fpc3 = (float)spinfo.m_nCur / g_rctOld.Width();
  1655. m_wndSplit2.GetColumnInfo(1, spinfo.m_nCur, spinfo.m_nMin);
  1656. float fpc4 = (float)spinfo.m_nCur / g_rctOld.Width();
  1657. m_wndSplit2.GetColumnInfo(2, spinfo.m_nCur, spinfo.m_nMin);
  1658. float fpc5 = (float)spinfo.m_nCur / g_rctOld.Width();
  1659. m_wndSplit3.GetRowInfo(0, spinfo.m_nCur, spinfo.m_nMin);
  1660. float fpc6 = (float)spinfo.m_nCur / g_rctOld.Height();
  1661. m_wndSplit3.GetRowInfo(1, spinfo.m_nCur, spinfo.m_nMin);
  1662. float fpc7 = (float)spinfo.m_nCur / g_rctOld.Height();
  1663. m_wndSplit.SetRowInfo(0, rctParent.Height() * fpc1, 100);
  1664. m_wndSplit.SetRowInfo(1, rctParent.Height() * fpc2, 25);
  1665. int nMin1 = (m_nCurrentStyle == 0) ? 10 : 25;
  1666. int nMin2 = (nMin1 == 10) ? 25 : 10;
  1667. m_wndSplit2.SetColumnInfo(0, rctParent.Width() * fpc3, nMin1);
  1668. m_wndSplit2.SetColumnInfo(1, rctParent.Width() * fpc4, 100);
  1669. m_wndSplit2.SetColumnInfo(2, rctParent.Width() * fpc5, nMin2);
  1670. m_wndSplit3.SetRowInfo(0, rctParent.Height() * fpc6, 50);
  1671. m_wndSplit3.SetRowInfo(1, rctParent.Height() * fpc7, 50);
  1672. m_wndSplit.RecalcLayout();
  1673. m_wndSplit2.RecalcLayout();
  1674. m_wndSplit3.RecalcLayout();
  1675. }
  1676. }
  1677. }
  1678. void OpenDialog (void);
  1679. void SaveAsDialog (bool bRegion);
  1680. void Select_Ungroup (void);
  1681. void CMainFrame::ToggleCamera()
  1682. {
  1683. if (m_bCamPreview)
  1684. m_bCamPreview = false;
  1685. else
  1686. m_bCamPreview = true;
  1687. }
  1688. void CMainFrame::OnFileClose()
  1689. {
  1690. }
  1691. void CMainFrame::OnFileExit()
  1692. {
  1693. PostMessage (WM_CLOSE, 0, 0L);
  1694. }
  1695. void CMainFrame::OnFileLoadproject()
  1696. {
  1697. if (ConfirmModified())
  1698. ProjectDialog ();
  1699. }
  1700. void CMainFrame::OnFileNew()
  1701. {
  1702. if (ConfirmModified())
  1703. Map_New ();
  1704. }
  1705. void CMainFrame::OnFileOpen()
  1706. {
  1707. if (ConfirmModified())
  1708. OpenDialog ();
  1709. }
  1710. void CMainFrame::OnFilePointfile()
  1711. {
  1712. if (g_qeglobals.d_pointfile_display_list)
  1713. Pointfile_Clear ();
  1714. else
  1715. Pointfile_Check ();
  1716. }
  1717. void CMainFrame::OnFilePrint()
  1718. {
  1719. }
  1720. void CMainFrame::OnFilePrintPreview()
  1721. {
  1722. }
  1723. void CMainFrame::OnFileSave()
  1724. {
  1725. if (!strcmp(currentmap, "unnamed.map"))
  1726. {
  1727. SaveAsDialog (false);
  1728. }
  1729. else
  1730. {
  1731. Map_SaveFile (currentmap, false);
  1732. }
  1733. }
  1734. void CMainFrame::OnFileSaveas()
  1735. {
  1736. SaveAsDialog(false);
  1737. }
  1738. void CMainFrame::OnView100()
  1739. {
  1740. if (m_pXYWnd)
  1741. m_pXYWnd->SetScale(1);
  1742. if (m_pXZWnd)
  1743. m_pXZWnd->SetScale(1);
  1744. if (m_pYZWnd)
  1745. m_pYZWnd->SetScale(1);
  1746. Sys_UpdateWindows (W_XY|W_XY_OVERLAY);
  1747. }
  1748. void CMainFrame::OnViewCenter()
  1749. {
  1750. m_pCamWnd->Camera().angles[ROLL] = m_pCamWnd->Camera().angles[PITCH] = 0;
  1751. m_pCamWnd->Camera().angles[YAW] = 22.5 *
  1752. floor( (m_pCamWnd->Camera().angles[YAW]+11)/22.5 );
  1753. Sys_UpdateWindows (W_CAMERA | W_XY_OVERLAY);
  1754. }
  1755. void CMainFrame::OnViewConsole()
  1756. {
  1757. if (m_nCurrentStyle > 0 && m_nCurrentStyle < 3) // QE4 style
  1758. {
  1759. if (inspector_mode == W_CONSOLE && m_nCurrentStyle != QR_QE4) // are we in console mode already?
  1760. {
  1761. if (::IsWindowVisible(g_qeglobals.d_hwndEntity))
  1762. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_HIDE);
  1763. else
  1764. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_NORMAL);
  1765. }
  1766. else
  1767. {
  1768. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_NORMAL);
  1769. SetInspectorMode(W_CONSOLE);
  1770. }
  1771. }
  1772. }
  1773. void CMainFrame::OnViewDownfloor()
  1774. {
  1775. m_pCamWnd->Cam_ChangeFloor (false);
  1776. }
  1777. void CMainFrame::OnViewEntity()
  1778. {
  1779. if (m_nCurrentStyle == 0 || m_nCurrentStyle == 3)
  1780. {
  1781. if (::IsWindowVisible(g_qeglobals.d_hwndEntity) && inspector_mode == W_ENTITY)
  1782. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_HIDE);
  1783. else
  1784. {
  1785. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_NORMAL);
  1786. SetInspectorMode(W_ENTITY);
  1787. }
  1788. }
  1789. else
  1790. {
  1791. if (inspector_mode == W_ENTITY && m_nCurrentStyle != QR_QE4)
  1792. {
  1793. if (::IsWindowVisible(g_qeglobals.d_hwndEntity))
  1794. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_HIDE);
  1795. else
  1796. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_NORMAL);
  1797. }
  1798. else
  1799. {
  1800. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_NORMAL);
  1801. SetInspectorMode(W_ENTITY);
  1802. }
  1803. }
  1804. }
  1805. void CMainFrame::OnViewFront()
  1806. {
  1807. if (m_nCurrentStyle != 2)
  1808. {
  1809. m_pXYWnd->SetViewType(YZ);
  1810. m_pXYWnd->PositionView();
  1811. }
  1812. Sys_UpdateWindows (W_XY);
  1813. }
  1814. void CMainFrame::OnMru(unsigned int nID)
  1815. {
  1816. DoMru(GetSafeHwnd(),nID);
  1817. }
  1818. void CMainFrame::OnViewNearest(unsigned int nID)
  1819. {
  1820. Texture_SetMode(nID);
  1821. }
  1822. void CMainFrame::OnTextureWad(unsigned int nID)
  1823. {
  1824. Sys_BeginWait ();
  1825. Texture_ShowDirectory (nID);
  1826. Sys_UpdateWindows (W_ALL);
  1827. }
  1828. void CMainFrame::OnBspCommand(unsigned int nID)
  1829. {
  1830. if (g_PrefsDlg.m_bSnapShots && stricmp(currentmap, "unnamed.map") != 0)
  1831. Map_Snapshot();
  1832. if (g_qeglobals.bBSPFrontendPlugin)
  1833. {
  1834. CString foo = g_BSPFrontendCommands.GetAt(nID-CMD_BSPCOMMAND);
  1835. g_BSPFrontendTable.m_pfnDispatchBSPCommand( foo.GetBuffer(0) );
  1836. }
  1837. else
  1838. {
  1839. RunBsp (bsp_commands[LOWORD(nID-CMD_BSPCOMMAND)]);
  1840. }
  1841. }
  1842. void CMainFrame::OnViewShowblocks()
  1843. {
  1844. g_qeglobals.show_blocks ^= 1;
  1845. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWBLOCKS, MF_BYCOMMAND | (g_qeglobals.show_blocks ? MF_CHECKED : MF_UNCHECKED) );
  1846. Sys_UpdateWindows (W_XY);
  1847. }
  1848. void CMainFrame::OnViewShowclip()
  1849. {
  1850. if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_CLIP ) & EXCLUDE_CLIP )
  1851. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCLIP, MF_BYCOMMAND | MF_UNCHECKED );
  1852. else
  1853. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCLIP, MF_BYCOMMAND | MF_CHECKED );
  1854. Sys_UpdateWindows (W_XY|W_CAMERA);
  1855. }
  1856. void CMainFrame::OnViewShowcoordinates()
  1857. {
  1858. g_qeglobals.d_savedinfo.show_coordinates ^= 1;
  1859. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCOORDINATES, MF_BYCOMMAND | (g_qeglobals.d_savedinfo.show_coordinates ? MF_CHECKED : MF_UNCHECKED) );
  1860. Sys_UpdateWindows (W_XY);
  1861. }
  1862. void CMainFrame::OnViewShowdetail()
  1863. {
  1864. if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_DETAIL ) & EXCLUDE_DETAIL )
  1865. {
  1866. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWDETAIL, MF_BYCOMMAND | MF_UNCHECKED );
  1867. ::SetWindowText (g_qeglobals.d_hwndCamera, "Camera View (DETAIL EXCLUDED)");
  1868. }
  1869. else
  1870. {
  1871. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWDETAIL, MF_BYCOMMAND | MF_CHECKED );
  1872. ::SetWindowText (g_qeglobals.d_hwndCamera, "Camera View");
  1873. }
  1874. Sys_UpdateWindows (W_XY|W_CAMERA);
  1875. }
  1876. void CMainFrame::OnViewShowent()
  1877. {
  1878. if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_ENT ) & EXCLUDE_ENT )
  1879. CheckMenuItem( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWENT, MF_BYCOMMAND | MF_UNCHECKED);
  1880. else
  1881. CheckMenuItem( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWENT, MF_BYCOMMAND | MF_CHECKED);
  1882. Sys_UpdateWindows (W_XY|W_CAMERA);
  1883. }
  1884. void CMainFrame::OnViewShowlights()
  1885. {
  1886. if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_LIGHTS ) & EXCLUDE_LIGHTS )
  1887. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWLIGHTS, MF_BYCOMMAND | MF_UNCHECKED );
  1888. else
  1889. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWLIGHTS, MF_BYCOMMAND | MF_CHECKED );
  1890. Sys_UpdateWindows (W_XY|W_CAMERA);
  1891. }
  1892. void CMainFrame::OnViewShownames()
  1893. {
  1894. g_qeglobals.d_savedinfo.show_names = !g_qeglobals.d_savedinfo.show_names;
  1895. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWNAMES, MF_BYCOMMAND | (g_qeglobals.d_savedinfo.show_names ? MF_CHECKED : MF_UNCHECKED) );
  1896. Map_BuildBrushData();
  1897. Sys_UpdateWindows (W_XY);
  1898. }
  1899. void CMainFrame::OnViewShowpath()
  1900. {
  1901. if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_PATHS ) & EXCLUDE_PATHS )
  1902. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWPATH, MF_BYCOMMAND | MF_UNCHECKED );
  1903. else
  1904. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWPATH, MF_BYCOMMAND | MF_CHECKED );
  1905. Sys_UpdateWindows (W_XY|W_CAMERA);
  1906. }
  1907. void CMainFrame::OnViewShowwater()
  1908. {
  1909. if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_WATER ) & EXCLUDE_WATER )
  1910. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWWATER, MF_BYCOMMAND | MF_UNCHECKED );
  1911. else
  1912. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWWATER, MF_BYCOMMAND | MF_CHECKED );
  1913. Sys_UpdateWindows (W_XY|W_CAMERA);
  1914. }
  1915. void CMainFrame::OnViewShowworld()
  1916. {
  1917. if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_WORLD ) & EXCLUDE_WORLD )
  1918. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWWORLD, MF_BYCOMMAND | MF_UNCHECKED );
  1919. else
  1920. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWWORLD, MF_BYCOMMAND | MF_CHECKED );
  1921. Sys_UpdateWindows (W_XY|W_CAMERA);
  1922. }
  1923. void CMainFrame::OnViewTexture()
  1924. {
  1925. if (m_nCurrentStyle > 0 && m_nCurrentStyle < 3) // QE4 style
  1926. {
  1927. if (inspector_mode == W_TEXTURE && m_nCurrentStyle != QR_QE4) // are we in console mode already?
  1928. {
  1929. if (::IsWindowVisible(g_qeglobals.d_hwndEntity))
  1930. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_HIDE);
  1931. else
  1932. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_SHOW);
  1933. }
  1934. else
  1935. {
  1936. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_SHOW);
  1937. SetInspectorMode(W_TEXTURE);
  1938. }
  1939. }
  1940. }
  1941. void CMainFrame::OnViewUpfloor()
  1942. {
  1943. m_pCamWnd->Cam_ChangeFloor (true);
  1944. }
  1945. void CMainFrame::OnViewXy()
  1946. {
  1947. if (m_nCurrentStyle != 2)
  1948. {
  1949. m_pXYWnd->SetViewType(XY);
  1950. m_pXYWnd->PositionView();
  1951. }
  1952. Sys_UpdateWindows (W_XY);
  1953. }
  1954. void CMainFrame::OnViewZ100()
  1955. {
  1956. z.scale = 1;
  1957. Sys_UpdateWindows (W_Z|W_Z_OVERLAY);
  1958. }
  1959. void CMainFrame::OnViewZoomin()
  1960. {
  1961. if (m_pXYWnd && m_pXYWnd->Active())
  1962. {
  1963. m_pXYWnd->SetScale(m_pXYWnd->Scale() * 5.0 / 4);
  1964. if (m_pXYWnd->Scale() > 20)
  1965. m_pXYWnd->SetScale(20);
  1966. }
  1967. if (m_pXZWnd && m_pXZWnd->Active())
  1968. {
  1969. m_pXZWnd->SetScale(m_pXZWnd->Scale() * 5.0 / 4);
  1970. if (m_pXZWnd->Scale() > 20)
  1971. m_pXZWnd->SetScale(20);
  1972. }
  1973. if (m_pYZWnd && m_pYZWnd->Active())
  1974. {
  1975. m_pYZWnd->SetScale(m_pYZWnd->Scale() * 5.0 / 4);
  1976. if (m_pYZWnd->Scale() > 20)
  1977. m_pYZWnd->SetScale(20);
  1978. }
  1979. Sys_UpdateWindows (W_XY|W_XY_OVERLAY);
  1980. }
  1981. void CMainFrame::OnViewZoomout()
  1982. {
  1983. if (m_pXYWnd && m_pXYWnd->Active())
  1984. {
  1985. m_pXYWnd->SetScale(m_pXYWnd->Scale() * 4.0 / 5);
  1986. if (m_pXYWnd->Scale() < 0.1 / 32)
  1987. m_pXYWnd->SetScale(0.1 /32);
  1988. }
  1989. if (m_pXZWnd && m_pXZWnd->Active())
  1990. {
  1991. m_pXZWnd->SetScale(m_pXZWnd->Scale() * 4.0 / 5);
  1992. if (m_pXZWnd->Scale() < 0.1 / 32)
  1993. m_pXZWnd->SetScale(0.1 / 32);
  1994. }
  1995. if (m_pYZWnd && m_pYZWnd->Active())
  1996. {
  1997. m_pYZWnd->SetScale(m_pYZWnd->Scale() * 4.0 / 5);
  1998. if (m_pYZWnd->Scale() < 0.1 / 32)
  1999. m_pYZWnd->SetScale(0.1 / 32);
  2000. }
  2001. Sys_UpdateWindows (W_XY|W_XY_OVERLAY);
  2002. }
  2003. void CMainFrame::OnViewZzoomin()
  2004. {
  2005. z.scale *= 5.0/4;
  2006. if (z.scale > 4)
  2007. z.scale = 4;
  2008. Sys_UpdateWindows (W_Z|W_Z_OVERLAY);
  2009. }
  2010. void CMainFrame::OnViewZzoomout()
  2011. {
  2012. z.scale *= 4.0/5;
  2013. if (z.scale < 0.125)
  2014. z.scale = 0.125;
  2015. Sys_UpdateWindows (W_Z|W_Z_OVERLAY);
  2016. }
  2017. void CMainFrame::OnViewSide()
  2018. {
  2019. if (m_nCurrentStyle != 2)
  2020. {
  2021. m_pXYWnd->SetViewType(XZ);
  2022. m_pXYWnd->PositionView();
  2023. }
  2024. Sys_UpdateWindows (W_XY);
  2025. }
  2026. void CMainFrame::OnGrid1(unsigned int nID)
  2027. {
  2028. HMENU hMenu = ::GetMenu(GetSafeHwnd());
  2029. CheckMenuItem(hMenu, ID_GRID_1, MF_BYCOMMAND | MF_UNCHECKED);
  2030. CheckMenuItem(hMenu, ID_GRID_2, MF_BYCOMMAND | MF_UNCHECKED);
  2031. CheckMenuItem(hMenu, ID_GRID_4, MF_BYCOMMAND | MF_UNCHECKED);
  2032. CheckMenuItem(hMenu, ID_GRID_8, MF_BYCOMMAND | MF_UNCHECKED);
  2033. CheckMenuItem(hMenu, ID_GRID_16, MF_BYCOMMAND | MF_UNCHECKED);
  2034. CheckMenuItem(hMenu, ID_GRID_32, MF_BYCOMMAND | MF_UNCHECKED);
  2035. CheckMenuItem(hMenu, ID_GRID_64, MF_BYCOMMAND | MF_UNCHECKED);
  2036. switch (nID)
  2037. {
  2038. case ID_GRID_1: g_qeglobals.d_gridsize = 0; break;
  2039. case ID_GRID_2: g_qeglobals.d_gridsize = 1; break;
  2040. case ID_GRID_4: g_qeglobals.d_gridsize = 2; break;
  2041. case ID_GRID_8: g_qeglobals.d_gridsize = 3; break;
  2042. case ID_GRID_16: g_qeglobals.d_gridsize = 4; break;
  2043. case ID_GRID_32: g_qeglobals.d_gridsize = 5; break;
  2044. case ID_GRID_64: g_qeglobals.d_gridsize = 6; break;
  2045. }
  2046. g_qeglobals.d_gridsize = 1 << g_qeglobals.d_gridsize;
  2047. if (g_PrefsDlg.m_bSnapTToGrid)
  2048. g_qeglobals.d_savedinfo.m_nTextureTweak = g_qeglobals.d_gridsize;
  2049. SetGridStatus();
  2050. CheckMenuItem(hMenu, nID, MF_BYCOMMAND | MF_CHECKED);
  2051. Sys_UpdateWindows (W_XY|W_Z);
  2052. }
  2053. void CMainFrame::OnTexturesShowinuse()
  2054. {
  2055. Sys_BeginWait ();
  2056. Texture_ShowInuse ();
  2057. if (m_pTexWnd)
  2058. {
  2059. m_pTexWnd->RedrawWindow();
  2060. }
  2061. }
  2062. //from TexWnd.cpp
  2063. extern qboolean texture_showinuse;
  2064. void CMainFrame::OnUpdateTexturesShowinuse(CCmdUI* pCmdUI)
  2065. {
  2066. pCmdUI->SetCheck(texture_showinuse);
  2067. }
  2068. void CMainFrame::OnTexturesInspector()
  2069. {
  2070. DoSurface ();
  2071. }
  2072. void CMainFrame::OnMiscBenchmark()
  2073. {
  2074. m_pCamWnd->BenchMark();
  2075. }
  2076. void CMainFrame::OnMiscFindbrush()
  2077. {
  2078. DoFind();
  2079. }
  2080. void CMainFrame::OnMiscGamma()
  2081. {
  2082. float fSave = g_qeglobals.d_savedinfo.fGamma;
  2083. DoGamma();
  2084. if (fSave != g_qeglobals.d_savedinfo.fGamma)
  2085. {
  2086. MessageBox("You must restart Q3Radiant for Gamma settings to take place");
  2087. }
  2088. }
  2089. void CMainFrame::OnMiscNextleakspot()
  2090. {
  2091. Pointfile_Next();
  2092. }
  2093. void CMainFrame::OnMiscPreviousleakspot()
  2094. {
  2095. Pointfile_Prev();
  2096. }
  2097. void CMainFrame::OnMiscPrintxy()
  2098. {
  2099. WXY_Print();
  2100. }
  2101. void CMainFrame::OnMiscSelectentitycolor()
  2102. {
  2103. if (edit_entity)
  2104. {
  2105. CString strColor = ValueForKey(edit_entity, "_color");
  2106. if (strColor.GetLength() > 0)
  2107. {
  2108. float fR, fG, fB;
  2109. int n = sscanf(strColor,"%f %f %f", &fR, &fG, &fB);
  2110. if (n == 3)
  2111. {
  2112. g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][0] = fR;
  2113. g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][1] = fG;
  2114. g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][2] = fB;
  2115. }
  2116. }
  2117. if (inspector_mode == W_ENTITY && (DoColor(COLOR_ENTITY)))
  2118. {
  2119. char buffer[100];
  2120. sprintf(buffer, "%f %f %f", g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][0],
  2121. g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][1],
  2122. g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][2]);
  2123. ::SetWindowText( hwndEnt[EntValueField], buffer );
  2124. ::SetWindowText( hwndEnt[EntKeyField], "_color" );
  2125. AddProp();
  2126. //DK - SOF change to get color to entity quickly
  2127. //--::SetWindowText( hwndEnt[EntValueField], buffer );
  2128. //-- ::SetWindowText( hwndEnt[EntKeyField], "color" );
  2129. //-- AddProp();
  2130. }
  2131. Sys_UpdateWindows( W_ALL );
  2132. }
  2133. }
  2134. void CMainFrame::OnTexturebk()
  2135. {
  2136. DoColor(COLOR_TEXTUREBACK);
  2137. Sys_UpdateWindows (W_ALL);
  2138. }
  2139. void CMainFrame::OnColorsMajor()
  2140. {
  2141. DoColor(COLOR_GRIDMAJOR);
  2142. Sys_UpdateWindows (W_ALL);
  2143. }
  2144. void CMainFrame::OnColorsMinor()
  2145. {
  2146. DoColor(COLOR_GRIDMINOR);
  2147. Sys_UpdateWindows (W_ALL);
  2148. }
  2149. void CMainFrame::OnColorsXybk()
  2150. {
  2151. DoColor(COLOR_GRIDBACK);
  2152. Sys_UpdateWindows (W_ALL);
  2153. }
  2154. void CMainFrame::OnBrush3sided()
  2155. {
  2156. Undo_Start("3 sided");
  2157. Undo_AddBrushList(&selected_brushes);
  2158. Brush_MakeSided(3);
  2159. Undo_EndBrushList(&selected_brushes);
  2160. Undo_End();
  2161. }
  2162. void CMainFrame::OnBrush4sided()
  2163. {
  2164. Undo_Start("4 sided");
  2165. Undo_AddBrushList(&selected_brushes);
  2166. Brush_MakeSided(4);
  2167. Undo_EndBrushList(&selected_brushes);
  2168. Undo_End();
  2169. }
  2170. void CMainFrame::OnBrush5sided()
  2171. {
  2172. Undo_Start("5 sided");
  2173. Undo_AddBrushList(&selected_brushes);
  2174. Brush_MakeSided(5);
  2175. Undo_EndBrushList(&selected_brushes);
  2176. Undo_End();
  2177. }
  2178. void CMainFrame::OnBrush6sided()
  2179. {
  2180. Undo_Start("6 sided");
  2181. Undo_AddBrushList(&selected_brushes);
  2182. Brush_MakeSided(6);
  2183. Undo_EndBrushList(&selected_brushes);
  2184. Undo_End();
  2185. }
  2186. void CMainFrame::OnBrush7sided()
  2187. {
  2188. Undo_Start("7 sided");
  2189. Undo_AddBrushList(&selected_brushes);
  2190. Brush_MakeSided(7);
  2191. Undo_EndBrushList(&selected_brushes);
  2192. Undo_End();
  2193. }
  2194. void CMainFrame::OnBrush8sided()
  2195. {
  2196. Undo_Start("8 sided");
  2197. Undo_AddBrushList(&selected_brushes);
  2198. Brush_MakeSided(8);
  2199. Undo_EndBrushList(&selected_brushes);
  2200. Undo_End();
  2201. }
  2202. void CMainFrame::OnBrush9sided()
  2203. {
  2204. Undo_Start("9 sided");
  2205. Undo_AddBrushList(&selected_brushes);
  2206. Brush_MakeSided(9);
  2207. Undo_EndBrushList(&selected_brushes);
  2208. Undo_End();
  2209. }
  2210. void CMainFrame::OnBrushArbitrarysided()
  2211. {
  2212. Undo_Start("arbitrary sided");
  2213. Undo_AddBrushList(&selected_brushes);
  2214. DoSides();
  2215. Undo_EndBrushList(&selected_brushes);
  2216. Undo_End();
  2217. }
  2218. void CMainFrame::OnBrushFlipx()
  2219. {
  2220. Undo_Start("flip X");
  2221. Undo_AddBrushList(&selected_brushes);
  2222. Select_FlipAxis (0);
  2223. for (brush_t *b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
  2224. {
  2225. if(b->owner->eclass->fixedsize)
  2226. {
  2227. char buf[16];
  2228. float a = FloatForKey(b->owner, "angle");
  2229. a = div( ( 180 - a ) , 180 ).rem;
  2230. SetKeyValue(b->owner, "angle", itoa(a, buf, 10));
  2231. Brush_Build(b);
  2232. }
  2233. }
  2234. Undo_EndBrushList(&selected_brushes);
  2235. Undo_End();
  2236. }
  2237. void CMainFrame::OnBrushFlipy()
  2238. {
  2239. Undo_Start("flip Y");
  2240. Undo_AddBrushList(&selected_brushes);
  2241. Select_FlipAxis (1);
  2242. for (brush_t *b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
  2243. {
  2244. if(b->owner->eclass->fixedsize)
  2245. {
  2246. float a = FloatForKey(b->owner, "angle");
  2247. if (a == 0 || a == 180 || a == 360)
  2248. continue;
  2249. if ( a == 90 || a == 270)
  2250. {
  2251. a += 180;
  2252. }
  2253. else if (a > 270)
  2254. a += 90;
  2255. else if (a > 180)
  2256. a -= 90;
  2257. else if (a > 90)
  2258. a += 90;
  2259. else
  2260. a -= 90;
  2261. a = (int)a % 360;
  2262. char buf[16];
  2263. SetKeyValue(b->owner, "angle", itoa(a, buf, 10));
  2264. Brush_Build(b);
  2265. }
  2266. }
  2267. Undo_EndBrushList(&selected_brushes);
  2268. Undo_End();
  2269. }
  2270. void CMainFrame::OnBrushFlipz()
  2271. {
  2272. Undo_Start("flip Z");
  2273. Undo_AddBrushList(&selected_brushes);
  2274. Select_FlipAxis (2);
  2275. Undo_EndBrushList(&selected_brushes);
  2276. Undo_End();
  2277. }
  2278. void CMainFrame::OnBrushRotatex()
  2279. {
  2280. Undo_Start("rotate X");
  2281. Undo_AddBrushList(&selected_brushes);
  2282. Select_RotateAxis (0, 90);
  2283. Undo_EndBrushList(&selected_brushes);
  2284. Undo_End();
  2285. }
  2286. void CMainFrame::OnBrushRotatey()
  2287. {
  2288. Undo_Start("rotate Y");
  2289. Undo_AddBrushList(&selected_brushes);
  2290. Select_RotateAxis (1, 90);
  2291. Undo_EndBrushList(&selected_brushes);
  2292. Undo_End();
  2293. }
  2294. void CMainFrame::OnBrushRotatez()
  2295. {
  2296. Undo_Start("rotate Z");
  2297. Undo_AddBrushList(&selected_brushes);
  2298. Select_RotateAxis (2, 90);
  2299. Undo_EndBrushList(&selected_brushes);
  2300. Undo_End();
  2301. }
  2302. void CMainFrame::OnRegionOff()
  2303. {
  2304. Map_RegionOff ();
  2305. }
  2306. void CMainFrame::OnRegionSetbrush()
  2307. {
  2308. Map_RegionBrush ();
  2309. }
  2310. void CMainFrame::OnRegionSetselection()
  2311. {
  2312. Map_RegionSelectedBrushes ();
  2313. }
  2314. void CMainFrame::OnRegionSettallbrush()
  2315. {
  2316. Map_RegionTallBrush ();
  2317. }
  2318. void CMainFrame::OnRegionSetxy()
  2319. {
  2320. Map_RegionXY ();
  2321. }
  2322. void CMainFrame::OnSelectionArbitraryrotation()
  2323. {
  2324. //if (ActiveXY())
  2325. // ActiveXY()->UndoCopy();
  2326. Undo_Start("arbitrary rotation");
  2327. Undo_AddBrushList(&selected_brushes);
  2328. CRotateDlg dlg;
  2329. dlg.DoModal();
  2330. //DoRotate ();
  2331. Undo_EndBrushList(&selected_brushes);
  2332. Undo_End();
  2333. }
  2334. void CMainFrame::OnSelectionClone()
  2335. {
  2336. //if (ActiveXY())
  2337. // ActiveXY()->UndoCopy();
  2338. Select_Clone();
  2339. }
  2340. void CMainFrame::OnSelectionConnect()
  2341. {
  2342. ConnectEntities();
  2343. }
  2344. void CMainFrame::OnSelectionMakehollow()
  2345. {
  2346. //if (ActiveXY())
  2347. // ActiveXY()->UndoCopy();
  2348. Undo_Start("hollow");
  2349. Undo_AddBrushList(&selected_brushes);
  2350. CSG_MakeHollow ();
  2351. Undo_EndBrushList(&selected_brushes);
  2352. Undo_End();
  2353. }
  2354. void CMainFrame::OnSelectionCsgsubtract()
  2355. {
  2356. //if (ActiveXY())
  2357. // ActiveXY()->UndoCopy();
  2358. Undo_Start("CSG subtract");
  2359. CSG_Subtract();
  2360. Undo_End();
  2361. }
  2362. void CMainFrame::OnSelectionCsgmerge()
  2363. {
  2364. //if (ActiveXY())
  2365. // ActiveXY()->UndoCopy();
  2366. Undo_Start("CSG merge");
  2367. Undo_AddBrushList(&selected_brushes);
  2368. CSG_Merge();
  2369. Undo_EndBrushList(&selected_brushes);
  2370. Undo_End();
  2371. }
  2372. void CMainFrame::OnSelectionNoOutline()
  2373. {
  2374. g_qeglobals.dontDrawSelectedOutlines ^= 1;
  2375. Sys_UpdateWindows(W_ALL);
  2376. }
  2377. void CMainFrame::OnSelectionDelete()
  2378. {
  2379. brush_t *brush;
  2380. //if (ActiveXY())
  2381. // ActiveXY()->UndoCopy();
  2382. Undo_Start("delete");
  2383. Undo_AddBrushList(&selected_brushes);
  2384. //add all deleted entities to the undo
  2385. for (brush = selected_brushes.next; brush != &selected_brushes; brush = brush->next)
  2386. {
  2387. Undo_AddEntity(brush->owner);
  2388. }
  2389. // NOTE: Select_Delete does NOT delete entities
  2390. Select_Delete();
  2391. Undo_EndBrushList(&selected_brushes);
  2392. Undo_End();
  2393. }
  2394. void CMainFrame::OnSelectionDeselect()
  2395. {
  2396. if (!ByeByeSurfaceDialog())
  2397. {
  2398. if (g_bClipMode)
  2399. OnViewClipper();
  2400. else if (g_bRotateMode)
  2401. OnSelectMouserotate();
  2402. else if (g_bScaleMode)
  2403. OnSelectMousescale();
  2404. else if (g_bPathMode)
  2405. {
  2406. if (ActiveXY())
  2407. ActiveXY()->KillPathMode();
  2408. }
  2409. else
  2410. {
  2411. if (g_qeglobals.d_select_mode == sel_curvepoint && g_qeglobals.d_num_move_points > 0)
  2412. {
  2413. g_qeglobals.d_num_move_points = 0;
  2414. Sys_UpdateWindows(W_ALL);
  2415. }
  2416. else if ( g_qeglobals.d_select_mode == sel_terrainpoint && g_qeglobals.d_numterrapoints > 0 )
  2417. {
  2418. g_qeglobals.d_numterrapoints = 0;
  2419. Sys_UpdateWindows( W_ALL );
  2420. }
  2421. else
  2422. {
  2423. Select_Deselect ();
  2424. SetStatusText(2, " ");
  2425. }
  2426. }
  2427. }
  2428. }
  2429. void CMainFrame::OnSelectionDragedges()
  2430. {
  2431. if (g_qeglobals.d_select_mode == sel_edge)
  2432. {
  2433. clearSelection();
  2434. Sys_UpdateWindows (W_ALL);
  2435. }
  2436. else
  2437. {
  2438. SetupVertexSelection ();
  2439. if (g_qeglobals.d_numpoints)
  2440. g_qeglobals.d_select_mode = sel_edge;
  2441. Sys_UpdateWindows (W_ALL);
  2442. }
  2443. }
  2444. void CMainFrame::OnSelectionDragvertecies()
  2445. {
  2446. if (g_qeglobals.d_select_mode == sel_vertex || g_qeglobals.d_select_mode == sel_curvepoint ||
  2447. g_qeglobals.d_select_mode == sel_terrainpoint )
  2448. {
  2449. clearSelection();
  2450. Sys_UpdateWindows (W_ALL);
  2451. }
  2452. else
  2453. {
  2454. //--if (QE_SingleBrush() && selected_brushes.next->patchBrush)
  2455. if ( OnlyTerrainSelected() )
  2456. {
  2457. //Terrain_Edit();
  2458. }
  2459. else if (OnlyPatchesSelected())
  2460. {
  2461. Patch_EditPatch();
  2462. }
  2463. else if ( !AnyPatchesSelected() && !AnyTerrainSelected() )
  2464. {
  2465. SetupVertexSelection ();
  2466. if (g_qeglobals.d_numpoints)
  2467. g_qeglobals.d_select_mode = sel_vertex;
  2468. }
  2469. Sys_UpdateWindows (W_ALL);
  2470. }
  2471. }
  2472. void CMainFrame::OnRaiseLowerTerrain()
  2473. {
  2474. //if ( !OnlyTerrainSelected() || ( g_qeglobals.d_select_mode == sel_terrainpoint ) )
  2475. //if ( ( g_qeglobals.d_select_mode == sel_terrainpoint ) || ( g_qeglobals.d_select_mode == sel_terraintexture ) )
  2476. if ( g_qeglobals.d_select_mode == sel_terrainpoint ) {
  2477. clearSelection();
  2478. Sys_UpdateWindows (W_ALL);
  2479. }
  2480. else if ( g_qeglobals.d_select_mode == sel_terraintexture ) {
  2481. clearSelection();
  2482. g_qeglobals.d_select_mode = sel_terrainpoint;
  2483. Sys_UpdateWindows (W_ALL);
  2484. }
  2485. else
  2486. {
  2487. //g_qeglobals.d_select_mode = sel_terrainpoint;
  2488. clearSelection();
  2489. g_qeglobals.d_select_mode = sel_terraintexture;
  2490. Sys_UpdateWindows (W_ALL);
  2491. // Terrain_Edit();
  2492. }
  2493. }
  2494. void CMainFrame::OnSelectionMakeDetail()
  2495. {
  2496. Undo_Start("make detail");
  2497. Undo_AddBrushList(&selected_brushes);
  2498. Select_MakeDetail ();
  2499. Undo_EndBrushList(&selected_brushes);
  2500. Undo_End();
  2501. }
  2502. void CMainFrame::OnSelectionMakeStructural()
  2503. {
  2504. Undo_Start("make structural");
  2505. Undo_AddBrushList(&selected_brushes);
  2506. Select_MakeStructural ();
  2507. Undo_EndBrushList(&selected_brushes);
  2508. Undo_End();
  2509. }
  2510. void CMainFrame::OnSelectionSelectcompletetall()
  2511. {
  2512. if (ActiveXY())
  2513. ActiveXY()->UndoCopy();
  2514. Select_CompleteTall ();
  2515. }
  2516. void CMainFrame::OnSelectionSelectinside()
  2517. {
  2518. Select_Inside ();
  2519. }
  2520. void CMainFrame::OnSelectionSelectpartialtall()
  2521. {
  2522. Select_PartialTall();
  2523. }
  2524. void CMainFrame::OnSelectionSelecttouching()
  2525. {
  2526. Select_Touching();
  2527. }
  2528. void CMainFrame::OnSelectionUngroupentity()
  2529. {
  2530. Select_Ungroup();
  2531. }
  2532. void CMainFrame::OnTexturesPopup()
  2533. {
  2534. HandlePopup(this, IDR_POPUP_TEXTURE);
  2535. }
  2536. void CMainFrame::OnSplinesPopup()
  2537. {
  2538. HandlePopup(this, IDR_POPUP_SPLINE);
  2539. }
  2540. void CMainFrame::OnPopupSelection()
  2541. {
  2542. HandlePopup(this, IDR_POPUP_SELECTION);
  2543. }
  2544. void CMainFrame::OnViewChange()
  2545. {
  2546. OnViewNextview();
  2547. //HandlePopup(this, IDR_POPUP_VIEW);
  2548. }
  2549. void CMainFrame::OnViewCameraupdate()
  2550. {
  2551. Sys_UpdateWindows(W_CAMERA);
  2552. }
  2553. void CMainFrame::OnUpdateViewCameraupdate(CCmdUI* pCmdUI)
  2554. {
  2555. pCmdUI->Enable(m_bCamPreview == false);
  2556. }
  2557. void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect)
  2558. {
  2559. CFrameWnd::OnSizing(fwSide, pRect);
  2560. GetClientRect(g_rctOld);
  2561. }
  2562. void CMainFrame::OnHelpAbout()
  2563. {
  2564. DoAbout();
  2565. }
  2566. void CMainFrame::OnViewClipper()
  2567. {
  2568. if (ActiveXY())
  2569. {
  2570. if (ActiveXY()->ClipMode())
  2571. {
  2572. ActiveXY()->SetClipMode(false);
  2573. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_VIEW_CLIPPER, FALSE);
  2574. }
  2575. else
  2576. {
  2577. if (ActiveXY()->RotateMode())
  2578. OnSelectMouserotate();
  2579. ActiveXY()->SetClipMode(true);
  2580. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_VIEW_CLIPPER);
  2581. }
  2582. }
  2583. }
  2584. void CMainFrame::OnCameraAngledown()
  2585. {
  2586. m_pCamWnd->Camera().angles[0] -= SPEED_TURN;
  2587. if (m_pCamWnd->Camera().angles[0] < -85)
  2588. m_pCamWnd->Camera().angles[0] = -85;
  2589. Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY);
  2590. }
  2591. void CMainFrame::OnCameraAngleup()
  2592. {
  2593. m_pCamWnd->Camera().angles[0] += SPEED_TURN;
  2594. if (m_pCamWnd->Camera().angles[0] > 85)
  2595. m_pCamWnd->Camera().angles[0] = 85;
  2596. Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY);
  2597. }
  2598. void CMainFrame::OnCameraBack()
  2599. {
  2600. VectorMA (m_pCamWnd->Camera().origin, -SPEED_MOVE, m_pCamWnd->Camera().forward, m_pCamWnd->Camera().origin);
  2601. int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);
  2602. Sys_UpdateWindows (nUpdate);
  2603. }
  2604. void CMainFrame::OnCameraDown()
  2605. {
  2606. m_pCamWnd->Camera().origin[2] -= SPEED_MOVE;
  2607. int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);
  2608. Sys_UpdateWindows (nUpdate);
  2609. }
  2610. void CMainFrame::OnCameraForward()
  2611. {
  2612. VectorMA (m_pCamWnd->Camera().origin, SPEED_MOVE, m_pCamWnd->Camera().forward, m_pCamWnd->Camera().origin);
  2613. int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);
  2614. Sys_UpdateWindows (nUpdate);
  2615. }
  2616. void CMainFrame::OnCameraLeft()
  2617. {
  2618. m_pCamWnd->Camera().angles[1] += SPEED_TURN;
  2619. int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);
  2620. Sys_UpdateWindows (nUpdate);
  2621. }
  2622. void CMainFrame::OnCameraRight()
  2623. {
  2624. m_pCamWnd->Camera().angles[1] -= SPEED_TURN;
  2625. int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);
  2626. Sys_UpdateWindows (nUpdate);
  2627. }
  2628. void CMainFrame::OnCameraStrafeleft()
  2629. {
  2630. VectorMA (m_pCamWnd->Camera().origin, -SPEED_MOVE, m_pCamWnd->Camera().right, m_pCamWnd->Camera().origin);
  2631. int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);
  2632. Sys_UpdateWindows (nUpdate);
  2633. }
  2634. void CMainFrame::OnCameraStraferight()
  2635. {
  2636. VectorMA (m_pCamWnd->Camera().origin, SPEED_MOVE, m_pCamWnd->Camera().right, m_pCamWnd->Camera().origin);
  2637. int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);
  2638. Sys_UpdateWindows (nUpdate);
  2639. }
  2640. void CMainFrame::OnCameraUp()
  2641. {
  2642. m_pCamWnd->Camera().origin[2] += SPEED_MOVE;
  2643. int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);
  2644. Sys_UpdateWindows (nUpdate);
  2645. }
  2646. void CMainFrame::OnGridToggle()
  2647. {
  2648. g_qeglobals.d_showgrid = !g_qeglobals.d_showgrid;
  2649. Sys_UpdateWindows (W_XY|W_Z);
  2650. }
  2651. void CMainFrame::OnPrefs()
  2652. {
  2653. int nView = g_PrefsDlg.m_nView;
  2654. BOOL bToolbar = g_PrefsDlg.m_bWideToolbar;
  2655. BOOL bTextureBar = g_PrefsDlg.m_bTextureBar;
  2656. BOOL bSGIOpenGL = g_PrefsDlg.m_bSGIOpenGL;
  2657. BOOL bBuggyICD = g_PrefsDlg.m_bBuggyICD;
  2658. int nShader = g_PrefsDlg.m_nShader;
  2659. g_PrefsDlg.LoadPrefs();
  2660. if (g_PrefsDlg.DoModal() == IDOK)
  2661. {
  2662. if (g_PrefsDlg.m_nView != nView || g_PrefsDlg.m_bWideToolbar != bToolbar
  2663. || g_PrefsDlg.m_bSGIOpenGL != bSGIOpenGL || g_PrefsDlg.m_bBuggyICD != bBuggyICD || nShader != g_PrefsDlg.m_nShader)
  2664. MessageBox("You need to restart Q3Radiant for the view changes to take place.");
  2665. if (m_pTexWnd)
  2666. m_pTexWnd->UpdatePrefs();
  2667. if (bTextureBar != g_PrefsDlg.m_bTextureBar)
  2668. {
  2669. if (bTextureBar) // was turned on
  2670. ShowControlBar(&m_wndTextureBar, TRUE, TRUE);
  2671. else // was turned off
  2672. ShowControlBar(&m_wndTextureBar, FALSE, TRUE);
  2673. m_wndTextureBar.Invalidate();
  2674. }
  2675. CMenu* pMenu = GetMenu();
  2676. if (pMenu)
  2677. pMenu->CheckMenuItem(ID_SNAPTOGRID, MF_BYCOMMAND | (!g_PrefsDlg.m_bNoClamp) ? MF_CHECKED : MF_UNCHECKED);
  2678. }
  2679. }
  2680. // 0 = radiant styel
  2681. // 1 = qe4 style
  2682. void CMainFrame::SetWindowStyle(int nStyle)
  2683. {
  2684. }
  2685. void CMainFrame::OnTogglecamera()
  2686. {
  2687. if (m_nCurrentStyle > 0 && m_nCurrentStyle < 3) // QE4 style
  2688. {
  2689. if (m_pCamWnd && m_pCamWnd->GetSafeHwnd())
  2690. {
  2691. if (m_pCamWnd->IsWindowVisible())
  2692. m_pCamWnd->ShowWindow(SW_HIDE);
  2693. else
  2694. m_pCamWnd->ShowWindow(SW_SHOW);
  2695. }
  2696. }
  2697. }
  2698. void CMainFrame::OnToggleconsole()
  2699. {
  2700. if (m_nCurrentStyle > 0 && m_nCurrentStyle < 3) // QE4 style
  2701. {
  2702. if (m_pEditWnd && m_pEditWnd->GetSafeHwnd())
  2703. {
  2704. if (m_pEditWnd->IsWindowVisible())
  2705. m_pEditWnd->ShowWindow(SW_HIDE);
  2706. else
  2707. m_pEditWnd->ShowWindow(SW_SHOW);
  2708. }
  2709. }
  2710. }
  2711. void CMainFrame::OnToggleview()
  2712. {
  2713. if (m_nCurrentStyle == 1) // QE4 style
  2714. {
  2715. if (m_pXYWnd && m_pXYWnd->GetSafeHwnd())
  2716. {
  2717. if (m_pXYWnd->IsWindowVisible())
  2718. m_pXYWnd->ShowWindow(SW_HIDE);
  2719. else
  2720. m_pXYWnd->ShowWindow(SW_SHOW);
  2721. }
  2722. }
  2723. }
  2724. void CMainFrame::OnTogglez()
  2725. {
  2726. if (m_nCurrentStyle == 1 || m_nCurrentStyle == 2) // QE4 style
  2727. {
  2728. if (m_pZWnd && m_pZWnd->GetSafeHwnd())
  2729. {
  2730. if (m_pZWnd->IsWindowVisible())
  2731. m_pZWnd->ShowWindow(SW_HIDE);
  2732. else
  2733. m_pZWnd->ShowWindow(SW_SHOW);
  2734. }
  2735. }
  2736. else
  2737. {
  2738. Undo_Redo();
  2739. }
  2740. }
  2741. void CMainFrame::OnToggleLock()
  2742. {
  2743. g_PrefsDlg.m_bTextureLock = !g_PrefsDlg.m_bTextureLock;
  2744. CMenu* pMenu = GetMenu();
  2745. if (pMenu)
  2746. pMenu->CheckMenuItem(ID_TOGGLE_LOCK, MF_BYCOMMAND | (g_PrefsDlg.m_bTextureLock) ? MF_CHECKED : MF_UNCHECKED);
  2747. g_PrefsDlg.SavePrefs();
  2748. SetGridStatus();
  2749. }
  2750. void CMainFrame::OnEditMapinfo()
  2751. {
  2752. CMapInfo dlg;
  2753. dlg.DoModal();
  2754. }
  2755. void CMainFrame::OnEditEntityinfo()
  2756. {
  2757. CEntityListDlg dlg;
  2758. dlg.DoModal();
  2759. }
  2760. void CMainFrame::OnBrushScripts()
  2761. {
  2762. CScriptDlg dlg;
  2763. dlg.DoModal();
  2764. }
  2765. void CMainFrame::OnViewNextview()
  2766. {
  2767. if (m_nCurrentStyle != 2)
  2768. {
  2769. if (m_pXYWnd->GetViewType() == XY)
  2770. m_pXYWnd->SetViewType(XZ);
  2771. else
  2772. if (m_pXYWnd->GetViewType() == XZ)
  2773. m_pXYWnd->SetViewType(YZ);
  2774. else
  2775. m_pXYWnd->SetViewType(XY);
  2776. m_pXYWnd->PositionView();
  2777. Sys_UpdateWindows (W_XY);
  2778. }
  2779. }
  2780. void CMainFrame::OnHelpCommandlist()
  2781. {
  2782. CCommandsDlg dlg;
  2783. dlg.DoModal();
  2784. #if 0
  2785. if (g_b3Dfx)
  2786. {
  2787. C3DFXCamWnd* pWnd = new C3DFXCamWnd();
  2788. CRect rect(50,50,400, 400);
  2789. pWnd->Create(_3DFXCAMERA_WINDOW_CLASS, "", QE3_CHILDSTYLE, rect, this, 1234);
  2790. pWnd->ShowWindow(SW_SHOW);
  2791. }
  2792. #endif
  2793. }
  2794. void CMainFrame::OnFileNewproject()
  2795. {
  2796. CNewProjDlg dlg;
  2797. if (dlg.DoModal() == IDOK && dlg.m_strName.GetLength() > 0)
  2798. {
  2799. CString strQ2;
  2800. CString strQ2File;
  2801. ExtractPath_and_Filename(g_PrefsDlg.m_strQuake2, strQ2, strQ2File);
  2802. AddSlash(strQ2);
  2803. strQ2 += dlg.m_strName;
  2804. CString strProjToLoad;
  2805. CString strMapToLoad;
  2806. bool bGood = true;
  2807. if (::CreateDirectory(strQ2, NULL))
  2808. {
  2809. CString strDir = strQ2;
  2810. strDir += "\\maps";
  2811. if (::CreateDirectory(strDir, NULL))
  2812. {
  2813. CString strSource = g_strAppPath;
  2814. AddSlash(strSource);
  2815. strSource += "projmap.dat";
  2816. CString strDest = strDir;
  2817. AddSlash(strDest);
  2818. CString strName;
  2819. strName.Format("%s.map", dlg.m_strName);
  2820. strDest += strName;
  2821. strMapToLoad = strDest;
  2822. if (!::CopyFile(strSource, strDest, FALSE))
  2823. bGood = false;
  2824. }
  2825. else bGood = false;
  2826. strDir = strQ2;
  2827. strDir += "\\pics";
  2828. if (::CreateDirectory(strDir, NULL))
  2829. {
  2830. CString strSource = g_strAppPath;
  2831. AddSlash(strSource);
  2832. strSource += "colormap.pcx";
  2833. CString strDest = strDir;
  2834. AddSlash(strDest);
  2835. strDest += "colormap.pcx";
  2836. if (!::CopyFile(strSource, strDest, FALSE))
  2837. bGood = false;
  2838. }
  2839. else bGood = false;
  2840. strDir = strQ2;
  2841. strDir += "\\scripts";
  2842. if (::CreateDirectory(strDir, NULL))
  2843. {
  2844. CString strSource = g_strAppPath;
  2845. AddSlash(strSource);
  2846. strSource += "projqe4.dat";
  2847. CString strDest = strDir;
  2848. AddSlash(strDest);
  2849. strDest += "quake.qe4";
  2850. if (!::CopyFile(strSource, strDest, FALSE))
  2851. bGood = false;
  2852. else
  2853. strProjToLoad = strDest;
  2854. }
  2855. else bGood = false;
  2856. if (bGood && strProjToLoad.GetLength() > 0)
  2857. {
  2858. if (QE_LoadProject(strProjToLoad.GetBuffer(0)))
  2859. {
  2860. if (strMapToLoad.GetLength() > 0)
  2861. Map_LoadFile(strMapToLoad.GetBuffer(0));
  2862. }
  2863. }
  2864. }
  2865. else
  2866. {
  2867. CString strMsg;
  2868. strMsg.Format("Unable to create directory %s", strQ2);
  2869. MessageBox(strMsg);
  2870. }
  2871. }
  2872. }
  2873. void CMainFrame::UpdateStatusText()
  2874. {
  2875. for (int n = 0; n < 6; n++)
  2876. {
  2877. if (m_strStatus[n].GetLength() >= 0 && m_wndStatusBar.GetSafeHwnd())
  2878. m_wndStatusBar.SetPaneText(n, m_strStatus[n]);
  2879. }
  2880. }
  2881. void CMainFrame::SetStatusText(int nPane, const char * pText)
  2882. {
  2883. if (pText && nPane <= 5 && nPane > 0)
  2884. {
  2885. m_strStatus[nPane] = pText;
  2886. UpdateStatusText();
  2887. }
  2888. }
  2889. void CMainFrame::UpdateWindows(int nBits)
  2890. {
  2891. if (!g_bScreenUpdates)
  2892. return;
  2893. if (nBits & (W_XY | W_XY_OVERLAY))
  2894. {
  2895. if (m_pXYWnd)
  2896. m_pXYWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
  2897. if (m_pXZWnd)
  2898. m_pXZWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
  2899. if (m_pYZWnd)
  2900. m_pYZWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
  2901. }
  2902. if (nBits & W_CAMERA || ((nBits & W_CAMERA_IFON) && m_bCamPreview))
  2903. {
  2904. if (m_pCamWnd)
  2905. {
  2906. m_pCamWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
  2907. }
  2908. }
  2909. if (nBits & (W_Z | W_Z_OVERLAY))
  2910. {
  2911. if (m_pZWnd)
  2912. m_pZWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
  2913. }
  2914. if (nBits & W_TEXTURE)
  2915. {
  2916. if (m_pTexWnd)
  2917. m_pTexWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
  2918. }
  2919. }
  2920. void WINAPI Sys_UpdateWindows (int nBits)
  2921. {
  2922. if (g_PrefsDlg.m_bQE4Painting)
  2923. g_nUpdateBits |= nBits;
  2924. else
  2925. g_pParentWnd->UpdateWindows(nBits);
  2926. }
  2927. void CMainFrame::OnFlipClip()
  2928. {
  2929. if (m_pActiveXY)
  2930. m_pActiveXY->FlipClip();
  2931. }
  2932. void CMainFrame::OnClipSelected()
  2933. {
  2934. if (m_pActiveXY && m_pActiveXY->ClipMode())
  2935. {
  2936. Undo_Start("clip selected");
  2937. Undo_AddBrushList(&selected_brushes);
  2938. m_pActiveXY->Clip();
  2939. Undo_EndBrushList(&selected_brushes);
  2940. Undo_End();
  2941. }
  2942. else
  2943. {
  2944. if (g_bPatchBendMode)
  2945. Patch_BendHandleENTER();
  2946. else if (g_bPatchBendMode)
  2947. Patch_InsDelHandleENTER();
  2948. }
  2949. }
  2950. void CMainFrame::OnSplitSelected()
  2951. {
  2952. if (m_pActiveXY)
  2953. {
  2954. Undo_Start("split selected");
  2955. Undo_AddBrushList(&selected_brushes);
  2956. m_pActiveXY->SplitClip();
  2957. Undo_EndBrushList(&selected_brushes);
  2958. Undo_End();
  2959. }
  2960. }
  2961. CXYWnd* CMainFrame::ActiveXY()
  2962. {
  2963. return m_pActiveXY;
  2964. }
  2965. void CMainFrame::OnToggleviewXz()
  2966. {
  2967. if (m_nCurrentStyle == 1) // QE4 style
  2968. {
  2969. if (m_pXZWnd && m_pXZWnd->GetSafeHwnd())
  2970. {
  2971. // get windowplacement doesn't actually save this so we will here
  2972. g_PrefsDlg.m_bXZVis = m_pXZWnd->IsWindowVisible();
  2973. if (g_PrefsDlg.m_bXZVis)
  2974. m_pXZWnd->ShowWindow(SW_HIDE);
  2975. else
  2976. m_pXZWnd->ShowWindow(SW_SHOW);
  2977. g_PrefsDlg.m_bXZVis ^= 1;
  2978. g_PrefsDlg.SavePrefs();
  2979. }
  2980. }
  2981. }
  2982. void CMainFrame::OnToggleviewYz()
  2983. {
  2984. if (m_nCurrentStyle == 1) // QE4 style
  2985. {
  2986. if (m_pYZWnd && m_pYZWnd->GetSafeHwnd())
  2987. {
  2988. g_PrefsDlg.m_bYZVis = m_pYZWnd->IsWindowVisible();
  2989. if (g_PrefsDlg.m_bYZVis)
  2990. m_pYZWnd->ShowWindow(SW_HIDE);
  2991. else
  2992. m_pYZWnd->ShowWindow(SW_SHOW);
  2993. g_PrefsDlg.m_bYZVis ^= 1;
  2994. g_PrefsDlg.SavePrefs();
  2995. }
  2996. }
  2997. }
  2998. void CMainFrame::OnColorsBrush()
  2999. {
  3000. DoColor(COLOR_BRUSHES);
  3001. Sys_UpdateWindows (W_ALL);
  3002. }
  3003. void CMainFrame::OnColorsClipper()
  3004. {
  3005. DoColor(COLOR_CLIPPER);
  3006. Sys_UpdateWindows (W_ALL);
  3007. }
  3008. void CMainFrame::OnColorsGridtext()
  3009. {
  3010. DoColor(COLOR_GRIDTEXT);
  3011. Sys_UpdateWindows (W_ALL);
  3012. }
  3013. void CMainFrame::OnColorsSelectedbrush()
  3014. {
  3015. DoColor(COLOR_SELBRUSHES);
  3016. Sys_UpdateWindows (W_ALL);
  3017. }
  3018. void CMainFrame::OnColorsGridblock()
  3019. {
  3020. DoColor(COLOR_GRIDBLOCK);
  3021. Sys_UpdateWindows (W_ALL);
  3022. }
  3023. void CMainFrame::OnColorsViewname()
  3024. {
  3025. DoColor(COLOR_VIEWNAME);
  3026. Sys_UpdateWindows (W_ALL);
  3027. }
  3028. void CMainFrame::OnColorSetoriginal()
  3029. {
  3030. for (int i=0 ; i<3 ; i++)
  3031. {
  3032. g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][i] = 0.25;
  3033. g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][i] = 1.0;
  3034. g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][i] = 0.75;
  3035. g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][i] = 0.5;
  3036. g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][i] = 0.25;
  3037. }
  3038. g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][0] = 0.0;
  3039. g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][1] = 0.0;
  3040. g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][2] = 1.0;
  3041. g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][0] = 0.0;
  3042. g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][1] = 0.0;
  3043. g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][2] = 0.0;
  3044. g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] = 1.0;
  3045. g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] = 0.0;
  3046. g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] = 0.0;
  3047. g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][0] = 0.0;
  3048. g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][1] = 0.0;
  3049. g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][2] = 1.0;
  3050. g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][0] = 0.0;
  3051. g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][1] = 0.0;
  3052. g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][2] = 0.0;
  3053. g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][0] = 0.5;
  3054. g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][1] = 0.0;
  3055. g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][2] = 0.75;
  3056. Sys_UpdateWindows (W_ALL);
  3057. }
  3058. void CMainFrame::OnColorSetqer()
  3059. {
  3060. for (int i=0 ; i<3 ; i++)
  3061. {
  3062. g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][i] = 0.25;
  3063. g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][i] = 1.0;
  3064. g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][i] = 1.0;
  3065. g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][i] = 0.5;
  3066. g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][i] = 0.25;
  3067. }
  3068. g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][0] = 0.0;
  3069. g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][1] = 0.0;
  3070. g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][2] = 1.0;
  3071. g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][0] = 0.0;
  3072. g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][1] = 0.0;
  3073. g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][2] = 0.0;
  3074. g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] = 1.0;
  3075. g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] = 0.0;
  3076. g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] = 0.0;
  3077. g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][0] = 0.0;
  3078. g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][1] = 0.0;
  3079. g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][2] = 1.0;
  3080. g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][0] = 0.0;
  3081. g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][1] = 0.0;
  3082. g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][2] = 0.0;
  3083. g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][0] = 0.5;
  3084. g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][1] = 0.0;
  3085. g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][2] = 0.75;
  3086. Sys_UpdateWindows (W_ALL);
  3087. }
  3088. void CMainFrame::OnColorSetblack()
  3089. {
  3090. for (int i=0 ; i<3 ; i++)
  3091. {
  3092. g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][i] = 0.25;
  3093. g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][i] = 0.0;
  3094. g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][i] = 0.0;
  3095. g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][i] = 0.25;
  3096. }
  3097. g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][0] = 0.3;
  3098. g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][1] = 0.5;
  3099. g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][2] = 0.5;
  3100. g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][0] = 0.0;
  3101. g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][1] = 0.0;
  3102. g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][2] = 1.0;
  3103. g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][0] = 1.0;
  3104. g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][1] = 1.0;
  3105. g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][2] = 1.0;
  3106. g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] = 1.0;
  3107. g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] = 0.0;
  3108. g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] = 0.0;
  3109. g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][0] = 0.0;
  3110. g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][1] = 0.0;
  3111. g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][2] = 1.0;
  3112. g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][0] = 1.0;
  3113. g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][1] = 1.0;
  3114. g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][2] = 1.0;
  3115. g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][0] = 0.7;
  3116. g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][1] = 0.7;
  3117. g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][2] = 0.0;
  3118. Sys_UpdateWindows (W_ALL);
  3119. }
  3120. void CMainFrame::OnSnaptogrid()
  3121. {
  3122. g_PrefsDlg.m_bNoClamp ^= 1;
  3123. g_PrefsDlg.SavePrefs();
  3124. CMenu* pMenu = GetMenu();
  3125. if (pMenu)
  3126. pMenu->CheckMenuItem(ID_SNAPTOGRID, MF_BYCOMMAND | (!g_PrefsDlg.m_bNoClamp) ? MF_CHECKED : MF_UNCHECKED);
  3127. }
  3128. void CMainFrame::OnSelectScale()
  3129. {
  3130. //if (ActiveXY())
  3131. // ActiveXY()->UndoCopy();
  3132. Undo_Start("scale");
  3133. Undo_AddBrushList(&selected_brushes);
  3134. CScaleDialog dlg;
  3135. if (dlg.DoModal() == IDOK)
  3136. {
  3137. if (dlg.m_fX > 0 && dlg.m_fY > 0 && dlg.m_fZ > 0)
  3138. {
  3139. Select_Scale(dlg.m_fX, dlg.m_fY, dlg.m_fZ);
  3140. Sys_UpdateWindows (W_ALL);
  3141. }
  3142. else
  3143. Sys_Printf("Warning.. Tried to scale by a zero value.");
  3144. }
  3145. Undo_EndBrushList(&selected_brushes);
  3146. Undo_End();
  3147. }
  3148. void CMainFrame::OnSelectMouserotate()
  3149. {
  3150. if (ActiveXY())
  3151. {
  3152. if (ActiveXY()->ClipMode())
  3153. OnViewClipper();
  3154. if (ActiveXY()->RotateMode())
  3155. {
  3156. // SetRotateMode(false) always works
  3157. ActiveXY()->SetRotateMode(false);
  3158. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSEROTATE, FALSE);
  3159. Map_BuildBrushData();
  3160. }
  3161. else
  3162. {
  3163. // may not work if no brush selected, see return value
  3164. if (ActiveXY()->SetRotateMode(true))
  3165. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSEROTATE, TRUE);
  3166. else
  3167. // if MFC called, we need to set back to FALSE ourselves
  3168. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSEROTATE, FALSE);
  3169. }
  3170. }
  3171. }
  3172. void CMainFrame::OnEditCopybrush()
  3173. {
  3174. if (ActiveXY())
  3175. ActiveXY()->Copy();
  3176. }
  3177. void CMainFrame::OnEditPastebrush()
  3178. {
  3179. if (ActiveXY())
  3180. ActiveXY()->Paste();
  3181. }
  3182. void CMainFrame::OnEditUndo()
  3183. {
  3184. // if (ActiveXY())
  3185. // ActiveXY()->Undo();
  3186. Undo_Undo();
  3187. }
  3188. void CMainFrame::OnEditRedo()
  3189. {
  3190. Undo_Redo();
  3191. }
  3192. void CMainFrame::OnUpdateEditUndo(CCmdUI* pCmdUI)
  3193. {
  3194. /*
  3195. BOOL bEnable = false;
  3196. if (ActiveXY())
  3197. bEnable = ActiveXY()->UndoAvailable();
  3198. pCmdUI->Enable(bEnable);
  3199. */
  3200. pCmdUI->Enable(Undo_UndoAvailable());
  3201. }
  3202. void CMainFrame::OnUpdateEditRedo(CCmdUI* pCmdUI)
  3203. {
  3204. pCmdUI->Enable(Undo_RedoAvailable());
  3205. }
  3206. void CMainFrame::OnSelectionTextureDec()
  3207. {
  3208. g_qeglobals.d_savedinfo.m_nTextureTweak--;
  3209. if (g_qeglobals.d_savedinfo.m_nTextureTweak == 0)
  3210. g_qeglobals.d_savedinfo.m_nTextureTweak--;
  3211. SetTexValStatus();
  3212. }
  3213. void CMainFrame::OnSelectionTextureFit()
  3214. {
  3215. // TODO: Add your command handler code here
  3216. }
  3217. void CMainFrame::OnSelectionTextureInc()
  3218. {
  3219. g_qeglobals.d_savedinfo.m_nTextureTweak++;
  3220. if (g_qeglobals.d_savedinfo.m_nTextureTweak == 0)
  3221. g_qeglobals.d_savedinfo.m_nTextureTweak++;
  3222. SetTexValStatus();
  3223. }
  3224. void CMainFrame::OnSelectionTextureRotateclock()
  3225. {
  3226. Select_RotateTexture(abs(g_PrefsDlg.m_nRotation));
  3227. }
  3228. void CMainFrame::OnSelectionTextureRotatecounter()
  3229. {
  3230. Select_RotateTexture(-abs(g_PrefsDlg.m_nRotation));
  3231. }
  3232. void CMainFrame::OnSelectionTextureScaledown()
  3233. {
  3234. Select_ScaleTexture(0, -abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
  3235. }
  3236. void CMainFrame::OnSelectionTextureScaleup()
  3237. {
  3238. Select_ScaleTexture(0, abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
  3239. }
  3240. void CMainFrame::OnSelectionTextureScaleLeft()
  3241. {
  3242. Select_ScaleTexture(-abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0);
  3243. }
  3244. void CMainFrame::OnSelectionTextureScaleRight()
  3245. {
  3246. Select_ScaleTexture(abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0);
  3247. }
  3248. void CMainFrame::OnSelectionTextureShiftdown()
  3249. {
  3250. Select_ShiftTexture(0, -abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
  3251. }
  3252. void CMainFrame::OnSelectionTextureShiftleft()
  3253. {
  3254. Select_ShiftTexture(-abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0);
  3255. }
  3256. void CMainFrame::OnSelectionTextureShiftright()
  3257. {
  3258. Select_ShiftTexture(abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0);
  3259. }
  3260. void CMainFrame::OnSelectionTextureShiftup()
  3261. {
  3262. Select_ShiftTexture(0, abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
  3263. }
  3264. void CMainFrame::OnGridNext()
  3265. {
  3266. if (g_qeglobals.d_gridsize < 64)
  3267. {
  3268. g_qeglobals.d_gridsize = g_qeglobals.d_gridsize << 1;
  3269. Sys_UpdateWindows(W_XY | W_Z);
  3270. SetGridStatus();
  3271. HMENU hMenu = ::GetMenu(GetSafeHwnd());
  3272. CheckMenuItem(hMenu, ID_GRID_1, MF_BYCOMMAND | MF_UNCHECKED);
  3273. CheckMenuItem(hMenu, ID_GRID_2, MF_BYCOMMAND | MF_UNCHECKED);
  3274. CheckMenuItem(hMenu, ID_GRID_4, MF_BYCOMMAND | MF_UNCHECKED);
  3275. CheckMenuItem(hMenu, ID_GRID_8, MF_BYCOMMAND | MF_UNCHECKED);
  3276. CheckMenuItem(hMenu, ID_GRID_16, MF_BYCOMMAND | MF_UNCHECKED);
  3277. CheckMenuItem(hMenu, ID_GRID_32, MF_BYCOMMAND | MF_UNCHECKED);
  3278. CheckMenuItem(hMenu, ID_GRID_64, MF_BYCOMMAND | MF_UNCHECKED);
  3279. int nID;
  3280. switch (g_qeglobals.d_gridsize)
  3281. {
  3282. case 1: nID = ID_GRID_1; break;
  3283. case 2: nID = ID_GRID_2; break;
  3284. case 4: nID = ID_GRID_4; break;
  3285. case 8: nID = ID_GRID_8; break;
  3286. case 16: nID = ID_GRID_16; break;
  3287. case 32: nID = ID_GRID_32; break;
  3288. case 64: nID = ID_GRID_64; break;
  3289. }
  3290. CheckMenuItem(hMenu, nID, MF_BYCOMMAND | MF_CHECKED);
  3291. }
  3292. }
  3293. void CMainFrame::OnGridPrev()
  3294. {
  3295. if (g_qeglobals.d_gridsize > 1)
  3296. {
  3297. g_qeglobals.d_gridsize = g_qeglobals.d_gridsize >> 1;
  3298. Sys_UpdateWindows(W_XY | W_Z);
  3299. SetGridStatus();
  3300. HMENU hMenu = ::GetMenu(GetSafeHwnd());
  3301. CheckMenuItem(hMenu, ID_GRID_1, MF_BYCOMMAND | MF_UNCHECKED);
  3302. CheckMenuItem(hMenu, ID_GRID_2, MF_BYCOMMAND | MF_UNCHECKED);
  3303. CheckMenuItem(hMenu, ID_GRID_4, MF_BYCOMMAND | MF_UNCHECKED);
  3304. CheckMenuItem(hMenu, ID_GRID_8, MF_BYCOMMAND | MF_UNCHECKED);
  3305. CheckMenuItem(hMenu, ID_GRID_16, MF_BYCOMMAND | MF_UNCHECKED);
  3306. CheckMenuItem(hMenu, ID_GRID_32, MF_BYCOMMAND | MF_UNCHECKED);
  3307. CheckMenuItem(hMenu, ID_GRID_64, MF_BYCOMMAND | MF_UNCHECKED);
  3308. int nID;
  3309. switch (g_qeglobals.d_gridsize)
  3310. {
  3311. case 1: nID = ID_GRID_1; break;
  3312. case 2: nID = ID_GRID_2; break;
  3313. case 4: nID = ID_GRID_4; break;
  3314. case 8: nID = ID_GRID_8; break;
  3315. case 16: nID = ID_GRID_16; break;
  3316. case 32: nID = ID_GRID_32; break;
  3317. case 64: nID = ID_GRID_64; break;
  3318. }
  3319. CheckMenuItem(hMenu, nID, MF_BYCOMMAND | MF_CHECKED);
  3320. }
  3321. }
  3322. void CMainFrame::SetGridStatus()
  3323. {
  3324. CString strStatus;
  3325. char c1;
  3326. char c2;
  3327. c1 = (g_PrefsDlg.m_bTextureLock) ? 'M' : ' ';
  3328. c2 = (g_PrefsDlg.m_bRotateLock) ? 'R' : ' ';
  3329. strStatus.Format("G:%i T:%i R:%i C:%i L:%c%c", g_qeglobals.d_gridsize, g_qeglobals.d_savedinfo.m_nTextureTweak, g_PrefsDlg.m_nRotation, g_PrefsDlg.m_nCubicScale, c1, c2);
  3330. SetStatusText(4, strStatus);
  3331. }
  3332. void CMainFrame::SetTexValStatus()
  3333. {
  3334. //CString strStatus;
  3335. //strStatus.Format("T: %i C: %i", g_nTextureTweak, g_nCubicScale);
  3336. //SetStatusText(5, strStatus.GetBuffer(0));
  3337. SetGridStatus();
  3338. }
  3339. void CMainFrame::OnTextureReplaceall()
  3340. {
  3341. CFindTextureDlg::show();
  3342. }
  3343. void CMainFrame::OnScalelockx()
  3344. {
  3345. if (g_nScaleHow & SCALE_X)
  3346. {
  3347. g_nScaleHow ^= SCALE_X;
  3348. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKX, FALSE);
  3349. }
  3350. else
  3351. {
  3352. g_nScaleHow |= SCALE_X;
  3353. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKX);
  3354. }
  3355. }
  3356. void CMainFrame::OnScalelocky()
  3357. {
  3358. if (g_nScaleHow & SCALE_Y)
  3359. {
  3360. g_nScaleHow ^= SCALE_Y;
  3361. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKY, FALSE);
  3362. }
  3363. else
  3364. {
  3365. g_nScaleHow |= SCALE_Y;
  3366. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKY);
  3367. }
  3368. }
  3369. void CMainFrame::OnScalelockz()
  3370. {
  3371. if (g_nScaleHow & SCALE_Z)
  3372. {
  3373. g_nScaleHow ^= SCALE_Z;
  3374. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKZ, FALSE);
  3375. }
  3376. else
  3377. {
  3378. g_nScaleHow |= SCALE_Z;
  3379. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKZ);
  3380. }
  3381. }
  3382. void CMainFrame::OnSelectMousescale()
  3383. {
  3384. if (ActiveXY())
  3385. {
  3386. if (ActiveXY()->ClipMode())
  3387. OnViewClipper();
  3388. if (ActiveXY()->RotateMode())
  3389. {
  3390. // SetRotateMode(false) always works
  3391. ActiveXY()->SetRotateMode(false);
  3392. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSESCALE, FALSE);
  3393. }
  3394. if (ActiveXY()->ScaleMode())
  3395. {
  3396. ActiveXY()->SetScaleMode(false);
  3397. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSESCALE, FALSE);
  3398. }
  3399. else
  3400. {
  3401. ActiveXY()->SetScaleMode(true);
  3402. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSESCALE);
  3403. }
  3404. }
  3405. }
  3406. void CMainFrame::OnFileImport()
  3407. {
  3408. }
  3409. void CMainFrame::OnFileProjectsettings()
  3410. {
  3411. DoProjectSettings();
  3412. }
  3413. void CMainFrame::OnUpdateFileImport(CCmdUI* pCmdUI)
  3414. {
  3415. pCmdUI->Enable(FALSE);
  3416. }
  3417. void CMainFrame::OnViewCubein()
  3418. {
  3419. g_PrefsDlg.m_nCubicScale--;
  3420. if (g_PrefsDlg.m_nCubicScale < 1)
  3421. g_PrefsDlg.m_nCubicScale = 1;
  3422. g_PrefsDlg.SavePrefs();
  3423. Sys_UpdateWindows(W_CAMERA);
  3424. SetTexValStatus();
  3425. }
  3426. void CMainFrame::OnViewCubeout()
  3427. {
  3428. g_PrefsDlg.m_nCubicScale++;
  3429. if (g_PrefsDlg.m_nCubicScale > 22)
  3430. g_PrefsDlg.m_nCubicScale = 22;
  3431. g_PrefsDlg.SavePrefs();
  3432. Sys_UpdateWindows(W_CAMERA);
  3433. SetTexValStatus();
  3434. }
  3435. void CMainFrame::OnViewCubicclipping()
  3436. {
  3437. g_PrefsDlg.m_bCubicClipping ^= 1;
  3438. CMenu* pMenu = GetMenu();
  3439. if (pMenu)
  3440. pMenu->CheckMenuItem(ID_VIEW_CUBICCLIPPING, MF_BYCOMMAND | (g_PrefsDlg.m_bCubicClipping) ? MF_CHECKED : MF_UNCHECKED);
  3441. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_VIEW_CUBICCLIPPING, (g_PrefsDlg.m_bCubicClipping) ? TRUE : FALSE);
  3442. g_PrefsDlg.SavePrefs();
  3443. Map_BuildBrushData ();
  3444. Sys_UpdateWindows(W_CAMERA);
  3445. }
  3446. void CMainFrame::OnFileSaveregion()
  3447. {
  3448. SaveAsDialog (true);
  3449. }
  3450. void CMainFrame::OnUpdateFileSaveregion(CCmdUI* pCmdUI)
  3451. {
  3452. pCmdUI->Enable(static_cast<BOOL>(region_active));
  3453. }
  3454. void CMainFrame::OnSelectionMovedown()
  3455. {
  3456. Undo_Start("move up");
  3457. Undo_AddBrushList(&selected_brushes);
  3458. vec3_t vAmt;
  3459. vAmt[0] = vAmt[1] = 0.0;
  3460. vAmt[2] = -g_qeglobals.d_gridsize;
  3461. Select_Move (vAmt);
  3462. Sys_UpdateWindows(W_CAMERA | W_XY | W_Z);
  3463. Undo_EndBrushList(&selected_brushes);
  3464. Undo_End();
  3465. }
  3466. void CMainFrame::OnSelectionMoveup()
  3467. {
  3468. vec3_t vAmt;
  3469. vAmt[0] = vAmt[1] = 0.0;
  3470. vAmt[2] = g_qeglobals.d_gridsize;
  3471. Select_Move (vAmt);
  3472. Sys_UpdateWindows(W_CAMERA | W_XY | W_Z);
  3473. }
  3474. void CMainFrame::OnToolbarMain()
  3475. {
  3476. }
  3477. void CMainFrame::OnToolbarTexture()
  3478. {
  3479. }
  3480. void CMainFrame::OnSelectionPrint()
  3481. {
  3482. for (brush_t* b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
  3483. Brush_Print(b);
  3484. }
  3485. void CMainFrame::UpdateTextureBar()
  3486. {
  3487. if (m_wndTextureBar.GetSafeHwnd())
  3488. m_wndTextureBar.GetSurfaceAttributes();
  3489. }
  3490. bool g_bTABDown = false;
  3491. bool g_bOriginalFlag;
  3492. void CMainFrame::OnSelectionTogglesizepaint()
  3493. {
  3494. if (::GetAsyncKeyState('Q'))
  3495. {
  3496. if (!g_bTABDown)
  3497. {
  3498. g_bTABDown = true;
  3499. g_bOriginalFlag = g_PrefsDlg.m_bSizePaint;
  3500. g_PrefsDlg.m_bSizePaint = !g_bOriginalFlag;
  3501. Sys_UpdateWindows(W_XY);
  3502. return;
  3503. }
  3504. }
  3505. else
  3506. {
  3507. g_bTABDown = false;
  3508. g_PrefsDlg.m_bSizePaint = g_bOriginalFlag;
  3509. Sys_UpdateWindows(W_XY);
  3510. return;
  3511. }
  3512. }
  3513. void CMainFrame::OnBrushMakecone()
  3514. {
  3515. Undo_Start("make cone");
  3516. Undo_AddBrushList(&selected_brushes);
  3517. DoSides(true);
  3518. Undo_EndBrushList(&selected_brushes);
  3519. Undo_End();
  3520. }
  3521. void CMainFrame::OnTexturesLoad()
  3522. {
  3523. BROWSEINFO bi;
  3524. CString strPath;
  3525. char* p = strPath.GetBuffer(MAX_PATH+1);
  3526. bi.hwndOwner = GetSafeHwnd();
  3527. bi.pidlRoot = NULL;
  3528. bi.pszDisplayName = p;
  3529. bi.lpszTitle = "Load textures from path";
  3530. bi.ulFlags = 0;
  3531. bi.lpfn = NULL;
  3532. bi.lParam = NULL;
  3533. bi.iImage = 0;
  3534. LPITEMIDLIST pidlBrowse;
  3535. pidlBrowse = SHBrowseForFolder(&bi);
  3536. if (pidlBrowse)
  3537. {
  3538. SHGetPathFromIDList(pidlBrowse, p);
  3539. strPath.ReleaseBuffer();
  3540. AddSlash(strPath);
  3541. Texture_ShowDirectory(strPath.GetBuffer(0));
  3542. }
  3543. }
  3544. void CMainFrame::OnToggleRotatelock()
  3545. {
  3546. g_PrefsDlg.m_bRotateLock ^= 1;
  3547. CMenu* pMenu = GetMenu();
  3548. if (pMenu)
  3549. pMenu->CheckMenuItem(ID_TOGGLE_ROTATELOCK, MF_BYCOMMAND | (g_PrefsDlg.m_bRotateLock) ? MF_CHECKED : MF_UNCHECKED);
  3550. g_PrefsDlg.SavePrefs();
  3551. SetGridStatus();
  3552. }
  3553. void CMainFrame::OnCurveBevel()
  3554. {
  3555. //Curve_MakeCurvedBrush (false, false, false, false, false, true, true);
  3556. }
  3557. void CMainFrame::OnCurveCylinder()
  3558. {
  3559. //Curve_MakeCurvedBrush (false, false, false, true, true, true, true);
  3560. }
  3561. void CMainFrame::OnCurveEighthsphere()
  3562. {
  3563. //Curve_MakeCurvedBrush (false, true, false, true, true, false, false);
  3564. }
  3565. void CMainFrame::OnCurveEndcap()
  3566. {
  3567. //Curve_MakeCurvedBrush (false, false, false, false, true, true, true);
  3568. }
  3569. void CMainFrame::OnCurveHemisphere()
  3570. {
  3571. //Curve_MakeCurvedBrush (false, true, false, true, true, true, true);
  3572. }
  3573. void CMainFrame::OnCurveInvertcurve()
  3574. {
  3575. //Curve_Invert ();
  3576. }
  3577. void CMainFrame::OnCurveQuarter()
  3578. {
  3579. //Curve_MakeCurvedBrush (false, true, false, true, true, true, false);
  3580. }
  3581. void CMainFrame::OnCurveSphere()
  3582. {
  3583. //Curve_MakeCurvedBrush (false, true, true, true, true, true, true);
  3584. }
  3585. void CMainFrame::OnFileImportmap()
  3586. {
  3587. CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Map files (*.map)|*.map||", this);
  3588. if (dlgFile.DoModal() == IDOK)
  3589. {
  3590. Map_ImportFile(dlgFile.GetPathName().GetBuffer(0));
  3591. }
  3592. }
  3593. void CMainFrame::OnFileExportmap()
  3594. {
  3595. CFileDialog dlgFile(FALSE, "map", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Map files (*.map)|*.map||", this);
  3596. if (dlgFile.DoModal() == IDOK)
  3597. {
  3598. Map_SaveSelected(dlgFile.GetPathName().GetBuffer(0));
  3599. }
  3600. }
  3601. void CMainFrame::OnViewShowcurves()
  3602. {
  3603. if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_CURVES ) & EXCLUDE_CURVES )
  3604. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCURVES, MF_BYCOMMAND | MF_UNCHECKED );
  3605. else
  3606. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCURVES, MF_BYCOMMAND | MF_CHECKED );
  3607. Sys_UpdateWindows (W_XY|W_CAMERA);
  3608. }
  3609. void CMainFrame::OnSelectionSelectNudgedown()
  3610. {
  3611. NudgeSelection(3, g_qeglobals.d_savedinfo.m_nTextureTweak);
  3612. }
  3613. void CMainFrame::OnSelectionSelectNudgeleft()
  3614. {
  3615. NudgeSelection(0, g_qeglobals.d_savedinfo.m_nTextureTweak);
  3616. }
  3617. void CMainFrame::OnSelectionSelectNudgeright()
  3618. {
  3619. NudgeSelection(2, g_qeglobals.d_savedinfo.m_nTextureTweak);
  3620. }
  3621. void CMainFrame::OnSelectionSelectNudgeup()
  3622. {
  3623. NudgeSelection(1, g_qeglobals.d_savedinfo.m_nTextureTweak);
  3624. }
  3625. void CMainFrame::NudgeSelection(int nDirection, int nAmount)
  3626. {
  3627. if (ActiveXY()->RotateMode())
  3628. {
  3629. int nAxis = 0;
  3630. if (ActiveXY()->GetViewType() == XY)
  3631. {
  3632. nAxis = 2;
  3633. }
  3634. else
  3635. if (g_pParentWnd->ActiveXY()->GetViewType() == XZ)
  3636. {
  3637. nAxis = 1;
  3638. nAmount = -nAmount;
  3639. }
  3640. if (nDirection == 2 || nDirection == 3)
  3641. {
  3642. nAmount = -nAmount;
  3643. }
  3644. float fDeg = -nAmount;
  3645. float fAdj = nAmount;
  3646. g_pParentWnd->ActiveXY()->Rotation()[nAxis] += fAdj;
  3647. CString strStatus;
  3648. strStatus.Format("Rotation x:: %.1f y:: %.1f z:: %.1f", g_pParentWnd->ActiveXY()->Rotation()[0], g_pParentWnd->ActiveXY()->Rotation()[1], g_pParentWnd->ActiveXY()->Rotation()[2]);
  3649. g_pParentWnd->SetStatusText(2, strStatus);
  3650. Select_RotateAxis(nAxis, fDeg, false, true);
  3651. Sys_UpdateWindows (W_ALL);
  3652. }
  3653. else
  3654. if (ActiveXY()->ScaleMode())
  3655. {
  3656. if (nDirection == 0 || nDirection == 3)
  3657. {
  3658. nAmount = -nAmount;
  3659. }
  3660. vec3_t v;
  3661. v[0] = v[1] = v[2] = 1.0;
  3662. if (nAmount > 0)
  3663. {
  3664. v[0] = 1.1;
  3665. v[1] = 1.1;
  3666. v[2] = 1.1;
  3667. }
  3668. else
  3669. {
  3670. v[0] = 0.9;
  3671. v[1] = 0.9;
  3672. v[2] = 0.9;
  3673. }
  3674. Select_Scale((g_nScaleHow & SCALE_X) ? v[0] : 1.0,
  3675. (g_nScaleHow & SCALE_Y) ? v[1] : 1.0,
  3676. (g_nScaleHow & SCALE_Z) ? v[2] : 1.0);
  3677. Sys_UpdateWindows (W_ALL);
  3678. }
  3679. else
  3680. {
  3681. // 0 - left, 1 - up, 2 - right, 3 - down
  3682. int nDim;
  3683. if (nDirection == 0)
  3684. {
  3685. nDim = ActiveXY()->GetViewType() == YZ ? 1 : 0;
  3686. nAmount = -nAmount;
  3687. }
  3688. else if (nDirection == 1)
  3689. {
  3690. nDim = ActiveXY()->GetViewType() == XY ? 1 : 2;
  3691. }
  3692. else if (nDirection == 2)
  3693. {
  3694. nDim = ActiveXY()->GetViewType() == YZ ? 1 : 0;
  3695. }
  3696. else
  3697. {
  3698. nDim = ActiveXY()->GetViewType() == XY ? 1 : 2;
  3699. nAmount = -nAmount;
  3700. }
  3701. Nudge(nDim, nAmount);
  3702. }
  3703. }
  3704. BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
  3705. {
  3706. return CFrameWnd::PreTranslateMessage(pMsg);
  3707. }
  3708. void CMainFrame::Nudge(int nDim, float fNudge)
  3709. {
  3710. vec3_t vMove;
  3711. vMove[0] = vMove[1] = vMove[2] = 0;
  3712. vMove[nDim] = fNudge;
  3713. Select_Move(vMove, true);
  3714. Sys_UpdateWindows (W_ALL);
  3715. }
  3716. void CMainFrame::OnTexturesLoadlist()
  3717. {
  3718. CDialogTextures dlg;
  3719. if (dlg.DoModal() == IDOK && dlg.m_nSelection >= 0)
  3720. {
  3721. Texture_ShowDirectory(dlg.m_nSelection + CMD_TEXTUREWAD);
  3722. }
  3723. }
  3724. void CMainFrame::OnDontselectcurve()
  3725. {
  3726. g_PrefsDlg.m_bSelectCurves ^= 1;
  3727. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_DONTSELECTCURVE, (g_PrefsDlg.m_bSelectCurves) ? FALSE : TRUE);
  3728. }
  3729. void CMainFrame::OnConvertcurves()
  3730. {
  3731. #if 0
  3732. Select_Deselect();
  3733. for (brush_t* pb = active_brushes.next ; pb != &active_brushes ; pb = pb->next)
  3734. {
  3735. if (pb->curveBrush)
  3736. {
  3737. for (face_t* f = pb->brush_faces ; f ; f=f->next)
  3738. {
  3739. if (f->texdef.contents & CONTENTS_LADDER)
  3740. {
  3741. f->texdef.contents &= ~CONTENTS_LADDER;
  3742. f->texdef.contents |= CONTENTS_NEGATIVE_CURVE;
  3743. }
  3744. }
  3745. }
  3746. }
  3747. Map_BuildBrushData();
  3748. #endif
  3749. }
  3750. void CMainFrame::OnDynamicLighting()
  3751. {
  3752. CCamWnd* pCam = new CCamWnd();
  3753. CRect rect(100, 100, 300, 300);
  3754. pCam->Create(CAMERA_WINDOW_CLASS, "", WS_OVERLAPPEDWINDOW, rect, GetDesktopWindow(), 12345);
  3755. pCam->ShowWindow(SW_SHOW);
  3756. }
  3757. void CMainFrame::OnCurveSimplepatchmesh()
  3758. {
  3759. Undo_Start("make simpe patch mesh");
  3760. Undo_AddBrushList(&selected_brushes);
  3761. CPatchDensityDlg dlg;
  3762. dlg.DoModal();
  3763. Undo_EndBrushList(&selected_brushes);
  3764. Undo_End();
  3765. }
  3766. void CMainFrame::OnPatchToggleBox()
  3767. {
  3768. g_bPatchShowBounds ^= 1;
  3769. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_SHOWBOUNDINGBOX, (g_bPatchShowBounds) ? TRUE : FALSE);
  3770. Sys_UpdateWindows(W_ALL);
  3771. }
  3772. void CMainFrame::OnPatchWireframe()
  3773. {
  3774. g_bPatchWireFrame ^= 1;
  3775. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_WIREFRAME, (g_bPatchWireFrame) ? TRUE : FALSE);
  3776. Sys_UpdateWindows(W_ALL);
  3777. }
  3778. void CMainFrame::OnCurvePatchcone()
  3779. {
  3780. Undo_Start("make curve cone");
  3781. Undo_AddBrushList(&selected_brushes);
  3782. Patch_BrushToMesh(true);
  3783. Sys_UpdateWindows (W_ALL);
  3784. Undo_EndBrushList(&selected_brushes);
  3785. Undo_End();
  3786. }
  3787. void CMainFrame::OnCurvePatchtube()
  3788. {
  3789. Undo_Start("make curve cylinder");
  3790. Undo_AddBrushList(&selected_brushes);
  3791. Patch_BrushToMesh(false);
  3792. Sys_UpdateWindows (W_ALL);
  3793. Undo_EndBrushList(&selected_brushes);
  3794. Undo_End();
  3795. }
  3796. void CMainFrame::OnPatchWeld()
  3797. {
  3798. g_bPatchWeld ^= 1;
  3799. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_WELD, (g_bPatchWeld) ? TRUE : FALSE);
  3800. Sys_UpdateWindows(W_ALL);
  3801. }
  3802. void CMainFrame::OnCurvePatchbevel()
  3803. {
  3804. Undo_Start("make bevel");
  3805. Undo_AddBrushList(&selected_brushes);
  3806. Patch_BrushToMesh(false, true, false);
  3807. Sys_UpdateWindows (W_ALL);
  3808. Undo_EndBrushList(&selected_brushes);
  3809. Undo_End();
  3810. }
  3811. void CMainFrame::OnCurvePatchendcap()
  3812. {
  3813. Undo_Start("make end cap");
  3814. Undo_AddBrushList(&selected_brushes);
  3815. Patch_BrushToMesh(false, false, true);
  3816. Sys_UpdateWindows (W_ALL);
  3817. Undo_EndBrushList(&selected_brushes);
  3818. Undo_End();
  3819. }
  3820. void CMainFrame::OnCurvePatchinvertedbevel()
  3821. {
  3822. //Patch_BrushToMesh(false, true, false, true);
  3823. //Sys_UpdateWindows (W_ALL);
  3824. }
  3825. void CMainFrame::OnCurvePatchinvertedendcap()
  3826. {
  3827. //Patch_BrushToMesh(false, false, true, true);
  3828. //Sys_UpdateWindows (W_ALL);
  3829. }
  3830. void CMainFrame::OnPatchDrilldown()
  3831. {
  3832. g_bPatchDrillDown ^= 1;
  3833. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_DRILLDOWN, (g_bPatchDrillDown) ? TRUE : FALSE);
  3834. Sys_UpdateWindows(W_ALL);
  3835. }
  3836. void CMainFrame::OnCurveInsertcolumn()
  3837. {
  3838. Undo_Start("insert colum");
  3839. Undo_AddBrushList(&selected_brushes);
  3840. //Patch_AdjustSelectedRowCols(0, 2);
  3841. Patch_AdjustSelected(true, true, true);
  3842. Sys_UpdateWindows(W_ALL);
  3843. Undo_EndBrushList(&selected_brushes);
  3844. Undo_End();
  3845. }
  3846. void CMainFrame::OnCurveInsertrow()
  3847. {
  3848. Undo_Start("insert row");
  3849. Undo_AddBrushList(&selected_brushes);
  3850. //Patch_AdjustSelectedRowCols(2, 0);
  3851. Patch_AdjustSelected(true, false, true);
  3852. Sys_UpdateWindows(W_ALL);
  3853. Undo_EndBrushList(&selected_brushes);
  3854. Undo_End();
  3855. }
  3856. void CMainFrame::OnCurveDeletecolumn()
  3857. {
  3858. Undo_Start("delete column");
  3859. Undo_AddBrushList(&selected_brushes);
  3860. Patch_AdjustSelected(false, true, true);
  3861. Sys_UpdateWindows(W_ALL);
  3862. Undo_EndBrushList(&selected_brushes);
  3863. Undo_End();
  3864. }
  3865. void CMainFrame::OnCurveDeleterow()
  3866. {
  3867. Undo_Start("delete row");
  3868. Undo_AddBrushList(&selected_brushes);
  3869. Patch_AdjustSelected(false, false, true);
  3870. Sys_UpdateWindows(W_ALL);
  3871. Undo_EndBrushList(&selected_brushes);
  3872. Undo_End();
  3873. }
  3874. void CMainFrame::OnCurveInsertAddcolumn()
  3875. {
  3876. Undo_Start("add (2) columns");
  3877. Undo_AddBrushList(&selected_brushes);
  3878. Patch_AdjustSelected(true, true, true);
  3879. Sys_UpdateWindows(W_ALL);
  3880. Undo_EndBrushList(&selected_brushes);
  3881. Undo_End();
  3882. }
  3883. void CMainFrame::OnCurveInsertAddrow()
  3884. {
  3885. Undo_Start("add (2) rows");
  3886. Undo_AddBrushList(&selected_brushes);
  3887. Patch_AdjustSelected(true, false, true);
  3888. Sys_UpdateWindows(W_ALL);
  3889. Undo_EndBrushList(&selected_brushes);
  3890. Undo_End();
  3891. }
  3892. void CMainFrame::OnCurveInsertInsertcolumn()
  3893. {
  3894. Undo_Start("insert (2) columns");
  3895. Undo_AddBrushList(&selected_brushes);
  3896. Patch_AdjustSelected(true, true, false);
  3897. Sys_UpdateWindows(W_ALL);
  3898. Undo_EndBrushList(&selected_brushes);
  3899. Undo_End();
  3900. }
  3901. void CMainFrame::OnCurveInsertInsertrow()
  3902. {
  3903. Undo_Start("insert (2) rows");
  3904. Undo_AddBrushList(&selected_brushes);
  3905. Patch_AdjustSelected(true, false, false);
  3906. Sys_UpdateWindows(W_ALL);
  3907. Undo_EndBrushList(&selected_brushes);
  3908. Undo_End();
  3909. }
  3910. void CMainFrame::OnCurveNegative()
  3911. {
  3912. Patch_ToggleInverted();
  3913. //Sys_UpdateWindows(W_ALL);
  3914. }
  3915. void CMainFrame::OnCurveNegativeTextureX()
  3916. {
  3917. Patch_InvertTexture(false);
  3918. //Sys_UpdateWindows(W_ALL);
  3919. }
  3920. void CMainFrame::OnCurveNegativeTextureY()
  3921. {
  3922. Patch_InvertTexture(true);
  3923. //Sys_UpdateWindows(W_ALL);
  3924. }
  3925. void CMainFrame::OnCurveDeleteFirstcolumn()
  3926. {
  3927. Undo_Start("delete first (2) columns");
  3928. Undo_AddBrushList(&selected_brushes);
  3929. Patch_AdjustSelected(false, true, true);
  3930. Sys_UpdateWindows(W_ALL);
  3931. Undo_EndBrushList(&selected_brushes);
  3932. Undo_End();
  3933. }
  3934. void CMainFrame::OnCurveDeleteFirstrow()
  3935. {
  3936. Undo_Start("delete first (2) rows");
  3937. Undo_AddBrushList(&selected_brushes);
  3938. Patch_AdjustSelected(false, false, true);
  3939. Sys_UpdateWindows(W_ALL);
  3940. Undo_EndBrushList(&selected_brushes);
  3941. Undo_End();
  3942. }
  3943. void CMainFrame::OnCurveDeleteLastcolumn()
  3944. {
  3945. Undo_Start("delete last (2) columns");
  3946. Undo_AddBrushList(&selected_brushes);
  3947. Patch_AdjustSelected(false, true, false);
  3948. Sys_UpdateWindows(W_ALL);
  3949. Undo_EndBrushList(&selected_brushes);
  3950. Undo_End();
  3951. }
  3952. void CMainFrame::OnCurveDeleteLastrow()
  3953. {
  3954. Undo_Start("delete last (2) rows");
  3955. Undo_AddBrushList(&selected_brushes);
  3956. Patch_AdjustSelected(false, false, false);
  3957. Sys_UpdateWindows(W_ALL);
  3958. Undo_EndBrushList(&selected_brushes);
  3959. Undo_End();
  3960. }
  3961. void CMainFrame::OnPatchBend()
  3962. {
  3963. Patch_BendToggle();
  3964. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_BEND, (g_bPatchBendMode) ? TRUE : FALSE);
  3965. Sys_UpdateWindows(W_ALL);
  3966. }
  3967. void CMainFrame::OnPatchInsdel()
  3968. {
  3969. Patch_InsDelToggle();
  3970. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_INSDEL, (g_bPatchInsertMode) ? TRUE : FALSE);
  3971. Sys_UpdateWindows(W_ALL);
  3972. }
  3973. void CMainFrame::OnPatchEnter()
  3974. {
  3975. }
  3976. void CMainFrame::OnPatchTab()
  3977. {
  3978. if (g_bPatchBendMode)
  3979. Patch_BendHandleTAB();
  3980. else if (g_bPatchInsertMode)
  3981. Patch_InsDelHandleTAB();
  3982. else
  3983. {
  3984. // check to see if the selected brush is part of a func group
  3985. // if it is, deselect everything and reselect the next brush
  3986. // in the group
  3987. brush_t *b = selected_brushes.next;
  3988. entity_t * e;
  3989. if (b != &selected_brushes)
  3990. {
  3991. if (strcmpi(b->owner->eclass->name, "worldspawn") != 0)
  3992. {
  3993. e = b->owner;
  3994. Select_Deselect();
  3995. for (brush_t * b2 = e->brushes.onext ; b2 != &e->brushes ; b2 = b2->onext)
  3996. {
  3997. if (b == b2)
  3998. {
  3999. b2 = b2->onext;
  4000. break;
  4001. }
  4002. }
  4003. if (b2 == &e->brushes)
  4004. b2 = b2->onext;
  4005. Select_Brush(b2, false);
  4006. Sys_UpdateWindows(W_ALL);
  4007. }
  4008. }
  4009. }
  4010. }
  4011. void CMainFrame::UpdatePatchToolbarButtons()
  4012. {
  4013. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_BEND, (g_bPatchBendMode) ? TRUE : FALSE);
  4014. m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_INSDEL, (g_bPatchInsertMode) ? TRUE : FALSE);
  4015. }
  4016. void CMainFrame::OnCurvePatchdensetube()
  4017. {
  4018. Undo_Start("dense cylinder");
  4019. Undo_AddBrushList(&selected_brushes);
  4020. Patch_BrushToMesh(false);
  4021. OnCurveInsertAddrow();
  4022. OnCurveInsertInsertrow();
  4023. Sys_UpdateWindows (W_ALL);
  4024. Undo_EndBrushList(&selected_brushes);
  4025. Undo_End();
  4026. }
  4027. void CMainFrame::OnCurvePatchverydensetube()
  4028. {
  4029. Undo_Start("very dense cylinder");
  4030. Undo_AddBrushList(&selected_brushes);
  4031. Patch_BrushToMesh(false);
  4032. OnCurveInsertAddrow();
  4033. OnCurveInsertInsertrow();
  4034. OnCurveInsertAddrow();
  4035. OnCurveInsertInsertrow();
  4036. Sys_UpdateWindows (W_ALL);
  4037. Undo_EndBrushList(&selected_brushes);
  4038. Undo_End();
  4039. }
  4040. void CMainFrame::OnCurveCap()
  4041. {
  4042. Patch_CapCurrent();
  4043. Sys_UpdateWindows (W_ALL);
  4044. }
  4045. void CMainFrame::OnCurveCapInvertedbevel()
  4046. {
  4047. Patch_CapCurrent(true);
  4048. Sys_UpdateWindows (W_ALL);
  4049. }
  4050. void CMainFrame::OnCurveCapInvertedendcap()
  4051. {
  4052. Patch_CapCurrent(false, true);
  4053. Sys_UpdateWindows (W_ALL);
  4054. }
  4055. void CMainFrame::OnCurveRedisperseCols()
  4056. {
  4057. Patch_DisperseColumns();
  4058. Sys_UpdateWindows (W_ALL);
  4059. }
  4060. void CMainFrame::OnCurveRedisperseRows()
  4061. {
  4062. Patch_DisperseRows();
  4063. Sys_UpdateWindows (W_ALL);
  4064. }
  4065. void CMainFrame::OnPatchNaturalize()
  4066. {
  4067. Patch_NaturalizeSelected();
  4068. Sys_UpdateWindows (W_ALL);
  4069. }
  4070. void CMainFrame::OnSnapToGrid()
  4071. {
  4072. Select_SnapToGrid();
  4073. Sys_UpdateWindows (W_ALL);
  4074. }
  4075. void CMainFrame::OnCurvePatchsquare()
  4076. {
  4077. Undo_Start("square cylinder");
  4078. Undo_AddBrushList(&selected_brushes);
  4079. Patch_BrushToMesh(false, false, false, true);
  4080. Sys_UpdateWindows (W_ALL);
  4081. Undo_EndBrushList(&selected_brushes);
  4082. Undo_End();
  4083. }
  4084. void CMainFrame::OnTerrainCreateFromBrush()
  4085. {
  4086. Terrain_BrushToMesh();
  4087. Sys_UpdateWindows (W_ALL);
  4088. }
  4089. void CMainFrame::CheckTextureScale(int id)
  4090. {
  4091. CMenu* pMenu = GetMenu();
  4092. if (pMenu)
  4093. {
  4094. pMenu->CheckMenuItem(ID_TEXTURES_TEXTUREWINDOWSCALE_10, MF_BYCOMMAND | MF_UNCHECKED);
  4095. pMenu->CheckMenuItem(ID_TEXTURES_TEXTUREWINDOWSCALE_25, MF_BYCOMMAND | MF_UNCHECKED);
  4096. pMenu->CheckMenuItem(ID_TEXTURES_TEXTUREWINDOWSCALE_50, MF_BYCOMMAND | MF_UNCHECKED);
  4097. pMenu->CheckMenuItem(ID_TEXTURES_TEXTUREWINDOWSCALE_100, MF_BYCOMMAND | MF_UNCHECKED);
  4098. pMenu->CheckMenuItem(ID_TEXTURES_TEXTUREWINDOWSCALE_200, MF_BYCOMMAND | MF_UNCHECKED);
  4099. pMenu->CheckMenuItem(id, MF_BYCOMMAND | MF_CHECKED);
  4100. }
  4101. g_PrefsDlg.SavePrefs();
  4102. Texture_ResetPosition();
  4103. Sys_UpdateWindows(W_TEXTURE);
  4104. }
  4105. void CMainFrame::OnTexturesTexturewindowscale10()
  4106. {
  4107. g_PrefsDlg.m_nTextureScale = 10;
  4108. CheckTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_10);
  4109. }
  4110. void CMainFrame::OnTexturesTexturewindowscale100()
  4111. {
  4112. g_PrefsDlg.m_nTextureScale = 100;
  4113. CheckTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_100);
  4114. }
  4115. void CMainFrame::OnTexturesTexturewindowscale200()
  4116. {
  4117. g_PrefsDlg.m_nTextureScale = 200;
  4118. CheckTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_200);
  4119. }
  4120. void CMainFrame::OnTexturesTexturewindowscale25()
  4121. {
  4122. g_PrefsDlg.m_nTextureScale = 25;
  4123. CheckTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_25);
  4124. }
  4125. void CMainFrame::OnTexturesTexturewindowscale50()
  4126. {
  4127. g_PrefsDlg.m_nTextureScale = 50;
  4128. CheckTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_50);
  4129. }
  4130. void CMainFrame::OnTexturesFlush()
  4131. {
  4132. Texture_Flush();
  4133. Sys_UpdateWindows(W_ALL);
  4134. }
  4135. void CMainFrame::OnCurveOverlayClear()
  4136. {
  4137. Patch_ClearOverlays();
  4138. Sys_UpdateWindows(W_ALL);
  4139. }
  4140. void CMainFrame::OnCurveOverlaySet()
  4141. {
  4142. Patch_SetOverlays();
  4143. Sys_UpdateWindows(W_ALL);
  4144. }
  4145. void CMainFrame::OnCurveThicken()
  4146. {
  4147. Undo_Start("curve thicken");
  4148. Undo_AddBrushList(&selected_brushes);
  4149. CDialogThick dlg;
  4150. if (dlg.DoModal() == IDOK)
  4151. {
  4152. Patch_Thicken(dlg.m_nAmount, dlg.m_bSeams);
  4153. Sys_UpdateWindows(W_ALL);
  4154. }
  4155. Undo_EndBrushList(&selected_brushes);
  4156. Undo_End();
  4157. }
  4158. void CMainFrame::OnCurveCyclecap()
  4159. {
  4160. Patch_NaturalizeSelected(true, true);
  4161. Sys_UpdateWindows (W_ALL);
  4162. }
  4163. void CMainFrame::OnCurveMatrixTranspose()
  4164. {
  4165. Patch_Transpose();
  4166. Sys_UpdateWindows (W_ALL);
  4167. }
  4168. void CMainFrame::OnTexturesReloadshaders()
  4169. {
  4170. CWaitCursor wait;
  4171. ReloadShaders();
  4172. Sys_UpdateWindows (W_ALL);
  4173. }
  4174. void CMainFrame::SetEntityCheck()
  4175. {
  4176. CMenu* pMenu = GetMenu();
  4177. if (pMenu)
  4178. {
  4179. pMenu->CheckMenuItem(ID_VIEW_ENTITIESAS_BOUNDINGBOX, MF_BYCOMMAND | (g_PrefsDlg.m_nEntityShowState == ENTITY_BOX) ? MF_CHECKED : MF_UNCHECKED);
  4180. pMenu->CheckMenuItem(ID_VIEW_ENTITIESAS_WIREFRAME, MF_BYCOMMAND | (g_PrefsDlg.m_nEntityShowState == ENTITY_WIRE) ? MF_CHECKED : MF_UNCHECKED);
  4181. pMenu->CheckMenuItem(ID_VIEW_ENTITIESAS_SELECTEDWIREFRAME, MF_BYCOMMAND | (g_PrefsDlg.m_nEntityShowState == ENTITY_SELECTED) ? MF_CHECKED : MF_UNCHECKED);
  4182. pMenu->CheckMenuItem(ID_VIEW_ENTITIESAS_SELECTEDSKINNED, MF_BYCOMMAND | (g_PrefsDlg.m_nEntityShowState == ENTITY_SELECTED_SKIN) ? MF_CHECKED : MF_UNCHECKED);
  4183. pMenu->CheckMenuItem(ID_VIEW_ENTITIESAS_SKINNED, MF_BYCOMMAND | (g_PrefsDlg.m_nEntityShowState == ENTITY_SKINNED) ? MF_CHECKED : MF_UNCHECKED);
  4184. pMenu->CheckMenuItem(ID_VIEW_ENTITIESAS_SKINNEDANDBOXED, MF_BYCOMMAND | (g_PrefsDlg.m_nEntityShowState == ENTITY_SKINNED_BOXED) ? MF_CHECKED : MF_UNCHECKED);
  4185. }
  4186. }
  4187. void CMainFrame::OnShowEntities()
  4188. {
  4189. HandlePopup(this, IDR_POPUP_ENTITY);
  4190. }
  4191. void CMainFrame::OnViewEntitiesasBoundingbox()
  4192. {
  4193. g_PrefsDlg.m_nEntityShowState = ENTITY_BOX;
  4194. SetEntityCheck();
  4195. g_PrefsDlg.SavePrefs();
  4196. Sys_UpdateWindows (W_ALL);
  4197. }
  4198. void CMainFrame::OnViewEntitiesasSelectedskinned()
  4199. {
  4200. g_PrefsDlg.m_nEntityShowState = ENTITY_SELECTED_SKIN;
  4201. SetEntityCheck();
  4202. g_PrefsDlg.SavePrefs();
  4203. Sys_UpdateWindows (W_ALL);
  4204. }
  4205. void CMainFrame::OnViewEntitiesasSelectedwireframe()
  4206. {
  4207. g_PrefsDlg.m_nEntityShowState = ENTITY_SELECTED;
  4208. SetEntityCheck();
  4209. g_PrefsDlg.SavePrefs();
  4210. Sys_UpdateWindows (W_ALL);
  4211. }
  4212. void CMainFrame::OnViewEntitiesasSkinned()
  4213. {
  4214. g_PrefsDlg.m_nEntityShowState = ENTITY_SKINNED;
  4215. SetEntityCheck();
  4216. g_PrefsDlg.SavePrefs();
  4217. Sys_UpdateWindows (W_ALL);
  4218. }
  4219. void CMainFrame::OnViewEntitiesasSkinnedandboxed()
  4220. {
  4221. g_PrefsDlg.m_nEntityShowState = ENTITY_SKINNED_BOXED;
  4222. SetEntityCheck();
  4223. g_PrefsDlg.SavePrefs();
  4224. Sys_UpdateWindows (W_ALL);
  4225. }
  4226. void CMainFrame::OnViewEntitiesasWireframe()
  4227. {
  4228. g_PrefsDlg.m_nEntityShowState = ENTITY_WIRE;
  4229. SetEntityCheck();
  4230. g_PrefsDlg.SavePrefs();
  4231. Sys_UpdateWindows (W_ALL);
  4232. }
  4233. void CMainFrame::OnPluginsRefresh()
  4234. {
  4235. CleanPlugInMenu();
  4236. CString str(g_strAppPath);
  4237. AddSlash(str);
  4238. str += "plugins\\";
  4239. m_PlugInMgr.Init(str);
  4240. }
  4241. void CMainFrame::CleanPlugInMenu()
  4242. {
  4243. m_nNextPlugInID = ID_PLUGIN_START;
  4244. CMenu* pMenu = GetMenu();
  4245. //--pMenu->RemoveMenu(MENU_PLUGIN, MF_BYPOSITION);
  4246. //--pMenu->InsertMenu(MENU_PLUGIN, MF_BYPOSITION, 0, "Plugins");
  4247. //--DrawMenuBar();
  4248. CMenu* pSub = pMenu->GetSubMenu(MENU_PLUGIN);
  4249. if (pSub)
  4250. {
  4251. int n = pSub->GetMenuItemCount();
  4252. for (int i = n; i > 1 ; i--)
  4253. {
  4254. pSub->RemoveMenu(i, MF_BYPOSITION);
  4255. }
  4256. }
  4257. }
  4258. void CMainFrame::AddPlugInMenuItem(CPlugIn* pPlugIn)
  4259. {
  4260. const char *menuText; //PGM
  4261. CMenu* pMenu = GetMenu();
  4262. CMenu* pSub = pMenu->GetSubMenu(MENU_PLUGIN);
  4263. if (pSub)
  4264. {
  4265. CMenu* pChild = new CMenu();
  4266. pChild->CreateMenu();
  4267. int nCount = pPlugIn->getCommandCount();
  4268. if (nCount > 0)
  4269. {
  4270. while (nCount > 0)
  4271. {
  4272. menuText = pPlugIn->getCommand(--nCount);
  4273. if (menuText != NULL && strlen(menuText) > 0)
  4274. {
  4275. if(!strcmp(menuText, "-"))
  4276. pChild->AppendMenu(MF_SEPARATOR, NULL);
  4277. else
  4278. pChild->AppendMenu(MF_STRING, m_nNextPlugInID, menuText);
  4279. pPlugIn->addMenuID(m_nNextPlugInID++);
  4280. }
  4281. }
  4282. pSub->AppendMenu(MF_POPUP, reinterpret_cast<unsigned int>(pChild->GetSafeHmenu()), pPlugIn->getMenuName());
  4283. }
  4284. }
  4285. }
  4286. void CMainFrame::OnPlugIn(unsigned int nID)
  4287. {
  4288. CMenu* pMenu = GetMenu();
  4289. CString str;
  4290. pMenu->GetMenuString(nID, str, MF_BYCOMMAND);
  4291. m_PlugInMgr.Dispatch(nID, str);
  4292. }
  4293. void CMainFrame::OnViewShowhint()
  4294. {
  4295. if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_HINT ) & EXCLUDE_HINT )
  4296. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWHINT, MF_BYCOMMAND | MF_UNCHECKED );
  4297. else
  4298. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWHINT, MF_BYCOMMAND | MF_CHECKED );
  4299. Sys_UpdateWindows (W_XY|W_CAMERA);
  4300. }
  4301. void CMainFrame::OnTexturesShowall()
  4302. {
  4303. Texture_ShowAll();
  4304. }
  4305. void CMainFrame::OnPatchInspector()
  4306. {
  4307. DoPatchInspector();
  4308. }
  4309. void CMainFrame::OnViewOpengllighting()
  4310. {
  4311. g_PrefsDlg.m_bGLLighting ^= 1;
  4312. g_PrefsDlg.SavePrefs();
  4313. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_OPENGLLIGHTING, MF_BYCOMMAND | (g_PrefsDlg.m_bGLLighting) ? MF_CHECKED : MF_UNCHECKED );
  4314. Sys_UpdateWindows (W_XY|W_CAMERA);
  4315. }
  4316. void CMainFrame::OnSelectAll()
  4317. {
  4318. Select_AllOfType();
  4319. }
  4320. void CMainFrame::OnViewShowcaulk()
  4321. {
  4322. if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_CAULK ) & EXCLUDE_CAULK )
  4323. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCAULK, MF_BYCOMMAND | MF_UNCHECKED );
  4324. else
  4325. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCAULK, MF_BYCOMMAND | MF_CHECKED );
  4326. Sys_UpdateWindows (W_XY|W_CAMERA);
  4327. }
  4328. void CMainFrame::OnCurveFreeze()
  4329. {
  4330. Patch_Freeze();
  4331. }
  4332. void CMainFrame::OnCurveUnFreeze()
  4333. {
  4334. Patch_UnFreeze(false);
  4335. }
  4336. void CMainFrame::OnCurveUnFreezeAll()
  4337. {
  4338. Patch_UnFreeze(true);
  4339. }
  4340. void CMainFrame::OnSelectReselect()
  4341. {
  4342. Select_Reselect();
  4343. }
  4344. void CMainFrame::OnViewShowangles()
  4345. {
  4346. if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_ANGLES ) & EXCLUDE_ANGLES )
  4347. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWANGLES, MF_BYCOMMAND | MF_UNCHECKED );
  4348. else
  4349. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWANGLES, MF_BYCOMMAND | MF_CHECKED );
  4350. Sys_UpdateWindows (W_XY|W_CAMERA);
  4351. }
  4352. void CMainFrame::OnEditSaveprefab()
  4353. {
  4354. CFileDialog dlgFile(FALSE, "pfb", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Prefab files (*.pfb)|*.pfb||", this);
  4355. char CurPath[1024];
  4356. if (g_PrefsDlg.m_strPrefabPath.GetLength() > 0)
  4357. {
  4358. strcpy(CurPath, g_PrefsDlg.m_strPrefabPath);
  4359. }
  4360. else
  4361. {
  4362. ::GetCurrentDirectory(1024, CurPath);
  4363. }
  4364. dlgFile.m_ofn.lpstrInitialDir = CurPath;
  4365. if (dlgFile.DoModal() == IDOK)
  4366. {
  4367. Map_SaveSelected(dlgFile.GetPathName().GetBuffer(0));
  4368. }
  4369. }
  4370. void CMainFrame::OnEditLoadprefab()
  4371. {
  4372. CFileDialog dlgFile(TRUE, "pfb", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Prefab files (*.pfb)|*.pfb||", this);
  4373. char CurPath[1024];
  4374. if (g_PrefsDlg.m_strPrefabPath.GetLength() > 0)
  4375. {
  4376. strcpy(CurPath, g_PrefsDlg.m_strPrefabPath);
  4377. }
  4378. else
  4379. {
  4380. ::GetCurrentDirectory(1024, CurPath);
  4381. }
  4382. dlgFile.m_ofn.lpstrInitialDir = CurPath;
  4383. if (dlgFile.DoModal() == IDOK)
  4384. {
  4385. Map_ImportFile(dlgFile.GetPathName().GetBuffer(0));
  4386. }
  4387. }
  4388. void CMainFrame::OnCurveMoreendcapsbevelsSquarebevel()
  4389. {
  4390. Undo_Start("square bevel");
  4391. Undo_AddBrushList(&selected_brushes);
  4392. Patch_BrushToMesh(false, true, false, true);
  4393. Sys_UpdateWindows (W_ALL);
  4394. Undo_EndBrushList(&selected_brushes);
  4395. Undo_End();
  4396. }
  4397. void CMainFrame::OnCurveMoreendcapsbevelsSquareendcap()
  4398. {
  4399. Undo_Start("square endcap");
  4400. Undo_AddBrushList(&selected_brushes);
  4401. Patch_BrushToMesh(false, false, true, true);
  4402. Sys_UpdateWindows (W_ALL);
  4403. Undo_EndBrushList(&selected_brushes);
  4404. Undo_End();
  4405. }
  4406. void CMainFrame::OnBrushPrimitivesSphere()
  4407. {
  4408. Undo_Start("make sphere");
  4409. Undo_AddBrushList(&selected_brushes);
  4410. DoSides(false, true);
  4411. Undo_EndBrushList(&selected_brushes);
  4412. Undo_End();
  4413. }
  4414. extern bool g_bCrossHairs;
  4415. void CMainFrame::OnViewCrosshair()
  4416. {
  4417. g_bCrossHairs ^= 1;
  4418. Sys_UpdateWindows (W_XY);
  4419. }
  4420. void CMainFrame::OnViewHideshowHideselected()
  4421. {
  4422. Select_Hide();
  4423. Select_Deselect();
  4424. }
  4425. void CMainFrame::OnViewHideshowShowhidden()
  4426. {
  4427. Select_ShowAllHidden();
  4428. }
  4429. void CMainFrame::OnTexturesShadersShow()
  4430. {
  4431. g_PrefsDlg.m_bShowShaders ^= 1;
  4432. CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_TEXTURES_SHADERS_SHOW, MF_BYCOMMAND | ((g_PrefsDlg.m_bShowShaders) ? MF_CHECKED : MF_UNCHECKED ));
  4433. Sys_UpdateWindows(W_TEXTURE);
  4434. }
  4435. void CMainFrame::OnTexturesFlushUnused()
  4436. {
  4437. Texture_FlushUnused();
  4438. Sys_UpdateWindows(W_TEXTURE);
  4439. }
  4440. void CMainFrame::OnSelectionInvert()
  4441. {
  4442. Select_Invert();
  4443. Sys_UpdateWindows(W_XY | W_Z | W_CAMERA);
  4444. }
  4445. void CMainFrame::OnViewGroups()
  4446. {
  4447. if (m_nCurrentStyle == 0 || m_nCurrentStyle == 3)
  4448. {
  4449. if (::IsWindowVisible(g_qeglobals.d_hwndEntity) && inspector_mode == W_GROUP)
  4450. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_HIDE);
  4451. else
  4452. {
  4453. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_NORMAL);
  4454. SetInspectorMode(W_GROUP);
  4455. }
  4456. }
  4457. else
  4458. {
  4459. if (inspector_mode == W_GROUP && m_nCurrentStyle != QR_QE4)
  4460. {
  4461. if (::IsWindowVisible(g_qeglobals.d_hwndEntity))
  4462. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_HIDE);
  4463. else
  4464. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_NORMAL);
  4465. }
  4466. else
  4467. {
  4468. ::ShowWindow(g_qeglobals.d_hwndEntity, SW_NORMAL);
  4469. SetInspectorMode(W_GROUP);
  4470. }
  4471. }
  4472. }
  4473. void CMainFrame::OnDropGroupAddtoWorld()
  4474. {
  4475. Select_AddToGroup("World");
  4476. Sys_UpdateWindows (W_ALL);
  4477. }
  4478. void CMainFrame::OnDropGroupName()
  4479. {
  4480. CNameDlg dlg("Name Selection", this);
  4481. if (dlg.DoModal() == IDOK)
  4482. {
  4483. Select_Name(dlg.m_strName);
  4484. Sys_UpdateWindows (W_ALL);
  4485. }
  4486. }
  4487. void CMainFrame::OnDropGroupNewgroup()
  4488. {
  4489. }
  4490. void CMainFrame::OnDropGroupRemove()
  4491. {
  4492. Select_AddToGroup("World");
  4493. Sys_UpdateWindows (W_ALL);
  4494. }
  4495. void CMainFrame::OnSplinesMode()
  4496. {
  4497. g_qeglobals.d_select_mode = sel_addpoint;
  4498. g_qeglobals.selectObject = g_splineList->getPositionObj();
  4499. g_splineList->clear();
  4500. g_splineList->startEdit(true);
  4501. showCameraInspector();
  4502. Sys_UpdateWindows(W_ALL);
  4503. }
  4504. void CMainFrame::OnSplinesLoad()
  4505. {
  4506. g_splineList->load("maps/test.camera");
  4507. g_splineList->buildCamera();
  4508. }
  4509. void CMainFrame::OnSplinesSave()
  4510. {
  4511. g_splineList->save("maps/test.camera");
  4512. }
  4513. void CMainFrame::OnSplinesEdit()
  4514. {
  4515. showCameraInspector();
  4516. Sys_UpdateWindows(W_ALL);
  4517. }
  4518. extern void testCamSpeed();
  4519. void CMainFrame::OnSplineTest()
  4520. {
  4521. long start = GetTickCount();
  4522. g_splineList->startCamera(start);
  4523. float cycle = g_splineList->getTotalTime();
  4524. long msecs = cycle * 1000;
  4525. long current = start;
  4526. vec3_t lookat;
  4527. VectorClear(lookat);
  4528. vec3_t dir;
  4529. while (current < start + msecs) {
  4530. float fov;
  4531. g_splineList->getCameraInfo(current, &g_pParentWnd->GetCamera()->Camera().origin[0], &dir[0], &fov);
  4532. g_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159;
  4533. g_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159;
  4534. g_pParentWnd->UpdateWindows(W_XY | W_CAMERA);
  4535. current = GetTickCount();
  4536. }
  4537. g_splineList->setRunning(false);
  4538. }
  4539. void CMainFrame::OnSplinesTarget()
  4540. {
  4541. }
  4542. void CMainFrame::OnSplinesTargetPoints()
  4543. {
  4544. }
  4545. void CMainFrame::OnSplinesCameraPoints()
  4546. {
  4547. }
  4548. void CMainFrame::OnPopupNewcameraInterpolated()
  4549. {
  4550. g_qeglobals.d_select_mode = sel_addpoint;
  4551. g_qeglobals.selectObject = g_splineList->startNewCamera(idCameraPosition::INTERPOLATED);
  4552. OnSplinesEdit();
  4553. }
  4554. void CMainFrame::OnPopupNewcameraSpline()
  4555. {
  4556. g_qeglobals.d_select_mode = sel_addpoint;
  4557. g_qeglobals.selectObject = g_splineList->startNewCamera(idCameraPosition::SPLINE);
  4558. OnSplinesEdit();
  4559. }
  4560. void CMainFrame::OnPopupNewcameraFixed()
  4561. {
  4562. g_qeglobals.d_select_mode = sel_addpoint;
  4563. g_qeglobals.selectObject = g_splineList->startNewCamera(idCameraPosition::FIXED);
  4564. OnSplinesEdit();
  4565. }