]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - include/qerplugin.h
add q3map2 build to scons
[xonotic/netradiant.git] / include / qerplugin.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 // QERadiant PlugIns
23 //
24 //
25
26 #ifndef __QERPLUGIN_H__
27 #define __QERPLUGIN_H__
28
29 /*!
30 \todo this header is intended to be turned into a header for the core editor functionality
31 some portability related code should be moved to synapse (such as the GUID stuff)
32 */
33
34 #include <stdio.h>
35 #include <string.h>
36 // TTimo
37 // ideally the plugin API would be UI toolkit independent, but removing the dependency with GLib seems tricky right now..
38 #include <glib.h>
39 #include "qertypes.h"
40
41 // FIXME TTimo:
42 // GUID declaration here should be trashed, it is in synapse.h
43 #ifdef _WIN32
44 #include <wtypes.h>
45 #endif
46
47 #define QER_MAX_NAMELEN 1024
48
49 #ifndef _WIN32
50 #include "misc_def.h"
51 #endif
52
53 // the editor will look for plugins in two places, the plugins path 
54 // under the application path, and the path under the basepath as defined
55 // in the project (.qe4) file.
56 //
57 // you can drop any number of new texture, model format DLL's in the standard plugin path
58 // but only one plugin that overrides map loading/saving, surface dialog, surface flags, etc.. 
59 // should be used at one time.. if multiples are loaded then the last one loaded will be the 
60 // active one
61 //
62 // type of services the plugin supplies, pass any combo of these flags
63 // it is assumed the plugin will have a matching function as defined below
64 // to correlate to the implied functionality
65 // 
66
67 #define RADIANT_MAJOR "radiant"
68
69 // basics
70 #define QERPLUG_INIT "QERPlug_Init"
71 #define QERPLUG_GETNAME "QERPlug_GetName"
72 #define QERPLUG_GETCOMMANDLIST "QERPlug_GetCommandList"
73 #define QERPLUG_DISPATCH "QERPlug_Dispatch"
74 #define QERPLUG_GETFUNCTABLE "QERPlug_GetFuncTable"
75
76 // game stuff
77 #define QERPLUG_GETTEXTUREINFO "QERPlug_GetTextureInfo"   // gets a texture info structure
78 #define QERPLUG_LOADTEXTURE    "QERPlug_LoadTexture"      // loads a texture, will return an RGBA structure
79                                                           // and any surface flags/contents for it
80 #define QERPLUG_GETSURFACEFLAGS "QERPlug_GetSurfaceFlags" // gets a list of surface/content flag names from a plugin
81
82 struct _QERTextureInfo
83 {
84   char m_TextureExtension[QER_MAX_NAMELEN];   // the extension these textures have
85   qboolean m_bHiColor;    // if textures are NOT high color, the default 
86                       // palette (as described inthe qe4 file will be used for gamma correction)
87                       // if they are high color, gamma and shading are computed on the fly 
88                       // based on the rgba data
89   //--bool m_bIsShader;   // will probably do q3 shaders this way when i merge
90   qboolean m_bWadStyle;   // if this is true, the plugin will be presented with the texture path
91                       // defined in the .qe4 file and is expected to preload all the textures
92   qboolean m_bHalfLife;   // causes brushes to be saved/parsed without the surface contents/flags/value
93 };
94
95 struct _QERTextureLoad    // returned by a plugin
96 {
97   _QERTextureLoad()
98   { 
99     memset(reinterpret_cast<void*>(this), 0, sizeof(_QERTextureLoad));
100   };
101
102   ~_QERTextureLoad()
103   {
104     delete []m_pRGBA;
105     delete []m_pName;
106   };
107
108   void makeSpace(int nSize)
109   {
110     m_pRGBA = new unsigned char[nSize+1];
111   };
112
113   void setName(const char* p)
114   {
115     m_pName = new char[strlen(p)+1];
116     strcpy(m_pName, p);
117   };
118
119
120   unsigned char *m_pRGBA; // rgba data (alpha channel is supported and drawn appropriately)
121   int m_nWidth;           // width
122   int m_nHeight;          // height
123   int m_nContents;        // default contents
124   int m_nFlags;           // "" flags
125   int m_nValue;           // "" value
126   char *m_pName;          // name to be referenced in map, build tools, etc.
127 };
128
129 struct _QERModelInfo
130 {
131   char m_ModelExtension[QER_MAX_NAMELEN];
132   bool m_bSkinned;
133   bool m_bMultipart;
134 };
135
136 struct _QERModelLoad
137 {
138   // vertex and skin data
139 };
140
141
142 //=========================================
143 // plugin functions
144 #if 0
145 // NOTE TTimo: hack to make old plugin tech and new plugin tech live together
146 #ifndef _IPLUGIN_H_
147 // toolkit-independant interface, cast hwndMain to GtkWidget*
148 typedef const char* (WINAPI *PFN_QERPLUG_INIT)(void* hApp, void* hwndMain);
149 typedef const char* (WINAPI *PFN_QERPLUG_GETNAME)();
150 typedef const char* (WINAPI *PFN_QERPLUG_GETCOMMANDLIST)();
151 typedef void  (WINAPI *PFN_QERPLUG_DISPATCH)(const char* p, vec3_t vMin, vec3_t vMax, bool bSingleBrush);
152 #endif
153 #endif
154
155 typedef char* (WINAPI *PFN_QERPLUG_GETFUNCTABLE)();
156
157 // v1.5
158 //
159 // Texture loading
160 // returns a ptr to _QERTextureInfo
161 typedef void* (WINAPI *PFN_QERPLUG_GETTEXTUREINFO)();
162 //
163 // loads a texture by calling the texture load func in the editor (defined below)
164 // transparency (for water, fog, lava, etc.. ) can be emulated in the editor
165 // by passing in appropriate alpha data or by setting the appropriate surface flags
166 // expected by q2 (which the editor will use.. )
167 typedef void (WINAPI *PFN_QERPLUG_LOADTEXTURE)(const char* pFilename); 
168
169 // v1.6
170 typedef void* (WINAPI *PFN_QERPLUG_GETSURFACEFLAGS)();
171
172 // v1.7
173 // if exists in plugin, gets called between INIT and GETCOMMANDLIST
174 // the plugin can register the EClasses he wants to handle
175 //++timo TODO: this has got to move into the table, and be requested by QERPlug_RequestInterface
176 //++timo FIXME: the LPVOID parameter must be casted to an IEpair interface
177 #define QERPLUG_REGISTERPLUGINENTITIES "QERPlug_RegisterPluginEntities"
178 typedef void (WINAPI * PFN_QERPLUG_REGISTERPLUGINENTITIES)( void* );
179
180 // if exists in plugin, gets called between INIT and GETCOMMANDLIST
181 // the plugin can Init all it needs for surface properties
182 #define QERPLUG_INITSURFACEPROPERTIES "QERPlug_InitSurfaceProperties"
183 typedef void (WINAPI * PFN_QERPLUG_INITSURFACEPROPERTIES)();
184
185 // if Radiant needs to use a particular set of commands, it can request the plugin to fill a func table
186 // this is similar to PFN_QERAPP_REQUESTINTERFACE
187 #define QERPLUG_REQUESTINTERFACE "QERPlug_RequestInterface"
188 typedef int (WINAPI * PFN_QERPLUG_REQUESTINTERFACE) (REFGUID refGUID, void* pInterface, const char *version_name);
189
190 // Load an image file
191 typedef void (* PFN_QERAPP_LOADIMAGE) (const char *name, unsigned char **pic, int *width, int *height);
192
193 // TTimo FIXME: the logic for this is in synapse now
194
195 // MODULES specific:
196 // if it exports this entry point, will be considered as a module
197 // a module is a plugin that provides some REQUIRED interfaces to Radiant, such as the shader module
198 // Radiant will call QERPLUG_LISTINTERFACES to get a list of the interfaces a given plugin implements
199 // then it will call PFN_QERPLUG_REQUESTINTERFACE to actually get them
200
201 // following leo's code .. looks ok to use a string to identify the various versions of a same interface
202 // obviously it would be handy to have the same string naming for the interfaces.
203 // best way would be to have the names come in when you list the interfaces
204 // NOTE: we might have a problem with the order in which the interfaces are filled in
205 //   there's some kind of dependency graph, the shader module expects to find the VFS ready etc.
206 typedef struct moduleentry_s {
207   const GUID *interface_GUID;
208   const char* interface_name;
209   const char* version_name; 
210 } moduleentry_t;
211
212 #define QERPLUG_LISTINTERFACES "QERPlug_ListInterfaces"
213 #define MAX_QERPLUG_INTERFACES 10
214 typedef int (WINAPI* PFN_QERPLUG_LISTINTERFACES) (moduleentry_t table[MAX_QERPLUG_INTERFACES]);
215
216 // ========================================
217 // GTK+ helper functions
218
219 // NOTE: parent can be NULL in all functions but it's best to set them
220
221 // simple Message Box, see above for the 'type' flags
222 // toolkit-independent, cast parent ot a GtkWidget*
223 typedef gint (WINAPI* PFN_QERAPP_MESSAGEBOX) (void *parent, const char* text,
224                                               const char* caption, guint32 type, const char *URL);
225
226 // file and directory selection functions return NULL if the user hits cancel
227 // or a gchar* string that must be g_free'd by the user
228 // - 'title' is the dialog title (can be NULL)
229 // - 'path' is used to set the initial directory (can be NULL)
230 // - 'pattern': the first pattern is for the win32 mode, then comes the Gtk pattern list, see Radiant source for samples
231 // TTimo 04/01/2001 toolkit-independant, cast parent to a GtkWidget*
232 typedef const gchar* (* PFN_QERAPP_FILEDIALOG) (void *parent, gboolean open, const char* title,
233                                                 const char* path, const char* pattern);
234 typedef gchar* (WINAPI* PFN_QERAPP_DIRDIALOG) (void *parent, const char* title,
235                                                const char* path);
236
237 // return true if the user closed the dialog with 'Ok'
238 // 'color' is used to set the initial value and store the selected value
239 typedef bool (WINAPI* PFN_QERAPP_COLORDIALOG) (void *parent, float *color,
240                                                const char* title);
241
242 // load a .bmp file and store the results in 'gdkpixmap' and 'mask'
243 // returns TRUE on success but even if it fails, it creates an empty pixmap
244 // NOTE: 'filename' is relative to <radiant_path>/plugins/bitmaps/
245 // TTimo 04/01/2001 toolkit-independant, cast gkpixmap to GdkPixmap and mask to GdkBitmap
246 typedef bool (WINAPI* PFN_QERAPP_LOADBITMAP) (const char* filename, void **gdkpixmap, void **mask);
247
248 // ========================================
249 // read/write preferences file
250
251 // use this function to get the directory where the preferences file are stored
252 typedef const char* (WINAPI* PFN_QERAPP_PROFILE_GETDIR) ();
253
254 // 'filename' is the absolute path
255 typedef bool (WINAPI* PFN_QERAPP_PROFILE_SAVEINT) (const char *filename, const char *section,
256                                                    const char *key, int value);
257 typedef bool (WINAPI* PFN_QERAPP_PROFILE_SAVESTR) (const char *filename, const char *section,
258                                                    const char *key, const char *value);
259 typedef int (WINAPI* PFN_QERAPP_PROFILE_LOADINT) (const char *filename, const char *section,
260                                                   const char *key, int default_value);
261 typedef char* (WINAPI* PFN_QERAPP_PROFILE_LOADSTR) (const char *filename, const char *section,
262                                                     const char *key, const char *default_value);
263
264 //=========================================
265 // editor functions
266
267 // There are 3 potential brush handle lists
268 // 1. the list that contains brushes a plugin creates using CreateBrushHandle
269 // 2. the selected brush list (brushes the user has selected)
270 // 3. the active brush list (brushes in the map that are not selected)
271 // 
272 // In general, the same things can be done to brush handles (face manip, delete brushhandle, etc.. ) in each
273 // list. There are a few exceptions. 
274 // 1. You cannot commit a selected or active brush handle to the map. This is because it is already in the map. 
275 // 2. You cannot bind brush handles from the selected or active brush list to an entity. As of v1.0 of the plugins
276 // the only way for a plugin to create entities is to create a brush handles (or a list of handles) and then bind
277 // them to an entity. This will commit the brush(s) and/or the entities to the map as well.
278 // 
279 // To use the active or selected brush lists, you must first allocate them (which returns a count) and then
280 // release them when you are finish manipulating brushes in one of those lists. 
281
282 //++timo NOTE : the #defines here are never used, but can help finding where things are done in the editor
283 #if 0
284 // brush manipulation routines
285 #define QERAPP_CREATEBRUSH "QERApp_CreateBrush"
286 #define QERAPP_CREATEBRUSHHANDLE "QERApp_CreateBrushHandle"
287 #define QERAPP_DELETEBRUSHHANDLE "QERApp_DeleteBrushHandle"
288 #define QERAPP_COMMITBRUSHHANDLETOMAP "QERApp_CommitBrushHandleToMap"
289 //++timo not implemented .. remove
290 // #define QERAPP_BINDHANDLESTOENTITY "QERApp_BindHandlesToEntity"
291 #define QERAPP_ADDFACE "QERApp_AddFace"
292 #define QERAPP_ADDFACEDATA "QERApp_AddFaceData"
293 #define QERAPP_GETFACECOUNT "QERApp_GetFaceCount"
294 #define QERAPP_GETFACEDATA "QERApp_GetFaceData"
295 #define QERAPP_SETFACEDATA "QERApp_SetFaceData"
296 #define QERAPP_DELETEFACE "QERApp_DeleteFace"
297 #define QERAPP_TEXTUREBRUSH "QERApp_TextureBrush"
298 #define QERAPP_BUILDBRUSH "QERApp_BuildBrush"                                   // PGM
299 #define QERAPP_SELECTEDBRUSHCOUNT "QERApp_SelectedBrushCount"
300 #define QERAPP_ALLOCATESELECTEDBRUSHHANDLES "QERApp_AllocateSelectedBrushHandles"
301 #define QERAPP_RELEASESELECTEDBRUSHHANDLES "QERApp_ReleaseSelectedBrushHandles"
302 #define QERAPP_GETSELECTEDBRUSHHANDLE "QERApp_GetSelectedBrushHandle"
303 #define QERAPP_ACTIVEBRUSHCOUNT "QERApp_ActiveBrushCount"
304 #define QERAPP_ALLOCATEACTIVEBRUSHHANDLES "QERApp_AllocateActiveBrushHandles"
305 #define QERAPP_RELEASEACTIVEBRUSHHANDLES "QERApp_ReleaseActiveBrushHandles"
306 #define QERAPP_GETACTIVEBRUSHHANDLE "QERApp_GetActiveBrushHandle"
307
308 // texture stuff
309 #define QERAPP_TEXTURECOUNT "QERApp_TextureCount"
310 #define QERAPP_GETTEXTURE "QERApp_GetTexture"
311 #define QERAPP_GETCURRENTTEXTURE "QERApp_GetCurrentTexture"
312 #define QERAPP_SETCURRENTTEXTURE "QERApp_SetCurrentTexture"
313
314 // selection 
315 #define QERAPP_DELETESELECTION "QERApp_DeleteSelection"
316 #define QERAPP_SELECTBRUSH "QERApp_SelectBrush"                                 // PGM
317 #define QERAPP_DESELECTBRUSH "QERApp_DeselectBrush"                             // PGM
318 #define QERAPP_DESELECTALLBRUSHES "QERApp_DeselectAllBrushes"   // PGM
319
320 // data gathering
321 #define QERAPP_GETPOINTS "QERApp_GetPoints"
322 #define QERAPP_SELECTBRUSHES "QERApp_GetBrushes"
323
324 // entity class stuff
325 // the entity handling is very basic for 1.0
326 #define QERAPP_GETECLASSCOUNT "QERApp_GetEClassCount"
327 #define QERAPP_GETECLASS "QERApp_GetEClass"
328
329 // misc
330 #define QERAPP_SYSMSG "QERApp_SysMsg"
331 #define QERAPP_INFOMSG "QERApp_InfoMsg"
332 #define QERAPP_HIDEINFOMSG "QERApp_HideInfoMsg"
333 #define QERAPP_RESET_PLUGINS "QERApp_ResetPlugins"
334
335 // texture loading
336 #define QERAPP_LOADTEXTURERGBA "QERApp_LoadTextureRGBA"
337
338 // FIXME: the following are not implemented yet
339 // hook registrations
340 #define QERAPP_REGISTER_MAPLOADFUNC "QERApp_Register_MapLoadFunc"
341 #define QERAPP_REGISTER_MAPSAVEFUNC "QERApp_Register_MapSaveFunc"
342
343 // FIXME: the following are not implemented yet
344 #define QERAPP_REGISTER_PROJECTLOADFUNC "QERApp_Register_ProjectLoadFunc"
345 #define QERAPP_REGISTER_MOUSEHANDLER "QERApp_Register_MouseHandler"
346 #define QERAPP_REGISTER_KEYHANDLER "QERApp_Register_KeyHandler"
347
348 // FIXME: new primtives do not work in v1.00
349 // primitives are new types of things in the map
350 // for instance, the Q3 curves could have been done as 
351 // primitives instead of being built in 
352 // it will be a plugins responsibility to hook the map load and save funcs to load
353 // and/or save any additional data (like new primitives of some type)
354 // the editor will call each registered renderer during the rendering process to repaint
355 // any primitives the plugin owns
356 // each primitive object has a temporary sibling brush that lives in the map
357 // FIXME: go backwards on this a bit.. orient it more towards the temp brush mode as it will be cleaner
358 // basically a plugin will hook the map load and save and will add the primitives to the map.. this will
359 // produce a temporary 'primitive' brush and the appropriate renderer will be called as well as the 
360 // edit handler (for edge drags, sizes, rotates, etc.. ) and the vertex maker will be called when vertex
361 // mode is attemped on the brush.. there will need to be a GetPrimitiveBounds callback in the edit handler
362 // so the brush can resize appropriately as needed.. this might be the plugins responsibility to set the 
363 // sibling brushes size.. it will then be the plugins responsibility to hook map save to save the primitives
364 // as the editor will discard any temp primitive brushes.. (there probably needs to be some kind of sanity check
365 // here as far as keeping the brushes and the plugin in sync.. i suppose the edit handler can deal with all of that
366 // crap but it looks like a nice place for a mess)
367 #define QERAPP_REGISTER_PRIMITIVE "QERApp_Register_Primitive"
368 #define QERAPP_REGISTER_RENDERER "QERApp_Register_Renderer"
369 #define QERAPP_REGISTER_EDITHANDLER "QERApp_Register_EditHandler"
370 #define QERAPP_REGISTER_VERTEXMAKER "QERApp_Register_VertexMaker"
371 #define QERAPP_ADDPRIMITIVE "QERApp_AddPrimitive"
372
373 // v1.70
374 #define QERAPP_GETENTITYCOUNT "QERApp_GetEntityCount"
375 #define QERAPP_GETENTITYHANDLE "QERApp_GetEntityHandle"
376 //++timo not implemented for the moment
377 // #define QERAPP_GETENTITYINFO "QERApp_GetEntityInfo"
378 //++timo does the keyval need some more funcs to add/remove ?
379 // get the pointer and do the changes yourself
380 #define QERAPP_ALLOCATEEPAIR "QERApp_AllocateEpair"
381 #define QERAPP_ALLOCATEENTITYBRUSHHANDLES "QERApp_AllocateEntityBrushHandles"
382 #define QERAPP_RELEASEENTITYBRUSHHANDLES "QERApp_ReleaseEntityBrushHandles"
383 #define QERAPP_GETENTITYBRUSHHANDLE "QERApp_GetEntityBrushHandle"
384 #define QERAPP_CREATEENTITYHANDLE "QERApp_CreateEntityHandle"
385 #define QERAPP_COMMITBRUSHHANDLETOENTITY "QERApp_CommitBrushHandleToEntity"
386 #define QERAPP_COMMITENTITYHANDLETOMAP "QERApp_CommitEntityHandleToMap"
387 #define QERAPP_SETSCREENUPDATE "QERApp_SetScreenUpdate"
388 #define QERAPP_BUILDBRUSH2 "QERApp_BuildBrush2"
389 #endif
390
391 // v1.80
392 #define QERAPP_GETDISPATCHPARAMS "QERApp_GetDispatchParams"
393
394 struct _QERPointData
395 {
396   int     m_nCount;
397   vec3_t *m_pVectors;
398 };
399
400 struct _QERFaceData
401 {
402   char  m_TextureName[QER_MAX_NAMELEN];
403   int   m_nContents;
404   int   m_nFlags;
405   int   m_nValue;
406   float m_fShift[2];
407   float m_fRotate;
408   float m_fScale[2];
409   vec3_t m_v1, m_v2, m_v3;
410   // brush primitive additions
411   qboolean m_bBPrimit;
412   brushprimit_texdef_t brushprimit_texdef;
413 };
414
415 typedef void (WINAPI * PFN_QERAPP_CREATEBRUSH)(vec3_t vMin, vec3_t vMax);
416
417 typedef void* (WINAPI * PFN_QERAPP_CREATEBRUSHHANDLE)();
418 typedef void (WINAPI * PFN_QERAPP_DELETEBRUSHHANDLE)(void* pv);
419 typedef void (WINAPI * PFN_QERAPP_COMMITBRUSHHANDLETOMAP)(void* pv);
420 typedef void (WINAPI * PFN_QERAPP_ADDFACE)(void* pv, vec3_t v1, vec3_t v2, vec3_t v3);
421
422 typedef void (WINAPI * PFN_QERAPP_ADDFACEDATA)(void* pv, _QERFaceData *pData);
423 typedef int  (WINAPI * PFN_QERAPP_GETFACECOUNT)(void* pv);
424 typedef _QERFaceData* (WINAPI * PFN_QERAPP_GETFACEDATA)(void* pv, int nFaceIndex);
425 typedef void (WINAPI * PFN_QERAPP_SETFACEDATA)(void* pv, int nFaceIndex, _QERFaceData *pData);
426 typedef void (WINAPI * PFN_QERAPP_DELETEFACE)(void* pv, int nFaceIndex);
427 typedef void (WINAPI * PFN_QERAPP_TEXTUREBRUSH)(void* pv, char* pName);
428 typedef void (WINAPI * PFN_QERAPP_BUILDBRUSH)(void* pv);                // PGM
429 typedef void (WINAPI * PFN_QERAPP_SELECTBRUSH)(void* pv);               // PGM
430 typedef void (WINAPI * PFN_QERAPP_DESELECTBRUSH)(void* pv);             // PGM
431 typedef void (WINAPI * PFN_QERAPP_DESELECTALLBRUSHES)();                        // PGM
432
433 typedef void (WINAPI * PFN_QERAPP_DELETESELECTION)();
434 typedef void (WINAPI * PFN_QERAPP_GETPOINTS)(int nMax, _QERPointData *pData, char* pMsg);
435
436 typedef int  (WINAPI * PFN_QERAPP_SELECTEDBRUSHCOUNT)();
437 typedef int (WINAPI * PFN_QERAPP_ALLOCATESELECTEDBRUSHHANDLES)();
438 typedef void (WINAPI * PFN_QERAPP_RELEASESELECTEDBRUSHHANDLES)();
439 typedef void* (WINAPI * PFN_QERAPP_GETSELECTEDBRUSHHANDLE)(int nIndex);
440
441 typedef int  (WINAPI * PFN_QERAPP_ACTIVEBRUSHCOUNT)();
442 typedef int (WINAPI * PFN_QERAPP_ALLOCATEACTIVEBRUSHHANDLES)();
443 typedef void (WINAPI * PFN_QERAPP_RELEASEACTIVEBRUSHHANDLES)();
444 typedef void* (WINAPI * PFN_QERAPP_GETACTIVEBRUSHHANDLE)(int nIndex);
445
446 typedef int  (WINAPI * PFN_QERAPP_TEXTURECOUNT)();
447 typedef char* (WINAPI * PFN_QERAPP_GETTEXTURE)(int nIndex);
448 typedef char* (WINAPI * PFN_QERAPP_GETCURRENTTEXTURE)();
449 typedef void (WINAPI * PFN_QERAPP_SETCURRENTTEXTURE)(char* pName);
450
451 typedef void (WINAPI * PFN_QERAPP_REGISTERMAPLOAD)(void* vp);
452 typedef void (WINAPI * PFN_QERAPP_REGISTERMAPSAVE)(void* vp);
453
454 typedef int (WINAPI * PFN_QERAPP_GETECLASSCOUNT)();
455 typedef char* (WINAPI * PFN_QERAPP_GETECLASS)(int nIndex);
456
457 typedef void (WINAPI * PFN_QERAPP_RESETPLUGINS)();
458 //--typedef int (WINAPI* PFN_QERAPP_GETENTITYCOUNT)();
459
460 /*!
461 \fn LoadTextureRGBA
462 \param pPixels is the raw RGBA pixel data (24bits, 8 bit depth)
463 \param nWidth image width
464 \param nHeight image height
465 this will work from the RGBA data and create a GL texture (accessed through a GL bind number)
466 it takes care of creating the mipmapping levels too
467 see http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=575 for some related issues
468 */
469 typedef qtexture_t* (* PFN_QERAPP_LOADTEXTURERGBA)(unsigned char* pPixels, int nWidth, int nHeight);
470
471 //--typedef LPCSTR (WINAPI* PFN_QERAPP_GETENTITY)(int nIndex);
472
473 // v1.70
474 typedef int (WINAPI * PFN_QERAPP_GETENTITYCOUNT)();
475 typedef void* (WINAPI * PFN_QERAPP_GETENTITYHANDLE)(int nIndex);
476 // FIXME: those two are fairly outdated, you get the epairs
477 //   but you don't have a clean epair read/write query
478 //   and you rely on the C structs directly, which might go away soon
479 //   ok now, stop using, it's bad for your karma (see iepairs.h instead)
480 typedef epair_t* (WINAPI * PFN_QERAPP_ALLOCATEEPAIR)( char*, char* );
481 typedef int (WINAPI * PFN_QERAPP_ALLOCATEENTITYBRUSHHANDLES)(void* vp);
482 typedef void (WINAPI * PFN_QERAPP_RELEASEENTITYBRUSHHANDLES)();
483 typedef void* (WINAPI * PFN_QERAPP_GETENTITYBRUSHHANDLE)(int nIndex);
484 typedef void* (WINAPI * PFN_QERAPP_CREATEENTITYHANDLE)();
485 typedef void (WINAPI * PFN_QERAPP_COMMITBRUSHHANDLETOENTITY)( void* vpBrush, void* vpEntity);
486 typedef void (WINAPI * PFN_QERAPP_COMMITENTITYHANDLETOMAP)(void* vp);
487 typedef void (WINAPI * PFN_QERAPP_SETSCREENUPDATE)(int bScreenUpdate);
488 // this one uses window flags defined in qertypes.h
489 typedef void (WINAPI * PFN_QERAPP_SYSUPDATEWINDOWS)(int bits);
490 //++timo remove this one
491 typedef void (WINAPI * PFN_QERAPP_BUILDBRUSH2)(void* vp, int bConvert);
492
493 // v1.80
494 typedef void (WINAPI * PFN_QERAPP_GETDISPATCHPARAMS)(vec3_t vMin, vec3_t vMax, bool *bSingleBrush);
495
496 typedef int (WINAPI * PFN_QERAPP_REQUESTINTERFACE)( REFGUID, void* );
497 // use this one for errors, Radiant will stop after the "edit preferences" dialog
498 typedef void (WINAPI * PFN_QERAPP_ERROR)(char* pMsg, ...);
499 // use to gain read access to the project epairs
500 // FIXME: removed, accessed through QERPlug_RegisterPluginEntities with the IEpair interface
501 // typedef void (WINAPI* PFN_QERAPP_GETPROJECTEPAIR)(epair_t **);
502 // used to allocate and read a buffer
503 //++timo NOTE: perhaps this would need moving to some kind of dedicated interface
504 typedef int (WINAPI * PFN_QERAPP_LOADFILE)(const char *pLocation, void ** buffer);
505 typedef char* (WINAPI * PFN_QERAPP_EXPANDRELETIVEPATH)(char *);
506 typedef void (WINAPI * PFN_QERAPP_QECONVERTDOSTOUNIXNAME)( char *dst, const char *src );
507 typedef int (WINAPI * PFN_QERAPP_HASSHADER)(const char *);
508 typedef int (WINAPI * PFN_QERAPP_TEXTURELOADSKIN)(char *pName, int *pnWidth, int *pnHeight);
509 // retrieves the path to the engine from the preferences dialog box
510 typedef const char* (WINAPI * PFN_QERAPP_GETGAMEPATH)();
511 // retrieves full Radiant path
512 typedef const char* (WINAPI * PFN_QERAPP_GETQERPATH)();
513 // retieves .game name of current active game
514 typedef const char* (WINAPI * PFN_QERAPP_GETGAMEFILE)();
515
516 // patches in/out
517 // NOTE: this is a bit different from the brushes in/out, no LPVOID handles this time
518 // use int indexes instead
519 // if you call AllocateActivePatchHandles, you'll be playing with active patches
520 // AllocateSelectedPatcheHandles for selected stuff
521 // a call to CreatePatchHandle will move you to a seperate index table
522 typedef int                             (WINAPI * PFN_QERAPP_ALLOCATEACTIVEPATCHHANDLES)                ();
523 typedef int                             (WINAPI * PFN_QERAPP_ALLOCATESELECTEDPATCHHANDLES)      ();
524 typedef void                    (WINAPI * PFN_QERAPP_RELEASEPATCHHANDLES)                       ();
525 typedef patchMesh_t*    (WINAPI * PFN_QERAPP_GETPATCHDATA)                                      (int);
526 typedef patchMesh_t*    (WINAPI * PFN_QERAPP_GETPATCHHANDLE)                            (int);
527 typedef void                    (WINAPI * PFN_QERAPP_DELETEPATCH)                               (int);
528 typedef int                             (WINAPI * PFN_QERAPP_CREATEPATCHHANDLE)                         ();
529 // when commiting, only a few patchMesh_t members are relevant:
530 //  int width, height;          // in control points, not patches
531 //  int   contents, flags, value, type;
532 //  drawVert_t ctrl[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT];
533 // once you have commited the index is still available, if the patch handle was allocated by you
534 //   then you can re-use the index to commit other patches .. otherwise you can change existing patches
535 // NOTE: the handle thing for plugin-allocated patches is a bit silly (nobody's perfect)
536 // TODO: change current behaviour to an index = 0 to tell Radiant to allocate, other indexes to existing patches
537 // patch is selected after a commit
538 // you can add an optional texture / shader name .. if NULL will use the current texture
539 typedef void                    (WINAPI * PFN_QERAPP_COMMITPATCHHANDLETOMAP)                    (int, patchMesh_t* pMesh, char *texName);
540 typedef void                    (WINAPI * PFN_QERAPP_COMMITPATCHHANDLETOENTITY)                 (int, patchMesh_t* pMesh, char *texName, void* vpEntity);
541
542 // console output
543 #define SYS_VRB 0 ///< verbose support (on/off)
544 #define SYS_STD 1 ///< standard print level - this is the default
545 #define SYS_WRN 2 ///< warnings
546 #define SYS_ERR 3 ///< error
547 #define SYS_NOCON 4 ///< no console, only print to the file (useful whenever Sys_Printf and output IS the problem)
548 typedef void (WINAPI* PFN_QERAPP_SYSPRINTF) (const char *text, ...);
549 typedef void (WINAPI* PFN_QERAPP_SYSFPRINTF) (int flag, const char *text, ...);
550
551 typedef void (WINAPI* PFN_QERAPP_SYSBEGINWAIT) ();
552 typedef void (WINAPI* PFN_QERAPP_SYSENDWAIT) ();
553
554 typedef void (* PFN_QERAPP_SYSBEEP) ();
555
556 typedef void (* PFN_QERAPP_SYSSTATUS) (const char *psz, int part );
557
558 // core map functionality
559 typedef void      (* PFN_QERAPP_MAPNEW)                     ();
560 typedef void      (* PFN_QERAPP_MAPFREE)                    ();
561 typedef void      (* PFN_QERAPP_MAPBUILDBRUSHDATA)          ();
562 typedef qboolean  (* PFN_QERAPP_MAPISBRUSHFILTERED)         (brush_t *);
563 typedef void      (* PFN_QERAPP_MAPSTARTPOSITION)           ();
564 typedef void      (* PFN_QERAPP_MAPREGIONOFF)               ();
565 //typedef void      (* PFN_QERAPP_SAVEASDIALOG)               (bool bRegion);
566 typedef void      (* PFN_QERAPP_SETBUILDWINDINGSNOTEXBUILD) (bool);
567 typedef void      (* PFN_QERAPP_POINTFILECLEAR)             ();
568
569 typedef void (* PFN_QERAPP_SYSSETTITLE) (const char *text);
570
571 typedef void (* PFN_QERAPP_CSGMAKEHOLLOW) ();
572
573 typedef void (* PFN_QERAPP_REGIONSPAWNPOINT) (FILE *f);
574
575 /*!
576 access to a portable GetTickCount
577 */
578 typedef unsigned long (* PFN_QERAPP_GETTICKCOUNT) ();
579
580 class IModelCache
581 {
582 public:
583   virtual entity_interfaces_t *GetByID(const char *id, const char* version) = 0;
584   virtual void DeleteByID(const char *id, const char* version) = 0;
585   virtual void RefreshAll() = 0;
586 };
587
588 typedef IModelCache* (* PFN_GETMODELCACHE)();
589
590 class IFileTypeList
591 {
592 public:
593   virtual void addType(filetype_t type) = 0;
594 };
595
596 class IFileTypeRegistry
597 {
598 public:
599   virtual void addType(const char* key, filetype_t type) = 0;
600   virtual void getTypeList(const char* key, IFileTypeList* typelist) = 0;
601 private:
602 };
603
604 typedef IFileTypeRegistry* (* PFN_GETFILETYPEREGISTRY)();
605
606 typedef const char* (* PFN_QERAPP_READPROJECTKEY)(const char* key);
607
608 typedef char* (* PFN_GETMAPFILENAME)();
609
610   // FIXME:
611 // add map format extensions
612 // add texture format handlers
613 // add surface dialog handler
614 // add model handler/displayer
615
616 // v1 func table
617 // Plugins need to declare one of these and implement the getfunctable as described above
618 struct _QERFuncTable_1
619 {
620   int   m_nSize;
621   PFN_QERAPP_CREATEBRUSH            m_pfnCreateBrush;
622   PFN_QERAPP_CREATEBRUSHHANDLE      m_pfnCreateBrushHandle;
623   PFN_QERAPP_DELETEBRUSHHANDLE      m_pfnDeleteBrushHandle;
624   PFN_QERAPP_COMMITBRUSHHANDLETOMAP m_pfnCommitBrushHandle;
625   PFN_QERAPP_ADDFACE                m_pfnAddFace;
626   PFN_QERAPP_ADDFACEDATA            m_pfnAddFaceData;
627   PFN_QERAPP_GETFACEDATA            m_pfnGetFaceData;
628   PFN_QERAPP_GETFACECOUNT           m_pfnGetFaceCount;
629   PFN_QERAPP_SETFACEDATA            m_pfnSetFaceData;
630   PFN_QERAPP_DELETEFACE             m_pfnDeleteFace;
631   PFN_QERAPP_TEXTUREBRUSH           m_pfnTextureBrush;
632   PFN_QERAPP_BUILDBRUSH                         m_pfnBuildBrush;                                // PGM
633   PFN_QERAPP_SELECTBRUSH                        m_pfnSelectBrush;                               // PGM
634   PFN_QERAPP_DESELECTBRUSH                      m_pfnDeselectBrush;                             // PGM
635   PFN_QERAPP_DESELECTALLBRUSHES         m_pfnDeselectAllBrushes;                // PGM
636
637   PFN_QERAPP_DELETESELECTION        m_pfnDeleteSelection;
638   PFN_QERAPP_GETPOINTS              m_pfnGetPoints;
639
640   PFN_QERAPP_SELECTEDBRUSHCOUNT           m_pfnSelectedBrushCount;
641   PFN_QERAPP_ALLOCATESELECTEDBRUSHHANDLES m_pfnAllocateSelectedBrushHandles;
642   PFN_QERAPP_RELEASESELECTEDBRUSHHANDLES  m_pfnReleaseSelectedBrushHandles;
643   PFN_QERAPP_GETSELECTEDBRUSHHANDLE       m_pfnGetSelectedBrushHandle;
644
645   PFN_QERAPP_ACTIVEBRUSHCOUNT             m_pfnActiveBrushCount;
646   PFN_QERAPP_ALLOCATEACTIVEBRUSHHANDLES   m_pfnAllocateActiveBrushHandles;
647   PFN_QERAPP_RELEASEACTIVEBRUSHHANDLES    m_pfnReleaseActiveBrushHandles;
648   PFN_QERAPP_GETACTIVEBRUSHHANDLE         m_pfnGetActiveBrushHandle;
649
650   //++timo this would need to be removed and replaced by the IShaders interface
651   PFN_QERAPP_TEXTURECOUNT                 m_pfnTextureCount;
652   PFN_QERAPP_GETTEXTURE                   m_pfnGetTexture;
653   PFN_QERAPP_GETCURRENTTEXTURE            m_pfnGetCurrentTexture;
654   PFN_QERAPP_SETCURRENTTEXTURE            m_pfnSetCurrentTexture;
655
656   PFN_QERAPP_GETECLASSCOUNT         m_pfnGetEClassCount;
657   PFN_QERAPP_GETECLASS              m_pfnGetEClass;
658   PFN_QERAPP_RESETPLUGINS           m_pfnResetPlugins;
659   // v1.00 ends here
660   // v1.50 starts here
661   PFN_QERAPP_LOADTEXTURERGBA        m_pfnLoadTextureRGBA;
662   // v1.50 ends here
663   // v1.70 starts here
664   PFN_QERAPP_GETENTITYCOUNT                     m_pfnGetEntityCount;
665   PFN_QERAPP_GETENTITYHANDLE            m_pfnGetEntityHandle;
666   PFN_QERAPP_ALLOCATEENTITYBRUSHHANDLES m_pfnAllocateEntityBrushHandles;
667   PFN_QERAPP_RELEASEENTITYBRUSHHANDLES  m_pfnReleaseEntityBrushHandles;
668   PFN_QERAPP_GETENTITYBRUSHHANDLE       m_pfnGetEntityBrushHandle;
669   PFN_QERAPP_CREATEENTITYHANDLE         m_pfnCreateEntityHandle;
670   PFN_QERAPP_COMMITBRUSHHANDLETOENTITY  m_pfnCommitBrushHandleToEntity;
671   PFN_QERAPP_COMMITENTITYHANDLETOMAP    m_pfnCommitEntityHandleToMap;
672   PFN_QERAPP_ALLOCATEEPAIR                      m_pfnAllocateEpair;
673   PFN_QERAPP_SETSCREENUPDATE            m_pfnSetScreenUpdate;
674   PFN_QERAPP_BUILDBRUSH2                        m_pfnBuildBrush2;
675   // v1.70 ends here
676   // v1.80 starts here
677   PFN_QERAPP_GETDISPATCHPARAMS     m_pfnGetDispatchParams;
678
679   // plugins can request additional interfaces
680   PFN_QERAPP_REQUESTINTERFACE           m_pfnRequestInterface;
681   PFN_QERAPP_ERROR                                      m_pfnError;
682   // loading a file into a buffer
683   PFN_QERAPP_LOADFILE                           m_pfnLoadFile;
684   PFN_QERAPP_EXPANDRELETIVEPATH         m_pfnExpandReletivePath;
685   PFN_QERAPP_QECONVERTDOSTOUNIXNAME     m_pfnQE_ConvertDOSToUnixName;
686   PFN_QERAPP_HASSHADER                          m_pfnHasShader;
687   PFN_QERAPP_TEXTURELOADSKIN            m_pfnTexture_LoadSkin;
688   PFN_QERAPP_GETGAMEPATH                        m_pfnGetGamePath;
689   PFN_QERAPP_GETQERPATH                         m_pfnGetQERPath;
690   PFN_QERAPP_GETGAMEFILE                        m_pfnGetGameFile;
691   // patches in / out
692   PFN_QERAPP_ALLOCATEACTIVEPATCHHANDLES         m_pfnAllocateActivePatchHandles;
693   PFN_QERAPP_ALLOCATESELECTEDPATCHHANDLES       m_pfnAllocateSelectedPatchHandles;
694   PFN_QERAPP_RELEASEPATCHHANDLES                        m_pfnReleasePatchHandles;
695   PFN_QERAPP_GETPATCHDATA                                       m_pfnGetPatchData;
696   PFN_QERAPP_GETPATCHHANDLE                             m_pfnGetPatchHandle;
697   PFN_QERAPP_DELETEPATCH                                        m_pfnDeletePatch;
698   PFN_QERAPP_CREATEPATCHHANDLE                          m_pfnCreatePatchHandle;
699   PFN_QERAPP_COMMITPATCHHANDLETOMAP                     m_pfnCommitPatchHandleToMap;
700   PFN_QERAPP_COMMITPATCHHANDLETOENTITY  m_pfnCommitPatchHandleToEntity;
701
702   PFN_QERAPP_LOADIMAGE  m_pfnLoadImage;
703
704   // GTK+ functions
705   PFN_QERAPP_MESSAGEBOX  m_pfnMessageBox;
706   PFN_QERAPP_FILEDIALOG  m_pfnFileDialog;
707   PFN_QERAPP_DIRDIALOG   m_pfnDirDialog;
708   PFN_QERAPP_COLORDIALOG m_pfnColorDialog;
709   PFN_QERAPP_LOADBITMAP  m_pfnLoadBitmap;
710
711   // Profile functions
712   PFN_QERAPP_PROFILE_GETDIR  m_pfnProfileGetDirectory;
713   PFN_QERAPP_PROFILE_SAVEINT m_pfnProfileSaveInt;
714   PFN_QERAPP_PROFILE_SAVESTR m_pfnProfileSaveString;
715   PFN_QERAPP_PROFILE_LOADINT m_pfnProfileLoadInt;
716   PFN_QERAPP_PROFILE_LOADSTR m_pfnProfileLoadString;
717
718   // Sys_ functions
719   PFN_QERAPP_SYSUPDATEWINDOWS           m_pfnSysUpdateWindows;
720   PFN_QERAPP_SYSBEEP m_pfnSysBeep;
721   PFN_QERAPP_SYSPRINTF  m_pfnSysPrintf;
722   PFN_QERAPP_SYSFPRINTF m_pfnSysFPrintf;
723   PFN_QERAPP_SYSBEGINWAIT m_pfnSysBeginWait;
724   PFN_QERAPP_SYSENDWAIT m_pfnSysEndWait;
725   PFN_QERAPP_SYSSETTITLE m_pfnSys_SetTitle;
726   PFN_QERAPP_SYSSTATUS m_pfnSys_Status;
727
728   // some core functionality on the map
729   PFN_QERAPP_MAPNEW m_pfnMapNew;
730   PFN_QERAPP_MAPFREE m_pfnMapFree;
731   PFN_QERAPP_MAPBUILDBRUSHDATA m_pfnMapBuildBrushData;
732   PFN_QERAPP_MAPISBRUSHFILTERED m_pfnMap_IsBrushFiltered;
733   PFN_QERAPP_MAPSTARTPOSITION m_pfnMapStartPosition;
734   PFN_QERAPP_MAPREGIONOFF m_pfnMapRegionOff;
735   PFN_QERAPP_SETBUILDWINDINGSNOTEXBUILD m_pfnSetBuildWindingsNoTexBuild;
736 //  PFN_QERAPP_SAVEASDIALOG m_pfnSaveAsDialog;
737   PFN_QERAPP_POINTFILECLEAR m_pfnPointFileClear;
738
739   // FIXME TTimo prolly want to move that somewhere else
740   PFN_QERAPP_CSGMAKEHOLLOW m_pfnCSG_MakeHollow;
741
742   PFN_QERAPP_REGIONSPAWNPOINT m_pfnRegionSpawnPoint;
743   PFN_QERAPP_GETTICKCOUNT m_pfnQGetTickCount;
744   PFN_GETMODELCACHE m_pfnGetModelCache;
745   PFN_GETFILETYPEREGISTRY m_pfnGetFileTypeRegistry;
746
747   PFN_QERAPP_READPROJECTKEY m_pfnReadProjectKey;
748
749   // digibob from the old _QERAppBSPFrontendTable table
750         PFN_GETMAPFILENAME  m_pfnGetMapName;
751 };
752
753 // macros to access those faster in plugins
754 #ifdef USE_QERTABLE_DEFINE
755 #ifndef __QERTABLENAME
756 #define __QERTABLENAME g_FuncTable
757 #endif
758 #define CSG_MakeHollow __QERTABLENAME.m_pfnCSG_MakeHollow
759 #define Sys_Beep __QERTABLENAME.m_pfnSysBeep
760 #define Sys_Printf __QERTABLENAME.m_pfnSysPrintf
761 #define Sys_FPrintf __QERTABLENAME.m_pfnSysFPrintf
762 #define Sys_BeginWait __QERTABLENAME.m_pfnSysBeginWait
763 #define Sys_EndWait __QERTABLENAME.m_pfnSysEndWait
764 #define Sys_UpdateWindows __QERTABLENAME.m_pfnSysUpdateWindows
765 #define Sys_SetTitle __QERTABLENAME.m_pfnSys_SetTitle
766 #define Sys_Status __QERTABLENAME.m_pfnSys_Status
767 #define Select_Deselect __QERTABLENAME.m_pfnDeselectAllBrushes
768 #define Map_New __QERTABLENAME.m_pfnMapNew
769 #define Map_Free __QERTABLENAME.m_pfnMapFree
770 #define Map_IsBrushFiltered __QERTABLENAME.m_pfnMap_IsBrushFiltered
771 #define Map_BuildBrushData __QERTABLENAME.m_pfnMapBuildBrushData
772 #define Map_StartPosition __QERTABLENAME.m_pfnMapStartPosition
773 #define Map_RegionOff __QERTABLENAME.m_pfnMapRegionOff
774 #define QE_ConvertDOSToUnixName __QERTABLENAME.m_pfnQE_ConvertDOSToUnixName
775 #define SetBuildWindingsNoTexBuild __QERTABLENAME.m_pfnSetBuildWindingsNoTexBuild
776 //#define SaveAsDialog __QERTABLENAME.m_pfnSaveAsDialog
777 #define Pointfile_Clear __QERTABLENAME.m_pfnPointFileClear
778 #define SetScreenUpdate __QERTABLENAME.m_pfnSetScreenUpdate
779 #define Region_SpawnPoint __QERTABLENAME.m_pfnRegionSpawnPoint
780 #define QGetTickCount __QERTABLENAME.m_pfnGetTickCount
781 #define GetModelCache __QERTABLENAME.m_pfnGetModelCache
782 #define GetFileTypeRegistry __QERTABLENAME.m_pfnGetFileTypeRegistry
783 #else
784 IFileTypeRegistry* GetFileTypeRegistry();
785 #endif
786
787 #endif