2 BobToolz plugin for GtkRadiant
3 Copyright (C) 2001 Gordon Biggans
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "qerplugin.h"
25 #include "string/string.h"
28 #include "funchandlers.h"
30 #include "DVisDrawer.h"
31 #include "DTrainDrawer.h"
32 #include "DTreePlanter.h"
34 #include "dialogs/dialogs-gtk.h"
35 #include "../../libs/cmdlib.h"
37 void BobToolz_construct()
41 void BobToolz_destroy()
62 char* PLUGIN_NAME = "bobToolz";
64 // commands in the menu
65 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";
68 GtkWidget *g_pRadiantWnd = NULL;
70 static const char *PLUGIN_ABOUT = "bobToolz for SDRadiant\n"
71 "by digibob (digibob@splashdamage.com)\n"
72 "http://www.splashdamage.com\n\n"
73 "Additional Contributors:\n"
74 "MarsMattel, RR2DO2\n";
76 extern "C" const char* QERPlug_Init( void* hApp, void* pMainWidget ) {
77 g_pRadiantWnd = (GtkWidget*)pMainWidget;
79 return "bobToolz for GTKradiant";
82 extern "C" const char* QERPlug_GetName() {
86 extern "C" const char* QERPlug_GetCommandList() {
87 return PLUGIN_COMMANDS;
90 extern "C" void QERPlug_Dispatch (const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush) {
93 if( string_equal_nocase( p, "brush cleanup" ) ) {
95 } else if( string_equal_nocase( p, "polygon builder" ) ) {
97 } else if( string_equal_nocase( p, "caulk selection" ) ) {
99 } else if( string_equal_nocase( p, "tree planter" ) ) {
101 } else if( string_equal_nocase( p, "plot splines" ) ) {
103 } else if( string_equal_nocase( p, "drop entity" ) ) {
105 } else if( string_equal_nocase( p, "merge patches" ) ) {
107 } else if( string_equal_nocase( p, "split patches" ) ) {
109 } else if( string_equal_nocase( p, "turn edge" ) ) {
111 } else if( string_equal_nocase(p, "reset textures...") ) {
113 } else if( string_equal_nocase(p, "pitomatic") ) {
115 } else if( string_equal_nocase(p, "vis viewer") ) {
117 } else if( string_equal_nocase(p, "about...") ) {
118 DoMessageBox(PLUGIN_ABOUT, "About", eMB_OK);
122 const char* QERPlug_GetCommandTitleList()
128 #define NUM_TOOLBARBUTTONS 9
130 std::size_t ToolbarButtonCount( void ) {
131 return NUM_TOOLBARBUTTONS;
134 class CBobtoolzToolbarButton : public IToolbarButton
137 virtual const char* getImage() const
140 case 0: return "bobtoolz_cleanup.bmp";
141 case 1: return "bobtoolz_poly.bmp";
142 case 2: return "bobtoolz_caulk.bmp";
143 case 3: return "bobtoolz_treeplanter.bmp";
144 case 4: return "bobtoolz_trainpathplot.bmp";
145 case 5: return "bobtoolz_dropent.bmp";
146 case 6: return "bobtoolz_merge.bmp";
147 case 7: return "bobtoolz_split.bmp";
148 case 8: return "bobtoolz_turnedge.bmp";
152 virtual EType getType() const
155 case 3: return eToggleButton;
156 default: return eButton;
159 virtual const char* getText() const
162 case 0: return "Cleanup";
163 case 1: return "Polygons";
164 case 2: return "Caulk";
165 case 3: return "Tree Planter";
166 case 4: return "Plot Splines";
167 case 5: return "Drop Entity";
168 case 6: return "Merge Patches";
169 case 7: return "Split Patches";
170 case 8: return "Flip Terrain";
174 virtual const char* getTooltip() const
177 case 0: return "Brush Cleanup";
178 case 1: return "Polygons";
179 case 2: return "Caulk selection";
180 case 3: return "Tree Planter";
181 case 4: return "Plot Splines";
182 case 5: return "Drop Entity";
183 case 6: return "Merge Patches";
184 case 7: return "Split Patches";
185 case 8: return "Flip Terrain";
190 virtual void activate() const
195 case 0: DoFixBrushes(); break;
196 case 1: DoPolygonsTB(); break;
197 case 2: DoCaulkSelection(); break;
198 case 3: DoTreePlanter(); break;
199 case 4: DoTrainPathPlot(); break;
200 case 5: DoDropEnts(); break;
201 case 6: DoMergePatches(); break;
202 case 7: DoSplitPatch(); break;
203 case 8: DoFlipTerrain(); break;
210 CBobtoolzToolbarButton g_bobtoolzToolbarButtons[NUM_TOOLBARBUTTONS];
212 const IToolbarButton* GetToolbarButton(std::size_t index)
214 g_bobtoolzToolbarButtons[index].mIndex = index;
215 return &g_bobtoolzToolbarButtons[index];
219 #include "modulesystem/singletonmodule.h"
221 #include "iscenegraph.h"
224 #include "ishaders.h"
229 #include "iglrender.h"
232 class BobToolzPluginDependencies :
233 public GlobalRadiantModuleRef,
234 public GlobalUndoModuleRef,
235 public GlobalSceneGraphModuleRef,
236 public GlobalSelectionModuleRef,
237 public GlobalEntityModuleRef,
238 public GlobalEntityClassManagerModuleRef,
239 public GlobalShadersModuleRef,
240 public GlobalShaderCacheModuleRef,
241 public GlobalBrushModuleRef,
242 public GlobalPatchModuleRef,
243 public GlobalOpenGLModuleRef,
244 public GlobalOpenGLStateLibraryModuleRef
247 BobToolzPluginDependencies() :
248 GlobalEntityModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("entities")),
249 GlobalShadersModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("shaders")),
250 GlobalBrushModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("brushtypes")),
251 GlobalPatchModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("patchtypes")),
252 GlobalEntityClassManagerModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("entityclass"))
257 class BobToolzPluginModule : public TypeSystemRef
259 _QERPluginTable m_plugin;
261 typedef _QERPluginTable Type;
262 STRING_CONSTANT(Name, "bobtoolz");
264 BobToolzPluginModule()
266 m_plugin.m_pfnQERPlug_Init = QERPlug_Init;
267 m_plugin.m_pfnQERPlug_GetName = QERPlug_GetName;
268 m_plugin.m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
269 m_plugin.m_pfnQERPlug_GetCommandTitleList = QERPlug_GetCommandTitleList;
270 m_plugin.m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
272 BobToolz_construct();
274 ~BobToolzPluginModule()
278 _QERPluginTable* getTable()
284 typedef SingletonModule<BobToolzPluginModule, BobToolzPluginDependencies> SingletonBobToolzPluginModule;
286 SingletonBobToolzPluginModule g_BobToolzPluginModule;
289 class BobToolzToolbarDependencies :
290 public ModuleRef<_QERPluginTable>
293 BobToolzToolbarDependencies() :
294 ModuleRef<_QERPluginTable>("bobtoolz")
299 class BobToolzToolbarModule : public TypeSystemRef
301 _QERPlugToolbarTable m_table;
303 typedef _QERPlugToolbarTable Type;
304 STRING_CONSTANT(Name, "bobtoolz");
306 BobToolzToolbarModule()
308 m_table.m_pfnToolbarButtonCount = ToolbarButtonCount;
309 m_table.m_pfnGetToolbarButton = GetToolbarButton;
311 _QERPlugToolbarTable* getTable()
317 typedef SingletonModule<BobToolzToolbarModule, BobToolzToolbarDependencies> SingletonBobToolzToolbarModule;
319 SingletonBobToolzToolbarModule g_BobToolzToolbarModule;
322 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
324 initialiseModule(server);
326 g_BobToolzPluginModule.selfRegister();
327 g_BobToolzToolbarModule.selfRegister();