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