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
98 memset( reinterpret_cast<void*>( this ), 0, sizeof( _QERTextureLoad ) );
106 void makeSpace( int nSize ){
107 m_pRGBA = new unsigned char[nSize + 1];
110 void setName( const char* p ){
111 m_pName = new char[strlen( p ) + 1];
112 strcpy( m_pName, p );
116 unsigned char *m_pRGBA; // rgba data (alpha channel is supported and drawn appropriately)
117 int m_nWidth; // width
118 int m_nHeight; // height
119 int m_nContents; // default contents
120 int m_nFlags; // "" flags
121 int m_nValue; // "" value
122 char *m_pName; // name to be referenced in map, build tools, etc.
127 char m_ModelExtension[QER_MAX_NAMELEN];
134 // vertex and skin data
138 //=========================================
141 // NOTE TTimo: hack to make old plugin tech and new plugin tech live together
143 // toolkit-independant interface, cast hwndMain to GtkWidget*
144 typedef const char* ( WINAPI * PFN_QERPLUG_INIT )( void* hApp, void* hwndMain );
145 typedef const char* ( WINAPI * PFN_QERPLUG_GETNAME )();
146 typedef const char* ( WINAPI * PFN_QERPLUG_GETCOMMANDLIST )();
147 typedef void ( WINAPI * PFN_QERPLUG_DISPATCH )( const char* p, vec3_t vMin, vec3_t vMax, bool bSingleBrush );
151 typedef char* ( WINAPI * PFN_QERPLUG_GETFUNCTABLE )();
156 // returns a ptr to _QERTextureInfo
157 typedef void* ( WINAPI * PFN_QERPLUG_GETTEXTUREINFO )();
159 // loads a texture by calling the texture load func in the editor (defined below)
160 // transparency (for water, fog, lava, etc.. ) can be emulated in the editor
161 // by passing in appropriate alpha data or by setting the appropriate surface flags
162 // expected by q2 (which the editor will use.. )
163 typedef void ( WINAPI * PFN_QERPLUG_LOADTEXTURE )( const char* pFilename );
166 typedef void* ( WINAPI * PFN_QERPLUG_GETSURFACEFLAGS )();
169 // if exists in plugin, gets called between INIT and GETCOMMANDLIST
170 // the plugin can register the EClasses he wants to handle
171 //++timo TODO: this has got to move into the table, and be requested by QERPlug_RequestInterface
172 //++timo FIXME: the LPVOID parameter must be casted to an IEpair interface
173 #define QERPLUG_REGISTERPLUGINENTITIES "QERPlug_RegisterPluginEntities"
174 typedef void ( WINAPI * PFN_QERPLUG_REGISTERPLUGINENTITIES )( void* );
176 // if exists in plugin, gets called between INIT and GETCOMMANDLIST
177 // the plugin can Init all it needs for surface properties
178 #define QERPLUG_INITSURFACEPROPERTIES "QERPlug_InitSurfaceProperties"
179 typedef void ( WINAPI * PFN_QERPLUG_INITSURFACEPROPERTIES )();
181 // if Radiant needs to use a particular set of commands, it can request the plugin to fill a func table
182 // this is similar to PFN_QERAPP_REQUESTINTERFACE
183 #define QERPLUG_REQUESTINTERFACE "QERPlug_RequestInterface"
184 typedef int ( WINAPI * PFN_QERPLUG_REQUESTINTERFACE )( REFGUID refGUID, void* pInterface, const char *version_name );
186 // Load an image file
187 typedef void ( *PFN_QERAPP_LOADIMAGE )( const char *name, unsigned char **pic, int *width, int *height );
189 // TTimo FIXME: the logic for this is in synapse now
192 // if it exports this entry point, will be considered as a module
193 // a module is a plugin that provides some REQUIRED interfaces to Radiant, such as the shader module
194 // Radiant will call QERPLUG_LISTINTERFACES to get a list of the interfaces a given plugin implements
195 // then it will call PFN_QERPLUG_REQUESTINTERFACE to actually get them
197 // following leo's code .. looks ok to use a string to identify the various versions of a same interface
198 // obviously it would be handy to have the same string naming for the interfaces.
199 // best way would be to have the names come in when you list the interfaces
200 // NOTE: we might have a problem with the order in which the interfaces are filled in
201 // there's some kind of dependency graph, the shader module expects to find the VFS ready etc.
202 typedef struct moduleentry_s {
203 const GUID *interface_GUID;
204 const char* interface_name;
205 const char* version_name;
208 #define QERPLUG_LISTINTERFACES "QERPlug_ListInterfaces"
209 #define MAX_QERPLUG_INTERFACES 10
210 typedef int ( WINAPI * PFN_QERPLUG_LISTINTERFACES )( moduleentry_t table[MAX_QERPLUG_INTERFACES] );
212 // ========================================
213 // GTK+ helper functions
215 // NOTE: parent can be NULL in all functions but it's best to set them
217 // simple Message Box, see above for the 'type' flags
218 // toolkit-independent, cast parent ot a GtkWidget*
219 typedef gint ( WINAPI * PFN_QERAPP_MESSAGEBOX )( void *parent, const char* text,
220 const char* caption, guint32 type, const char *URL );
222 // file and directory selection functions return NULL if the user hits cancel
223 // or a gchar* string that must be g_free'd by the user
224 // - 'title' is the dialog title (can be NULL)
225 // - 'path' is used to set the initial directory (can be NULL)
226 // - 'pattern': the first pattern is for the win32 mode, then comes the Gtk pattern list, see Radiant source for samples
227 // TTimo 04/01/2001 toolkit-independant, cast parent to a GtkWidget*
228 typedef const gchar* ( *PFN_QERAPP_FILEDIALOG )( void *parent, gboolean open, const char* title,
229 const char* path, const char* pattern, const char *baseSubDir );
230 typedef gchar* ( WINAPI * PFN_QERAPP_DIRDIALOG )( void *parent, const char* title,
233 // return true if the user closed the dialog with 'Ok'
234 // 'color' is used to set the initial value and store the selected value
235 typedef bool ( WINAPI * PFN_QERAPP_COLORDIALOG )( void *parent, float *color,
238 // load a .bmp file and store the results in 'gdkpixmap' and 'mask'
239 // returns TRUE on success but even if it fails, it creates an empty pixmap
240 // NOTE: 'filename' is relative to <radiant_path>/plugins/bitmaps/
241 // TTimo 04/01/2001 toolkit-independant, cast gkpixmap to GdkPixmap and mask to GdkBitmap
242 typedef bool ( WINAPI * PFN_QERAPP_LOADBITMAP )( const char* filename, void **gdkpixmap, void **mask );
244 // ========================================
245 // read/write preferences file
247 // use this function to get the directory where the preferences file are stored
248 typedef const char* ( WINAPI * PFN_QERAPP_PROFILE_GETDIR )();
250 // 'filename' is the absolute path
251 typedef bool ( WINAPI * PFN_QERAPP_PROFILE_SAVEINT )( const char *filename, const char *section,
252 const char *key, int value );
253 typedef bool ( WINAPI * PFN_QERAPP_PROFILE_SAVESTR )( const char *filename, const char *section,
254 const char *key, const char *value );
255 typedef int ( WINAPI * PFN_QERAPP_PROFILE_LOADINT )( const char *filename, const char *section,
256 const char *key, int default_value );
257 typedef char* ( WINAPI * PFN_QERAPP_PROFILE_LOADSTR )( const char *filename, const char *section,
258 const char *key, const char *default_value );
260 //=========================================
263 // There are 3 potential brush handle lists
264 // 1. the list that contains brushes a plugin creates using CreateBrushHandle
265 // 2. the selected brush list (brushes the user has selected)
266 // 3. the active brush list (brushes in the map that are not selected)
268 // In general, the same things can be done to brush handles (face manip, delete brushhandle, etc.. ) in each
269 // list. There are a few exceptions.
270 // 1. You cannot commit a selected or active brush handle to the map. This is because it is already in the map.
271 // 2. You cannot bind brush handles from the selected or active brush list to an entity. As of v1.0 of the plugins
272 // the only way for a plugin to create entities is to create a brush handles (or a list of handles) and then bind
273 // them to an entity. This will commit the brush(s) and/or the entities to the map as well.
275 // To use the active or selected brush lists, you must first allocate them (which returns a count) and then
276 // release them when you are finish manipulating brushes in one of those lists.
278 //++timo NOTE : the #defines here are never used, but can help finding where things are done in the editor
280 // brush manipulation routines
281 #define QERAPP_CREATEBRUSH "QERApp_CreateBrush"
282 #define QERAPP_CREATEBRUSHHANDLE "QERApp_CreateBrushHandle"
283 #define QERAPP_DELETEBRUSHHANDLE "QERApp_DeleteBrushHandle"
284 #define QERAPP_COMMITBRUSHHANDLETOMAP "QERApp_CommitBrushHandleToMap"
285 //++timo not implemented .. remove
286 // #define QERAPP_BINDHANDLESTOENTITY "QERApp_BindHandlesToEntity"
287 #define QERAPP_ADDFACE "QERApp_AddFace"
288 #define QERAPP_ADDFACEDATA "QERApp_AddFaceData"
289 #define QERAPP_GETFACECOUNT "QERApp_GetFaceCount"
290 #define QERAPP_GETFACEDATA "QERApp_GetFaceData"
291 #define QERAPP_SETFACEDATA "QERApp_SetFaceData"
292 #define QERAPP_DELETEFACE "QERApp_DeleteFace"
293 #define QERAPP_TEXTUREBRUSH "QERApp_TextureBrush"
294 #define QERAPP_BUILDBRUSH "QERApp_BuildBrush" // PGM
295 #define QERAPP_SELECTEDBRUSHCOUNT "QERApp_SelectedBrushCount"
296 #define QERAPP_ALLOCATESELECTEDBRUSHHANDLES "QERApp_AllocateSelectedBrushHandles"
297 #define QERAPP_RELEASESELECTEDBRUSHHANDLES "QERApp_ReleaseSelectedBrushHandles"
298 #define QERAPP_GETSELECTEDBRUSHHANDLE "QERApp_GetSelectedBrushHandle"
299 #define QERAPP_ACTIVEBRUSHCOUNT "QERApp_ActiveBrushCount"
300 #define QERAPP_ALLOCATEACTIVEBRUSHHANDLES "QERApp_AllocateActiveBrushHandles"
301 #define QERAPP_RELEASEACTIVEBRUSHHANDLES "QERApp_ReleaseActiveBrushHandles"
302 #define QERAPP_GETACTIVEBRUSHHANDLE "QERApp_GetActiveBrushHandle"
305 #define QERAPP_TEXTURECOUNT "QERApp_TextureCount"
306 #define QERAPP_GETTEXTURE "QERApp_GetTexture"
307 #define QERAPP_GETCURRENTTEXTURE "QERApp_GetCurrentTexture"
308 #define QERAPP_SETCURRENTTEXTURE "QERApp_SetCurrentTexture"
311 #define QERAPP_DELETESELECTION "QERApp_DeleteSelection"
312 #define QERAPP_SELECTBRUSH "QERApp_SelectBrush" // PGM
313 #define QERAPP_DESELECTBRUSH "QERApp_DeselectBrush" // PGM
314 #define QERAPP_DESELECTALLBRUSHES "QERApp_DeselectAllBrushes" // PGM
317 #define QERAPP_GETPOINTS "QERApp_GetPoints"
318 #define QERAPP_SELECTBRUSHES "QERApp_GetBrushes"
320 // entity class stuff
321 // the entity handling is very basic for 1.0
322 #define QERAPP_GETECLASSCOUNT "QERApp_GetEClassCount"
323 #define QERAPP_GETECLASS "QERApp_GetEClass"
326 #define QERAPP_SYSMSG "QERApp_SysMsg"
327 #define QERAPP_INFOMSG "QERApp_InfoMsg"
328 #define QERAPP_HIDEINFOMSG "QERApp_HideInfoMsg"
329 #define QERAPP_RESET_PLUGINS "QERApp_ResetPlugins"
332 #define QERAPP_LOADTEXTURERGBA "QERApp_LoadTextureRGBA"
334 // FIXME: the following are not implemented yet
335 // hook registrations
336 #define QERAPP_REGISTER_MAPLOADFUNC "QERApp_Register_MapLoadFunc"
337 #define QERAPP_REGISTER_MAPSAVEFUNC "QERApp_Register_MapSaveFunc"
339 // FIXME: the following are not implemented yet
340 #define QERAPP_REGISTER_PROJECTLOADFUNC "QERApp_Register_ProjectLoadFunc"
341 #define QERAPP_REGISTER_MOUSEHANDLER "QERApp_Register_MouseHandler"
342 #define QERAPP_REGISTER_KEYHANDLER "QERApp_Register_KeyHandler"
344 // FIXME: new primtives do not work in v1.00
345 // primitives are new types of things in the map
346 // for instance, the Q3 curves could have been done as
347 // primitives instead of being built in
348 // it will be a plugins responsibility to hook the map load and save funcs to load
349 // and/or save any additional data (like new primitives of some type)
350 // the editor will call each registered renderer during the rendering process to repaint
351 // any primitives the plugin owns
352 // each primitive object has a temporary sibling brush that lives in the map
353 // FIXME: go backwards on this a bit.. orient it more towards the temp brush mode as it will be cleaner
354 // basically a plugin will hook the map load and save and will add the primitives to the map.. this will
355 // produce a temporary 'primitive' brush and the appropriate renderer will be called as well as the
356 // edit handler (for edge drags, sizes, rotates, etc.. ) and the vertex maker will be called when vertex
357 // mode is attemped on the brush.. there will need to be a GetPrimitiveBounds callback in the edit handler
358 // so the brush can resize appropriately as needed.. this might be the plugins responsibility to set the
359 // sibling brushes size.. it will then be the plugins responsibility to hook map save to save the primitives
360 // as the editor will discard any temp primitive brushes.. (there probably needs to be some kind of sanity check
361 // here as far as keeping the brushes and the plugin in sync.. i suppose the edit handler can deal with all of that
362 // crap but it looks like a nice place for a mess)
363 #define QERAPP_REGISTER_PRIMITIVE "QERApp_Register_Primitive"
364 #define QERAPP_REGISTER_RENDERER "QERApp_Register_Renderer"
365 #define QERAPP_REGISTER_EDITHANDLER "QERApp_Register_EditHandler"
366 #define QERAPP_REGISTER_VERTEXMAKER "QERApp_Register_VertexMaker"
367 #define QERAPP_ADDPRIMITIVE "QERApp_AddPrimitive"
370 #define QERAPP_GETENTITYCOUNT "QERApp_GetEntityCount"
371 #define QERAPP_GETENTITYHANDLE "QERApp_GetEntityHandle"
372 //++timo not implemented for the moment
373 // #define QERAPP_GETENTITYINFO "QERApp_GetEntityInfo"
374 //++timo does the keyval need some more funcs to add/remove ?
375 // get the pointer and do the changes yourself
376 #define QERAPP_ALLOCATEEPAIR "QERApp_AllocateEpair"
377 #define QERAPP_ALLOCATEENTITYBRUSHHANDLES "QERApp_AllocateEntityBrushHandles"
378 #define QERAPP_RELEASEENTITYBRUSHHANDLES "QERApp_ReleaseEntityBrushHandles"
379 #define QERAPP_GETENTITYBRUSHHANDLE "QERApp_GetEntityBrushHandle"
380 #define QERAPP_CREATEENTITYHANDLE "QERApp_CreateEntityHandle"
381 #define QERAPP_COMMITBRUSHHANDLETOENTITY "QERApp_CommitBrushHandleToEntity"
382 #define QERAPP_COMMITENTITYHANDLETOMAP "QERApp_CommitEntityHandleToMap"
383 #define QERAPP_SETSCREENUPDATE "QERApp_SetScreenUpdate"
384 #define QERAPP_BUILDBRUSH2 "QERApp_BuildBrush2"
388 #define QERAPP_GETDISPATCHPARAMS "QERApp_GetDispatchParams"
398 char m_TextureName[QER_MAX_NAMELEN];
405 vec3_t m_v1, m_v2, m_v3;
406 // brush primitive additions
408 brushprimit_texdef_t brushprimit_texdef;
411 typedef void ( WINAPI * PFN_QERAPP_CREATEBRUSH )( vec3_t vMin, vec3_t vMax );
413 typedef void* ( WINAPI * PFN_QERAPP_CREATEBRUSHHANDLE )();
414 typedef void ( WINAPI * PFN_QERAPP_DELETEBRUSHHANDLE )( void* pv );
415 typedef void ( WINAPI * PFN_QERAPP_COMMITBRUSHHANDLETOMAP )( void* pv );
416 typedef void ( WINAPI * PFN_QERAPP_ADDFACE )( void* pv, vec3_t v1, vec3_t v2, vec3_t v3 );
418 typedef void ( WINAPI * PFN_QERAPP_ADDFACEDATA )( void* pv, _QERFaceData *pData );
419 typedef int ( WINAPI * PFN_QERAPP_GETFACECOUNT )( void* pv );
420 typedef _QERFaceData* ( WINAPI * PFN_QERAPP_GETFACEDATA )( void* pv, int nFaceIndex );
421 typedef void ( WINAPI * PFN_QERAPP_SETFACEDATA )( void* pv, int nFaceIndex, _QERFaceData *pData );
422 typedef void ( WINAPI * PFN_QERAPP_DELETEFACE )( void* pv, int nFaceIndex );
423 typedef void ( WINAPI * PFN_QERAPP_TEXTUREBRUSH )( void* pv, char* pName );
424 typedef void ( WINAPI * PFN_QERAPP_BUILDBRUSH )( void* pv ); // PGM
425 typedef void ( WINAPI * PFN_QERAPP_SELECTBRUSH )( void* pv ); // PGM
426 typedef void ( WINAPI * PFN_QERAPP_DESELECTBRUSH )( void* pv ); // PGM
427 typedef void ( WINAPI * PFN_QERAPP_DESELECTALLBRUSHES )(); // PGM
429 typedef void ( WINAPI * PFN_QERAPP_DELETESELECTION )();
430 typedef void ( WINAPI * PFN_QERAPP_GETPOINTS )( int nMax, _QERPointData *pData, char* pMsg );
432 typedef int ( WINAPI * PFN_QERAPP_SELECTEDBRUSHCOUNT )();
433 typedef int ( WINAPI * PFN_QERAPP_ALLOCATESELECTEDBRUSHHANDLES )();
434 typedef void ( WINAPI * PFN_QERAPP_RELEASESELECTEDBRUSHHANDLES )();
435 typedef void* ( WINAPI * PFN_QERAPP_GETSELECTEDBRUSHHANDLE )( int nIndex );
437 typedef int ( WINAPI * PFN_QERAPP_ACTIVEBRUSHCOUNT )();
438 typedef int ( WINAPI * PFN_QERAPP_ALLOCATEACTIVEBRUSHHANDLES )();
439 typedef void ( WINAPI * PFN_QERAPP_RELEASEACTIVEBRUSHHANDLES )();
440 typedef void* ( WINAPI * PFN_QERAPP_GETACTIVEBRUSHHANDLE )( int nIndex );
442 typedef int ( WINAPI * PFN_QERAPP_TEXTURECOUNT )();
443 typedef char* ( WINAPI * PFN_QERAPP_GETTEXTURE )( int nIndex );
444 typedef char* ( WINAPI * PFN_QERAPP_GETCURRENTTEXTURE )();
445 typedef void ( WINAPI * PFN_QERAPP_SETCURRENTTEXTURE )( char* pName );
447 typedef void ( WINAPI * PFN_QERAPP_REGISTERMAPLOAD )( void* vp );
448 typedef void ( WINAPI * PFN_QERAPP_REGISTERMAPSAVE )( void* vp );
450 typedef int ( WINAPI * PFN_QERAPP_GETECLASSCOUNT )();
451 typedef char* ( WINAPI * PFN_QERAPP_GETECLASS )( int nIndex );
453 typedef void ( WINAPI * PFN_QERAPP_RESETPLUGINS )();
454 //--typedef int (WINAPI* PFN_QERAPP_GETENTITYCOUNT)();
458 \param pPixels is the raw RGBA pixel data (24bits, 8 bit depth)
459 \param nWidth image width
460 \param nHeight image height
461 this will work from the RGBA data and create a GL texture (accessed through a GL bind number)
462 it takes care of creating the mipmapping levels too
464 typedef qtexture_t* ( *PFN_QERAPP_LOADTEXTURERGBA )( unsigned char* pPixels, int nWidth, int nHeight );
466 //--typedef LPCSTR (WINAPI* PFN_QERAPP_GETENTITY)(int nIndex);
469 typedef int ( WINAPI * PFN_QERAPP_GETENTITYCOUNT )();
470 typedef void* ( WINAPI * PFN_QERAPP_GETENTITYHANDLE )( int nIndex );
471 // FIXME: those two are fairly outdated, you get the epairs
472 // but you don't have a clean epair read/write query
473 // and you rely on the C structs directly, which might go away soon
474 // ok now, stop using, it's bad for your karma (see iepairs.h instead)
475 typedef epair_t* ( WINAPI * PFN_QERAPP_ALLOCATEEPAIR )( const char*, const char* );
476 typedef int ( WINAPI * PFN_QERAPP_ALLOCATEENTITYBRUSHHANDLES )( void* vp );
477 typedef void ( WINAPI * PFN_QERAPP_RELEASEENTITYBRUSHHANDLES )();
478 typedef void* ( WINAPI * PFN_QERAPP_GETENTITYBRUSHHANDLE )( int nIndex );
479 typedef void* ( WINAPI * PFN_QERAPP_CREATEENTITYHANDLE )();
480 typedef void ( WINAPI * PFN_QERAPP_COMMITBRUSHHANDLETOENTITY )( void* vpBrush, void* vpEntity );
481 typedef void ( WINAPI * PFN_QERAPP_COMMITENTITYHANDLETOMAP )( void* vp );
482 typedef void ( WINAPI * PFN_QERAPP_SETSCREENUPDATE )( int bScreenUpdate );
483 // this one uses window flags defined in qertypes.h
484 typedef void ( WINAPI * PFN_QERAPP_SYSUPDATEWINDOWS )( int bits );
485 //++timo remove this one
486 typedef void ( WINAPI * PFN_QERAPP_BUILDBRUSH2 )( void* vp, int bConvert );
489 typedef void ( WINAPI * PFN_QERAPP_GETDISPATCHPARAMS )( vec3_t vMin, vec3_t vMax, bool *bSingleBrush );
491 typedef int ( WINAPI * PFN_QERAPP_REQUESTINTERFACE )( REFGUID, void* );
492 // use this one for errors, Radiant will stop after the "edit preferences" dialog
493 typedef void ( WINAPI * PFN_QERAPP_ERROR )( const char* pMsg, ... );
494 // use to gain read access to the project epairs
495 // FIXME: removed, accessed through QERPlug_RegisterPluginEntities with the IEpair interface
496 // typedef void (WINAPI* PFN_QERAPP_GETPROJECTEPAIR)(epair_t **);
497 // used to allocate and read a buffer
498 //++timo NOTE: perhaps this would need moving to some kind of dedicated interface
499 typedef int ( WINAPI * PFN_QERAPP_LOADFILE )( const char *pLocation, void ** buffer );
500 typedef char* ( WINAPI * PFN_QERAPP_EXPANDRELETIVEPATH )( char * );
501 typedef void ( WINAPI * PFN_QERAPP_QECONVERTDOSTOUNIXNAME )( char *dst, const char *src );
502 typedef int ( WINAPI * PFN_QERAPP_HASSHADER )( const char * );
503 typedef int ( WINAPI * PFN_QERAPP_TEXTURELOADSKIN )( char *pName, int *pnWidth, int *pnHeight );
504 // retrieves the path to the engine from the preferences dialog box
505 typedef const char* ( WINAPI * PFN_QERAPP_GETGAMEPATH )();
506 // retrieves full Radiant path
507 typedef const char* ( WINAPI * PFN_QERAPP_GETQERPATH )();
508 // retieves .game name of current active game
509 typedef const char* ( WINAPI * PFN_QERAPP_GETGAMEFILE )();
512 // NOTE: this is a bit different from the brushes in/out, no LPVOID handles this time
513 // use int indexes instead
514 // if you call AllocateActivePatchHandles, you'll be playing with active patches
515 // AllocateSelectedPatcheHandles for selected stuff
516 // a call to CreatePatchHandle will move you to a seperate index table
517 typedef int ( WINAPI * PFN_QERAPP_ALLOCATEACTIVEPATCHHANDLES )();
518 typedef int ( WINAPI * PFN_QERAPP_ALLOCATESELECTEDPATCHHANDLES )();
519 typedef void ( WINAPI * PFN_QERAPP_RELEASEPATCHHANDLES )();
520 typedef patchMesh_t* ( WINAPI * PFN_QERAPP_GETPATCHDATA )( int );
521 typedef patchMesh_t* ( WINAPI * PFN_QERAPP_GETPATCHHANDLE )( int );
522 typedef void ( WINAPI * PFN_QERAPP_DELETEPATCH )( int );
523 typedef int ( WINAPI * PFN_QERAPP_CREATEPATCHHANDLE )();
524 // when commiting, only a few patchMesh_t members are relevant:
525 // int width, height; // in control points, not patches
526 // int contents, flags, value, type;
527 // drawVert_t ctrl[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT];
528 // once you have commited the index is still available, if the patch handle was allocated by you
529 // then you can re-use the index to commit other patches .. otherwise you can change existing patches
530 // NOTE: the handle thing for plugin-allocated patches is a bit silly (nobody's perfect)
531 // TODO: change current behaviour to an index = 0 to tell Radiant to allocate, other indexes to existing patches
532 // patch is selected after a commit
533 // you can add an optional texture / shader name .. if NULL will use the current texture
534 typedef void ( WINAPI * PFN_QERAPP_COMMITPATCHHANDLETOMAP )( int, patchMesh_t* pMesh, char *texName );
535 typedef void ( WINAPI * PFN_QERAPP_COMMITPATCHHANDLETOENTITY )( int, patchMesh_t* pMesh, char *texName, void* vpEntity );
538 #define SYS_VRB 0 ///< verbose support (on/off)
539 #define SYS_STD 1 ///< standard print level - this is the default
540 #define SYS_WRN 2 ///< warnings
541 #define SYS_ERR 3 ///< error
542 #define SYS_NOCON 4 ///< no console, only print to the file (useful whenever Sys_Printf and output IS the problem)
543 typedef void ( WINAPI * PFN_QERAPP_SYSPRINTF )( const char *text, ... );
544 typedef void ( WINAPI * PFN_QERAPP_SYSFPRINTF )( int flag, const char *text, ... );
546 typedef void ( WINAPI * PFN_QERAPP_SYSBEGINWAIT )();
547 typedef void ( WINAPI * PFN_QERAPP_SYSENDWAIT )();
549 typedef void ( *PFN_QERAPP_SYSBEEP )();
551 typedef void ( *PFN_QERAPP_SYSSTATUS )( const char *psz, int part );
553 // core map functionality
554 typedef void ( *PFN_QERAPP_MAPNEW )();
555 typedef void ( *PFN_QERAPP_MAPFREE )();
556 typedef void ( *PFN_QERAPP_MAPBUILDBRUSHDATA )();
557 typedef qboolean ( *PFN_QERAPP_MAPISBRUSHFILTERED )( brush_t * );
558 typedef void ( *PFN_QERAPP_MAPSTARTPOSITION )();
559 typedef void ( *PFN_QERAPP_MAPREGIONOFF )();
560 //typedef void (* PFN_QERAPP_SAVEASDIALOG) (bool bRegion);
561 typedef void ( *PFN_QERAPP_SETBUILDWINDINGSNOTEXBUILD )( bool );
562 typedef void ( *PFN_QERAPP_POINTFILECLEAR )();
564 typedef void ( *PFN_QERAPP_SYSSETTITLE )( const char *text );
566 typedef void ( *PFN_QERAPP_CSGMAKEHOLLOW )();
568 typedef void ( *PFN_QERAPP_REGIONSPAWNPOINT )( FILE *f );
571 access to a portable GetTickCount
573 typedef unsigned long ( *PFN_QERAPP_GETTICKCOUNT )();
578 virtual ~IModelCache() { }
579 virtual entity_interfaces_t *GetByID( const char *id, const char* version ) = 0;
580 virtual void DeleteByID( const char *id, const char* version ) = 0;
581 virtual void RefreshAll() = 0;
584 typedef IModelCache* ( *PFN_GETMODELCACHE )();
589 virtual ~IFileTypeList() { }
590 virtual void addType( filetype_t type ) = 0;
593 class IFileTypeRegistry
596 virtual ~IFileTypeRegistry() { }
597 virtual void addType( const char* key, filetype_t type ) = 0;
598 virtual void getTypeList( const char* key, IFileTypeList* typelist ) = 0;
602 typedef IFileTypeRegistry* ( *PFN_GETFILETYPEREGISTRY )();
604 typedef const char* ( *PFN_QERAPP_READPROJECTKEY )( const char* key );
606 typedef char* ( *PFN_GETMAPFILENAME )();
608 typedef bfilter_t* ( *PFN_QERPLUG_FILTERADD )( int type, int bmask, const char *str, int exclude );
610 typedef void ( *PFN_QERPLUG_FILTERACTIVATE )( void );
613 // add map format extensions
614 // add texture format handlers
615 // add surface dialog handler
616 // add model handler/displayer
619 // Plugins need to declare one of these and implement the getfunctable as described above
620 struct _QERFuncTable_1
623 PFN_QERAPP_CREATEBRUSH m_pfnCreateBrush;
624 PFN_QERAPP_CREATEBRUSHHANDLE m_pfnCreateBrushHandle;
625 PFN_QERAPP_DELETEBRUSHHANDLE m_pfnDeleteBrushHandle;
626 PFN_QERAPP_COMMITBRUSHHANDLETOMAP m_pfnCommitBrushHandle;
627 PFN_QERAPP_ADDFACE m_pfnAddFace;
628 PFN_QERAPP_ADDFACEDATA m_pfnAddFaceData;
629 PFN_QERAPP_GETFACEDATA m_pfnGetFaceData;
630 PFN_QERAPP_GETFACECOUNT m_pfnGetFaceCount;
631 PFN_QERAPP_SETFACEDATA m_pfnSetFaceData;
632 PFN_QERAPP_DELETEFACE m_pfnDeleteFace;
633 PFN_QERAPP_TEXTUREBRUSH m_pfnTextureBrush;
634 PFN_QERAPP_BUILDBRUSH m_pfnBuildBrush; // PGM
635 PFN_QERAPP_SELECTBRUSH m_pfnSelectBrush; // PGM
636 PFN_QERAPP_DESELECTBRUSH m_pfnDeselectBrush; // PGM
637 PFN_QERAPP_DESELECTALLBRUSHES m_pfnDeselectAllBrushes; // PGM
639 PFN_QERAPP_DELETESELECTION m_pfnDeleteSelection;
640 PFN_QERAPP_GETPOINTS m_pfnGetPoints;
642 PFN_QERAPP_SELECTEDBRUSHCOUNT m_pfnSelectedBrushCount;
643 PFN_QERAPP_ALLOCATESELECTEDBRUSHHANDLES m_pfnAllocateSelectedBrushHandles;
644 PFN_QERAPP_RELEASESELECTEDBRUSHHANDLES m_pfnReleaseSelectedBrushHandles;
645 PFN_QERAPP_GETSELECTEDBRUSHHANDLE m_pfnGetSelectedBrushHandle;
647 PFN_QERAPP_ACTIVEBRUSHCOUNT m_pfnActiveBrushCount;
648 PFN_QERAPP_ALLOCATEACTIVEBRUSHHANDLES m_pfnAllocateActiveBrushHandles;
649 PFN_QERAPP_RELEASEACTIVEBRUSHHANDLES m_pfnReleaseActiveBrushHandles;
650 PFN_QERAPP_GETACTIVEBRUSHHANDLE m_pfnGetActiveBrushHandle;
652 //++timo this would need to be removed and replaced by the IShaders interface
653 PFN_QERAPP_TEXTURECOUNT m_pfnTextureCount;
654 PFN_QERAPP_GETTEXTURE m_pfnGetTexture;
655 PFN_QERAPP_GETCURRENTTEXTURE m_pfnGetCurrentTexture;
656 PFN_QERAPP_SETCURRENTTEXTURE m_pfnSetCurrentTexture;
658 PFN_QERAPP_GETECLASSCOUNT m_pfnGetEClassCount;
659 PFN_QERAPP_GETECLASS m_pfnGetEClass;
660 PFN_QERAPP_RESETPLUGINS m_pfnResetPlugins;
663 PFN_QERAPP_LOADTEXTURERGBA m_pfnLoadTextureRGBA;
666 PFN_QERAPP_GETENTITYCOUNT m_pfnGetEntityCount;
667 PFN_QERAPP_GETENTITYHANDLE m_pfnGetEntityHandle;
668 PFN_QERAPP_ALLOCATEENTITYBRUSHHANDLES m_pfnAllocateEntityBrushHandles;
669 PFN_QERAPP_RELEASEENTITYBRUSHHANDLES m_pfnReleaseEntityBrushHandles;
670 PFN_QERAPP_GETENTITYBRUSHHANDLE m_pfnGetEntityBrushHandle;
671 PFN_QERAPP_CREATEENTITYHANDLE m_pfnCreateEntityHandle;
672 PFN_QERAPP_COMMITBRUSHHANDLETOENTITY m_pfnCommitBrushHandleToEntity;
673 PFN_QERAPP_COMMITENTITYHANDLETOMAP m_pfnCommitEntityHandleToMap;
674 PFN_QERAPP_ALLOCATEEPAIR m_pfnAllocateEpair;
675 PFN_QERAPP_SETSCREENUPDATE m_pfnSetScreenUpdate;
676 PFN_QERAPP_BUILDBRUSH2 m_pfnBuildBrush2;
679 PFN_QERAPP_GETDISPATCHPARAMS m_pfnGetDispatchParams;
681 // plugins can request additional interfaces
682 PFN_QERAPP_REQUESTINTERFACE m_pfnRequestInterface;
683 PFN_QERAPP_ERROR m_pfnError;
684 // loading a file into a buffer
685 PFN_QERAPP_LOADFILE m_pfnLoadFile;
686 PFN_QERAPP_EXPANDRELETIVEPATH m_pfnExpandReletivePath;
687 PFN_QERAPP_QECONVERTDOSTOUNIXNAME m_pfnQE_ConvertDOSToUnixName;
688 PFN_QERAPP_HASSHADER m_pfnHasShader;
689 PFN_QERAPP_TEXTURELOADSKIN m_pfnTexture_LoadSkin;
690 PFN_QERAPP_GETGAMEPATH m_pfnGetGamePath;
691 PFN_QERAPP_GETQERPATH m_pfnGetQERPath;
692 PFN_QERAPP_GETGAMEFILE m_pfnGetGameFile;
694 PFN_QERAPP_ALLOCATEACTIVEPATCHHANDLES m_pfnAllocateActivePatchHandles;
695 PFN_QERAPP_ALLOCATESELECTEDPATCHHANDLES m_pfnAllocateSelectedPatchHandles;
696 PFN_QERAPP_RELEASEPATCHHANDLES m_pfnReleasePatchHandles;
697 PFN_QERAPP_GETPATCHDATA m_pfnGetPatchData;
698 PFN_QERAPP_GETPATCHHANDLE m_pfnGetPatchHandle;
699 PFN_QERAPP_DELETEPATCH m_pfnDeletePatch;
700 PFN_QERAPP_CREATEPATCHHANDLE m_pfnCreatePatchHandle;
701 PFN_QERAPP_COMMITPATCHHANDLETOMAP m_pfnCommitPatchHandleToMap;
702 PFN_QERAPP_COMMITPATCHHANDLETOENTITY m_pfnCommitPatchHandleToEntity;
704 PFN_QERAPP_LOADIMAGE m_pfnLoadImage;
707 PFN_QERAPP_MESSAGEBOX m_pfnMessageBox;
708 PFN_QERAPP_FILEDIALOG m_pfnFileDialog;
709 PFN_QERAPP_DIRDIALOG m_pfnDirDialog;
710 PFN_QERAPP_COLORDIALOG m_pfnColorDialog;
711 PFN_QERAPP_LOADBITMAP m_pfnLoadBitmap;
714 PFN_QERAPP_PROFILE_GETDIR m_pfnProfileGetDirectory;
715 PFN_QERAPP_PROFILE_SAVEINT m_pfnProfileSaveInt;
716 PFN_QERAPP_PROFILE_SAVESTR m_pfnProfileSaveString;
717 PFN_QERAPP_PROFILE_LOADINT m_pfnProfileLoadInt;
718 PFN_QERAPP_PROFILE_LOADSTR m_pfnProfileLoadString;
721 PFN_QERAPP_SYSUPDATEWINDOWS m_pfnSysUpdateWindows;
722 PFN_QERAPP_SYSBEEP m_pfnSysBeep;
723 PFN_QERAPP_SYSPRINTF m_pfnSysPrintf;
724 PFN_QERAPP_SYSFPRINTF m_pfnSysFPrintf;
725 PFN_QERAPP_SYSBEGINWAIT m_pfnSysBeginWait;
726 PFN_QERAPP_SYSENDWAIT m_pfnSysEndWait;
727 PFN_QERAPP_SYSSETTITLE m_pfnSys_SetTitle;
728 PFN_QERAPP_SYSSTATUS m_pfnSys_Status;
730 // some core functionality on the map
731 PFN_QERAPP_MAPNEW m_pfnMapNew;
732 PFN_QERAPP_MAPFREE m_pfnMapFree;
733 PFN_QERAPP_MAPBUILDBRUSHDATA m_pfnMapBuildBrushData;
734 PFN_QERAPP_MAPISBRUSHFILTERED m_pfnMap_IsBrushFiltered;
735 PFN_QERAPP_MAPSTARTPOSITION m_pfnMapStartPosition;
736 PFN_QERAPP_MAPREGIONOFF m_pfnMapRegionOff;
737 PFN_QERAPP_SETBUILDWINDINGSNOTEXBUILD m_pfnSetBuildWindingsNoTexBuild;
738 // PFN_QERAPP_SAVEASDIALOG m_pfnSaveAsDialog;
739 PFN_QERAPP_POINTFILECLEAR m_pfnPointFileClear;
741 // FIXME TTimo prolly want to move that somewhere else
742 PFN_QERAPP_CSGMAKEHOLLOW m_pfnCSG_MakeHollow;
744 PFN_QERAPP_REGIONSPAWNPOINT m_pfnRegionSpawnPoint;
745 PFN_QERAPP_GETTICKCOUNT m_pfnQGetTickCount;
746 PFN_GETMODELCACHE m_pfnGetModelCache;
747 PFN_GETFILETYPEREGISTRY m_pfnGetFileTypeRegistry;
749 PFN_QERAPP_READPROJECTKEY m_pfnReadProjectKey;
751 PFN_QERPLUG_FILTERACTIVATE m_pfnFiltersActivate;
752 PFN_QERPLUG_FILTERADD m_pfnFilterAdd;
754 // digibob from the old _QERAppBSPFrontendTable table
755 PFN_GETMAPFILENAME m_pfnGetMapName;
758 // macros to access those faster in plugins
759 #ifdef USE_QERTABLE_DEFINE
760 #ifndef __QERTABLENAME
761 #define __QERTABLENAME g_FuncTable
763 #define CSG_MakeHollow __QERTABLENAME.m_pfnCSG_MakeHollow
764 #define Sys_Beep __QERTABLENAME.m_pfnSysBeep
765 #define Sys_Printf __QERTABLENAME.m_pfnSysPrintf
766 #define Sys_FPrintf __QERTABLENAME.m_pfnSysFPrintf
767 #define Sys_BeginWait __QERTABLENAME.m_pfnSysBeginWait
768 #define Sys_EndWait __QERTABLENAME.m_pfnSysEndWait
769 #define Sys_UpdateWindows __QERTABLENAME.m_pfnSysUpdateWindows
770 #define Sys_SetTitle __QERTABLENAME.m_pfnSys_SetTitle
771 #define Sys_Status __QERTABLENAME.m_pfnSys_Status
772 #define Select_Deselect __QERTABLENAME.m_pfnDeselectAllBrushes
773 #define Map_New __QERTABLENAME.m_pfnMapNew
774 #define Map_Free __QERTABLENAME.m_pfnMapFree
775 #define Map_IsBrushFiltered __QERTABLENAME.m_pfnMap_IsBrushFiltered
776 #define Map_BuildBrushData __QERTABLENAME.m_pfnMapBuildBrushData
777 #define Map_StartPosition __QERTABLENAME.m_pfnMapStartPosition
778 #define Map_RegionOff __QERTABLENAME.m_pfnMapRegionOff
779 #define QE_ConvertDOSToUnixName __QERTABLENAME.m_pfnQE_ConvertDOSToUnixName
780 #define SetBuildWindingsNoTexBuild __QERTABLENAME.m_pfnSetBuildWindingsNoTexBuild
781 //#define SaveAsDialog __QERTABLENAME.m_pfnSaveAsDialog
782 #define Pointfile_Clear __QERTABLENAME.m_pfnPointFileClear
783 #define SetScreenUpdate __QERTABLENAME.m_pfnSetScreenUpdate
784 #define Region_SpawnPoint __QERTABLENAME.m_pfnRegionSpawnPoint
785 #define QGetTickCount __QERTABLENAME.m_pfnGetTickCount
786 #define GetModelCache __QERTABLENAME.m_pfnGetModelCache
787 #define GetFileTypeRegistry __QERTABLENAME.m_pfnGetFileTypeRegistry
789 IFileTypeRegistry* GetFileTypeRegistry();