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 #ifndef __QE3_H__ 30 #define __QE3_H__ 31 32 #ifdef ID_DEBUG_MEMORY 33 #undef new 34 #undef DEBUG_NEW 35 #define DEBUG_NEW new 36 #endif 37 38 // this define to use HTREEITEM and MFC stuff in the headers 39 #define QERTYPES_USE_MFC 40 #include "qertypes.h" 41 #include "cmdlib.h" 42 #include "parse.h" 43 44 #include <commctrl.h> 45 #include "afxres.h" 46 #include "../../sys/win32/rc/Radiant_resource.h" // main symbols 47 #include "../../sys/win32/win_local.h" 48 49 #include "qedefs.h" 50 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; 55 56 // assume that all maps fit within this 57 const float HUGE_DISTANCE = 100000; 58 59 #include "textures.h" 60 #include "EditorBrush.h" 61 #include "EditorEntity.h" 62 #include "EditorMap.h" 63 #include "select.h" 64 #include "splines.h" 65 66 #include "z.h" 67 #include "mru.h" 68 #include "waitdlg.h" 69 #include "MainFrm.h" 70 #include "PrefsDlg.h" 71 #include "FindTextureDlg.h" 72 #include "dialogtextures.h" 73 #include "InspectorDialog.h" 74 #include "undo.h" 75 #include "PMESH.H" 76 77 // the dec offsetof macro doesn't work very well... 78 #define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier) 79 80 81 void Error (char *error, ...); 82 void Warning (char *error, ...); 83 84 typedef struct 85 { 86 int p1, p2; 87 face_t *f1, *f2; 88 } pedge_t; 89 90 typedef struct 91 { 92 int iSize; 93 int iTexMenu; // nearest, linear, etc 94 float fGamma; // gamma for textures 95 char szProject[256]; // last project loaded 96 idVec3 colors[COLOR_LAST]; 97 bool show_names; 98 bool show_coordinates; 99 int exclude; 100 float m_nTextureTweak; 101 bool editorExpanded; 102 RECT oldEditRect; 103 bool showSoundAlways; 104 bool showSoundWhenSelected; 105 } SavedInfo_t; 106 107 // 108 // system functions 109 // 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); 119 bool Sys_Waiting(); 120 void Sys_EndWait (void); 121 void Sys_Status(const char *psz, int part = -1); 122 123 /* 124 ** most of the QE globals are stored in this structure 125 */ 126 typedef struct 127 { 128 bool d_showgrid; 129 float d_gridsize; 130 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 133 134 int d_num_entities; 135 136 entity_t *d_project_entity; 137 138 idVec3 d_new_brush_bottom, d_new_brush_top; 139 140 HINSTANCE d_hInstance; 141 142 idVec3 d_points[MAX_POINTS]; 143 int d_numpoints; 144 pedge_t d_edges[MAX_EDGES]; 145 int d_numedges; 146 147 int d_num_move_points; 148 idVec3 *d_move_points[MAX_MOVE_POINTS]; 149 150 int d_num_move_planes; 151 idPlane *d_move_planes[MAX_MOVE_PLANES]; 152 153 qtexture_t *d_qtextures; 154 155 texturewin_t d_texturewin; 156 157 int d_pointfile_display_list; 158 159 LPMRUMENU d_lpMruMenu; 160 161 SavedInfo_t d_savedinfo; 162 163 int d_workcount; 164 165 // connect entities uses the last two brushes selected 166 int d_select_count; 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; // 171 172 int d_font_list; 173 174 int d_parsed_brushes; 175 176 bool show_blocks; 177 178 // Timo 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; 183 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 186 bool bNeedConvert; 187 bool bOldBrushes; 188 bool bPrimitBrushes; 189 float mapVersion; 190 191 idVec3 d_vAreaTL; 192 idVec3 d_vAreaBR; 193 194 // tells if we are using .INI files for prefs instead of registry 195 bool use_ini; 196 // even in .INI mode we use the registry for all void* prefs 197 char use_ini_registry[64]; 198 199 //Timo 200 // tells we have surface properties plugin 201 bool bSurfacePropertiesPlugin; 202 // tells we are using a BSP frontend plugin 203 bool bBSPFrontendPlugin; 204 205 // the editor has its own soundWorld and renderWorld, completely distinct from the game 206 idRenderWorld *rw; 207 idSoundWorld *sw; 208 } QEGlobals_t; 209 210 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 ); 218 219 // 220 // drag.c 221 // 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; 228 // 229 // csg.c 230 // 231 void CSG_MakeHollow (void); 232 void CSG_Subtract (void); 233 void CSG_Merge (void); 234 235 // 236 // vertsel.c 237 // 238 239 void SetupVertexSelection (void); 240 void SelectEdgeByRay (idVec3 org, idVec3 dir); 241 void SelectVertexByRay (idVec3 org, idVec3 dir); 242 243 void ConnectEntities (void); 244 245 extern int update_bits; 246 247 extern int screen_width; 248 extern int screen_height; 249 250 extern HANDLE bsp_process; 251 extern HANDLE g_hBSPOutput; 252 extern HANDLE g_hBSPInput; 253 254 255 char *TranslateString (char *buf); 256 257 void ProjectDialog (void); 258 259 void FillTextureMenu (CStringArray* pArray = NULL); 260 void FillBSPMenu (void); 261 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 267 ); 268 269 270 // 271 // win_cam.c 272 // 273 void WCam_Create (HINSTANCE hInstance); 274 275 276 // 277 // win_xy.c 278 // 279 void WXY_Create (HINSTANCE hInstance); 280 281 // 282 // win_z.c 283 // 284 void WZ_Create (HINSTANCE hInstance); 285 286 // 287 // win_ent.c 288 // 289 290 291 // 292 // win_main.c 293 // 294 void Main_Create (HINSTANCE hInstance); 295 extern bool SaveWindowState(HWND hWnd, const char *pszName); 296 extern bool LoadWindowState(HWND hWnd, const char *pszName); 297 298 extern bool SaveRegistryInfo(const char *pszName, void *pvBuf, long lSize); 299 extern bool LoadRegistryInfo(const char *pszName, void *pvBuf, long *plSize); 300 301 302 303 // win_dlg.c 304 305 void DoGamma(void); 306 void DoFind(void); 307 void DoRotate(void); 308 void DoSides(bool bCone = false, bool bSphere = false, bool bTorus = false); 309 void DoAbout(void); 310 void DoSurface(); 311 312 /* 313 ** QE function declarations 314 */ 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); 319 void QE_Init (void); 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); 323 324 325 // sys stuff 326 void Sys_MarkMapModified (void); 327 328 /* 329 ** QE Win32 function declarations 330 */ 331 int WINAPI QEW_SetupPixelFormat(HDC hDC, bool zbuffer ); 332 333 /* 334 ** extern declarations 335 */ 336 extern QEGlobals_t g_qeglobals; 337 extern int mapModified; // for quit confirmation (0 = clean, 1 = unsaved, 338 339 //++timo clean (moved into qertypes.h) 340 //enum VIEWTYPE {YZ, XZ, XY}; 341 342 343 extern bool g_bAxialMode; 344 extern int g_axialAnchor; 345 extern int g_axialDest; 346 347 extern void Face_FlipTexture_BrushPrimit(face_t *face, bool y); 348 extern void Brush_FlipTexture_BrushPrimit(brush_t *b, bool y); 349 350 // Timo 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 ); 362 // texture locking 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 ); 368 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); 380 #ifdef _DEBUG 381 void BPMatDump(float A[2][3]); 382 #endif 383 384 385 // 386 // eclass.cpp 387 // 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); 393 394 extern bool g_bShowLightVolumes; 395 extern bool g_bShowLightTextures; 396 extern const idMaterial *Texture_LoadLight(const char *name); 397 398 #define FONT_HEIGHT 10 399 400 void UniqueTargetName(idStr& rStr); 401 402 #define MAP_VERSION 2.0 403 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; 409 410 // layout styles 411 #define QR_SPLIT 0 412 #define QR_QE4 1 413 #define QR_4WAY 2 414 #define QR_SPLITZ 3 415 416 417 // externs 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; 437 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); 461 extern z_t z; 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 ); 477 478 extern bool ByeByeSurfaceDialog(); 479 extern void UpdateSurfaceDialog(); 480 extern void UpdateLightInspector(); 481 482 BOOL UpdateEntitySel(eclass_t *pec); 483 void SetInspectorMode(int iType); 484 BOOL GetSelectAllCriteria(CString &strKey, CString &strVal); 485 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); 492 493 void UpdateRadiantColor( float r, float g, float b, float a ); 494 495 #endif /* !__QE3_H__ */ 496