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...,-,Vis Viewer,Path Plotter...,-,Stair Builder...,PitOMatic,Make Chain...,Door Builder...,-,Texture Reset...,Intersect...";
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, "texture reset...") ) {
95 } else if( string_equal_nocase(p, "pitomatic") ) {
97 } else if( string_equal_nocase(p, "vis viewer") ) {
99 } else if( string_equal_nocase(p, "stair builder...") ) {
101 } else if( string_equal_nocase(p, "door builder...") ) {
103 } else if( string_equal_nocase(p, "intersect...") ) {
105 } else if( string_equal_nocase(p, "make chain...") ) {
107 } else if( string_equal_nocase(p, "path plotter...") ) {
109 } else if( string_equal_nocase(p, "about...") ) {
110 DoMessageBox(PLUGIN_ABOUT, "About", eMB_OK);
114 const char* QERPlug_GetCommandTitleList()
120 #define NUM_TOOLBARBUTTONS 14
122 std::size_t ToolbarButtonCount( void ) {
123 return NUM_TOOLBARBUTTONS;
126 class CBobtoolzToolbarButton : public IToolbarButton
129 virtual const char* getImage() const
132 case 0: return "bobtoolz_cleanup.bmp";
133 case 1: return "bobtoolz_poly.bmp";
134 case 2: return "bobtoolz_caulk.bmp";
136 case 4: return "bobtoolz_treeplanter.bmp";
137 case 5: return "bobtoolz_trainpathplot.bmp";
138 case 6: return "bobtoolz_dropent.bmp";
140 case 8: return "bobtoolz_merge.bmp";
141 case 9: return "bobtoolz_split.bmp";
142 case 10: return "bobtoolz_splitrow.bmp";
143 case 11: return "bobtoolz_splitcol.bmp";
145 case 13: return "bobtoolz_turnedge.bmp";
149 virtual EType getType() const
152 case 3: return eSpace;
153 case 4: return eToggleButton;
154 case 7: return eSpace;
155 case 12: return eSpace;
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 4: return "Tree Planter";
166 case 5: return "Plot Splines";
167 case 6: return "Drop Entity";
168 case 8: return "Merge 2 Patches";
169 case 9: return "Split Patch";
170 case 10: return "Split Patch Rows";
171 case 11: return "Split Patch Columns";
172 case 13: return "Flip Terrain";
176 virtual const char* getTooltip() const
179 case 0: return "Brush Cleanup";
180 case 1: return "Polygons";
181 case 2: return "Caulk selection";
182 case 4: return "Tree Planter";
183 case 5: return "Plot Splines";
184 case 6: return "Drop Entity";
185 case 8: return "Merge 2 Patches";
186 case 9: return "Split Patch";
187 case 10: return "Split Patch Rows";
188 case 11: return "Split Patch Columns";
189 case 13: return "Flip Terrain (Turn Edge)";
194 virtual void activate() const
199 case 0: DoFixBrushes(); break;
200 case 1: DoPolygonsTB(); break;
201 case 2: DoCaulkSelection(); break;
202 case 4: DoTreePlanter(); break;
203 case 5: DoTrainPathPlot(); break;
204 case 6: DoDropEnts(); break;
205 case 8: DoMergePatches(); break;
206 case 9: DoSplitPatch(); break;
207 case 10: DoSplitPatchRows(); break;
208 case 11: DoSplitPatchCols(); break;
209 case 13: DoFlipTerrain(); break;
216 CBobtoolzToolbarButton g_bobtoolzToolbarButtons[NUM_TOOLBARBUTTONS];
218 const IToolbarButton* GetToolbarButton(std::size_t index)
220 g_bobtoolzToolbarButtons[index].mIndex = index;
221 return &g_bobtoolzToolbarButtons[index];
225 #include "modulesystem/singletonmodule.h"
227 #include "iscenegraph.h"
230 #include "ishaders.h"
235 #include "iglrender.h"
238 class BobToolzPluginDependencies :
239 public GlobalRadiantModuleRef,
240 public GlobalUndoModuleRef,
241 public GlobalSceneGraphModuleRef,
242 public GlobalSelectionModuleRef,
243 public GlobalEntityModuleRef,
244 public GlobalEntityClassManagerModuleRef,
245 public GlobalShadersModuleRef,
246 public GlobalShaderCacheModuleRef,
247 public GlobalBrushModuleRef,
248 public GlobalPatchModuleRef,
249 public GlobalOpenGLModuleRef,
250 public GlobalOpenGLStateLibraryModuleRef
253 BobToolzPluginDependencies() :
254 GlobalEntityModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("entities")),
255 GlobalShadersModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("shaders")),
256 GlobalBrushModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("brushtypes")),
257 GlobalPatchModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("patchtypes")),
258 GlobalEntityClassManagerModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("entityclass"))
263 class BobToolzPluginModule : public TypeSystemRef
265 _QERPluginTable m_plugin;
267 typedef _QERPluginTable Type;
268 STRING_CONSTANT(Name, "bobToolz");
270 BobToolzPluginModule()
272 m_plugin.m_pfnQERPlug_Init = QERPlug_Init;
273 m_plugin.m_pfnQERPlug_GetName = QERPlug_GetName;
274 m_plugin.m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
275 m_plugin.m_pfnQERPlug_GetCommandTitleList = QERPlug_GetCommandTitleList;
276 m_plugin.m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
278 BobToolz_construct();
280 ~BobToolzPluginModule()
284 _QERPluginTable* getTable()
290 typedef SingletonModule<BobToolzPluginModule, BobToolzPluginDependencies> SingletonBobToolzPluginModule;
292 SingletonBobToolzPluginModule g_BobToolzPluginModule;
295 class BobToolzToolbarDependencies :
296 public ModuleRef<_QERPluginTable>
299 BobToolzToolbarDependencies() :
300 ModuleRef<_QERPluginTable>("bobToolz")
305 class BobToolzToolbarModule : public TypeSystemRef
307 _QERPlugToolbarTable m_table;
309 typedef _QERPlugToolbarTable Type;
310 STRING_CONSTANT(Name, "bobToolz");
312 BobToolzToolbarModule()
314 m_table.m_pfnToolbarButtonCount = ToolbarButtonCount;
315 m_table.m_pfnGetToolbarButton = GetToolbarButton;
317 _QERPlugToolbarTable* getTable()
323 typedef SingletonModule<BobToolzToolbarModule, BobToolzToolbarDependencies> SingletonBobToolzToolbarModule;
325 SingletonBobToolzToolbarModule g_BobToolzToolbarModule;
328 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
330 initialiseModule(server);
332 g_BobToolzPluginModule.selfRegister();
333 g_BobToolzToolbarModule.selfRegister();