]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/qe3.h
c4412cbd4a760bdb1b1ad338103467b90e81d30e
[xonotic/netradiant.git] / radiant / qe3.h
1 /*
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5 This file is part of GtkRadiant.
6
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21
22 #ifndef _QE3_H_
23 #define _QE3_H_
24
25 #ifdef _WIN32
26
27 // disable data conversion warnings for gl
28 #pragma warning(disable : 4244)     // MIPS
29 #pragma warning(disable : 4136)     // X86
30 #pragma warning(disable : 4051)     // ALPHA
31 #pragma warning(disable : 4800)
32 #endif
33
34 // for interfaces, we require main plugin header included
35 #include "iplugin.h"
36 #include "qerplugin.h"
37 #include "qertypes.h"
38
39 #include "missing.h" // temporary stuff, needs to be removed
40 #include "idatastream.h"
41 #include "file.h"
42
43 #include "qgl.h"
44
45 #include <gtk/gtk.h>
46 #include <glib/gi18n.h>
47 #include <math.h>
48 #include <stdlib.h>
49
50 #include <stdio.h>
51
52 // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=672
53 // this is the version to expect from template projects
54 #define PROJECT_VERSION 2
55
56 //#define MEM_DEBUG
57 #ifdef MEM_DEBUG
58
59 #define malloc(a) debug_malloc(a, __FILE__, __LINE__)
60 #define free(a) debug_free(a, __FILE__, __LINE__)
61
62 void* debug_malloc (size_t size, const char* file, int line);
63 void debug_free (void *buf, const char* file, int line);
64
65 #endif
66
67 #ifdef _DEBUG
68 //#define DBG_WINDOWPOS
69 #endif
70
71 #ifdef DBG_WINDOWPOS
72 void CheckWatchit(char *msg);
73 #endif
74
75 // those two files are generated
76 // if they are missing, you NEED to run makeversion.sh
77 // NOTE: for win32 users, cygwin installation is REQUIRED to run makeversion.sh
78 // NOTE TTimo if any of those changes (they might change a lot), then the whole app is rebuilt.
79 //   very often it's not necessary
80 #include "version.h"
81 #include "aboutmsg.h"
82
83 // synapse is our utility lib for dynamic shared objects management
84 #include "synapse.h"
85
86 #include "qertypes.h"
87 #include "cmdlib.h"
88 #include "mathlib.h"
89 #include "parse.h"
90
91 #include "qedefs.h"
92 #include "qfiles.h"
93 #include "textures.h"
94 #include "brush.h"
95 //#include "entity.h"
96 #define USE_ENTITYTABLE_DEFINE
97 #include "ientity.h"
98 extern _QEREntityTable __ENTITYTABLENAME;
99 // wrappers for brush access
100 #include "ibrush.h"
101 // wrappers for patch access
102 #include "ipatch.h"
103
104 #include "imodel.h"
105
106 #include "imap.h"
107
108 #include "iundo.h"
109
110 extern _QERPlugMapTable g_MapTable;
111
112 //++timo for BP conversion escaping FIXME: remove when mixing two formats!
113 extern bool g_bCancel_Map_LoadFile;
114 // used to be #defines, multiple engine support suggests we should go towards dynamic
115 extern int g_MaxWorldCoord;
116 extern int g_MinWorldCoord;
117 extern int g_MaxBrushSize;
118 /*
119 // set to true when we are parsing a terrain entity
120 extern bool g_bParseTerrain;
121 extern IShader *g_pTerrainShader, *g_pCaulk;
122 */
123 #include "map.h"
124
125 #include "select.h"
126
127 #include "camera.h"
128 #include "z.h"
129
130 #include "undo.h"
131 #include "glwidget.h"
132
133 // the dec offsetof macro doesn't work very well...
134 #define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier)
135
136 // set these before calling CheckParm
137 extern int myargc;
138 extern char **myargv;
139
140 // our own implementation of Q_int, clamping can be disabled on prefs
141 vec_t Rad_rint (vec_t in);
142
143 double I_FloatTime (void);
144
145 void   Error (const char *error, ...);
146 int    CheckParm (const char *check);
147 void   ParseCommandLine (char *lpCmdLine);
148
149 int    ParseNum (const char *str);
150
151 char*  COM_Parse (char *data);
152 char*  Get_COM_Token();
153
154 extern  char            com_token[1024];
155 extern  qboolean        com_eof;
156
157 #define MAX_NUM_ARGVS   32
158 extern  int             argc;
159 extern  char            *argv[MAX_NUM_ARGVS];
160
161 //
162 // system functions
163 //
164 // TTimo NOTE: WINAPI funcs can be accessed by plugins
165 void    Sys_UpdateStatusBar( void );
166 void    WINAPI Sys_UpdateWindows (int bits);
167 void    Sys_Beep (void);
168 void    Sys_ClearPrintf (void);
169 double  Sys_DoubleTime (void);
170 void    Sys_GetCursorPos (int *x, int *y);
171 void    Sys_SetCursorPos (int x, int y);
172 void    Sys_SetTitle (const char *text);
173 void    WINAPI Sys_BeginWait (void);
174 void    WINAPI Sys_EndWait (void);
175 void    Sys_Status(const char *psz, int part);
176 bool    Sys_AltDown ();
177 bool    Sys_ShiftDown ();
178 // will open/close/check the log file based on the following globals:
179 // g_PrefsDlg.m_bLogConsole g_qeglobals.hLogFile
180 void    Sys_LogFile (void);
181
182 extern  qboolean verbose;
183 #include "qsysprintf.h"
184
185 // NOTE TTimo I split out the GUI-depependant stuff from QEGlobals_t into a seperate struct
186 typedef struct
187 {
188   // GL widget of the camera view
189   // all textures are binded in this context and shared with the others
190   GtkWidget *d_glBase;
191
192   GtkWidget *d_main_window; // d_hwndMain
193   GtkWidget *d_edit;        // d_hwndEdit
194   GtkWidget *d_entity;      // d_hwndEntity
195   GtkWidget *d_camera;      // d_hwndCamera;
196   GtkWidget *d_texture;     // d_hwndTexture;
197   GtkWidget *d_texture_scroll;
198   GtkWidget *d_z;           // d_hwndZ;
199
200 } QEGlobals_GUI_t;
201
202 // usefull portability stuff
203 //++timo move them somewhere
204 bool DoesFileExist(const char* pBuff, long& lSize);
205
206 char *copystring (char *s);
207 char *ExpandReletivePath (char *p);
208
209 #include "xmlstuff.h"
210 #include "points.h"
211
212 //
213 // drag.c
214 //
215 void Drag_Begin (int x, int y, int buttons, vec3_t xaxis, vec3_t yaxis, vec3_t origin, vec3_t dir, bool sf_camera = false);
216 void Drag_MouseMoved (int x, int y, int buttons);
217 void Drag_MouseUp (int nButtons = 0);
218
219 //
220 // csg.c
221 //
222 void CSG_MakeHollow (void);
223 void CSG_Subtract (void);
224 void CSG_Merge (void);
225
226 //
227 // vertsel.c
228 //
229
230 void SetupVertexSelection (void);
231 void SelectEdgeByRay (vec3_t org, vec3_t dir);
232 void SelectVertexByRay (vec3_t org, vec3_t dir);
233
234 void ConnectEntities (void);
235
236 extern  int     update_bits;
237
238 extern  int     screen_width;
239 extern  int     screen_height;
240
241 char *TranslateString (char *buf);
242
243 //
244 // linux_qe3.cc
245 //
246 //void OpenDialog ();
247 //void SaveAsDialog (bool bRegion);
248 void ProjectDialog (void);
249 void MRU_Load ();
250 void MRU_Save ();
251 void MRU_AddWidget (GtkWidget *widget, int pos);
252 void MRU_AddFile (const char *str);
253 void MRU_Activate (int index);
254
255
256 void FillTextureMenu (GSList** pArray = NULL);
257 void FillBSPMenu (void);
258
259 // profile functions - kind of utility lib
260 // they are kind of dumb, they expect to get the path to the .ini file or to the prefs directory when called
261 // load_buffer and save_buffer expect the path only, theyll build a $(pszName).bin file
262 bool WINAPI profile_save_int (const char *filename, const char *section, const char *key, int value);
263 bool WINAPI profile_save_float (const char *filename, const char *section, const char *key, float value);
264 bool WINAPI profile_save_string (const char *filename, const char *section, const char *key, const char *value);
265 bool profile_save_buffer (const char *rc_path, const char *pszName, void *pvBuf, guint32 lSize);
266 bool profile_load_buffer (const char *rc_path, const char *pszName, void *pvBuf, guint32 *plSize);
267 int WINAPI profile_load_int (const char *filename, const char *section, const char *key, int default_value);
268 float WINAPI profile_load_float (const char *filename, const char *section, const char *key, float default_value);
269 char* WINAPI profile_load_string (const char *filename, const char *section, const char *key, const char *default_value);
270 // used in the command map code
271 bool read_var (const char *filename, const char *section, const char *key, char *value);
272
273 //
274 // entityw.c
275 //
276 void FillClassList (void);
277 bool UpdateEntitySel(eclass_t *pec);
278 void SetInspectorMode(int iType);
279 void SetSpawnFlags(void);
280 void GetSpawnFlags(void);
281 void SetKeyValuePairs(bool bClearMD3 = false);
282 extern void BuildGammaTable(float g);
283 bool GetSelectAllCriteria(CString &strKey, CString &strVal);
284
285 // linux_dlg.c
286
287 typedef enum {
288   BEVEL = 0,
289   ENDCAP,
290   IBEVEL,
291   IENDCAP
292 } CapDialog;
293
294 int DoCapDlg (int *type, bool *b_GroupResul);
295 int DoBSInputDlg (const char *fields[5], float values[5]);
296 int DoTextureLayout (float *fx, float *fy);
297 char* DoNameDlg (const char* title);
298 char* DoNewProjectDlg ();
299 /*
300 text editor, open filename at given line
301 opening at line works only for win32 / editpad and builtin Gtk editor
302
303 we only allow one instance of the Gtk editor widget opened at a given time
304 if we get called with an existing instance, switch to new file ..
305 */
306 void DoTextEditor (const char* filename, int cursorpos);
307 int DoLightIntensityDlg (int *intensity);
308
309 void DoMapInfo ();
310 void DoEntityList ();
311 void DoGamma();
312 void DoFind();
313 void DoRotateDlg ();
314 void DoSides(bool bCone = false, bool bSphere = false, bool bTorus = false);
315 void DoAbout();
316 void DoSnapTToGrid(float hscale = 0.0f, float vscale = 0.0f);
317 void DoSurface();
318 void ToggleSurface(); // will show/hide depending on the current state
319 void DoNewPatchDlg ();
320 void DoThickenDlg ();
321 void DoCommandListDlg ();
322 void DoScaleDlg ();;
323 void DoTextureListDlg ();
324 void DoScriptsDlg ();
325
326 // QE function declarations
327 void     QE_CheckAutoSave( void );
328 void     WINAPI QE_ConvertDOSToUnixName( char *dst, const char *src );
329 void     QE_CountBrushesAndUpdateStatusBar( void );
330 void     WINAPI QE_CheckOpenGLForErrors(void);
331 void     QE_ExpandBspString (char *bspaction, GPtrArray & out, char *mapname);
332 // initialise the VFS from current project settings
333 void     QE_InitVFS();
334 // do all initialisations that should happen after a project is load (during startup or project change)
335 void     QE_Init (void);
336 qboolean QE_KeyDown (int key, int nFlags = 0);
337 // does some sanity checks on the project entity, such as removing ending filename seperators from paths
338 // (this usually gets propagated to the actual project file since most of the time we save right after calling the check)
339 void     QE_CheckProjectEntity();
340 // this will load a new project entity in memory, and potentially process it from a template
341 // NOTE TTimo calling QE_LoadProject won't take care of the various initialisation that are performed depending on the project settings
342 //   you should then call QE_Init for that
343 #define PROJECT_TEMPLATE_NAME "default_project.proj"
344 #define PROJECT_USER_NAME "user_project.proj"
345 #define PROJECT_FILETYPE "proj"
346 qboolean QE_LoadProject (const char *projectfile);
347 qboolean QE_SingleBrush (bool bQuiet = false);
348
349
350 // sys stuff
351 void Sys_MarkMapModified (void);
352
353 #if 0 // no longer used
354
355 // QE Win32 function declarations
356 #ifdef _WIN32
357 int  WINAPI QEW_SetupPixelFormat(HDC hDC, qboolean zbuffer );
358 void QEW_StopGL( HWND hWnd, HGLRC hGLRC, HDC hDC );
359 #endif
360
361 #endif
362
363 // extern declarations
364 extern QEGlobals_t   g_qeglobals;
365 extern QEGlobals_GUI_t g_qeglobals_gui;
366
367 qboolean IsBrushSelected(brush_t* bSel);
368
369 // curve brushes
370
371 void Curve_MakeCurvedBrush (qboolean negative, qboolean top, qboolean bottom,
372                                         qboolean s1, qboolean s2, qboolean s3, qboolean s4);
373
374 void Curve_Invert (void);
375
376 void Curve_AddFakePlanes( brush_t *B );
377 void Curve_StripFakePlanes( brush_t *B );
378 void Curve_BuildPoints (brush_t *b);
379 void Curve_XYDraw (brush_t *b);
380 void Curve_CameraDraw (brush_t *b);
381
382 void Curve_WriteFile (char *name);
383
384
385 // patch stuff
386 patchMesh_t *Patch_Alloc();
387 patchMesh_t* MakeNewPatch();
388 brush_t* AddBrushForPatch(patchMesh_t *pm, bool bLinkToWorld = true);
389 brush_t* Patch_GenericMesh(int nWidth, int nHeight, int nOrientation = 2, bool bDeleteSource = true, bool bOverride = false);
390 //void Patch_ReadFile (char *name);
391 //void Patch_WriteFile (char *name);
392 void Patch_BuildPoints (brush_t *b);
393 void Patch_Move(patchMesh_t *p, const vec3_t vMove, bool bRebuild = false);
394 //++timo had to add a default value for bSnap (see Patch_ApplyMatrix call from Select_ApplyMatrix in select.cpp)
395 void Patch_ApplyMatrix(patchMesh_t *p, const vec3_t vOrigin, const vec3_t vMatrix[3], bool bSnap = false);
396 void Patch_EditPatch();
397 void Patch_Deselect();
398 void Patch_Deselect(patchMesh_t *p);
399 void Patch_Delete(patchMesh_t *p);
400 int  Patch_MemorySize(patchMesh_t *p);
401 void Patch_Select(patchMesh_t *p);
402 void Patch_Scale(patchMesh_t *p, const vec3_t vOrigin, const vec3_t vAmt, bool bRebuilt = true);
403 void Patch_Cleanup();
404 void Patch_SetView(int n);
405 void Patch_SetTexture(patchMesh_t *p, texdef_t *tex_def, IPluginTexdef* pPlugTexdef = NULL);
406 void Patch_BrushToMesh(bool bCone = false, bool bBevel = false, bool bEndcap = false, bool bSquare = false, int nHeight = 3);
407 bool Patch_DragScale(patchMesh_t *p, vec3_t vAmt, vec3_t vMove);
408 //void Patch_ReadBuffer(char* pBuff, bool bSelect = false);
409 //void Patch_WriteFile (MemStream* pMemFile);
410 void Patch_UpdateSelected(vec3_t vMove);
411 //brush_t* Patch_Parse(bool bOld);
412 //void Patch_Write (patchMesh_t *p, FILE *f);
413 //void Patch_Write (patchMesh_t *p, MemStream *file);
414 //void Patch_AdjustColumns(patchMesh_t *p, int nCols);
415 //void Patch_AdjustRows(patchMesh_t *p, int nRows);
416 void Patch_AdjustSelected(bool bInsert, bool bColumn, bool bFlag);
417 patchMesh_t* Patch_Duplicate(patchMesh_t *pFrom);
418 void Patch_RotateTexture(patchMesh_t *p, float fAngle);
419 void Patch_ScaleTexture(patchMesh_t *p, float fx, float fy, bool bFixup = true);
420 // shift of some pixel amount
421 void Patch_ShiftTexture(patchMesh_t *p, float fx, float fy);
422 // shift of ST increments
423 void Patch_ShiftTextureST(patchMesh_t *p, float fx, float fy);
424 void Patch_DrawCam(patchMesh_t *p);
425 void Patch_DrawXY(patchMesh_t *p);
426 void Patch_InsertColumn(patchMesh_t *p, bool bAdd);
427 void Patch_InsertRow(patchMesh_t *p, bool bAdd);
428 void Patch_RemoveRow(patchMesh_t *p, bool bFirst);
429 void Patch_RemoveColumn(patchMesh_t *p, bool bFirst);
430 void Patch_ToggleInverted();
431 void Patch_Restore(patchMesh_t *p);
432 void Patch_Save(patchMesh_t *p);
433 void Patch_SetTextureInfo(texdef_t* pt);
434 void Patch_NaturalTexturing();
435 void Patch_ResetTexturing(float fx, float fy);
436 void Patch_FitTexturing();
437 void Patch_BendToggle();
438 //void Patch_StartInsDel();
439 void Patch_BendHandleTAB();
440 void Patch_BendHandleENTER();
441 void Patch_SelectBendNormal();
442 void Patch_SelectBendAxis();
443 bool OnlyPatchesSelected();
444 bool AnyPatchesSelected();
445 patchMesh_t* SinglePatchSelected();
446 void Patch_CapCurrent();
447 void Patch_DisperseRows();
448 void Patch_DisperseIntermediateRows();
449 void Patch_DisperseIntermediateColumns();
450 void Patch_CycleCapSelected();
451 void Patch_NaturalizeSelected(bool bCap = false);//, bool bCycleCap = false);
452 void Patch_SelectAreaPoints(bool bMulti);
453 void Patch_InvertTexture(bool bY);
454 void patchInvert(patchMesh_t *p);
455 //void Patch_InsDelToggle();
456 //void Patch_InsDelHandleTAB();
457 //void Patch_InsDelHandleENTER();
458 void Patch_SetOverlays();
459 void Patch_ClearOverlays();
460 void Patch_Thicken(int nAmount, bool bSeam, qboolean bGroupResult);
461 void Patch_Transpose();
462 void Patch_Freeze();
463 void Patch_UnFreeze(bool bAll);
464 const char* Patch_GetTextureName();
465 void Patch_FindReplaceTexture(brush_t *pb, const char *pFind, const char *pReplace, bool bForce);
466 void Patch_SnapToGrid(patchMesh_t *p);
467 extern bool g_bPatchShowBounds;
468 extern bool g_bPatchWireFrame;
469 extern bool g_bPatchWeld;
470 extern bool g_bPatchDrillDown;
471 //extern bool g_bPatchInsertMode;
472 extern bool g_bPatchBendMode;
473 extern vec3_t g_vBendOrigin;
474 //void Patch_FromTriangle(vec5_t vx, vec5_t vy, vec5_t vz);
475 const char* Patch_GetKeyValue(patchMesh_t *p, const char *pKey);
476 void Patch_SetEpair(patchMesh_t *p, const char *pKey, const char *pValue);
477 void Patch_LODMatchAll();
478 void Patch_CalcBounds(patchMesh_t *p, vec3_t& vMin, vec3_t& vMax);
479
480
481
482
483 // group stuff
484 // group_t are loaded / saved through "group_info" entities
485 // they hold epairs for group settings and additionnal access info (tree nodes)
486 typedef struct group_s
487 {
488   struct group_s *next;
489   epair_t *epairs;
490 #if 0 //! Deprecated in gtk 2.x.
491   GtkCTreeNode *itemOwner;
492 #endif
493 } group_t;
494
495 // NOTES: grouping only enabled in brush primitives mode
496 // grouping works by naming brushes and setting display properties
497 // the group hierarchy is not related with the map hierarchy (entity list, brushes etc.)
498 // brushes with no group are under the "world" node (default for all brushes)
499 // void Group_GetListFromWorld(CStringArray *pArray);
500 void Group_RemoveListFromWorld();
501 // void Group_SetListToWorld(CStringArray *pArray);
502 // void Group_BuildTree(CTreeCtrl *pTree);
503 // void Group_DecomposeTree(CTreeCtrl *pTree);
504 // save group_t as "classname" "group_info" things
505 void Group_Save(FILE *f);
506 // clean the brushes ownerItem, clean the treeview and rebuild everything
507 // is usually called when loading a new map, but may be called anytime
508 void Group_Init();
509 void Group_Add(entity_t *e);
510
511 // remove a brush from it's current group, will erase the "group" epair if any, and delete the tree control node
512 void Group_RemoveBrush(brush_t *b);
513 void Group_AddToWorld(brush_t *b);
514 // will remove brush of it's current group if any, and will add it wherever needed according to it's "group" key
515 void Group_AddToProperGroup(brush_t *b);
516 void Group_AddToSelected(brush_t *b);
517 // allocate a new group, set name
518 group_t* Group_Alloc(const char *name);
519 // we use entities to store information about the groups
520 // these entities are not linked into the world, and they have no brushes
521 // only loaded / saved in map file
522 group_t* Group_ForName(const char *name);
523
524 // TTimo
525 // new brush primitive stuff
526
527 #ifdef _DEBUG
528 //#define DBG_BP
529 #endif
530
531 // get the relative axes of the current texturing
532 void BrushPrimit_GetRelativeAxes(face_t *f, vec3_t vecS, vec3_t vecT);
533 // brush primitive stuff
534 void ComputeAxisBase(vec3_t normal, vec3_t texS, vec3_t texT );
535 void FaceToBrushPrimitFace(face_t *f);
536 void BrushPrimitFaceToFace(face_t *f);
537 void EmitBrushPrimitTextureCoordinates(face_t *, winding_t *);
538 // EmitTextureCoordinates, is old code used for brush to brush primitive conversion
539 void EmitTextureCoordinates ( float *xyzst, qtexture_t *q, face_t *f);
540 //void BrushPrimit_Parse(brush_t *);
541 // compute a fake shift scale rot representation from the texture matrix
542 void TexMatToFakeTexCoords( vec_t texMat[2][3], float shift[2], float *rot, float scale[2] );
543 void FakeTexCoordsToTexMat( float shift[2], float rot, float scale[2], vec_t texMat[2][3] );
544 void ConvertTexMatWithQTexture( vec_t texMat1[2][3], qtexture_t *qtex1, vec_t texMat2[2][3], qtexture_t *qtex2 );
545 // NOTE: this is a wrapper over the vec_t mat[2][3] version
546 void ConvertTexMatWithQTexture( brushprimit_texdef_t *texMat1, qtexture_t *qtex1, brushprimit_texdef_t *texMat2, qtexture_t *qtex2 );
547 // texture locking
548 void ShiftTextureGeometric_BrushPrimit(face_t *f, vec3_t delta);
549 void ShiftTextureRelative_BrushPrimit( face_t *f, float x, float y );
550 void RotateFaceTexture_BrushPrimit(face_t *f, int nAxis, float fDeg, vec3_t vOrigin );
551 // used in CCamWnd::ShiftTexture_BrushPrimit
552 void ComputeBest2DVector( vec3_t v, vec3_t X, vec3_t Y, int &x, int &y );
553 void Face_FitTexture_BrushPrimit( face_t *face, vec3_t minx, vec3_t maxs, int nHeight, int nWidth );
554 // lock textures on a random transformation
555 void ApplyMatrix_BrushPrimit(face_t *f, vec3_t matrix[3], vec3_t origin);
556 // low level functions .. put in mathlib?
557 #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];}
558 // apply a scale transformation to the BP matrix
559 #define BPMatScale(m,sS,sT) {m[0][0]*=sS; m[1][0]*=sS; m[0][1]*=sT; m[1][1]*=sT;}
560 // apply a translation transformation to a BP matrix
561 #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;}
562 // 2D homogeneous matrix product C = A*B
563 void BPMatMul(vec_t A[2][3], vec_t B[2][3], vec_t C[2][3]);
564 // apply a rotation (degrees)
565 void BPMatRotate(vec_t A[2][3], float theta);
566 #ifdef _DEBUG
567 void BPMatDump(vec_t A[2][3]);
568 #endif
569 // GL matrix product
570 void GLMatMul(vec_t M[4][4], vec_t A[4], vec_t B[4]);
571 qboolean IsBrushPrimitMode();
572 //
573 // eclass.cpp
574 //
575 #include "ieclass.h"
576
577 /*!
578   \todo those are at the eclass manager level, but some documentation about what they do will be helpful
579 */
580 extern qboolean parsing_single;
581 extern qboolean eclass_found;
582 extern eclass_t *eclass_e;
583 extern eclass_t *g_md3Cache;
584
585 /*!
586 eclass manager API
587 */
588 void Eclass_InsertAlphabetized(eclass_t *e);
589 eclass_t** Get_EClass_E();
590 void Set_Eclass_Found(qboolean);
591 qboolean Get_Parsing_Single();
592
593 // .def loading, builtin module
594 #include "eclass_def.h"
595 extern CSynapseBuiltinClientDef eclass_def;
596
597 /*!
598 global table to .def entity class description
599 this is a builtin module, even if we rely on fgd, we still use this one in cases such as entities not found etc.
600 */
601 extern _EClassTable g_EClassDefTable;
602
603 /*!
604 support for one additional/optional entity format
605 */
606 extern bool g_bHaveEClassExt;
607 extern _EClassTable g_EClassExtTable;
608
609
610 #include "iplugin.h"
611 // for interfaces, we require main plugin header included
612 #include "qerplugin.h"
613
614 //
615 // SurfaceDlg.cpp and surface properties plugin
616 //
617 //++timo some patch in/out stuff is in there, needs to be moved out in a dedicated interface
618 #include "isurfaceplugin.h"
619 #include "surfaceplugin.h"
620 void WINAPI Patch_Rebuild(patchMesh_t *p);
621 #include "isurfaceplugin.h"
622 extern _QERPlugSurfaceTable g_SurfaceTable;
623 void SurfaceDlgFitAll();
624
625 //
626 // OpenGL interface
627 //
628 #include "igl.h"
629
630 GtkWidget* WINAPI QERApp_GetQeglobalsGLWidget();
631 void WINAPI QERApp_HookGL2DWindow(IGL2DWindow* pGLW);
632 void WINAPI QERApp_UnHookGL2DWindow(IGL2DWindow* pGLW);
633 void WINAPI QERApp_HookGL3DWindow(IGL3DWindow* pGLW);
634 void WINAPI QERApp_UnHookGL3DWindow(IGL3DWindow* pGLW);
635 void Draw2DPluginEntities( VIEWTYPE vt );
636 void Draw3DPluginEntities();
637
638 //
639 // IShaders interface
640 //
641 #define USE_SHADERSTABLE_DEFINE
642 #include "ishaders.h"
643 extern _QERShadersTable g_ShadersTable;
644
645 //
646 // ISelectedFace interface
647 //
648 #include "iselectedface.h"
649 int WINAPI QERApp_GetSelectedFaceCount();
650 // NOTE: it's the brush corresponding to the selected face below!
651 brush_t* WINAPI QERApp_GetSelectedFaceBrush(int iface);
652 face_t* WINAPI QERApp_GetSelectedFace(int iface);
653 int WINAPI QERApp_GetFaceInfo(int iface, _QERFaceData *pFaceData, winding_t *pWinding);
654 int WINAPI QERApp_SetFaceInfo(int iface, _QERFaceData *pFaceData);
655 int WINAPI QERApp_ISelectedFace_GetTextureNumber(int iface);
656 void WINAPI QERApp_GetTextureSize(int iface, int Size[2]);
657
658 //
659 // IEpairs interface
660 //
661 //#include "iepairs.h"
662 //#include "epairswrapper.h"
663
664 //
665 // IImage interface
666 //
667 #include "iimage.h"
668
669 //
670 // IFileSystem interface
671 //
672 #define USE_VFSTABLE_DEFINE
673 #include "ifilesystem.h"
674
675 extern _QERFileSystemTable g_FileSystemTable;
676
677 //
678 // TexWnd.cpp
679 //
680 extern qboolean g_bShowAllShaders;
681
682 //
683 // texwindow.cpp
684 //
685 //++timo TODO: we can probably raise the MAX_TEXTUREDIRS limit?
686 #define         MAX_TEXTUREDIRS 256
687
688 extern CPtrArray g_lstSkinCache;
689 qtexture_t *QERApp_LoadTextureRGBA(unsigned char* pPixels, int nWidth, int nHeight);
690
691 //
692 // IScripLib interface
693 // GetToken, UnGetToken, etc.
694 #include "iscriplib.h"
695 extern FILE *g_File;
696 void WINAPI QERApp_MapPrintf_FILE( char *text, ... );
697
698 //
699 // ISurfacePlugin interface
700 //
701 void QERApp_GetTwoSelectedPatch( patchMesh_t **p1, patchMesh_t **p2 );
702
703 //
704 // IBSPFrontend interface
705 //
706 #include "ibspfrontend.h"
707 extern _QERPlugBSPFrontendTable g_BSPFrontendTable;
708 extern GSList *g_BSPFrontendCommands;
709
710 //
711 // IToolbar
712 //
713 #include "itoolbar.h"
714
715 //
716 // IMessaging interface
717 #include "iui.h"
718 #include "iui_gtk.h"
719 #include "ui.h"
720 IWindow* WINAPI QERApp_CreateGLWindow();
721 void WINAPI QERApp_HookWindow(IWindowListener* pListen);
722 void WINAPI QERApp_UnHookWindow(IWindowListener* pListen);
723 IXYWndWrapper* WINAPI QERApp_GetXYWndWrapper();
724 void WINAPI QERApp_HookListener(IListener* pListen, int Msg);
725 int  WINAPI QERApp_UnHookListener(IListener* pListen);
726 void DispatchRadiantMsg( int Msg );
727 // dispatch for IWindowListener entities
728 void DispatchOnMouseMove(guint32 nFlags, int x, int y);
729 bool DispatchOnLButtonDown(guint32 nFlags, int x, int y);
730 bool DispatchOnLButtonUp(guint32 nFlags, int x, int y);
731
732 //
733 // IData interface
734 //
735 #include "idata.h"
736
737 //
738 // ICamera interface
739 //
740 #include "icamera.h"
741
742 // Some declarations that were in stdafx.h
743
744 // main.cpp
745 extern gint try_destroy_splash(gpointer);
746
747 #include "mainframe.h"
748 #include "preferences.h"
749 #include "findtexturedialog.h"
750 #include "surfacedialog.h"
751 #include "patchdialog.h"
752
753 class MainFrame;
754 class ClipPoint;
755
756 extern MainFrame* g_pParentWnd;
757 extern CString g_strAppPath;
758 extern CString g_strDTDPath;
759 extern CString g_pidFile;
760 extern CString g_pidGameFile;
761 extern CString g_strBitmapsPath;
762 extern CString g_strPluginsDir;
763 extern CString g_strModulesDir;
764
765 extern CGameDescription *g_pGameDescription;
766 extern CString g_strGameToolsPath;
767
768 extern CString g_strTempPath;
769 extern PrefsDlg& g_PrefsDlg;
770 extern FindTextureDialog& g_dlgFind;
771 extern SurfaceDlg g_dlgSurface;
772 extern PatchDialog g_PatchDialog;
773
774 extern int g_bIgnoreCommands;
775
776 void HideInfoDialog();
777 void ShowInfoDialog(const char* pText);
778
779 // externs
780 //extern void HandleCommand (GtkWidget *widget, gpointer data, bool keydown);
781 extern gint HandleCommand (GtkWidget *widget, gpointer data);
782 extern void AddSlash(CString&);
783 extern void DLLBuildDone();
784 extern void CleanUpEntities();
785 extern void FindReplace(CString& strContents, const char* pTag, const char* pValue);
786 extern void CheckBspProcess();
787 extern void QE_CountBrushesAndUpdateStatusBar();
788 extern void     QE_CheckAutoSave();
789 extern qtexture_t       *current_texture;
790 extern void SaveWithRegion(char *name); // save the current map, sets the map name in the name buffer (deals with regioning)
791 extern void RunBsp (char *command);
792 extern void Map_Snapshot();
793 //extern void WXY_Print();
794 extern void AddProp( void );
795 extern qboolean DoColor(int iIndex);
796 extern entity_t *edit_entity;
797 extern int inspector_mode;
798 extern bool g_bRotateMode;
799 extern bool g_bClipMode;
800 extern bool g_bScaleMode;
801 extern int g_nScaleHow;
802 extern bool g_bPathMode;
803 extern void RunScript(char* pBuffer);
804 extern bool ExtractPath_and_Filename(const char* pPath, CString& strPath, CString& strFilename);
805 extern void Select_Scale(float x, float y, float z);
806 extern void Select_RotateTexture(int amt);
807 extern void Select_ScaleTexture(float x, float y);
808 extern void Select_ShiftTexture(int x, int y);
809 extern void FindReplaceTextures(const char* pFind, const char* pReplace, bool bSelected, bool bForce, bool bSelectMatchingFaces);
810 /*!
811 \fn DoProjectSettings shows the dialog for per-game configurable settings by the user
812 typically this sets up things like mod editing configuration
813 those a per-project, not the same thing as preferences which are global to the game conf
814 this is still being worked on, as we have several issues with how things are configured
815 we also have a number of behaviours defined in the .game, which can't be edited graphically
816 we dump those properties to the console when the project settings dialog shows up
817 */
818 extern void DoProjectSettings();
819 extern qboolean region_active;
820 extern void Brush_Print(brush_t* b);
821 extern void Texture_ShowStartupShaders();
822 extern void Map_ImportFile (char *filename);
823 extern void Map_SaveSelected(char* pFilename);
824 extern void UpdateSurfaceDialog();
825 extern void Select_GetTrueMid (vec3_t mid);
826 extern bool g_bSwitch;
827 extern brush_t g_brFrontSplits;
828 extern brush_t g_brBackSplits;
829 extern ClipPoint g_Clip1;
830 extern ClipPoint g_Clip2;
831 extern brush_t* g_pSplitList;
832 extern ClipPoint g_PathPoints[256];
833 extern void AcquirePath(int nCount, PFNPathCallback* pFunc);
834 extern bool g_bScreenUpdates;
835 extern SCommandInfo g_Commands[];
836 extern int g_nCommandCount;
837 extern SKeyInfo g_Keys[];
838 extern int g_nKeyCount;
839 extern int inspector_mode;
840 extern char     *bsp_commands[256];
841 extern void RunScriptByName(char*, bool);
842 extern void DoNewColor(int* i1, int* i2, int* i3);
843 extern void UpdateSurfaceDialog();
844 extern void CSG_SplitBrushByFace (brush_t *in, face_t *f, brush_t **front, brush_t **back);
845 //extern void HandlePopup(CWnd* pWindow, unsigned int uId);
846 extern z_t z;
847 extern void Select_Scale(float x, float y, float z);
848 extern void TextureAxisFromPlane(plane_t *pln, vec3_t xv, vec3_t yv);
849 //extern void VectorRotate (vec3_t va, vec3_t vb, vec3_t out);
850 //extern void VectorRotate (vec3_t vIn, vec3_t vRotation, vec3_t vOrigin, vec3_t out);
851 extern qboolean QE_SaveProject (const char* pProjectFile);
852 //extern void NewBSP(char* pCommandLine, HWND);
853 //extern void NewVIS(char* pCommandLine, HWND);
854 //extern void NewRAD(char* pCommandLine, HWND);
855 extern void RunTools(char* pCommandLine, GtkWidget* hwnd, const char* pPAKFile);
856 extern void Clamp(float& f, int nClamp);
857 extern void MemFile_fprintf(MemStream* pMemFile, const char* pText, ...);
858 //extern void SaveWindowPlacement(HWND hwnd, const char* pName);
859 //extern bool LoadWindowPlacement(HWND hwnd, const char* pName);
860 extern qboolean ConfirmModified (void);
861 extern void DoPatchInspector();
862 extern void TogglePatchInspector();
863 void UpdatePatchInspector();
864 extern int BuildShortPathName(const char* pPath, char* pBuffer, int nBufferLen);
865 extern int g_nBrushId;
866
867 // defined in gtkdlgs.cpp, we might want to move declaration and implementatin with other Select_ stuff..
868 // NOTE: there's also a Select_Brush(brush_t *b) function.. unrelated
869 extern void SelectBrush (int entitynum, int brushnum);
870
871 // bp_dlg.cpp
872 // ret: 0 = abort, 1 = load and convert, 2 = changed project settings, load and don't convert
873 // the user might decide to switch the BP mode in project settings
874 // status: 0 = loading regular, got conflict 1 = loading BP, got conflict
875 extern int BP_MessageBox (int status);
876
877 // main.cpp
878 extern gint try_destroy_splash(gpointer);
879
880 // SPoG
881 // targetname.cpp
882 void Entity_Connect(entity_t *e1, entity_t *e2);
883 int GetUniqueTargetId(int iHint);
884
885 // xywindow.cpp
886 void CreateEntityFromName(const char* name, const vec3_t origin);
887
888 // eclass.cpp
889 /*!
890 \brief initialization of the eclass manager
891 general guidelines about eclass.cpp implementation:
892 - we don't support unlimited number of eclass file formats together
893   currently limited to two
894   support for .def is builtin to the core, but you may choose not to activate it
895 - search and load of the files:
896   the manager is in charge of scanning for eclass definition files to load
897   there is a general configuration setting for games which use a different set of
898     entities between single player mode and multiplayer mode (TODO: the code doing
899     this needs to be abstracted some more)
900 - duplicate files / multiple files:
901   if two files with the same name exist (for instance in the basegame, and in fs_game)
902   then only the first one found in the scan order is loaded
903   if several files are found, they are all loaded
904   this allows mods to either replace or extend the list of eclass
905 - if eclass_singleload prop is used in the .game, then there is no multiple files check
906   the first file found is loaded, and there is no further search for the given extension
907   (this was an addition for HL support)
908 */
909 void Eclass_Init ();
910 eclass_t *Eclass_ForName (const char *name, qboolean has_brushes);
911 eclass_t * EClass_Create( const char *name, float col1, float col2, float col3, const vec3_t *mins, const vec3_t *maxs, const char *comments );
912
913 #endif // _QE3_H_