2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
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.
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.
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/>.
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.
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.
26 ===========================================================================
32 #ifdef ID_DEBUG_MEMORY
38 // this define to use HTREEITEM and MFC stuff in the headers
39 #define QERTYPES_USE_MFC
46 #include "../../sys/win32/rc/Radiant_resource.h" // main symbols
47 #include "../../sys/win32/win_local.h"
51 // stuff from old qfiles.h
52 #define MAX_MAP_ENTITIES 2048
53 const int MAX_MOVE_POINTS = 4096;
54 const int MAX_MOVE_PLANES = 2048;
56 // assume that all maps fit within this
57 const float HUGE_DISTANCE = 100000;
60 #include "EditorBrush.h"
61 #include "EditorEntity.h"
62 #include "EditorMap.h"
71 #include "FindTextureDlg.h"
72 #include "dialogtextures.h"
73 #include "InspectorDialog.h"
77 // the dec offsetof macro doesn't work very well...
78 #define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier)
81 void Error (char *error, ...);
82 void Warning (char *error, ...);
93 int iTexMenu; // nearest, linear, etc
94 float fGamma; // gamma for textures
95 char szProject[256]; // last project loaded
96 idVec3 colors[COLOR_LAST];
98 bool show_coordinates;
100 float m_nTextureTweak;
103 bool showSoundAlways;
104 bool showSoundWhenSelected;
110 // TTimo NOTE: WINAPI funcs can be accessed by plugins
111 void Sys_UpdateStatusBar( void );
112 void WINAPI Sys_UpdateWindows (int bits);
113 void Sys_Beep (void);
114 double Sys_DoubleTime (void);
115 void Sys_GetCursorPos (int *x, int *y);
116 void Sys_SetCursorPos (int x, int y);
117 void Sys_SetTitle (const char *text);
118 void Sys_BeginWait (void);
120 void Sys_EndWait (void);
121 void Sys_Status(const char *psz, int part = -1);
124 ** most of the QE globals are stored in this structure
131 int rotateAxis; // 0, 1 or 2
132 int flatRotation; // 0, 1 or 2, 0 == off, 1 == rotate about the rotation origin, 1 == rotate about the selection mid point
136 entity_t *d_project_entity;
138 idVec3 d_new_brush_bottom, d_new_brush_top;
140 HINSTANCE d_hInstance;
142 idVec3 d_points[MAX_POINTS];
144 pedge_t d_edges[MAX_EDGES];
147 int d_num_move_points;
148 idVec3 *d_move_points[MAX_MOVE_POINTS];
150 int d_num_move_planes;
151 idPlane *d_move_planes[MAX_MOVE_PLANES];
153 qtexture_t *d_qtextures;
155 texturewin_t d_texturewin;
157 int d_pointfile_display_list;
159 LPMRUMENU d_lpMruMenu;
161 SavedInfo_t d_savedinfo;
165 // connect entities uses the last two brushes selected
167 brush_t *d_select_order[MAX_MAP_ENTITIES];
168 idVec3 d_select_translate; // for dragging w/o making new display lists
169 select_t d_select_mode;
170 idPointListInterface *selectObject; //
174 int d_parsed_brushes;
179 // tells if we are internally using brush primitive (texture coordinates and map format)
180 // this is a shortcut for IntForKey( g_qeglobals.d_project_entity, "brush_primit" )
181 // NOTE: must keep the two ones in sync
182 BOOL m_bBrushPrimitMode;
184 // used while importing brush data from file or memory buffer
185 // tells if conversion between map format and internal preferences ( m_bBrushPrimitMode ) is needed
194 // tells if we are using .INI files for prefs instead of registry
196 // even in .INI mode we use the registry for all void* prefs
197 char use_ini_registry[64];
200 // tells we have surface properties plugin
201 bool bSurfacePropertiesPlugin;
202 // tells we are using a BSP frontend plugin
203 bool bBSPFrontendPlugin;
205 // the editor has its own soundWorld and renderWorld, completely distinct from the game
211 void Pointfile_Delete (void);
212 void WINAPI Pointfile_Check (void);
213 void Pointfile_Next (void);
214 void Pointfile_Prev (void);
215 void Pointfile_Clear (void);
216 void Pointfile_Draw( void );
217 void Pointfile_Load( void );
222 void Drag_Begin (int x, int y, int buttons,
223 const idVec3 &xaxis, const idVec3 &yaxis,
224 const idVec3 &origin, const idVec3 &dir);
225 void Drag_MouseMoved (int x, int y, int buttons);
226 void Drag_MouseUp (int nButtons = 0);
227 extern bool g_moveOnly;
231 void CSG_MakeHollow (void);
232 void CSG_Subtract (void);
233 void CSG_Merge (void);
239 void SetupVertexSelection (void);
240 void SelectEdgeByRay (idVec3 org, idVec3 dir);
241 void SelectVertexByRay (idVec3 org, idVec3 dir);
243 void ConnectEntities (void);
245 extern int update_bits;
247 extern int screen_width;
248 extern int screen_height;
250 extern HANDLE bsp_process;
251 extern HANDLE g_hBSPOutput;
252 extern HANDLE g_hBSPInput;
255 char *TranslateString (char *buf);
257 void ProjectDialog (void);
259 void FillTextureMenu (CStringArray* pArray = NULL);
260 void FillBSPMenu (void);
262 BOOL CALLBACK Win_Dialog (
263 HWND hwndDlg, // handle to dialog box
264 UINT uMsg, // message
265 WPARAM wParam, // first message parameter
266 LPARAM lParam // second message parameter
273 void WCam_Create (HINSTANCE hInstance);
279 void WXY_Create (HINSTANCE hInstance);
284 void WZ_Create (HINSTANCE hInstance);
294 void Main_Create (HINSTANCE hInstance);
295 extern bool SaveWindowState(HWND hWnd, const char *pszName);
296 extern bool LoadWindowState(HWND hWnd, const char *pszName);
298 extern bool SaveRegistryInfo(const char *pszName, void *pvBuf, long lSize);
299 extern bool LoadRegistryInfo(const char *pszName, void *pvBuf, long *plSize);
308 void DoSides(bool bCone = false, bool bSphere = false, bool bTorus = false);
313 ** QE function declarations
315 void QE_CheckAutoSave( void );
316 void QE_CountBrushesAndUpdateStatusBar( void );
317 void WINAPI QE_CheckOpenGLForErrors(void);
318 void QE_ExpandBspString (char *bspaction, char *out, char *mapname, bool useTemps);
320 bool QE_KeyDown (int key, int nFlags = 0);
321 bool QE_LoadProject (char *projectfile);
322 bool QE_SingleBrush (bool bQuiet = false, bool entityOK = false);
326 void Sys_MarkMapModified (void);
329 ** QE Win32 function declarations
331 int WINAPI QEW_SetupPixelFormat(HDC hDC, bool zbuffer );
334 ** extern declarations
336 extern QEGlobals_t g_qeglobals;
337 extern int mapModified; // for quit confirmation (0 = clean, 1 = unsaved,
339 //++timo clean (moved into qertypes.h)
340 //enum VIEWTYPE {YZ, XZ, XY};
343 extern bool g_bAxialMode;
344 extern int g_axialAnchor;
345 extern int g_axialDest;
347 extern void Face_FlipTexture_BrushPrimit(face_t *face, bool y);
348 extern void Brush_FlipTexture_BrushPrimit(brush_t *b, bool y);
351 // new brush primitive stuff
352 //void ComputeAxisBase( idVec3 &normal,idVec3 &texS,idVec3 &texT );
353 void FaceToBrushPrimitFace(face_t *f);
354 void EmitBrushPrimitTextureCoordinates(face_t *, idWinding *, patchMesh_t *patch = NULL);
355 // EmitTextureCoordinates, is old code used for brush to brush primitive conversion
356 void EmitTextureCoordinates ( idVec5 &xyzst, const idMaterial *q, face_t *f, bool force = false);
357 void BrushPrimit_Parse(brush_t *, bool newFormat, const idVec3 origin);
358 // compute a fake shift scale rot representation from the texture matrix
359 void TexMatToFakeTexCoords( float texMat[2][3], float shift[2], float *rot, float scale[2] );
360 void FakeTexCoordsToTexMat( float shift[2], float rot, float scale[2], float texMat[2][3] );
361 void ConvertTexMatWithQTexture( brushprimit_texdef_t *texMat1, const idMaterial *qtex1, brushprimit_texdef_t *texMat2, const idMaterial *qtex2, float sScale = 1.0, float tScale = 1.0 );
363 void Face_MoveTexture_BrushPrimit(face_t *f, idVec3 delta);
364 void Select_ShiftTexture_BrushPrimit( face_t *f, float x, float y, bool autoAdjust );
365 void RotateFaceTexture_BrushPrimit(face_t *f, int nAxis, float fDeg, idVec3 vOrigin );
366 // used in CCamWnd::ShiftTexture_BrushPrimit
367 void ComputeBest2DVector( idVec3 v, idVec3 X, idVec3 Y, int &x, int &y );
369 void ApplyMatrix_BrushPrimit(face_t *f, idMat3 matrix, idVec3 origin);
370 // low level functions .. put in mathlib?
371 #define BPMatCopy(a,b) {b[0][0] = a[0][0]; b[0][1] = a[0][1]; b[0][2] = a[0][2]; b[1][0] = a[1][0]; b[1][1] = a[1][1]; b[1][2] = a[1][2];}
372 // apply a scale transformation to the BP matrix
373 #define BPMatScale(m,sS,sT) {m[0][0]*=sS; m[1][0]*=sS; m[0][1]*=sT; m[1][1]*=sT;}
374 // apply a translation transformation to a BP matrix
375 #define BPMatTranslate(m,s,t) {m[0][2] += m[0][0]*s + m[0][1]*t; m[1][2] += m[1][0]*s+m[1][1]*t;}
376 // 2D homogeneous matrix product C = A*B
377 void BPMatMul(float A[2][3], float B[2][3], float C[2][3]);
378 // apply a rotation (degrees)
379 void BPMatRotate(float A[2][3], float theta);
381 void BPMatDump(float A[2][3]);
388 extern bool parsing_single;
389 extern bool eclass_found;
390 extern eclass_t *eclass_e;
391 void Eclass_ScanFile( char *filename );
392 void FillClassList (void);
394 extern bool g_bShowLightVolumes;
395 extern bool g_bShowLightTextures;
396 extern const idMaterial *Texture_LoadLight(const char *name);
398 #define FONT_HEIGHT 10
400 void UniqueTargetName(idStr& rStr);
402 #define MAP_VERSION 2.0
404 extern CMainFrame* g_pParentWnd;
405 extern CString g_strAppPath;
406 extern CPrefsDlg& g_PrefsDlg;
407 extern CFindTextureDlg& g_dlgFind;
408 extern idCVar radiant_entityMode;
418 extern void AddSlash(CString&);
419 extern void DLLBuildDone();
420 extern void CleanUpEntities();
421 extern void QE_CountBrushesAndUpdateStatusBar();
422 extern void QE_CheckAutoSave();
423 extern qtexture_t *notexture;
424 extern qtexture_t *current_texture;
425 extern bool SaveWindowState(HWND hWnd, const char *pszName);
426 extern void Map_Snapshot();
427 extern void WXY_Print();
428 extern void AddProp( void );
429 extern int inspector_mode;
430 extern bool g_bRotateMode;
431 extern bool g_bClipMode;
432 extern bool g_bScaleMode;
433 extern int g_nScaleHow;
434 extern bool g_bPathMode;
435 extern void RunScript(char* pBuffer);
436 extern HINSTANCE g_hOpenGL32;
438 extern void FindReplaceTextures(const char* pFind, const char* pReplace, bool bSelected, bool bForce);
439 extern void DoProjectSettings();
440 extern bool region_active;
441 extern void Texture_ShowDirectory (char* pPath, bool Linked = false);
442 extern void Map_ImportFile (char *filename);
443 extern void Map_SaveSelected(char* pFilename);
444 extern bool g_bNewFace;
445 extern bool g_bSwitch;
446 extern brush_t g_brFrontSplits;
447 extern brush_t g_brBackSplits;
448 extern CClipPoint g_Clip1;
449 extern CClipPoint g_Clip2;
450 extern brush_t* g_pSplitList;
451 extern CClipPoint g_PathPoints[256];
452 extern void AcquirePath(int nCount, PFNPathCallback* pFunc);
453 extern bool g_bScreenUpdates;
454 extern SCommandInfo g_Commands[];
455 extern int g_nCommandCount;
456 extern SKeyInfo g_Keys[];
457 extern int g_nKeyCount;
458 extern int inspector_mode;
459 extern const char *bsp_commands[256];
460 extern void HandlePopup(CWnd* pWindow, unsigned int uId);
462 extern CString g_strProject;
463 extern void TextureAxisFromPlane( const idPlane &pln, idVec3 &xv, idVec3 &yv);
464 extern bool QE_SaveProject (const char* pProjectFile);
465 extern void Clamp(float& f, int nClamp);
466 extern bool WriteFileString( FILE *fp, char *string, ... );
467 extern void MemFile_fprintf(CMemFile* pMemFile, const char* pText, ...);
468 extern void SaveWindowPlacement(HWND hwnd, const char* pName);
469 extern bool LoadWindowPlacement(HWND hwnd, const char* pName);
470 extern bool ConfirmModified (void);
471 extern void DoPatchInspector();
472 void UpdatePatchInspector();
473 extern int g_nSmartX;
474 extern int g_nSmartY;
475 extern brush_t* CreateEntityBrush(int x, int y, CXYWnd* pWnd);
476 int PointInMoveList( idVec3 *pf );
478 extern bool ByeByeSurfaceDialog();
479 extern void UpdateSurfaceDialog();
480 extern void UpdateLightInspector();
482 BOOL UpdateEntitySel(eclass_t *pec);
483 void SetInspectorMode(int iType);
484 BOOL GetSelectAllCriteria(CString &strKey, CString &strVal);
486 int GetCvarInt(const char *name, const int def);
487 const char *GetCvarString(const char *name, const char *def);
488 void SetCvarInt(const char *name, const int value);
489 void SetCvarString(const char *name, const char *value);
490 void SetCvarBinary(const char *name, void *pv, int size);
491 bool GetCvarBinary(const char *name, void *pv, int size);
493 void UpdateRadiantColor( float r, float g, float b, float a );
495 #endif /* !__QE3_H__ */