Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "StdAfx.h"
+
+
+#include "str.h"
+#include "qerplugin.h"
+#include "mathlib.h"
+#include "string/string.h"
+#include "itoolbar.h"
#include "funchandlers.h"
-#include "misc.h"
+#include "DBobView.h"
+#include "DVisDrawer.h"
+#include "DTrainDrawer.h"
+#include "DTreePlanter.h"
#include "dialogs/dialogs-gtk.h"
#include "../../libs/cmdlib.h"
-// Radiant function table
-_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 g_EntityTable;
+void BobToolz_construct(){
+}
+
+void BobToolz_destroy(){
+ if ( g_PathView ) {
+ delete g_PathView;
+ g_PathView = NULL;
+ }
+ if ( g_VisView ) {
+ delete g_VisView;
+ g_VisView = NULL;
+ }
+ if ( g_TrainView ) {
+ delete g_TrainView;
+ g_TrainView = NULL;
+ }
+ if ( g_TreePlanter ) {
+ delete g_TreePlanter;
+ g_TreePlanter = NULL;
+ }
+}
// plugin name
-const char* PLUGIN_NAME = "bobToolz";
+char* PLUGIN_NAME = "bobToolz";
// commands in the menu
-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";
+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,Split patches cols,Split patches rows,Turn edge";
// globals
GtkWidget *g_pRadiantWnd = NULL;
extern "C" void QERPlug_Dispatch( const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush ) {
LoadLists();
- if ( !stricmp( p, "brush cleanup" ) ) {
+ if ( string_equal_nocase( p, "brush cleanup" ) ) {
DoFixBrushes();
}
- else if ( !stricmp( p, "polygon builder" ) ) {
+ else if ( string_equal_nocase( p, "polygon builder" ) ) {
DoPolygonsTB();
}
- else if ( !stricmp( p, "caulk selection" ) ) {
+ else if ( string_equal_nocase( p, "caulk selection" ) ) {
DoCaulkSelection();
}
- else if ( !stricmp( p, "tree planter" ) ) {
+ else if ( string_equal_nocase( p, "tree planter" ) ) {
DoTreePlanter();
}
- else if ( !stricmp( p, "plot splines" ) ) {
+ else if ( string_equal_nocase( p, "plot splines" ) ) {
DoTrainPathPlot();
}
- else if ( !stricmp( p, "drop entity" ) ) {
+ else if ( string_equal_nocase( p, "drop entity" ) ) {
DoDropEnts();
}
- else if ( !stricmp( p, "merge patches" ) ) {
+ else if ( string_equal_nocase( p, "merge patches" ) ) {
DoMergePatches();
}
- else if ( !stricmp( p, "split patches" ) ) {
+ else if ( string_equal_nocase( p, "split patches" ) ) {
DoSplitPatch();
}
- else if ( !stricmp( p, "turn edge" ) ) {
+ else if ( string_equal_nocase( p, "split patches rows" ) ) {
+ DoSplitPatchRows();
+ }
+ else if ( string_equal_nocase( p, "split patches cols" ) ) {
+ DoSplitPatchCols();
+ }
+ else if ( string_equal_nocase( p, "turn edge" ) ) {
DoFlipTerrain();
}
- else if ( !stricmp( p, "reset textures..." ) ) {
+ else if ( string_equal_nocase( p, "reset textures..." ) ) {
DoResetTextures();
}
- else if ( !stricmp( p, "pitomatic" ) ) {
- DoPitBuilder( vMin, vMax );
+ else if ( string_equal_nocase( p, "pitomatic" ) ) {
+ DoPitBuilder();
}
- else if ( !stricmp( p, "vis viewer" ) ) {
+ else if ( string_equal_nocase( p, "vis viewer" ) ) {
DoVisAnalyse();
}
- else if ( !stricmp( p, "about..." ) ) {
- DoMessageBox( PLUGIN_ABOUT, "About", IDOK );
+ else if ( string_equal_nocase( p, "stair builder..." ) ) {
+ DoBuildStairs();
+ }
+ else if ( string_equal_nocase( p, "door builder..." ) ) {
+ DoBuildDoors();
+ }
+ else if ( string_equal_nocase( p, "intersect..." ) ) {
+ DoIntersect();
+ }
+ else if ( string_equal_nocase( p, "make chain..." ) ) {
+ DoMakeChain();
+ }
+ else if ( string_equal_nocase( p, "path plotter..." ) ) {
+ DoPathPlotter();
+ }
+ else if ( string_equal_nocase( p, "about..." ) ) {
+ DoMessageBox( PLUGIN_ABOUT, "About", eMB_OK );
}
}
-#define NUM_TOOLBARBUTTONS 9
-
-unsigned int ToolbarButtonCount( void ) {
- return NUM_TOOLBARBUTTONS;
+const char* QERPlug_GetCommandTitleList(){
+ return "";
}
-// Load a xpm file and return a pixmap widget.
-GtkWidget* new_pixmap( char* filename ) {
- GdkPixmap *gdkpixmap;
- GdkBitmap *mask;
- GtkWidget *pixmap;
- g_FuncTable.m_pfnLoadBitmap( filename, (void **)&gdkpixmap, (void **)&mask );
- pixmap = gtk_pixmap_new( gdkpixmap, mask );
+#define NUM_TOOLBARBUTTONS 14
- gdk_pixmap_unref( gdkpixmap );
- gdk_pixmap_unref( mask );
-
- return pixmap;
+std::size_t ToolbarButtonCount( void ) {
+ return NUM_TOOLBARBUTTONS;
}
class CBobtoolzToolbarButton : public IToolbarButton
public:
virtual const char* getImage() const {
switch ( mIndex ) {
- case 0: return "bobtoolz_cleanup.bmp";
- case 1: return "bobtoolz_poly.bmp";
- case 2: return "bobtoolz_caulk.bmp";
- case 3: return "bobtoolz_treeplanter.bmp";
- case 4: return "bobtoolz_trainpathplot.bmp";
- case 5: return "bobtoolz_dropent.bmp";
- case 6: return "bobtoolz_merge.bmp";
- case 7: return "bobtoolz_split.bmp";
- case 8: return "bobtoolz_turnedge.bmp";
+ case 0: return "bobtoolz_cleanup.png";
+ case 1: return "bobtoolz_poly.png";
+ case 2: return "bobtoolz_caulk.png";
+ case 3: return "";
+ case 4: return "bobtoolz_treeplanter.png";
+ case 5: return "bobtoolz_trainpathplot.png";
+ case 6: return "bobtoolz_dropent.png";
+ case 7: return "";
+ case 8: return "bobtoolz_merge.png";
+ case 9: return "bobtoolz_split.png";
+ case 10: return "bobtoolz_splitrow.png";
+ case 11: return "bobtoolz_splitcol.png";
+ case 12: return "";
+ case 13: return "bobtoolz_turnedge.png";
}
return NULL;
}
virtual EType getType() const {
switch ( mIndex ) {
- case 3: return eToggleButton;
+ case 3: return eSpace;
+ case 4: return eToggleButton;
+ case 7: return eSpace;
+ case 12: return eSpace;
default: return eButton;
}
}
case 0: return "Cleanup";
case 1: return "Polygons";
case 2: return "Caulk";
- case 3: return "Tree Planter";
- case 4: return "Plot Splines";
- case 5: return "Drop Entity";
- case 6: return "Merge Patches";
- case 7: return "Split Patches";
- case 8: return "Flip Terrain";
+ case 4: return "Tree Planter";
+ case 5: return "Plot Splines";
+ case 6: return "Drop Entity";
+ case 8: return "Merge 2 Patches";
+ case 9: return "Split Patch";
+ case 10: return "Split Patch Rows";
+ case 11: return "Split Patch Columns";
+ case 13: return "Flip Terrain";
}
return NULL;
}
case 0: return "Brush Cleanup";
case 1: return "Polygons";
case 2: return "Caulk selection";
- case 3: return "Tree Planter";
- case 4: return "Plot Splines";
- case 5: return "Drop Entity";
- case 6: return "Merge Patches";
- case 7: return "Split Patches";
- case 8: return "Flip Terrain";
+ case 4: return "Tree Planter";
+ case 5: return "Plot Splines";
+ case 6: return "Drop Entity";
+ case 8: return "Merge 2 Patches";
+ case 9: return "Split Patch";
+ case 10: return "Split Patch Rows";
+ case 11: return "Split Patch Columns";
+ case 13: return "Flip Terrain (Turn Edge)";
}
return NULL;
}
case 0: DoFixBrushes(); break;
case 1: DoPolygonsTB(); break;
case 2: DoCaulkSelection(); break;
- case 3: DoTreePlanter(); break;
- case 4: DoTrainPathPlot(); break;
- case 5: DoDropEnts(); break;
- case 6: DoMergePatches(); break;
- case 7: DoSplitPatch(); break;
- case 8: DoFlipTerrain(); break;
+ case 4: DoTreePlanter(); break;
+ case 5: DoTrainPathPlot(); break;
+ case 6: DoDropEnts(); break;
+ case 8: DoMergePatches(); break;
+ case 9: DoSplitPatch(); break;
+ case 10: DoSplitPatchRows(); break;
+ case 11: DoSplitPatchCols(); break;
+ case 13: DoFlipTerrain(); break;
}
}
-int mIndex;
+std::size_t mIndex;
};
CBobtoolzToolbarButton g_bobtoolzToolbarButtons[NUM_TOOLBARBUTTONS];
-const IToolbarButton* GetToolbarButton( unsigned int index ){
+const IToolbarButton* GetToolbarButton( std::size_t index ){
g_bobtoolzToolbarButtons[index].mIndex = index;
return &g_bobtoolzToolbarButtons[index];
}
-// =============================================================================
-// SYNAPSE
-class CSynapseClientBobtoolz : public CSynapseClient
+#include "modulesystem/singletonmodule.h"
+
+#include "iscenegraph.h"
+#include "irender.h"
+#include "iundo.h"
+#include "ishaders.h"
+#include "ipatch.h"
+#include "ibrush.h"
+#include "ientity.h"
+#include "ieclass.h"
+#include "iglrender.h"
+#include "iplugin.h"
+
+class BobToolzPluginDependencies :
+ public GlobalRadiantModuleRef,
+ public GlobalUndoModuleRef,
+ public GlobalSceneGraphModuleRef,
+ public GlobalSelectionModuleRef,
+ public GlobalEntityModuleRef,
+ public GlobalEntityClassManagerModuleRef,
+ public GlobalShadersModuleRef,
+ public GlobalShaderCacheModuleRef,
+ public GlobalBrushModuleRef,
+ public GlobalPatchModuleRef,
+ public GlobalOpenGLModuleRef,
+ public GlobalOpenGLStateLibraryModuleRef
{
public:
-// CSynapseClient API
-bool RequestAPI( APIDescriptor_t *pAPI );
-const char* GetInfo();
-
-CSynapseClientBobtoolz() { }
-virtual ~CSynapseClientBobtoolz() { }
+BobToolzPluginDependencies() :
+ GlobalEntityModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entities" ) ),
+ GlobalShadersModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "shaders" ) ),
+ GlobalBrushModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "brushtypes" ) ),
+ GlobalPatchModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "patchtypes" ) ),
+ GlobalEntityClassManagerModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entityclass" ) ){
+}
};
+class BobToolzPluginModule : public TypeSystemRef
+{
+_QERPluginTable m_plugin;
+public:
+typedef _QERPluginTable Type;
+STRING_CONSTANT( Name, "bobToolz" );
-CSynapseServer* g_pSynapseServer = NULL;
-CSynapseClientBobtoolz g_SynapseClient;
+BobToolzPluginModule(){
+ m_plugin.m_pfnQERPlug_Init = QERPlug_Init;
+ m_plugin.m_pfnQERPlug_GetName = QERPlug_GetName;
+ m_plugin.m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
+ m_plugin.m_pfnQERPlug_GetCommandTitleList = QERPlug_GetCommandTitleList;
+ m_plugin.m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
-#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 );
- return NULL;
- }
- 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( 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( g_FuncTable ), SYN_REQUIRE, &g_FuncTable );
- g_SynapseClient.AddAPI( QGL_MAJOR, NULL, sizeof( g_QglTable ), SYN_REQUIRE, &g_QglTable );
-
- return &g_SynapseClient;
+ BobToolz_construct();
}
+~BobToolzPluginModule(){
+ BobToolz_destroy();
+}
+_QERPluginTable* getTable(){
+ return &m_plugin;
+}
+};
-bool CSynapseClientBobtoolz::RequestAPI( APIDescriptor_t *pAPI ){
- if ( !strcmp( pAPI->minor_name, BOBTOOLZ_MINOR ) ) {
- if ( !strcmp( pAPI->major_name, PLUGIN_MAJOR ) ) {
- _QERPluginTable* pTable = static_cast<_QERPluginTable*>( pAPI->mpTable );
+typedef SingletonModule<BobToolzPluginModule, BobToolzPluginDependencies> SingletonBobToolzPluginModule;
- pTable->m_pfnQERPlug_Init = QERPlug_Init;
- pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
- pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
- pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
+SingletonBobToolzPluginModule g_BobToolzPluginModule;
- return true;
- }
- else if ( !strcmp( pAPI->major_name, TOOLBAR_MAJOR ) ) {
- _QERPlugToolbarTable* pTable = static_cast<_QERPlugToolbarTable*>( pAPI->mpTable );
- pTable->m_pfnToolbarButtonCount = &ToolbarButtonCount;
- pTable->m_pfnGetToolbarButton = &GetToolbarButton;
+class BobToolzToolbarDependencies :
+ public ModuleRef<_QERPluginTable>
+{
+public:
+BobToolzToolbarDependencies() :
+ ModuleRef<_QERPluginTable>( "bobToolz" ){
+}
+};
- return true;
- }
- }
+class BobToolzToolbarModule : public TypeSystemRef
+{
+_QERPlugToolbarTable m_table;
+public:
+typedef _QERPlugToolbarTable Type;
+STRING_CONSTANT( Name, "bobToolz" );
- Syn_Printf( "ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo() );
- return false;
+BobToolzToolbarModule(){
+ m_table.m_pfnToolbarButtonCount = ToolbarButtonCount;
+ m_table.m_pfnGetToolbarButton = GetToolbarButton;
}
+_QERPlugToolbarTable* getTable(){
+ return &m_table;
+}
+};
-#include "version.h"
+typedef SingletonModule<BobToolzToolbarModule, BobToolzToolbarDependencies> SingletonBobToolzToolbarModule;
-const char* CSynapseClientBobtoolz::GetInfo(){
- return "bobToolz module built " __DATE__ " " RADIANT_VERSION;
-}
+SingletonBobToolzToolbarModule g_BobToolzToolbarModule;
+
+
+extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){
+ initialiseModule( server );
-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;
+ g_BobToolzPluginModule.selfRegister();
+ g_BobToolzToolbarModule.selfRegister();
}