2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
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.
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.
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
26 #ifndef __QERPLUGIN_H__
27 #define __QERPLUGIN_H__
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)
37 // ideally the plugin API would be UI toolkit independent, but removing the dependency with GLib seems tricky right now..
42 // GUID declaration here should be trashed, it is in synapse.h
47 #define QER_MAX_NAMELEN 1024
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.
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
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
67 #define RADIANT_MAJOR "radiant"
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"
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
82 struct _QERTextureInfo
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
95 struct _QERTextureLoad // returned by a plugin
99 memset(reinterpret_cast<void*>(this), 0, sizeof(_QERTextureLoad));
108 void makeSpace(int nSize)
110 m_pRGBA = new unsigned char[nSize+1];
113 void setName(const char* p)
115 m_pName = new char[strlen(p)+1];
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.
131 char m_ModelExtension[QER_MAX_NAMELEN];
138 // vertex and skin data
142 //=========================================
145 // NOTE TTimo: hack to make old plugin tech and new plugin tech live together
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);
155 typedef char* (WINAPI *PFN_QERPLUG_GETFUNCTABLE)();
160 // returns a ptr to _QERTextureInfo
161 typedef void* (WINAPI *PFN_QERPLUG_GETTEXTUREINFO)();
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);
170 typedef void* (WINAPI *PFN_QERPLUG_GETSURFACEFLAGS)();
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* );
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)();
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);
190 // Load an image file
191 typedef void (* PFN_QERAPP_LOADIMAGE) (const char *name, unsigned char **pic, int *width, int *height);
193 // TTimo FIXME: the logic for this is in synapse now
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
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;
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]);
216 // ========================================
217 // GTK+ helper functions
219 // NOTE: parent can be NULL in all functions but it's best to set them
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);
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,
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,
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);
248 // ========================================
249 // read/write preferences file
251 // use this function to get the directory where the preferences file are stored
252 typedef const char* (WINAPI* PFN_QERAPP_PROFILE_GETDIR) ();
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);
264 //=========================================
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)
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.
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.
282 //++timo NOTE : the #defines here are never used, but can help finding where things are done in the editor
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"
309 #define QERAPP_TEXTURECOUNT "QERApp_TextureCount"
310 #define QERAPP_GETTEXTURE "QERApp_GetTexture"
311 #define QERAPP_GETCURRENTTEXTURE "QERApp_GetCurrentTexture"
312 #define QERAPP_SETCURRENTTEXTURE "QERApp_SetCurrentTexture"
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
321 #define QERAPP_GETPOINTS "QERApp_GetPoints"
322 #define QERAPP_SELECTBRUSHES "QERApp_GetBrushes"
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"
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"
336 #define QERAPP_LOADTEXTURERGBA "QERApp_LoadTextureRGBA"
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"
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"
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"
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"
392 #define QERAPP_GETDISPATCHPARAMS "QERApp_GetDispatchParams"
402 char m_TextureName[QER_MAX_NAMELEN];
409 vec3_t m_v1, m_v2, m_v3;
410 // brush primitive additions
412 brushprimit_texdef_t brushprimit_texdef;
415 typedef void (WINAPI * PFN_QERAPP_CREATEBRUSH)(vec3_t vMin, vec3_t vMax);
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);
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
433 typedef void (WINAPI * PFN_QERAPP_DELETESELECTION)();
434 typedef void (WINAPI * PFN_QERAPP_GETPOINTS)(int nMax, _QERPointData *pData, char* pMsg);
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);
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);
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);
451 typedef void (WINAPI * PFN_QERAPP_REGISTERMAPLOAD)(void* vp);
452 typedef void (WINAPI * PFN_QERAPP_REGISTERMAPSAVE)(void* vp);
454 typedef int (WINAPI * PFN_QERAPP_GETECLASSCOUNT)();
455 typedef char* (WINAPI * PFN_QERAPP_GETECLASS)(int nIndex);
457 typedef void (WINAPI * PFN_QERAPP_RESETPLUGINS)();
458 //--typedef int (WINAPI* PFN_QERAPP_GETENTITYCOUNT)();
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
469 typedef qtexture_t* (* PFN_QERAPP_LOADTEXTURERGBA)(unsigned char* pPixels, int nWidth, int nHeight);
471 //--typedef LPCSTR (WINAPI* PFN_QERAPP_GETENTITY)(int nIndex);
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);
494 typedef void (WINAPI * PFN_QERAPP_GETDISPATCHPARAMS)(vec3_t vMin, vec3_t vMax, bool *bSingleBrush);
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)();
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);
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, ...);
551 typedef void (WINAPI* PFN_QERAPP_SYSBEGINWAIT) ();
552 typedef void (WINAPI* PFN_QERAPP_SYSENDWAIT) ();
554 typedef void (* PFN_QERAPP_SYSBEEP) ();
556 typedef void (* PFN_QERAPP_SYSSTATUS) (const char *psz, int part );
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) ();
569 typedef void (* PFN_QERAPP_SYSSETTITLE) (const char *text);
571 typedef void (* PFN_QERAPP_CSGMAKEHOLLOW) ();
573 typedef void (* PFN_QERAPP_REGIONSPAWNPOINT) (FILE *f);
576 access to a portable GetTickCount
578 typedef unsigned long (* PFN_QERAPP_GETTICKCOUNT) ();
583 virtual ~IModelCache() { }
584 virtual entity_interfaces_t *GetByID(const char *id, const char* version) = 0;
585 virtual void DeleteByID(const char *id, const char* version) = 0;
586 virtual void RefreshAll() = 0;
589 typedef IModelCache* (* PFN_GETMODELCACHE)();
594 virtual ~IFileTypeList() { }
595 virtual void addType(filetype_t type) = 0;
598 class IFileTypeRegistry
601 virtual ~IFileTypeRegistry() { }
602 virtual void addType(const char* key, filetype_t type) = 0;
603 virtual void getTypeList(const char* key, IFileTypeList* typelist) = 0;
607 typedef IFileTypeRegistry* (* PFN_GETFILETYPEREGISTRY)();
609 typedef const char* (* PFN_QERAPP_READPROJECTKEY)(const char* key);
611 typedef char* (* PFN_GETMAPFILENAME)();
614 // add map format extensions
615 // add texture format handlers
616 // add surface dialog handler
617 // add model handler/displayer
620 // Plugins need to declare one of these and implement the getfunctable as described above
621 struct _QERFuncTable_1
624 PFN_QERAPP_CREATEBRUSH m_pfnCreateBrush;
625 PFN_QERAPP_CREATEBRUSHHANDLE m_pfnCreateBrushHandle;
626 PFN_QERAPP_DELETEBRUSHHANDLE m_pfnDeleteBrushHandle;
627 PFN_QERAPP_COMMITBRUSHHANDLETOMAP m_pfnCommitBrushHandle;
628 PFN_QERAPP_ADDFACE m_pfnAddFace;
629 PFN_QERAPP_ADDFACEDATA m_pfnAddFaceData;
630 PFN_QERAPP_GETFACEDATA m_pfnGetFaceData;
631 PFN_QERAPP_GETFACECOUNT m_pfnGetFaceCount;
632 PFN_QERAPP_SETFACEDATA m_pfnSetFaceData;
633 PFN_QERAPP_DELETEFACE m_pfnDeleteFace;
634 PFN_QERAPP_TEXTUREBRUSH m_pfnTextureBrush;
635 PFN_QERAPP_BUILDBRUSH m_pfnBuildBrush; // PGM
636 PFN_QERAPP_SELECTBRUSH m_pfnSelectBrush; // PGM
637 PFN_QERAPP_DESELECTBRUSH m_pfnDeselectBrush; // PGM
638 PFN_QERAPP_DESELECTALLBRUSHES m_pfnDeselectAllBrushes; // PGM
640 PFN_QERAPP_DELETESELECTION m_pfnDeleteSelection;
641 PFN_QERAPP_GETPOINTS m_pfnGetPoints;
643 PFN_QERAPP_SELECTEDBRUSHCOUNT m_pfnSelectedBrushCount;
644 PFN_QERAPP_ALLOCATESELECTEDBRUSHHANDLES m_pfnAllocateSelectedBrushHandles;
645 PFN_QERAPP_RELEASESELECTEDBRUSHHANDLES m_pfnReleaseSelectedBrushHandles;
646 PFN_QERAPP_GETSELECTEDBRUSHHANDLE m_pfnGetSelectedBrushHandle;
648 PFN_QERAPP_ACTIVEBRUSHCOUNT m_pfnActiveBrushCount;
649 PFN_QERAPP_ALLOCATEACTIVEBRUSHHANDLES m_pfnAllocateActiveBrushHandles;
650 PFN_QERAPP_RELEASEACTIVEBRUSHHANDLES m_pfnReleaseActiveBrushHandles;
651 PFN_QERAPP_GETACTIVEBRUSHHANDLE m_pfnGetActiveBrushHandle;
653 //++timo this would need to be removed and replaced by the IShaders interface
654 PFN_QERAPP_TEXTURECOUNT m_pfnTextureCount;
655 PFN_QERAPP_GETTEXTURE m_pfnGetTexture;
656 PFN_QERAPP_GETCURRENTTEXTURE m_pfnGetCurrentTexture;
657 PFN_QERAPP_SETCURRENTTEXTURE m_pfnSetCurrentTexture;
659 PFN_QERAPP_GETECLASSCOUNT m_pfnGetEClassCount;
660 PFN_QERAPP_GETECLASS m_pfnGetEClass;
661 PFN_QERAPP_RESETPLUGINS m_pfnResetPlugins;
664 PFN_QERAPP_LOADTEXTURERGBA m_pfnLoadTextureRGBA;
667 PFN_QERAPP_GETENTITYCOUNT m_pfnGetEntityCount;
668 PFN_QERAPP_GETENTITYHANDLE m_pfnGetEntityHandle;
669 PFN_QERAPP_ALLOCATEENTITYBRUSHHANDLES m_pfnAllocateEntityBrushHandles;
670 PFN_QERAPP_RELEASEENTITYBRUSHHANDLES m_pfnReleaseEntityBrushHandles;
671 PFN_QERAPP_GETENTITYBRUSHHANDLE m_pfnGetEntityBrushHandle;
672 PFN_QERAPP_CREATEENTITYHANDLE m_pfnCreateEntityHandle;
673 PFN_QERAPP_COMMITBRUSHHANDLETOENTITY m_pfnCommitBrushHandleToEntity;
674 PFN_QERAPP_COMMITENTITYHANDLETOMAP m_pfnCommitEntityHandleToMap;
675 PFN_QERAPP_ALLOCATEEPAIR m_pfnAllocateEpair;
676 PFN_QERAPP_SETSCREENUPDATE m_pfnSetScreenUpdate;
677 PFN_QERAPP_BUILDBRUSH2 m_pfnBuildBrush2;
680 PFN_QERAPP_GETDISPATCHPARAMS m_pfnGetDispatchParams;
682 // plugins can request additional interfaces
683 PFN_QERAPP_REQUESTINTERFACE m_pfnRequestInterface;
684 PFN_QERAPP_ERROR m_pfnError;
685 // loading a file into a buffer
686 PFN_QERAPP_LOADFILE m_pfnLoadFile;
687 PFN_QERAPP_EXPANDRELETIVEPATH m_pfnExpandReletivePath;
688 PFN_QERAPP_QECONVERTDOSTOUNIXNAME m_pfnQE_ConvertDOSToUnixName;
689 PFN_QERAPP_HASSHADER m_pfnHasShader;
690 PFN_QERAPP_TEXTURELOADSKIN m_pfnTexture_LoadSkin;
691 PFN_QERAPP_GETGAMEPATH m_pfnGetGamePath;
692 PFN_QERAPP_GETQERPATH m_pfnGetQERPath;
693 PFN_QERAPP_GETGAMEFILE m_pfnGetGameFile;
695 PFN_QERAPP_ALLOCATEACTIVEPATCHHANDLES m_pfnAllocateActivePatchHandles;
696 PFN_QERAPP_ALLOCATESELECTEDPATCHHANDLES m_pfnAllocateSelectedPatchHandles;
697 PFN_QERAPP_RELEASEPATCHHANDLES m_pfnReleasePatchHandles;
698 PFN_QERAPP_GETPATCHDATA m_pfnGetPatchData;
699 PFN_QERAPP_GETPATCHHANDLE m_pfnGetPatchHandle;
700 PFN_QERAPP_DELETEPATCH m_pfnDeletePatch;
701 PFN_QERAPP_CREATEPATCHHANDLE m_pfnCreatePatchHandle;
702 PFN_QERAPP_COMMITPATCHHANDLETOMAP m_pfnCommitPatchHandleToMap;
703 PFN_QERAPP_COMMITPATCHHANDLETOENTITY m_pfnCommitPatchHandleToEntity;
705 PFN_QERAPP_LOADIMAGE m_pfnLoadImage;
708 PFN_QERAPP_MESSAGEBOX m_pfnMessageBox;
709 PFN_QERAPP_FILEDIALOG m_pfnFileDialog;
710 PFN_QERAPP_DIRDIALOG m_pfnDirDialog;
711 PFN_QERAPP_COLORDIALOG m_pfnColorDialog;
712 PFN_QERAPP_LOADBITMAP m_pfnLoadBitmap;
715 PFN_QERAPP_PROFILE_GETDIR m_pfnProfileGetDirectory;
716 PFN_QERAPP_PROFILE_SAVEINT m_pfnProfileSaveInt;
717 PFN_QERAPP_PROFILE_SAVESTR m_pfnProfileSaveString;
718 PFN_QERAPP_PROFILE_LOADINT m_pfnProfileLoadInt;
719 PFN_QERAPP_PROFILE_LOADSTR m_pfnProfileLoadString;
722 PFN_QERAPP_SYSUPDATEWINDOWS m_pfnSysUpdateWindows;
723 PFN_QERAPP_SYSBEEP m_pfnSysBeep;
724 PFN_QERAPP_SYSPRINTF m_pfnSysPrintf;
725 PFN_QERAPP_SYSFPRINTF m_pfnSysFPrintf;
726 PFN_QERAPP_SYSBEGINWAIT m_pfnSysBeginWait;
727 PFN_QERAPP_SYSENDWAIT m_pfnSysEndWait;
728 PFN_QERAPP_SYSSETTITLE m_pfnSys_SetTitle;
729 PFN_QERAPP_SYSSTATUS m_pfnSys_Status;
731 // some core functionality on the map
732 PFN_QERAPP_MAPNEW m_pfnMapNew;
733 PFN_QERAPP_MAPFREE m_pfnMapFree;
734 PFN_QERAPP_MAPBUILDBRUSHDATA m_pfnMapBuildBrushData;
735 PFN_QERAPP_MAPISBRUSHFILTERED m_pfnMap_IsBrushFiltered;
736 PFN_QERAPP_MAPSTARTPOSITION m_pfnMapStartPosition;
737 PFN_QERAPP_MAPREGIONOFF m_pfnMapRegionOff;
738 PFN_QERAPP_SETBUILDWINDINGSNOTEXBUILD m_pfnSetBuildWindingsNoTexBuild;
739 // PFN_QERAPP_SAVEASDIALOG m_pfnSaveAsDialog;
740 PFN_QERAPP_POINTFILECLEAR m_pfnPointFileClear;
742 // FIXME TTimo prolly want to move that somewhere else
743 PFN_QERAPP_CSGMAKEHOLLOW m_pfnCSG_MakeHollow;
745 PFN_QERAPP_REGIONSPAWNPOINT m_pfnRegionSpawnPoint;
746 PFN_QERAPP_GETTICKCOUNT m_pfnQGetTickCount;
747 PFN_GETMODELCACHE m_pfnGetModelCache;
748 PFN_GETFILETYPEREGISTRY m_pfnGetFileTypeRegistry;
750 PFN_QERAPP_READPROJECTKEY m_pfnReadProjectKey;
752 // digibob from the old _QERAppBSPFrontendTable table
753 PFN_GETMAPFILENAME m_pfnGetMapName;
756 // macros to access those faster in plugins
757 #ifdef USE_QERTABLE_DEFINE
758 #ifndef __QERTABLENAME
759 #define __QERTABLENAME g_FuncTable
761 #define CSG_MakeHollow __QERTABLENAME.m_pfnCSG_MakeHollow
762 #define Sys_Beep __QERTABLENAME.m_pfnSysBeep
763 #define Sys_Printf __QERTABLENAME.m_pfnSysPrintf
764 #define Sys_FPrintf __QERTABLENAME.m_pfnSysFPrintf
765 #define Sys_BeginWait __QERTABLENAME.m_pfnSysBeginWait
766 #define Sys_EndWait __QERTABLENAME.m_pfnSysEndWait
767 #define Sys_UpdateWindows __QERTABLENAME.m_pfnSysUpdateWindows
768 #define Sys_SetTitle __QERTABLENAME.m_pfnSys_SetTitle
769 #define Sys_Status __QERTABLENAME.m_pfnSys_Status
770 #define Select_Deselect __QERTABLENAME.m_pfnDeselectAllBrushes
771 #define Map_New __QERTABLENAME.m_pfnMapNew
772 #define Map_Free __QERTABLENAME.m_pfnMapFree
773 #define Map_IsBrushFiltered __QERTABLENAME.m_pfnMap_IsBrushFiltered
774 #define Map_BuildBrushData __QERTABLENAME.m_pfnMapBuildBrushData
775 #define Map_StartPosition __QERTABLENAME.m_pfnMapStartPosition
776 #define Map_RegionOff __QERTABLENAME.m_pfnMapRegionOff
777 #define QE_ConvertDOSToUnixName __QERTABLENAME.m_pfnQE_ConvertDOSToUnixName
778 #define SetBuildWindingsNoTexBuild __QERTABLENAME.m_pfnSetBuildWindingsNoTexBuild
779 //#define SaveAsDialog __QERTABLENAME.m_pfnSaveAsDialog
780 #define Pointfile_Clear __QERTABLENAME.m_pfnPointFileClear
781 #define SetScreenUpdate __QERTABLENAME.m_pfnSetScreenUpdate
782 #define Region_SpawnPoint __QERTABLENAME.m_pfnRegionSpawnPoint
783 #define QGetTickCount __QERTABLENAME.m_pfnGetTickCount
784 #define GetModelCache __QERTABLENAME.m_pfnGetModelCache
785 #define GetFileTypeRegistry __QERTABLENAME.m_pfnGetFileTypeRegistry
787 IFileTypeRegistry* GetFileTypeRegistry();