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
22 // PlugInManager.cpp: implementation of the CPlugInManager class.
24 //////////////////////////////////////////////////////////////////////
27 #if defined ( __linux__ ) || defined ( __APPLE__ )
43 #include "pluginmanager.h"
50 CRadiantImageManager g_ImageManager;
51 CRadiantPluginManager g_PluginsManager;
53 _QERPlugSurfaceTable g_SurfaceTable;
54 _QERFileSystemTable g_FileSystemTable;
55 _QERShadersTable g_ShadersTable;
56 _QERPlugMapTable g_MapTable;
57 _QERPlugMapTable g_MapTable2;
58 _QEREntityTable g_EntityTable;
59 _EClassTable g_EClassDefTable;
62 extending entity class formats
63 this approach only allows a single additional format, but it is enough for now
65 bool g_bHaveEClassExt = false;
66 _EClassTable g_EClassExtTable;
69 filetype_t g_pattern_all( "all files", "*.*" );
70 filetype_t g_pattern_projqe4v2( "qe4 v2 project files", "*.qe4" );
71 filetype_t g_pattern_projxml( "xml project files", "*.proj" );
72 filetype_t g_pattern_mapq3( "quake3 maps", "*.map" );
73 filetype_t g_pattern_mapxml( "xml quake3 maps", "*.xmap" );
74 filetype_t g_pattern_modelmd3( "md3 models", "*.md3" );
75 filetype_t g_pattern_modelmdc( "mdc models", "*.mdc" );
76 filetype_t g_pattern_modelmd2( "md2 models", "*.md2" );
77 filetype_t g_pattern_modelmdl( "mdl models", "*.mdl" );
78 //filetype_t g_pattern_modelea3("EA3 models", "*.ea3");
79 filetype_t g_pattern_soundwav( "PCM sound files", "*.wav" );
80 filetype_t g_pattern_regq3( "quake3 region", "*.reg" );
84 class RadiantFileTypeRegistry : public IFileTypeRegistry
87 virtual ~RadiantFileTypeRegistry() {}
88 virtual void addType( const char* key, filetype_t type ){
89 m_typelists[key].push_back( type );
91 virtual void getTypeList( const char* key, IFileTypeList* typelist ){
92 filetype_list_t& list_ref = m_typelists[key];
93 for ( unsigned int i = 0; i < list_ref.size(); ++i )
94 typelist->addType( list_ref[i].getType() );
97 struct filetype_copy_t
99 inline filetype_copy_t( const filetype_t other )
100 : m_name( other.name ), m_pattern( other.pattern )
102 inline filetype_t getType() const {
103 return filetype_t( m_name.c_str(), m_pattern.c_str() );
109 typedef vector<filetype_copy_t> filetype_list_t;
110 map<string_t, filetype_list_t> m_typelists;
113 static RadiantFileTypeRegistry g_patterns;
115 IFileTypeRegistry* GetFileTypeRegistry(){
119 void InitFileTypes(){
120 //GetFileTypeRegistry()->addType("project", g_pattern_projqe4v2);
121 GetFileTypeRegistry()->addType( "project", g_pattern_projxml );
123 GetFileTypeRegistry()->addType( MAP_MAJOR, g_pattern_mapq3 );
124 GetFileTypeRegistry()->addType( MAP_MAJOR, g_pattern_mapxml );
126 GetFileTypeRegistry()->addType( "region", g_pattern_regq3 );
128 GetFileTypeRegistry()->addType(MODEL_MAJOR, g_pattern_modelmd3);
129 GetFileTypeRegistry()->addType(MODEL_MAJOR, g_pattern_modelmd2);
130 GetFileTypeRegistry()->addType(MODEL_MAJOR, g_pattern_modelmdl);
131 GetFileTypeRegistry()->addType(MODEL_MAJOR, g_pattern_modelmdc);
132 //GetFileTypeRegistry()->addType(MODEL_MAJOR, g_pattern_modelea3);
135 GetFileTypeRegistry()->addType( "sound", g_pattern_soundwav );
139 class CRadiantModelModuleManager : public CSynapseAPIManager
141 typedef list<APIDescriptor_t*> APIDescriptorList;
143 APIDescriptorList mAPIs;
145 CRadiantModelModuleManager(){
146 SetMatchAPI( MODEL_MAJOR, "*" );
148 virtual ~CRadiantModelModuleManager(){
149 APIDescriptorList::iterator i;
150 for ( i = mAPIs.begin(); i != mAPIs.end(); i++ )
152 delete (_QERPlugModelTable*)( *i )->mpTable;
159 // CSynapseAPIManager interface -------------------
160 APIDescriptor_t* BuildRequireAPI( APIDescriptor_t* pAPI ){
161 APIDescriptor_t* pRequireAPI = CSynapseAPIManager::PrepareRequireAPI( pAPI );
162 pRequireAPI->mpTable = new _QERPlugModelTable;
163 ( (_QERPlugModelTable*)pRequireAPI->mpTable )->m_nSize = sizeof( _QERPlugModelTable );
164 pRequireAPI->mSize = sizeof( _QERPlugModelTable );
165 mAPIs.push_front( pRequireAPI );
169 // Model Manager specific
170 const _QERPlugModelTable* GetModelTable( const char* version ){
171 APIDescriptorList::iterator i;
172 for ( i = mAPIs.begin(); i != mAPIs.end(); i++ )
173 if ( strcmp( version, ( *i )->minor_name ) == 0 ) {
174 return ( (_QERPlugModelTable*)( *i )->mpTable );
180 CRadiantModelModuleManager g_ModelManager;
182 /*! One of these exists for each unique model ID in use */
185 friend class CModelManager;
187 CModelWrapper ( const char *id, const char* version ) : refcount( 1 ){
199 void copy( const char* id, const char* version ){
204 m_model.pRender = NULL;
205 m_model.pSelect = NULL;
206 m_model.pEdit = NULL;
208 const _QERPlugModelTable* pTable = g_ModelManager.GetModelTable( m_version.c_str() );
210 if ( pTable != NULL ) {
211 pTable->m_pfnLoadModel( &m_model, m_id.c_str() );
215 if ( m_model.pRender ) {
216 m_model.pRender->DecRef();
218 if ( m_model.pSelect ) {
219 m_model.pSelect->DecRef();
221 if ( m_model.pEdit ) {
222 m_model.pEdit->DecRef();
227 entity_interfaces_t m_model;
231 /*! Creates and tracks CModelWrapper instances.
232 Creates a new instance for each unique ID requested, keeps count of the number of
233 times an ID is being referenced, and destroys any instance that is no longer in use */
234 class CModelManager : public IModelCache
238 m_ptrs = g_ptr_array_new();
240 virtual ~CModelManager(){
241 g_ptr_array_free( m_ptrs, FALSE );
244 virtual void DeleteByID( const char *id, const char* version ){
247 for ( i = 0; i < m_ptrs->len; i++ )
249 elem = (CModelWrapper*)m_ptrs->pdata[i];
250 if ( strcmp( elem->m_version.c_str(), version ) == 0
251 && strcmp( elem->m_id.c_str(), id ) == 0
252 && --elem->refcount == 0 ) {
253 g_ptr_array_remove_index_fast( m_ptrs, i );
260 virtual entity_interfaces_t *GetByID( const char *id, const char* version ){
263 for ( i = 0; i < m_ptrs->len; i++ )
265 elem = (CModelWrapper*)m_ptrs->pdata[i];
266 if ( strcmp( elem->m_version.c_str(), version ) == 0
267 && strcmp( elem->m_id.c_str(), id ) == 0 ) {
269 return &elem->m_model;
273 elem = new CModelWrapper( id, version );
274 g_ptr_array_add( m_ptrs, elem );
276 return &elem->m_model;
279 virtual void RefreshAll(){
280 for ( unsigned int i = 0; i < m_ptrs->len; ++i )
281 ( (CModelWrapper*)m_ptrs->pdata[i] )->Refresh();
284 GPtrArray *m_ptrs; // array of CModelWrapper*
287 CModelManager g_model_cache;
289 IModelCache* GetModelCache(){
290 return &g_model_cache;
294 class CRadiantToolbarModuleManager : public CSynapseAPIManager
296 typedef list<APIDescriptor_t*> APIDescriptorList;
298 APIDescriptorList mAPIs;
300 CRadiantToolbarModuleManager(){
301 SetMatchAPI( TOOLBAR_MAJOR, "*" );
303 virtual ~CRadiantToolbarModuleManager(){
304 APIDescriptorList::iterator i;
305 for ( i = mAPIs.begin(); i != mAPIs.end(); i++ )
307 delete (_QERPlugToolbarTable*)( *i )->mpTable;
314 // CSynapseAPIManager interface -------------------
315 APIDescriptor_t* BuildRequireAPI( APIDescriptor_t* pAPI ){
316 APIDescriptor_t* pRequireAPI = CSynapseAPIManager::PrepareRequireAPI( pAPI );
317 pRequireAPI->mpTable = new _QERPlugToolbarTable;
318 ( (_QERPlugToolbarTable*)pRequireAPI->mpTable )->m_nSize = sizeof( _QERPlugToolbarTable );
319 pRequireAPI->mSize = sizeof( _QERPlugToolbarTable );
320 mAPIs.push_front( pRequireAPI );
324 // Toolbar Manager specific
325 void ConstructToolbar(){
326 APIDescriptorList::iterator i;
327 for ( i = mAPIs.begin(); i != mAPIs.end(); i++ )
328 AddItem( (_QERPlugToolbarTable*)( *i )->mpTable );
333 void AddItem( _QERPlugToolbarTable* pTable ){
334 const unsigned int count = pTable->m_pfnToolbarButtonCount();
335 for ( unsigned int i = 0; i < count; ++i )
337 const IToolbarButton* button = pTable->m_pfnGetToolbarButton( i );
338 g_pParentWnd->AddPlugInToolbarButton( button );
343 CRadiantToolbarModuleManager g_ToolbarModuleManager;
346 /* image manager ---------------------------------------- */
348 CRadiantImageManager::~CRadiantImageManager(){
349 list<CImageTableSlot *>::iterator iSlot;
350 for ( iSlot = mSlots.begin(); iSlot != mSlots.end(); iSlot++ )
357 void CImageTableSlot::InitForFillAPITable( APIDescriptor_t *pAPI ){
359 mpTable = new _QERPlugImageTable;
360 mpTable->m_nSize = sizeof( _QERPlugImageTable );
361 mpAPI->mSize = sizeof( _QERPlugImageTable );
362 mpAPI->mpTable = mpTable;
365 void CRadiantImageManager::FillAPITable( APIDescriptor_t *pAPI ){
366 CImageTableSlot *pSlot = new CImageTableSlot();
367 pSlot->InitForFillAPITable( pAPI );
368 mSlots.push_front( pSlot );
372 Loads an image by calling the module that handles the extension extracted from the filename
373 \param name The filename to load. If no extension is provided, we walk the list of supported extensions.
374 \param pic The returned image data
375 \param width The returned width of the image
376 \param height The returned height of the image
378 void CRadiantImageManager::LoadImage( const char *name, byte **pic, int *width, int *height ){
379 const char *ext = NULL;
383 len = strlen( name );
384 if ( ( len > 5 ) && ( name[len - 4] == '.' ) ) {
385 ext = &name[len - 3];
389 // if no extension is provided, start walking through the list
391 list<CImageTableSlot *>::iterator iSlot;
392 for ( iSlot = mSlots.begin(); iSlot != mSlots.end(); iSlot++ )
394 APIDescriptor_t *pAPI = ( *iSlot )->GetDescriptor();
395 fullname.Format( "%s.%s", name, pAPI->minor_name );
396 ( *iSlot )->GetTable()->m_pfnLoadImage( fullname.GetBuffer(), pic, width, height );
398 return; // this was the right extension, we loaded
404 // start walking the interfaces
405 list<CImageTableSlot *>::iterator iSlot;
406 for ( iSlot = mSlots.begin(); iSlot != mSlots.end(); iSlot++ )
408 APIDescriptor_t *pAPI = ( *iSlot )->GetDescriptor();
409 if ( !strcmp( pAPI->minor_name, ext ) ) {
410 ( *iSlot )->GetTable()->m_pfnLoadImage( name, pic, width, height );
414 Sys_FPrintf( SYS_WRN, "WARNING: no image table for extension '%s'\n", ext );
417 void CRadiantImageManager::BeginExtensionsScan(){
418 mExtScanSlot = mSlots.begin();
421 const char* CRadiantImageManager::GetNextExtension(){
422 if ( mExtScanSlot != mSlots.end() ) {
423 char *ext = ( *mExtScanSlot )->GetDescriptor()->minor_name;
430 /* plugin manager --------------------------------------- */
431 APIDescriptor_t* CRadiantPluginManager::BuildRequireAPI( APIDescriptor_t *pAPI ){
432 CPluginSlot *pSlot = new CPluginSlot( pAPI );
433 mSlots.push_front( pSlot );
434 return pSlot->GetDescriptor();
437 void CRadiantPluginManager::PopulateMenu(){
438 list<CPluginSlot *>::iterator iPlug;
439 for ( iPlug = mSlots.begin(); iPlug != mSlots.end(); iPlug++ )
441 g_pParentWnd->AddPlugInMenuItem( *iPlug );
445 void CSynapseClientRadiant::ImportMap( IDataStream *in, CPtrArray *ents, const char *type ){
446 if ( strcmp( type,"map" ) == 0 ) {
447 g_MapTable.m_pfnMap_Read( in, ents );
449 else if ( strcmp( type,"xmap" ) == 0 ) {
450 g_MapTable2.m_pfnMap_Read( in, ents );
453 Sys_FPrintf( SYS_WRN, "WARNING: no module found for map interface type '%s'\n", type );
457 void CSynapseClientRadiant::ExportMap( CPtrArray *ents, IDataStream *out, const char *type ){
458 if ( strcmp( type,"map" ) == 0 ) {
459 g_MapTable.m_pfnMap_Write( ents, out );
461 else if ( strcmp( type,"xmap" ) == 0 ) {
462 g_MapTable2.m_pfnMap_Write( ents, out );
465 Sys_FPrintf( SYS_WRN, "WARNING: no module found for map interface type '%s'\n", type );
469 CPluginSlot::CPluginSlot( APIDescriptor_t *pAPI ){
470 mpAPI = CSynapseAPIManager::PrepareRequireAPI( pAPI );
471 mpTable = new _QERPluginTable;
472 mpTable->m_nSize = sizeof( _QERPluginTable );
473 mpAPI->mSize = sizeof( _QERPluginTable );
474 mpAPI->mpTable = mpTable;
475 m_CommandStrings = NULL;
480 CPluginSlot::~CPluginSlot(){
483 while ( m_CommandStrings )
485 ::free( m_CommandStrings->data );
486 m_CommandStrings = g_slist_remove( m_CommandStrings, m_CommandStrings->data );
490 void CPluginSlot::Init(){
491 CString str = mpTable->m_pfnQERPlug_GetCommandList();
493 strcpy( cTemp, str );
494 char* token = strtok( cTemp, ",;" );
495 if ( token && *token == ' ' ) {
496 while ( *token == ' ' )
499 while ( token != NULL )
501 m_CommandStrings = g_slist_append( m_CommandStrings, strdup( token ) );
502 token = strtok( NULL, ",;" );
504 mpTable->m_pfnQERPlug_Init( NULL, (void*)g_pParentWnd->m_pWidget );
508 const char* CPluginSlot::getMenuName(){
509 return mpAPI->minor_name;
512 int CPluginSlot::getCommandCount(){
516 return g_slist_length( m_CommandStrings );
519 const char* CPluginSlot::getCommand( int n ){
523 return (char*)g_slist_nth_data( m_CommandStrings, n );
526 void CPluginSlot::addMenuID( int n ){
527 m_CommandIDs = g_slist_append( m_CommandIDs, GINT_TO_POINTER( n ) );
530 bool CPluginSlot::ownsCommandID( int n ){
533 for ( lst = m_CommandIDs; lst != NULL; lst = g_slist_next( lst ) )
535 if ( GPOINTER_TO_INT( lst->data ) == n ) {
542 void CPluginSlot::Dispatch( const char *p ){
544 if ( selected_brushes.next == &selected_brushes ) {
545 vMin[0] = vMin[1] = vMin[2] = 0;
546 VectorCopy( vMin, vMax );
550 Select_GetBounds( vMin, vMax );
552 mpTable->m_pfnQERPlug_Dispatch( p, vMin, vMax, QE_SingleBrush( true ) );
555 CRadiantPluginManager::~CRadiantPluginManager(){
556 list<CPluginSlot *>::iterator iSlot;
557 for ( iSlot = mSlots.begin(); iSlot != mSlots.end(); iSlot++ )
564 bool CRadiantPluginManager::Dispatch( int n, const char* p ){
565 list<CPluginSlot *>::iterator iPlug;
566 for ( iPlug = mSlots.begin(); iPlug != mSlots.end(); iPlug++ )
568 CPluginSlot *pPlug = *iPlug;
569 if ( pPlug->ownsCommandID( n ) ) {
570 pPlug->Dispatch( p );
577 //////////////////////////////////////////////////////////////////////
578 // Construction/Destruction
579 //////////////////////////////////////////////////////////////////////
581 CPlugInManager::CPlugInManager(){
582 PatchesMode = EActivePatches;
586 CPlugInManager::~CPlugInManager(){
590 void CPlugInManager::InitForDir( const Str &dir ){
594 path += g_strPluginsDir;
596 g_pParentWnd->GetSynapseServer().AddSearchPath( path );
598 if ( strcmp( g_strPluginsDir.GetBuffer(), g_strModulesDir.GetBuffer() ) != 0 ) {
600 path += g_strModulesDir;
602 g_pParentWnd->GetSynapseServer().AddSearchPath( path );
606 static const XMLConfigEntry_t manager_entries[] =
608 { VFS_MAJOR, SYN_REQUIRE, sizeof( g_FileSystemTable ), &g_FileSystemTable },
609 { SHADERS_MAJOR, SYN_REQUIRE, sizeof( g_ShadersTable ), &g_ShadersTable },
610 { MAP_MAJOR, SYN_REQUIRE, sizeof( g_MapTable ), &g_MapTable },
611 { ECLASS_MAJOR, SYN_REQUIRE, sizeof( g_EClassDefTable ), &g_EClassDefTable },
612 { SURFACEDIALOG_MAJOR, SYN_REQUIRE, sizeof( g_SurfaceTable ), &g_SurfaceTable },
613 { NULL, SYN_UNKNOWN, 0, NULL }
616 void CPlugInManager::Init(){
622 g_qeglobals.bBSPFrontendPlugin = false;
624 InitForDir( g_strGameToolsPath );
625 InitForDir( g_strAppPath );
627 synapse_config = g_strGameToolsPath;
628 synapse_config += "synapse.config";
629 if ( !g_pParentWnd->GetSynapseServer().Initialize( synapse_config.GetBuffer(), &Sys_Printf_VA ) ) {
630 Error( "Synpase server initialization failed (see console)\n" );
634 g_pParentWnd->GetSynapseServer().EnumerateBuiltinModule( &eclass_def );
637 g_pParentWnd->GetSynapseClient().AddAPI( RADIANT_MAJOR, NULL, sizeof( _QERFuncTable_1 ) );
638 g_pParentWnd->GetSynapseClient().AddAPI( SCRIPLIB_MAJOR, NULL, sizeof( _QERScripLibTable ) );
639 g_pParentWnd->GetSynapseClient().AddAPI( BRUSH_MAJOR, NULL, sizeof( _QERBrushTable ) );
640 g_pParentWnd->GetSynapseClient().AddAPI( APPSHADERS_MAJOR, NULL, sizeof( _QERAppShadersTable ) );
641 g_pParentWnd->GetSynapseClient().AddAPI( QGL_MAJOR, NULL, sizeof( _QERQglTable ) );
642 g_pParentWnd->GetSynapseClient().AddAPI( DATA_MAJOR, NULL, sizeof( _QERAppDataTable ) );
643 g_pParentWnd->GetSynapseClient().AddAPI( PATCH_MAJOR, NULL, sizeof( _QERPatchTable ) );
644 g_pParentWnd->GetSynapseClient().AddAPI( ECLASSMANAGER_MAJOR, NULL, sizeof( _EClassManagerTable ) );
645 g_pParentWnd->GetSynapseClient().AddAPI( SELECTEDFACE_MAJOR, NULL, sizeof( _QERSelectedFaceTable ) );
646 g_pParentWnd->GetSynapseClient().AddAPI( APPSURFACEDIALOG_MAJOR, NULL, sizeof( _QERAppSurfaceTable ) );
647 g_pParentWnd->GetSynapseClient().AddAPI( UNDO_MAJOR, NULL, sizeof( _QERUndoTable ) );
648 g_pParentWnd->GetSynapseClient().AddAPI( UI_MAJOR, NULL, sizeof( _QERUITable ) );
649 g_pParentWnd->GetSynapseClient().AddAPI( UIGTK_MAJOR, NULL, sizeof( _QERUIGtkTable ) );
650 g_pParentWnd->GetSynapseClient().AddAPI( CAMERA_MAJOR, NULL, sizeof( _QERCameraTable ) );
652 // modules configured by XML
653 if ( !g_pParentWnd->GetSynapseClient().ConfigXML( &g_pParentWnd->GetSynapseServer(), "core", manager_entries ) ) {
654 Error( "Synapse server initialization failed (see console)\n" );
657 // adding a manager is a special case that ConfigXML doesn't take care of
658 g_pParentWnd->GetSynapseServer().SelectClientConfig( "core" );
660 if ( !g_pParentWnd->GetSynapseServer().GetConfigForAPI( IMAGE_MAJOR, &minor ) ) {
661 Syn_Printf( "GetConfigForAPI '%s' failed - invalid XML config file?\n", IMAGE_MAJOR );
662 Error( "Synapse server initialization failed (see console)\n" );
664 g_ImageManager.SetMatchAPI( IMAGE_MAJOR, minor );
665 g_pParentWnd->GetSynapseClient().AddManager( &g_ImageManager );
667 // SYN_REQUIRE entries which are still hardcoded
668 g_pParentWnd->GetSynapseClient().AddAPI( MAP_MAJOR, "mapxml", sizeof( g_MapTable2 ), SYN_REQUIRE, &g_MapTable2 );
669 g_pParentWnd->GetSynapseClient().AddAPI( ENTITY_MAJOR, NULL, sizeof( g_EntityTable ), SYN_REQUIRE, &g_EntityTable );
671 // plugins: load anything that claims to be a plugin
672 // minor becomes some kind of matching pattern
673 // g_PluginsManager is an API any class, it receives several function tables as needed
674 // you can't do a SYN_PROVIDE with that, has to be a SYN_REQUIRE ?
675 g_PluginsManager.SetMatchAPI( PLUGIN_MAJOR, "*" );
676 g_pParentWnd->GetSynapseClient().AddManager( &g_PluginsManager );
677 g_pParentWnd->GetSynapseClient().AddManager( &g_ToolbarModuleManager );
678 g_pParentWnd->GetSynapseClient().AddManager( &g_ModelManager );
679 if ( !g_pParentWnd->GetSynapseServer().Resolve( &g_pParentWnd->GetSynapseClient() ) ) {
680 Error( "synapse initialization fail (see console)" );
682 g_PluginsManager.PopulateMenu();
683 g_ToolbarModuleManager.ConstructToolbar();
687 void CPlugInManager::Shutdown(){
688 g_pParentWnd->GetSynapseServer().Shutdown();
691 void CPlugInManager::Cleanup(){
694 for ( i = 0; i < m_BrushHandles.GetSize(); i++ )
696 brush_t *pb = reinterpret_cast<brush_t*>( m_BrushHandles.GetAt( i ) );
699 m_BrushHandles.RemoveAll();
701 for ( i = 0; i < m_EntityHandles.GetSize(); i++ )
703 entity_t *pe = reinterpret_cast<entity_t*>( m_EntityHandles.GetAt( i ) );
706 m_EntityHandles.RemoveAll();
709 // these are linked into the map
710 m_PatchesHandles.RemoveAll();
711 // these patches were allocated by Radiant on plugin request
712 // if the list is not empty, it means either the plugin asked for allocation and never commited them to the map
713 // in which case we are supposed to delete them
714 // or it commited them but never called m_pfnReleasePatchHandles, in case the patches may have already been
715 // erased and we are trying a second time, therefore crashing ..
716 //++timo FIXME: for now I leave a leak warning, we'd need a table to keep track of commited patches
718 if ( m_PluginPatches.GetSize() != 0 ) {
719 Sys_Printf( "WARNING: m_PluginPatches.GetSize() != 0 in CPlugInManager::Cleanup, possible leak\n" );
723 /* for (i = 0; i < m_PluginPatches.GetSize(); i++)
725 patchMesh_t *pMesh = reinterpret_cast<patchMesh_t*>(m_PluginPatches.GetAt(i));
729 m_PluginPatches.RemoveAll(); */
732 void CPlugInManager::Dispatch( int n, const char * p ){
733 g_PluginsManager.Dispatch( n, p );
736 void WINAPI QERApp_GetDispatchParams( vec3_t vMin, vec3_t vMax, bool *bSingleBrush ){
737 if ( selected_brushes.next == &selected_brushes ) {
738 vMin[0] = vMin[1] = vMin[2] = 0;
739 VectorCopy( vMin, vMax );
743 Select_GetBounds( vMin, vMax );
746 if ( bSingleBrush ) {
747 *bSingleBrush = QE_SingleBrush( true );
752 // creates a dummy brush in the active brushes list
753 // FIXME : is this one really USED ?
754 void WINAPI QERApp_CreateBrush( vec3_t vMin, vec3_t vMax ){
756 brush_t* pBrush = Brush_Create( vMin, vMax, &g_qeglobals.d_texturewin.texdef );
757 Entity_LinkBrush( world_entity, pBrush );
758 Brush_Build( pBrush );
759 Brush_AddToList( pBrush, &active_brushes );
760 Select_Brush( pBrush );
761 Sys_UpdateWindows( W_ALL );
764 void* CPlugInManager::CreateBrushHandle(){
765 brush_t *pb = Brush_Alloc();
766 pb->numberId = g_nBrushId++;
767 m_BrushHandles.Add( pb );
771 void CPlugInManager::DeleteBrushHandle( void * vp ){
772 CPtrArray* pHandles[3];
773 pHandles[0] = &m_SelectedBrushHandles;
774 pHandles[1] = &m_ActiveBrushHandles;
775 pHandles[2] = &m_BrushHandles;
777 for ( int j = 0; j < 3; j++ )
779 for ( int i = 0; i < pHandles[j]->GetSize(); i++ )
781 brush_t *pb = reinterpret_cast<brush_t*>( pHandles[j]->GetAt( i ) );
782 if ( pb == reinterpret_cast<brush_t*>( vp ) ) {
784 // only remove it from the list if it is work area
785 // this allows the selected and active list indexes to remain constant
786 // throughout a session (i.e. between an allocate and release)
787 pHandles[j]->RemoveAt( i );
790 Sys_MarkMapModified(); // PGM
797 void CPlugInManager::CommitBrushHandleToMap( void * vp ){
798 g_bScreenUpdates = false;
799 for ( int i = 0; i < m_BrushHandles.GetSize(); i++ )
801 brush_t *pb = reinterpret_cast<brush_t*>( m_BrushHandles.GetAt( i ) );
802 if ( pb == reinterpret_cast<brush_t*>( vp ) ) {
803 m_BrushHandles.RemoveAt( i );
804 Entity_LinkBrush( world_entity, pb );
806 Brush_AddToList( pb, &active_brushes );
810 g_bScreenUpdates = true;
811 Sys_UpdateWindows( W_ALL );
814 void CPlugInManager::AddFaceToBrushHandle( void * vp, vec3_t v1, vec3_t v2, vec3_t v3 ){
815 brush_t *bp = FindBrushHandle( vp );
817 face_t *f = Face_Alloc();
818 f->texdef = g_qeglobals.d_texturewin.texdef;
819 f->texdef.flags &= ~SURF_KEEP;
820 f->texdef.contents &= ~CONTENTS_KEEP;
821 f->next = bp->brush_faces;
823 VectorCopy( v1, f->planepts[0] );
824 VectorCopy( v2, f->planepts[1] );
825 VectorCopy( v3, f->planepts[2] );
829 brush_t* CPlugInManager::FindBrushHandle( void * vp ){
830 CPtrArray* pHandles[4];
831 pHandles[0] = &m_SelectedBrushHandles;
832 pHandles[1] = &m_ActiveBrushHandles;
833 pHandles[2] = &m_BrushHandles;
834 pHandles[3] = &m_EntityBrushHandles;
836 for ( int j = 0; j < 4; j++ )
838 for ( int i = 0; i < pHandles[j]->GetSize(); i++ )
840 brush_t *pb = reinterpret_cast<brush_t*>( pHandles[j]->GetAt( i ) );
841 if ( pb == reinterpret_cast<brush_t*>( vp ) ) {
849 patchMesh_t* CPlugInManager::FindPatchHandle( int index ){
850 switch ( PatchesMode )
853 case ESelectedPatches:
854 if ( index < m_PatchesHandles.GetSize() ) {
855 brush_t *pb = reinterpret_cast<brush_t *>( m_PatchesHandles.GetAt( index ) );
859 Sys_Printf( "WARNING: out of bounds in CPlugInManager::FindPatchHandle\n" );
862 case EAllocatedPatches:
863 if ( index < m_PluginPatches.GetSize() ) {
864 patchMesh_t *pPatch = reinterpret_cast<patchMesh_t *>( m_PluginPatches.GetAt( index ) );
868 Sys_Printf( "WARNING: out of bounds in CPlugInManager::FindPatchHandle\n" );
875 void* WINAPI QERApp_CreateBrushHandle(){
876 return g_pParentWnd->GetPlugInMgr().CreateBrushHandle();
879 void WINAPI QERApp_DeleteBrushHandle( void* vp ){
880 g_pParentWnd->GetPlugInMgr().DeleteBrushHandle( vp );
883 void WINAPI QERApp_CommitBrushHandleToMap( void* vp ){
884 g_pParentWnd->GetPlugInMgr().CommitBrushHandleToMap( vp );
887 void WINAPI QERApp_AddFace( void* vp, vec3_t v1, vec3_t v2, vec3_t v3 ){
888 g_pParentWnd->GetPlugInMgr().AddFaceToBrushHandle( vp, v1, v2, v3 );
891 void WINAPI QERApp_DeleteSelection(){
895 void QERApp_GetCamera( vec3_t origin, vec3_t angles ){
896 VectorCopy( g_pParentWnd->GetCamWnd()->Camera()->origin, origin );
897 VectorCopy( g_pParentWnd->GetCamWnd()->Camera()->angles, angles );
900 void QERApp_SetCamera( vec3_t origin, vec3_t angles ){
901 VectorCopy( origin, g_pParentWnd->GetCamWnd()->Camera()->origin );
902 VectorCopy( angles, g_pParentWnd->GetCamWnd()->Camera()->angles );
904 Sys_UpdateWindows( W_ALL ); // specify
905 g_pParentWnd->OnTimer();
908 void QERApp_GetCamWindowExtents( int *x, int *y, int *width, int *height ){
911 if ( g_pParentWnd->CurrentStyle() == MainFrame::eFloating ) {
912 widget = g_pParentWnd->GetCamWnd()->m_pParent;
915 widget = g_pParentWnd->GetCamWnd()->GetWidget();
918 get_window_pos( widget, x, y );
920 *width = g_pParentWnd->GetCamWnd()->Camera()->width;
921 *height = g_pParentWnd->GetCamWnd()->Camera()->height;
924 //FIXME: this AcquirePath stuff is pretty much a mess and needs cleaned up
925 bool g_bPlugWait = false;
926 bool g_bPlugOK = false;
927 int g_nPlugCount = 0;
929 void _PlugDone( bool b, int n ){
935 void WINAPI QERApp_GetPoints( int nMax, _QERPointData *pData, char* pMsg ){
936 ShowInfoDialog( pMsg );
940 // g_nPlugCount=nMax-1;
941 AcquirePath( nMax, &_PlugDone );
943 while ( g_bPlugWait )
944 gtk_main_iteration();
949 pData->m_pVectors = NULL;
951 if ( g_bPlugOK && g_nPlugCount > 0 ) {
952 pData->m_nCount = g_nPlugCount;
953 pData->m_pVectors = reinterpret_cast<vec3_t*>( qmalloc( g_nPlugCount * sizeof( vec3_t ) ) );
954 vec3_t *pOut = pData->m_pVectors;
955 for ( int i = 0; i < g_nPlugCount; i++ )
957 memcpy( pOut, &g_PathPoints[i],sizeof( vec3_t ) );
965 void CheckTexture( face_t *f ){
966 if ( !f->d_texture ) {
968 Sys_Printf( "CheckTexture: requesting %s\n", f->texdef.name );
970 f->pShader = QERApp_Shader_ForName( f->texdef.GetName() );
971 f->pShader->IncRef();
972 f->d_texture = f->pShader->getTexture();
976 // expects pData->m_TextureName to be relative to "textures/"
977 void WINAPI QERApp_AddFaceData( void* pv, _QERFaceData *pData ){
979 Sys_Printf( "FindBrushHandle..." );
981 brush_t* pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle( pv );
983 Sys_Printf( "Done\n" );
985 if ( pBrush != NULL ) {
986 face_t *f = Face_Alloc();
987 f->texdef = g_qeglobals.d_texturewin.texdef;
988 f->texdef.flags = pData->m_nFlags;
989 f->texdef.contents = pData->m_nContents;
990 f->texdef.value = pData->m_nValue;
991 f->texdef.SetName( pData->m_TextureName );
992 f->next = pBrush->brush_faces;
993 pBrush->brush_faces = f;
994 VectorCopy( pData->m_v1, f->planepts[0] );
995 VectorCopy( pData->m_v2, f->planepts[1] );
996 VectorCopy( pData->m_v3, f->planepts[2] );
997 // we might need to convert one way or the other if the input and the brush coordinates setting don't match
998 if ( pData->m_bBPrimit == true ) {
999 f->brushprimit_texdef = pData->brushprimit_texdef;
1000 if ( !g_qeglobals.m_bBrushPrimitMode ) {
1001 // before calling into the conversion, make sure we have a texture!
1004 Sys_Printf( "BrushPrimitFaceToFace..." );
1007 // convert BP to regular
1008 BrushPrimitFaceToFace( f );
1010 Sys_Printf( "Done\n" );
1017 if ( pData->m_bBPrimit != false ) {
1018 Sys_FPrintf( SYS_WRN, "non-initialized pData->m_bBPrimit in QERApp_AddFaceData\n" );
1021 f->texdef.rotate = pData->m_fRotate;
1022 f->texdef.shift[0] = pData->m_fShift[0];
1023 f->texdef.shift[1] = pData->m_fShift[1];
1024 f->texdef.scale[0] = pData->m_fScale[0];
1025 f->texdef.scale[1] = pData->m_fScale[1];
1026 if ( g_qeglobals.m_bBrushPrimitMode ) {
1029 Sys_Printf( "FaceToBrushPrimitFace..." );
1032 // convert regular to BP
1033 FaceToBrushPrimitFace( f );
1035 Sys_Printf( "Done\n" );
1039 Sys_MarkMapModified(); // PGM
1043 int WINAPI QERApp_GetFaceCount( void* pv ){
1045 brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle( pv );
1046 if ( pBrush != NULL ) {
1047 for ( face_t *f = pBrush->brush_faces ; f; f = f->next )
1055 _QERFaceData* WINAPI QERApp_GetFaceData( void* pv, int nFaceIndex ){
1056 static _QERFaceData face;
1058 brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle( pv );
1060 if ( pBrush != NULL ) {
1061 for ( face_t *f = pBrush->brush_faces ; f; f = f->next )
1065 if ( !pBrush->brush_faces ) {
1066 Sys_Printf( "Warning : pBrush->brush_faces is NULL in QERApp_GetFaceData\n" );
1071 if ( n == nFaceIndex ) {
1072 face.m_nContents = f->texdef.contents;
1073 face.m_nFlags = f->texdef.flags;
1074 face.m_nValue = f->texdef.value;
1075 if ( g_qeglobals.m_bBrushPrimitMode ) {
1076 //++timo NOTE: we may want to convert back to old format for backward compatibility with some old plugins?
1077 face.m_bBPrimit = true;
1078 face.brushprimit_texdef = f->brushprimit_texdef;
1082 face.m_fRotate = f->texdef.rotate;
1083 face.m_fScale[0] = f->texdef.scale[0];
1084 face.m_fScale[1] = f->texdef.scale[1];
1085 face.m_fShift[0] = f->texdef.shift[0];
1086 face.m_fShift[1] = f->texdef.shift[1];
1088 strcpy( face.m_TextureName, f->texdef.GetName() );
1089 VectorCopy( f->planepts[0], face.m_v1 );
1090 VectorCopy( f->planepts[1], face.m_v2 );
1091 VectorCopy( f->planepts[2], face.m_v3 );
1100 void WINAPI QERApp_SetFaceData( void* pv, int nFaceIndex, _QERFaceData *pData ){
1102 brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle( pv );
1104 if ( pBrush != NULL ) {
1105 for ( face_t *f = pBrush->brush_faces ; f; f = f->next )
1107 if ( n == nFaceIndex ) {
1108 f->texdef.flags = pData->m_nFlags;
1109 f->texdef.contents = pData->m_nContents;
1110 f->texdef.value = pData->m_nValue;
1111 f->texdef.rotate = pData->m_fRotate;
1112 f->texdef.shift[0] = pData->m_fShift[0];
1113 f->texdef.shift[1] = pData->m_fShift[1];
1114 f->texdef.scale[0] = pData->m_fScale[0];
1115 f->texdef.scale[1] = pData->m_fScale[1];
1116 //strcpy(f->texdef.name, pData->m_TextureName);
1117 f->texdef.SetName( pData->m_TextureName );
1118 VectorCopy( pData->m_v1, f->planepts[0] );
1119 VectorCopy( pData->m_v2, f->planepts[1] );
1120 VectorCopy( pData->m_v3, f->planepts[2] );
1121 Sys_MarkMapModified(); // PGM
1129 void WINAPI QERApp_DeleteFace( void* pv, int nFaceIndex ){
1131 brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle( pv );
1132 if ( pBrush != NULL ) {
1133 face_t *pPrev = pBrush->brush_faces;
1134 for ( face_t *f = pBrush->brush_faces; f; f = f->next )
1136 if ( n == nFaceIndex ) {
1137 pPrev->next = f->next;
1139 Sys_MarkMapModified(); // PGM
1150 void WINAPI QERApp_BuildBrush( void* pv ){
1151 brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle( pv );
1152 if ( pBrush != NULL ) {
1153 Brush_Build( pBrush );
1154 Sys_UpdateWindows( W_ALL );
1158 //Timo : another version with bConvert flag
1159 //++timo since 1.7 is not compatible with earlier plugin versions, remove this one and update QERApp_BuildBrush
1160 void WINAPI QERApp_BuildBrush2( void* pv, int bConvert ){
1161 brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle( pv );
1162 if ( pBrush != NULL ) {
1163 Brush_Build( pBrush, true, true, bConvert );
1164 Sys_UpdateWindows( W_ALL );
1168 void WINAPI QERApp_SelectBrush( void* pv ){
1169 brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle( pv );
1170 if ( pBrush != NULL ) {
1171 Select_Brush( pBrush, false );
1172 Sys_UpdateWindows( W_ALL );
1177 void WINAPI QERApp_DeselectBrush( void* pv ){
1178 // FIXME - implement this!
1181 void WINAPI QERApp_ResetPlugins(){
1182 g_pParentWnd->OnPluginsRefresh();
1185 void WINAPI QERApp_DeselectAllBrushes(){
1187 Sys_UpdateWindows( W_ALL );
1192 void WINAPI QERApp_TextureBrush( void* pv, char* pName ){
1193 brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle( pv );
1194 if ( pBrush != NULL ) {
1195 for ( face_t *f = pBrush->brush_faces ; f; f = f->next )
1197 //strcpy(f->texdef.name, pName);
1198 f->texdef.SetName( pName );
1200 Sys_MarkMapModified(); // PGM
1204 int WINAPI QERApp_SelectedBrushCount(){
1206 for ( brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next )
1213 int WINAPI QERApp_ActiveBrushCount(){
1215 for ( brush_t *pb = active_brushes.next ; pb != &active_brushes ; pb = pb->next )
1222 int WINAPI QERApp_AllocateSelectedBrushHandles(){
1224 for ( brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next )
1227 g_pParentWnd->GetPlugInMgr().GetSelectedHandles().Add( pb );
1232 int WINAPI QERApp_AllocateActiveBrushHandles(){
1234 for ( brush_t *pb = active_brushes.next ; pb != &active_brushes ; pb = pb->next )
1237 g_pParentWnd->GetPlugInMgr().GetActiveHandles().Add( pb );
1242 void WINAPI QERApp_ReleaseSelectedBrushHandles(){
1243 g_pParentWnd->GetPlugInMgr().GetSelectedHandles().RemoveAll();
1244 Sys_UpdateWindows( W_ALL );
1247 void WINAPI QERApp_ReleaseActiveBrushHandles(){
1248 g_pParentWnd->GetPlugInMgr().GetActiveHandles().RemoveAll();
1249 Sys_UpdateWindows( W_ALL );
1252 void* WINAPI QERApp_GetActiveBrushHandle( int nIndex ){
1253 if ( nIndex < g_pParentWnd->GetPlugInMgr().GetActiveHandles().GetSize() ) {
1254 return reinterpret_cast<void*>( g_pParentWnd->GetPlugInMgr().GetActiveHandles().GetAt( nIndex ) );
1259 void* WINAPI QERApp_GetSelectedBrushHandle( int nIndex ){
1260 if ( nIndex < g_pParentWnd->GetPlugInMgr().GetSelectedHandles().GetSize() ) {
1261 return reinterpret_cast<void*>( g_pParentWnd->GetPlugInMgr().GetSelectedHandles().GetAt( nIndex ) );
1266 int WINAPI QERApp_TextureCount(){
1267 //++timo TODO: replace by QERApp_GetActiveShaderCount and verify
1273 IShader *pShader = Texture_NextPos( &x, &y );
1282 char* WINAPI QERApp_GetTexture( int nIndex ){
1283 //++timo TODO: replace by QERApp_ActiveShader_ForIndex
1284 // these funcs would end up being provided for backward compatibility
1285 static char name[QER_MAX_NAMELEN];
1291 IShader *pShader = Texture_NextPos( &x, &y );
1295 if ( n == nIndex ) {
1296 strcpy( name, pShader->getName() );
1304 char* WINAPI QERApp_GetCurrentTexture(){
1305 static char current_tex[1024];
1306 strcpy( current_tex,g_qeglobals.d_texturewin.texdef.GetName() );
1310 void WINAPI QERApp_SetCurrentTexture( char* strName ){
1311 //++timo hu ?? tex is not initialized ?? can be any value ..
1313 //++timo added a brushprimit_texdef ..
1314 // smthg to be done here
1315 brushprimit_texdef_t brushprimit_tex;
1316 //strcpy(tex.name, strName);
1317 tex.SetName( strName );
1318 Texture_SetTexture( &tex,&brushprimit_tex );
1321 int WINAPI QERApp_GetEClassCount(){
1323 for ( eclass_t *e = eclass ; e ; e = e->next )
1330 char* WINAPI QERApp_GetEClass( int nIndex ){
1332 for ( eclass_t *e = eclass ; e ; e = e->next )
1334 if ( n == nIndex ) {
1342 // world_entity holds the worldspawn and is indexed as 0
1343 // other entities are in the entities doubly linked list
1344 // QERApp_GetEntityCount counts the entities like in any C array: [0..length-1]
1345 int WINAPI QERApp_GetEntityCount(){
1347 for ( entity_t *pe = entities.next ; pe != &entities ; pe = pe->next )
1354 // We don't store entities in CPtrArray, we need to walk the list
1355 void* WINAPI QERApp_GetEntityHandle( int nIndex ){
1356 if ( nIndex == 0 ) {
1357 // looks for the worldspawn
1358 return static_cast<void*>( world_entity );
1360 entity_t *pe = &entities;
1362 while ( n < nIndex )
1367 return static_cast<void*>( pe );
1370 epair_t* WINAPI QERApp_AllocateEpair( const char *key, const char *val ){
1371 epair_t *e = (epair_t*)qmalloc( sizeof( *e ) );
1372 e->key = (char*)qmalloc( strlen( key ) + 1 );
1373 strcpy( e->key, key );
1374 e->value = (char*)qmalloc( strlen( val ) + 1 );
1375 strcpy( e->value, val );
1380 IEpair* WINAPI QERApp_IEpairForEntityHandle(void *vp)
1382 entity_t *pe = static_cast<entity_t *>(vp);
1383 CEpairsWrapper *pEp = new CEpairsWrapper(pe);
1388 IEpair* WINAPI QERApp_IEpairForProjectKeys()
1390 CEpairsWrapper *pEp = new CEpairsWrapper(g_qeglobals.d_project_entity);
1396 int WINAPI QERApp_AllocateEntityBrushHandles( void* vp ){
1397 entity_t *pe = static_cast<entity_t *>( vp );
1399 if ( !pe->brushes.onext ) {
1402 g_pParentWnd->GetPlugInMgr().GetEntityBrushHandles().RemoveAll();
1403 for ( brush_t *pb = pe->brushes.onext ; pb != &pe->brushes ; pb = pb->onext )
1406 g_pParentWnd->GetPlugInMgr().GetEntityBrushHandles().Add( pb );
1411 void WINAPI QERApp_ReleaseEntityBrushHandles(){
1412 g_pParentWnd->GetPlugInMgr().GetEntityBrushHandles().RemoveAll();
1415 void* WINAPI QERApp_GetEntityBrushHandle( int nIndex ){
1416 if ( nIndex < g_pParentWnd->GetPlugInMgr().GetEntityBrushHandles().GetSize() ) {
1417 return g_pParentWnd->GetPlugInMgr().GetEntityBrushHandles().GetAt( nIndex );
1422 // FIXME TTimo that entity handles thing sucks .. we should get rid of it ..
1424 void* WINAPI QERApp_CreateEntityHandle(){
1425 entity_t *pe = reinterpret_cast<entity_t*>( qmalloc( sizeof( entity_t ) ) );
1426 pe->brushes.onext = pe->brushes.oprev = &pe->brushes;
1427 g_pParentWnd->GetPlugInMgr().GetEntityHandles().Add( static_cast<void*>( pe ) );
1428 return static_cast<void*>( pe );
1431 // the vpBrush needs to be in m_BrushHandles
1432 //++timo we don't have allocation nor storage for vpEntity, no checks for this one
1433 void WINAPI QERApp_CommitBrushHandleToEntity( void* vpBrush, void* vpEntity ){
1434 g_pParentWnd->GetPlugInMgr().CommitBrushHandleToEntity( vpBrush, vpEntity );
1438 const char* QERApp_ReadProjectKey( const char* key ){
1439 return ValueForKey( g_qeglobals.d_project_entity, key );
1442 #ifdef USEPLUGINENTITIES
1444 int WINAPI QERApp_ScanFileForEClass( char *filename ){
1445 // set single class parsing
1446 parsing_single = true;
1447 Eclass_ScanFile( filename );
1448 if ( eclass_found ) {
1449 eclass_e->nShowFlags |= ECLASS_PLUGINENTITY;
1454 #endif // USEPLUGINENTITIES
1456 // the vpBrush needs to be in m_BrushHandles
1457 //++timo add a debug check to see if we found the brush handle
1458 // NOTE : seems there's no way to check vpEntity is valid .. this is dangerous
1459 // links the brush to its entity, everything else is done when commiting the entity to the map
1460 void CPlugInManager::CommitBrushHandleToEntity( void* vpBrush, void* vpEntity ){
1463 for ( int i = 0 ; i < m_BrushHandles.GetSize() ; i++ )
1465 if ( vpBrush == m_BrushHandles.GetAt( i ) ) {
1466 m_BrushHandles.RemoveAt( i );
1467 pb = reinterpret_cast<brush_t*>( vpBrush );
1468 pe = reinterpret_cast<entity_t *>( vpEntity );
1469 Entity_LinkBrush( pe, pb );
1472 Sys_UpdateWindows( W_ALL );
1475 // the vpEntity must be in m_EntityHandles
1476 void WINAPI QERApp_CommitEntityHandleToMap( void* vpEntity ){
1477 g_pParentWnd->GetPlugInMgr().CommitEntityHandleToMap( vpEntity );
1481 int WINAPI QERApp_LoadFile( const char *pLocation, void ** buffer ){
1482 int nSize = vfsLoadFile( pLocation, buffer, 0 );
1486 char * WINAPI QERApp_ExpandReletivePath( char *p ){
1487 return ExpandReletivePath( p );
1490 qtexture_t* WINAPI QERApp_Texture_ForName( const char *name ){
1491 // if the texture is not loaded yet, this call will get it loaded
1492 // but: when we assign a GL bind number, we need to be in the g_qeglobals.d_xxxBase GL context
1493 // the plugin may set the GL context to whatever he likes, but then load would fail
1494 // NOTE: is context switching time-consuming? then maybe the plugin could handle the context
1495 // switch and only add a sanity check in debug mode here
1496 // read current context
1497 gtk_glwidget_make_current( g_qeglobals_gui.d_glBase );
1500 Sys_Printf( "WARNING: QERApp_Texture_ForName ... don't call that!!\n" );
1501 qtexture_t* qtex = QERApp_Texture_ForName2( name );
1505 char* QERApp_Token(){
1509 int QERApp_ScriptLine(){
1513 // we save the map and return the name .. either .map or .reg to support region compiling
1514 char* QERApp_GetMapName(){
1515 static char name[PATH_MAX];
1516 SaveWithRegion( name );
1520 void CPlugInManager::CommitEntityHandleToMap( void* vpEntity ){
1526 for ( int i = 0 ; i < m_EntityHandles.GetSize() ; i++ )
1528 if ( vpEntity == m_EntityHandles.GetAt( i ) ) {
1529 m_EntityHandles.RemoveAt( i );
1530 pe = reinterpret_cast<entity_t*>( vpEntity );
1531 // fill additional fields
1532 // straight copy from Entity_Parse
1534 GetVectorForKey( pe, "origin", pe->origin );
1536 if ( pe->brushes.onext == &pe->brushes ) {
1537 has_brushes = false;
1542 e = Eclass_ForName( ValueForKey( pe, "classname" ), has_brushes );
1545 if ( e->fixedsize ) {
1546 if ( pe->brushes.onext != &pe->brushes ) {
1547 Sys_Printf( "Warning : Fixed size entity with brushes in CPlugInManager::CommitEntityHandleToMap\n" );
1549 // create a custom brush
1550 VectorAdd( e->mins, pe->origin, mins );
1551 VectorAdd( e->maxs, pe->origin, maxs );
1554 if (e->nShowFlags & ECLASS_MISCMODEL)
1556 char* p = ValueForKey(pe, "model");
1557 if (p != NULL && strlen(p) > 0)
1560 a = FloatForKey (pe, "angle");
1561 if (GetCachedModel(pe, p, vMin, vMax))
1563 // create a custom brush
1564 VectorAdd (pe->md3Class->mins, pe->origin, mins);
1565 VectorAdd (pe->md3Class->maxs, pe->origin, maxs);
1570 b = Brush_Create( mins, maxs, &e->texdef );
1575 vAngle[0] = vAngle[1] = 0;
1577 Brush_Rotate(b, vAngle, pe->origin, false);
1582 b->onext = pe->brushes.onext;
1583 b->oprev = &pe->brushes;
1584 pe->brushes.onext->oprev = b;
1585 pe->brushes.onext = b;
1589 if ( pe->brushes.next == &pe->brushes ) {
1590 Sys_Printf( "Warning: Brush entity with no brushes in CPlugInManager::CommitEntityHandleToMap\n" );
1594 // add brushes to the active brushes list
1595 // and build them along the way
1596 for ( b = pe->brushes.onext ; b != &pe->brushes ; b = b->onext )
1598 // convert between old brushes and brush primitive
1599 if ( g_qeglobals.m_bBrushPrimitMode ) {
1600 // we only filled the shift scale rot fields, needs conversion
1601 Brush_Build( b, true, true, true );
1605 // we are using old brushes
1608 b->next = active_brushes.next;
1609 active_brushes.next->prev = b;
1610 b->prev = &active_brushes;
1611 active_brushes.next = b;
1614 // handle worldspawn entities
1615 // if worldspawn has no brushes, use the new one
1616 if ( !strcmp( ValueForKey( pe, "classname" ), "worldspawn" ) ) {
1617 if ( world_entity && ( world_entity->brushes.onext != &world_entity->brushes ) ) {
1618 // worldspawn already has brushes
1619 Sys_Printf( "Commiting worldspawn as func_group\n" );
1620 SetKeyValue( pe, "classname", "func_group" );
1621 // add the entity to the end of the entity list
1622 pe->next = &entities;
1623 pe->prev = entities.prev;
1624 entities.prev->next = pe;
1626 g_qeglobals.d_num_entities++;
1630 // there's a worldspawn with no brushes, we assume the map is empty
1631 if ( world_entity ) {
1632 Entity_Free( world_entity );
1636 Sys_Printf( "Warning : unexpected world_entity == NULL in CommitEntityHandleToMap\n" );
1642 // add the entity to the end of the entity list
1643 pe->next = &entities;
1644 pe->prev = entities.prev;
1645 entities.prev->next = pe;
1647 g_qeglobals.d_num_entities++;
1653 void WINAPI QERApp_SetScreenUpdate( int bScreenUpdates ){
1654 g_bScreenUpdates = bScreenUpdates;
1657 texturewin_t* QERApp_QeglobalsTexturewin(){
1658 return &g_qeglobals.d_texturewin;
1661 texdef_t* QERApp_QeglobalsSavedinfo_SIInc(){
1662 return &g_qeglobals.d_savedinfo.m_SIIncrement;
1665 patchMesh_t* QERApp_GetSelectedPatch(){
1666 for ( brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next )
1668 if ( pb->patchBrush ) {
1673 Sys_Printf( "WARNING: QERApp_GetSelectedPatchTexdef called with no patch selected\n" );
1678 const char* WINAPI QERApp_GetGamePath(){
1679 return g_pGameDescription->mEnginePath.GetBuffer();
1683 \todo the name of this API should prolly be changed
1684 would also need to prompt g_strAppPath / g_strGameToolsPath independently?
1687 // changed g_strGameToolsPath to g_strAppPath
1688 const char* WINAPI QERApp_GetQERPath(){
1689 return g_strAppPath.GetBuffer();
1692 const char* WINAPI QERApp_GetGameFile(){
1693 // FIXME: Arnout: temp solution, need proper 'which game is this' indicator or a different solution for plugins/modules
1694 return g_pGameDescription->mGameFile.GetBuffer();
1697 // patches in/out -----------------------------------
1698 int WINAPI QERApp_AllocateActivePatchHandles(){
1699 return g_pParentWnd->GetPlugInMgr().AllocateActivePatchHandles();
1703 float QERApp_QeglobalsGetGridSize(){
1704 return g_qeglobals.d_gridsize;
1707 int CPlugInManager::AllocateActivePatchHandles(){
1709 for ( brush_t *pb = active_brushes.next ; pb != &active_brushes ; pb = pb->next )
1711 if ( pb->patchBrush ) {
1713 m_PatchesHandles.Add( pb );
1719 int WINAPI QERApp_AllocateSelectedPatchHandles(){
1720 return g_pParentWnd->GetPlugInMgr().AllocateSelectedPatchHandles();
1723 int CPlugInManager::AllocateSelectedPatchHandles(){
1726 PatchesMode = ESelectedPatches;
1727 for ( brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next )
1729 if ( pb->patchBrush ) {
1731 m_PatchesHandles.Add( pb );
1737 void WINAPI QERApp_ReleasePatchHandles(){
1738 g_pParentWnd->GetPlugInMgr().ReleasePatchesHandles();
1741 patchMesh_t* WINAPI QERApp_GetPatchData( int index ){
1742 static patchMesh_t patch;
1743 patchMesh_t *pPatch = g_pParentWnd->GetPlugInMgr().FindPatchHandle( index );
1745 memcpy( &patch, pPatch, sizeof( patchMesh_t ) );
1751 patchMesh_t* WINAPI QERApp_GetPatchHandle( int index ){
1752 return g_pParentWnd->GetPlugInMgr().FindPatchHandle( index );
1755 void WINAPI QERApp_DeletePatch( int index ){
1756 patchMesh_t *pPatch = g_pParentWnd->GetPlugInMgr().FindPatchHandle( index );
1758 brush_t *pb = pPatch->pSymbiot;
1759 Patch_Delete( pPatch );
1765 Sys_Printf( "Warning: QERApp_DeletePatch: FindPatchHandle failed\n" );
1769 int WINAPI QERApp_CreatePatchHandle(){
1770 return g_pParentWnd->GetPlugInMgr().CreatePatchHandle();
1773 int CPlugInManager::CreatePatchHandle(){
1774 // NOTE: we can't call the AddBrushForPatch until we have filled the patchMesh_t structure
1775 patchMesh_t *pPatch = MakeNewPatch();
1776 m_PluginPatches.Add( pPatch );
1778 PatchesMode = EAllocatedPatches;
1779 return m_PluginPatches.GetSize() - 1;
1782 void WINAPI QERApp_CommitPatchHandleToMap( int index, patchMesh_t *pMesh, char *texName ){
1784 Sys_Printf( "QERApp_CommitPatchHandleToMap %i..", index );
1786 g_pParentWnd->GetPlugInMgr().CommitPatchHandleToMap( index, pMesh, texName );
1788 Sys_Printf( "Done\n" );
1792 void WINAPI QERApp_CommitPatchHandleToEntity( int index, patchMesh_t *pMesh, char *texName, void* vpEntity ){
1794 Sys_Printf( "QERApp_CommitPatchHandleToEntity %i..", index );
1796 g_pParentWnd->GetPlugInMgr().CommitPatchHandleToEntity( index, pMesh, texName, vpEntity );
1798 Sys_Printf( "Done\n" );
1802 void CPlugInManager::CommitPatchHandleToMap( int index, patchMesh_t *pMesh, char *texName ){
1803 if ( PatchesMode == EAllocatedPatches ) {
1804 patchMesh_t *pPatch = reinterpret_cast<patchMesh_t *>( m_PluginPatches.GetAt( index ) );
1805 memcpy( pPatch, pMesh, sizeof( patchMesh_t ) );
1806 // patch texturing, if none given use current texture
1808 pPatch->pShader = QERApp_Shader_ForName( texName );
1811 pPatch->pShader = QERApp_Shader_ForName( g_qeglobals.d_texturewin.texdef.GetName() );
1813 pPatch->d_texture = pPatch->pShader->getTexture();
1814 pPatch->pShader->IncRef();
1815 g_bScreenUpdates = false;
1816 // the bLinkToWorld flag in AddBrushForPatch takes care of Brush_AddToList Entity_linkBrush and Brush_Build
1817 brush_t *pb = AddBrushForPatch( pPatch, true );
1819 g_bScreenUpdates = true;
1820 Sys_UpdateWindows( W_ALL );
1824 brush_t *pBrush = reinterpret_cast<brush_t *>( m_PatchesHandles.GetAt( index ) );
1825 patchMesh_t *pPatch = pBrush->pPatch;
1826 pPatch->width = pMesh->width;
1827 pPatch->height = pMesh->height;
1828 pPatch->contents = pMesh->contents;
1829 pPatch->flags = pMesh->flags;
1830 pPatch->value = pMesh->value;
1831 pPatch->type = pMesh->type;
1832 memcpy( pPatch->ctrl, pMesh->ctrl, sizeof( drawVert_t ) * MAX_PATCH_HEIGHT * MAX_PATCH_WIDTH );
1833 pPatch->bDirty = true;
1837 void CPlugInManager::CommitPatchHandleToEntity( int index, patchMesh_t *pMesh, char *texName, void *vpEntity ){
1838 entity_t* pe = reinterpret_cast<entity_t *>( vpEntity );
1840 if ( PatchesMode == EAllocatedPatches ) {
1841 patchMesh_t *pPatch = reinterpret_cast<patchMesh_t *>( m_PluginPatches.GetAt( index ) );
1842 memcpy( pPatch, pMesh, sizeof( patchMesh_t ) );
1843 // patch texturing, if none given use current texture
1845 pPatch->pShader = QERApp_Shader_ForName( texName );
1848 pPatch->pShader = QERApp_Shader_ForName( g_qeglobals.d_texturewin.texdef.GetName() );
1850 pPatch->d_texture = pPatch->pShader->getTexture();
1851 pPatch->pShader->IncRef();
1852 g_bScreenUpdates = false;
1853 brush_t *pb = AddBrushForPatch( pPatch, false ); // false, sp have to do the brush building/entity linking ourself
1854 Brush_AddToList( pb, &active_brushes );
1855 Entity_LinkBrush( pe, pb );
1857 g_bScreenUpdates = true;
1858 Sys_UpdateWindows( W_ALL );
1862 brush_t *pBrush = reinterpret_cast<brush_t *>( m_PatchesHandles.GetAt( index ) );
1863 patchMesh_t *pPatch = pBrush->pPatch;
1864 pPatch->width = pMesh->width;
1865 pPatch->height = pMesh->height;
1866 pPatch->contents = pMesh->contents;
1867 pPatch->flags = pMesh->flags;
1868 pPatch->value = pMesh->value;
1869 pPatch->type = pMesh->type;
1870 memcpy( pPatch->ctrl, pMesh->ctrl, sizeof( drawVert_t ) * MAX_PATCH_HEIGHT * MAX_PATCH_WIDTH );
1871 pPatch->bDirty = true;
1877 #if defined ( __linux__ ) || defined ( __APPLE__ )
1878 #include <gdk/gdkx.h>
1880 XVisualInfo* QEX_ChooseVisual( bool zbuffer ){
1881 int attrlist_z[] = { GLX_RGBA, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 16, 0};
1882 int attrlist[] = { GLX_RGBA, GLX_DOUBLEBUFFER, 0};
1886 dpy = GDK_DISPLAY();
1887 if ( dpy == NULL ) {
1888 Error( "OpenGL fatal error: Cannot get display.\n" );
1890 vi = qglXChooseVisual( dpy, DefaultScreen( dpy ), zbuffer ? attrlist_z : attrlist );
1892 Error( "OpenGL fatal error: glXChooseVisual failed.\n" );
1902 \todo FIXME TTimo broken most likely
1903 actually .. that's not enough, you have to go down for the game pack specific?
1905 const char* WINAPI QERApp_ProfileGetDirectory(){
1906 return g_strTempPath;
1909 GtkWidget* WINAPI QERApp_GetQeGlobalsGLWidget(){
1910 return g_qeglobals_gui.d_glBase;
1913 qboolean WINAPI BrushPrimitMode(){
1914 return g_qeglobals.m_bBrushPrimitMode;
1917 brush_t* WINAPI QERApp_ActiveBrushes(){
1918 return &active_brushes;
1921 brush_t* WINAPI QERApp_SelectedBrushes(){
1922 return &selected_brushes;
1925 brush_t* WINAPI QERApp_FilteredBrushes(){
1926 return &filtered_brushes;
1929 CPtrArray* WINAPI QERApp_LstSkinCache(){
1930 return &g_lstSkinCache;
1933 qtexture_t** WINAPI QERApp_QTextures(){
1934 return &g_qeglobals.d_qtextures;
1937 GHashTable* WINAPI QERApp_QTexmap(){
1938 return g_qeglobals.d_qtexmap;
1941 // a simplified version of Texture_SetTexture
1942 void WINAPI QERApp_Texture_SetTexture( texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef ){
1943 Texture_SetTexture( texdef, brushprimit_texdef );
1946 void QERApp_LoadImage( const char *name, unsigned char **pic, int *width, int *height ){
1947 g_ImageManager.LoadImage( name, pic, width, height );
1950 unsigned long QERApp_GetTickCount(){
1952 return GetTickCount();
1955 struct timezone tzp;
1956 static int basetime = 0;
1958 gettimeofday( &tp, &tzp );
1960 basetime = tp.tv_sec;
1962 return ( tp.tv_sec - basetime ) + tp.tv_usec / 1000;
1966 bool CSynapseClientRadiant::RequestAPI( APIDescriptor_t *pAPI ){
1967 if ( !strcmp( pAPI->major_name, RADIANT_MAJOR ) ) {
1968 _QERFuncTable_1* pTable = static_cast<_QERFuncTable_1*>( pAPI->mpTable );
1969 pTable->m_pfnCreateBrush = &QERApp_CreateBrush;
1970 pTable->m_pfnCreateBrushHandle = &QERApp_CreateBrushHandle;
1971 pTable->m_pfnDeleteBrushHandle = &QERApp_DeleteBrushHandle;
1972 pTable->m_pfnCommitBrushHandle = &QERApp_CommitBrushHandleToMap;
1973 pTable->m_pfnAddFace = &QERApp_AddFace;
1974 pTable->m_pfnAddFaceData = &QERApp_AddFaceData;
1975 pTable->m_pfnGetFaceData = &QERApp_GetFaceData;
1976 pTable->m_pfnGetFaceCount = &QERApp_GetFaceCount;
1977 pTable->m_pfnSetFaceData = &QERApp_SetFaceData;
1978 pTable->m_pfnDeleteFace = &QERApp_DeleteFace;
1979 pTable->m_pfnTextureBrush = &QERApp_TextureBrush;
1980 pTable->m_pfnBuildBrush = &QERApp_BuildBrush; // PGM
1981 pTable->m_pfnSelectBrush = &QERApp_SelectBrush; // PGM
1982 pTable->m_pfnDeselectBrush = &QERApp_DeselectBrush; // PGM
1983 pTable->m_pfnDeselectAllBrushes = &QERApp_DeselectAllBrushes; // PGM
1984 pTable->m_pfnDeleteSelection = &QERApp_DeleteSelection;
1985 pTable->m_pfnGetPoints = &QERApp_GetPoints;
1986 pTable->m_pfnSelectedBrushCount = &QERApp_SelectedBrushCount;
1987 pTable->m_pfnAllocateSelectedBrushHandles = &QERApp_AllocateSelectedBrushHandles;
1988 pTable->m_pfnReleaseSelectedBrushHandles = &QERApp_ReleaseSelectedBrushHandles;
1989 pTable->m_pfnGetSelectedBrushHandle = &QERApp_GetSelectedBrushHandle;
1990 pTable->m_pfnActiveBrushCount = &QERApp_ActiveBrushCount;
1991 pTable->m_pfnAllocateActiveBrushHandles = &QERApp_AllocateActiveBrushHandles;
1992 pTable->m_pfnReleaseActiveBrushHandles = &QERApp_ReleaseActiveBrushHandles;
1993 pTable->m_pfnGetActiveBrushHandle = &QERApp_GetActiveBrushHandle;
1994 pTable->m_pfnTextureCount = &QERApp_TextureCount;
1995 pTable->m_pfnGetTexture = &QERApp_GetTexture;
1996 pTable->m_pfnGetCurrentTexture = &QERApp_GetCurrentTexture;
1997 pTable->m_pfnSetCurrentTexture = &QERApp_SetCurrentTexture;
1998 pTable->m_pfnGetEClassCount = &QERApp_GetEClassCount;
1999 pTable->m_pfnGetEClass = &QERApp_GetEClass;
2000 pTable->m_pfnResetPlugins = &QERApp_ResetPlugins;
2001 pTable->m_pfnLoadTextureRGBA = &QERApp_LoadTextureRGBA;
2002 pTable->m_pfnGetEntityCount = &QERApp_GetEntityCount;
2003 pTable->m_pfnGetEntityHandle = &QERApp_GetEntityHandle;
2004 pTable->m_pfnAllocateEpair = &QERApp_AllocateEpair;
2005 pTable->m_pfnAllocateEntityBrushHandles = &QERApp_AllocateEntityBrushHandles;
2006 pTable->m_pfnReleaseEntityBrushHandles = &QERApp_ReleaseEntityBrushHandles;
2007 pTable->m_pfnGetEntityBrushHandle = &QERApp_GetEntityBrushHandle;
2008 pTable->m_pfnCreateEntityHandle = &QERApp_CreateEntityHandle;
2009 pTable->m_pfnCommitBrushHandleToEntity = &QERApp_CommitBrushHandleToEntity;
2010 pTable->m_pfnCommitEntityHandleToMap = &QERApp_CommitEntityHandleToMap;
2011 pTable->m_pfnSetScreenUpdate = &QERApp_SetScreenUpdate;
2012 pTable->m_pfnBuildBrush2 = &QERApp_BuildBrush2;
2013 pTable->m_pfnGetDispatchParams = &QERApp_GetDispatchParams;
2014 // pTable->m_pfnRequestInterface = &QERApp_RequestInterface;
2015 pTable->m_pfnError = &Error;
2016 pTable->m_pfnLoadFile = &QERApp_LoadFile;
2017 pTable->m_pfnExpandReletivePath = &QERApp_ExpandReletivePath;
2018 pTable->m_pfnQE_ConvertDOSToUnixName = &QE_ConvertDOSToUnixName;
2019 pTable->m_pfnHasShader = QERApp_HasShader;
2020 pTable->m_pfnTexture_LoadSkin = &Texture_LoadSkin;
2021 pTable->m_pfnGetGamePath = &QERApp_GetGamePath;
2022 pTable->m_pfnGetQERPath = &QERApp_GetQERPath;
2023 pTable->m_pfnGetGameFile = &QERApp_GetGameFile;
2024 pTable->m_pfnAllocateActivePatchHandles = &QERApp_AllocateActivePatchHandles;
2025 pTable->m_pfnAllocateSelectedPatchHandles = &QERApp_AllocateSelectedPatchHandles;
2026 pTable->m_pfnReleasePatchHandles = &QERApp_ReleasePatchHandles;
2027 pTable->m_pfnGetPatchData = &QERApp_GetPatchData;
2028 pTable->m_pfnGetPatchHandle = &QERApp_GetPatchHandle;
2029 pTable->m_pfnDeletePatch = &QERApp_DeletePatch;
2030 pTable->m_pfnCreatePatchHandle = &QERApp_CreatePatchHandle;
2031 pTable->m_pfnCommitPatchHandleToMap = &QERApp_CommitPatchHandleToMap;
2032 pTable->m_pfnCommitPatchHandleToEntity = &QERApp_CommitPatchHandleToEntity;
2033 pTable->m_pfnLoadImage = &QERApp_LoadImage;
2034 pTable->m_pfnMessageBox = >k_MessageBox;
2035 pTable->m_pfnFileDialog = &file_dialog;
2036 pTable->m_pfnColorDialog = &color_dialog;
2037 pTable->m_pfnDirDialog = &dir_dialog;
2038 pTable->m_pfnLoadBitmap = &load_plugin_bitmap;
2039 pTable->m_pfnProfileGetDirectory = &QERApp_ProfileGetDirectory;
2040 pTable->m_pfnProfileSaveInt = &profile_save_int;
2041 pTable->m_pfnProfileSaveString = &profile_save_string;
2042 pTable->m_pfnProfileLoadInt = &profile_load_int;
2043 pTable->m_pfnProfileLoadString = &profile_load_string;
2044 pTable->m_pfnSysUpdateWindows = &Sys_UpdateWindows;
2045 pTable->m_pfnSysPrintf = &Sys_Printf;
2046 pTable->m_pfnSysFPrintf = &Sys_FPrintf;
2047 pTable->m_pfnSysBeginWait = &Sys_BeginWait;
2048 pTable->m_pfnSysEndWait = &Sys_EndWait;
2049 pTable->m_pfnSys_SetTitle = &Sys_SetTitle;
2050 pTable->m_pfnSysBeep = &Sys_Beep;
2051 pTable->m_pfnSys_Status = &Sys_Status;
2052 pTable->m_pfnMapFree = &Map_Free;
2053 pTable->m_pfnMapNew = &Map_New;
2054 pTable->m_pfnMapBuildBrushData = &Map_BuildBrushData;
2055 pTable->m_pfnMap_IsBrushFiltered = &Map_IsBrushFiltered;
2056 pTable->m_pfnMapStartPosition = &Map_StartPosition;
2057 pTable->m_pfnMapRegionOff = &Map_RegionOff;
2058 pTable->m_pfnSetBuildWindingsNoTexBuild = &Brush_SetBuildWindingsNoTexBuild;
2059 pTable->m_pfnPointFileClear = &Pointfile_Clear;
2060 pTable->m_pfnCSG_MakeHollow = &CSG_MakeHollow;
2061 pTable->m_pfnRegionSpawnPoint = &Region_SpawnPoint;
2062 pTable->m_pfnQGetTickCount = &QERApp_GetTickCount;
2063 pTable->m_pfnGetModelCache = &GetModelCache;
2064 pTable->m_pfnGetFileTypeRegistry = &GetFileTypeRegistry;
2065 pTable->m_pfnReadProjectKey = &QERApp_ReadProjectKey;
2066 pTable->m_pfnGetMapName = &QERApp_GetMapName;
2067 pTable->m_pfnFilterAdd = &FilterCreate;
2068 pTable->m_pfnFiltersActivate = &FiltersActivate;
2072 if ( !strcmp( pAPI->major_name, SCRIPLIB_MAJOR ) ) {
2073 _QERScripLibTable *pScripLibTable = static_cast<_QERScripLibTable *>( pAPI->mpTable );
2074 pScripLibTable->m_pfnGetToken = &GetToken;
2075 pScripLibTable->m_pfnGetTokenExtra = &GetTokenExtra;
2076 pScripLibTable->m_pfnToken = &QERApp_Token;
2077 pScripLibTable->m_pfnUnGetToken = &UngetToken;
2078 pScripLibTable->m_pfnStartTokenParsing = &StartTokenParsing;
2079 pScripLibTable->m_pfnScriptLine = &QERApp_ScriptLine;
2080 pScripLibTable->m_pfnTokenAvailable = &TokenAvailable;
2081 pScripLibTable->m_pfnCOM_Parse = &COM_Parse;
2082 pScripLibTable->m_pfnGet_COM_Token = &Get_COM_Token;
2086 if ( !strcmp( pAPI->major_name, BRUSH_MAJOR ) ) {
2087 _QERBrushTable *pBrushTable = static_cast<_QERBrushTable *>( pAPI->mpTable );
2088 pBrushTable->m_pfnBP_MessageBox = &BP_MessageBox;
2089 pBrushTable->m_pfnBrush_AddToList = &Brush_AddToList;
2090 pBrushTable->m_pfnBrush_Build = &Brush_Build;
2091 pBrushTable->m_pfnBrush_Create = &Brush_Create;
2092 pBrushTable->m_pfnBrush_Free = &Brush_Free;
2093 pBrushTable->m_pfnBrush_Rotate = &Brush_Rotate;
2094 pBrushTable->m_pfnBrushAlloc = &Brush_Alloc;
2095 pBrushTable->m_pfnFace_Alloc = &Face_Alloc;
2096 pBrushTable->m_pfnHasModel = NULL; // &HasModel;
2100 if ( !strcmp( pAPI->major_name, APPSHADERS_MAJOR ) ) {
2101 _QERAppShadersTable *pShadersTable = static_cast<_QERAppShadersTable*>( pAPI->mpTable );
2102 pShadersTable->m_pfnQTextures = QERApp_QTextures;
2103 pShadersTable->m_pfnQTexmap = QERApp_QTexmap;
2104 pShadersTable->m_pfnQeglobalsTexturewin = QERApp_QeglobalsTexturewin;
2105 pShadersTable->m_pfnTexture_SetTexture = QERApp_Texture_SetTexture;
2106 pShadersTable->m_pfnTexture_ShowInuse = Texture_ShowInuse;
2107 pShadersTable->m_pfnBuildShaderList = &BuildShaderList;
2108 pShadersTable->m_pfnPreloadShaders = &PreloadShaders;
2112 if ( !strcmp( pAPI->major_name, QGL_MAJOR ) ) {
2113 _QERQglTable *pQglTable = static_cast<_QERQglTable *>( pAPI->mpTable );
2114 pQglTable->m_pfn_qglAlphaFunc = qglAlphaFunc;
2115 pQglTable->m_pfn_qglBegin = qglBegin;
2116 pQglTable->m_pfn_qglBindTexture = qglBindTexture;
2117 pQglTable->m_pfn_qglBlendFunc = qglBlendFunc;
2118 pQglTable->m_pfn_qglCallList = qglCallList;
2119 pQglTable->m_pfn_qglCallLists = qglCallLists;
2120 pQglTable->m_pfn_qglClear = qglClear;
2121 pQglTable->m_pfn_qglClearColor = qglClearColor;
2122 pQglTable->m_pfn_qglClearDepth = qglClearDepth;
2123 pQglTable->m_pfn_qglColor3f = qglColor3f;
2124 pQglTable->m_pfn_qglColor3fv = qglColor3fv;
2125 pQglTable->m_pfn_qglColor4f = qglColor4f;
2126 pQglTable->m_pfn_qglColor4fv = qglColor4fv;
2127 pQglTable->m_pfn_qglColor4ubv = qglColor4ubv;
2128 pQglTable->m_pfn_qglColorPointer = qglColorPointer;
2129 pQglTable->m_pfn_qglCullFace = qglCullFace;
2130 pQglTable->m_pfn_qglDepthFunc = qglDepthFunc;
2131 pQglTable->m_pfn_qglDepthMask = qglDepthMask;
2132 pQglTable->m_pfn_qglDisable = qglDisable;
2133 pQglTable->m_pfn_qglDisableClientState = qglDisableClientState;
2134 pQglTable->m_pfn_qglDeleteLists = qglDeleteLists;
2135 pQglTable->m_pfn_qglDeleteTextures = qglDeleteTextures;
2136 pQglTable->m_pfn_qglDrawElements = qglDrawElements;
2137 pQglTable->m_pfn_qglEnable = qglEnable;
2138 pQglTable->m_pfn_qglEnableClientState = qglEnableClientState;
2139 pQglTable->m_pfn_qglEnd = qglEnd;
2140 pQglTable->m_pfn_qglEndList = qglEndList;
2141 pQglTable->m_pfn_qglFogf = qglFogf;
2142 pQglTable->m_pfn_qglFogfv = qglFogfv;
2143 pQglTable->m_pfn_qglFogi = qglFogi;
2144 pQglTable->m_pfn_qglGenLists = qglGenLists;
2145 pQglTable->m_pfn_qglGenTextures = qglGenTextures;
2146 pQglTable->m_pfn_qglGetDoublev = qglGetDoublev;
2147 pQglTable->m_pfn_qglGetIntegerv = qglGetIntegerv;
2148 pQglTable->m_pfn_qglHint = qglHint;
2149 pQglTable->m_pfn_qglLightfv = qglLightfv;
2150 pQglTable->m_pfn_qglLineStipple = qglLineStipple;
2151 pQglTable->m_pfn_qglLineWidth = qglLineWidth;
2152 pQglTable->m_pfn_qglListBase = qglListBase;
2153 pQglTable->m_pfn_qglLoadIdentity = qglLoadIdentity;
2154 pQglTable->m_pfn_qglMaterialf = qglMaterialf;
2155 pQglTable->m_pfn_qglMaterialfv = qglMaterialfv;
2156 pQglTable->m_pfn_qglMatrixMode = qglMatrixMode;
2157 pQglTable->m_pfn_qglMultMatrixf = qglMultMatrixf;
2158 pQglTable->m_pfn_qglNewList = qglNewList;
2159 pQglTable->m_pfn_qglNormal3f = qglNormal3f;
2160 pQglTable->m_pfn_qglNormal3fv = qglNormal3fv;
2161 pQglTable->m_pfn_qglNormalPointer = qglNormalPointer;
2162 pQglTable->m_pfn_qglOrtho = qglOrtho;
2163 pQglTable->m_pfn_qglPointSize = qglPointSize;
2164 pQglTable->m_pfn_qglPolygonMode = qglPolygonMode;
2165 pQglTable->m_pfn_qglPopAttrib = qglPopAttrib;
2166 pQglTable->m_pfn_qglPopMatrix = qglPopMatrix;
2167 pQglTable->m_pfn_qglPushAttrib = qglPushAttrib;
2168 pQglTable->m_pfn_qglPushMatrix = qglPushMatrix;
2169 pQglTable->m_pfn_qglRasterPos3fv = qglRasterPos3fv;
2170 pQglTable->m_pfn_qglRotated = qglRotated;
2171 pQglTable->m_pfn_qglRotatef = qglRotatef;
2172 pQglTable->m_pfn_qglScalef = qglScalef;
2173 pQglTable->m_pfn_qglScissor = qglScissor;
2174 pQglTable->m_pfn_qglShadeModel = qglShadeModel;
2175 pQglTable->m_pfn_qglTexCoord2f = qglTexCoord2f;
2176 pQglTable->m_pfn_qglTexCoord2fv = qglTexCoord2fv;
2177 pQglTable->m_pfn_qglTexCoordPointer = qglTexCoordPointer;
2178 pQglTable->m_pfn_qglTexEnvf = qglTexEnvf;
2179 pQglTable->m_pfn_qglTexGenf = qglTexGenf;
2180 pQglTable->m_pfn_qglTexImage1D = qglTexImage1D;
2181 pQglTable->m_pfn_qglTexImage2D = qglTexImage2D;
2182 pQglTable->m_pfn_qglTexParameterf = qglTexParameterf;
2183 pQglTable->m_pfn_qglTexParameterfv = qglTexParameterfv;
2184 pQglTable->m_pfn_qglTexParameteri = qglTexParameteri;
2185 pQglTable->m_pfn_qglTexParameteriv = qglTexParameteriv;
2186 pQglTable->m_pfn_qglTexSubImage1D = qglTexSubImage1D;
2187 pQglTable->m_pfn_qglTexSubImage2D = qglTexSubImage2D;
2188 pQglTable->m_pfn_qglTranslated = qglTranslated;
2189 pQglTable->m_pfn_qglTranslatef = qglTranslatef;
2190 pQglTable->m_pfn_qglVertex2f = qglVertex2f;
2191 pQglTable->m_pfn_qglVertex3f = qglVertex3f;
2192 pQglTable->m_pfn_qglVertex3fv = qglVertex3fv;
2193 pQglTable->m_pfn_qglVertexPointer = qglVertexPointer;
2194 pQglTable->m_pfn_qglViewport = qglViewport;
2196 pQglTable->m_pfn_QE_CheckOpenGLForErrors = &QE_CheckOpenGLForErrors;
2198 pQglTable->m_pfn_qgluPerspective = qgluPerspective;
2199 pQglTable->m_pfn_qgluLookAt = qgluLookAt;
2200 pQglTable->m_pfnHookGL2DWindow = QERApp_HookGL2DWindow;
2201 pQglTable->m_pfnUnHookGL2DWindow = QERApp_UnHookGL2DWindow;
2202 pQglTable->m_pfnHookGL3DWindow = QERApp_HookGL3DWindow;
2203 pQglTable->m_pfnUnHookGL3DWindow = QERApp_UnHookGL3DWindow;
2207 if ( !strcmp( pAPI->major_name, DATA_MAJOR ) ) {
2208 _QERAppDataTable *pDataTable = static_cast<_QERAppDataTable *>( pAPI->mpTable );
2209 pDataTable->m_pfnActiveBrushes = QERApp_ActiveBrushes;
2210 pDataTable->m_pfnSelectedBrushes = QERApp_SelectedBrushes;
2211 pDataTable->m_pfnFilteredBrushes = QERApp_FilteredBrushes;
2212 pDataTable->m_pfnLstSkinCache = QERApp_LstSkinCache;
2216 if ( !strcmp( pAPI->major_name, PATCH_MAJOR ) ) {
2217 _QERPatchTable *pPatchTable = static_cast<_QERPatchTable *>( pAPI->mpTable );
2218 pPatchTable->m_pfnPatch_Alloc = &Patch_Alloc;
2219 pPatchTable->m_pfnAddBrushForPatch = &AddBrushForPatch;
2220 pPatchTable->m_pfnMakeNewPatch = &MakeNewPatch;
2224 if ( !strcmp( pAPI->major_name, ECLASSMANAGER_MAJOR ) ) {
2225 _EClassManagerTable *pEClassManTable = static_cast<_EClassManagerTable *>( pAPI->mpTable );
2227 pEClassManTable->m_pfnEclass_InsertAlphabetized = &Eclass_InsertAlphabetized;
2228 pEClassManTable->m_pfnGet_Eclass_E = &Get_EClass_E;
2229 pEClassManTable->m_pfnSet_Eclass_Found = &Set_Eclass_Found;
2230 pEClassManTable->m_pfnGet_Parsing_Single = &Get_Parsing_Single;
2231 pEClassManTable->m_pfnEClass_Create = &EClass_Create;
2232 pEClassManTable->m_pfnEclass_ForName = &Eclass_ForName;
2236 if ( !strcmp( pAPI->major_name, SELECTEDFACE_MAJOR ) ) {
2237 _QERSelectedFaceTable *pSelectedFaceTable = static_cast<_QERSelectedFaceTable *>( pAPI->mpTable );
2239 pSelectedFaceTable->m_pfnGetSelectedFaceCount = &QERApp_GetSelectedFaceCount;
2240 pSelectedFaceTable->m_pfnGetFaceBrush = &QERApp_GetSelectedFaceBrush;
2241 pSelectedFaceTable->m_pfnGetFace = &QERApp_GetSelectedFace;
2242 pSelectedFaceTable->m_pfnGetFaceInfo = &QERApp_GetFaceInfo;
2243 pSelectedFaceTable->m_pfnSetFaceInfo = &QERApp_SetFaceInfo;
2244 pSelectedFaceTable->m_pfnGetTextureNumber = &QERApp_ISelectedFace_GetTextureNumber;
2245 pSelectedFaceTable->m_pfnGetTextureSize = &QERApp_GetTextureSize;
2246 pSelectedFaceTable->m_pfnSelect_SetTexture = &Select_SetTexture;
2249 if ( !strcmp( pAPI->major_name, APPSURFACEDIALOG_MAJOR ) ) {
2250 _QERAppSurfaceTable *pSurfDialogTable = static_cast<_QERAppSurfaceTable *>( pAPI->mpTable );
2251 pSurfDialogTable->m_pfnOnlyPatchesSelected = &OnlyPatchesSelected;
2252 pSurfDialogTable->m_pfnAnyPatchesSelected = &AnyPatchesSelected;
2253 pSurfDialogTable->m_pfnGetSelectedPatch = &QERApp_GetSelectedPatch;
2254 pSurfDialogTable->m_pfnGetTwoSelectedPatch = &QERApp_GetTwoSelectedPatch;
2255 pSurfDialogTable->m_pfnTexMatToFakeTexCoords = &TexMatToFakeTexCoords;
2256 pSurfDialogTable->m_pfnConvertTexMatWithQTexture = &ConvertTexMatWithQTexture;
2257 pSurfDialogTable->m_pfnFakeTexCoordsToTexMat = &FakeTexCoordsToTexMat;
2258 pSurfDialogTable->m_pfnPatch_ResetTexturing = &Patch_ResetTexturing;
2259 pSurfDialogTable->m_pfnPatch_FitTexturing = &Patch_FitTexturing;
2260 pSurfDialogTable->m_pfnPatch_NaturalizeSelected = &Patch_NaturalizeSelected;
2261 pSurfDialogTable->m_pfnPatch_GetTextureName = &Patch_GetTextureName;
2262 pSurfDialogTable->m_pfnQE_SingleBrush = &QE_SingleBrush;
2263 pSurfDialogTable->m_pfnIsBrushPrimitMode = &IsBrushPrimitMode;
2264 pSurfDialogTable->m_pfnComputeAxisBase = &ComputeAxisBase;
2265 pSurfDialogTable->m_pfnBPMatMul = &BPMatMul;
2266 pSurfDialogTable->m_pfnEmitBrushPrimitTextureCoordinates = &EmitBrushPrimitTextureCoordinates;
2267 pSurfDialogTable->m_pfnQeglobalsTexturewin = &QERApp_QeglobalsTexturewin;
2268 pSurfDialogTable->m_pfnSelect_FitTexture = &Select_FitTexture;
2269 pSurfDialogTable->m_pfnQERApp_QeglobalsSavedinfo_SIInc = &QERApp_QeglobalsSavedinfo_SIInc;
2270 pSurfDialogTable->m_pfnQeglobalsGetGridSize = &QERApp_QeglobalsGetGridSize;
2271 pSurfDialogTable->m_pfnFaceList_FitTexture = &SI_FaceList_FitTexture;
2272 pSurfDialogTable->m_pfnGetMainWindow = &SI_GetMainWindow;
2273 pSurfDialogTable->m_pfnSetWinPos_From_Prefs = &SI_SetWinPos_from_Prefs;
2274 pSurfDialogTable->m_pfnGetSelectedFaceCountfromBrushes = &SI_GetSelectedFaceCountfromBrushes;
2275 pSurfDialogTable->m_pfnGetSelFacesTexdef = &SI_GetSelFacesTexdef;
2276 pSurfDialogTable->m_pfnSetTexdef_FaceList = &SI_SetTexdef_FaceList;
2280 if ( !strcmp( pAPI->major_name, UNDO_MAJOR ) ) {
2281 _QERUndoTable *pUndoTable = static_cast<_QERUndoTable *>( pAPI->mpTable );
2283 pUndoTable->m_pfnUndo_Start = &Undo_Start;
2284 pUndoTable->m_pfnUndo_End = &Undo_End;
2285 pUndoTable->m_pfnUndo_AddBrush = &Undo_AddBrush;
2286 pUndoTable->m_pfnUndo_EndBrush = &Undo_EndBrush;
2287 pUndoTable->m_pfnUndo_AddBrushList = &Undo_AddBrushList;
2288 pUndoTable->m_pfnUndo_EndBrushList = &Undo_EndBrushList;
2289 pUndoTable->m_pfnUndo_AddEntity = &Undo_AddEntity;
2290 pUndoTable->m_pfnUndo_EndEntity = &Undo_EndEntity;
2291 pUndoTable->m_pfnUndo_Undo = &Undo_Undo; // Nurail
2292 pUndoTable->m_pfnUndo_Redo = &Undo_Redo; // Nurail
2293 pUndoTable->m_pfnUndo_GetUndoId = &Undo_GetUndoId; // Nurail
2294 pUndoTable->m_pfnUndo_UndoAvailable = &Undo_UndoAvailable; // Nurail
2295 pUndoTable->m_pfnUndo_RedoAvailable = &Undo_RedoAvailable; // Nurail
2299 if ( !strcmp( pAPI->major_name, CAMERA_MAJOR ) ) {
2300 _QERCameraTable *pCameraTable = static_cast<_QERCameraTable *>( pAPI->mpTable );
2302 pCameraTable->m_pfnGetCamera = &QERApp_GetCamera;
2303 pCameraTable->m_pfnSetCamera = &QERApp_SetCamera;
2304 pCameraTable->m_pfnGetCamWindowExtents = &QERApp_GetCamWindowExtents;
2308 if ( !strcmp( pAPI->major_name, UI_MAJOR ) ) {
2309 _QERUITable *pUITable = static_cast<_QERUITable *>( pAPI->mpTable );
2311 pUITable->m_pfnCreateGLWindow = QERApp_CreateGLWindow;
2312 pUITable->m_pfnHookWindow = QERApp_HookWindow;
2313 pUITable->m_pfnUnHookWindow = QERApp_UnHookWindow;
2314 pUITable->m_pfnGetXYWndWrapper = QERApp_GetXYWndWrapper;
2315 pUITable->m_pfnHookListener = QERApp_HookListener;
2316 pUITable->m_pfnUnHookListener = QERApp_UnHookListener;
2320 if ( !strcmp( pAPI->major_name, UIGTK_MAJOR ) ) {
2321 _QERUIGtkTable *pUIGtkTable = static_cast<_QERUIGtkTable *>( pAPI->mpTable );
2323 pUIGtkTable->m_pfn_GetQeglobalsGLWidget = &QERApp_GetQeGlobalsGLWidget;
2324 pUIGtkTable->m_pfn_glwidget_new = >k_glwidget_new;
2325 pUIGtkTable->m_pfn_glwidget_swap_buffers = >k_glwidget_swap_buffers;
2326 pUIGtkTable->m_pfn_glwidget_make_current = >k_glwidget_make_current;
2327 pUIGtkTable->m_pfn_glwidget_destroy_context = >k_glwidget_destroy_context;
2328 pUIGtkTable->m_pfn_glwidget_create_context = >k_glwidget_create_context;
2330 pUIGtkTable->m_pfn_glwidget_get_context = >k_glwidget_get_context;
2339 const char* CSynapseClientRadiant::GetInfo(){
2340 return "Radiant - synapse core built " __DATE__ " " RADIANT_VERSION;
2343 const char* CSynapseClientRadiant::GetName(){