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 const char *PLUGIN_NAME = "bobToolz";
64 // commands in the menu
65 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,Split patches cols,Split patches rows,Turn edge";
68 ui::Window g_pRadiantWnd{ui::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)
78 g_pRadiantWnd = ui::Window::from(pMainWidget);
80 return "bobToolz for GTKradiant";
83 extern "C" const char *QERPlug_GetName()
88 extern "C" const char *QERPlug_GetCommandList()
90 return PLUGIN_COMMANDS;
93 extern "C" void QERPlug_Dispatch(const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)
97 if (string_equal_nocase(p, "brush cleanup")) {
99 } else if (string_equal_nocase(p, "polygon builder")) {
101 } else if (string_equal_nocase(p, "caulk selection")) {
103 } else if (string_equal_nocase(p, "tree planter")) {
105 } else if (string_equal_nocase(p, "plot splines")) {
107 } else if (string_equal_nocase(p, "drop entity")) {
109 } else if (string_equal_nocase(p, "merge patches")) {
111 } else if (string_equal_nocase(p, "split patches")) {
113 } else if (string_equal_nocase(p, "split patches rows")) {
115 } else if (string_equal_nocase(p, "split patches cols")) {
117 } else if (string_equal_nocase(p, "turn edge")) {
119 } else if (string_equal_nocase(p, "reset textures...")) {
121 } else if (string_equal_nocase(p, "pitomatic")) {
123 } else if (string_equal_nocase(p, "vis viewer")) {
125 } else if (string_equal_nocase(p, "stair builder...")) {
127 } else if (string_equal_nocase(p, "door builder...")) {
129 } else if (string_equal_nocase(p, "intersect...")) {
131 } else if (string_equal_nocase(p, "make chain...")) {
133 } else if (string_equal_nocase(p, "path plotter...")) {
135 } else if (string_equal_nocase(p, "about...")) {
136 DoMessageBox(PLUGIN_ABOUT, "About", eMB_OK);
140 const char *QERPlug_GetCommandTitleList()
146 const int NUM_TOOLBARBUTTONS = 14;
148 std::size_t ToolbarButtonCount(void)
150 return NUM_TOOLBARBUTTONS;
153 class CBobtoolzToolbarButton : public IToolbarButton {
155 virtual const char *getImage() const
159 return "bobtoolz_cleanup.png";
161 return "bobtoolz_poly.png";
163 return "bobtoolz_caulk.png";
167 return "bobtoolz_treeplanter.png";
169 return "bobtoolz_trainpathplot.png";
171 return "bobtoolz_dropent.png";
175 return "bobtoolz_merge.png";
177 return "bobtoolz_split.png";
179 return "bobtoolz_splitrow.png";
181 return "bobtoolz_splitcol.png";
185 return "bobtoolz_turnedge.png";
190 virtual EType getType() const
196 return eToggleButton;
206 virtual const char *getText() const
216 return "Tree Planter";
218 return "Plot Splines";
220 return "Drop Entity";
222 return "Merge 2 Patches";
224 return "Split Patch";
226 return "Split Patch Rows";
228 return "Split Patch Columns";
230 return "Flip Terrain";
235 virtual const char *getTooltip() const
239 return "Brush Cleanup";
243 return "Caulk selection";
245 return "Tree Planter";
247 return "Plot Splines";
249 return "Drop Entity";
251 return "Merge 2 Patches";
253 return "Split Patch";
255 return "Split Patch Rows";
257 return "Split Patch Columns";
259 return "Flip Terrain (Turn Edge)";
264 virtual void activate() const
308 CBobtoolzToolbarButton g_bobtoolzToolbarButtons[NUM_TOOLBARBUTTONS];
310 const IToolbarButton *GetToolbarButton(std::size_t index)
312 g_bobtoolzToolbarButtons[index].mIndex = index;
313 return &g_bobtoolzToolbarButtons[index];
317 #include "modulesystem/singletonmodule.h"
319 #include "iscenegraph.h"
322 #include "ishaders.h"
327 #include "iglrender.h"
330 class BobToolzPluginDependencies :
331 public GlobalRadiantModuleRef,
332 public GlobalUndoModuleRef,
333 public GlobalSceneGraphModuleRef,
334 public GlobalSelectionModuleRef,
335 public GlobalEntityModuleRef,
336 public GlobalEntityClassManagerModuleRef,
337 public GlobalShadersModuleRef,
338 public GlobalShaderCacheModuleRef,
339 public GlobalBrushModuleRef,
340 public GlobalPatchModuleRef,
341 public GlobalOpenGLModuleRef,
342 public GlobalOpenGLStateLibraryModuleRef {
344 BobToolzPluginDependencies() :
345 GlobalEntityModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("entities")),
346 GlobalEntityClassManagerModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("entityclass")),
347 GlobalShadersModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("shaders")),
348 GlobalBrushModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("brushtypes")),
349 GlobalPatchModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("patchtypes"))
354 class BobToolzPluginModule : public TypeSystemRef {
355 _QERPluginTable m_plugin;
357 typedef _QERPluginTable Type;
359 STRING_CONSTANT(Name, "bobToolz");
361 BobToolzPluginModule()
363 m_plugin.m_pfnQERPlug_Init = QERPlug_Init;
364 m_plugin.m_pfnQERPlug_GetName = QERPlug_GetName;
365 m_plugin.m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
366 m_plugin.m_pfnQERPlug_GetCommandTitleList = QERPlug_GetCommandTitleList;
367 m_plugin.m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
369 BobToolz_construct();
372 ~BobToolzPluginModule()
377 _QERPluginTable *getTable()
383 typedef SingletonModule<BobToolzPluginModule, BobToolzPluginDependencies> SingletonBobToolzPluginModule;
385 SingletonBobToolzPluginModule g_BobToolzPluginModule;
388 class BobToolzToolbarDependencies :
389 public ModuleRef<_QERPluginTable> {
391 BobToolzToolbarDependencies() :
392 ModuleRef<_QERPluginTable>("bobToolz")
397 class BobToolzToolbarModule : public TypeSystemRef {
398 _QERPlugToolbarTable m_table;
400 typedef _QERPlugToolbarTable Type;
402 STRING_CONSTANT(Name, "bobToolz");
404 BobToolzToolbarModule()
406 m_table.m_pfnToolbarButtonCount = ToolbarButtonCount;
407 m_table.m_pfnGetToolbarButton = GetToolbarButton;
410 _QERPlugToolbarTable *getTable()
416 typedef SingletonModule<BobToolzToolbarModule, BobToolzToolbarDependencies> SingletonBobToolzToolbarModule;
418 SingletonBobToolzToolbarModule g_BobToolzToolbarModule;
421 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer &server)
423 initialiseModule(server);
425 g_BobToolzPluginModule.selfRegister();
426 g_BobToolzToolbarModule.selfRegister();