]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - contrib/bobtoolz/bobToolz-GTK.cpp
* applied patch by StefanV (from mailinglist) that fixes an error in config.py (broke...
[xonotic/netradiant.git] / contrib / bobtoolz / bobToolz-GTK.cpp
index b0940e0842a951e48d527a21a4df4d2becc21e41..d824df5402b7d040dcb33a64d15ac7d681001309 100644 (file)
@@ -17,38 +17,29 @@ License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
-#include "libxml/parser.h"
-
-
-#include "str.h"
+#include "StdAfx.h"
 
 #include "funchandlers.h"
+#include "misc.h"
 
 #include "dialogs/dialogs-gtk.h"
 #include "../../libs/cmdlib.h"
 
-void BobToolz_construct()
-{
-}
-
-void BobToolz_destroy()
-{
-}
-
 // Radiant function table
-_QERFuncTable_1                          __QERTABLENAME;
-_QERShadersTable                 __SHADERSTABLENAME;                   // vvvvvvvvvvvvvvvvvvvv
-_QERQglTable                             __QGLTABLENAME;                               // for path plotting (hooking to DBobView)
+_QERFuncTable_1                          g_FuncTable;
+_QERAppDataTable                 g_AppDataTable;
+_QERBrushTable                   g_BrushTable;
+_QERShadersTable                 g_ShadersTable;                       // vvvvvvvvvvvvvvvvvvvv
+_QERSelectedFaceTable g_SelectedFaceTable;     // to get texture sizes
+_QERQglTable                             g_QglTable;                           // for path plotting (hooking to DBobView)
 _QERUITable                                      g_MessageTable;                       // for path plotting (listening for update)
-_QEREntityTable                          __ENTITYTABLENAME;
-_QERBrushTable                   __BRUSHTABLENAME;
-_QERPatchTable                   __PATCHTABLENAME;
+_QEREntityTable                          g_EntityTable;
 
 // plugin name
-char* PLUGIN_NAME = "bobToolz";
+const char* PLUGIN_NAME = "bobToolz";
 
 // commands in the menu
-static char* PLUGIN_COMMANDS = "About...,-,Reset Textures...,PitOMatic,-,Vis Viewer,Brush Cleanup,Polygon Builder,Caulk Selection,-,Tree Planter,Drop Entity,Plot Splines,-,Merge Patches,Split patches,Turn edge";
+static const char* PLUGIN_COMMANDS = "About...,-,Reset Textures...,PitOMatic,-,Vis Viewer,Brush Cleanup,Polygon Builder,Caulk Selection,-,Tree Planter,Drop Entity,Plot Splines,-,Merge Patches,Split patches,Turn edge";
 
 // globals
 GtkWidget *g_pRadiantWnd = NULL;
@@ -76,32 +67,32 @@ extern "C" const char* QERPlug_GetCommandList() {
 extern "C" void QERPlug_Dispatch (const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush) {
        LoadLists();
 
-       if( string_equal_nocase( p, "brush cleanup" ) ) {
+       if( !stricmp( p, "brush cleanup" ) ) {
     DoFixBrushes();
-  } else if( string_equal_nocase( p, "polygon builder" ) ) {
+  } else if( !stricmp( p, "polygon builder" ) ) {
     DoPolygonsTB();
-  } else if( string_equal_nocase( p, "caulk selection" ) ) {
+  } else if( !stricmp( p, "caulk selection" ) ) {
     DoCaulkSelection();
-  } else if( string_equal_nocase( p, "tree planter" ) ) {
+  } else if( !stricmp( p, "tree planter" ) ) {
     DoTreePlanter();
-  } else if( string_equal_nocase( p, "plot splines" ) ) {
+  } else if( !stricmp( p, "plot splines" ) ) {
     DoTrainPathPlot();
-  } else if( string_equal_nocase( p, "drop entity" ) ) {
+  } else if( !stricmp( p, "drop entity" ) ) {
     DoDropEnts();
-  } else if( string_equal_nocase( p, "merge patches" ) ) {
+  } else if( !stricmp( p, "merge patches" ) ) {
     DoMergePatches();
-  } else if( string_equal_nocase( p, "split patches" ) ) {
+  } else if( !stricmp( p, "split patches" ) ) {
     DoSplitPatch();
-  } else if( string_equal_nocase( p, "turn edge" ) ) {
+  } else if( !stricmp( p, "turn edge" ) ) {
     DoFlipTerrain();
-  } else if( string_equal_nocase(p, "reset textures...") ) {
+  } else if( !stricmp(p, "reset textures...") ) {
                DoResetTextures();
-       } else if( string_equal_nocase(p, "pitomatic") ) {
-               DoPitBuilder();
-       } else if( string_equal_nocase(p, "vis viewer") ) {
+       } else if( !stricmp(p, "pitomatic") ) {
+               DoPitBuilder(vMin, vMax);
+       } else if( !stricmp(p, "vis viewer") ) {
                DoVisAnalyse();
-       } else if( string_equal_nocase(p, "about...") ) {
-               DoMessageBox(PLUGIN_ABOUT, "About", eMB_OK);
+       } else if( !stricmp(p, "about...") ) {
+               DoMessageBox(PLUGIN_ABOUT, "About", IDOK);
        }
 }
 
@@ -117,14 +108,14 @@ GtkWidget* new_pixmap (char* filename) {
        GdkBitmap *mask;
        GtkWidget *pixmap;
 
-       g_FuncTable.m_pfnLoadBitmap(filename, (void **)&gdkpixmap, (void **)&mask);     
+       g_FuncTable.m_pfnLoadBitmap(filename, (void **)&gdkpixmap, (void **)&mask);
        pixmap = gtk_pixmap_new (gdkpixmap, mask);
 
        gdk_pixmap_unref (gdkpixmap);
        gdk_pixmap_unref (mask);
 
        return pixmap;
-} 
+}
 
 class CBobtoolzToolbarButton : public IToolbarButton
 {
@@ -149,7 +140,7 @@ public:
     switch( mIndex ) {
       case 3: return eToggleButton;
       default: return eButton;
-    }    
+    }
   }
   virtual const char* getText() const
   {
@@ -213,26 +204,28 @@ const IToolbarButton* GetToolbarButton(unsigned int index)
 // =============================================================================
 // SYNAPSE
 
-#include "synapse.h"
-
 class CSynapseClientBobtoolz : public CSynapseClient
 {
 public:
   // CSynapseClient API
   bool RequestAPI(APIDescriptor_t *pAPI);
   const char* GetInfo();
-  
+
   CSynapseClientBobtoolz() { }
   virtual ~CSynapseClientBobtoolz() { }
 };
 
-#define BOBTOOLZ_MINOR "bobtoolz"
 
 CSynapseServer* g_pSynapseServer = NULL;
 CSynapseClientBobtoolz g_SynapseClient;
 
-extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)
-{
+#if __GNUC__ >= 4
+#pragma GCC visibility push(default)
+#endif
+extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {
+#if __GNUC__ >= 4
+#pragma GCC visibility pop
+#endif
   if (strcmp(version, SYNAPSE_VERSION))
   {
     Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
@@ -241,17 +234,17 @@ extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const
   g_pSynapseServer = pServer;
   g_pSynapseServer->IncRef();
   Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
-    
+
   g_SynapseClient.AddAPI(TOOLBAR_MAJOR, BOBTOOLZ_MINOR, sizeof(_QERPlugToolbarTable));
   g_SynapseClient.AddAPI(PLUGIN_MAJOR, BOBTOOLZ_MINOR, sizeof(_QERPluginTable));
 
-  g_SynapseClient.AddAPI(BRUSH_MAJOR, NULL, sizeof(__BRUSHTABLENAME), SYN_REQUIRE, &g_BrushTable);
-  g_SynapseClient.AddAPI(PATCH_MAJOR, NULL, sizeof(__PATCHTABLENAME), SYN_REQUIRE, &g_BrushTable);
+  g_SynapseClient.AddAPI(DATA_MAJOR, NULL, sizeof(g_AppDataTable), SYN_REQUIRE, &g_AppDataTable);
+  g_SynapseClient.AddAPI(BRUSH_MAJOR, NULL, sizeof(g_BrushTable), SYN_REQUIRE, &g_BrushTable);
   g_SynapseClient.AddAPI(SHADERS_MAJOR, "*", sizeof(g_ShadersTable), SYN_REQUIRE, &g_ShadersTable);
   g_SynapseClient.AddAPI(ENTITY_MAJOR, NULL, sizeof(g_EntityTable), SYN_REQUIRE, &g_EntityTable);
   g_SynapseClient.AddAPI(SELECTEDFACE_MAJOR, NULL, sizeof(g_SelectedFaceTable), SYN_REQUIRE, &g_SelectedFaceTable);
   g_SynapseClient.AddAPI(UI_MAJOR, NULL, sizeof(g_MessageTable), SYN_REQUIRE, &g_MessageTable);
-  g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(__QERTABLENAME), SYN_REQUIRE, &g_FuncTable);
+  g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(g_FuncTable), SYN_REQUIRE, &g_FuncTable);
   g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(g_QglTable), SYN_REQUIRE, &g_QglTable);
 
   return &g_SynapseClient;
@@ -294,3 +287,11 @@ const char* CSynapseClientBobtoolz::GetInfo()
   return "bobToolz module built " __DATE__ " " RADIANT_VERSION;
 }
 
+char* GetFilename(char* buffer, const char* filename) {
+       strcpy(buffer, g_pSynapseServer->GetModuleFilename(&g_SynapseClient));
+       StripFilename( buffer );
+       strcat(buffer, "/");
+       strcat(buffer, filename);
+       buffer = UnixToDosPath(buffer);
+       return buffer;
+}