1 /*
2 ===========================================================================
3
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6
7 This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
8
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25
26 ===========================================================================
27 */
28
29 #include "tools/edit_gui_common.h"
30
31
32 #include "qe3.h"
33 #include "Radiant.h"
34 #include "ZWnd.h"
35 #include "CamWnd.h"
36 #include "MapInfo.h"
37 #include "MainFrm.h"
38 #include "RotateDlg.h"
39 #include "EntityListDlg.h"
40 #include "NewProjDlg.h"
41 #include "CommandsDlg.h"
42 #include "ScaleDialog.h"
43 #include "FindTextureDlg.h"
44 #include "SurfaceDlg.h"
45 #include "shlobj.h"
46 #include "DialogTextures.h"
47 #include "PatchDensityDlg.h"
48 #include "DialogThick.h"
49 #include "PatchDialog.h"
50 #include "Undo.h"
51 #include "NewTexWnd.h"
52 #include "splines.h"
53 #include "dlgcamera.h"
54 #include "mmsystem.h"
55 #include "LightDlg.h"
56 #include "GetString.h"
57 #include "EntKeyFindReplace.h"
58 #include "InspectorDialog.h"
59 #include "autocaulk.h"
60
61 #include "../../sys/win32/rc/common_resource.h"
62 #include "../comafx/DialogName.h"
63 #include "../comafx/DialogColorPicker.h"
64
65 #ifdef _DEBUG
66 #define new DEBUG_NEW
67 #undef THIS_FILE
68 static char THIS_FILE[] = __FILE__;
69 #endif
70
71 // globals
72 CString g_strAppPath; // holds the full path of the executable
73 CMainFrame *g_pParentWnd = NULL; // used to precast to CMainFrame
74 CPrefsDlg g_Preferences; // global prefs instance
75 CPrefsDlg &g_PrefsDlg = g_Preferences; // reference used throughout
76 int g_nUpdateBits = 0; // window update flags
77 bool g_bScreenUpdates = true; // whether window painting is active, used in a few places
78
79 //
80 // to disable updates for speed reasons both of the above should be made members
81 // of CMainFrame
82 // bool g_bSnapToGrid = true; // early use, no longer in use, clamping pref will
83 // be used
84 //
85 CString g_strProject; // holds the active project filename
86
87 #define D3XP_ID_FILE_SAVE_COPY ( WM_USER + 28476 )
88 #define D3XP_ID_SHOW_MODELS ( WM_USER + 28477 )
89
90 //
91 // CMainFrame
92 // command mapping stuff m_strCommand is the command string m_nKey is the windows
93 // VK_??? equivelant m_nModifiers are key states as follows bit 0 - shift 1 - alt
94 // 2 - control 4 - press only
95 //
96 #define SPEED_MOVE 32.0f
97 #define SPEED_TURN 22.5f
98
99 #define MAX_GRID 64.0f
100 #define MIN_GRID 0.125f
101
102 SCommandInfo g_Commands[] = {
103 { "Texture_AxialByHeight", 'U', 0, ID_SELECT_AXIALTEXTURE_BYHEIGHT },
104 { "Texture_AxialArbitrary", 'U', RAD_SHIFT, ID_SELECT_AXIALTEXTURE_ARBITRARY },
105 { "Texture_AxialByWidth", 'U', RAD_CONTROL, ID_SELECT_AXIALTEXTURE_BYWIDTH },
106 { "Texture_Decrement", VK_SUBTRACT, RAD_SHIFT, ID_SELECTION_TEXTURE_DEC },
107 { "Texture_Increment", VK_ADD, RAD_SHIFT, ID_SELECTION_TEXTURE_INC },
108 { "Texture_Fit", '5', RAD_SHIFT, ID_SELECTION_TEXTURE_FIT },
109 { "Texture_RotateClock", VK_NEXT, RAD_SHIFT, ID_SELECTION_TEXTURE_ROTATECLOCK },
110 { "Texture_RotateCounter", VK_PRIOR, RAD_SHIFT, ID_SELECTION_TEXTURE_ROTATECOUNTER },
111 { "Texture_ScaleUp", VK_UP, RAD_CONTROL, ID_SELECTION_TEXTURE_SCALEUP },
112 { "Texture_ScaleDown", VK_DOWN, RAD_CONTROL, ID_SELECTION_TEXTURE_SCALEDOWN },
113 { "Texture_ShiftLeft", VK_LEFT, RAD_SHIFT, ID_SELECTION_TEXTURE_SHIFTLEFT },
114 { "Texture_ShiftRight", VK_RIGHT, RAD_SHIFT, ID_SELECTION_TEXTURE_SHIFTRIGHT },
115 { "Texture_ShiftUp", VK_UP, RAD_SHIFT, ID_SELECTION_TEXTURE_SHIFTUP },
116 { "Texture_ShiftDown", VK_DOWN, RAD_SHIFT, ID_SELECTION_TEXTURE_SHIFTDOWN },
117 { "Texture_ScaleLeft", VK_LEFT, RAD_CONTROL, ID_SELECTION_TEXTURE_SCALELEFT },
118 { "Texture_ScaleRight", VK_RIGHT, RAD_CONTROL, ID_SELECTION_TEXTURE_SCALERIGHT },
119 { "Texture_InvertX", 'I', RAD_CONTROL|RAD_SHIFT, ID_CURVE_NEGATIVETEXTUREY },
120 { "Texture_InvertY", 'I', RAD_SHIFT, ID_CURVE_NEGATIVETEXTUREX },
121 { "Texture_ToggleLock", 'T', RAD_SHIFT, ID_TOGGLE_LOCK },
122
123 { "Texture_ShowAllTextures", 'A', RAD_CONTROL, ID_TEXTURES_SHOWALL },
124
125 { "Edit_Copy", 'C', RAD_CONTROL, ID_EDIT_COPYBRUSH },
126 { "Edit_Paste", 'V', RAD_CONTROL, ID_EDIT_PASTEBRUSH },
127 { "Edit_Undo", 'Z', RAD_CONTROL, ID_EDIT_UNDO },
128 { "Edit_Redo", 'Y', RAD_CONTROL, ID_EDIT_REDO },
129
130 { "Camera_Forward", VK_UP, 0, ID_CAMERA_FORWARD },
131 { "Camera_Back", VK_DOWN, 0, ID_CAMERA_BACK },
132 { "Camera_Left", VK_LEFT, 0, ID_CAMERA_LEFT },
133 { "Camera_Right", VK_RIGHT, 0, ID_CAMERA_RIGHT },
134 { "Camera_Up", 'D', 0, ID_CAMERA_UP },
135 { "Camera_Down", 'C', 0, ID_CAMERA_DOWN },
136 { "Camera_AngleUp", 'A', 0, ID_CAMERA_ANGLEUP },
137 { "Camera_AngleDown", 'Z', 0, ID_CAMERA_ANGLEDOWN },
138 // FIXME: DG: SteelStorm2 has bindings for Camera_Left and Camera_StrafeLeft switched (same for Right)
139 { "Camera_StrafeRight", VK_PERIOD, 0, ID_CAMERA_STRAFERIGHT },
140 { "Camera_StrafeLeft", VK_COMMA, 0, ID_CAMERA_STRAFELEFT },
141 { "Camera_UpFloor", VK_PRIOR, 0, ID_VIEW_UPFLOOR },
142 { "Camera_DownFloor", VK_NEXT, 0, ID_VIEW_DOWNFLOOR },
143 { "Camera_CenterView", VK_END, 0, ID_VIEW_CENTER },
144
145 { "Grid_ZoomOut", VK_INSERT, 0, ID_VIEW_ZOOMOUT },
146 { "FileSaveCopy", 'C', RAD_CONTROL|RAD_ALT|RAD_SHIFT, D3XP_ID_FILE_SAVE_COPY },
147 { "ShowHideModels", 'M', RAD_CONTROL, D3XP_ID_SHOW_MODELS },
148 { "NextView", VK_HOME, 0, ID_VIEW_NEXTVIEW },
149 { "Grid_ZoomIn", VK_DELETE, 0, ID_VIEW_ZOOMIN },
150
151 { "Grid_SetPoint5", '4', RAD_SHIFT, ID_GRID_POINT5 },
152 { "Grid_SetPoint25", '3', RAD_SHIFT, ID_GRID_POINT25 },
153 { "Grid_SetPoint125", '2', RAD_SHIFT, ID_GRID_POINT125 },
154 //{ "Grid_SetPoint0625", '1', RAD_SHIFT, ID_GRID_POINT0625 },
155 { "Grid_Set1", '1', 0, ID_GRID_1 },
156 { "Grid_Set2", '2', 0, ID_GRID_2 },
157 { "Grid_Set4", '3', 0, ID_GRID_4 },
158 { "Grid_Set8", '4', 0, ID_GRID_8 },
159 { "Grid_Set16", '5', 0, ID_GRID_16 },
160 { "Grid_Set32", '6', 0, ID_GRID_32 },
161 { "Grid_Set64", '7', 0, ID_GRID_64 },
162 { "Grid_Down", VK_OEM_4, 0, ID_GRID_PREV }, /* [{ in us layout */
163 { "Grid_Up", VK_OEM_6, 0, ID_GRID_NEXT }, /* ]} in US layouts */
164
165 { "Grid_Toggle", '0', 0, ID_GRID_TOGGLE },
166 { "Grid_ToggleSizePaint", 'Q', RAD_PRESS, ID_SELECTION_TOGGLESIZEPAINT },
167
168 { "Grid_PrecisionCursorMode",VK_F11, 0 , ID_PRECISION_CURSOR_CYCLE},
169
170 /* Begin SS2 Changes */
171 { "Grid_SetViewTop", VK_NUMPAD7, 0, ID_SET_VIEW_TOP },
172 { "Grid_SetViewSide", VK_NUMPAD3, 0, ID_SET_VIEW_SIDE },
173 { "Grid_SetViewFront", VK_NUMPAD1, 0, ID_SET_VIEW_FRONT },
174 /* End SS2 Changes */
175
176 { "Grid_NextView", VK_TAB, RAD_CONTROL, ID_VIEW_NEXTVIEW },
177 { "Grid_ToggleCrosshairs", 'X', RAD_SHIFT, ID_VIEW_CROSSHAIR },
178
179 { "Grid_ZZoomOut", VK_INSERT, RAD_CONTROL, ID_VIEW_ZZOOMOUT },
180 { "Grid_ZZoomIn", VK_DELETE, RAD_CONTROL, ID_VIEW_ZZOOMIN },
181
182 { "Brush_Make3Sided", '3', RAD_CONTROL, ID_BRUSH_3SIDED },
183 { "Brush_Make4Sided", '4', RAD_CONTROL, ID_BRUSH_4SIDED },
184 { "Brush_Make5Sided", '5', RAD_CONTROL, ID_BRUSH_5SIDED },
185 { "Brush_Make6Sided", '6', RAD_CONTROL, ID_BRUSH_6SIDED },
186 { "Brush_Make7Sided", '7', RAD_CONTROL, ID_BRUSH_7SIDED },
187 { "Brush_Make8Sided", '8', RAD_CONTROL, ID_BRUSH_8SIDED },
188 { "Brush_Make9Sided", '9', RAD_CONTROL, ID_BRUSH_9SIDED },
189
190 { "Leak_NextSpot", 'K', RAD_CONTROL|RAD_SHIFT, ID_MISC_NEXTLEAKSPOT },
191 { "Leak_PrevSpot", 'L', RAD_CONTROL|RAD_SHIFT, ID_MISC_PREVIOUSLEAKSPOT },
192
193 { "File_Open", 'O', RAD_CONTROL, ID_FILE_OPEN },
194 { "File_Save", 'S', RAD_CONTROL, ID_FILE_SAVE },
195
196 { "TAB", VK_TAB, 0, ID_PATCH_TAB },
197 { "TAB", VK_TAB, RAD_SHIFT, ID_PATCH_TAB },
198
199 { "Patch_BendMode", 'B', 0, ID_PATCH_BEND },
200 { "Patch_FreezeVertices", 'F', 0, ID_CURVE_FREEZE },
201 { "Patch_UnFreezeVertices", 'F', RAD_CONTROL, ID_CURVE_UNFREEZE },
202 { "Patch_UnFreezeAllVertices",'F', RAD_CONTROL|RAD_SHIFT, ID_CURVE_UNFREEZEALL },
203 { "Patch_Thicken", 'T', RAD_CONTROL, ID_CURVE_THICKEN },
204 { "Patch_ClearOverlays", 'Y', RAD_SHIFT, ID_CURVE_OVERLAY_CLEAR },
205 { "Patch_MakeOverlay", 'Y', 0, ID_CURVE_OVERLAY_SET },
206 { "Patch_CycleCapTexturing", 'P', RAD_CONTROL|RAD_SHIFT, ID_CURVE_CYCLECAP },
207 { "Patch_CycleCapTexturingAlt",'P', RAD_SHIFT, ID_CURVE_CYCLECAPALT },
208 { "Patch_InvertCurve", 'I', RAD_CONTROL, ID_CURVE_NEGATIVE },
209 { "Patch_IncPatchColumn", VK_ADD, RAD_CONTROL|RAD_SHIFT, ID_CURVE_INSERTCOLUMN },
210 { "Patch_IncPatchRow", VK_ADD, RAD_CONTROL, ID_CURVE_INSERTROW },
211 { "Patch_DecPatchColumn", VK_SUBTRACT, RAD_CONTROL|RAD_SHIFT, ID_CURVE_DELETECOLUMN },
212 { "Patch_DecPatchRow", VK_SUBTRACT, RAD_CONTROL, ID_CURVE_DELETEROW },
213 { "Patch_RedisperseRows", 'E', RAD_CONTROL, ID_CURVE_REDISPERSE_ROWS },
214 { "Patch_RedisperseCols", 'E', RAD_CONTROL|RAD_SHIFT, ID_CURVE_REDISPERSE_COLS },
215 { "Patch_Naturalize", 'N', RAD_CONTROL, ID_PATCH_NATURALIZE },
216 { "Patch_SnapToGrid", 'G', RAD_CONTROL, ID_SELECT_SNAPTOGRID },
217 { "Patch_CapCurrentCurve", 'C', RAD_SHIFT, ID_CURVE_CAP },
218
219 { "Clipper_Toggle", 'X', 0, ID_VIEW_CLIPPER },
220 { "Clipper_ClipSelected", VK_RETURN, 0, ID_CLIP_SELECTED },
221 { "Clipper_SplitSelected", VK_RETURN, RAD_SHIFT, ID_SPLIT_SELECTED },
222 { "Clipper_FlipClip", VK_RETURN, RAD_CONTROL, ID_FLIP_CLIP },
223
224 { "CameraClip_ZoomOut", VK_OEM_4, RAD_CONTROL, ID_VIEW_CUBEOUT },
225 { "CameraClip_ZoomIn", VK_OEM_5, RAD_CONTROL, ID_VIEW_CUBEIN },
226 { "CameraClip_Toggle", VK_OEM_6, RAD_CONTROL, ID_VIEW_CUBICCLIPPING },
227
228 { "ViewTab_EntityInfo", 'N', 0, ID_VIEW_ENTITY },
229 { "ViewTab_Console", 'O', 0, ID_VIEW_CONSOLE },
230 { "ViewTab_Textures", 'T', 0, ID_VIEW_TEXTURE },
231 { "ViewTab_MediaBrowser", 'M', 0, ID_VIEW_MEDIABROWSER },
232
233 { "Window_SurfaceInspector",'S', 0, ID_TEXTURES_INSPECTOR },
234 { "Window_PatchInspector", 'S', RAD_SHIFT, ID_PATCH_INSPECTOR },
235 { "Window_EntityList", 'I', 0, ID_EDIT_ENTITYINFO },
236 { "Window_Preferences", 'P', 0, ID_PREFS },
237 { "Window_ToggleCamera", 'C', RAD_CONTROL|RAD_SHIFT, ID_TOGGLECAMERA },
238 { "Window_ToggleView", 'V', RAD_CONTROL|RAD_SHIFT, ID_TOGGLEVIEW },
239 { "Window_ToggleZ", 'Z', RAD_CONTROL|RAD_SHIFT, ID_TOGGLEZ },
240 { "Window_LightEditor", 'J', 0, ID_PROJECTED_LIGHT },
241 { "Window_EntityColor", 'K', 0, ID_MISC_SELECTENTITYCOLOR },
242
243 { "Selection_DragEdges", 'E', 0, ID_SELECTION_DRAGEDGES },
244 { "Selection_DragVertices", 'V', 0, ID_SELECTION_DRAGVERTECIES },
245 { "Selection_Clone", VK_SPACE, 0, ID_SELECTION_CLONE },
246 { "Selection_Delete", VK_BACK, 0, ID_SELECTION_DELETE },
247 { "Selection_UnSelect", VK_ESCAPE, 0, ID_SELECTION_DESELECT },
248 { "Selection_Invert", 'I' , 0 , ID_SELECTION_INVERT },
249 { "Selection_ToggleMoveOnly",'W', 0, ID_SELECTION_MOVEONLY },
250
251 { "Selection_MoveDown", VK_SUBTRACT, 0, ID_SELECTION_MOVEDOWN },
252 { "Selection_MoveUp", VK_ADD, 0, ID_SELECTION_MOVEUP },
253 { "Selection_DumpBrush", 'D', RAD_SHIFT, ID_SELECTION_PRINT },
254 { "Selection_NudgeLeft", VK_LEFT, RAD_ALT, ID_SELECTION_SELECT_NUDGELEFT },
255 { "Selection_NudgeRight", VK_RIGHT, RAD_ALT, ID_SELECTION_SELECT_NUDGERIGHT },
256 { "Selection_NudgeUp", VK_UP, RAD_ALT, ID_SELECTION_SELECT_NUDGEUP },
257 { "Selection_NudgeDown", VK_DOWN, RAD_ALT, ID_SELECTION_SELECT_NUDGEDOWN },
258 { "Selection_Combine", 'K', RAD_SHIFT, ID_SELECTION_COMBINE },
259 { "Selection_Connect", 'K', RAD_CONTROL, ID_SELECTION_CONNECT },
260 { "Selection_Ungroup", 'G', RAD_SHIFT, ID_SELECTION_UNGROUPENTITY },
261 { "Selection_CSGMerge", 'M', RAD_SHIFT, ID_SELECTION_CSGMERGE },
262
263 { "Selection_CenterOrigin", 'O', RAD_SHIFT, ID_SELECTION_CENTER_ORIGIN },
264 { "Selection_SelectCompleteEntity", 'E' , RAD_CONTROL|RAD_ALT|RAD_SHIFT , ID_SELECT_COMPLETE_ENTITY },
265 { "Selection_SelectAllOfType", 'A', RAD_SHIFT, ID_SELECT_ALL },
266
267 { "Show_ToggleLights", '0' , RAD_ALT , ID_VIEW_SHOWLIGHTS },
268 { "Show_TogglePatches", 'P', RAD_CONTROL, ID_VIEW_SHOWCURVES },
269 { "Show_ToggleClip", 'L', RAD_CONTROL, ID_VIEW_SHOWCLIP },
270
271 { "Show_HideSelected", 'H', 0, ID_VIEW_HIDESHOW_HIDESELECTED },
272 { "Show_ShowHidden", 'H', RAD_SHIFT, ID_VIEW_HIDESHOW_SHOWHIDDEN },
273 { "Show_HideNotSelected", 'H', RAD_CONTROL|RAD_SHIFT, ID_VIEW_HIDESHOW_HIDENOTSELECTED },
274
275 { "Render_ToggleSound", VK_F9, 0, ID_VIEW_RENDERSOUND },
276 { "Render_ToggleSelections", VK_F8, 0, ID_VIEW_RENDERSELECTION },
277 { "Render_RebuildData", VK_F7, 0, ID_VIEW_REBUILDRENDERDATA },
278 { "Render_ToggleAnimation", VK_F6, 0, ID_VIEW_MATERIALANIMATION},
279 { "Render_ToggleEntityOutlines", VK_F5, 0, ID_VIEW_RENDERENTITYOUTLINES },
280 { "Render_ToggleRealtimeBuild", VK_F4, 0, ID_VIEW_REALTIMEREBUILD },
281 { "Render_Toggle", VK_F3, 0, ID_VIEW_RENDERMODE },
282
283 { "Find_Textures", 'F', RAD_SHIFT, ID_TEXTURE_REPLACEALL },
284 { "Find_Entity", VK_F3, RAD_CONTROL, ID_MISC_FINDORREPLACEENTITY},
285 { "Find_NextEntity", VK_F3,RAD_SHIFT, ID_MISC_FINDNEXTENT},
286
287 { "_ShowDOOM", VK_F2, 0, ID_SHOW_DOOM },
288
289 { "Rotate_MouseRotate", 'R', 0, ID_SELECT_MOUSEROTATE },
290 { "Rotate_ToggleFlatRotation", 'R', RAD_CONTROL, ID_VIEW_CAMERAUPDATE },
291 { "Rotate_CycleRotationAxis", 'R', RAD_SHIFT, ID_TOGGLE_ROTATELOCK },
292
293 { "_AutoCaulk", 'A', RAD_CONTROL|RAD_SHIFT, ID_AUTOCAULK }, // ctrl-shift-a, since SHIFT-A is already taken
294 };
295
296 int g_nCommandCount = sizeof(g_Commands) / sizeof(SCommandInfo);
297
298 SKeyInfo g_Keys[] = {
299 /* To understand the VK_* information, please read the MSDN:
300 http://msdn.microsoft.com/en-us/library/ms927178.aspx
301 */
302 { "Space", VK_SPACE },
303 { "Backspace", VK_BACK },
304 { "Escape", VK_ESCAPE },
305 { "End", VK_END },
306 { "Insert", VK_INSERT },
307 { "Delete", VK_DELETE },
308 { "PageUp", VK_PRIOR },
309 { "PageDown", VK_NEXT },
310 { "Up", VK_UP },
311 { "Down", VK_DOWN },
312 { "Left", VK_LEFT },
313 { "Right", VK_RIGHT },
314 { "F1", VK_F1 },
315 { "F2", VK_F2 },
316 { "F3", VK_F3 },
317 { "F4", VK_F4 },
318 { "F5", VK_F5 },
319 { "F6", VK_F6 },
320 { "F7", VK_F7 },
321 { "F8", VK_F8 },
322 { "F9", VK_F9 },
323 { "F10", VK_F10 },
324 { "F11", VK_F11 },
325 { "F12", VK_F12 },
326 { "Tab", VK_TAB },
327 { "Return", VK_RETURN },
328 { "Comma", VK_COMMA },
329 { "Period", VK_PERIOD },
330 { "Plus", VK_ADD },
331 { "Multiply", VK_MULTIPLY },
332 { "Subtract", VK_SUBTRACT },
333 { "NumPad0", VK_NUMPAD0 },
334 { "NumPad1", VK_NUMPAD1 },
335 { "NumPad2", VK_NUMPAD2 },
336 { "NumPad3", VK_NUMPAD3 },
337 { "NumPad4", VK_NUMPAD4 },
338 { "NumPad5", VK_NUMPAD5 },
339 { "NumPad6", VK_NUMPAD6 },
340 { "NumPad7", VK_NUMPAD7 },
341 { "NumPad8", VK_NUMPAD8 },
342 { "NumPad9", VK_NUMPAD9 },
343 { "[", VK_OEM_4 }, /* Was 219, 0xDB */
344 { "\\", VK_OEM_5 }, /* Was 220, 0xDC */
345 { "]", VK_OEM_6 }, /* Was 221, 0xDD */
346 };
347
348 int g_nKeyCount = sizeof(g_Keys) / sizeof(SKeyInfo);
349
350 const int CMD_TEXTUREWAD_END = CMD_TEXTUREWAD + 127;
351 const int CMD_BSPCOMMAND_END = CMD_BSPCOMMAND + 127;
352 const int IDMRU_END = IDMRU + 9;
353
354 const int g_msgBSPDone = RegisterWindowMessage(DMAP_DONE);
355 const int g_msgBSPStatus = RegisterWindowMessage(DMAP_MSGID);
356
357 IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd)
358 BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
359 //{{AFX_MSG_MAP(CMainFrame)
360 ON_WM_PARENTNOTIFY()
361 ON_WM_CREATE()
362 ON_WM_TIMER()
363 ON_WM_DESTROY()
364 ON_WM_CLOSE()
365 ON_WM_KEYDOWN()
366 ON_WM_SIZE()
367 ON_COMMAND(ID_VIEW_CAMERATOGGLE, ToggleCamera)
368 ON_COMMAND(ID_FILE_CLOSE, OnFileClose)
369 ON_COMMAND(ID_FILE_EXIT, OnFileExit)
370 ON_COMMAND(ID_FILE_LOADPROJECT, OnFileLoadproject)
371 ON_COMMAND(ID_FILE_NEW, OnFileNew)
372 ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
373 ON_COMMAND(ID_FILE_POINTFILE, OnFilePointfile)
374 ON_COMMAND(ID_FILE_PRINT, OnFilePrint)
375 ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview)
376 ON_COMMAND(ID_FILE_SAVE, OnFileSave)
377 ON_COMMAND(ID_FILE_SAVEAS, OnFileSaveas)
378 ON_COMMAND(D3XP_ID_FILE_SAVE_COPY, OnFileSaveCopy)
379 ON_COMMAND(D3XP_ID_SHOW_MODELS, OnViewShowModels )
380 ON_COMMAND(ID_VIEW_100, OnView100)
381 ON_COMMAND(ID_VIEW_CENTER, OnViewCenter)
382 ON_COMMAND(ID_VIEW_CONSOLE, OnViewConsole)
383 ON_COMMAND(ID_VIEW_DOWNFLOOR, OnViewDownfloor)
384 ON_COMMAND(ID_VIEW_ENTITY, OnViewEntity)
385 ON_COMMAND(ID_VIEW_MEDIABROWSER, OnViewMediaBrowser)
386 ON_COMMAND(ID_VIEW_FRONT, OnViewFront)
387 ON_COMMAND(ID_VIEW_SHOWBLOCKS, OnViewShowblocks)
388 ON_COMMAND(ID_VIEW_SHOWCLIP, OnViewShowclip)
389 ON_COMMAND(ID_VIEW_SHOWTRIGGERS, OnViewShowTriggers)
390 ON_COMMAND(ID_VIEW_SHOWCOORDINATES, OnViewShowcoordinates)
391 ON_COMMAND(ID_VIEW_SHOWENT, OnViewShowent)
392 ON_COMMAND(ID_VIEW_SHOWLIGHTS, OnViewShowlights)
393 ON_COMMAND(ID_VIEW_SHOWNAMES, OnViewShownames)
394 ON_COMMAND(ID_VIEW_SHOWPATH, OnViewShowpath)
395 ON_COMMAND(ID_VIEW_SHOWCOMBATNODES, OnViewShowCombatNodes)
396 ON_COMMAND(ID_VIEW_SHOWWATER, OnViewShowwater)
397 ON_COMMAND(ID_VIEW_SHOWWORLD, OnViewShowworld)
398 ON_COMMAND(ID_VIEW_TEXTURE, OnViewTexture)
399 ON_COMMAND(ID_VIEW_UPFLOOR, OnViewUpfloor)
400 ON_COMMAND(ID_VIEW_XY, OnViewXy)
401 ON_COMMAND(ID_VIEW_Z100, OnViewZ100)
402 ON_COMMAND(ID_VIEW_ZOOMIN, OnViewZoomin)
403 ON_COMMAND(ID_VIEW_ZOOMOUT, OnViewZoomout)
404 ON_COMMAND(ID_VIEW_ZZOOMIN, OnViewZzoomin)
405 ON_COMMAND(ID_VIEW_ZZOOMOUT, OnViewZzoomout)
406 ON_COMMAND(ID_VIEW_SIDE, OnViewSide)
407 ON_COMMAND(ID_TEXTURES_SHOWINUSE, OnTexturesShowinuse)
408 ON_COMMAND(ID_TEXTURES_INSPECTOR, OnTexturesInspector)
409 ON_COMMAND(ID_MISC_FINDBRUSH, OnMiscFindbrush)
410 ON_COMMAND(ID_MISC_GAMMA, OnMiscGamma)
411 ON_COMMAND(ID_MISC_NEXTLEAKSPOT, OnMiscNextleakspot)
412 ON_COMMAND(ID_MISC_PREVIOUSLEAKSPOT, OnMiscPreviousleakspot)
413 ON_COMMAND(ID_MISC_PRINTXY, OnMiscPrintxy)
414 ON_COMMAND(ID_MISC_SELECTENTITYCOLOR, OnMiscSelectentitycolor)
415 ON_COMMAND(ID_MISC_FINDORREPLACEENTITY, OnMiscFindOrReplaceEntity)
416 ON_COMMAND(ID_MISC_FINDNEXTENT, OnMiscFindNextEntity)
417 ON_COMMAND(ID_MISC_SETVIEWPOS, OnMiscSetViewPos)
418 ON_COMMAND(ID_TEXTUREBK, OnTexturebk)
419 ON_COMMAND(ID_COLORS_MAJOR, OnColorsMajor)
420 ON_COMMAND(ID_COLORS_MINOR, OnColorsMinor)
421 ON_COMMAND(ID_COLORS_XYBK, OnColorsXybk)
422 ON_COMMAND(ID_BRUSH_3SIDED, OnBrush3sided)
423 ON_COMMAND(ID_BRUSH_4SIDED, OnBrush4sided)
424 ON_COMMAND(ID_BRUSH_5SIDED, OnBrush5sided)
425 ON_COMMAND(ID_BRUSH_6SIDED, OnBrush6sided)
426 ON_COMMAND(ID_BRUSH_7SIDED, OnBrush7sided)
427 ON_COMMAND(ID_BRUSH_8SIDED, OnBrush8sided)
428 ON_COMMAND(ID_BRUSH_9SIDED, OnBrush9sided)
429 ON_COMMAND(ID_BRUSH_ARBITRARYSIDED, OnBrushArbitrarysided)
430 ON_COMMAND(ID_BRUSH_FLIPX, OnBrushFlipx)
431 ON_COMMAND(ID_BRUSH_FLIPY, OnBrushFlipy)
432 ON_COMMAND(ID_BRUSH_FLIPZ, OnBrushFlipz)
433 ON_COMMAND(ID_BRUSH_ROTATEX, OnBrushRotatex)
434 ON_COMMAND(ID_BRUSH_ROTATEY, OnBrushRotatey)
435 ON_COMMAND(ID_BRUSH_ROTATEZ, OnBrushRotatez)
436 ON_COMMAND(ID_REGION_OFF, OnRegionOff)
437 ON_COMMAND(ID_REGION_SETBRUSH, OnRegionSetbrush)
438 ON_COMMAND(ID_REGION_SETSELECTION, OnRegionSetselection)
439 ON_COMMAND(ID_REGION_SETTALLBRUSH, OnRegionSettallbrush)
440 ON_COMMAND(ID_REGION_SETXY, OnRegionSetxy)
441 ON_COMMAND(ID_SELECTION_ARBITRARYROTATION, OnSelectionArbitraryrotation)
442 ON_COMMAND(ID_SELECTION_CLONE, OnSelectionClone)
443 ON_COMMAND(ID_SELECTION_CONNECT, OnSelectionConnect)
444 ON_COMMAND(ID_SELECTION_CSGSUBTRACT, OnSelectionCsgsubtract)
445 ON_COMMAND(ID_SELECTION_CSGMERGE, OnSelectionCsgmerge)
446 ON_COMMAND(ID_SELECTION_DELETE, OnSelectionDelete)
447 ON_COMMAND(ID_SELECTION_DESELECT, OnSelectionDeselect)
448 ON_COMMAND(ID_SELECTION_DRAGEDGES, OnSelectionDragedges)
449 ON_COMMAND(ID_SELECTION_DRAGVERTECIES, OnSelectionDragvertecies)
450 ON_COMMAND(ID_SELECTION_CENTER_ORIGIN, OnSelectionCenterOrigin)
451 ON_COMMAND(ID_SELECTION_MAKEHOLLOW, OnSelectionMakehollow)
452 ON_COMMAND(ID_SELECTION_SELECTCOMPLETETALL, OnSelectionSelectcompletetall)
453 ON_COMMAND(ID_SELECTION_SELECTINSIDE, OnSelectionSelectinside)
454 ON_COMMAND(ID_SELECTION_SELECTPARTIALTALL, OnSelectionSelectpartialtall)
455 ON_COMMAND(ID_SELECTION_SELECTTOUCHING, OnSelectionSelecttouching)
456 ON_COMMAND(ID_SELECTION_UNGROUPENTITY, OnSelectionUngroupentity)
457 ON_COMMAND(ID_TEXTURES_POPUP, OnTexturesPopup)
458 ON_COMMAND(ID_SPLINES_POPUP, OnSplinesPopup)
459 ON_COMMAND(ID_SPLINES_EDITPOINTS, OnSplinesEditPoints)
460 ON_COMMAND(ID_SPLINES_ADDPOINTS, OnSplinesAddPoints)
461 ON_COMMAND(ID_SPLINES_INSERTPOINTS, OnSplinesInsertPoint)
462 ON_COMMAND(ID_SPLINES_DELETEPOINTS, OnSplinesDeletePoint)
463 ON_COMMAND(ID_POPUP_SELECTION, OnPopupSelection)
464 ON_COMMAND(ID_VIEW_CHANGE, OnViewChange)
465 ON_COMMAND(ID_VIEW_CAMERAUPDATE, OnViewCameraupdate)
466 ON_WM_SIZING()
467 ON_COMMAND(ID_HELP_ABOUT, OnHelpAbout)
468 ON_COMMAND(ID_VIEW_CLIPPER, OnViewClipper)
469 ON_COMMAND(ID_CAMERA_ANGLEDOWN, OnCameraAngledown)
470 ON_COMMAND(ID_CAMERA_ANGLEUP, OnCameraAngleup)
471 ON_COMMAND(ID_CAMERA_BACK, OnCameraBack)
472 ON_COMMAND(ID_CAMERA_DOWN, OnCameraDown)
473 ON_COMMAND(ID_CAMERA_FORWARD, OnCameraForward)
474 ON_COMMAND(ID_CAMERA_LEFT, OnCameraLeft)
475 ON_COMMAND(ID_CAMERA_RIGHT, OnCameraRight)
476 ON_COMMAND(ID_CAMERA_STRAFELEFT, OnCameraStrafeleft)
477 ON_COMMAND(ID_CAMERA_STRAFERIGHT, OnCameraStraferight)
478 ON_COMMAND(ID_CAMERA_UP, OnCameraUp)
479 ON_COMMAND(ID_GRID_TOGGLE, OnGridToggle)
480 ON_COMMAND(ID_PREFS, OnPrefs)
481 ON_COMMAND(ID_TOGGLECAMERA, OnTogglecamera)
482 ON_COMMAND(ID_TOGGLEVIEW, OnToggleview)
483 ON_COMMAND(ID_TOGGLEZ, OnTogglez)
484 ON_COMMAND(ID_TOGGLE_LOCK, OnToggleLock)
485 ON_COMMAND(ID_EDIT_MAPINFO, OnEditMapinfo)
486 ON_COMMAND(ID_EDIT_ENTITYINFO, OnEditEntityinfo)
487 ON_COMMAND(ID_VIEW_NEXTVIEW, OnViewNextview)
488 ON_COMMAND(ID_SET_VIEW_TOP, OnSetViewTop)
489 ON_COMMAND(ID_SET_VIEW_SIDE, OnSetViewSide)
490 ON_COMMAND(ID_SET_VIEW_FRONT, OnSetViewFront)
491 ON_COMMAND(ID_HELP_COMMANDLIST, OnHelpCommandlist)
492 ON_COMMAND(ID_FILE_NEWPROJECT, OnFileNewproject)
493 ON_COMMAND(ID_FLIP_CLIP, OnFlipClip)
494 ON_COMMAND(ID_CLIP_SELECTED, OnClipSelected)
495 ON_COMMAND(ID_SPLIT_SELECTED, OnSplitSelected)
496 ON_COMMAND(ID_TOGGLEVIEW_XZ, OnToggleviewXz)
497 ON_COMMAND(ID_TOGGLEVIEW_YZ, OnToggleviewYz)
498 ON_COMMAND(ID_COLORS_BRUSH, OnColorsBrush)
499 ON_COMMAND(ID_COLORS_CLIPPER, OnColorsClipper)
500 ON_COMMAND(ID_COLORS_GRIDTEXT, OnColorsGridtext)
501 ON_COMMAND(ID_COLORS_SELECTEDBRUSH, OnColorsSelectedbrush)
502 ON_COMMAND(ID_COLORS_GRIDBLOCK, OnColorsGridblock)
503 ON_COMMAND(ID_COLORS_VIEWNAME, OnColorsViewname)
504 ON_COMMAND(ID_COLOR_SETORIGINAL, OnColorSetoriginal)
505 ON_COMMAND(ID_COLOR_SETQER, OnColorSetqer)
506 ON_COMMAND(ID_COLOR_SUPERMAL, OnColorSetSuperMal)
507 ON_COMMAND(ID_THEMES_MAX , OnColorSetMax )
508 ON_COMMAND(ID_COLOR_SETBLACK, OnColorSetblack)
509 ON_COMMAND(ID_SNAPTOGRID, OnSnaptogrid)
510 ON_COMMAND(ID_SELECT_SCALE, OnSelectScale)
511 ON_COMMAND(ID_SELECT_MOUSEROTATE, OnSelectMouserotate)
512 ON_COMMAND(ID_EDIT_COPYBRUSH, OnEditCopybrush)
513 ON_COMMAND(ID_EDIT_PASTEBRUSH, OnEditPastebrush)
514 ON_COMMAND(ID_EDIT_UNDO, OnEditUndo)
515 ON_COMMAND(ID_EDIT_REDO, OnEditRedo)
516 ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo)
517 ON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateEditRedo)
518 ON_COMMAND(ID_SELECTION_INVERT, OnSelectionInvert)
519 ON_COMMAND(ID_SELECTION_TEXTURE_DEC, OnSelectionTextureDec)
520 ON_COMMAND(ID_SELECTION_TEXTURE_FIT, OnSelectionTextureFit)
521 ON_COMMAND(ID_SELECTION_TEXTURE_INC, OnSelectionTextureInc)
522 ON_COMMAND(ID_SELECTION_TEXTURE_ROTATECLOCK, OnSelectionTextureRotateclock)
523 ON_COMMAND(ID_SELECTION_TEXTURE_ROTATECOUNTER, OnSelectionTextureRotatecounter)
524 ON_COMMAND(ID_SELECTION_TEXTURE_SCALEDOWN, OnSelectionTextureScaledown)
525 ON_COMMAND(ID_SELECTION_TEXTURE_SCALEUP, OnSelectionTextureScaleup)
526 ON_COMMAND(ID_SELECTION_TEXTURE_SHIFTDOWN, OnSelectionTextureShiftdown)
527 ON_COMMAND(ID_SELECTION_TEXTURE_SHIFTLEFT, OnSelectionTextureShiftleft)
528 ON_COMMAND(ID_SELECTION_TEXTURE_SHIFTRIGHT, OnSelectionTextureShiftright)
529 ON_COMMAND(ID_SELECTION_TEXTURE_SHIFTUP, OnSelectionTextureShiftup)
530 ON_COMMAND(ID_GRID_NEXT, OnGridNext)
531 ON_COMMAND(ID_GRID_PREV, OnGridPrev)
532 ON_COMMAND(ID_SELECTION_TEXTURE_SCALELEFT, OnSelectionTextureScaleLeft)
533 ON_COMMAND(ID_SELECTION_TEXTURE_SCALERIGHT, OnSelectionTextureScaleRight)
534 ON_COMMAND(ID_TEXTURE_REPLACEALL, OnTextureReplaceall)
535 ON_COMMAND(ID_SCALELOCKX, OnScalelockx)
536 ON_COMMAND(ID_SCALELOCKY, OnScalelocky)
537 ON_COMMAND(ID_SCALELOCKZ, OnScalelockz)
538 ON_COMMAND(ID_SELECT_MOUSESCALE, OnSelectMousescale)
539 ON_COMMAND(ID_VIEW_CUBICCLIPPING, OnViewCubicclipping)
540 ON_COMMAND(ID_FILE_IMPORT, OnFileImport)
541 ON_COMMAND(ID_FILE_PROJECTSETTINGS, OnFileProjectsettings)
542 ON_UPDATE_COMMAND_UI(ID_FILE_IMPORT, OnUpdateFileImport)
543 ON_COMMAND(ID_VIEW_CUBEIN, OnViewCubein)
544 ON_COMMAND(ID_VIEW_CUBEOUT, OnViewCubeout)
545 ON_COMMAND(ID_FILE_SAVEREGION, OnFileSaveregion)
546 ON_UPDATE_COMMAND_UI(ID_FILE_SAVEREGION, OnUpdateFileSaveregion)
547 ON_COMMAND(ID_SELECTION_MOVEDOWN, OnSelectionMovedown)
548 ON_COMMAND(ID_SELECTION_MOVEUP, OnSelectionMoveup)
549 ON_COMMAND(ID_TOOLBAR_MAIN, OnToolbarMain)
550 ON_COMMAND(ID_TOOLBAR_TEXTURE, OnToolbarTexture)
551 ON_COMMAND(ID_SELECTION_PRINT, OnSelectionPrint)
552 ON_COMMAND(ID_SELECTION_TOGGLESIZEPAINT, OnSelectionTogglesizepaint)
553 ON_COMMAND(ID_BRUSH_MAKECONE, OnBrushMakecone)
554 ON_COMMAND(ID_TEXTURES_LOAD, OnTexturesLoad)
555 ON_COMMAND(ID_TOGGLE_ROTATELOCK, OnToggleRotatelock)
556 ON_COMMAND(ID_CURVE_BEVEL, OnCurveBevel)
557 ON_COMMAND(ID_CURVE_INCREASE_VERT, OnCurveIncreaseVert)
558 ON_COMMAND(ID_CURVE_DECREASE_VERT, OnCurveDecreaseVert)
559 ON_COMMAND(ID_CURVE_INCREASE_HORZ, OnCurveIncreaseHorz)
560 ON_COMMAND(ID_CURVE_DECREASE_HORZ, OnCurveDecreaseHorz)
561 ON_COMMAND(ID_CURVE_CYLINDER, OnCurveCylinder)
562 ON_COMMAND(ID_CURVE_EIGHTHSPHERE, OnCurveEighthsphere)
563 ON_COMMAND(ID_CURVE_ENDCAP, OnCurveEndcap)
564 ON_COMMAND(ID_CURVE_HEMISPHERE, OnCurveHemisphere)
565 ON_COMMAND(ID_CURVE_INVERTCURVE, OnCurveInvertcurve)
566 ON_COMMAND(ID_CURVE_QUARTER, OnCurveQuarter)
567 ON_COMMAND(ID_CURVE_SPHERE, OnCurveSphere)
568 ON_COMMAND(ID_FILE_IMPORTMAP, OnFileImportmap)
569 ON_COMMAND(ID_FILE_EXPORTMAP, OnFileExportmap)
570 ON_COMMAND(ID_EDIT_LOADPREFAB, OnEditLoadprefab)
571 ON_COMMAND(ID_VIEW_SHOWCURVES, OnViewShowcurves)
572 ON_COMMAND(ID_SELECTION_SELECT_NUDGEDOWN, OnSelectionSelectNudgedown)
573 ON_COMMAND(ID_SELECTION_SELECT_NUDGELEFT, OnSelectionSelectNudgeleft)
574 ON_COMMAND(ID_SELECTION_SELECT_NUDGERIGHT, OnSelectionSelectNudgeright)
575 ON_COMMAND(ID_SELECTION_SELECT_NUDGEUP, OnSelectionSelectNudgeup)
576 ON_WM_SYSKEYDOWN()
577 ON_COMMAND(ID_TEXTURES_LOADLIST, OnTexturesLoadlist)
578 ON_COMMAND(ID_DYNAMIC_LIGHTING, OnDynamicLighting)
579 ON_COMMAND(ID_CURVE_SIMPLEPATCHMESH, OnCurveSimplepatchmesh)
580 ON_COMMAND(ID_PATCH_SHOWBOUNDINGBOX, OnPatchToggleBox)
581 ON_COMMAND(ID_PATCH_WIREFRAME, OnPatchWireframe)
582 ON_COMMAND(ID_CURVE_PATCHCONE, OnCurvePatchcone)
583 ON_COMMAND(ID_CURVE_PATCHTUBE, OnCurvePatchtube)
584 ON_COMMAND(ID_PATCH_WELD, OnPatchWeld)
585 ON_COMMAND(ID_CURVE_PATCHBEVEL, OnCurvePatchbevel)
586 ON_COMMAND(ID_CURVE_PATCHENDCAP, OnCurvePatchendcap)
587 ON_COMMAND(ID_CURVE_PATCHINVERTEDBEVEL, OnCurvePatchinvertedbevel)
588 ON_COMMAND(ID_CURVE_PATCHINVERTEDENDCAP, OnCurvePatchinvertedendcap)
589 ON_COMMAND(ID_PATCH_DRILLDOWN, OnPatchDrilldown)
590 ON_COMMAND(ID_CURVE_INSERTCOLUMN, OnCurveInsertcolumn)
591 ON_COMMAND(ID_CURVE_INSERTROW, OnCurveInsertrow)
592 ON_COMMAND(ID_CURVE_DELETECOLUMN, OnCurveDeletecolumn)
593 ON_COMMAND(ID_CURVE_DELETEROW, OnCurveDeleterow)
594 ON_COMMAND(ID_CURVE_INSERT_ADDCOLUMN, OnCurveInsertAddcolumn)
595 ON_COMMAND(ID_CURVE_INSERT_ADDROW, OnCurveInsertAddrow)
596 ON_COMMAND(ID_CURVE_INSERT_INSERTCOLUMN, OnCurveInsertInsertcolumn)
597 ON_COMMAND(ID_CURVE_INSERT_INSERTROW, OnCurveInsertInsertrow)
598 ON_COMMAND(ID_CURVE_NEGATIVE, OnCurveNegative)
599 ON_COMMAND(ID_CURVE_NEGATIVETEXTUREX, OnCurveNegativeTextureX)
600 ON_COMMAND(ID_CURVE_NEGATIVETEXTUREY, OnCurveNegativeTextureY)
601 ON_COMMAND(ID_CURVE_DELETE_FIRSTCOLUMN, OnCurveDeleteFirstcolumn)
602 ON_COMMAND(ID_CURVE_DELETE_FIRSTROW, OnCurveDeleteFirstrow)
603 ON_COMMAND(ID_CURVE_DELETE_LASTCOLUMN, OnCurveDeleteLastcolumn)
604 ON_COMMAND(ID_CURVE_DELETE_LASTROW, OnCurveDeleteLastrow)
605 ON_COMMAND(ID_PATCH_BEND, OnPatchBend)
606 ON_COMMAND(ID_PATCH_INSDEL, OnPatchInsdel)
607 ON_COMMAND(ID_PATCH_ENTER, OnPatchEnter)
608 ON_COMMAND(ID_PATCH_TAB, OnPatchTab)
609 ON_COMMAND(ID_CURVE_PATCHDENSETUBE, OnCurvePatchdensetube)
610 ON_COMMAND(ID_CURVE_PATCHVERYDENSETUBE, OnCurvePatchverydensetube)
611 ON_COMMAND(ID_CURVE_CAP, OnCurveCap)
612 ON_COMMAND(ID_CURVE_CAP_INVERTEDBEVEL, OnCurveCapInvertedbevel)
613 ON_COMMAND(ID_CURVE_CAP_INVERTEDENDCAP, OnCurveCapInvertedendcap)
614 ON_COMMAND(ID_CURVE_REDISPERSE_COLS, OnCurveRedisperseCols)
615 ON_COMMAND(ID_CURVE_REDISPERSE_ROWS, OnCurveRedisperseRows)
616 ON_COMMAND(ID_PATCH_NATURALIZE, OnPatchNaturalize)
617 ON_COMMAND(ID_PATCH_NATURALIZEALT, OnPatchNaturalizeAlt)
618 ON_COMMAND(ID_SELECT_SNAPTOGRID, OnSnapToGrid)
619 ON_COMMAND(ID_CURVE_PATCHSQUARE, OnCurvePatchsquare)
620 ON_COMMAND(ID_TEXTURES_TEXTUREWINDOWSCALE_10, OnTexturesTexturewindowscale10)
621 ON_COMMAND(ID_TEXTURES_TEXTUREWINDOWSCALE_100, OnTexturesTexturewindowscale100)
622 ON_COMMAND(ID_TEXTURES_TEXTUREWINDOWSCALE_200, OnTexturesTexturewindowscale200)
623 ON_COMMAND(ID_TEXTURES_TEXTUREWINDOWSCALE_25, OnTexturesTexturewindowscale25)
624 ON_COMMAND(ID_TEXTURES_TEXTUREWINDOWSCALE_50, OnTexturesTexturewindowscale50)
625 ON_COMMAND(ID_TEXTURES_FLUSH, OnTexturesFlush)
626 ON_COMMAND(ID_CURVE_OVERLAY_CLEAR, OnCurveOverlayClear)
627 ON_COMMAND(ID_CURVE_OVERLAY_SET, OnCurveOverlaySet)
628 ON_COMMAND(ID_CURVE_THICKEN, OnCurveThicken)
629 ON_COMMAND(ID_CURVE_CYCLECAP, OnCurveCyclecap)
630 ON_COMMAND(ID_CURVE_CYCLECAPALT, OnCurveCyclecapAlt)
631 ON_COMMAND(ID_CURVE_MATRIX_TRANSPOSE, OnCurveMatrixTranspose)
632 ON_COMMAND(ID_TEXTURES_RELOADSHADERS, OnTexturesReloadshaders)
633 ON_COMMAND(ID_SHOW_ENTITIES, OnShowEntities)
634 ON_COMMAND(ID_VIEW_ENTITIESAS_SKINNED, OnViewEntitiesasSkinned)
635 ON_COMMAND(ID_VIEW_ENTITIESAS_WIREFRAME, OnViewEntitiesasWireframe)
636 ON_COMMAND(ID_VIEW_SHOWHINT, OnViewShowhint)
637 ON_UPDATE_COMMAND_UI(ID_TEXTURES_SHOWINUSE, OnUpdateTexturesShowinuse)
638 ON_COMMAND(ID_TEXTURES_SHOWALL, OnTexturesShowall)
639 ON_COMMAND(ID_TEXTURES_HIDEALL, OnTexturesHideall)
640 ON_COMMAND(ID_PATCH_INSPECTOR, OnPatchInspector)
641 ON_COMMAND(ID_VIEW_OPENGLLIGHTING, OnViewOpengllighting)
642 ON_COMMAND(ID_SELECT_ALL, OnSelectAll)
643 ON_COMMAND(ID_VIEW_SHOWCAULK, OnViewShowcaulk)
644 ON_COMMAND(ID_CURVE_FREEZE, OnCurveFreeze)
645 ON_COMMAND(ID_CURVE_UNFREEZE, OnCurveUnFreeze)
646 ON_COMMAND(ID_CURVE_UNFREEZEALL, OnCurveUnFreezeAll)
647 ON_COMMAND(ID_SELECT_RESELECT, OnSelectReselect)
648 ON_COMMAND(ID_VIEW_SHOWANGLES, OnViewShowangles)
649 ON_COMMAND(ID_EDIT_SAVEPREFAB, OnEditSaveprefab)
650 ON_COMMAND(ID_CURVE_MOREENDCAPSBEVELS_SQUAREBEVEL, OnCurveMoreendcapsbevelsSquarebevel)
651 ON_COMMAND(ID_CURVE_MOREENDCAPSBEVELS_SQUAREENDCAP, OnCurveMoreendcapsbevelsSquareendcap)
652 ON_COMMAND(ID_BRUSH_PRIMITIVES_SPHERE, OnBrushPrimitivesSphere)
653 ON_COMMAND(ID_VIEW_CROSSHAIR, OnViewCrosshair)
654 ON_COMMAND(ID_VIEW_HIDESHOW_HIDESELECTED, OnViewHideshowHideselected)
655 ON_COMMAND(ID_VIEW_HIDESHOW_HIDENOTSELECTED, OnViewHideshowHideNotselected)
656 ON_COMMAND(ID_VIEW_HIDESHOW_SHOWHIDDEN, OnViewHideshowShowhidden)
657 ON_COMMAND(ID_TEXTURES_SHADERS_SHOW, OnTexturesShadersShow)
658 ON_COMMAND(ID_TEXTURES_FLUSH_UNUSED, OnTexturesFlushUnused)
659 ON_COMMAND(ID_PROJECTED_LIGHT, OnProjectedLight)
660 ON_COMMAND(ID_SHOW_LIGHTTEXTURES, OnShowLighttextures)
661 ON_COMMAND(ID_SHOW_LIGHTVOLUMES, OnShowLightvolumes)
662 ON_WM_ACTIVATE()
663 ON_COMMAND(ID_SPLINES_MODE, OnSplinesMode)
664 ON_COMMAND(ID_SPLINES_LOAD, OnSplinesLoad)
665 ON_COMMAND(ID_SPLINES_SAVE, OnSplinesSave)
666 //ON_COMMAND(ID_SPLINES_EDIT, OnSplinesEdit)
667 ON_COMMAND(ID_SPLINE_TEST, OnSplineTest)
668 ON_COMMAND(ID_POPUP_NEWCAMERA_INTERPOLATED, OnPopupNewcameraInterpolated)
669 ON_COMMAND(ID_POPUP_NEWCAMERA_SPLINE, OnPopupNewcameraSpline)
670 ON_COMMAND(ID_POPUP_NEWCAMERA_FIXED, OnPopupNewcameraFixed)
671 ON_COMMAND(ID_SELECTION_MOVEONLY, OnSelectionMoveonly)
672 ON_COMMAND(ID_SELECT_BRUSHESONLY, OnSelectBrushesOnly)
673 ON_COMMAND(ID_SELECT_BYBOUNDINGBRUSH, OnSelectByBoundingBrush)
674 ON_COMMAND(ID_SELECTION_COMBINE, OnSelectionCombine)
675 ON_COMMAND(ID_PATCH_COMBINE, OnPatchCombine)
676 ON_COMMAND(ID_SHOW_DOOM, OnShowDoom)
677 ON_COMMAND(ID_VIEW_RENDERMODE, OnViewRendermode)
678 ON_COMMAND(ID_VIEW_REBUILDRENDERDATA, OnViewRebuildrenderdata)
679 ON_COMMAND(ID_VIEW_REALTIMEREBUILD, OnViewRealtimerebuild)
680 ON_COMMAND(ID_VIEW_RENDERENTITYOUTLINES, OnViewRenderentityoutlines)
681 ON_COMMAND(ID_VIEW_MATERIALANIMATION, OnViewMaterialanimation)
682 ON_COMMAND(ID_SELECT_AXIALTEXTURE_BYWIDTH, OnAxialTextureByWidth)
683 ON_COMMAND(ID_SELECT_AXIALTEXTURE_BYHEIGHT, OnAxialTextureByHeight)
684 ON_COMMAND(ID_SELECT_AXIALTEXTURE_ARBITRARY, OnAxialTextureArbitrary)
685 ON_COMMAND(ID_SELECTION_EXPORT_TOOBJ, OnSelectionExportToobj)
686 ON_COMMAND(ID_SELECTION_EXPORT_TOCM, OnSelectionExportToCM)
687 ON_COMMAND(ID_VIEW_RENDERSELECTION, OnViewRenderselection)
688 ON_COMMAND(ID_SELECT_NOMODELS, OnSelectNomodels)
689 ON_COMMAND(ID_VIEW_SHOW_SHOWVISPORTALS, OnViewShowShowvisportals)
690 ON_COMMAND(ID_VIEW_SHOW_NODRAW, OnViewShowNoDraw)
691 ON_COMMAND(ID_VIEW_RENDERSOUND, OnViewRendersound)
692 ON_COMMAND(ID_SOUND_SHOWSOUNDVOLUMES, OnSoundShowsoundvolumes)
693 ON_COMMAND(ID_SOUND_SHOWSELECTEDSOUNDVOLUMES, OnSoundShowselectedsoundvolumes)
694 ON_COMMAND(ID_PATCH_NURBEDITOR, OnNurbEditor)
695 ON_COMMAND(ID_SELECT_COMPLETE_ENTITY, OnSelectCompleteEntity)
696 ON_COMMAND(ID_PRECISION_CURSOR_CYCLE , OnPrecisionCursorCycle)
697 ON_COMMAND(ID_MATERIALS_GENERATEMATERIALSLIST,OnGenerateMaterialsList)
698 ON_COMMAND(ID_SELECTION_VIEW_WIREFRAMEON, OnSelectionWireFrameOn)
699 ON_COMMAND(ID_SELECTION_VIEW_WIREFRAMEOFF, OnSelectionWireFrameOff)
700 ON_COMMAND(ID_SELECTION_VIEW_VISIBLEON, OnSelectionVisibleOn)
701 ON_COMMAND(ID_SELECTION_VIEW_VISIBLEOFF, OnSelectionVisibleOff)
702 //}}AFX_MSG_MAP
703 ON_COMMAND_RANGE(CMD_TEXTUREWAD, CMD_TEXTUREWAD_END, OnTextureWad)
704 ON_COMMAND_RANGE(CMD_BSPCOMMAND, CMD_BSPCOMMAND_END, OnBspCommand)
705 ON_COMMAND_RANGE(IDMRU, IDMRU_END, OnMru)
706 ON_COMMAND_RANGE(ID_VIEW_NEAREST, ID_TEXTURES_FLATSHADE, OnViewNearest)
707 ON_COMMAND_RANGE(ID_GRID_POINT0625, ID_GRID_64, OnGrid1)
708 #if _MSC_VER < 1300
709 ON_REGISTERED_MESSAGE(g_msgBSPDone, OnBSPDone)
710 ON_REGISTERED_MESSAGE(g_msgBSPStatus, OnBSPStatus)
711 ON_MESSAGE(WM_DISPLAYCHANGE, OnDisplayChange)
712 #endif
713 ON_COMMAND(ID_AUTOCAULK, OnAutocaulk)
714 ON_UPDATE_COMMAND_UI(ID_AUTOCAULK, OnUpdateAutocaulk)
715 ON_COMMAND(ID_SELECT_ALLTARGETS, OnSelectAlltargets)
716 END_MESSAGE_MAP()
717 static UINT indicators[] = {
718 ID_SEPARATOR, // status line indicator
719 ID_SEPARATOR, // status line indicator
720 ID_SEPARATOR, // status line indicator
721 ID_SEPARATOR, // status line indicator
722 ID_SEPARATOR, // status line indicator
723 ID_SEPARATOR, // status line indicator
724 };
725
726 /*
727 =======================================================================================================================
728 =======================================================================================================================
729 */
OnDisplayChange(UINT wParam,long lParam)730 void CMainFrame::OnDisplayChange(UINT wParam, long lParam) {
731 int n = wParam;
732 }
733
734 /*
735 =======================================================================================================================
736 =======================================================================================================================
737 */
OnBSPStatus(UINT wParam,long lParam)738 void CMainFrame::OnBSPStatus(UINT wParam, long lParam) {
739 // lparam is an atom contain the text
740 char buff[1024];
741 if (::GlobalGetAtomName(static_cast<ATOM>(lParam), buff, sizeof(buff))) {
742 common->Printf("%s", buff);
743 ::GlobalDeleteAtom(static_cast<ATOM>(lParam));
744 }
745 }
746
747 /*
748 =======================================================================================================================
749 =======================================================================================================================
750 */
OnBSPDone(UINT wParam,long lParam)751 void CMainFrame::OnBSPDone(UINT wParam, long lParam) {
752 idStr str = cvarSystem->GetCVarString( "radiant_bspdone" );
753 if (str.Length()) {
754 sndPlaySound(str.c_str(), SND_FILENAME | SND_ASYNC);
755 }
756 }
757
758 //
759 // =======================================================================================================================
760 // CMainFrame construction/destruction
761 // =======================================================================================================================
762 //
CMainFrame()763 CMainFrame::CMainFrame() {
764 m_bDoLoop = false;
765 g_pParentWnd = this;
766 m_pXYWnd = NULL;
767 m_pCamWnd = NULL;
768 m_pZWnd = NULL;
769 m_pYZWnd = NULL;
770 m_pXZWnd = NULL;
771 m_pActiveXY = NULL;
772 m_bCamPreview = true;
773 nurbMode = 0;
774 }
775
776 /*
777 =======================================================================================================================
778 =======================================================================================================================
779 */
~CMainFrame()780 CMainFrame::~CMainFrame() {
781 }
782
783 /*
784 =======================================================================================================================
785 =======================================================================================================================
786 */
HandlePopup(CWnd * pWindow,unsigned int uId)787 void HandlePopup(CWnd *pWindow, unsigned int uId) {
788 // Get the current position of the mouse
789 CPoint ptMouse;
790 GetCursorPos(&ptMouse);
791
792 // Load up a menu that has the options we are looking for in it
793 CMenu mnuPopup;
794 VERIFY(mnuPopup.LoadMenu(uId));
795 mnuPopup.GetSubMenu(0)->TrackPopupMenu
796 (
797 TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
798 ptMouse.x,
799 ptMouse.y,
800 pWindow
801 );
802 mnuPopup.DestroyMenu();
803
804 // Set focus back to window
805 pWindow->SetFocus();
806 }
807
808 /*
809 =======================================================================================================================
810 =======================================================================================================================
811 */
OnParentNotify(UINT message,LPARAM lParam)812 void CMainFrame::OnParentNotify(UINT message, LPARAM lParam) {
813 }
814
815 /*
816 =======================================================================================================================
817 =======================================================================================================================
818 */
SetButtonMenuStates()819 void CMainFrame::SetButtonMenuStates() {
820 CMenu *pMenu = GetMenu();
821 if (pMenu) {
822 //
823 pMenu->CheckMenuItem(ID_VIEW_SHOWNAMES, MF_BYCOMMAND | MF_CHECKED);
824 pMenu->CheckMenuItem(ID_VIEW_SHOWCOORDINATES, MF_BYCOMMAND | MF_CHECKED);
825 pMenu->CheckMenuItem(ID_VIEW_SHOWLIGHTS, MF_BYCOMMAND | MF_CHECKED);
826 pMenu->CheckMenuItem(ID_VIEW_SHOWCOMBATNODES, MF_BYCOMMAND | MF_CHECKED);
827 pMenu->CheckMenuItem(ID_VIEW_ENTITY, MF_BYCOMMAND | MF_CHECKED);
828 pMenu->CheckMenuItem(ID_VIEW_SHOWPATH, MF_BYCOMMAND | MF_CHECKED);
829 pMenu->CheckMenuItem(ID_VIEW_SHOWWATER, MF_BYCOMMAND | MF_CHECKED);
830 pMenu->CheckMenuItem(ID_VIEW_SHOWWORLD, MF_BYCOMMAND | MF_CHECKED);
831 pMenu->CheckMenuItem(ID_VIEW_SHOWCLIP, MF_BYCOMMAND | MF_CHECKED);
832 pMenu->CheckMenuItem(ID_VIEW_SHOWTRIGGERS, MF_BYCOMMAND | MF_CHECKED);
833 pMenu->CheckMenuItem(ID_VIEW_SHOWHINT, MF_BYCOMMAND | MF_CHECKED);
834 pMenu->CheckMenuItem(ID_VIEW_SHOWCAULK, MF_BYCOMMAND | MF_CHECKED);
835 pMenu->CheckMenuItem(ID_VIEW_SHOW_SHOWVISPORTALS, MF_BYCOMMAND | MF_CHECKED);
836 pMenu->CheckMenuItem(ID_VIEW_SHOW_NODRAW, MF_BYCOMMAND | MF_CHECKED);
837 pMenu->CheckMenuItem(ID_VIEW_SHOWANGLES, MF_BYCOMMAND | MF_CHECKED);
838
839 if (!g_qeglobals.d_savedinfo.show_names) {
840 pMenu->CheckMenuItem(ID_VIEW_SHOWNAMES, MF_BYCOMMAND | MF_UNCHECKED);
841 }
842
843 if (!g_qeglobals.d_savedinfo.show_coordinates) {
844 pMenu->CheckMenuItem(ID_VIEW_SHOWCOORDINATES, MF_BYCOMMAND | MF_UNCHECKED);
845 }
846
847 if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_LIGHTS) {
848 pMenu->CheckMenuItem(ID_VIEW_SHOWLIGHTS, MF_BYCOMMAND | MF_UNCHECKED);
849 }
850
851 if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_COMBATNODES) {
852 pMenu->CheckMenuItem(ID_VIEW_SHOWCOMBATNODES, MF_BYCOMMAND | MF_UNCHECKED);
853 }
854
855 if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_ENT) {
856 pMenu->CheckMenuItem(ID_VIEW_ENTITY, MF_BYCOMMAND | MF_UNCHECKED);
857 }
858
859 if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_PATHS) {
860 pMenu->CheckMenuItem(ID_VIEW_SHOWPATH, MF_BYCOMMAND | MF_UNCHECKED);
861 }
862
863 if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_DYNAMICS) {
864 pMenu->CheckMenuItem(ID_VIEW_SHOWWATER, MF_BYCOMMAND | MF_UNCHECKED);
865 }
866
867 if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_WORLD) {
868 pMenu->CheckMenuItem(ID_VIEW_SHOWWORLD, MF_BYCOMMAND | MF_UNCHECKED);
869 }
870
871 if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_CLIP) {
872 pMenu->CheckMenuItem(ID_VIEW_SHOWCLIP, MF_BYCOMMAND | MF_UNCHECKED);
873 }
874
875 if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_TRIGGERS) {
876 pMenu->CheckMenuItem(ID_VIEW_SHOWTRIGGERS, MF_BYCOMMAND | MF_UNCHECKED);
877 }
878
879 if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_HINT) {
880 pMenu->CheckMenuItem(ID_VIEW_SHOWHINT, MF_BYCOMMAND | MF_UNCHECKED);
881 }
882
883 if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_CAULK) {
884 pMenu->CheckMenuItem(ID_VIEW_SHOWCAULK, MF_BYCOMMAND | MF_UNCHECKED);
885 }
886
887 if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_VISPORTALS) {
888 pMenu->CheckMenuItem(ID_VIEW_SHOW_SHOWVISPORTALS, MF_BYCOMMAND | MF_UNCHECKED);
889 }
890
891 if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_NODRAW) {
892 pMenu->CheckMenuItem(ID_VIEW_SHOW_NODRAW, MF_BYCOMMAND | MF_UNCHECKED);
893 }
894
895 if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_ANGLES) {
896 pMenu->CheckMenuItem(ID_VIEW_SHOWANGLES, MF_BYCOMMAND | MF_UNCHECKED);
897 }
898
899 pMenu->CheckMenuItem(ID_TOGGLE_LOCK, MF_BYCOMMAND | (g_PrefsDlg.m_bTextureLock) ? MF_CHECKED : MF_UNCHECKED);
900 pMenu->CheckMenuItem
901 (
902 ID_TOGGLE_ROTATELOCK,
903 MF_BYCOMMAND | (g_PrefsDlg.m_bRotateLock) ? MF_CHECKED : MF_UNCHECKED
904 );
905 pMenu->CheckMenuItem
906 (
907 ID_VIEW_CUBICCLIPPING,
908 MF_BYCOMMAND | (g_PrefsDlg.m_bCubicClipping) ? MF_CHECKED : MF_UNCHECKED
909 );
910 pMenu->CheckMenuItem
911 (
912 ID_VIEW_OPENGLLIGHTING,
913 MF_BYCOMMAND | (g_PrefsDlg.m_bGLLighting) ? MF_CHECKED : MF_UNCHECKED
914 );
915 pMenu->CheckMenuItem(ID_SNAPTOGRID, MF_BYCOMMAND | (!g_PrefsDlg.m_bNoClamp) ? MF_CHECKED : MF_UNCHECKED);
916 if (m_wndToolBar.GetSafeHwnd()) {
917 m_wndToolBar.GetToolBarCtrl().CheckButton
918 (
919 ID_VIEW_CUBICCLIPPING,
920 (g_PrefsDlg.m_bCubicClipping) ? TRUE : FALSE
921 );
922 }
923
924 int n = g_PrefsDlg.m_nTextureScale;
925 int id;
926 switch (n)
927 {
928 case 10:
929 id = ID_TEXTURES_TEXTUREWINDOWSCALE_10;
930 break;
931 case 25:
932 id = ID_TEXTURES_TEXTUREWINDOWSCALE_25;
933 break;
934 case 50:
935 id = ID_TEXTURES_TEXTUREWINDOWSCALE_50;
936 break;
937 case 200:
938 id = ID_TEXTURES_TEXTUREWINDOWSCALE_200;
939 break;
940 default:
941 id = ID_TEXTURES_TEXTUREWINDOWSCALE_100;
942 break;
943 }
944
945 CheckTextureScale(id);
946 }
947
948 if (g_qeglobals.d_project_entity) {
949 // FillTextureMenu(); // redundant but i'll clean it up later.. yeah right..
950 FillBSPMenu();
951 LoadMruInReg(g_qeglobals.d_lpMruMenu, "Software\\" EDITOR_REGISTRY_KEY "\\MRU" );
952 PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu, ::GetSubMenu(::GetMenu(GetSafeHwnd()), 0), ID_FILE_EXIT);
953 }
954 }
955
956 /*
957 =======================================================================================================================
958 =======================================================================================================================
959 */
ShowMenuItemKeyBindings(CMenu * pMenu)960 void CMainFrame::ShowMenuItemKeyBindings(CMenu *pMenu) {
961 int i, j;
962 char key[1024], *ptr;
963 MENUITEMINFO MenuItemInfo;
964
965 // return;
966 for (i = 0; i < g_nCommandCount; i++) {
967 memset(&MenuItemInfo, 0, sizeof(MENUITEMINFO));
968 MenuItemInfo.cbSize = sizeof(MENUITEMINFO);
969 MenuItemInfo.fMask = MIIM_TYPE;
970 MenuItemInfo.dwTypeData = key;
971 MenuItemInfo.cch = sizeof(key);
972 if (!pMenu->GetMenuItemInfo(g_Commands[i].m_nCommand, &MenuItemInfo)) {
973 continue;
974 }
975
976 if (MenuItemInfo.fType != MFT_STRING) {
977 continue;
978 }
979
980 ptr = strchr(key, '\t');
981 if (ptr) {
982 *ptr = '\0';
983 }
984
985 strcat(key, "\t");
986 if (g_Commands[i].m_nModifiers) { // are there modifiers present?
987 if (g_Commands[i].m_nModifiers & RAD_SHIFT) {
988 strcat(key, "Shift-");
989 }
990
991 if (g_Commands[i].m_nModifiers & RAD_ALT) {
992 strcat(key, "Alt-");
993 }
994
995 if (g_Commands[i].m_nModifiers & RAD_CONTROL) {
996 strcat(key, "Ctrl-");
997 }
998 }
999
1000 for (j = 0; j < g_nKeyCount; j++) {
1001 if (g_Commands[i].m_nKey == g_Keys[j].m_nVKKey) {
1002 strcat(key, g_Keys[j].m_strName);
1003 break;
1004 }
1005 }
1006
1007 if (j >= g_nKeyCount) {
1008 sprintf(&key[strlen(key)], "%c", g_Commands[i].m_nKey);
1009 }
1010
1011 memset(&MenuItemInfo, 0, sizeof(MENUITEMINFO));
1012 MenuItemInfo.cbSize = sizeof(MENUITEMINFO);
1013 MenuItemInfo.fMask = MIIM_TYPE;
1014 MenuItemInfo.fType = MFT_STRING;
1015 MenuItemInfo.dwTypeData = key;
1016 MenuItemInfo.cch = strlen(key);
1017 SetMenuItemInfo(pMenu->m_hMenu, g_Commands[i].m_nCommand, FALSE, &MenuItemInfo);
1018 }
1019 }
1020
1021 /*
1022 ==============
1023 MFCCreate
1024 ==============
1025 */
MFCCreate(HINSTANCE hInstance)1026 void MFCCreate( HINSTANCE hInstance )
1027 {
1028 HMENU hMenu = NULL;
1029 int i = sizeof(g_qeglobals.d_savedinfo);
1030 long l = i;
1031
1032 g_qeglobals.d_savedinfo.exclude |= (EXCLUDE_HINT | EXCLUDE_CLIP);
1033 LoadRegistryInfo("radiant_SavedInfo", &g_qeglobals.d_savedinfo, &l);
1034
1035 int nOldSize = g_qeglobals.d_savedinfo.iSize;
1036 if (g_qeglobals.d_savedinfo.iSize != sizeof(g_qeglobals.d_savedinfo)) {
1037 // fill in new defaults
1038 g_qeglobals.d_savedinfo.iSize = sizeof(g_qeglobals.d_savedinfo);
1039 g_qeglobals.d_savedinfo.fGamma = 1.0;
1040 g_qeglobals.d_savedinfo.iTexMenu = ID_VIEW_BILINEARMIPMAP;
1041 g_qeglobals.d_savedinfo.m_nTextureTweak = 1.0;
1042
1043 //g_qeglobals.d_savedinfo.exclude = INCLUDE_EASY | INCLUDE_NORMAL | INCLUDE_HARD | INCLUDE_DEATHMATCH;
1044 g_qeglobals.d_savedinfo.show_coordinates = true;
1045 g_qeglobals.d_savedinfo.show_names = false;
1046
1047 for (i=0 ; i<3 ; i++) {
1048 g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][i] = 0;
1049 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][i] = 1.0;
1050 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][i] = 0.75;
1051 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][i] = 0.5;
1052 g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][i] = 0.25;
1053 }
1054
1055 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][0] = 0.0;
1056 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][1] = 0.0;
1057 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][2] = 1.0;
1058
1059 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][0] = 0.0;
1060 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][1] = 0.0;
1061 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][2] = 0.0;
1062
1063 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] = 1.0;
1064 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] = 0.0;
1065 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] = 0.0;
1066
1067 g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][0] = 0.0;
1068 g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][1] = 0.0;
1069 g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][2] = 1.0;
1070
1071 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][0] = 0.0;
1072 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][1] = 0.0;
1073 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][2] = 0.0;
1074
1075 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][0] = 0.5;
1076 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][1] = 0.0;
1077 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][2] = 0.75;
1078
1079
1080 // old size was smaller, reload original prefs
1081 if (nOldSize > 0 && nOldSize < sizeof(g_qeglobals.d_savedinfo)) {
1082 long l = nOldSize;
1083 LoadRegistryInfo("radiant_SavedInfo", &g_qeglobals.d_savedinfo, &l);
1084 }
1085 }
1086 }
1087
1088 /*
1089 =======================================================================================================================
1090 =======================================================================================================================
1091 */
OnCreate(LPCREATESTRUCT lpCreateStruct)1092 int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) {
1093 char *pBuffer = g_strAppPath.GetBufferSetLength(_MAX_PATH + 1);
1094 int nResult = ::GetModuleFileName(NULL, pBuffer, _MAX_PATH);
1095 ASSERT(nResult != 0);
1096 pBuffer[g_strAppPath.ReverseFind('\\') + 1] = '\0';
1097 g_strAppPath.ReleaseBuffer();
1098
1099 com_editors |= EDITOR_RADIANT;
1100
1101 InitCommonControls();
1102 g_qeglobals.d_hInstance = AfxGetInstanceHandle();
1103 MFCCreate(AfxGetInstanceHandle());
1104
1105 // g_PrefsDlg.LoadPrefs();
1106 if (CFrameWnd::OnCreate(lpCreateStruct) == -1) {
1107 return -1;
1108 }
1109
1110 UINT nID = (g_PrefsDlg.m_bWideToolbar) ? IDR_TOOLBAR_ADVANCED : IDR_TOOLBAR1;
1111
1112 if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
1113 | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(nID)) {
1114 TRACE0("Failed to create toolbar\n");
1115 return -1; // fail to create
1116 }
1117
1118 if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators) / sizeof(UINT))) {
1119 TRACE0("Failed to create status bar\n");
1120 return -1; // fail to create
1121 }
1122
1123 m_bCamPreview = true;
1124
1125 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKX, FALSE);
1126 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKY, FALSE);
1127 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKZ, FALSE);
1128 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_BYBOUNDINGBRUSH, FALSE);
1129 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_BRUSHESONLY, FALSE);
1130 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_SHOWBOUNDINGBOX, FALSE);
1131 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_WELD, TRUE);
1132 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_DRILLDOWN, TRUE);
1133 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SHOW_LIGHTVOLUMES, FALSE);
1134 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SHOW_LIGHTTEXTURES, FALSE);
1135 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECTION_MOVEONLY, FALSE);
1136 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SOUND_SHOWSOUNDVOLUMES,g_qeglobals.d_savedinfo.showSoundAlways);
1137 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SOUND_SHOWSELECTEDSOUNDVOLUMES,g_qeglobals.d_savedinfo.showSoundWhenSelected);
1138
1139 m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
1140 EnableDocking(CBRS_ALIGN_ANY);
1141 DockControlBar(&m_wndToolBar);
1142
1143 g_nScaleHow = 0;
1144
1145 m_wndTextureBar.Create(this, IDD_TEXTUREBAR, CBRS_BOTTOM, 7433);
1146 m_wndTextureBar.EnableDocking(CBRS_ALIGN_ANY);
1147 DockControlBar(&m_wndTextureBar);
1148
1149 g_qeglobals.d_lpMruMenu = CreateMruMenuDefault();
1150
1151 m_bAutoMenuEnable = FALSE;
1152
1153 LoadCommandMap();
1154
1155 CMenu *pMenu = GetMenu();
1156 ShowMenuItemKeyBindings(pMenu);
1157
1158 CFont *pFont = new CFont();
1159 pFont->CreatePointFont(g_PrefsDlg.m_nStatusSize * 10, "Arial");
1160 m_wndStatusBar.SetFont(pFont);
1161
1162
1163 if (g_PrefsDlg.m_bRunBefore == FALSE) {
1164 g_PrefsDlg.m_bRunBefore = TRUE;
1165 g_PrefsDlg.SavePrefs();
1166
1167 /*
1168 * if (MessageBox("Would you like QERadiant to build and load a default project?
1169 * If this is the first time you have run QERadiant or you are not familiar with
1170 * editing QE4 project files directly, this is HIGHLY recommended", "Create a
1171 * default project?", MB_YESNO) == IDYES) { OnFileNewproject(); }
1172 */
1173 }
1174 else
1175 {
1176 // load plugins before the first Map_LoadFile required for model plugins
1177 if (g_PrefsDlg.m_bLoadLastMap && g_PrefsDlg.m_strLastMap.GetLength() > 0) {
1178 Map_LoadFile(g_PrefsDlg.m_strLastMap.GetBuffer(0));
1179 }
1180 }
1181
1182 SetGridStatus();
1183 SetTexValStatus();
1184 SetButtonMenuStates();
1185 LoadBarState("RadiantToolBars2");
1186
1187 SetActiveXY(m_pXYWnd);
1188 m_pXYWnd->SetFocus();
1189
1190 PostMessage(WM_KEYDOWN, 'O', NULL);
1191
1192 if ( radiant_entityMode.GetBool() ) {
1193 g_qeglobals.d_savedinfo.exclude |= (EXCLUDE_PATHS | EXCLUDE_CLIP | EXCLUDE_CAULK | EXCLUDE_VISPORTALS | EXCLUDE_NODRAW | EXCLUDE_TRIGGERS);
1194 }
1195
1196 Sys_UpdateWindows ( W_ALL );
1197 return 0;
1198 }
1199
1200 /*
1201 =======================================================================================================================
1202 =======================================================================================================================
1203 */
1204
FindReplace(CString & strContents,const char * pTag,const char * pValue)1205 void FindReplace(CString& strContents, const char* pTag, const char* pValue) {
1206 if (strcmp(pTag, pValue) == 0)
1207 return;
1208 for (int nPos = strContents.Find(pTag); nPos >= 0; nPos = strContents.Find(pTag)) {
1209 int nRightLen = strContents.GetLength() - strlen(pTag) - nPos;
1210 CString strLeft = strContents.Left(nPos);
1211 CString strRight = strContents.Right(nRightLen);
1212 strLeft += pValue;
1213 strLeft += strRight;
1214 strContents = strLeft;
1215 }
1216 }
1217
LoadCommandMap()1218 void CMainFrame::LoadCommandMap() {
1219 CString strINI;
1220 char pBuff[1024];
1221 strINI = g_strAppPath;
1222 strINI += "\\radiant.ini";
1223
1224 for (int i = 0; i < g_nCommandCount; i++) {
1225 int nLen = GetPrivateProfileString("Commands", g_Commands[i].m_strCommand, "", pBuff, 1024, strINI);
1226 if (nLen > 0) {
1227 CString strBuff = pBuff;
1228 strBuff.TrimLeft();
1229 strBuff.TrimRight();
1230
1231 int nSpecial = strBuff.Find("+alt");
1232 g_Commands[i].m_nModifiers = 0;
1233 if (nSpecial >= 0) {
1234 g_Commands[i].m_nModifiers |= RAD_ALT;
1235 FindReplace(strBuff, "+alt", "");
1236 }
1237
1238 nSpecial = strBuff.Find("+ctrl");
1239 if (nSpecial >= 0) {
1240 g_Commands[i].m_nModifiers |= RAD_CONTROL;
1241 FindReplace(strBuff, "+ctrl", "");
1242 }
1243
1244 nSpecial = strBuff.Find("+shift");
1245 if (nSpecial >= 0) {
1246 g_Commands[i].m_nModifiers |= RAD_SHIFT;
1247 FindReplace(strBuff, "+shift", "");
1248 }
1249
1250 strBuff.TrimLeft();
1251 strBuff.TrimRight();
1252 strBuff.MakeUpper();
1253 if (nLen == 1) { // most often case.. deal with first
1254 g_Commands[i].m_nKey = __toascii(strBuff.GetAt(0));
1255 }
1256 else { // special key
1257 for (int j = 0; j < g_nKeyCount; j++) {
1258 if (strBuff.CompareNoCase(g_Keys[j].m_strName) == 0) {
1259 g_Commands[i].m_nKey = g_Keys[j].m_nVKKey;
1260 break;
1261 }
1262 }
1263 }
1264 }
1265 }
1266 }
1267
1268 /*
1269 =======================================================================================================================
1270 =======================================================================================================================
1271 */
PreCreateWindow(CREATESTRUCT & cs)1272 BOOL CMainFrame::PreCreateWindow(CREATESTRUCT &cs) {
1273 // TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs
1274 return CFrameWnd::PreCreateWindow(cs);
1275 }
1276
1277 // CMainFrame diagnostics
1278 #ifdef _DEBUG
1279
1280 /*
1281 =======================================================================================================================
1282 =======================================================================================================================
1283 */
AssertValid() const1284 void CMainFrame::AssertValid() const {
1285 CFrameWnd::AssertValid();
1286 }
1287
1288 /*
1289 =======================================================================================================================
1290 =======================================================================================================================
1291 */
Dump(CDumpContext & dc) const1292 void CMainFrame::Dump(CDumpContext &dc) const {
1293 CFrameWnd::Dump(dc);
1294 }
1295 #endif // _DEBUG
1296
1297 //
1298 // =======================================================================================================================
1299 // CMainFrame message handlers
1300 // =======================================================================================================================
1301 //
CreateQEChildren()1302 void CMainFrame::CreateQEChildren() {
1303 //
1304 // the project file can be specified on the command line, or implicitly found in
1305 // the basedir directory
1306 //
1307 bool bProjectLoaded = false;
1308 if (g_PrefsDlg.m_bLoadLast && g_PrefsDlg.m_strLastProject.GetLength() > 0) {
1309 bProjectLoaded = QE_LoadProject(g_PrefsDlg.m_strLastProject.GetBuffer(0));
1310 }
1311 if (!bProjectLoaded) {
1312 bProjectLoaded = QE_LoadProject( EDITOR_DEFAULT_PROJECT );
1313 }
1314
1315 if (!bProjectLoaded) {
1316 CFileDialog dlgFile( true, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, EDITOR_WINDOWTEXT " Project files (*.qe4, *.prj)|*.qe4|*.prj||", this );
1317 if (dlgFile.DoModal() == IDOK) {
1318 bProjectLoaded = QE_LoadProject(dlgFile.GetPathName().GetBuffer(0));
1319 }
1320 }
1321
1322 if (!bProjectLoaded) {
1323 Error("Unable to load project file. It was unavailable in the scripts path and the default could not be found");
1324 }
1325
1326 QE_Init();
1327
1328 common->Printf("Entering message loop\n");
1329
1330 m_bDoLoop = true;
1331 SetTimer(QE_TIMER0, 100, NULL);
1332 SetTimer(QE_TIMER1, g_PrefsDlg.m_nAutoSave * 60 * 1000, NULL);
1333 }
1334
1335 /*
1336 =======================================================================================================================
1337 =======================================================================================================================
1338 */
OnCommand(WPARAM wParam,LPARAM lParam)1339 BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam) {
1340 return CFrameWnd::OnCommand(wParam, lParam);
1341 }
1342
1343 /*
1344 =======================================================================================================================
1345 =======================================================================================================================
1346 */
DefWindowProc(UINT message,WPARAM wParam,LPARAM lParam)1347 LRESULT CMainFrame::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
1348 //RoutineProcessing();
1349 return CFrameWnd::DefWindowProc(message, wParam, lParam);
1350 }
1351
1352 /*
1353 =======================================================================================================================
1354 =======================================================================================================================
1355 */
RoutineProcessing()1356 void CMainFrame::RoutineProcessing() {
1357 if (m_bDoLoop) {
1358 double time = 0.0;
1359 static double oldtime = 0.0;
1360 double delta = 0.0;
1361
1362 time = Sys_DoubleTime();
1363 delta = time - oldtime;
1364 oldtime = time;
1365 if (delta > 0.2) {
1366 delta = 0.2;
1367 }
1368
1369 // run time dependant behavior
1370 if (m_pCamWnd) {
1371 m_pCamWnd->Cam_MouseControl(delta);
1372 }
1373
1374 if (g_PrefsDlg.m_bQE4Painting && g_nUpdateBits) {
1375 int nBits = g_nUpdateBits; // this is done to keep this routine from being
1376 g_nUpdateBits = 0; // re-entered due to the paint process.. only
1377 UpdateWindows(nBits); // happens in rare cases but causes a stack overflow
1378 }
1379 }
1380 }
1381
1382 /*
1383 =======================================================================================================================
1384 =======================================================================================================================
1385 */
WindowProc(UINT message,WPARAM wParam,LPARAM lParam)1386 LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
1387 return CFrameWnd::WindowProc(message, wParam, lParam);
1388 }
1389
1390 /*
1391 =======================================================================================================================
1392 =======================================================================================================================
1393 */
MouseDown()1394 bool MouseDown() {
1395 if (::GetAsyncKeyState(VK_LBUTTON)) {
1396 return true;
1397 }
1398
1399 if (::GetAsyncKeyState(VK_RBUTTON)) {
1400 return true;
1401 }
1402
1403 if (::GetAsyncKeyState(VK_MBUTTON)) {
1404 return true;
1405 }
1406
1407 return false;
1408 }
1409
1410 /*
1411 =======================================================================================================================
1412 =======================================================================================================================
1413 */
1414
OnTimer(UINT nIDEvent)1415 void CMainFrame::OnTimer(UINT nIDEvent) {
1416 static bool autoSavePending = false;
1417
1418 if ( nIDEvent == QE_TIMER0 && !MouseDown() ) {
1419 QE_CountBrushesAndUpdateStatusBar();
1420 }
1421 if ( nIDEvent == QE_TIMER1 || autoSavePending ) {
1422 if ( MouseDown() ) {
1423 autoSavePending = true;
1424 return;
1425 }
1426 if ( Sys_Waiting() ) {
1427 autoSavePending = true;
1428 return;
1429 }
1430 QE_CheckAutoSave();
1431 autoSavePending = false;
1432 }
1433 }
1434
1435 struct SplitInfo {
1436 int m_nMin;
1437 int m_nCur;
1438 };
1439
1440 /*
1441 =======================================================================================================================
1442 =======================================================================================================================
1443 */
LoadWindowPlacement(HWND hwnd,const char * pName)1444 bool LoadWindowPlacement(HWND hwnd, const char *pName) {
1445 WINDOWPLACEMENT wp;
1446 wp.length = sizeof(WINDOWPLACEMENT);
1447
1448 LONG lSize = sizeof(wp);
1449 if (LoadRegistryInfo(pName, &wp, &lSize)) {
1450 ::SetWindowPlacement(hwnd, &wp);
1451 return true;
1452 }
1453
1454 return false;
1455 }
1456
1457 /*
1458 =======================================================================================================================
1459 =======================================================================================================================
1460 */
SaveWindowPlacement(HWND hwnd,const char * pName)1461 void SaveWindowPlacement(HWND hwnd, const char *pName) {
1462 WINDOWPLACEMENT wp;
1463 wp.length = sizeof(WINDOWPLACEMENT);
1464 if (::GetWindowPlacement(hwnd, &wp)) {
1465 SaveRegistryInfo(pName, &wp, sizeof(wp));
1466 }
1467 }
1468
1469 /*
1470 =======================================================================================================================
1471 =======================================================================================================================
1472 */
OnDestroy()1473 void CMainFrame::OnDestroy() {
1474 KillTimer(QE_TIMER0);
1475
1476 SaveBarState("RadiantToolBars2");
1477
1478 // FIXME original mru stuff needs replaced with mfc stuff
1479 SaveMruInReg(g_qeglobals.d_lpMruMenu, "Software\\" EDITOR_REGISTRY_KEY "\\MRU");
1480
1481 DeleteMruMenu(g_qeglobals.d_lpMruMenu);
1482
1483 SaveRegistryInfo("radiant_SavedInfo", &g_qeglobals.d_savedinfo, sizeof(g_qeglobals.d_savedinfo));
1484
1485 SaveWindowPlacement(GetSafeHwnd(), "radiant_MainWindowPlace");
1486
1487 SaveWindowPlacement(m_pXYWnd->GetSafeHwnd(), "radiant_xywindow");
1488 SaveWindowPlacement(m_pXZWnd->GetSafeHwnd(), "radiant_xzwindow");
1489 SaveWindowPlacement(m_pYZWnd->GetSafeHwnd(), "radiant_yzwindow");
1490 SaveWindowPlacement(m_pCamWnd->GetSafeHwnd(), "radiant_camerawindow");
1491 SaveWindowPlacement(m_pZWnd->GetSafeHwnd(), "radiant_zwindow");
1492 SaveWindowState(g_Inspectors->texWnd.GetSafeHwnd(), "radiant_texwindow");
1493
1494 if (m_pXYWnd->GetSafeHwnd()) {
1495 m_pXYWnd->SendMessage(WM_DESTROY, 0, 0);
1496 }
1497
1498 delete m_pXYWnd;
1499 m_pXYWnd = NULL;
1500
1501 if (m_pYZWnd->GetSafeHwnd()) {
1502 m_pYZWnd->SendMessage(WM_DESTROY, 0, 0);
1503 }
1504
1505 delete m_pYZWnd;
1506 m_pYZWnd = NULL;
1507
1508 if (m_pXZWnd->GetSafeHwnd()) {
1509 m_pXZWnd->SendMessage(WM_DESTROY, 0, 0);
1510 }
1511
1512 delete m_pXZWnd;
1513 m_pXZWnd = NULL;
1514
1515 if (m_pZWnd->GetSafeHwnd()) {
1516 m_pZWnd->SendMessage(WM_DESTROY, 0, 0);
1517 }
1518
1519 delete m_pZWnd;
1520 m_pZWnd = NULL;
1521
1522 if (m_pCamWnd->GetSafeHwnd()) {
1523 m_pCamWnd->SendMessage(WM_DESTROY, 0, 0);
1524 }
1525
1526 delete m_pCamWnd;
1527 m_pCamWnd = NULL;
1528
1529 if ( idStr::Icmp(currentmap, "unnamed.map") != 0 ) {
1530 g_PrefsDlg.m_strLastMap = currentmap;
1531 g_PrefsDlg.SavePrefs();
1532 }
1533
1534 CleanUpEntities();
1535
1536 while (active_brushes.next != &active_brushes) {
1537 Brush_Free(active_brushes.next, false);
1538 }
1539
1540 while (selected_brushes.next != &selected_brushes) {
1541 Brush_Free(selected_brushes.next, false);
1542 }
1543
1544 while (filtered_brushes.next != &filtered_brushes) {
1545 Brush_Free(filtered_brushes.next, false);
1546 }
1547
1548 while (entities.next != &entities) {
1549 Entity_Free(entities.next);
1550 }
1551
1552
1553 g_qeglobals.d_project_entity->epairs.Clear();
1554
1555 entity_t *pEntity = g_qeglobals.d_project_entity->next;
1556 while (pEntity != NULL && pEntity != g_qeglobals.d_project_entity) {
1557 entity_t *pNextEntity = pEntity->next;
1558 Entity_Free(pEntity);
1559 pEntity = pNextEntity;
1560 }
1561
1562 Texture_Cleanup();
1563
1564 if (world_entity) {
1565 Entity_Free(world_entity);
1566 }
1567
1568 //
1569 // FIXME: idMaterial
1570 // if (notexture) { // Timo // Surface properties plugin #ifdef _DEBUG if (
1571 // !notexture->pData ) common->Printf("WARNING: found a qtexture_t* with no
1572 // IPluginQTexture\n"); #endif if ( notexture->pData )
1573 // GETPLUGINTEXDEF(notexture)->DecRef(); Mem_Free(notexture); }
1574 // if (current_texture) free(current_texture);
1575 //
1576
1577 // FIXME: idMaterial FreeShaders();
1578 CFrameWnd::OnDestroy();
1579
1580 AfxGetApp()->ExitInstance();
1581 }
1582
1583 /*
1584 =======================================================================================================================
1585 =======================================================================================================================
1586 */
OnClose()1587 void CMainFrame::OnClose() {
1588 if (ConfirmModified()) {
1589 g_Inspectors->SaveWindowPlacement ();
1590 CFrameWnd::OnClose();
1591 }
1592 }
1593
1594 /*
1595 =======================================================================================================================
1596 =======================================================================================================================
1597 */
OnKeyUp(UINT nChar,UINT nRepCnt,UINT nFlags)1598 void CMainFrame::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) {
1599 // run through our list to see if we have a handler for nChar
1600
1601 for (int i = 0; i < g_nCommandCount; i++) {
1602 if (g_Commands[i].m_nKey == nChar) { // find a match?
1603 bool bGo = true;
1604 if (g_Commands[i].m_nModifiers & RAD_PRESS) {
1605 int nModifiers = g_Commands[i].m_nModifiers &~RAD_PRESS;
1606 if (nModifiers) { // are there modifiers present?
1607 if (nModifiers & RAD_ALT) {
1608 if (!(GetAsyncKeyState(VK_MENU) & 0x8000)) {
1609 bGo = false;
1610 }
1611 }
1612
1613 if (nModifiers & RAD_CONTROL) {
1614 if (!(GetAsyncKeyState(VK_CONTROL) & 0x8000)) {
1615 bGo = false;
1616 }
1617 }
1618
1619 if (nModifiers & RAD_SHIFT) {
1620 if (!(GetAsyncKeyState(VK_SHIFT) & 0x8000)) {
1621 bGo = false;
1622 }
1623 }
1624 }
1625 else { // no modifiers make sure none of those keys are pressed
1626 if (GetAsyncKeyState(VK_MENU) & 0x8000) {
1627 bGo = false;
1628 }
1629
1630 if (GetAsyncKeyState(VK_CONTROL) & 0x8000) {
1631 bGo = false;
1632 }
1633
1634 if (GetAsyncKeyState(VK_SHIFT) & 0x8000) {
1635 bGo = false;
1636 }
1637 }
1638
1639 if (bGo) {
1640 SendMessage(WM_COMMAND, g_Commands[i].m_nCommand, 0);
1641 break;
1642 }
1643 }
1644 }
1645 }
1646 }
1647
1648 /*
1649 =======================================================================================================================
1650 =======================================================================================================================
1651 */
CamOK(unsigned int nKey)1652 bool CamOK(unsigned int nKey) {
1653 if (nKey == VK_UP || nKey == VK_LEFT || nKey == VK_RIGHT || nKey == VK_DOWN) {
1654 if (::GetAsyncKeyState(nKey)) {
1655 return true;
1656 }
1657 else {
1658 return false;
1659 }
1660 }
1661
1662 return true;
1663 }
1664
1665 /*
1666 =======================================================================================================================
1667 =======================================================================================================================
1668 */
OnSysKeyDown(UINT nChar,UINT nRepCnt,UINT nFlags)1669 void CMainFrame::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) {
1670 // OnKeyDown(nChar, nRepCnt, nFlags);
1671 if (nChar == VK_DOWN) {
1672 OnKeyDown(nChar, nRepCnt, nFlags);
1673 }
1674
1675 CFrameWnd::OnSysKeyDown(nChar, nRepCnt, nFlags);
1676 }
1677
1678 /*
1679 =======================================================================================================================
1680 =======================================================================================================================
1681 */
OnKeyDown(UINT nChar,UINT nRepCnt,UINT nFlags)1682 void CMainFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) {
1683
1684 for (int i = 0; i < g_nCommandCount; i++) {
1685 if (g_Commands[i].m_nKey == nChar) { // find a match?
1686 // check modifiers
1687 unsigned int nState = 0;
1688 if (GetAsyncKeyState(VK_MENU) & 0x8000) {
1689 nState |= RAD_ALT;
1690 }
1691
1692 if (GetAsyncKeyState(VK_CONTROL) & 0x8000) {
1693 nState |= RAD_CONTROL;
1694 }
1695
1696 if (GetAsyncKeyState(VK_SHIFT) & 0x8000) {
1697 nState |= RAD_SHIFT;
1698 }
1699
1700 if ((g_Commands[i].m_nModifiers & 0x7) == nState) {
1701 SendMessage(WM_COMMAND, g_Commands[i].m_nCommand, 0);
1702 break;
1703 }
1704 }
1705 }
1706
1707 CFrameWnd::OnKeyDown(nChar, nRepCnt, nFlags);
1708 }
1709
1710 /*
1711 =======================================================================================================================
1712 =======================================================================================================================
1713 */
OnCreateClient(LPCREATESTRUCT lpcs,CCreateContext * pContext)1714 BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext *pContext) {
1715
1716 g_Inspectors = new CInspectorDialog( this );
1717 g_Inspectors->Create(IDD_DIALOG_INSPECTORS, this);
1718
1719 LoadWindowPlacement(g_Inspectors->GetSafeHwnd(), "radiant_InspectorsWindow");
1720 g_Inspectors->ShowWindow(SW_SHOW);
1721
1722 CRect r;
1723 g_Inspectors->GetWindowRect ( r );
1724
1725 //stupid hack to get the window resize itself properly
1726 r.DeflateRect(0,0,0,1);
1727 g_Inspectors->MoveWindow(r);
1728 r.InflateRect(0,0,0,1);
1729 g_Inspectors->MoveWindow(r);
1730
1731
1732 if (!LoadWindowPlacement(GetSafeHwnd(), "radiant_MainWindowPlace")) {
1733 }
1734
1735 CRect rect(5, 25, 100, 100);
1736 CRect rctParent;
1737 GetClientRect(rctParent);
1738
1739 m_pCamWnd = new CCamWnd();
1740 m_pCamWnd->Create(CAMERA_WINDOW_CLASS, "", QE3_CHILDSTYLE, rect, this, 1234);
1741
1742 m_pZWnd = new CZWnd();
1743 m_pZWnd->Create(Z_WINDOW_CLASS, "", QE3_CHILDSTYLE, rect, this, 1238);
1744
1745 m_pXYWnd = new CXYWnd();
1746 m_pXYWnd->Create(XY_WINDOW_CLASS, "", QE3_CHILDSTYLE, rect, this, 1235);
1747 m_pXYWnd->SetViewType(XY);
1748
1749 m_pXZWnd = new CXYWnd();
1750 m_pXZWnd->Create(XY_WINDOW_CLASS, "", QE3_CHILDSTYLE, rect, this, 1236);
1751 m_pXZWnd->SetViewType(XZ);
1752
1753 m_pYZWnd = new CXYWnd();
1754 m_pYZWnd->Create(XY_WINDOW_CLASS, "", QE3_CHILDSTYLE, rect, this, 1237);
1755 m_pYZWnd->SetViewType(YZ);
1756
1757 m_pCamWnd->SetXYFriend(m_pXYWnd);
1758
1759 CRect rctWork;
1760
1761 LoadWindowPlacement(m_pXYWnd->GetSafeHwnd(), "radiant_xywindow");
1762 LoadWindowPlacement(m_pXZWnd->GetSafeHwnd(), "radiant_xzwindow");
1763 LoadWindowPlacement(m_pYZWnd->GetSafeHwnd(), "radiant_yzwindow");
1764 LoadWindowPlacement(m_pCamWnd->GetSafeHwnd(), "radiant_camerawindow");
1765 LoadWindowPlacement(m_pZWnd->GetSafeHwnd(), "radiant_zwindow");
1766
1767 if (!g_PrefsDlg.m_bXZVis) {
1768 m_pXZWnd->ShowWindow(SW_HIDE);
1769 }
1770
1771 if (!g_PrefsDlg.m_bYZVis) {
1772 m_pYZWnd->ShowWindow(SW_HIDE);
1773 }
1774
1775 if (!g_PrefsDlg.m_bZVis) {
1776 m_pZWnd->ShowWindow(SW_HIDE);
1777 }
1778
1779 CreateQEChildren();
1780
1781 if (m_pXYWnd) {
1782 m_pXYWnd->SetActive(true);
1783 }
1784
1785 Texture_SetMode(g_qeglobals.d_savedinfo.iTexMenu);
1786
1787 g_Inspectors->SetMode(W_CONSOLE);
1788 return TRUE;
1789 }
1790
1791 CRect g_rctOld(0, 0, 0, 0);
1792
1793 /*
1794 =======================================================================================================================
1795 =======================================================================================================================
1796 */
OnSize(UINT nType,int cx,int cy)1797 void CMainFrame::OnSize(UINT nType, int cx, int cy) {
1798 CFrameWnd::OnSize(nType, cx, cy);
1799
1800 CRect rctParent;
1801 GetClientRect(rctParent);
1802
1803 UINT nID;
1804 UINT nStyle;
1805 int nWidth;
1806 if (m_wndStatusBar.GetSafeHwnd()) {
1807 m_wndStatusBar.GetPaneInfo( 0, nID, nStyle, nWidth);
1808 m_wndStatusBar.SetPaneInfo( 0, nID, nStyle, rctParent.Width() * 0.15f );
1809 m_wndStatusBar.GetPaneInfo( 1, nID, nStyle, nWidth);
1810 m_wndStatusBar.SetPaneInfo( 1, nID, nStyle, rctParent.Width() * 0.15f);
1811 m_wndStatusBar.GetPaneInfo( 2, nID, nStyle, nWidth);
1812 m_wndStatusBar.SetPaneInfo( 2, nID, nStyle, rctParent.Width() * 0.15f );
1813 m_wndStatusBar.GetPaneInfo( 3, nID, nStyle, nWidth);
1814 m_wndStatusBar.SetPaneInfo( 3, nID, nStyle, rctParent.Width() * 0.39f );
1815 m_wndStatusBar.GetPaneInfo( 4, nID, nStyle, nWidth);
1816 m_wndStatusBar.SetPaneInfo( 4, nID, nStyle, rctParent.Width() * 0.15f );
1817 m_wndStatusBar.GetPaneInfo( 5, nID, nStyle, nWidth);
1818 m_wndStatusBar.SetPaneInfo( 5, nID, nStyle, rctParent.Width() * 0.01f );
1819 }
1820 }
1821
1822 void OpenDialog(void);
1823 void SaveAsDialog(bool bRegion);
1824 void Select_Ungroup();
1825
1826 /*
1827 =======================================================================================================================
1828 =======================================================================================================================
1829 */
ToggleCamera()1830 void CMainFrame::ToggleCamera() {
1831 if (m_bCamPreview) {
1832 m_bCamPreview = false;
1833 }
1834 else {
1835 m_bCamPreview = true;
1836 }
1837 }
1838
1839 /*
1840 =======================================================================================================================
1841 =======================================================================================================================
1842 */
OnFileClose()1843 void CMainFrame::OnFileClose() {
1844 }
1845
1846 /*
1847 =======================================================================================================================
1848 =======================================================================================================================
1849 */
OnFileExit()1850 void CMainFrame::OnFileExit() {
1851 PostMessage(WM_CLOSE, 0, 0L);
1852 }
1853
1854 /*
1855 =======================================================================================================================
1856 =======================================================================================================================
1857 */
OnFileLoadproject()1858 void CMainFrame::OnFileLoadproject() {
1859 if (ConfirmModified()) {
1860 ProjectDialog();
1861 }
1862 }
1863
1864 /*
1865 =======================================================================================================================
1866 =======================================================================================================================
1867 */
OnFileNew()1868 void CMainFrame::OnFileNew() {
1869 if (ConfirmModified()) {
1870 Map_New();
1871 }
1872 }
1873
1874 /*
1875 =======================================================================================================================
1876 =======================================================================================================================
1877 */
OnFileOpen()1878 void CMainFrame::OnFileOpen() {
1879 if (ConfirmModified()) {
1880 OpenDialog();
1881 }
1882 }
1883
1884 /*
1885 =======================================================================================================================
1886 =======================================================================================================================
1887 */
OnFilePointfile()1888 void CMainFrame::OnFilePointfile() {
1889 if (g_qeglobals.d_pointfile_display_list) {
1890 Pointfile_Clear();
1891 }
1892 else {
1893 Pointfile_Check();
1894 }
1895 Sys_UpdateWindows(W_ALL);
1896 }
1897
1898 /*
1899 =======================================================================================================================
1900 =======================================================================================================================
1901 */
OnFilePrint()1902 void CMainFrame::OnFilePrint() {
1903 }
1904
1905 /*
1906 =======================================================================================================================
1907 =======================================================================================================================
1908 */
OnFilePrintPreview()1909 void CMainFrame::OnFilePrintPreview() {
1910 }
1911
1912 /*
1913 =======================================================================================================================
1914 =======================================================================================================================
1915 */
OnFileSave()1916 void CMainFrame::OnFileSave() {
1917 if (!strcmp(currentmap, "unnamed.map")) {
1918 SaveAsDialog(false);
1919 }
1920 else {
1921 Map_SaveFile(currentmap, false);
1922 }
1923
1924 // DHM - _D3XP
1925 SetTimer(QE_TIMER1, g_PrefsDlg.m_nAutoSave * 60 * 1000, NULL);
1926 }
1927
1928 /*
1929 =======================================================================================================================
1930 =======================================================================================================================
1931 */
OnFileSaveas()1932 void CMainFrame::OnFileSaveas() {
1933 SaveAsDialog(false);
1934 }
1935
1936 /*
1937 =======================================================================================================================
1938 =======================================================================================================================
1939 */
OnFileSaveCopy()1940 void CMainFrame::OnFileSaveCopy() {
1941 char aFile[260] = "\0";
1942 char aFilter[260] = "Map\0*.map\0\0";
1943 char aTitle[260] = "Save a Copy\0";
1944 OPENFILENAME afn;
1945
1946 memset( &afn, 0, sizeof(OPENFILENAME) );
1947
1948 CString strPath = ValueForKey(g_qeglobals.d_project_entity, "basepath");
1949 AddSlash(strPath);
1950 strPath += "maps";
1951 if (g_PrefsDlg.m_strMaps.GetLength() > 0) {
1952 strPath += va("\\%s", g_PrefsDlg.m_strMaps.GetString());
1953 }
1954
1955 /* Place the terminating null character in the szFile. */
1956 aFile[0] = '\0';
1957
1958 /* Set the members of the OPENFILENAME structure. */
1959 afn.lStructSize = sizeof(OPENFILENAME);
1960 afn.hwndOwner = g_pParentWnd->GetSafeHwnd();
1961 afn.lpstrFilter = aFilter;
1962 afn.nFilterIndex = 1;
1963 afn.lpstrFile = aFile;
1964 afn.nMaxFile = sizeof(aFile);
1965 afn.lpstrFileTitle = NULL;
1966 afn.nMaxFileTitle = 0;
1967 afn.lpstrInitialDir = strPath;
1968 afn.lpstrTitle = aTitle;
1969 afn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT;
1970
1971 /* Display the Open dialog box. */
1972 if (!GetSaveFileName(&afn)) {
1973 return; // canceled
1974 }
1975
1976 DefaultExtension(afn.lpstrFile, ".map");
1977 Map_SaveFile(afn.lpstrFile, false); // ignore region
1978
1979 // Set the title back to the current working map
1980 Sys_SetTitle(currentmap);
1981 }
1982
1983 /*
1984 ==================================================================================================
1985 */
OnViewShowModels()1986 void CMainFrame::OnViewShowModels() {
1987 g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_MODELS;
1988
1989 Sys_UpdateWindows(W_ALL);
1990 }
1991
1992 /*
1993 =======================================================================================================================
1994 =======================================================================================================================
1995 */
OnView100()1996 void CMainFrame::OnView100() {
1997 if (m_pXYWnd) {
1998 m_pXYWnd->SetScale(1);
1999 }
2000
2001 if (m_pXZWnd) {
2002 m_pXZWnd->SetScale(1);
2003 }
2004
2005 if (m_pYZWnd) {
2006 m_pYZWnd->SetScale(1);
2007 }
2008
2009 Sys_UpdateWindows(W_XY | W_XY_OVERLAY);
2010 }
2011
2012 /*
2013 =======================================================================================================================
2014 =======================================================================================================================
2015 */
OnViewCenter()2016 void CMainFrame::OnViewCenter() {
2017 m_pCamWnd->Camera().angles[ROLL] = m_pCamWnd->Camera().angles[PITCH] = 0;
2018 m_pCamWnd->Camera().angles[YAW] = 22.5 * floor((m_pCamWnd->Camera().angles[YAW] + 11) / 22.5);
2019 Sys_UpdateWindows(W_CAMERA | W_XY_OVERLAY);
2020 }
2021
2022 /*
2023 =======================================================================================================================
2024 =======================================================================================================================
2025 */
OnViewConsole()2026 void CMainFrame::OnViewConsole() {
2027 g_Inspectors->SetMode(W_CONSOLE);
2028 }
2029
2030 /*
2031 =======================================================================================================================
2032 =======================================================================================================================
2033 */
OnViewDownfloor()2034 void CMainFrame::OnViewDownfloor() {
2035 m_pCamWnd->Cam_ChangeFloor(false);
2036 }
2037
2038 /*
2039 =======================================================================================================================
2040 =======================================================================================================================
2041 */
OnViewEntity()2042 void CMainFrame::OnViewEntity() {
2043 g_Inspectors->SetMode(W_ENTITY);
2044 }
2045
OnViewMediaBrowser()2046 void CMainFrame::OnViewMediaBrowser() {
2047 g_Inspectors->SetMode(W_MEDIA);
2048 }
2049
2050
2051
2052 /*
2053 =======================================================================================================================
2054 =======================================================================================================================
2055 */
OnViewFront()2056 void CMainFrame::OnViewFront() {
2057 m_pXYWnd->SetViewType(YZ);
2058 m_pXYWnd->PositionView();
2059 Sys_UpdateWindows(W_XY);
2060 }
2061
2062 /*
2063 =======================================================================================================================
2064 =======================================================================================================================
2065 */
2066
DoMru(HWND hWnd,WORD wId)2067 BOOL DoMru(HWND hWnd,WORD wId)
2068 {
2069 char szFileName[128];
2070 OFSTRUCT of;
2071 BOOL fExist;
2072
2073 GetMenuItem(g_qeglobals.d_lpMruMenu, wId, TRUE, szFileName, sizeof(szFileName));
2074
2075 // Test if the file exists.
2076
2077 fExist = OpenFile(szFileName ,&of,OF_EXIST) != HFILE_ERROR;
2078
2079 if (fExist) {
2080
2081 // Place the file on the top of MRU.
2082 AddNewItem(g_qeglobals.d_lpMruMenu,(LPSTR)szFileName);
2083
2084 // Now perform opening this file !!!
2085 Map_LoadFile (szFileName);
2086 }
2087 else
2088 // Remove the file on MRU.
2089 DelMenuItem(g_qeglobals.d_lpMruMenu,wId,TRUE);
2090
2091 // Refresh the File menu.
2092 PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(hWnd),0),
2093 ID_FILE_EXIT);
2094
2095 return fExist;
2096 }
2097
OnMru(unsigned int nID)2098 void CMainFrame::OnMru(unsigned int nID) {
2099 // DHM - _D3XP
2100 if (ConfirmModified()) {
2101 DoMru(GetSafeHwnd(), nID);
2102 }
2103 }
2104
2105 /*
2106 =======================================================================================================================
2107 =======================================================================================================================
2108 */
OnViewNearest(unsigned int nID)2109 void CMainFrame::OnViewNearest(unsigned int nID) {
2110 Texture_SetMode(nID);
2111 }
2112
2113 /*
2114 =======================================================================================================================
2115 =======================================================================================================================
2116 */
OnTextureWad(unsigned int nID)2117 void CMainFrame::OnTextureWad(unsigned int nID) {
2118 Sys_BeginWait();
2119
2120 // FIXME: idMaterial Texture_ShowDirectory (nID);
2121 Sys_UpdateWindows(W_ALL);
2122 }
2123
2124 /*
2125 =======================================================================================================================
2126 =======================================================================================================================
2127 */
2128
2129 /*
2130 ============
2131 RunBsp
2132
2133 This is the new all-internal bsp
2134 ============
2135 */
RunBsp(const char * command)2136 void RunBsp (const char *command) {
2137 char sys[2048];
2138 char name[2048];
2139 char *in;
2140
2141 // bring the console window forward for feedback
2142 g_Inspectors->SetMode(W_CONSOLE);
2143
2144 // decide if we are doing a .map or a .reg
2145 strcpy (name, currentmap);
2146 if ( region_active ) {
2147 Map_SaveFile (name, false);
2148 StripExtension (name);
2149 strcat (name, ".reg");
2150 }
2151
2152 if ( !Map_SaveFile ( name, region_active ) ) {
2153 return;
2154 }
2155
2156 // name should be a full pathname, but we only
2157 // want to pass the maps/ part to dmap
2158 in = strstr(name, "maps/");
2159 if ( !in ) {
2160 in = strstr(name, "maps\\");
2161 }
2162 if ( !in ) {
2163 in = name;
2164 }
2165
2166 if (idStr::Icmpn(command, "bspext", strlen("runbsp")) == 0) {
2167 PROCESS_INFORMATION ProcessInformation;
2168 STARTUPINFO startupinfo;
2169 char buff[2048];
2170
2171 idStr base = cvarSystem->GetCVarString( "fs_basepath" );
2172 idStr cd = cvarSystem->GetCVarString( "fs_cdpath" );
2173 idStr paths;
2174 if (base.Length()) {
2175 paths += "+set fs_basepath ";
2176 paths += base;
2177 }
2178 if (cd.Length()) {
2179 paths += "+set fs_cdpath ";
2180 paths += cd;
2181 }
2182
2183 ::GetModuleFileName(AfxGetApp()->m_hInstance, buff, sizeof(buff));
2184 if (strlen(command) > strlen("bspext")) {
2185 idStr::snPrintf( sys, sizeof(sys), "%s %s +set r_fullscreen 0 +dmap editorOutput %s %s +quit", buff, paths.c_str(), command + strlen("bspext"), in );
2186 } else {
2187 idStr::snPrintf( sys, sizeof(sys), "%s %s +set r_fullscreen 0 +dmap editorOutput %s +quit", buff, paths.c_str(), in );
2188 }
2189
2190 ::GetStartupInfo (&startupinfo);
2191 if (!CreateProcess(NULL, sys, NULL, NULL, FALSE, 0, NULL, NULL, &startupinfo, &ProcessInformation)) {
2192 common->Printf("Could not start bsp process %s %s/n", buff, sys);
2193 }
2194 g_pParentWnd->SetFocus();
2195
2196 } else { // assumes bsp is the command
2197 if (strlen(command) > strlen("bsp")) {
2198 idStr::snPrintf( sys, sizeof(sys), "dmap %s %s", command + strlen("bsp"), in );
2199 } else {
2200 idStr::snPrintf( sys, sizeof(sys), "dmap %s", in );
2201 }
2202
2203 cmdSystem->BufferCommandText( CMD_EXEC_NOW, "disconnect\n" );
2204
2205 // issue the bsp command
2206 Dmap_f( idCmdArgs( sys, false ) );
2207 }
2208 }
2209
OnBspCommand(unsigned int nID)2210 void CMainFrame::OnBspCommand(unsigned int nID) {
2211 if (g_PrefsDlg.m_bSnapShots && stricmp(currentmap, "unnamed.map") != 0) {
2212 Map_Snapshot();
2213 }
2214
2215 RunBsp(bsp_commands[LOWORD(nID - CMD_BSPCOMMAND)]);
2216
2217 // DHM - _D3XP
2218 SetTimer(QE_TIMER1, g_PrefsDlg.m_nAutoSave * 60 * 1000, NULL);
2219 }
2220
2221 /*
2222 =======================================================================================================================
2223 =======================================================================================================================
2224 */
OnViewShowblocks()2225 void CMainFrame::OnViewShowblocks() {
2226 g_qeglobals.show_blocks = !(g_qeglobals.show_blocks);
2227 CheckMenuItem
2228 (
2229 ::GetMenu(GetSafeHwnd()),
2230 ID_VIEW_SHOWBLOCKS,
2231 MF_BYCOMMAND | (g_qeglobals.show_blocks ? MF_CHECKED : MF_UNCHECKED)
2232 );
2233 Sys_UpdateWindows(W_XY);
2234 }
2235
2236 /*
2237 =======================================================================================================================
2238 =======================================================================================================================
2239 */
OnViewShowclip()2240 void CMainFrame::OnViewShowclip() {
2241 if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_CLIP) & EXCLUDE_CLIP) {
2242 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWCLIP, MF_BYCOMMAND | MF_UNCHECKED);
2243 }
2244 else {
2245 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWCLIP, MF_BYCOMMAND | MF_CHECKED);
2246 }
2247
2248 Sys_UpdateWindows(W_XY | W_CAMERA);
2249 }
2250
2251 /*
2252 =======================================================================================================================
2253 =======================================================================================================================
2254 */
OnViewShowTriggers()2255 void CMainFrame::OnViewShowTriggers() {
2256 if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_TRIGGERS) & EXCLUDE_TRIGGERS) {
2257 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWTRIGGERS, MF_BYCOMMAND | MF_UNCHECKED);
2258 }
2259 else {
2260 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWTRIGGERS, MF_BYCOMMAND | MF_CHECKED);
2261 }
2262
2263 Sys_UpdateWindows(W_XY | W_CAMERA);
2264 }
2265
2266 /*
2267 =======================================================================================================================
2268 =======================================================================================================================
2269 */
OnViewShowcoordinates()2270 void CMainFrame::OnViewShowcoordinates() {
2271 g_qeglobals.d_savedinfo.show_coordinates ^= 1;
2272 CheckMenuItem
2273 (
2274 ::GetMenu(GetSafeHwnd()),
2275 ID_VIEW_SHOWCOORDINATES,
2276 MF_BYCOMMAND | (g_qeglobals.d_savedinfo.show_coordinates ? MF_CHECKED : MF_UNCHECKED)
2277 );
2278 Sys_UpdateWindows(W_XY);
2279 }
2280
2281 /*
2282 =======================================================================================================================
2283 =======================================================================================================================
2284 */
OnViewShowent()2285 void CMainFrame::OnViewShowent() {
2286 if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_ENT) & EXCLUDE_ENT) {
2287 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWENT, MF_BYCOMMAND | MF_UNCHECKED);
2288 }
2289 else {
2290 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWENT, MF_BYCOMMAND | MF_CHECKED);
2291 }
2292
2293 Sys_UpdateWindows(W_XY | W_CAMERA);
2294 }
2295
2296 /*
2297 =======================================================================================================================
2298 =======================================================================================================================
2299 */
OnViewShowlights()2300 void CMainFrame::OnViewShowlights() {
2301 if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_LIGHTS) & EXCLUDE_LIGHTS) {
2302 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWLIGHTS, MF_BYCOMMAND | MF_UNCHECKED);
2303 }
2304 else {
2305 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWLIGHTS, MF_BYCOMMAND | MF_CHECKED);
2306 }
2307
2308 Sys_UpdateWindows(W_XY | W_CAMERA);
2309 }
2310
2311 /*
2312 =======================================================================================================================
2313 =======================================================================================================================
2314 */
OnViewShownames()2315 void CMainFrame::OnViewShownames() {
2316 g_qeglobals.d_savedinfo.show_names = !(g_qeglobals.d_savedinfo.show_names);
2317 CheckMenuItem
2318 (
2319 ::GetMenu(GetSafeHwnd()),
2320 ID_VIEW_SHOWNAMES,
2321 MF_BYCOMMAND | (g_qeglobals.d_savedinfo.show_names ? MF_CHECKED : MF_UNCHECKED)
2322 );
2323 Map_BuildBrushData();
2324 Sys_UpdateWindows(W_XY);
2325 }
2326
2327 /*
2328 =======================================================================================================================
2329 =======================================================================================================================
2330 */
OnViewShowpath()2331 void CMainFrame::OnViewShowpath() {
2332 if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_PATHS) & EXCLUDE_PATHS) {
2333 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWPATH, MF_BYCOMMAND | MF_UNCHECKED);
2334 }
2335 else {
2336 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWPATH, MF_BYCOMMAND | MF_CHECKED);
2337 }
2338
2339 Sys_UpdateWindows(W_XY | W_CAMERA);
2340 }
2341
2342 /*
2343 =======================================================================================================================
2344 =======================================================================================================================
2345 */
OnViewShowCombatNodes()2346 void CMainFrame::OnViewShowCombatNodes() {
2347 if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_COMBATNODES) & EXCLUDE_COMBATNODES) {
2348 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWCOMBATNODES, MF_BYCOMMAND | MF_UNCHECKED);
2349 }
2350 else {
2351 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWCOMBATNODES, MF_BYCOMMAND | MF_CHECKED);
2352 }
2353
2354 Sys_UpdateWindows(W_XY | W_CAMERA);
2355 }
2356
2357 /*
2358 =======================================================================================================================
2359 =======================================================================================================================
2360 */
OnViewShowwater()2361 void CMainFrame::OnViewShowwater() {
2362 if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_DYNAMICS) & EXCLUDE_DYNAMICS) {
2363 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWWATER, MF_BYCOMMAND | MF_UNCHECKED);
2364 }
2365 else {
2366 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWWATER, MF_BYCOMMAND | MF_CHECKED);
2367 }
2368
2369 Sys_UpdateWindows(W_XY | W_CAMERA);
2370 }
2371
2372 /*
2373 =======================================================================================================================
2374 =======================================================================================================================
2375 */
OnViewShowworld()2376 void CMainFrame::OnViewShowworld() {
2377 if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_WORLD) & EXCLUDE_WORLD) {
2378 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWWORLD, MF_BYCOMMAND | MF_UNCHECKED);
2379 }
2380 else {
2381 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWWORLD, MF_BYCOMMAND | MF_CHECKED);
2382 }
2383
2384 Sys_UpdateWindows(W_XY | W_CAMERA);
2385 }
2386
2387 /*
2388 =======================================================================================================================
2389 =======================================================================================================================
2390 */
OnViewTexture()2391 void CMainFrame::OnViewTexture() {
2392 g_Inspectors->SetMode(W_TEXTURE);
2393 }
2394
2395 /*
2396 =======================================================================================================================
2397 =======================================================================================================================
2398 */
OnViewUpfloor()2399 void CMainFrame::OnViewUpfloor() {
2400 m_pCamWnd->Cam_ChangeFloor(true);
2401 }
2402
2403 /*
2404 =======================================================================================================================
2405 =======================================================================================================================
2406 */
OnViewXy()2407 void CMainFrame::OnViewXy() {
2408 m_pXYWnd->SetViewType(XY);
2409 m_pXYWnd->PositionView();
2410 Sys_UpdateWindows(W_XY);
2411 }
2412
2413 /*
2414 =======================================================================================================================
2415 =======================================================================================================================
2416 */
OnViewZ100()2417 void CMainFrame::OnViewZ100() {
2418 z.scale = 1;
2419 Sys_UpdateWindows(W_Z | W_Z_OVERLAY);
2420 }
2421
2422 /*
2423 =======================================================================================================================
2424 =======================================================================================================================
2425 */
OnViewZoomin()2426 void CMainFrame::OnViewZoomin() {
2427 if ( m_pXYWnd && m_pXYWnd->Active() ) {
2428 m_pXYWnd->SetScale( m_pXYWnd->Scale() * 5.0f / 4.0f );
2429 if ( m_pXYWnd->Scale() > 256.0f ) {
2430 m_pXYWnd->SetScale( 256.0f );
2431 }
2432 }
2433
2434 if ( m_pXZWnd && m_pXZWnd->Active() ) {
2435 m_pXZWnd->SetScale( m_pXZWnd->Scale() * 5.0f / 4.0f );
2436 if ( m_pXZWnd->Scale() > 256.0f ) {
2437 m_pXZWnd->SetScale( 256.0f );
2438 }
2439 }
2440
2441 if ( m_pYZWnd && m_pYZWnd->Active() ) {
2442 m_pYZWnd->SetScale( m_pYZWnd->Scale() * 5.0f / 4.0f );
2443 if ( m_pYZWnd->Scale() > 256.0f ) {
2444 m_pYZWnd->SetScale( 256.0f );
2445 }
2446 }
2447
2448 Sys_UpdateWindows( W_XY | W_XY_OVERLAY );
2449 }
2450
2451 /*
2452 =======================================================================================================================
2453 =======================================================================================================================
2454 */
OnViewZoomout()2455 void CMainFrame::OnViewZoomout() {
2456 if ( m_pXYWnd && m_pXYWnd->Active() ) {
2457 m_pXYWnd->SetScale( m_pXYWnd->Scale() * 4.0f / 5.0f );
2458 if ( m_pXYWnd->Scale() < 0.1f / 32.0f ) {
2459 m_pXYWnd->SetScale( 0.1f / 32.0f );
2460 }
2461 }
2462
2463 if ( m_pXZWnd && m_pXZWnd->Active() ) {
2464 m_pXZWnd->SetScale( m_pXZWnd->Scale() * 4.0f / 5.0f );
2465 if ( m_pXZWnd->Scale() < 0.1f / 32.0f ) {
2466 m_pXZWnd->SetScale( 0.1f / 32.0f );
2467 }
2468 }
2469
2470 if ( m_pYZWnd && m_pYZWnd->Active() ) {
2471 m_pYZWnd->SetScale( m_pYZWnd->Scale() * 4.0f / 5.0f );
2472 if ( m_pYZWnd->Scale() < 0.1f / 32.0f ) {
2473 m_pYZWnd->SetScale( 0.1f / 32.0f );
2474 }
2475 }
2476
2477 Sys_UpdateWindows(W_XY | W_XY_OVERLAY);
2478 }
2479
2480 /*
2481 =======================================================================================================================
2482 =======================================================================================================================
2483 */
OnViewZzoomin()2484 void CMainFrame::OnViewZzoomin() {
2485 z.scale *= 5.0f / 4.0f;
2486 if ( z.scale > 4.0f ) {
2487 z.scale = 4.0f;
2488 }
2489
2490 Sys_UpdateWindows(W_Z | W_Z_OVERLAY);
2491 }
2492
2493 /*
2494 =======================================================================================================================
2495 =======================================================================================================================
2496 */
OnViewZzoomout()2497 void CMainFrame::OnViewZzoomout() {
2498 z.scale *= 4.0f / 5.0f;
2499 if ( z.scale < 0.125f ) {
2500 z.scale = 0.125f;
2501 }
2502
2503 Sys_UpdateWindows(W_Z | W_Z_OVERLAY);
2504 }
2505
2506 /*
2507 =======================================================================================================================
2508 =======================================================================================================================
2509 */
OnViewSide()2510 void CMainFrame::OnViewSide() {
2511 m_pXYWnd->SetViewType(XZ);
2512 m_pXYWnd->PositionView();
2513 Sys_UpdateWindows(W_XY);
2514 }
2515
UpdateGrid(void)2516 static void UpdateGrid(void)
2517 {
2518 // g_qeglobals.d_gridsize = 1 << g_qeglobals.d_gridsize;
2519 if (g_PrefsDlg.m_bSnapTToGrid) {
2520 g_qeglobals.d_savedinfo.m_nTextureTweak = g_qeglobals.d_gridsize;
2521 }
2522 }
2523
2524 /*
2525 =======================================================================================================================
2526 =======================================================================================================================
2527 */
OnGrid1(unsigned int nID)2528 void CMainFrame::OnGrid1(unsigned int nID) {
2529 switch (nID)
2530 {
2531 case ID_GRID_1:
2532 g_qeglobals.d_gridsize = 1;
2533 break;
2534 case ID_GRID_2:
2535 g_qeglobals.d_gridsize = 2;
2536 break;
2537 case ID_GRID_4:
2538 g_qeglobals.d_gridsize = 4;
2539 break;
2540 case ID_GRID_8:
2541 g_qeglobals.d_gridsize = 8;
2542 break;
2543 case ID_GRID_16:
2544 g_qeglobals.d_gridsize = 16;
2545 break;
2546 case ID_GRID_32:
2547 g_qeglobals.d_gridsize = 32;
2548 break;
2549 case ID_GRID_64:
2550 g_qeglobals.d_gridsize = 64;
2551 break;
2552 case ID_GRID_POINT5:
2553 g_qeglobals.d_gridsize = 0.5f;
2554 break;
2555 case ID_GRID_POINT25:
2556 g_qeglobals.d_gridsize = 0.25f;
2557 break;
2558 case ID_GRID_POINT125:
2559 g_qeglobals.d_gridsize = 0.125f;
2560 break;
2561 //case ID_GRID_POINT0625:
2562 // g_qeglobals.d_gridsize = 0.0625f;
2563 // break;
2564 }
2565
2566 UpdateGrid();
2567
2568 SetGridStatus();
2569 SetGridChecks(nID);
2570 Sys_UpdateWindows(W_XY | W_Z);
2571 }
2572
2573 /*
2574 =======================================================================================================================
2575 =======================================================================================================================
2576 */
OnTexturesShowinuse()2577 void CMainFrame::OnTexturesShowinuse() {
2578 Sys_BeginWait();
2579 Texture_ShowInuse();
2580 g_Inspectors->texWnd.RedrawWindow();
2581 }
2582
2583 // from TexWnd.cpp
2584 extern bool texture_showinuse;
2585
2586 /*
2587 =======================================================================================================================
2588 =======================================================================================================================
2589 */
OnUpdateTexturesShowinuse(CCmdUI * pCmdUI)2590 void CMainFrame::OnUpdateTexturesShowinuse(CCmdUI *pCmdUI) {
2591 pCmdUI->SetCheck(texture_showinuse);
2592 }
2593
2594 /*
2595 =======================================================================================================================
2596 =======================================================================================================================
2597 */
OnTexturesInspector()2598 void CMainFrame::OnTexturesInspector() {
2599 DoSurface();
2600 }
2601
2602 /*
2603 =======================================================================================================================
2604 =======================================================================================================================
2605 */
OnMiscFindbrush()2606 void CMainFrame::OnMiscFindbrush() {
2607 DoFind();
2608 }
2609
2610 /*
2611 =======================================================================================================================
2612 =======================================================================================================================
2613 */
OnMiscGamma()2614 void CMainFrame::OnMiscGamma() {
2615 float fSave = g_qeglobals.d_savedinfo.fGamma;
2616 DoGamma();
2617 if (fSave != g_qeglobals.d_savedinfo.fGamma) {
2618 MessageBox("You must restart Q3Radiant for Gamma settings to take place");
2619 }
2620 }
2621
2622 /*
2623 =======================================================================================================================
2624 =======================================================================================================================
2625 */
OnMiscNextleakspot()2626 void CMainFrame::OnMiscNextleakspot() {
2627 Pointfile_Next();
2628 }
2629
2630 /*
2631 =======================================================================================================================
2632 =======================================================================================================================
2633 */
OnMiscPreviousleakspot()2634 void CMainFrame::OnMiscPreviousleakspot() {
2635 Pointfile_Prev();
2636 }
2637
2638 /*
2639 =======================================================================================================================
2640 =======================================================================================================================
2641 */
OnMiscPrintxy()2642 void CMainFrame::OnMiscPrintxy() {
2643 WXY_Print();
2644 }
2645
2646 /*
2647 =======================================================================================================================
2648 =======================================================================================================================
2649 */
2650
UpdateRadiantColor(float r,float g,float b,float a)2651 void UpdateRadiantColor( float r, float g, float b, float a ) {
2652 if ( g_pParentWnd ) {
2653 g_pParentWnd->RoutineProcessing();
2654 }
2655 }
2656
DoColor(int iIndex)2657 bool DoColor( int iIndex ) {
2658 COLORREF cr = (int)(g_qeglobals.d_savedinfo.colors[iIndex][0]*255) +
2659 (((int)(g_qeglobals.d_savedinfo.colors[iIndex][1]*255))<<8) +
2660 (((int)(g_qeglobals.d_savedinfo.colors[iIndex][2]*255))<<16);
2661
2662 CDialogColorPicker dlg(cr);
2663
2664 dlg.UpdateParent = UpdateRadiantColor;
2665
2666 if ( dlg.DoModal() == IDOK ) {
2667 g_qeglobals.d_savedinfo.colors[iIndex][0] = (dlg.GetColor() & 255)/255.0;
2668 g_qeglobals.d_savedinfo.colors[iIndex][1] = ((dlg.GetColor() >> 8)&255)/255.0;
2669 g_qeglobals.d_savedinfo.colors[iIndex][2] = ((dlg.GetColor() >> 16)&255)/255.0;
2670
2671 Sys_UpdateWindows (W_ALL);
2672 return true;
2673 } else {
2674 return false;
2675 }
2676 }
2677
2678 /*
2679 =======================================================================================================================
2680 =======================================================================================================================
2681 */
2682 extern void Select_SetKeyVal(const char *key, const char *val);
OnMiscSelectentitycolor()2683 void CMainFrame::OnMiscSelectentitycolor() {
2684
2685 entity_t *ent = NULL;
2686 if (QE_SingleBrush(true, true)) {
2687 ent = selected_brushes.next->owner;
2688 CString strColor = ValueForKey(ent, "_color");
2689 if (strColor.GetLength() > 0) {
2690 float fR, fG, fB;
2691 int n = sscanf(strColor, "%f %f %f", &fR, &fG, &fB);
2692 if (n == 3) {
2693 g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][0] = fR;
2694 g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][1] = fG;
2695 g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][2] = fB;
2696 }
2697 }
2698 }
2699
2700 if (DoColor(COLOR_ENTITY)) {
2701 char buffer[100];
2702 sprintf(buffer, "%f %f %f", g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][0], g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][1],g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][2]);
2703 Select_SetKeyVal("_color", buffer);
2704 if (ent) {
2705 g_Inspectors->UpdateEntitySel(ent->eclass);
2706 }
2707 Sys_UpdateWindows(W_ALL);
2708 }
2709 }
2710
2711 CString strFindKey;
2712 CString strFindValue;
2713 CString strReplaceKey;
2714 CString strReplaceValue;
2715 bool gbWholeStringMatchOnly = true;
2716 bool gbSelectAllMatchingEnts= false;
2717 brush_t* gpPrevEntBrushFound = NULL;
2718
2719 // all this because there's no ansi stristr(), sigh...
2720 //
String_ToLower(LPCSTR psString)2721 LPCSTR String_ToLower(LPCSTR psString)
2722 {
2723 const int iBufferSize = 4096;
2724 static char sString[8][iBufferSize];
2725 static int iIndex=0;
2726
2727 if (strlen(psString)>=iBufferSize)
2728 {
2729 assert(0);
2730 common->Printf("String_ToLower(): Warning, input string was %d bytes too large, performing strlwr() inline!\n",strlen(psString)-(iBufferSize-1));
2731 return strlwr(const_cast<char*>(psString));
2732 }
2733
2734 iIndex = ++ iIndex & 7;
2735
2736 strcpy(sString[iIndex],psString);
2737 strlwr(sString[iIndex]);
2738
2739 return sString[iIndex];
2740 }
2741
2742
FindNextBrush(brush_t * pPrevFoundBrush)2743 bool FindNextBrush(brush_t* pPrevFoundBrush) // can be NULL for fresh search
2744 {
2745 bool bFoundSomething = false;
2746 entity_t *pLastFoundEnt;
2747 brush_t *pLastFoundBrush;
2748
2749 CWaitCursor waitcursor;
2750
2751 Select_Deselect(true); // bool bDeSelectToListBack
2752
2753 // see whether to start search from prev_brush->next by checking if prev_brush is still in the active list...
2754 //
2755 brush_t *pStartBrush = active_brushes.next;
2756
2757 if (pPrevFoundBrush && !gbSelectAllMatchingEnts)
2758 {
2759 brush_t *pPrev = NULL;
2760 for (brush_t* b = active_brushes.next ; b != &active_brushes ; b = b->next)
2761 {
2762 if (pPrev == pPrevFoundBrush && pPrevFoundBrush)
2763 {
2764 pStartBrush = b;
2765 break;
2766 }
2767 pPrev = b;
2768 }
2769 }
2770
2771 // now do the search proper...
2772 //
2773 int iBrushesScanned = 0;
2774 int iBrushesSelected=0;
2775 int iEntsScanned = 0;
2776
2777 brush_t* pNextBrush;
2778 for (brush_t* b = pStartBrush; b != &active_brushes ; b = pNextBrush)
2779 {
2780 // setup the <nextbrush> ptr before going any further (because selecting a brush down below moves it to a
2781 // different link list), but we need to ensure that the next brush has a different ent-owner than the current
2782 // one, or multi-brush ents will confuse the list process if they get selected (infinite loop badness)...
2783 //
2784 // pNextBrush = &active_brushes; // default to loop-stop condition
2785 pNextBrush = b->next;
2786 while (pNextBrush->owner == b->owner && pNextBrush!=&active_brushes)
2787 {
2788 pNextBrush = pNextBrush->next;
2789 }
2790
2791 iBrushesScanned++;
2792
2793 // a simple progress bar so they don't think it's locked up on long searches...
2794 //
2795 static int iDotBodge=0;
2796 if (!(++iDotBodge&15))
2797 common->Printf("."); // cut down on printing
2798
2799 bool bMatch = false;
2800 entity_t* ent = b->owner;
2801
2802 if (ent && ent!= world_entity) // needed!
2803 {
2804 iEntsScanned++;
2805 if (FilterBrush (b))
2806 continue;
2807
2808 // only check the find-key if there was one specified...
2809 //
2810 if (!strFindKey.IsEmpty())
2811 {
2812 const char *psEntFoundValue = ValueForKey(ent, strFindKey);
2813
2814 if (strlen(psEntFoundValue)
2815 &&
2816 (
2817 // (stricmp(strFindValue, psEntFoundValue)==0) // found this exact key/value
2818 (
2819 (gbWholeStringMatchOnly && stricmp(psEntFoundValue, strFindValue)==0)
2820 ||
2821 (!gbWholeStringMatchOnly && strstr(String_ToLower(psEntFoundValue), String_ToLower(strFindValue)))
2822 )
2823 || // or
2824 (strFindValue.IsEmpty()) // any value for this key if blank value search specified
2825 )
2826 )
2827 {
2828 bMatch = true;
2829 }
2830 }
2831 else
2832 {
2833 // no FIND key specified, so just scan all of them...
2834 //
2835 int iNumEntKeys = GetNumKeys(ent);
2836 for (int i=0; i<iNumEntKeys; i++)
2837 {
2838 const char *psEntFoundValue = ValueForKey(ent, GetKeyString(ent, i));
2839 if (psEntFoundValue)
2840 {
2841 if ( (strlen(psEntFoundValue) && strFindValue.IsEmpty()) // if blank <value> search specified then any found-value is ok
2842 ||
2843 (gbWholeStringMatchOnly && stricmp(psEntFoundValue, strFindValue)==0)
2844 ||
2845 (!gbWholeStringMatchOnly && strstr(String_ToLower(psEntFoundValue), String_ToLower(strFindValue)))
2846 )
2847 {
2848 if (!gbWholeStringMatchOnly && strstr(String_ToLower(psEntFoundValue), String_ToLower(strFindValue)))
2849 {
2850 // OutputDebugString(va("Matching because: psEntFoundValue '%s' & strFindValue '%s'\n",psEntFoundValue, strFindValue));
2851 // Sys_Printf("Matching because: psEntFoundValue '%s' & strFindValue '%s'\n",psEntFoundValue, strFindValue);
2852
2853 // if (strstr(psEntFoundValue,"killsplat"))
2854 // {
2855 // DebugBreak();
2856 // }
2857 }
2858 bMatch = true;
2859 break;
2860 }
2861 }
2862 }
2863 }
2864
2865 if (bMatch)
2866 {
2867 bFoundSomething = true;
2868 pLastFoundEnt = ent;
2869 pLastFoundBrush = b;
2870 iBrushesSelected++;
2871
2872 g_bScreenUpdates = false; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!
2873
2874 Select_Brush(b);
2875
2876 g_bScreenUpdates = true; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!
2877
2878 if (!gbSelectAllMatchingEnts)
2879 break;
2880 }
2881 }
2882 }
2883 if (gbSelectAllMatchingEnts)
2884 {
2885 common->Printf("\nBrushes Selected: %d (Brushes Scanned %d, Ents Scanned %d)\n", iBrushesSelected, iBrushesScanned, iEntsScanned);
2886 }
2887
2888 if (bFoundSomething)
2889 {
2890 idVec3 v3Origin;
2891
2892 if (pLastFoundEnt->origin[0] != 0.0f || pLastFoundEnt->origin[1] != 0.0f || pLastFoundEnt->origin[2] != 0.0f)
2893 {
2894 VectorCopy(pLastFoundEnt->origin,v3Origin);
2895 }
2896 else
2897 {
2898 // pLastFoundEnt's origin is zero, so use average point of brush mins maxs instead...
2899 //
2900 v3Origin[0] = (pLastFoundBrush->mins[0] + pLastFoundBrush->maxs[0])/2;
2901 v3Origin[1] = (pLastFoundBrush->mins[1] + pLastFoundBrush->maxs[1])/2;
2902 v3Origin[2] = (pLastFoundBrush->mins[2] + pLastFoundBrush->maxs[2])/2;
2903 }
2904
2905 // got one, jump the camera to it...
2906 //
2907 VectorCopy(v3Origin, g_pParentWnd->GetCamera()->Camera().origin);
2908 g_pParentWnd->GetCamera()->Camera().origin[1] -= 32; // back off a touch to look at it
2909 g_pParentWnd->GetCamera()->Camera().angles[0] = 0;
2910 g_pParentWnd->GetCamera()->Camera().angles[1] = 90;
2911 g_pParentWnd->GetCamera()->Camera().angles[2] = 0;
2912
2913 // force main screen into XY camera mode (just in case)...
2914 //
2915 g_pParentWnd->SetActiveXY(g_pParentWnd->GetXYWnd());
2916 g_pParentWnd->GetXYWnd()->PositionView();
2917
2918 Sys_UpdateWindows (W_ALL);
2919 //
2920 // and record for next find request (F3)...
2921 //
2922 gpPrevEntBrushFound = pLastFoundBrush;
2923 }
2924
2925 return bFoundSomething;
2926 }
2927
2928
OnMiscFindOrReplaceEntity()2929 void CMainFrame::OnMiscFindOrReplaceEntity()
2930 {
2931 CEntKeyFindReplace FindReplace(&strFindKey, &strFindValue, &strReplaceKey, &strReplaceValue, &gbWholeStringMatchOnly, &gbSelectAllMatchingEnts);
2932 switch (FindReplace.DoModal())
2933 {
2934 case ID_RET_REPLACE:
2935 {
2936 brush_t* next = NULL;
2937 int iOccurences = 0;
2938 for (brush_t* b = active_brushes.next ; b != &active_brushes ; b = next)
2939 {
2940 next = b->next; // important to do this here, in case brush gets linked to a different list
2941 entity_t* ent = b->owner;
2942
2943 if (ent) // needed!
2944 {
2945 if (FilterBrush (b))
2946 continue;
2947
2948 const char *psEntFoundValue = ValueForKey(ent, strFindKey);
2949
2950 if (stricmp(strFindValue, psEntFoundValue)==0 || // found this exact key/value
2951 (strlen(psEntFoundValue) && strFindValue.IsEmpty()) // or any value for this key if blank value search specified
2952 )
2953 {
2954 // found this search key/value, so delete it...
2955 //
2956 DeleteKey(ent,strFindKey);
2957 //
2958 // and replace with the new key/value (if specified)...
2959 //
2960 if (!strReplaceKey.IsEmpty() && !strReplaceValue.IsEmpty())
2961 {
2962 SetKeyValue (ent, strReplaceKey, strReplaceValue);
2963 }
2964 iOccurences++;
2965 }
2966 }
2967 }
2968 if (iOccurences)
2969 {
2970 common->Printf("%d occurence(s) replaced\n",iOccurences);
2971 }
2972 else
2973 {
2974 common->Printf("Nothing found to replace\n");
2975 }
2976 }
2977 break;
2978 case ID_RET_FIND:
2979 {
2980 gpPrevEntBrushFound = NULL;
2981 FindNextBrush(NULL);
2982 }
2983 break;
2984 }
2985 }
OnMiscFindNextEntity()2986 void CMainFrame::OnMiscFindNextEntity()
2987 {
2988 // try it once, if it fails, try it again from top, and give up if still failed after that...
2989 //
2990 if (!FindNextBrush(gpPrevEntBrushFound))
2991 {
2992 gpPrevEntBrushFound = NULL;
2993 FindNextBrush(NULL);
2994 }
2995 }
2996
OnMiscSetViewPos()2997 void CMainFrame::OnMiscSetViewPos()
2998 {
2999 CString psNewCoords = GetString("Input coords (x y z [rot])\n\nUse spaces to seperate numbers");
3000 if (!psNewCoords.IsEmpty())
3001 {
3002 idVec3 v3Viewpos;
3003 float fYaw = 0;
3004
3005 psNewCoords.Remove(',');
3006 int iArgsFound = sscanf(psNewCoords,"%f %f %f",&v3Viewpos[0], &v3Viewpos[1], &v3Viewpos[2]);
3007 if (iArgsFound == 3)
3008 {
3009 // try for an optional 4th (note how this wasn't part of the sscanf() above, so I can check 1st-3, not just any 3)
3010 //
3011 int iArgsFound = sscanf(psNewCoords,"%f %f %f %f", &v3Viewpos[0], &v3Viewpos[1], &v3Viewpos[2], &fYaw);
3012 if (iArgsFound != 4)
3013 {
3014 fYaw = 0; // jic
3015 }
3016
3017 g_pParentWnd->GetCamera()->Camera().angles[YAW] = fYaw;
3018 VectorCopy (v3Viewpos, g_pParentWnd->GetCamera()->Camera().origin);
3019 VectorCopy (v3Viewpos, g_pParentWnd->GetXYWnd()->GetOrigin());
3020 Sys_UpdateWindows (W_ALL);
3021 }
3022 else
3023 {
3024 ErrorBox(va("\"%s\" wasn't 3 valid floats with spaces",psNewCoords.GetString()));
3025 }
3026 }
3027 }
3028
3029 /*
3030 =======================================================================================================================
3031 =======================================================================================================================
3032 */
OnTexturebk()3033 void CMainFrame::OnTexturebk() {
3034 DoColor(COLOR_TEXTUREBACK);
3035 Sys_UpdateWindows(W_ALL);
3036 }
3037
3038 /*
3039 =======================================================================================================================
3040 =======================================================================================================================
3041 */
OnColorsMajor()3042 void CMainFrame::OnColorsMajor() {
3043 DoColor(COLOR_GRIDMAJOR);
3044 Sys_UpdateWindows(W_ALL);
3045 }
3046
3047 /*
3048 =======================================================================================================================
3049 =======================================================================================================================
3050 */
OnColorsMinor()3051 void CMainFrame::OnColorsMinor() {
3052 DoColor(COLOR_GRIDMINOR);
3053 Sys_UpdateWindows(W_ALL);
3054 }
3055
3056 /*
3057 =======================================================================================================================
3058 =======================================================================================================================
3059 */
OnColorsXybk()3060 void CMainFrame::OnColorsXybk() {
3061 DoColor(COLOR_GRIDBACK);
3062 Sys_UpdateWindows(W_ALL);
3063 }
3064
3065 /*
3066 =======================================================================================================================
3067 =======================================================================================================================
3068 */
OnBrush3sided()3069 void CMainFrame::OnBrush3sided() {
3070 Undo_Start("3 sided");
3071 Undo_AddBrushList(&selected_brushes);
3072 Brush_MakeSided(3);
3073 Undo_EndBrushList(&selected_brushes);
3074 Undo_End();
3075 }
3076
3077 /*
3078 =======================================================================================================================
3079 =======================================================================================================================
3080 */
OnBrush4sided()3081 void CMainFrame::OnBrush4sided() {
3082 Undo_Start("4 sided");
3083 Undo_AddBrushList(&selected_brushes);
3084 Brush_MakeSided(4);
3085 Undo_EndBrushList(&selected_brushes);
3086 Undo_End();
3087 }
3088
3089 /*
3090 =======================================================================================================================
3091 =======================================================================================================================
3092 */
OnBrush5sided()3093 void CMainFrame::OnBrush5sided() {
3094 Undo_Start("5 sided");
3095 Undo_AddBrushList(&selected_brushes);
3096 Brush_MakeSided(5);
3097 Undo_EndBrushList(&selected_brushes);
3098 Undo_End();
3099 }
3100
3101 /*
3102 =======================================================================================================================
3103 =======================================================================================================================
3104 */
OnBrush6sided()3105 void CMainFrame::OnBrush6sided() {
3106 Undo_Start("6 sided");
3107 Undo_AddBrushList(&selected_brushes);
3108 Brush_MakeSided(6);
3109 Undo_EndBrushList(&selected_brushes);
3110 Undo_End();
3111 }
3112
3113 /*
3114 =======================================================================================================================
3115 =======================================================================================================================
3116 */
OnBrush7sided()3117 void CMainFrame::OnBrush7sided() {
3118 Undo_Start("7 sided");
3119 Undo_AddBrushList(&selected_brushes);
3120 Brush_MakeSided(7);
3121 Undo_EndBrushList(&selected_brushes);
3122 Undo_End();
3123 }
3124
3125 /*
3126 =======================================================================================================================
3127 =======================================================================================================================
3128 */
OnBrush8sided()3129 void CMainFrame::OnBrush8sided() {
3130 Undo_Start("8 sided");
3131 Undo_AddBrushList(&selected_brushes);
3132 Brush_MakeSided(8);
3133 Undo_EndBrushList(&selected_brushes);
3134 Undo_End();
3135 }
3136
3137 /*
3138 =======================================================================================================================
3139 =======================================================================================================================
3140 */
OnBrush9sided()3141 void CMainFrame::OnBrush9sided() {
3142 Undo_Start("9 sided");
3143 Undo_AddBrushList(&selected_brushes);
3144 Brush_MakeSided(9);
3145 Undo_EndBrushList(&selected_brushes);
3146 Undo_End();
3147 }
3148
3149 /*
3150 =======================================================================================================================
3151 =======================================================================================================================
3152 */
OnBrushArbitrarysided()3153 void CMainFrame::OnBrushArbitrarysided() {
3154 Undo_Start("arbitrary sided");
3155 Undo_AddBrushList(&selected_brushes);
3156 DoSides();
3157 Undo_EndBrushList(&selected_brushes);
3158 Undo_End();
3159 }
3160
3161 /*
3162 =======================================================================================================================
3163 =======================================================================================================================
3164 */
OnBrushFlipx()3165 void CMainFrame::OnBrushFlipx() {
3166 Undo_Start("flip X");
3167 Undo_AddBrushList(&selected_brushes);
3168
3169 Select_FlipAxis(0);
3170 for (brush_t * b = selected_brushes.next; b != &selected_brushes; b = b->next) {
3171 if (b->owner->eclass->fixedsize) {
3172 char buf[16];
3173 float a = FloatForKey(b->owner, "angle");
3174 a = div((180 - a), 180).rem;
3175 SetKeyValue(b->owner, "angle", itoa(a, buf, 10));
3176 Brush_Build(b);
3177 }
3178 }
3179 Patch_ToggleInverted();
3180 Undo_EndBrushList(&selected_brushes);
3181 Undo_End();
3182 }
3183
3184 /*
3185 =======================================================================================================================
3186 =======================================================================================================================
3187 */
OnBrushFlipy()3188 void CMainFrame::OnBrushFlipy() {
3189 Undo_Start("flip Y");
3190 Undo_AddBrushList(&selected_brushes);
3191
3192 Select_FlipAxis(1);
3193 for (brush_t * b = selected_brushes.next; b != &selected_brushes; b = b->next) {
3194 if (b->owner->eclass->fixedsize) {
3195 float a = FloatForKey(b->owner, "angle");
3196 if (a == 0 || a == 180 || a == 360) {
3197 continue;
3198 }
3199
3200 if (a == 90 || a == 270) {
3201 a += 180;
3202 }
3203 else if (a > 270) {
3204 a += 90;
3205 }
3206 else if (a > 180) {
3207 a -= 90;
3208 }
3209 else if (a > 90) {
3210 a += 90;
3211 }
3212 else {
3213 a -= 90;
3214 }
3215
3216 a = (int)a % 360;
3217
3218 char buf[16];
3219 SetKeyValue(b->owner, "angle", itoa(a, buf, 10));
3220 Brush_Build(b);
3221 }
3222 }
3223 Patch_ToggleInverted();
3224 Undo_EndBrushList(&selected_brushes);
3225 Undo_End();
3226 }
3227
3228 /*
3229 =======================================================================================================================
3230 =======================================================================================================================
3231 */
OnBrushFlipz()3232 void CMainFrame::OnBrushFlipz() {
3233 Undo_Start("flip Z");
3234 Undo_AddBrushList(&selected_brushes);
3235 Select_FlipAxis(2);
3236 Patch_ToggleInverted();
3237 Undo_EndBrushList(&selected_brushes);
3238 Undo_End();
3239 }
3240
3241 /*
3242 =======================================================================================================================
3243 =======================================================================================================================
3244 */
OnBrushRotatex()3245 void CMainFrame::OnBrushRotatex() {
3246 Undo_Start("rotate X");
3247 Undo_AddBrushList(&selected_brushes);
3248 Select_RotateAxis(0, 90);
3249 Undo_EndBrushList(&selected_brushes);
3250 Undo_End();
3251 }
3252
3253 /*
3254 =======================================================================================================================
3255 =======================================================================================================================
3256 */
OnBrushRotatey()3257 void CMainFrame::OnBrushRotatey() {
3258 Undo_Start("rotate Y");
3259 Undo_AddBrushList(&selected_brushes);
3260 Select_RotateAxis(1, 90);
3261 Undo_EndBrushList(&selected_brushes);
3262 Undo_End();
3263 }
3264
3265 /*
3266 =======================================================================================================================
3267 =======================================================================================================================
3268 */
OnBrushRotatez()3269 void CMainFrame::OnBrushRotatez() {
3270 Undo_Start("rotate Z");
3271 Undo_AddBrushList(&selected_brushes);
3272 Select_RotateAxis(2, 90);
3273 Undo_EndBrushList(&selected_brushes);
3274 Undo_End();
3275 }
3276
3277 /*
3278 =======================================================================================================================
3279 =======================================================================================================================
3280 */
OnRegionOff()3281 void CMainFrame::OnRegionOff() {
3282 Map_RegionOff();
3283 }
3284
3285 /*
3286 =======================================================================================================================
3287 =======================================================================================================================
3288 */
OnRegionSetbrush()3289 void CMainFrame::OnRegionSetbrush() {
3290 Map_RegionBrush();
3291 }
3292
3293 /*
3294 =======================================================================================================================
3295 =======================================================================================================================
3296 */
OnRegionSetselection()3297 void CMainFrame::OnRegionSetselection() {
3298 Map_RegionSelectedBrushes();
3299 }
3300
3301 /*
3302 =======================================================================================================================
3303 =======================================================================================================================
3304 */
OnRegionSettallbrush()3305 void CMainFrame::OnRegionSettallbrush() {
3306 Map_RegionTallBrush();
3307 }
3308
3309 /*
3310 =======================================================================================================================
3311 =======================================================================================================================
3312 */
OnRegionSetxy()3313 void CMainFrame::OnRegionSetxy() {
3314 Map_RegionXY();
3315 }
3316
3317 /*
3318 =======================================================================================================================
3319 =======================================================================================================================
3320 */
OnSelectionArbitraryrotation()3321 void CMainFrame::OnSelectionArbitraryrotation() {
3322 // if (ActiveXY()) ActiveXY()->UndoCopy();
3323 Undo_Start("arbitrary rotation");
3324 Undo_AddBrushList(&selected_brushes);
3325
3326 CRotateDlg dlg;
3327 dlg.DoModal();
3328
3329 // DoRotate ();
3330 Undo_EndBrushList(&selected_brushes);
3331 Undo_End();
3332 }
3333
3334 /*
3335 =======================================================================================================================
3336 =======================================================================================================================
3337 */
OnSelectionClone()3338 void CMainFrame::OnSelectionClone() {
3339 // if (ActiveXY()) ActiveXY()->UndoCopy();
3340 Select_Clone();
3341 }
3342
3343 /*
3344 =======================================================================================================================
3345 =======================================================================================================================
3346 */
OnSelectionConnect()3347 void CMainFrame::OnSelectionConnect() {
3348 ConnectEntities();
3349 }
3350
3351 /*
3352 =======================================================================================================================
3353 =======================================================================================================================
3354 */
OnSelectionMakehollow()3355 void CMainFrame::OnSelectionMakehollow() {
3356 // if (ActiveXY()) ActiveXY()->UndoCopy();
3357 Undo_Start("hollow");
3358 Undo_AddBrushList(&selected_brushes);
3359 CSG_MakeHollow();
3360 Undo_EndBrushList(&selected_brushes);
3361 Undo_End();
3362 }
3363
3364 /*
3365 =======================================================================================================================
3366 =======================================================================================================================
3367 */
OnSelectionCsgsubtract()3368 void CMainFrame::OnSelectionCsgsubtract() {
3369 // if (ActiveXY()) ActiveXY()->UndoCopy();
3370 Undo_Start("CSG subtract");
3371 CSG_Subtract();
3372 Undo_End();
3373 }
3374
3375 /*
3376 =======================================================================================================================
3377 =======================================================================================================================
3378 */
OnSelectionCsgmerge()3379 void CMainFrame::OnSelectionCsgmerge() {
3380 // if (ActiveXY()) ActiveXY()->UndoCopy();
3381 Undo_Start("CSG merge");
3382 Undo_AddBrushList(&selected_brushes);
3383 CSG_Merge();
3384 Undo_EndBrushList(&selected_brushes);
3385 Undo_End();
3386 }
3387
3388 /*
3389 =======================================================================================================================
3390 =======================================================================================================================
3391 */
OnSelectionDelete()3392 void CMainFrame::OnSelectionDelete() {
3393 brush_t *brush;
3394
3395 // if (ActiveXY()) ActiveXY()->UndoCopy();
3396 Undo_Start("delete");
3397 Undo_AddBrushList(&selected_brushes);
3398
3399 // add all deleted entities to the undo
3400 for (brush = selected_brushes.next; brush != &selected_brushes; brush = brush->next) {
3401 Undo_AddEntity(brush->owner);
3402 }
3403
3404 // NOTE: Select_Delete does NOT delete entities
3405 Select_Delete();
3406 Undo_EndBrushList(&selected_brushes);
3407 Undo_End();
3408 }
3409
3410 /*
3411 =======================================================================================================================
3412 =======================================================================================================================
3413 */
OnSelectionDeselect()3414 void CMainFrame::OnSelectionDeselect() {
3415 if (!ByeByeSurfaceDialog()) {
3416 if (g_bClipMode) {
3417 OnViewClipper();
3418 } else if (g_bRotateMode) {
3419 OnSelectMouserotate();
3420 } else if (g_bScaleMode) {
3421 OnSelectMousescale();
3422 } else if (g_bPathMode) {
3423 if (ActiveXY()) {
3424 ActiveXY()->KillPathMode();
3425 }
3426 } else if (g_bAxialMode) {
3427 g_bAxialMode = false;
3428 Sys_UpdateWindows(W_CAMERA);
3429 } else {
3430 if (g_qeglobals.d_select_mode == sel_curvepoint && g_qeglobals.d_num_move_points > 0) {
3431 g_qeglobals.d_num_move_points = 0;
3432 Sys_UpdateWindows(W_ALL);
3433 } else {
3434 Select_Deselect();
3435 SetStatusText(2, " ");
3436 }
3437 }
3438 }
3439 }
3440
3441 /*
3442 =======================================================================================================================
3443 =======================================================================================================================
3444 */
OnSelectionDragedges()3445 void CMainFrame::OnSelectionDragedges() {
3446 if (g_qeglobals.d_select_mode == sel_edge) {
3447 g_qeglobals.d_select_mode = sel_brush;
3448 Sys_UpdateWindows(W_ALL);
3449 }
3450 else {
3451 SetupVertexSelection();
3452 if (g_qeglobals.d_numpoints) {
3453 g_qeglobals.d_select_mode = sel_edge;
3454 }
3455
3456 Sys_UpdateWindows(W_ALL);
3457 }
3458 }
3459
3460 /*
3461 =======================================================================================================================
3462 =======================================================================================================================
3463 */
OnSelectionDragvertecies()3464 void CMainFrame::OnSelectionDragvertecies() {
3465 if (g_qeglobals.d_select_mode == sel_vertex || g_qeglobals.d_select_mode == sel_curvepoint) {
3466 g_qeglobals.d_select_mode = sel_brush;
3467 Sys_UpdateWindows(W_ALL);
3468 }
3469 else {
3470 // --if (QE_SingleBrush() && selected_brushes.next->patchBrush)
3471 if (OnlyPatchesSelected()) {
3472 Patch_EditPatch();
3473 }
3474 else if (!AnyPatchesSelected()) {
3475 SetupVertexSelection();
3476 if (g_qeglobals.d_numpoints) {
3477 g_qeglobals.d_select_mode = sel_vertex;
3478 }
3479 }
3480
3481 Sys_UpdateWindows(W_ALL);
3482 }
3483 }
3484
3485 /*
3486 =======================================================================================================================
3487 =======================================================================================================================
3488 */
OnSelectionCenterOrigin()3489 void CMainFrame::OnSelectionCenterOrigin() {
3490 Undo_Start("center origin");
3491 Undo_AddBrushList(&selected_brushes);
3492 Select_CenterOrigin();
3493 Undo_EndBrushList(&selected_brushes);
3494 Undo_End();
3495 }
3496
3497 /*
3498 =======================================================================================================================
3499 =======================================================================================================================
3500 */
OnSelectionSelectcompletetall()3501 void CMainFrame::OnSelectionSelectcompletetall() {
3502 //if (ActiveXY()) {
3503 // ActiveXY()->UndoCopy();
3504 //}
3505
3506 Select_CompleteTall();
3507 }
3508
3509 /*
3510 =======================================================================================================================
3511 =======================================================================================================================
3512 */
OnSelectionSelectinside()3513 void CMainFrame::OnSelectionSelectinside() {
3514 Select_Inside();
3515 }
3516
3517 /*
3518 =======================================================================================================================
3519 =======================================================================================================================
3520 */
OnSelectionSelectpartialtall()3521 void CMainFrame::OnSelectionSelectpartialtall() {
3522 Select_PartialTall();
3523 }
3524
3525 /*
3526 =======================================================================================================================
3527 =======================================================================================================================
3528 */
OnSelectionSelecttouching()3529 void CMainFrame::OnSelectionSelecttouching() {
3530 Select_Touching();
3531 }
3532
3533 /*
3534 =======================================================================================================================
3535 =======================================================================================================================
3536 */
OnSelectionUngroupentity()3537 void CMainFrame::OnSelectionUngroupentity() {
3538 Select_Ungroup();
3539 }
3540
OnAutocaulk()3541 void CMainFrame::OnAutocaulk()
3542 {
3543 Select_AutoCaulk();
3544 }
OnUpdateAutocaulk(CCmdUI * pCmdUI)3545 void CMainFrame::OnUpdateAutocaulk(CCmdUI* pCmdUI)
3546 {
3547 pCmdUI->Enable( selected_brushes.next != &selected_brushes);
3548 }
3549
3550
3551 /*
3552 =======================================================================================================================
3553 =======================================================================================================================
3554 */
OnTexturesPopup()3555 void CMainFrame::OnTexturesPopup() {
3556 HandlePopup(this, IDR_POPUP_TEXTURE);
3557 }
3558
3559 /*
3560 =======================================================================================================================
3561 =======================================================================================================================
3562 */
OnSplinesPopup()3563 void CMainFrame::OnSplinesPopup() {
3564 HandlePopup(this, IDR_POPUP_SPLINE);
3565 }
3566
3567 /*
3568 =======================================================================================================================
3569 =======================================================================================================================
3570 */
OnPopupSelection()3571 void CMainFrame::OnPopupSelection() {
3572 HandlePopup(this, IDR_POPUP_SELECTION);
3573 }
3574
3575 /*
3576 =======================================================================================================================
3577 =======================================================================================================================
3578 */
OnViewChange()3579 void CMainFrame::OnViewChange() {
3580 OnViewNextview();
3581 }
3582
3583 /*
3584 =======================================================================================================================
3585 =======================================================================================================================
3586 */
OnViewCameraupdate()3587 void CMainFrame::OnViewCameraupdate() {
3588 g_qeglobals.flatRotation++;
3589
3590 if (g_qeglobals.flatRotation > 2) {
3591 g_qeglobals.flatRotation = 0;
3592 }
3593
3594 if (g_qeglobals.flatRotation) {
3595 g_qeglobals.rotateAxis = 0;
3596 if (ActiveXY()->GetViewType() == XY) {
3597 g_qeglobals.rotateAxis = 2;
3598 } else if (ActiveXY()->GetViewType() == XZ) {
3599 g_qeglobals.rotateAxis = 1;
3600 }
3601 }
3602 Select_InitializeRotation();
3603 Sys_UpdateWindows(W_CAMERA | W_XY);
3604 }
3605
3606
3607 /*
3608 =======================================================================================================================
3609 =======================================================================================================================
3610 */
OnSizing(UINT fwSide,LPRECT pRect)3611 void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect) {
3612 CFrameWnd::OnSizing(fwSide, pRect);
3613 GetClientRect(g_rctOld);
3614 }
3615
3616 /*
3617 =======================================================================================================================
3618 =======================================================================================================================
3619 */
OnHelpAbout()3620 void CMainFrame::OnHelpAbout() {
3621 DoAbout();
3622 }
3623
3624 /*
3625 =======================================================================================================================
3626 =======================================================================================================================
3627 */
OnViewClipper()3628 void CMainFrame::OnViewClipper() {
3629 if (ActiveXY()) {
3630 if (ActiveXY()->ClipMode()) {
3631 ActiveXY()->SetClipMode(false);
3632 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_VIEW_CLIPPER, FALSE);
3633 }
3634 else {
3635 if (ActiveXY()->RotateMode()) {
3636 OnSelectMouserotate();
3637 }
3638
3639 ActiveXY()->SetClipMode(true);
3640 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_VIEW_CLIPPER);
3641 }
3642 }
3643 }
3644
3645 /*
3646 =======================================================================================================================
3647 =======================================================================================================================
3648 */
OnCameraAngledown()3649 void CMainFrame::OnCameraAngledown() {
3650 m_pCamWnd->Camera().angles[0] -= SPEED_TURN;
3651 if (m_pCamWnd->Camera().angles[0] < -85) {
3652 m_pCamWnd->Camera().angles[0] = -85;
3653 }
3654
3655 Sys_UpdateWindows(W_CAMERA | W_XY_OVERLAY);
3656 }
3657
3658 /*
3659 =======================================================================================================================
3660 =======================================================================================================================
3661 */
OnCameraAngleup()3662 void CMainFrame::OnCameraAngleup() {
3663 m_pCamWnd->Camera().angles[0] += SPEED_TURN;
3664 if (m_pCamWnd->Camera().angles[0] > 85) {
3665 m_pCamWnd->Camera().angles[0] = 85;
3666 }
3667
3668 Sys_UpdateWindows(W_CAMERA | W_XY_OVERLAY);
3669 }
3670
3671 /*
3672 =======================================================================================================================
3673 =======================================================================================================================
3674 */
OnCameraBack()3675 void CMainFrame::OnCameraBack() {
3676 VectorMA(m_pCamWnd->Camera().origin, -SPEED_MOVE, m_pCamWnd->Camera().forward, m_pCamWnd->Camera().origin);
3677
3678 int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);
3679 Sys_UpdateWindows(nUpdate);
3680 }
3681
3682 /*
3683 =======================================================================================================================
3684 =======================================================================================================================
3685 */
OnCameraDown()3686 void CMainFrame::OnCameraDown() {
3687 m_pCamWnd->Camera().origin[2] -= SPEED_MOVE;
3688 Sys_UpdateWindows(W_CAMERA | W_XY | W_Z);
3689 }
3690
3691 /*
3692 =======================================================================================================================
3693 =======================================================================================================================
3694 */
OnCameraForward()3695 void CMainFrame::OnCameraForward() {
3696 VectorMA(m_pCamWnd->Camera().origin, SPEED_MOVE, m_pCamWnd->Camera().forward, m_pCamWnd->Camera().origin);
3697
3698 int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);
3699 Sys_UpdateWindows(nUpdate);
3700 }
3701
3702 /*
3703 =======================================================================================================================
3704 =======================================================================================================================
3705 */
OnCameraLeft()3706 void CMainFrame::OnCameraLeft() {
3707 m_pCamWnd->Camera().angles[1] += SPEED_TURN;
3708
3709 int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);
3710 Sys_UpdateWindows(nUpdate);
3711 }
3712
3713 /*
3714 =======================================================================================================================
3715 =======================================================================================================================
3716 */
OnCameraRight()3717 void CMainFrame::OnCameraRight() {
3718 m_pCamWnd->Camera().angles[1] -= SPEED_TURN;
3719
3720 int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);
3721 Sys_UpdateWindows(nUpdate);
3722 }
3723
3724 /*
3725 =======================================================================================================================
3726 =======================================================================================================================
3727 */
OnCameraStrafeleft()3728 void CMainFrame::OnCameraStrafeleft() {
3729 VectorMA(m_pCamWnd->Camera().origin, -SPEED_MOVE, m_pCamWnd->Camera().right, m_pCamWnd->Camera().origin);
3730
3731 int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);
3732 Sys_UpdateWindows(nUpdate);
3733 }
3734
3735 /*
3736 =======================================================================================================================
3737 =======================================================================================================================
3738 */
OnCameraStraferight()3739 void CMainFrame::OnCameraStraferight() {
3740 VectorMA(m_pCamWnd->Camera().origin, SPEED_MOVE, m_pCamWnd->Camera().right, m_pCamWnd->Camera().origin);
3741
3742 int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);
3743 Sys_UpdateWindows(nUpdate);
3744 }
3745
3746 /*
3747 =======================================================================================================================
3748 =======================================================================================================================
3749 */
OnCameraUp()3750 void CMainFrame::OnCameraUp() {
3751 m_pCamWnd->Camera().origin[2] += SPEED_MOVE;
3752 Sys_UpdateWindows(W_CAMERA | W_XY | W_Z);
3753 }
3754
3755 /*
3756 =======================================================================================================================
3757 =======================================================================================================================
3758 */
OnGridToggle()3759 void CMainFrame::OnGridToggle() {
3760 g_qeglobals.d_showgrid ^= 1;
3761 Sys_UpdateWindows(W_XY | W_Z);
3762 }
3763
3764 /*
3765 =======================================================================================================================
3766 =======================================================================================================================
3767 */
OnPrefs()3768 void CMainFrame::OnPrefs() {
3769 BOOL bToolbar = g_PrefsDlg.m_bWideToolbar;
3770 g_PrefsDlg.LoadPrefs();
3771 if (g_PrefsDlg.DoModal() == IDOK) {
3772 if (g_PrefsDlg.m_bWideToolbar != bToolbar) {
3773 MessageBox("You need to restart Q3Radiant for the view changes to take place.");
3774 }
3775
3776 g_Inspectors->texWnd.UpdatePrefs();
3777
3778 CMenu *pMenu = GetMenu();
3779 if (pMenu) {
3780 pMenu->CheckMenuItem(ID_SNAPTOGRID, MF_BYCOMMAND | (!g_PrefsDlg.m_bNoClamp) ? MF_CHECKED : MF_UNCHECKED);
3781 }
3782 }
3783 }
3784
3785 //
3786 // =======================================================================================================================
3787 // 0 = radiant styel 1 = qe4 style
3788 // =======================================================================================================================
3789 //
SetWindowStyle(int nStyle)3790 void CMainFrame::SetWindowStyle(int nStyle) {
3791 }
3792
3793 /*
3794 =======================================================================================================================
3795 =======================================================================================================================
3796 */
OnTogglecamera()3797 void CMainFrame::OnTogglecamera() {
3798 if (m_pCamWnd->IsWindowVisible()) {
3799 m_pCamWnd->ShowWindow(SW_HIDE);
3800 } else {
3801 m_pCamWnd->ShowWindow(SW_SHOW);
3802 }
3803 }
3804
3805
3806 /*
3807 =======================================================================================================================
3808 =======================================================================================================================
3809 */
OnToggleview()3810 void CMainFrame::OnToggleview() {
3811 if (m_pXYWnd && m_pXYWnd->GetSafeHwnd()) {
3812 if (m_pXYWnd->IsWindowVisible()) {
3813 m_pXYWnd->ShowWindow(SW_HIDE);
3814 } else {
3815 m_pXYWnd->ShowWindow(SW_SHOW);
3816 }
3817 }
3818 }
3819
3820 /*
3821 =======================================================================================================================
3822 =======================================================================================================================
3823 */
OnTogglez()3824 void CMainFrame::OnTogglez() {
3825 if (m_pZWnd && m_pZWnd->GetSafeHwnd()) {
3826 if (m_pZWnd->IsWindowVisible()) {
3827 m_pZWnd->ShowWindow(SW_HIDE);
3828 } else {
3829 m_pZWnd->ShowWindow(SW_SHOW);
3830 }
3831 }
3832 }
3833
3834 /*
3835 =======================================================================================================================
3836 =======================================================================================================================
3837 */
OnToggleLock()3838 void CMainFrame::OnToggleLock() {
3839 g_PrefsDlg.m_bTextureLock = !g_PrefsDlg.m_bTextureLock;
3840
3841 CMenu *pMenu = GetMenu();
3842 if (pMenu) {
3843 pMenu->CheckMenuItem(ID_TOGGLE_LOCK, MF_BYCOMMAND | (g_PrefsDlg.m_bTextureLock) ? MF_CHECKED : MF_UNCHECKED);
3844 }
3845
3846 g_PrefsDlg.SavePrefs();
3847 SetGridStatus();
3848 }
3849
3850 /*
3851 =======================================================================================================================
3852 =======================================================================================================================
3853 */
OnEditMapinfo()3854 void CMainFrame::OnEditMapinfo() {
3855 CMapInfo dlg;
3856 dlg.DoModal();
3857 }
3858
3859 /*
3860 =======================================================================================================================
3861 =======================================================================================================================
3862 */
OnEditEntityinfo()3863 void CMainFrame::OnEditEntityinfo() {
3864 CEntityListDlg::ShowDialog();
3865 }
3866
3867 /*
3868 =======================================================================================================================
3869 =======================================================================================================================
3870 */
OnViewNextview()3871 void CMainFrame::OnViewNextview() {
3872 if (m_pXYWnd->GetViewType() == XY) {
3873 m_pXYWnd->SetViewType(XZ);
3874 }
3875 else if (m_pXYWnd->GetViewType() == XZ) {
3876 m_pXYWnd->SetViewType(YZ);
3877 }
3878 else {
3879 m_pXYWnd->SetViewType(XY);
3880 }
3881
3882 m_pXYWnd->PositionView();
3883 if (g_qeglobals.flatRotation) {
3884 g_qeglobals.rotateAxis = 0;
3885 if (ActiveXY()->GetViewType() == XY) {
3886 g_qeglobals.rotateAxis = 2;
3887 } else if (ActiveXY()->GetViewType() == XZ) {
3888 g_qeglobals.rotateAxis = 1;
3889 }
3890 }
3891 Sys_UpdateWindows(W_XY | W_CAMERA);
3892 }
3893
3894 /* Begin SS2 Changes */
OnSetViewTop()3895 void CMainFrame::OnSetViewTop() {
3896 if (m_pXYWnd->GetViewType() != XY) {
3897 m_pXYWnd->SetViewType(XY);
3898 m_pXYWnd->PositionView();
3899 if (g_qeglobals.flatRotation) {
3900 g_qeglobals.rotateAxis = 2;
3901 }
3902 Sys_UpdateWindows(W_XY | W_CAMERA);
3903 }
3904 }
3905
OnSetViewSide()3906 void CMainFrame::OnSetViewSide() {
3907 if (m_pXYWnd->GetViewType() != YZ) {
3908 m_pXYWnd->SetViewType(YZ);
3909 m_pXYWnd->PositionView();
3910 if (g_qeglobals.flatRotation) {
3911 g_qeglobals.rotateAxis = 0;
3912 }
3913 Sys_UpdateWindows(W_XY | W_CAMERA);
3914 }
3915 }
3916
OnSetViewFront()3917 void CMainFrame::OnSetViewFront() {
3918 if (m_pXYWnd->GetViewType() != XZ) {
3919 m_pXYWnd->SetViewType(XZ);
3920 m_pXYWnd->PositionView();
3921 if (g_qeglobals.flatRotation) {
3922 g_qeglobals.rotateAxis = 1;
3923 }
3924 Sys_UpdateWindows(W_XY | W_CAMERA);
3925 }
3926 }
3927 /* End SS2 Changes */
3928
3929
3930 /*
3931 =======================================================================================================================
3932 =======================================================================================================================
3933 */
OnHelpCommandlist()3934 void CMainFrame::OnHelpCommandlist() {
3935 CCommandsDlg dlg;
3936 dlg.DoModal();
3937 #if 0
3938 if (g_b3Dfx) {
3939 C3DFXCamWnd *pWnd = new C3DFXCamWnd();
3940 CRect rect(50, 50, 400, 400);
3941 pWnd->Create(_3DFXCAMERA_WINDOW_CLASS, "", QE3_CHILDSTYLE, rect, this, 1234);
3942 pWnd->ShowWindow(SW_SHOW);
3943 }
3944 #endif
3945 }
3946
3947 /*
3948 =======================================================================================================================
3949 =======================================================================================================================
3950 */
OnFileNewproject()3951 void CMainFrame::OnFileNewproject()
3952 {
3953 }
3954
3955 /*
3956 =======================================================================================================================
3957 =======================================================================================================================
3958 */
UpdateStatusText()3959 void CMainFrame::UpdateStatusText() {
3960 for (int n = 0; n < 6; n++) {
3961 if (m_strStatus[n].GetLength() >= 0 && m_wndStatusBar.GetSafeHwnd()) {
3962 m_wndStatusBar.SetPaneText(n, m_strStatus[n]);
3963 }
3964 }
3965 }
3966
3967 /*
3968 =======================================================================================================================
3969 =======================================================================================================================
3970 */
SetStatusText(int nPane,const char * pText)3971 void CMainFrame::SetStatusText(int nPane, const char *pText) {
3972 if (pText && nPane <= 5 && nPane >= 0) {
3973 m_strStatus[nPane] = pText;
3974 UpdateStatusText();
3975 }
3976 }
3977
3978 /*
3979 =======================================================================================================================
3980 =======================================================================================================================
3981 */
UpdateWindows(int nBits)3982 void CMainFrame::UpdateWindows(int nBits) {
3983
3984 if (!g_bScreenUpdates) {
3985 return;
3986 }
3987
3988 if (nBits & (W_XY | W_XY_OVERLAY)) {
3989 if (m_pXYWnd) {
3990 m_pXYWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
3991 }
3992
3993 if (m_pXZWnd) {
3994 m_pXZWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
3995 }
3996
3997 if (m_pYZWnd) {
3998 m_pYZWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
3999 }
4000 }
4001
4002 if (nBits & W_CAMERA || ((nBits & W_CAMERA_IFON) && m_bCamPreview)) {
4003 if (m_pCamWnd) {
4004 m_pCamWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
4005 }
4006 }
4007
4008 if (nBits & (W_Z | W_Z_OVERLAY)) {
4009 if (m_pZWnd) {
4010 m_pZWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
4011 }
4012 }
4013
4014 if (nBits & W_TEXTURE) {
4015 g_Inspectors->texWnd.RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
4016 }
4017 }
4018
4019 /*
4020 =======================================================================================================================
4021 =======================================================================================================================
4022 */
Sys_UpdateWindows(int nBits)4023 void WINAPI Sys_UpdateWindows(int nBits) {
4024 if (g_PrefsDlg.m_bQE4Painting) {
4025 g_nUpdateBits |= nBits;
4026 }
4027 else if ( g_pParentWnd ) {
4028 g_pParentWnd->UpdateWindows(nBits);
4029 }
4030 }
4031
4032 /*
4033 =======================================================================================================================
4034 =======================================================================================================================
4035 */
OnFlipClip()4036 void CMainFrame::OnFlipClip() {
4037 if (m_pActiveXY) {
4038 m_pActiveXY->FlipClip();
4039 }
4040 }
4041
4042 /*
4043 =======================================================================================================================
4044 =======================================================================================================================
4045 */
OnClipSelected()4046 void CMainFrame::OnClipSelected() {
4047 if (m_pActiveXY && m_pActiveXY->ClipMode()) {
4048 Undo_Start("clip selected");
4049 Undo_AddBrushList(&selected_brushes);
4050 m_pActiveXY->Clip();
4051 Undo_EndBrushList(&selected_brushes);
4052 Undo_End();
4053 } else {
4054 if (g_bPatchBendMode) {
4055 Patch_BendHandleENTER();
4056 } else if (g_bAxialMode) {
4057
4058 }
4059 //else if (g_bPatchBendMode) {
4060 // Patch_InsDelHandleENTER();
4061 //}
4062 }
4063 }
4064
4065 /*
4066 =======================================================================================================================
4067 =======================================================================================================================
4068 */
OnSplitSelected()4069 void CMainFrame::OnSplitSelected() {
4070 if (m_pActiveXY) {
4071 Undo_Start("split selected");
4072 Undo_AddBrushList(&selected_brushes);
4073 m_pActiveXY->SplitClip();
4074 Undo_EndBrushList(&selected_brushes);
4075 Undo_End();
4076 }
4077 }
4078
4079 /*
4080 =======================================================================================================================
4081 =======================================================================================================================
4082 */
ActiveXY()4083 CXYWnd *CMainFrame::ActiveXY() {
4084 return m_pActiveXY;
4085 }
4086
4087 /*
4088 =======================================================================================================================
4089 =======================================================================================================================
4090 */
OnToggleviewXz()4091 void CMainFrame::OnToggleviewXz() {
4092 if (m_pXZWnd && m_pXZWnd->GetSafeHwnd()) {
4093 // get windowplacement doesn't actually save this so we will here
4094 g_PrefsDlg.m_bXZVis = m_pXZWnd->IsWindowVisible();
4095 if (g_PrefsDlg.m_bXZVis) {
4096 m_pXZWnd->ShowWindow(SW_HIDE);
4097 } else {
4098 m_pXZWnd->ShowWindow(SW_SHOW);
4099 }
4100
4101 g_PrefsDlg.m_bXZVis ^= 1;
4102 g_PrefsDlg.SavePrefs();
4103 }
4104 }
4105
4106 /*
4107 =======================================================================================================================
4108 =======================================================================================================================
4109 */
OnToggleviewYz()4110 void CMainFrame::OnToggleviewYz() {
4111 if (m_pYZWnd && m_pYZWnd->GetSafeHwnd()) {
4112 g_PrefsDlg.m_bYZVis = m_pYZWnd->IsWindowVisible();
4113 if (g_PrefsDlg.m_bYZVis) {
4114 m_pYZWnd->ShowWindow(SW_HIDE);
4115 } else {
4116 m_pYZWnd->ShowWindow(SW_SHOW);
4117 }
4118
4119 g_PrefsDlg.m_bYZVis ^= 1;
4120 g_PrefsDlg.SavePrefs();
4121 }
4122 }
4123
4124 /*
4125 =======================================================================================================================
4126 =======================================================================================================================
4127 */
4128
OnToggleToolbar()4129 void CMainFrame::OnToggleToolbar()
4130 {
4131 ShowControlBar(&m_wndToolBar, !m_wndToolBar.IsWindowVisible(), false);
4132 }
4133
OnToggleTextureBar()4134 void CMainFrame::OnToggleTextureBar()
4135 {
4136 ShowControlBar(&m_wndTextureBar, !m_wndTextureBar.IsWindowVisible(), false);
4137 }
4138
4139
4140 /*
4141 =======================================================================================================================
4142 =======================================================================================================================
4143 */
OnColorsBrush()4144 void CMainFrame::OnColorsBrush() {
4145 DoColor(COLOR_BRUSHES);
4146 Sys_UpdateWindows(W_ALL);
4147 }
4148
4149 /*
4150 =======================================================================================================================
4151 =======================================================================================================================
4152 */
OnColorsClipper()4153 void CMainFrame::OnColorsClipper() {
4154 DoColor(COLOR_CLIPPER);
4155 Sys_UpdateWindows(W_ALL);
4156 }
4157
4158 /*
4159 =======================================================================================================================
4160 =======================================================================================================================
4161 */
OnColorsGridtext()4162 void CMainFrame::OnColorsGridtext() {
4163 DoColor(COLOR_GRIDTEXT);
4164 Sys_UpdateWindows(W_ALL);
4165 }
4166
4167 /*
4168 =======================================================================================================================
4169 =======================================================================================================================
4170 */
OnColorsSelectedbrush()4171 void CMainFrame::OnColorsSelectedbrush() {
4172 DoColor(COLOR_SELBRUSHES);
4173 Sys_UpdateWindows(W_ALL);
4174 }
4175
4176 /*
4177 =======================================================================================================================
4178 =======================================================================================================================
4179 */
OnColorsGridblock()4180 void CMainFrame::OnColorsGridblock() {
4181 DoColor(COLOR_GRIDBLOCK);
4182 Sys_UpdateWindows(W_ALL);
4183 }
4184
4185 /*
4186 =======================================================================================================================
4187 =======================================================================================================================
4188 */
OnColorsViewname()4189 void CMainFrame::OnColorsViewname() {
4190 DoColor(COLOR_VIEWNAME);
4191 Sys_UpdateWindows(W_ALL);
4192 }
4193
4194 /*
4195 =======================================================================================================================
4196 =======================================================================================================================
4197 */
OnColorSetoriginal()4198 void CMainFrame::OnColorSetoriginal() {
4199 for (int i = 0; i < 3; i++) {
4200 g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][i] = 0.0f;
4201 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][i] = 1.0f;
4202 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][i] = 0.75f;
4203 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][i] = 0.5f;
4204 g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][i] = 0.25f;
4205 }
4206
4207 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][0] = 0.0f;
4208 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][1] = 0.0f;
4209 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][2] = 1.0f;
4210
4211 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][0] = 0.0f;
4212 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][1] = 0.0f;
4213 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][2] = 0.0f;
4214
4215 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] = 1.0f;
4216 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] = 0.0f;
4217 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] = 0.0f;
4218
4219 g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][0] = 0.0f;
4220 g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][1] = 0.0f;
4221 g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][2] = 1.0f;
4222
4223 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][0] = 0.0f;
4224 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][1] = 0.0f;
4225 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][2] = 0.0f;
4226
4227 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][0] = 0.5f;
4228 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][1] = 0.0f;
4229 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][2] = 0.75f;
4230
4231 g_qeglobals.d_savedinfo.colors[COLOR_PRECISION_CROSSHAIR][0] = 1.0;
4232 g_qeglobals.d_savedinfo.colors[COLOR_PRECISION_CROSSHAIR][1] = 0.0;
4233 g_qeglobals.d_savedinfo.colors[COLOR_PRECISION_CROSSHAIR][2] = 1.0;
4234
4235 Sys_UpdateWindows(W_ALL);
4236 }
4237
4238 /*
4239 =======================================================================================================================
4240 =======================================================================================================================
4241 */
OnColorSetqer()4242 void CMainFrame::OnColorSetqer() {
4243 for (int i = 0; i < 3; i++) {
4244 g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][i] = 0.0f;
4245 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][i] = 1.0f;
4246 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][i] = 1.0f;
4247 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][i] = 0.5f;
4248 g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][i] = 0.25f;
4249 }
4250
4251 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][0] = 0.0f;
4252 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][1] = 0.0f;
4253 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][2] = 1.0f;
4254
4255 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][0] = 0.0f;
4256 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][1] = 0.0f;
4257 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][2] = 0.0f;
4258
4259 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] = 1.0f;
4260 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] = 0.0f;
4261 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] = 0.0f;
4262
4263 g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][0] = 0.0f;
4264 g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][1] = 0.0f;
4265 g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][2] = 1.0f;
4266
4267 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][0] = 0.0f;
4268 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][1] = 0.0f;
4269 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][2] = 0.0f;
4270
4271 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][0] = 0.5f;
4272 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][1] = 0.0f;
4273 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][2] = 0.75f;
4274
4275 g_qeglobals.d_savedinfo.colors[COLOR_PRECISION_CROSSHAIR][0] = 1.0;
4276 g_qeglobals.d_savedinfo.colors[COLOR_PRECISION_CROSSHAIR][1] = 0.0;
4277 g_qeglobals.d_savedinfo.colors[COLOR_PRECISION_CROSSHAIR][2] = 1.0;
4278
4279 Sys_UpdateWindows(W_ALL);
4280 }
4281
4282 //FIXME: these just need to be read from a def file
OnColorSetSuperMal()4283 void CMainFrame::OnColorSetSuperMal() {
4284 OnColorSetqer();
4285 g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][0] = 0.0f;
4286 g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][1] = 0.0f;
4287 g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][2] = 0.0f;
4288 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][0] = 0.35f;
4289 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][1] = 0.35f;
4290 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][2] = 0.35f;
4291 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][0] = 0.5f;
4292 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][1] = 0.5f;
4293 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][2] = 0.5f;
4294 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][0] = 0.39f;
4295 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][1] = 0.39f;
4296 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][2] = 0.39f;
4297 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][0] = 0.0f;
4298 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][1] = 0.0f;
4299 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][2] = 0.0f;
4300 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][0] = 0.0f;
4301 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][1] = 0.0f;
4302 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][2] = 0.0f;
4303 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] = 1.0f;
4304 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] = 0.90f;
4305 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] = 0.90f;
4306 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][0] = 0.5f;
4307 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][1] = 0.0f;
4308 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][2] = 0.74f;
4309
4310
4311 Sys_UpdateWindows(W_ALL);
4312 }
4313
4314 /*
4315 =======================================================================================================================
4316 =======================================================================================================================
4317 */
OnColorSetblack()4318 void CMainFrame::OnColorSetblack() {
4319 for (int i = 0; i < 3; i++) {
4320 g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][i] = 0.0f;
4321 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][i] = 0.0f;
4322 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][i] = 0.0f;
4323 g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][i] = 0.25f;
4324 }
4325
4326 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][0] = 0.3f;
4327 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][1] = 0.5f;
4328 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][2] = 0.5f;
4329
4330 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][0] = 0.0f;
4331 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][1] = 0.0f;
4332 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][2] = 1.0f;
4333
4334 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][0] = 1.0f;
4335 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][1] = 1.0f;
4336 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][2] = 1.0f;
4337
4338 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] = 1.0f;
4339 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] = 0.0f;
4340 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] = 0.0f;
4341
4342 g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][0] = 0.0f;
4343 g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][1] = 0.0f;
4344 g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][2] = 1.0f;
4345
4346 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][0] = 1.0f;
4347 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][1] = 1.0f;
4348 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][2] = 1.0f;
4349
4350 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][0] = 0.7f;
4351 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][1] = 0.7f;
4352 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][2] = 0.0f;
4353
4354 g_qeglobals.d_savedinfo.colors[COLOR_PRECISION_CROSSHAIR][0] = 1.0;
4355 g_qeglobals.d_savedinfo.colors[COLOR_PRECISION_CROSSHAIR][1] = 0.0;
4356 g_qeglobals.d_savedinfo.colors[COLOR_PRECISION_CROSSHAIR][2] = 1.0;
4357
4358 Sys_UpdateWindows(W_ALL);
4359 }
4360
OnColorSetMax()4361 void CMainFrame::OnColorSetMax() {
4362 for (int i=0 ; i<3 ; i++) {
4363 g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][i] = 0.25f;
4364 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][i] = 0.77f;
4365 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][i] = 0.83f;
4366 g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][i] = 0.89f;
4367 g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][i] = 0.25f;
4368 }
4369
4370 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][0] = 1.0f;
4371 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][1] = 1.0f;
4372 g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][2] = 1.0f;
4373 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][0] = 0.0f;
4374 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][1] = 0.0f;
4375 g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][2] = 0.0f;
4376 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] = 1.0f;
4377 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] = 0.0f;
4378 g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] = 0.0f;
4379 g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][0] = 0.0f;
4380 g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][1] = 0.0f;
4381 g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][2] = 1.0f;
4382 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][0] = 0.0f;
4383 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][1] = 0.0f;
4384 g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][2] = 0.0f;
4385 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][0] = 0.5f;
4386 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][1] = 0.0f;
4387 g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][2] = 0.75f;
4388
4389 //g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][0] = 0.0f;
4390 //g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][1] = 1.0f;
4391 //g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][2] = 1.0f;
4392
4393 g_qeglobals.d_savedinfo.colors[COLOR_PRECISION_CROSSHAIR][0] = 1.0f;
4394 g_qeglobals.d_savedinfo.colors[COLOR_PRECISION_CROSSHAIR][1] = 0.0f;
4395 g_qeglobals.d_savedinfo.colors[COLOR_PRECISION_CROSSHAIR][2] = 1.0f;
4396
4397 Sys_UpdateWindows (W_ALL);
4398
4399 }
4400
4401 /*
4402 =======================================================================================================================
4403 =======================================================================================================================
4404 */
OnSnaptogrid()4405 void CMainFrame::OnSnaptogrid() {
4406 g_PrefsDlg.m_bNoClamp ^= 1;
4407 g_PrefsDlg.SavePrefs();
4408
4409 CMenu *pMenu = GetMenu();
4410 if (pMenu) {
4411 pMenu->CheckMenuItem(ID_SNAPTOGRID, MF_BYCOMMAND | (!g_PrefsDlg.m_bNoClamp) ? MF_CHECKED : MF_UNCHECKED);
4412 }
4413 }
4414
4415 /*
4416 =======================================================================================================================
4417 =======================================================================================================================
4418 */
OnSelectScale()4419 void CMainFrame::OnSelectScale() {
4420 // if (ActiveXY()) ActiveXY()->UndoCopy();
4421 Undo_Start("scale");
4422 Undo_AddBrushList(&selected_brushes);
4423
4424 CScaleDialog dlg;
4425 if (dlg.DoModal() == IDOK) {
4426 if (dlg.m_fX > 0 && dlg.m_fY > 0 && dlg.m_fZ > 0) {
4427 Select_Scale(dlg.m_fX, dlg.m_fY, dlg.m_fZ);
4428 Sys_UpdateWindows(W_ALL);
4429 }
4430 else {
4431 common->Printf("Warning.. Tried to scale by a zero value.");
4432 }
4433 }
4434
4435 Undo_EndBrushList(&selected_brushes);
4436 Undo_End();
4437 }
4438
4439 /*
4440 =======================================================================================================================
4441 =======================================================================================================================
4442 */
OnSelectMouserotate()4443 void CMainFrame::OnSelectMouserotate() {
4444 if (ActiveXY()) {
4445 if (ActiveXY()->ClipMode()) {
4446 OnViewClipper();
4447 }
4448
4449 if (ActiveXY()->RotateMode()) {
4450 ActiveXY()->SetRotateMode(false);
4451 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSEROTATE, FALSE);
4452 Map_BuildBrushData();
4453 }
4454 else {
4455 // may not work if no brush selected, see return value
4456 if (ActiveXY()->SetRotateMode(true)) {
4457 g_qeglobals.rotateAxis = 0;
4458 if (ActiveXY()->GetViewType() == XY) {
4459 g_qeglobals.rotateAxis = 2;
4460 } else if (ActiveXY()->GetViewType() == XZ) {
4461 g_qeglobals.rotateAxis = 1;
4462 }
4463 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSEROTATE, TRUE);
4464 }
4465 else { // if MFC called, we need to set back to FALSE ourselves
4466 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSEROTATE, FALSE);
4467 }
4468 }
4469 }
4470 Sys_UpdateWindows(W_CAMERA | W_XY);
4471 }
4472
4473 /*
4474 =======================================================================================================================
4475 =======================================================================================================================
4476 */
OnEditCopybrush()4477 void CMainFrame::OnEditCopybrush() {
4478 if (ActiveXY()) {
4479 ActiveXY()->Copy();
4480 }
4481 }
4482
4483 /*
4484 =======================================================================================================================
4485 =======================================================================================================================
4486 */
OnEditPastebrush()4487 void CMainFrame::OnEditPastebrush() {
4488 if (ActiveXY()) {
4489 ActiveXY()->Paste();
4490 }
4491 }
4492
4493 /*
4494 =======================================================================================================================
4495 =======================================================================================================================
4496 */
OnEditUndo()4497 void CMainFrame::OnEditUndo() {
4498 // if (ActiveXY()) ActiveXY()->Undo();
4499 Undo_Undo();
4500 }
4501
4502 /*
4503 =======================================================================================================================
4504 =======================================================================================================================
4505 */
OnEditRedo()4506 void CMainFrame::OnEditRedo() {
4507 Undo_Redo();
4508 }
4509
4510 /*
4511 =======================================================================================================================
4512 =======================================================================================================================
4513 */
OnUpdateEditUndo(CCmdUI * pCmdUI)4514 void CMainFrame::OnUpdateEditUndo(CCmdUI *pCmdUI) {
4515 /*
4516 * BOOL bEnable = false; if (ActiveXY()) bEnable = ActiveXY()->UndoAvailable();
4517 * pCmdUI->Enable(bEnable);
4518 */
4519 pCmdUI->Enable(Undo_UndoAvailable());
4520 }
4521
4522 /*
4523 =======================================================================================================================
4524 =======================================================================================================================
4525 */
OnUpdateEditRedo(CCmdUI * pCmdUI)4526 void CMainFrame::OnUpdateEditRedo(CCmdUI *pCmdUI) {
4527 pCmdUI->Enable(Undo_RedoAvailable());
4528 }
4529
4530 /*
4531 =======================================================================================================================
4532 =======================================================================================================================
4533 */
OnSelectionTextureDec()4534 void CMainFrame::OnSelectionTextureDec() {
4535 g_qeglobals.d_savedinfo.m_nTextureTweak -= 1.0f;
4536 if ( g_qeglobals.d_savedinfo.m_nTextureTweak == 0.0f ) {
4537 g_qeglobals.d_savedinfo.m_nTextureTweak -= 1.0f;
4538 }
4539
4540 SetTexValStatus();
4541 }
4542
4543 /*
4544 =======================================================================================================================
4545 =======================================================================================================================
4546 */
OnSelectionTextureFit()4547 void CMainFrame::OnSelectionTextureFit() {
4548 Select_FitTexture( 1.0f, 1.0f );
4549 }
4550
4551 /*
4552 =======================================================================================================================
4553 =======================================================================================================================
4554 */
OnSelectionTextureInc()4555 void CMainFrame::OnSelectionTextureInc() {
4556 g_qeglobals.d_savedinfo.m_nTextureTweak += 1.0f;
4557 if ( g_qeglobals.d_savedinfo.m_nTextureTweak == 0.0f ) {
4558 g_qeglobals.d_savedinfo.m_nTextureTweak += 1.0f;
4559 }
4560
4561 SetTexValStatus();
4562 }
4563
4564 /*
4565 =======================================================================================================================
4566 =======================================================================================================================
4567 */
OnSelectionTextureRotateclock()4568 void CMainFrame::OnSelectionTextureRotateclock() {
4569 Select_RotateTexture(abs(g_PrefsDlg.m_nRotation));
4570 }
4571
4572 /*
4573 =======================================================================================================================
4574 =======================================================================================================================
4575 */
OnSelectionTextureRotatecounter()4576 void CMainFrame::OnSelectionTextureRotatecounter() {
4577 Select_RotateTexture(-abs(g_PrefsDlg.m_nRotation));
4578 }
4579
4580 /*
4581 =======================================================================================================================
4582 =======================================================================================================================
4583 */
OnSelectionTextureScaledown()4584 void CMainFrame::OnSelectionTextureScaledown() {
4585 Select_ScaleTexture(0, -g_qeglobals.d_savedinfo.m_nTextureTweak);
4586 }
4587
4588 /*
4589 =======================================================================================================================
4590 =======================================================================================================================
4591 */
OnSelectionTextureScaleup()4592 void CMainFrame::OnSelectionTextureScaleup() {
4593 Select_ScaleTexture(0, g_qeglobals.d_savedinfo.m_nTextureTweak);
4594 }
4595
4596 /*
4597 =======================================================================================================================
4598 =======================================================================================================================
4599 */
OnSelectionTextureScaleLeft()4600 void CMainFrame::OnSelectionTextureScaleLeft() {
4601 Select_ScaleTexture(g_qeglobals.d_savedinfo.m_nTextureTweak, 0);
4602 }
4603
4604 /*
4605 =======================================================================================================================
4606 =======================================================================================================================
4607 */
OnSelectionTextureScaleRight()4608 void CMainFrame::OnSelectionTextureScaleRight() {
4609 Select_ScaleTexture(g_qeglobals.d_savedinfo.m_nTextureTweak, 0);
4610 }
4611
4612 /*
4613 =======================================================================================================================
4614 =======================================================================================================================
4615 */
OnSelectionTextureShiftdown()4616 void CMainFrame::OnSelectionTextureShiftdown() {
4617 Select_ShiftTexture(0, -g_qeglobals.d_savedinfo.m_nTextureTweak, true);
4618 }
4619
4620 /*
4621 =======================================================================================================================
4622 =======================================================================================================================
4623 */
OnSelectionTextureShiftleft()4624 void CMainFrame::OnSelectionTextureShiftleft() {
4625 Select_ShiftTexture(-g_qeglobals.d_savedinfo.m_nTextureTweak, 0, true);
4626 }
4627
4628 /*
4629 =======================================================================================================================
4630 =======================================================================================================================
4631 */
OnSelectionTextureShiftright()4632 void CMainFrame::OnSelectionTextureShiftright() {
4633 Select_ShiftTexture(g_qeglobals.d_savedinfo.m_nTextureTweak, 0, true);
4634 }
4635
4636 /*
4637 =======================================================================================================================
4638 =======================================================================================================================
4639 */
OnSelectionTextureShiftup()4640 void CMainFrame::OnSelectionTextureShiftup() {
4641 Select_ShiftTexture(0, g_qeglobals.d_savedinfo.m_nTextureTweak, true);
4642 }
4643
4644 /*
4645 =======================================================================================================================
4646 =======================================================================================================================
4647 */
SetGridChecks(int id)4648 void CMainFrame::SetGridChecks(int id) {
4649 HMENU hMenu = ::GetMenu(GetSafeHwnd());
4650 CheckMenuItem(hMenu, ID_GRID_1, MF_BYCOMMAND | MF_UNCHECKED);
4651 CheckMenuItem(hMenu, ID_GRID_2, MF_BYCOMMAND | MF_UNCHECKED);
4652 CheckMenuItem(hMenu, ID_GRID_4, MF_BYCOMMAND | MF_UNCHECKED);
4653 CheckMenuItem(hMenu, ID_GRID_8, MF_BYCOMMAND | MF_UNCHECKED);
4654 CheckMenuItem(hMenu, ID_GRID_16, MF_BYCOMMAND | MF_UNCHECKED);
4655 CheckMenuItem(hMenu, ID_GRID_32, MF_BYCOMMAND | MF_UNCHECKED);
4656 CheckMenuItem(hMenu, ID_GRID_64, MF_BYCOMMAND | MF_UNCHECKED);
4657 CheckMenuItem(hMenu, ID_GRID_POINT5, MF_BYCOMMAND | MF_UNCHECKED);
4658 CheckMenuItem(hMenu, ID_GRID_POINT25, MF_BYCOMMAND | MF_UNCHECKED);
4659 CheckMenuItem(hMenu, ID_GRID_POINT125, MF_BYCOMMAND | MF_UNCHECKED);
4660 CheckMenuItem(hMenu, ID_GRID_POINT0625, MF_BYCOMMAND | MF_UNCHECKED);
4661 CheckMenuItem(hMenu, id, MF_BYCOMMAND | MF_CHECKED);
4662 }
4663
4664 /*
4665 =======================================================================================================================
4666 =======================================================================================================================
4667 */
OnGridNext()4668 void CMainFrame::OnGridNext() {
4669 if (g_qeglobals.d_gridsize >= MAX_GRID) {
4670 return;
4671 }
4672
4673 g_qeglobals.d_gridsize *= 2.0f;
4674
4675 float minGrid = MIN_GRID;
4676 int id = ID_GRID_START;
4677
4678 while (minGrid < g_qeglobals.d_gridsize && id < ID_GRID_END) {
4679 minGrid *= 2.0f;
4680 id++;
4681 }
4682
4683 UpdateGrid();
4684
4685 SetGridChecks(id);
4686 SetGridStatus();
4687 Sys_UpdateWindows(W_XY | W_Z);
4688 }
4689
4690 /*
4691 =======================================================================================================================
4692 =======================================================================================================================
4693 */
OnGridPrev()4694 void CMainFrame::OnGridPrev() {
4695 if (g_qeglobals.d_gridsize <= MIN_GRID) {
4696 return;
4697 }
4698
4699 g_qeglobals.d_gridsize /= 2;
4700
4701 float maxGrid = MAX_GRID;
4702 int id = ID_GRID_END;
4703
4704 while (maxGrid > g_qeglobals.d_gridsize && id > ID_GRID_START) {
4705 maxGrid /= 2.0f;
4706 id--;
4707 }
4708
4709 UpdateGrid();
4710
4711 SetGridChecks(id);
4712 SetGridStatus();
4713 Sys_UpdateWindows(W_XY | W_Z);
4714 }
4715
4716 /*
4717 =======================================================================================================================
4718 =======================================================================================================================
4719 */
SetGridStatus()4720 void CMainFrame::SetGridStatus() {
4721 CString strStatus;
4722 char c1;
4723 char c2;
4724 c1 = (g_PrefsDlg.m_bTextureLock) ? 'M' : ' ';
4725 c2 = (g_PrefsDlg.m_bRotateLock) ? 'R' : ' ';
4726 strStatus.Format
4727 (
4728 "G:%1.2f T:%1.2f R:%i C:%i L:%c%c",
4729 g_qeglobals.d_gridsize,
4730 g_qeglobals.d_savedinfo.m_nTextureTweak,
4731 g_PrefsDlg.m_nRotation,
4732 g_PrefsDlg.m_nCubicScale,
4733 c1,
4734 c2
4735 );
4736 SetStatusText(4, strStatus);
4737 }
4738
4739 /*
4740 =======================================================================================================================
4741 =======================================================================================================================
4742 */
SetTexValStatus()4743 void CMainFrame::SetTexValStatus() {
4744 //
4745 // CString strStatus; strStatus.Format("T: %i C: %i", g_nTextureTweak,
4746 // g_nCubicScale); SetStatusText(5, strStatus.GetBuffer(0));
4747 //
4748 SetGridStatus();
4749 }
4750
4751 /*
4752 =======================================================================================================================
4753 =======================================================================================================================
4754 */
OnTextureReplaceall()4755 void CMainFrame::OnTextureReplaceall() {
4756 CFindTextureDlg::show();
4757 }
4758
4759 /*
4760 =======================================================================================================================
4761 =======================================================================================================================
4762 */
OnScalelockx()4763 void CMainFrame::OnScalelockx() {
4764 if (g_nScaleHow & SCALE_X) {
4765 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKX, FALSE);
4766 }
4767 else {
4768 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKX);
4769 }
4770
4771 g_nScaleHow ^= SCALE_X;
4772 }
4773
4774 /*
4775 =======================================================================================================================
4776 =======================================================================================================================
4777 */
OnScalelocky()4778 void CMainFrame::OnScalelocky() {
4779 if (g_nScaleHow & SCALE_Y) {
4780 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKY, FALSE);
4781 }
4782 else {
4783 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKY);
4784 }
4785
4786 g_nScaleHow ^= SCALE_Y;
4787 }
4788
4789 /*
4790 =======================================================================================================================
4791 =======================================================================================================================
4792 */
OnScalelockz()4793 void CMainFrame::OnScalelockz() {
4794 if (g_nScaleHow & SCALE_Z) {
4795 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKZ, FALSE);
4796 }
4797 else {
4798 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKZ);
4799 }
4800
4801 g_nScaleHow ^= SCALE_Z;
4802 }
4803
4804 /*
4805 =======================================================================================================================
4806 =======================================================================================================================
4807 */
OnSelectMousescale()4808 void CMainFrame::OnSelectMousescale() {
4809 if (ActiveXY()) {
4810 if (ActiveXY()->ClipMode()) {
4811 OnViewClipper();
4812 }
4813
4814 if (ActiveXY()->RotateMode()) {
4815 // SetRotateMode(false) always works
4816 ActiveXY()->SetRotateMode(false);
4817 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSESCALE, FALSE);
4818 }
4819
4820 if (ActiveXY()->ScaleMode()) {
4821 ActiveXY()->SetScaleMode(false);
4822 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSESCALE, FALSE);
4823 }
4824 else {
4825 ActiveXY()->SetScaleMode(true);
4826 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSESCALE);
4827 }
4828 }
4829 }
4830
4831 /*
4832 =======================================================================================================================
4833 =======================================================================================================================
4834 */
OnFileImport()4835 void CMainFrame::OnFileImport() {
4836 }
4837
4838 /*
4839 =======================================================================================================================
4840 =======================================================================================================================
4841 */
OnFileProjectsettings()4842 void CMainFrame::OnFileProjectsettings() {
4843 DoProjectSettings();
4844 }
4845
4846 /*
4847 =======================================================================================================================
4848 =======================================================================================================================
4849 */
OnUpdateFileImport(CCmdUI * pCmdUI)4850 void CMainFrame::OnUpdateFileImport(CCmdUI *pCmdUI) {
4851 pCmdUI->Enable(FALSE);
4852 }
4853
4854 /*
4855 =======================================================================================================================
4856 =======================================================================================================================
4857 */
OnViewCubein()4858 void CMainFrame::OnViewCubein() {
4859 g_PrefsDlg.m_nCubicScale--;
4860 if (g_PrefsDlg.m_nCubicScale < 1) {
4861 g_PrefsDlg.m_nCubicScale = 1;
4862 }
4863
4864 g_PrefsDlg.SavePrefs();
4865 Sys_UpdateWindows(W_CAMERA);
4866 SetTexValStatus();
4867 }
4868
4869 /*
4870 =======================================================================================================================
4871 =======================================================================================================================
4872 */
OnViewCubeout()4873 void CMainFrame::OnViewCubeout() {
4874 g_PrefsDlg.m_nCubicScale++;
4875 if (g_PrefsDlg.m_nCubicScale > 99) {
4876 g_PrefsDlg.m_nCubicScale = 99;
4877 }
4878
4879 g_PrefsDlg.SavePrefs();
4880 Sys_UpdateWindows(W_CAMERA);
4881 SetTexValStatus();
4882 }
4883
4884 /*
4885 =======================================================================================================================
4886 =======================================================================================================================
4887 */
OnViewCubicclipping()4888 void CMainFrame::OnViewCubicclipping() {
4889 g_PrefsDlg.m_bCubicClipping ^= 1;
4890
4891 CMenu *pMenu = GetMenu();
4892 if (pMenu) {
4893 pMenu->CheckMenuItem
4894 (
4895 ID_VIEW_CUBICCLIPPING,
4896 MF_BYCOMMAND | (g_PrefsDlg.m_bCubicClipping) ? MF_CHECKED : MF_UNCHECKED
4897 );
4898 }
4899
4900 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_VIEW_CUBICCLIPPING, (g_PrefsDlg.m_bCubicClipping) ? TRUE : FALSE);
4901 g_PrefsDlg.SavePrefs();
4902 Map_BuildBrushData();
4903 Sys_UpdateWindows(W_CAMERA);
4904 }
4905
4906 /*
4907 =======================================================================================================================
4908 =======================================================================================================================
4909 */
OnFileSaveregion()4910 void CMainFrame::OnFileSaveregion() {
4911 SaveAsDialog(true);
4912 }
4913
4914 /*
4915 =======================================================================================================================
4916 =======================================================================================================================
4917 */
OnUpdateFileSaveregion(CCmdUI * pCmdUI)4918 void CMainFrame::OnUpdateFileSaveregion(CCmdUI *pCmdUI) {
4919 pCmdUI->Enable (static_cast<BOOL>(region_active));
4920 }
4921
4922 /*
4923 =======================================================================================================================
4924 =======================================================================================================================
4925 */
OnSelectionMovedown()4926 void CMainFrame::OnSelectionMovedown() {
4927 Undo_Start("move up");
4928 Undo_AddBrushList(&selected_brushes);
4929
4930 idVec3 vAmt;
4931 vAmt[0] = vAmt[1] = 0.0f;
4932 vAmt[2] = -g_qeglobals.d_gridsize;
4933 Select_Move(vAmt);
4934 Sys_UpdateWindows(W_CAMERA | W_XY | W_Z);
4935
4936 Undo_EndBrushList(&selected_brushes);
4937 Undo_End();
4938 }
4939
4940 /*
4941 =======================================================================================================================
4942 =======================================================================================================================
4943 */
OnSelectionMoveup()4944 void CMainFrame::OnSelectionMoveup() {
4945 idVec3 vAmt;
4946 vAmt[0] = vAmt[1] = 0.0f;
4947 vAmt[2] = g_qeglobals.d_gridsize;
4948 Select_Move(vAmt);
4949 Sys_UpdateWindows(W_CAMERA | W_XY | W_Z);
4950 }
4951
4952 /*
4953 =======================================================================================================================
4954 =======================================================================================================================
4955 */
OnToolbarMain()4956 void CMainFrame::OnToolbarMain() {
4957 }
4958
4959 /*
4960 =======================================================================================================================
4961 =======================================================================================================================
4962 */
OnToolbarTexture()4963 void CMainFrame::OnToolbarTexture() {
4964 }
4965
4966 /*
4967 =======================================================================================================================
4968 =======================================================================================================================
4969 */
OnSelectionPrint()4970 void CMainFrame::OnSelectionPrint() {
4971 for (brush_t * b = selected_brushes.next; b != &selected_brushes; b = b->next) {
4972 Brush_Print(b);
4973 }
4974 }
4975
4976 /*
4977 =======================================================================================================================
4978 =======================================================================================================================
4979 */
UpdateTextureBar()4980 void CMainFrame::UpdateTextureBar() {
4981 if (m_wndTextureBar.GetSafeHwnd()) {
4982 m_wndTextureBar.GetSurfaceAttributes();
4983 }
4984 }
4985
4986 bool g_bTABDown = false;
4987 bool g_bOriginalFlag;
4988
4989 /*
4990 =======================================================================================================================
4991 =======================================================================================================================
4992 */
OnSelectionTogglesizepaint()4993 void CMainFrame::OnSelectionTogglesizepaint() {
4994 if (::GetAsyncKeyState('Q')) {
4995 if (!g_bTABDown) {
4996 g_bTABDown = true;
4997 g_bOriginalFlag = ( g_PrefsDlg.m_bSizePaint != FALSE );
4998 g_PrefsDlg.m_bSizePaint = !g_bOriginalFlag;
4999 Sys_UpdateWindows(W_XY);
5000 return;
5001 }
5002 }
5003 else {
5004 g_bTABDown = false;
5005 g_PrefsDlg.m_bSizePaint = g_bOriginalFlag;
5006 Sys_UpdateWindows(W_XY);
5007 return;
5008 }
5009 }
5010
5011 /*
5012 =======================================================================================================================
5013 =======================================================================================================================
5014 */
OnBrushMakecone()5015 void CMainFrame::OnBrushMakecone() {
5016 Undo_Start("make cone");
5017 Undo_AddBrushList(&selected_brushes);
5018 DoSides(true);
5019 Undo_EndBrushList(&selected_brushes);
5020 Undo_End();
5021 }
5022
5023 /*
5024 =======================================================================================================================
5025 =======================================================================================================================
5026 */
OnTexturesLoad()5027 void CMainFrame::OnTexturesLoad() {
5028 BROWSEINFO bi;
5029 CString strPath;
5030 char *p = strPath.GetBuffer(MAX_PATH + 1);
5031 bi.hwndOwner = GetSafeHwnd();
5032 bi.pidlRoot = NULL;
5033 bi.pszDisplayName = p;
5034 bi.lpszTitle = "Load textures from path";
5035 bi.ulFlags = 0;
5036 bi.lpfn = NULL;
5037 bi.lParam = NULL;
5038 bi.iImage = 0;
5039
5040 LPITEMIDLIST pidlBrowse;
5041 pidlBrowse = SHBrowseForFolder(&bi);
5042 if (pidlBrowse) {
5043 SHGetPathFromIDList(pidlBrowse, p);
5044 strPath.ReleaseBuffer();
5045 AddSlash(strPath);
5046 //FIXME: idMaterial
5047 //Texture_ShowDirectory(strPath.GetBuffer(0));
5048 }
5049 }
5050
5051 /*
5052 =======================================================================================================================
5053 =======================================================================================================================
5054 */
OnToggleRotatelock()5055 void CMainFrame::OnToggleRotatelock() {
5056 g_qeglobals.flatRotation = false;
5057 g_qeglobals.rotateAxis++;
5058 if (g_qeglobals.rotateAxis > 2) {
5059 g_qeglobals.rotateAxis = 0;
5060 }
5061 Select_InitializeRotation();
5062 Sys_UpdateWindows(W_CAMERA | W_XY);
5063 }
5064
5065 /*
5066 =======================================================================================================================
5067 =======================================================================================================================
5068 */
OnCurveBevel()5069 void CMainFrame::OnCurveBevel() {
5070 // Curve_MakeCurvedBrush (false, false, false, false, false, true, true);
5071 }
5072
5073 /*
5074 =======================================================================================================================
5075 =======================================================================================================================
5076 */
OnCurveCylinder()5077 void CMainFrame::OnCurveCylinder() {
5078 // Curve_MakeCurvedBrush (false, false, false, true, true, true, true);
5079 }
5080
5081 /*
5082 =======================================================================================================================
5083 =======================================================================================================================
5084 */
OnCurveEighthsphere()5085 void CMainFrame::OnCurveEighthsphere() {
5086 // Curve_MakeCurvedBrush (false, true, false, true, true, false, false);
5087 }
5088
5089 /*
5090 =======================================================================================================================
5091 =======================================================================================================================
5092 */
OnCurveEndcap()5093 void CMainFrame::OnCurveEndcap() {
5094 // Curve_MakeCurvedBrush (false, false, false, false, true, true, true);
5095 }
5096
5097 /*
5098 =======================================================================================================================
5099 =======================================================================================================================
5100 */
OnCurveHemisphere()5101 void CMainFrame::OnCurveHemisphere() {
5102 // Curve_MakeCurvedBrush (false, true, false, true, true, true, true);
5103 }
5104
5105 /*
5106 =======================================================================================================================
5107 =======================================================================================================================
5108 */
OnCurveInvertcurve()5109 void CMainFrame::OnCurveInvertcurve() {
5110 // Curve_Invert ();
5111 }
5112
5113 /*
5114 =======================================================================================================================
5115 =======================================================================================================================
5116 */
OnCurveQuarter()5117 void CMainFrame::OnCurveQuarter() {
5118 // Curve_MakeCurvedBrush (false, true, false, true, true, true, false);
5119 }
5120
5121 /*
5122 =======================================================================================================================
5123 =======================================================================================================================
5124 */
OnCurveSphere()5125 void CMainFrame::OnCurveSphere() {
5126 // Curve_MakeCurvedBrush (false, true, true, true, true, true, true);
5127 }
5128
5129 /*
5130 =======================================================================================================================
5131 =======================================================================================================================
5132 */
OnFileImportmap()5133 void CMainFrame::OnFileImportmap() {
5134 CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Map files (*.map)|*.map||", this);
5135 if (dlgFile.DoModal() == IDOK) {
5136 Map_ImportFile(dlgFile.GetPathName().GetBuffer(0));
5137 }
5138 }
5139
5140 /*
5141 =======================================================================================================================
5142 =======================================================================================================================
5143 */
OnFileExportmap()5144 void CMainFrame::OnFileExportmap() {
5145 CFileDialog dlgFile(FALSE, "map", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Map files (*.map)|*.map||", this);
5146 if (dlgFile.DoModal() == IDOK) {
5147 Map_SaveSelected(dlgFile.GetPathName().GetBuffer(0));
5148 }
5149 }
5150
5151 /*
5152 =======================================================================================================================
5153 =======================================================================================================================
5154 */
OnViewShowcurves()5155 void CMainFrame::OnViewShowcurves() {
5156 if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_CURVES) & EXCLUDE_CURVES) {
5157 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWCURVES, MF_BYCOMMAND | MF_UNCHECKED);
5158 }
5159 else {
5160 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWCURVES, MF_BYCOMMAND | MF_CHECKED);
5161 }
5162
5163 Sys_UpdateWindows(W_XY | W_CAMERA);
5164 }
5165
5166 /*
5167 =======================================================================================================================
5168 =======================================================================================================================
5169 */
OnSelectionSelectNudgedown()5170 void CMainFrame::OnSelectionSelectNudgedown() {
5171 NudgeSelection(3, g_qeglobals.d_savedinfo.m_nTextureTweak);
5172 }
5173
5174 /*
5175 =======================================================================================================================
5176 =======================================================================================================================
5177 */
OnSelectionSelectNudgeleft()5178 void CMainFrame::OnSelectionSelectNudgeleft() {
5179 NudgeSelection(0, g_qeglobals.d_savedinfo.m_nTextureTweak);
5180 }
5181
5182 /*
5183 =======================================================================================================================
5184 =======================================================================================================================
5185 */
OnSelectionSelectNudgeright()5186 void CMainFrame::OnSelectionSelectNudgeright() {
5187 NudgeSelection(2, g_qeglobals.d_savedinfo.m_nTextureTweak);
5188 }
5189
5190 /*
5191 =======================================================================================================================
5192 =======================================================================================================================
5193 */
OnSelectionSelectNudgeup()5194 void CMainFrame::OnSelectionSelectNudgeup() {
5195 NudgeSelection(1, g_qeglobals.d_savedinfo.m_nTextureTweak);
5196 }
5197
5198 /*
5199 =======================================================================================================================
5200 =======================================================================================================================
5201 */
NudgeSelection(int nDirection,float fAmount)5202 void CMainFrame::NudgeSelection(int nDirection, float fAmount) {
5203 if (ActiveXY()->RotateMode()) {
5204 int nAxis = 0;
5205 if (ActiveXY()->GetViewType() == XY) {
5206 nAxis = 2;
5207 } else if (g_pParentWnd->ActiveXY()->GetViewType() == XZ) {
5208 nAxis = 1;
5209 fAmount = -fAmount;
5210 }
5211
5212 if (nDirection == 2 || nDirection == 3) {
5213 fAmount = -fAmount;
5214 }
5215
5216 float fDeg = -fAmount;
5217
5218 g_pParentWnd->ActiveXY()->Rotation()[nAxis] += fAmount;
5219
5220 CString strStatus;
5221 strStatus.Format
5222 (
5223 "Rotation x:: %.1f y:: %.1f z:: %.1f",
5224 g_pParentWnd->ActiveXY()->Rotation()[0],
5225 g_pParentWnd->ActiveXY()->Rotation()[1],
5226 g_pParentWnd->ActiveXY()->Rotation()[2]
5227 );
5228 g_pParentWnd->SetStatusText(2, strStatus);
5229 Select_RotateAxis(nAxis, fDeg, false, true);
5230 Sys_UpdateWindows(W_ALL);
5231 }
5232 else if (ActiveXY()->ScaleMode()) {
5233 if (nDirection == 0 || nDirection == 3) {
5234 fAmount = -fAmount;
5235 }
5236
5237 idVec3 v;
5238 v[0] = v[1] = v[2] = 1.0f;
5239 if (fAmount > 0) {
5240 v[0] = 1.1f;
5241 v[1] = 1.1f;
5242 v[2] = 1.1f;
5243 }
5244 else {
5245 v[0] = 0.9f;
5246 v[1] = 0.9f;
5247 v[2] = 0.9f;
5248 }
5249
5250 Select_Scale
5251 (
5252 (g_nScaleHow & SCALE_X) ? v[0] : 1.0f,
5253 (g_nScaleHow & SCALE_Y) ? v[1] : 1.0f,
5254 (g_nScaleHow & SCALE_Z) ? v[2] : 1.0f
5255 );
5256 Sys_UpdateWindows(W_ALL);
5257 }
5258 else {
5259 // 0 - left, 1 - up, 2 - right, 3 - down
5260 int nDim;
5261 if (nDirection == 0) {
5262 nDim = ActiveXY()->GetViewType() == YZ ? 1 : 0;
5263 fAmount = -fAmount;
5264 }
5265 else if (nDirection == 1) {
5266 nDim = ActiveXY()->GetViewType() == XY ? 1 : 2;
5267 }
5268 else if (nDirection == 2) {
5269 nDim = ActiveXY()->GetViewType() == YZ ? 1 : 0;
5270 }
5271 else {
5272 nDim = ActiveXY()->GetViewType() == XY ? 1 : 2;
5273 fAmount = -fAmount;
5274 }
5275
5276 Nudge(nDim, fAmount);
5277 }
5278 }
5279
5280 /*
5281 =======================================================================================================================
5282 =======================================================================================================================
5283 */
PreTranslateMessage(MSG * pMsg)5284 BOOL CMainFrame::PreTranslateMessage(MSG *pMsg) {
5285 return CFrameWnd::PreTranslateMessage(pMsg);
5286 }
5287
5288 /*
5289 =======================================================================================================================
5290 =======================================================================================================================
5291 */
Nudge(int nDim,float fNudge)5292 void CMainFrame::Nudge(int nDim, float fNudge) {
5293 idVec3 vMove;
5294 vMove[0] = vMove[1] = vMove[2] = 0;
5295 vMove[nDim] = fNudge;
5296 Select_Move(vMove, true);
5297 Sys_UpdateWindows(W_ALL);
5298 }
5299
5300 /*
5301 =======================================================================================================================
5302 =======================================================================================================================
5303 */
OnTexturesLoadlist()5304 void CMainFrame::OnTexturesLoadlist() {
5305 CDialogTextures dlg;
5306 dlg.DoModal();
5307 }
5308
5309 /*
5310 =======================================================================================================================
5311 =======================================================================================================================
5312 */
OnSelectByBoundingBrush()5313 void CMainFrame::OnSelectByBoundingBrush() {
5314 g_PrefsDlg.m_selectByBoundingBrush ^= 1;
5315 m_wndToolBar.GetToolBarCtrl().CheckButton
5316 (
5317 ID_SELECT_BYBOUNDINGBRUSH,
5318 (g_PrefsDlg.m_selectByBoundingBrush) ? TRUE : FALSE
5319 );
5320 }
5321
5322 /*
5323 =======================================================================================================================
5324 =======================================================================================================================
5325 */
OnSelectBrushesOnly()5326 void CMainFrame::OnSelectBrushesOnly() {
5327 g_PrefsDlg.m_selectOnlyBrushes ^= 1;
5328 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_BRUSHESONLY, (g_PrefsDlg.m_selectOnlyBrushes) ? TRUE : FALSE);
5329 }
5330
5331
5332
5333
5334 /*
5335 =======================================================================================================================
5336 =======================================================================================================================
5337 */
OnDynamicLighting()5338 void CMainFrame::OnDynamicLighting() {
5339 CCamWnd *pCam = new CCamWnd();
5340 CRect rect(100, 100, 300, 300);
5341 pCam->Create(CAMERA_WINDOW_CLASS, "", WS_OVERLAPPEDWINDOW, rect, GetDesktopWindow(), 12345);
5342 pCam->ShowWindow(SW_SHOW);
5343 }
5344
5345 /*
5346 =======================================================================================================================
5347 =======================================================================================================================
5348 */
OnCurveSimplepatchmesh()5349 void CMainFrame::OnCurveSimplepatchmesh() {
5350 Undo_Start("make simpe patch mesh");
5351 Undo_AddBrushList(&selected_brushes);
5352
5353 CPatchDensityDlg dlg;
5354 dlg.DoModal();
5355
5356 Undo_EndBrushList(&selected_brushes);
5357 Undo_End();
5358 }
5359
5360 /*
5361 =======================================================================================================================
5362 =======================================================================================================================
5363 */
OnPatchToggleBox()5364 void CMainFrame::OnPatchToggleBox() {
5365 g_bPatchShowBounds ^= 1;
5366 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_SHOWBOUNDINGBOX, (g_bPatchShowBounds) ? TRUE : FALSE);
5367 Sys_UpdateWindows(W_ALL);
5368 }
5369
5370 /*
5371 =======================================================================================================================
5372 =======================================================================================================================
5373 */
OnPatchWireframe()5374 void CMainFrame::OnPatchWireframe() {
5375 g_bPatchWireFrame ^= 1;
5376 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_WIREFRAME, (g_bPatchWireFrame) ? TRUE : FALSE);
5377 Sys_UpdateWindows(W_ALL);
5378 }
5379
5380 /*
5381 =======================================================================================================================
5382 =======================================================================================================================
5383 */
OnCurvePatchcone()5384 void CMainFrame::OnCurvePatchcone() {
5385 Undo_Start("make curve cone");
5386 Undo_AddBrushList(&selected_brushes);
5387 Patch_BrushToMesh(true);
5388 Sys_UpdateWindows(W_ALL);
5389 Undo_EndBrushList(&selected_brushes);
5390 Undo_End();
5391 }
5392
5393 /*
5394 =======================================================================================================================
5395 =======================================================================================================================
5396 */
OnCurvePatchtube()5397 void CMainFrame::OnCurvePatchtube() {
5398 Undo_Start("make curve cylinder");
5399 Undo_AddBrushList(&selected_brushes);
5400 Patch_BrushToMesh(false);
5401 Sys_UpdateWindows(W_ALL);
5402 Undo_EndBrushList(&selected_brushes);
5403 Undo_End();
5404 }
5405
5406 /*
5407 =======================================================================================================================
5408 =======================================================================================================================
5409 */
OnPatchWeld()5410 void CMainFrame::OnPatchWeld() {
5411 g_bPatchWeld ^= 1;
5412 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_WELD, (g_bPatchWeld) ? TRUE : FALSE);
5413 Sys_UpdateWindows(W_ALL);
5414 }
5415
5416 /*
5417 =======================================================================================================================
5418 =======================================================================================================================
5419 */
OnCurvePatchbevel()5420 void CMainFrame::OnCurvePatchbevel() {
5421 Undo_Start("make bevel");
5422 Undo_AddBrushList(&selected_brushes);
5423 Patch_BrushToMesh(false, true, false);
5424 Sys_UpdateWindows(W_ALL);
5425 Undo_EndBrushList(&selected_brushes);
5426 Undo_End();
5427 }
5428
5429 /*
5430 =======================================================================================================================
5431 =======================================================================================================================
5432 */
OnCurvePatchendcap()5433 void CMainFrame::OnCurvePatchendcap() {
5434 Undo_Start("make end cap");
5435 Undo_AddBrushList(&selected_brushes);
5436 Patch_BrushToMesh(false, false, true);
5437 Sys_UpdateWindows(W_ALL);
5438 Undo_EndBrushList(&selected_brushes);
5439 Undo_End();
5440 }
5441
5442 /*
5443 =======================================================================================================================
5444 =======================================================================================================================
5445 */
OnCurvePatchinvertedbevel()5446 void CMainFrame::OnCurvePatchinvertedbevel() {
5447 // Patch_BrushToMesh(false, true, false, true); Sys_UpdateWindows (W_ALL);
5448 }
5449
5450 /*
5451 =======================================================================================================================
5452 =======================================================================================================================
5453 */
OnCurvePatchinvertedendcap()5454 void CMainFrame::OnCurvePatchinvertedendcap() {
5455 // Patch_BrushToMesh(false, false, true, true); Sys_UpdateWindows (W_ALL);
5456 }
5457
5458 /*
5459 =======================================================================================================================
5460 =======================================================================================================================
5461 */
OnPatchDrilldown()5462 void CMainFrame::OnPatchDrilldown() {
5463 g_bPatchDrillDown ^= 1;
5464 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_DRILLDOWN, (g_bPatchDrillDown) ? TRUE : FALSE);
5465 Sys_UpdateWindows(W_ALL);
5466 }
5467
5468 /*
5469 =======================================================================================================================
5470 =======================================================================================================================
5471 */
OnCurveInsertcolumn()5472 void CMainFrame::OnCurveInsertcolumn() {
5473 Undo_Start("insert colum");
5474 Undo_AddBrushList(&selected_brushes);
5475
5476 // Patch_AdjustSelectedRowCols(0, 2);
5477 Patch_AdjustSelected(true, true, true);
5478 Sys_UpdateWindows(W_ALL);
5479 Undo_EndBrushList(&selected_brushes);
5480 Undo_End();
5481 }
5482
5483 /*
5484 =======================================================================================================================
5485 =======================================================================================================================
5486 */
OnCurveInsertrow()5487 void CMainFrame::OnCurveInsertrow() {
5488 Undo_Start("insert row");
5489 Undo_AddBrushList(&selected_brushes);
5490
5491 // Patch_AdjustSelectedRowCols(2, 0);
5492 Patch_AdjustSelected(true, false, true);
5493 Sys_UpdateWindows(W_ALL);
5494 Undo_EndBrushList(&selected_brushes);
5495 Undo_End();
5496 }
5497
5498 /*
5499 =======================================================================================================================
5500 =======================================================================================================================
5501 */
OnCurveDeletecolumn()5502 void CMainFrame::OnCurveDeletecolumn() {
5503 Undo_Start("delete column");
5504 Undo_AddBrushList(&selected_brushes);
5505 Patch_AdjustSelected(false, true, true);
5506 Sys_UpdateWindows(W_ALL);
5507 Undo_EndBrushList(&selected_brushes);
5508 Undo_End();
5509 }
5510
5511 /*
5512 =======================================================================================================================
5513 =======================================================================================================================
5514 */
OnCurveDeleterow()5515 void CMainFrame::OnCurveDeleterow() {
5516 Undo_Start("delete row");
5517 Undo_AddBrushList(&selected_brushes);
5518 Patch_AdjustSelected(false, false, true);
5519 Sys_UpdateWindows(W_ALL);
5520 Undo_EndBrushList(&selected_brushes);
5521 Undo_End();
5522 }
5523
5524 /*
5525 =======================================================================================================================
5526 =======================================================================================================================
5527 */
OnCurveInsertAddcolumn()5528 void CMainFrame::OnCurveInsertAddcolumn() {
5529 Undo_Start("add (2) columns");
5530 Undo_AddBrushList(&selected_brushes);
5531 Patch_AdjustSelected(true, true, true);
5532 Sys_UpdateWindows(W_ALL);
5533 Undo_EndBrushList(&selected_brushes);
5534 Undo_End();
5535 }
5536
5537 /*
5538 =======================================================================================================================
5539 =======================================================================================================================
5540 */
OnCurveInsertAddrow()5541 void CMainFrame::OnCurveInsertAddrow() {
5542 Undo_Start("add (2) rows");
5543 Undo_AddBrushList(&selected_brushes);
5544 Patch_AdjustSelected(true, false, true);
5545 Sys_UpdateWindows(W_ALL);
5546 Undo_EndBrushList(&selected_brushes);
5547 Undo_End();
5548 }
5549
5550 /*
5551 =======================================================================================================================
5552 =======================================================================================================================
5553 */
OnCurveInsertInsertcolumn()5554 void CMainFrame::OnCurveInsertInsertcolumn() {
5555 Undo_Start("insert (2) columns");
5556 Undo_AddBrushList(&selected_brushes);
5557 Patch_AdjustSelected(true, true, false);
5558 Sys_UpdateWindows(W_ALL);
5559 Undo_EndBrushList(&selected_brushes);
5560 Undo_End();
5561 }
5562
5563 /*
5564 =======================================================================================================================
5565 =======================================================================================================================
5566 */
OnCurveInsertInsertrow()5567 void CMainFrame::OnCurveInsertInsertrow() {
5568 Undo_Start("insert (2) rows");
5569 Undo_AddBrushList(&selected_brushes);
5570 Patch_AdjustSelected(true, false, false);
5571 Sys_UpdateWindows(W_ALL);
5572 Undo_EndBrushList(&selected_brushes);
5573 Undo_End();
5574 }
5575
5576 /*
5577 =======================================================================================================================
5578 =======================================================================================================================
5579 */
OnCurveNegative()5580 void CMainFrame::OnCurveNegative() {
5581 Patch_ToggleInverted();
5582
5583 // Sys_UpdateWindows(W_ALL);
5584 }
5585
5586 /*
5587 =======================================================================================================================
5588 =======================================================================================================================
5589 */
OnCurveNegativeTextureX()5590 void CMainFrame::OnCurveNegativeTextureX() {
5591 Select_FlipTexture(false);
5592
5593 // Sys_UpdateWindows(W_ALL);
5594 }
5595
5596 /*
5597 =======================================================================================================================
5598 =======================================================================================================================
5599 */
OnCurveNegativeTextureY()5600 void CMainFrame::OnCurveNegativeTextureY() {
5601 Select_FlipTexture(true);
5602 // Sys_UpdateWindows(W_ALL);
5603 }
5604
5605 /*
5606 =======================================================================================================================
5607 =======================================================================================================================
5608 */
OnCurveDeleteFirstcolumn()5609 void CMainFrame::OnCurveDeleteFirstcolumn() {
5610 Undo_Start("delete first (2) columns");
5611 Undo_AddBrushList(&selected_brushes);
5612 Patch_AdjustSelected(false, true, true);
5613 Sys_UpdateWindows(W_ALL);
5614 Undo_EndBrushList(&selected_brushes);
5615 Undo_End();
5616 }
5617
5618 /*
5619 =======================================================================================================================
5620 =======================================================================================================================
5621 */
OnCurveDeleteFirstrow()5622 void CMainFrame::OnCurveDeleteFirstrow() {
5623 Undo_Start("delete first (2) rows");
5624 Undo_AddBrushList(&selected_brushes);
5625 Patch_AdjustSelected(false, false, true);
5626 Sys_UpdateWindows(W_ALL);
5627 Undo_EndBrushList(&selected_brushes);
5628 Undo_End();
5629 }
5630
5631 /*
5632 =======================================================================================================================
5633 =======================================================================================================================
5634 */
OnCurveDeleteLastcolumn()5635 void CMainFrame::OnCurveDeleteLastcolumn() {
5636 Undo_Start("delete last (2) columns");
5637 Undo_AddBrushList(&selected_brushes);
5638 Patch_AdjustSelected(false, true, false);
5639 Sys_UpdateWindows(W_ALL);
5640 Undo_EndBrushList(&selected_brushes);
5641 Undo_End();
5642 }
5643
5644 /*
5645 =======================================================================================================================
5646 =======================================================================================================================
5647 */
OnCurveDeleteLastrow()5648 void CMainFrame::OnCurveDeleteLastrow() {
5649 Undo_Start("delete last (2) rows");
5650 Undo_AddBrushList(&selected_brushes);
5651 Patch_AdjustSelected(false, false, false);
5652 Sys_UpdateWindows(W_ALL);
5653 Undo_EndBrushList(&selected_brushes);
5654 Undo_End();
5655 }
5656
5657 /*
5658 =======================================================================================================================
5659 =======================================================================================================================
5660 */
OnPatchBend()5661 void CMainFrame::OnPatchBend() {
5662 Patch_BendToggle();
5663 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_BEND, (g_bPatchBendMode) ? TRUE : FALSE);
5664 Sys_UpdateWindows(W_ALL);
5665 }
5666
5667 /*
5668 =======================================================================================================================
5669 =======================================================================================================================
5670 */
OnPatchInsdel()5671 void CMainFrame::OnPatchInsdel() {
5672 Patch_InsDelToggle();
5673 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_INSDEL, (g_bPatchInsertMode) ? TRUE : FALSE);
5674 Sys_UpdateWindows(W_ALL);
5675 }
5676
5677 /*
5678 =======================================================================================================================
5679 =======================================================================================================================
5680 */
OnPatchEnter()5681 void CMainFrame::OnPatchEnter() {
5682 }
5683
5684 /*
5685 =======================================================================================================================
5686 =======================================================================================================================
5687 */
5688 extern bool Sys_KeyDown(int key);
OnPatchTab()5689 void CMainFrame::OnPatchTab() {
5690 if (g_bPatchBendMode) {
5691 Patch_BendHandleTAB();
5692 }
5693 else if (g_bPatchInsertMode) {
5694 Patch_InsDelHandleTAB();
5695 }
5696 else if (g_bAxialMode) {
5697 int faceCount = g_ptrSelectedFaces.GetSize();
5698 if (faceCount > 0) {
5699 face_t *selFace = reinterpret_cast < face_t * > (g_ptrSelectedFaces.GetAt(0));
5700 int *ip = (Sys_KeyDown(VK_SHIFT)) ? &g_axialAnchor : &g_axialDest;
5701 (*ip)++;
5702 if ( *ip >= selFace->face_winding->GetNumPoints() ) {
5703 *ip = 0;
5704 }
5705 }
5706 Sys_UpdateWindows(W_CAMERA);
5707 } else {
5708 //
5709 // check to see if the selected brush is part of a func group if it is, deselect
5710 // everything and reselect the next brush in the group
5711 //
5712 brush_t *b = selected_brushes.next;
5713 entity_t *e;
5714 if (b != &selected_brushes) {
5715 if ( idStr::Icmp(b->owner->eclass->name, "worldspawn") != 0 ) {
5716 e = b->owner;
5717 Select_Deselect();
5718 brush_t *b2;
5719 for (b2 = e->brushes.onext; b2 != &e->brushes; b2 = b2->onext) {
5720 if (b == b2) {
5721 b2 = b2->onext;
5722 break;
5723 }
5724 }
5725
5726 if (b2 == &e->brushes) {
5727 b2 = b2->onext;
5728 }
5729
5730 Select_Brush(b2, false);
5731 Sys_UpdateWindows(W_ALL);
5732 }
5733 }
5734 }
5735 }
5736
5737 /*
5738 =======================================================================================================================
5739 =======================================================================================================================
5740 */
UpdatePatchToolbarButtons()5741 void CMainFrame::UpdatePatchToolbarButtons() {
5742 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_BEND, (g_bPatchBendMode) ? TRUE : FALSE);
5743 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_INSDEL, (g_bPatchInsertMode) ? TRUE : FALSE);
5744 }
5745
5746 /*
5747 =======================================================================================================================
5748 =======================================================================================================================
5749 */
OnCurvePatchdensetube()5750 void CMainFrame::OnCurvePatchdensetube() {
5751 Undo_Start("dense cylinder");
5752 Undo_AddBrushList(&selected_brushes);
5753
5754 Patch_BrushToMesh(false);
5755 OnCurveInsertAddrow();
5756 OnCurveInsertInsertrow();
5757 Sys_UpdateWindows(W_ALL);
5758
5759 Undo_EndBrushList(&selected_brushes);
5760 Undo_End();
5761 }
5762
5763 /*
5764 =======================================================================================================================
5765 =======================================================================================================================
5766 */
OnCurvePatchverydensetube()5767 void CMainFrame::OnCurvePatchverydensetube() {
5768 Undo_Start("very dense cylinder");
5769 Undo_AddBrushList(&selected_brushes);
5770
5771 Patch_BrushToMesh(false);
5772 OnCurveInsertAddrow();
5773 OnCurveInsertInsertrow();
5774 OnCurveInsertAddrow();
5775 OnCurveInsertInsertrow();
5776 Sys_UpdateWindows(W_ALL);
5777
5778 Undo_EndBrushList(&selected_brushes);
5779 Undo_End();
5780 }
5781
5782 /*
5783 =======================================================================================================================
5784 =======================================================================================================================
5785 */
OnCurveCap()5786 void CMainFrame::OnCurveCap() {
5787 Patch_CapCurrent();
5788 Sys_UpdateWindows(W_ALL);
5789 }
5790
5791 /*
5792 =======================================================================================================================
5793 =======================================================================================================================
5794 */
OnCurveCapInvertedbevel()5795 void CMainFrame::OnCurveCapInvertedbevel() {
5796 Patch_CapCurrent(true);
5797 Sys_UpdateWindows(W_ALL);
5798 }
5799
5800 /*
5801 =======================================================================================================================
5802 =======================================================================================================================
5803 */
OnCurveCapInvertedendcap()5804 void CMainFrame::OnCurveCapInvertedendcap() {
5805 Patch_CapCurrent(false, true);
5806 Sys_UpdateWindows(W_ALL);
5807 }
5808
5809 /*
5810 =======================================================================================================================
5811 =======================================================================================================================
5812 */
OnCurveRedisperseCols()5813 void CMainFrame::OnCurveRedisperseCols() {
5814 Patch_DisperseColumns();
5815 Sys_UpdateWindows(W_ALL);
5816 }
5817
5818 /*
5819 =======================================================================================================================
5820 =======================================================================================================================
5821 */
OnCurveRedisperseRows()5822 void CMainFrame::OnCurveRedisperseRows() {
5823 Patch_DisperseRows();
5824 Sys_UpdateWindows(W_ALL);
5825 }
5826
5827 /*
5828 =======================================================================================================================
5829 =======================================================================================================================
5830 */
OnPatchNaturalize()5831 void CMainFrame::OnPatchNaturalize() {
5832 Patch_NaturalizeSelected();
5833 Sys_UpdateWindows(W_ALL);
5834 }
5835
5836 /*
5837 =======================================================================================================================
5838 =======================================================================================================================
5839 */
OnPatchNaturalizeAlt()5840 void CMainFrame::OnPatchNaturalizeAlt() {
5841 Patch_NaturalizeSelected(false, false, true);
5842 Sys_UpdateWindows(W_ALL);
5843 }
5844
5845 /*
5846 =======================================================================================================================
5847 =======================================================================================================================
5848 */
OnSnapToGrid()5849 void CMainFrame::OnSnapToGrid() {
5850 Select_SnapToGrid();
5851 Sys_UpdateWindows(W_ALL);
5852 }
5853
5854 /*
5855 =======================================================================================================================
5856 =======================================================================================================================
5857 */
OnCurvePatchsquare()5858 void CMainFrame::OnCurvePatchsquare() {
5859 Undo_Start("square cylinder");
5860 Undo_AddBrushList(&selected_brushes);
5861
5862 Patch_BrushToMesh(false, false, false, true);
5863 Sys_UpdateWindows(W_ALL);
5864
5865 Undo_EndBrushList(&selected_brushes);
5866 Undo_End();
5867 }
5868
5869 /*
5870 =======================================================================================================================
5871 =======================================================================================================================
5872 */
CheckTextureScale(int id)5873 void CMainFrame::CheckTextureScale(int id) {
5874 CMenu *pMenu = GetMenu();
5875 if (pMenu) {
5876 pMenu->CheckMenuItem(ID_TEXTURES_TEXTUREWINDOWSCALE_10, MF_BYCOMMAND | MF_UNCHECKED);
5877 pMenu->CheckMenuItem(ID_TEXTURES_TEXTUREWINDOWSCALE_25, MF_BYCOMMAND | MF_UNCHECKED);
5878 pMenu->CheckMenuItem(ID_TEXTURES_TEXTUREWINDOWSCALE_50, MF_BYCOMMAND | MF_UNCHECKED);
5879 pMenu->CheckMenuItem(ID_TEXTURES_TEXTUREWINDOWSCALE_100, MF_BYCOMMAND | MF_UNCHECKED);
5880 pMenu->CheckMenuItem(ID_TEXTURES_TEXTUREWINDOWSCALE_200, MF_BYCOMMAND | MF_UNCHECKED);
5881 pMenu->CheckMenuItem(id, MF_BYCOMMAND | MF_CHECKED);
5882 }
5883
5884 g_PrefsDlg.SavePrefs();
5885 //FIXME: idMaterial
5886 //Texture_ResetPosition();
5887 Sys_UpdateWindows(W_TEXTURE);
5888 }
5889
5890 /*
5891 =======================================================================================================================
5892 =======================================================================================================================
5893 */
OnTexturesTexturewindowscale10()5894 void CMainFrame::OnTexturesTexturewindowscale10() {
5895 g_PrefsDlg.m_nTextureScale = 10;
5896 CheckTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_10);
5897 }
5898
5899 /*
5900 =======================================================================================================================
5901 =======================================================================================================================
5902 */
OnTexturesTexturewindowscale100()5903 void CMainFrame::OnTexturesTexturewindowscale100() {
5904 g_PrefsDlg.m_nTextureScale = 100;
5905 CheckTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_100);
5906 }
5907
5908 /*
5909 =======================================================================================================================
5910 =======================================================================================================================
5911 */
OnTexturesTexturewindowscale200()5912 void CMainFrame::OnTexturesTexturewindowscale200() {
5913 g_PrefsDlg.m_nTextureScale = 200;
5914 CheckTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_200);
5915 }
5916
5917 /*
5918 =======================================================================================================================
5919 =======================================================================================================================
5920 */
OnTexturesTexturewindowscale25()5921 void CMainFrame::OnTexturesTexturewindowscale25() {
5922 g_PrefsDlg.m_nTextureScale = 25;
5923 CheckTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_25);
5924 }
5925
5926 /*
5927 =======================================================================================================================
5928 =======================================================================================================================
5929 */
OnTexturesTexturewindowscale50()5930 void CMainFrame::OnTexturesTexturewindowscale50() {
5931 g_PrefsDlg.m_nTextureScale = 50;
5932 CheckTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_50);
5933 }
5934
5935 /*
5936 =======================================================================================================================
5937 =======================================================================================================================
5938 */
OnTexturesFlush()5939 void CMainFrame::OnTexturesFlush() {
5940 //FIXME: idMaterial
5941 //Texture_Flush();
5942 Sys_UpdateWindows(W_ALL);
5943 }
5944
5945 /*
5946 =======================================================================================================================
5947 =======================================================================================================================
5948 */
OnCurveOverlayClear()5949 void CMainFrame::OnCurveOverlayClear() {
5950 Patch_ClearOverlays();
5951 Sys_UpdateWindows(W_ALL);
5952 }
5953
5954 /*
5955 =======================================================================================================================
5956 =======================================================================================================================
5957 */
OnCurveOverlaySet()5958 void CMainFrame::OnCurveOverlaySet() {
5959 Patch_SetOverlays();
5960 Sys_UpdateWindows(W_ALL);
5961 }
5962
5963 /*
5964 =======================================================================================================================
5965 =======================================================================================================================
5966 */
OnCurveThicken()5967 void CMainFrame::OnCurveThicken() {
5968 Undo_Start("curve thicken");
5969 Undo_AddBrushList(&selected_brushes);
5970
5971 CDialogThick dlg;
5972 if ( dlg.DoModal() == IDOK ) {
5973 Patch_Thicken( dlg.m_nAmount, ( dlg.m_bSeams != FALSE ) );
5974 Sys_UpdateWindows(W_ALL);
5975 }
5976
5977 Undo_EndBrushList(&selected_brushes);
5978 Undo_End();
5979 }
5980
5981 /*
5982 =======================================================================================================================
5983 =======================================================================================================================
5984 */
OnCurveCyclecap()5985 void CMainFrame::OnCurveCyclecap() {
5986 Patch_NaturalizeSelected(true, true);
5987 Sys_UpdateWindows(W_ALL);
5988 }
5989
OnCurveCyclecapAlt()5990 void CMainFrame::OnCurveCyclecapAlt() {
5991 Patch_NaturalizeSelected(true, true, true);
5992 Sys_UpdateWindows(W_ALL);
5993 }
5994
5995 /*
5996 =======================================================================================================================
5997 =======================================================================================================================
5998 */
OnCurveMatrixTranspose()5999 void CMainFrame::OnCurveMatrixTranspose() {
6000 Patch_Transpose();
6001 Sys_UpdateWindows(W_ALL);
6002 }
6003
6004 /*
6005 =======================================================================================================================
6006 =======================================================================================================================
6007 */
OnTexturesReloadshaders()6008 void CMainFrame::OnTexturesReloadshaders() {
6009 CWaitCursor wait;
6010 declManager->Reload( false );
6011 Sys_UpdateWindows(W_ALL);
6012 }
6013
6014 /*
6015 =======================================================================================================================
6016 =======================================================================================================================
6017 */
SetEntityCheck()6018 void CMainFrame::SetEntityCheck() {
6019 CMenu *pMenu = GetMenu();
6020 if (pMenu) {
6021 pMenu->CheckMenuItem(ID_VIEW_ENTITIESAS_WIREFRAME, MF_BYCOMMAND | (g_PrefsDlg.m_nEntityShowState == ENTITY_WIRE) ? MF_CHECKED : MF_UNCHECKED);
6022 pMenu->CheckMenuItem(ID_VIEW_ENTITIESAS_SKINNED, MF_BYCOMMAND | (g_PrefsDlg.m_nEntityShowState == ENTITY_SKINNED) ? MF_CHECKED : MF_UNCHECKED);
6023 }
6024 }
6025
6026 /*
6027 =======================================================================================================================
6028 =======================================================================================================================
6029 */
OnShowEntities()6030 void CMainFrame::OnShowEntities() {
6031 HandlePopup(this, IDR_POPUP_ENTITY);
6032 }
6033
6034 /*
6035 =======================================================================================================================
6036 =======================================================================================================================
6037 */
OnViewEntitiesasSkinned()6038 void CMainFrame::OnViewEntitiesasSkinned() {
6039 g_PrefsDlg.m_nEntityShowState = ENTITY_SKINNED;
6040 SetEntityCheck();
6041 g_PrefsDlg.SavePrefs();
6042 Sys_UpdateWindows(W_ALL);
6043 }
6044
6045 /*
6046 =======================================================================================================================
6047 =======================================================================================================================
6048 */
OnViewEntitiesasWireframe()6049 void CMainFrame::OnViewEntitiesasWireframe() {
6050 g_PrefsDlg.m_nEntityShowState = ENTITY_WIRE;
6051 SetEntityCheck();
6052 g_PrefsDlg.SavePrefs();
6053 Sys_UpdateWindows(W_ALL);
6054 }
6055
6056 /*
6057 =======================================================================================================================
6058 =======================================================================================================================
6059 */
OnViewShowhint()6060 void CMainFrame::OnViewShowhint() {
6061 if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_HINT) & EXCLUDE_HINT) {
6062 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWHINT, MF_BYCOMMAND | MF_UNCHECKED);
6063 }
6064 else {
6065 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWHINT, MF_BYCOMMAND | MF_CHECKED);
6066 }
6067
6068 Sys_UpdateWindows(W_XY | W_CAMERA);
6069 }
6070
6071 /*
6072 =======================================================================================================================
6073 =======================================================================================================================
6074 */
OnTexturesShowall()6075 void CMainFrame::OnTexturesShowall() {
6076 Texture_ShowAll();
6077 }
6078
OnTexturesHideall()6079 void CMainFrame::OnTexturesHideall() {
6080 Texture_HideAll();
6081 }
6082
6083 /*
6084 =======================================================================================================================
6085 =======================================================================================================================
6086 */
OnPatchInspector()6087 void CMainFrame::OnPatchInspector() {
6088 DoPatchInspector();
6089 }
6090
6091 /*
6092 =======================================================================================================================
6093 =======================================================================================================================
6094 */
OnViewOpengllighting()6095 void CMainFrame::OnViewOpengllighting() {
6096 g_PrefsDlg.m_bGLLighting ^= 1;
6097 g_PrefsDlg.SavePrefs();
6098 CheckMenuItem
6099 (
6100 ::GetMenu(GetSafeHwnd()),
6101 ID_VIEW_OPENGLLIGHTING,
6102 MF_BYCOMMAND | (g_PrefsDlg.m_bGLLighting) ? MF_CHECKED : MF_UNCHECKED
6103 );
6104 Sys_UpdateWindows(W_XY | W_CAMERA);
6105 }
6106
6107 /*
6108 =======================================================================================================================
6109 =======================================================================================================================
6110 */
OnSelectAll()6111 void CMainFrame::OnSelectAll() {
6112 Select_AllOfType();
6113 }
6114
6115 /*
6116 =======================================================================================================================
6117 =======================================================================================================================
6118 */
OnViewShowcaulk()6119 void CMainFrame::OnViewShowcaulk() {
6120 if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_CAULK) & EXCLUDE_CAULK) {
6121 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWCAULK, MF_BYCOMMAND | MF_UNCHECKED);
6122 }
6123 else {
6124 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWCAULK, MF_BYCOMMAND | MF_CHECKED);
6125 }
6126
6127 Sys_UpdateWindows(W_XY | W_CAMERA);
6128 }
6129
6130 /*
6131 =======================================================================================================================
6132 =======================================================================================================================
6133 */
OnCurveFreeze()6134 void CMainFrame::OnCurveFreeze() {
6135 Patch_Freeze();
6136 }
6137
6138 /*
6139 =======================================================================================================================
6140 =======================================================================================================================
6141 */
OnCurveUnFreeze()6142 void CMainFrame::OnCurveUnFreeze() {
6143 Patch_UnFreeze(false);
6144 }
6145
6146 /*
6147 =======================================================================================================================
6148 =======================================================================================================================
6149 */
OnCurveUnFreezeAll()6150 void CMainFrame::OnCurveUnFreezeAll() {
6151 Patch_UnFreeze(true);
6152 }
6153
6154 /*
6155 =======================================================================================================================
6156 =======================================================================================================================
6157 */
OnSelectReselect()6158 void CMainFrame::OnSelectReselect() {
6159 Select_Reselect();
6160 }
6161
6162 /*
6163 =======================================================================================================================
6164 =======================================================================================================================
6165 */
OnViewShowangles()6166 void CMainFrame::OnViewShowangles() {
6167 if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_ANGLES) & EXCLUDE_ANGLES) {
6168 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWANGLES, MF_BYCOMMAND | MF_UNCHECKED);
6169 }
6170 else {
6171 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOWANGLES, MF_BYCOMMAND | MF_CHECKED);
6172 }
6173
6174 Sys_UpdateWindows(W_XY | W_CAMERA);
6175 }
6176
6177 /*
6178 =======================================================================================================================
6179 =======================================================================================================================
6180 */
OnEditSaveprefab()6181 void CMainFrame::OnEditSaveprefab() {
6182 CFileDialog dlgFile
6183 (
6184 FALSE,
6185 "pfb",
6186 NULL,
6187 OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
6188 "Prefab files (*.pfb)|*.pfb||",
6189 this
6190 );
6191 char CurPath[1024];
6192 ::GetCurrentDirectory(1024, CurPath);
6193
6194 dlgFile.m_ofn.lpstrInitialDir = CurPath;
6195 if (dlgFile.DoModal() == IDOK) {
6196 Map_SaveSelected(dlgFile.GetPathName().GetBuffer(0));
6197 }
6198 }
6199
6200 /*
6201 =======================================================================================================================
6202 =======================================================================================================================
6203 */
OnEditLoadprefab()6204 void CMainFrame::OnEditLoadprefab() {
6205 CFileDialog dlgFile
6206 (
6207 TRUE,
6208 "pfb",
6209 NULL,
6210 OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
6211 "Prefab files (*.pfb)|*.pfb||",
6212 this
6213 );
6214 char CurPath[1024];
6215 ::GetCurrentDirectory(1024, CurPath);
6216 dlgFile.m_ofn.lpstrInitialDir = CurPath;
6217 if (dlgFile.DoModal() == IDOK) {
6218 Map_ImportFile(dlgFile.GetPathName().GetBuffer(0));
6219 }
6220 }
6221
6222 /*
6223 =======================================================================================================================
6224 =======================================================================================================================
6225 */
OnCurveMoreendcapsbevelsSquarebevel()6226 void CMainFrame::OnCurveMoreendcapsbevelsSquarebevel() {
6227 Undo_Start("square bevel");
6228 Undo_AddBrushList(&selected_brushes);
6229
6230 Patch_BrushToMesh(false, true, false, true);
6231 Sys_UpdateWindows(W_ALL);
6232
6233 Undo_EndBrushList(&selected_brushes);
6234 Undo_End();
6235 }
6236
6237 /*
6238 =======================================================================================================================
6239 =======================================================================================================================
6240 */
OnCurveMoreendcapsbevelsSquareendcap()6241 void CMainFrame::OnCurveMoreendcapsbevelsSquareendcap() {
6242 Undo_Start("square endcap");
6243 Undo_AddBrushList(&selected_brushes);
6244
6245 Patch_BrushToMesh(false, false, true, true);
6246 Sys_UpdateWindows(W_ALL);
6247
6248 Undo_EndBrushList(&selected_brushes);
6249 Undo_End();
6250 }
6251
6252 /*
6253 =======================================================================================================================
6254 =======================================================================================================================
6255 */
OnBrushPrimitivesSphere()6256 void CMainFrame::OnBrushPrimitivesSphere() {
6257 Undo_Start("make sphere");
6258 Undo_AddBrushList(&selected_brushes);
6259
6260 DoSides(false, true);
6261
6262 Undo_EndBrushList(&selected_brushes);
6263 Undo_End();
6264 }
6265
6266 extern bool g_bCrossHairs;
6267
6268 /*
6269 =======================================================================================================================
6270 =======================================================================================================================
6271 */
OnViewCrosshair()6272 void CMainFrame::OnViewCrosshair() {
6273 g_bCrossHairs ^= 1;
6274 Sys_UpdateWindows(W_XY);
6275 }
6276
6277 /*
6278 =======================================================================================================================
6279 =======================================================================================================================
6280 */
OnViewHideshowHideselected()6281 void CMainFrame::OnViewHideshowHideselected() {
6282 Select_Hide();
6283 Select_Deselect();
6284 }
6285
OnViewHideshowHideNotselected()6286 void CMainFrame::OnViewHideshowHideNotselected() {
6287 Select_Hide(true);
6288 Select_Deselect();
6289 }
6290
6291 /*
6292 =======================================================================================================================
6293 =======================================================================================================================
6294 */
OnViewHideshowShowhidden()6295 void CMainFrame::OnViewHideshowShowhidden() {
6296 Select_ShowAllHidden();
6297 }
6298
6299 /*
6300 =======================================================================================================================
6301 =======================================================================================================================
6302 */
OnTexturesShadersShow()6303 void CMainFrame::OnTexturesShadersShow() {
6304 //
6305 // g_PrefsDlg.m_bShowShaders ^= 1; CheckMenuItem (
6306 // ::GetMenu(GetSafeHwnd()), ID_TEXTURES_SHADERS_SHOW, MF_BYCOMMAND |
6307 // ((g_PrefsDlg.m_bShowShaders) ? MF_CHECKED : MF_UNCHECKED ));
6308 // Sys_UpdateWindows(W_TEXTURE);
6309 //
6310 }
6311
6312 /*
6313 =======================================================================================================================
6314 =======================================================================================================================
6315 */
OnTexturesFlushUnused()6316 void CMainFrame::OnTexturesFlushUnused() {
6317 //FIXME: idMaterial
6318 //Texture_FlushUnused();
6319 Sys_UpdateWindows(W_TEXTURE);
6320 }
6321
6322 /*
6323 =======================================================================================================================
6324 =======================================================================================================================
6325 */
OnSelectionInvert()6326 void CMainFrame::OnSelectionInvert() {
6327 Select_Invert();
6328 Sys_UpdateWindows(W_XY | W_Z | W_CAMERA);
6329 }
6330
6331 /*
6332 =======================================================================================================================
6333 =======================================================================================================================
6334 */
OnProjectedLight()6335 void CMainFrame::OnProjectedLight() {
6336 LightEditorInit( NULL );
6337 }
6338
6339 /*
6340 =======================================================================================================================
6341 =======================================================================================================================
6342 */
OnShowLighttextures()6343 void CMainFrame::OnShowLighttextures() {
6344 g_bShowLightTextures ^= 1;
6345 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SHOW_LIGHTTEXTURES, (g_bShowLightTextures) ? TRUE : FALSE);
6346 Sys_UpdateWindows(W_ALL);
6347 }
6348
6349 /*
6350 =======================================================================================================================
6351 =======================================================================================================================
6352 */
OnShowLightvolumes()6353 void CMainFrame::OnShowLightvolumes() {
6354 g_bShowLightVolumes ^= 1;
6355 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SHOW_LIGHTVOLUMES, (g_bShowLightVolumes) ? TRUE : FALSE);
6356 Sys_UpdateWindows(W_ALL);
6357 }
6358
6359 /*
6360 =======================================================================================================================
6361 =======================================================================================================================
6362 */
OnActivate(UINT nState,CWnd * pWndOther,BOOL bMinimized)6363 void CMainFrame::OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized) {
6364 CFrameWnd::OnActivate(nState, pWndOther, bMinimized);
6365
6366 if ( nState != WA_INACTIVE ) {
6367 common->ActivateTool( true );
6368 if (::IsWindowVisible(win32.hWnd)) {
6369 ::ShowWindow(win32.hWnd, SW_HIDE);
6370 }
6371
6372 // start playing the editor sound world
6373 soundSystem->SetPlayingSoundWorld( g_qeglobals.sw );
6374 }
6375 else {
6376 //com_editorActive = false;
6377 }
6378 }
6379
6380 /*
6381 =======================================================================================================================
6382 =======================================================================================================================
6383 */
OnSplinesMode()6384 void CMainFrame::OnSplinesMode() {
6385 g_qeglobals.d_select_mode = sel_addpoint;
6386 g_splineList->clear();
6387 g_splineList->startEdit(true);
6388 showCameraInspector();
6389 Sys_UpdateWindows(W_ALL);
6390 }
6391
6392 /*
6393 =======================================================================================================================
6394 =======================================================================================================================
6395 */
OnSplinesLoad()6396 void CMainFrame::OnSplinesLoad() {
6397 g_splineList->load("maps/test.camera");
6398 g_splineList->buildCamera();
6399 }
6400
6401 /*
6402 =======================================================================================================================
6403 =======================================================================================================================
6404 */
OnSplinesSave()6405 void CMainFrame::OnSplinesSave() {
6406 g_splineList->save("maps/test.camera");
6407 }
6408
6409 /*
6410 =======================================================================================================================
6411 =======================================================================================================================
6412 */
OnSplinesEdit()6413 void CMainFrame::OnSplinesEdit() {
6414 showCameraInspector();
6415 Sys_UpdateWindows(W_ALL);
6416 }
6417
6418 extern void testCamSpeed();
6419
6420 /*
6421 =======================================================================================================================
6422 =======================================================================================================================
6423 */
OnSplineTest()6424 void CMainFrame::OnSplineTest() {
6425 long start = GetTickCount();
6426 g_splineList->startCamera(start);
6427
6428 float cycle = g_splineList->getTotalTime();
6429 long msecs = cycle * 1000;
6430 long current = start;
6431 idVec3 lookat(0, 0, 0);
6432 idVec3 dir;
6433
6434 while (current < start + msecs) {
6435 float fov;
6436 g_splineList->getCameraInfo(current, g_pParentWnd->GetCamera()->Camera().origin, dir, &fov);
6437 g_pParentWnd->GetCamera()->Camera().angles[1] = atan2(dir[1], dir[0]) * 180 / 3.14159;
6438 g_pParentWnd->GetCamera()->Camera().angles[0] = asin(dir[2]) * 180 / 3.14159;
6439 g_pParentWnd->UpdateWindows(W_XY | W_CAMERA);
6440 current = GetTickCount();
6441 }
6442
6443 g_splineList->setRunning(false);
6444 }
6445
6446 /*
6447 =======================================================================================================================
6448 =======================================================================================================================
6449 */
OnSplinesTargetPoints()6450 void CMainFrame::OnSplinesTargetPoints() {
6451 }
6452
6453 /*
6454 =======================================================================================================================
6455 =======================================================================================================================
6456 */
OnSplinesCameraPoints()6457 void CMainFrame::OnSplinesCameraPoints() {
6458 }
6459
6460 /*
6461 =======================================================================================================================
6462 =======================================================================================================================
6463 */
OnPopupNewcameraInterpolated()6464 void CMainFrame::OnPopupNewcameraInterpolated() {
6465 g_qeglobals.d_select_mode = sel_addpoint;
6466 g_qeglobals.selectObject = g_splineList->startNewCamera(idCameraPosition::INTERPOLATED);
6467 OnSplinesEdit();
6468 }
6469
6470 /*
6471 =======================================================================================================================
6472 =======================================================================================================================
6473 */
OnPopupNewcameraSpline()6474 void CMainFrame::OnPopupNewcameraSpline() {
6475 g_qeglobals.d_select_mode = sel_addpoint;
6476 g_qeglobals.selectObject = g_splineList->startNewCamera(idCameraPosition::SPLINE);
6477 OnSplinesEdit();
6478 }
6479
6480 /*
6481 =======================================================================================================================
6482 =======================================================================================================================
6483 */
OnPopupNewcameraFixed()6484 void CMainFrame::OnPopupNewcameraFixed() {
6485 g_qeglobals.d_select_mode = sel_addpoint;
6486 g_qeglobals.selectObject = g_splineList->startNewCamera(idCameraPosition::FIXED);
6487 OnSplinesEdit();
6488 }
6489
6490 extern void Patch_AdjustSubdivisions(float hadj, float vadj);
6491
6492 /*
6493 =======================================================================================================================
6494 =======================================================================================================================
6495 */
OnCurveIncreaseVert()6496 void CMainFrame::OnCurveIncreaseVert() {
6497 Patch_AdjustSubdivisions( 0.0f, -0.5f );
6498 }
6499
6500 /*
6501 =======================================================================================================================
6502 =======================================================================================================================
6503 */
OnCurveDecreaseVert()6504 void CMainFrame::OnCurveDecreaseVert() {
6505 Patch_AdjustSubdivisions( 0.0f, 0.5f );
6506 }
6507
6508 /*
6509 =======================================================================================================================
6510 =======================================================================================================================
6511 */
OnCurveIncreaseHorz()6512 void CMainFrame::OnCurveIncreaseHorz() {
6513 Patch_AdjustSubdivisions( -0.5f, 0.0f );
6514 }
6515
6516 /*
6517 =======================================================================================================================
6518 =======================================================================================================================
6519 */
OnCurveDecreaseHorz()6520 void CMainFrame::OnCurveDecreaseHorz() {
6521 Patch_AdjustSubdivisions( 0.5f, 0.0f );
6522 }
6523
6524 /*
6525 =======================================================================================================================
6526 =======================================================================================================================
6527 */
OnSelectionMoveonly()6528 void CMainFrame::OnSelectionMoveonly() {
6529 g_moveOnly ^= 1;
6530 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECTION_MOVEONLY, (g_moveOnly) ? TRUE : FALSE);
6531 }
6532
OnSelectBrushlight()6533 void CMainFrame::OnSelectBrushlight()
6534 {
6535 // TODO: Add your command handler code here
6536
6537 }
6538
OnSelectionCombine()6539 void CMainFrame::OnSelectionCombine()
6540 {
6541 if (g_qeglobals.d_select_count < 2) {
6542 Sys_Status("Must have at least two things selected.", 0);
6543 Sys_Beep();
6544 return;
6545 }
6546
6547 entity_t *e1 = g_qeglobals.d_select_order[0]->owner;
6548
6549 if (e1 == world_entity) {
6550 Sys_Status("First selection must not be world.", 0);
6551 Sys_Beep();
6552 return;
6553 }
6554
6555 idStr str;
6556 idMat3 mat;
6557 idVec3 v;
6558 if (e1->eclass->nShowFlags & ECLASS_LIGHT) {
6559 // copy the lights origin and rotation matrix to
6560 // light_origin and light_rotation
6561 e1->trackLightOrigin = true;
6562 e1->brushes.onext->trackLightOrigin = true;
6563 if (GetVectorForKey(e1, "origin", v)) {
6564 SetKeyVec3(e1, "light_origin", v);
6565 e1->lightOrigin = v;
6566 }
6567 if (!GetMatrixForKey(e1, "rotation", mat)) {
6568 mat.Identity();
6569 }
6570 sprintf(str, "%g %g %g %g %g %g %g %g %g", mat[0][0], mat[0][1], mat[0][2], mat[1][0], mat[1][1], mat[1][2], mat[2][0], mat[2][1], mat[2][2]);
6571 SetKeyValue(e1, "light_rotation", str, false);
6572 e1->lightRotation = mat;
6573 }
6574
6575 bool setModel = true;
6576 for (brush_t *b = selected_brushes.next; b != &selected_brushes; b = b->next) {
6577 if (b->owner != e1) {
6578 if (e1->eclass->nShowFlags & ECLASS_LIGHT) {
6579 if (GetVectorForKey(b->owner, "origin", v)) {
6580 e1->origin = b->owner->origin;
6581 SetKeyVec3(e1, "origin", b->owner->origin);
6582 }
6583 if (GetMatrixForKey(b->owner, "rotation", mat)) {
6584 e1->rotation = b->owner->rotation;
6585 mat = b->owner->rotation;
6586 sprintf(str, "%g %g %g %g %g %g %g %g %g", mat[0][0], mat[0][1], mat[0][2], mat[1][0], mat[1][1], mat[1][2], mat[2][0], mat[2][1], mat[2][2]);
6587 SetKeyValue(e1, "rotation", str, false);
6588 }
6589 if (b->modelHandle) {
6590 SetKeyValue(e1, "model", ValueForKey(b->owner, "model"));
6591 setModel = false;
6592 } else {
6593 b->entityModel = true;
6594 }
6595 }
6596 Entity_UnlinkBrush(b);
6597 Entity_LinkBrush(e1, b);
6598 }
6599 }
6600
6601 if (setModel) {
6602 SetKeyValue(e1, "model", ValueForKey(e1, "name"));
6603 }
6604
6605 Select_Deselect();
6606 Select_Brush(g_qeglobals.d_select_order[0]);
6607 Sys_UpdateWindows(W_XY | W_CAMERA);
6608 }
6609
6610 extern void Patch_Weld(patchMesh_t *p, patchMesh_t *p2);
OnPatchCombine()6611 void CMainFrame::OnPatchCombine() {
6612 patchMesh_t *p, *p2;
6613 p = p2 = NULL;
6614 for (brush_t *b = selected_brushes.next; b != &selected_brushes; b = b->next) {
6615 if (b->pPatch) {
6616 if (p == NULL) {
6617 p = b->pPatch;
6618 } else if (p2 == NULL) {
6619 p2 = b->pPatch;
6620 Patch_Weld(p, p2);
6621 return;
6622 }
6623 }
6624 }
6625 }
6626
OnShowDoom()6627 void CMainFrame::OnShowDoom()
6628 {
6629 int show = ::IsWindowVisible(win32.hWnd) ? SW_HIDE : SW_NORMAL;
6630 if (show == SW_NORMAL) {
6631 g_Inspectors->SetMode(W_TEXTURE);
6632 }
6633 ::ShowWindow(win32.hWnd, show);
6634 }
6635
OnViewRendermode()6636 void CMainFrame::OnViewRendermode()
6637 {
6638 m_pCamWnd->ToggleRenderMode();
6639 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_RENDERMODE, MF_BYCOMMAND | (m_pCamWnd->GetRenderMode()) ? MF_CHECKED : MF_UNCHECKED);
6640 Sys_UpdateWindows(W_ALL);
6641 }
6642
OnViewRebuildrenderdata()6643 void CMainFrame::OnViewRebuildrenderdata()
6644 {
6645 m_pCamWnd->BuildRendererState();
6646 if (!m_pCamWnd->GetRenderMode()) {
6647 OnViewRendermode();
6648 }
6649 Sys_UpdateWindows(W_ALL);
6650 }
6651
OnViewRealtimerebuild()6652 void CMainFrame::OnViewRealtimerebuild()
6653 {
6654 m_pCamWnd->ToggleRebuildMode();
6655 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_REALTIMEREBUILD, MF_BYCOMMAND | (m_pCamWnd->GetRebuildMode()) ? MF_CHECKED : MF_UNCHECKED);
6656 Sys_UpdateWindows(W_ALL);
6657 }
6658
OnViewRenderentityoutlines()6659 void CMainFrame::OnViewRenderentityoutlines()
6660 {
6661 m_pCamWnd->ToggleEntityMode();
6662 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_RENDERENTITYOUTLINES, MF_BYCOMMAND | (m_pCamWnd->GetEntityMode()) ? MF_CHECKED : MF_UNCHECKED);
6663 Sys_UpdateWindows(W_ALL);
6664 }
6665
OnViewMaterialanimation()6666 void CMainFrame::OnViewMaterialanimation()
6667 {
6668 m_pCamWnd->ToggleAnimationMode();
6669 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_MATERIALANIMATION, MF_BYCOMMAND | (m_pCamWnd->GetAnimationMode()) ? MF_CHECKED : MF_UNCHECKED);
6670 Sys_UpdateWindows(W_ALL);
6671 }
6672
6673 extern void Face_SetAxialScale_BrushPrimit(face_t *face, bool y);
OnAxialTextureByWidth()6674 void CMainFrame::OnAxialTextureByWidth() {
6675 // temp test code
6676 int faceCount = g_ptrSelectedFaces.GetSize();
6677
6678 if (faceCount > 0) {
6679 for (int i = 0; i < faceCount; i++) {
6680 face_t *selFace = reinterpret_cast < face_t * > (g_ptrSelectedFaces.GetAt(i));
6681 Face_SetAxialScale_BrushPrimit(selFace, false);
6682 }
6683 Sys_UpdateWindows(W_CAMERA);
6684 }
6685
6686 }
6687
OnAxialTextureByHeight()6688 void CMainFrame::OnAxialTextureByHeight() {
6689 // temp test code
6690 int faceCount = g_ptrSelectedFaces.GetSize();
6691
6692 if (faceCount > 0) {
6693 for (int i = 0; i < faceCount; i++) {
6694 face_t *selFace = reinterpret_cast < face_t * > (g_ptrSelectedFaces.GetAt(i));
6695 Face_SetAxialScale_BrushPrimit(selFace, true);
6696 }
6697 Sys_UpdateWindows(W_CAMERA);
6698 }
6699 }
6700
OnAxialTextureArbitrary()6701 void CMainFrame::OnAxialTextureArbitrary() {
6702 if (g_bAxialMode) {
6703 g_bAxialMode = false;
6704 }
6705 int faceCount = g_ptrSelectedFaces.GetSize();
6706 if (faceCount > 0) {
6707 g_axialAnchor = 0;
6708 g_axialDest = 1;
6709 g_bAxialMode = true;
6710 }
6711 Sys_UpdateWindows(W_CAMERA);
6712 }
6713
6714 extern void Select_ToOBJ();
OnSelectionExportToobj()6715 void CMainFrame::OnSelectionExportToobj()
6716 {
6717 Select_ToOBJ();
6718 }
6719
6720 extern void Select_ToCM();
OnSelectionExportToCM()6721 void CMainFrame::OnSelectionExportToCM()
6722 {
6723 Select_ToCM();
6724 }
6725
OnSelectionWireFrameOff()6726 void CMainFrame::OnSelectionWireFrameOff() {
6727 Select_WireFrame( false );
6728 }
6729
OnSelectionWireFrameOn()6730 void CMainFrame::OnSelectionWireFrameOn() {
6731 Select_WireFrame( true );
6732 }
6733
OnSelectionVisibleOn()6734 void CMainFrame::OnSelectionVisibleOn() {
6735 Select_ForceVisible( true );
6736 }
6737
OnSelectionVisibleOff()6738 void CMainFrame::OnSelectionVisibleOff() {
6739 Select_ForceVisible( false );
6740 }
6741
6742
OnViewRenderselection()6743 void CMainFrame::OnViewRenderselection()
6744 {
6745 m_pCamWnd->ToggleSelectMode();
6746 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_RENDERSELECTION, MF_BYCOMMAND | (m_pCamWnd->GetSelectMode()) ? MF_CHECKED : MF_UNCHECKED);
6747 Sys_UpdateWindows(W_CAMERA);
6748 }
6749
OnSelectNomodels()6750 void CMainFrame::OnSelectNomodels()
6751 {
6752 g_PrefsDlg.m_selectNoModels ^= 1;
6753 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_NOMODELS, (g_PrefsDlg.m_selectNoModels) ? TRUE : FALSE);
6754 }
6755
OnViewShowShowvisportals()6756 void CMainFrame::OnViewShowShowvisportals()
6757 {
6758 if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_VISPORTALS) & EXCLUDE_VISPORTALS) {
6759 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOW_SHOWVISPORTALS, MF_BYCOMMAND | MF_UNCHECKED);
6760 }
6761 else {
6762 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOW_SHOWVISPORTALS, MF_BYCOMMAND | MF_CHECKED);
6763 }
6764
6765 Sys_UpdateWindows(W_XY | W_CAMERA);
6766 }
6767
OnViewShowNoDraw()6768 void CMainFrame::OnViewShowNoDraw()
6769 {
6770 if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_NODRAW) & EXCLUDE_NODRAW) {
6771 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOW_NODRAW, MF_BYCOMMAND | MF_UNCHECKED);
6772 }
6773 else {
6774 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_SHOW_NODRAW, MF_BYCOMMAND | MF_CHECKED);
6775 }
6776
6777 Sys_UpdateWindows(W_XY | W_CAMERA);
6778 }
6779
6780
6781
OnViewRendersound()6782 void CMainFrame::OnViewRendersound()
6783 {
6784 m_pCamWnd->ToggleSoundMode();
6785 CheckMenuItem(::GetMenu(GetSafeHwnd()), ID_VIEW_RENDERSOUND, MF_BYCOMMAND | (m_pCamWnd->GetSoundMode()) ? MF_CHECKED : MF_UNCHECKED);
6786 Sys_UpdateWindows(W_CAMERA);
6787 }
6788
6789
OnSoundShowsoundvolumes()6790 void CMainFrame::OnSoundShowsoundvolumes()
6791 {
6792 g_qeglobals.d_savedinfo.showSoundAlways ^= 1;
6793 if (g_qeglobals.d_savedinfo.showSoundAlways) {
6794 g_qeglobals.d_savedinfo.showSoundWhenSelected = false;
6795 }
6796 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SOUND_SHOWSOUNDVOLUMES,g_qeglobals.d_savedinfo.showSoundAlways);
6797 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SOUND_SHOWSELECTEDSOUNDVOLUMES,g_qeglobals.d_savedinfo.showSoundWhenSelected);
6798 Sys_UpdateWindows(W_XY | W_CAMERA);
6799 }
6800
OnNurbEditor()6801 void CMainFrame::OnNurbEditor() {
6802 nurbMode ^= 1;
6803 if (nurbMode) {
6804 int num = nurb.GetNumValues();
6805 idStr temp = va("%i 3 ", num);
6806 for (int i = 0; i < num; i++) {
6807 temp += va("(%i %i) ", (int)nurb.GetValue(i).x, (int)nurb.GetValue(i).y);
6808 }
6809 temp += "\r\n";
6810 if (OpenClipboard()) {
6811 ::EmptyClipboard();
6812 HGLOBAL clip;
6813 char* buff;
6814 clip = ::GlobalAlloc(GMEM_DDESHARE, temp.Length()+1);
6815 buff = (char*)::GlobalLock(clip);
6816 strcpy(buff, temp);
6817 ::GlobalUnlock(clip);
6818 ::SetClipboardData(CF_TEXT, clip);
6819 ::CloseClipboard();
6820 }
6821 nurb.Clear();
6822 }
6823 }
6824
6825
OnSoundShowselectedsoundvolumes()6826 void CMainFrame::OnSoundShowselectedsoundvolumes()
6827 {
6828 g_qeglobals.d_savedinfo.showSoundWhenSelected ^= 1;
6829 if (g_qeglobals.d_savedinfo.showSoundWhenSelected) {
6830 g_qeglobals.d_savedinfo.showSoundAlways = false;
6831 }
6832 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SOUND_SHOWSOUNDVOLUMES,g_qeglobals.d_savedinfo.showSoundAlways);
6833 m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SOUND_SHOWSELECTEDSOUNDVOLUMES,g_qeglobals.d_savedinfo.showSoundWhenSelected);
6834 Sys_UpdateWindows(W_XY | W_CAMERA);
6835 }
6836
OnSelectAlltargets()6837 void CMainFrame::OnSelectAlltargets()
6838 {
6839 Select_AllTargets();
6840 }
6841
6842
OnSelectCompleteEntity()6843 void CMainFrame::OnSelectCompleteEntity()
6844 {
6845 brush_t* b = NULL;
6846 entity_t* e = NULL;
6847
6848 b = selected_brushes.next;
6849 if ( b == &selected_brushes )
6850 {
6851 return; //no brushes selected
6852 }
6853
6854 e = b->owner;
6855 if ( b->owner == world_entity )
6856 {
6857 return; //don't select the world entity
6858 }
6859
6860 for (b = e->brushes.onext; b != &e->brushes; b = b->onext)
6861 {
6862 Select_Brush ( b , false );
6863 }
6864 Sys_UpdateWindows ( W_ALL );
6865 }
6866
6867
6868
6869
6870 //---------------------------------------------------------------------------
6871 // OnPrecisionCursorCycle
6872 //
6873 // Called when the user presses the "cycle precision cursor mode" key.
6874 // Cycles the precision cursor among the following three modes:
6875 // PRECISION_CURSOR_NONE
6876 // PRECISION_CURSOR_SNAP
6877 // PRECISION_CURSOR_FREE
6878 //---------------------------------------------------------------------------
OnPrecisionCursorCycle()6879 void CMainFrame::OnPrecisionCursorCycle()
6880 {
6881 m_pActiveXY->CyclePrecisionCrosshairMode();
6882 }
6883
OnGenerateMaterialsList()6884 void CMainFrame::OnGenerateMaterialsList()
6885 {
6886 idStrList mtrList;
6887 idStr mtrName,mtrFileName;
6888
6889
6890 g_Inspectors->consoleWnd.ExecuteCommand ( "clear" );
6891 Sys_BeginWait ();
6892 common->Printf ( "Generating list of active materials...\n" );
6893
6894 for ( brush_t* b = active_brushes.next ; b != &active_brushes ; b=b->next ) {
6895 if ( b->pPatch ){
6896 mtrName = b->pPatch->d_texture->GetName();
6897 if ( !mtrList.Find( mtrName) ) {
6898 mtrList.Insert ( mtrName );
6899 }
6900
6901 }
6902 else {
6903 for ( face_t* f = b->brush_faces ; f != NULL ; f=f->next)
6904 {
6905 mtrName = f->d_texture->GetName();
6906 if ( !mtrList.Find( mtrName) ) {
6907 mtrList.Insert ( mtrName );
6908 }
6909
6910 }
6911 }
6912 }
6913
6914 mtrList.Sort();
6915 for ( int i = 0 ; i < mtrList.Num() ; i++ ) {
6916 common->Printf ( "%s\n" , mtrList[i].c_str());
6917 }
6918
6919 mtrFileName = currentmap;
6920 // mtrFileName.ExtractFileName( mtrFileName );
6921 mtrFileName = mtrFileName.StripPath();
6922
6923 common->Printf ( "Done...found %i unique materials\n" , mtrList.Num());
6924 mtrFileName = mtrFileName + idStr ( "_Materials.txt" );
6925 g_Inspectors->SetMode ( W_CONSOLE , true );
6926 g_Inspectors->consoleWnd.SetConsoleText ( va ( "condump %s" , mtrFileName.c_str()) );
6927
6928 Sys_EndWait ();
6929 }
6930
6931 /*
6932 =======================================================================================================================
6933 =======================================================================================================================
6934 */
6935
6936
OnSplinesAddPoints()6937 void CMainFrame::OnSplinesAddPoints() {
6938 g_Inspectors->entityDlg.AddCurvePoints();
6939 }
6940
OnSplinesEditPoints()6941 void CMainFrame::OnSplinesEditPoints() {
6942 g_Inspectors->entityDlg.EditCurvePoints();
6943 }
6944
OnSplinesDeletePoint()6945 void CMainFrame::OnSplinesDeletePoint() {
6946 g_Inspectors->entityDlg.DeleteCurvePoint();
6947 }
6948
OnSplinesInsertPoint()6949 void CMainFrame::OnSplinesInsertPoint() {
6950 g_Inspectors->entityDlg.InsertCurvePoint();
6951 }
6952