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(){
40 void BobToolz_destroy(){
53 if ( g_TreePlanter ) {
60 char* PLUGIN_NAME = "bobToolz";
62 // commands in the menu
63 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";
66 GtkWidget *g_pRadiantWnd = NULL;
68 static const char *PLUGIN_ABOUT = "bobToolz for SDRadiant\n"
69 "by digibob (digibob@splashdamage.com)\n"
70 "http://www.splashdamage.com\n\n"
71 "Additional Contributors:\n"
72 "MarsMattel, RR2DO2\n";
74 extern "C" const char* QERPlug_Init( void* hApp, void* pMainWidget ) {
75 g_pRadiantWnd = (GtkWidget*)pMainWidget;
77 return "bobToolz for GTKradiant";
80 extern "C" const char* QERPlug_GetName() {
84 extern "C" const char* QERPlug_GetCommandList() {
85 return PLUGIN_COMMANDS;
88 extern "C" void QERPlug_Dispatch( const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush ) {
91 if ( string_equal_nocase( p, "brush cleanup" ) ) {
94 else if ( string_equal_nocase( p, "polygon builder" ) ) {
97 else if ( string_equal_nocase( p, "caulk selection" ) ) {
100 else if ( string_equal_nocase( p, "tree planter" ) ) {
103 else if ( string_equal_nocase( p, "plot splines" ) ) {
106 else if ( string_equal_nocase( p, "drop entity" ) ) {
109 else if ( string_equal_nocase( p, "merge patches" ) ) {
112 else if ( string_equal_nocase( p, "split patches" ) ) {
115 else if ( string_equal_nocase( p, "split patches rows" ) ) {
118 else if ( string_equal_nocase( p, "split patches cols" ) ) {
121 else if ( string_equal_nocase( p, "turn edge" ) ) {
124 else if ( string_equal_nocase( p, "reset textures..." ) ) {
127 else if ( string_equal_nocase( p, "pitomatic" ) ) {
130 else if ( string_equal_nocase( p, "vis viewer" ) ) {
133 else if ( string_equal_nocase( p, "stair builder..." ) ) {
136 else if ( string_equal_nocase( p, "door builder..." ) ) {
139 else if ( string_equal_nocase( p, "intersect..." ) ) {
142 else if ( string_equal_nocase( p, "make chain..." ) ) {
145 else if ( string_equal_nocase( p, "path plotter..." ) ) {
148 else if ( string_equal_nocase( p, "about..." ) ) {
149 DoMessageBox( PLUGIN_ABOUT, "About", eMB_OK );
153 const char* QERPlug_GetCommandTitleList(){
158 #define NUM_TOOLBARBUTTONS 14
160 std::size_t ToolbarButtonCount( void ) {
161 return NUM_TOOLBARBUTTONS;
164 class CBobtoolzToolbarButton : public IToolbarButton
167 virtual const char* getImage() const {
169 case 0: return "bobtoolz_cleanup.png";
170 case 1: return "bobtoolz_poly.png";
171 case 2: return "bobtoolz_caulk.png";
173 case 4: return "bobtoolz_treeplanter.png";
174 case 5: return "bobtoolz_trainpathplot.png";
175 case 6: return "bobtoolz_dropent.png";
177 case 8: return "bobtoolz_merge.png";
178 case 9: return "bobtoolz_split.png";
179 case 10: return "bobtoolz_splitrow.png";
180 case 11: return "bobtoolz_splitcol.png";
182 case 13: return "bobtoolz_turnedge.png";
186 virtual EType getType() const {
188 case 3: return eSpace;
189 case 4: return eToggleButton;
190 case 7: return eSpace;
191 case 12: return eSpace;
192 default: return eButton;
195 virtual const char* getText() const {
197 case 0: return "Cleanup";
198 case 1: return "Polygons";
199 case 2: return "Caulk";
200 case 4: return "Tree Planter";
201 case 5: return "Plot Splines";
202 case 6: return "Drop Entity";
203 case 8: return "Merge 2 Patches";
204 case 9: return "Split Patch";
205 case 10: return "Split Patch Rows";
206 case 11: return "Split Patch Columns";
207 case 13: return "Flip Terrain";
211 virtual const char* getTooltip() const {
213 case 0: return "Brush Cleanup";
214 case 1: return "Polygons";
215 case 2: return "Caulk selection";
216 case 4: return "Tree Planter";
217 case 5: return "Plot Splines";
218 case 6: return "Drop Entity";
219 case 8: return "Merge 2 Patches";
220 case 9: return "Split Patch";
221 case 10: return "Split Patch Rows";
222 case 11: return "Split Patch Columns";
223 case 13: return "Flip Terrain (Turn Edge)";
228 virtual void activate() const {
232 case 0: DoFixBrushes(); break;
233 case 1: DoPolygonsTB(); break;
234 case 2: DoCaulkSelection(); break;
235 case 4: DoTreePlanter(); break;
236 case 5: DoTrainPathPlot(); break;
237 case 6: DoDropEnts(); break;
238 case 8: DoMergePatches(); break;
239 case 9: DoSplitPatch(); break;
240 case 10: DoSplitPatchRows(); break;
241 case 11: DoSplitPatchCols(); break;
242 case 13: DoFlipTerrain(); break;
249 CBobtoolzToolbarButton g_bobtoolzToolbarButtons[NUM_TOOLBARBUTTONS];
251 const IToolbarButton* GetToolbarButton( std::size_t index ){
252 g_bobtoolzToolbarButtons[index].mIndex = index;
253 return &g_bobtoolzToolbarButtons[index];
257 #include "modulesystem/singletonmodule.h"
259 #include "iscenegraph.h"
262 #include "ishaders.h"
267 #include "iglrender.h"
270 class BobToolzPluginDependencies :
271 public GlobalRadiantModuleRef,
272 public GlobalUndoModuleRef,
273 public GlobalSceneGraphModuleRef,
274 public GlobalSelectionModuleRef,
275 public GlobalEntityModuleRef,
276 public GlobalEntityClassManagerModuleRef,
277 public GlobalShadersModuleRef,
278 public GlobalShaderCacheModuleRef,
279 public GlobalBrushModuleRef,
280 public GlobalPatchModuleRef,
281 public GlobalOpenGLModuleRef,
282 public GlobalOpenGLStateLibraryModuleRef
285 BobToolzPluginDependencies() :
286 GlobalEntityModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entities" ) ),
287 GlobalShadersModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "shaders" ) ),
288 GlobalBrushModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "brushtypes" ) ),
289 GlobalPatchModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "patchtypes" ) ),
290 GlobalEntityClassManagerModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entityclass" ) ){
294 class BobToolzPluginModule : public TypeSystemRef
296 _QERPluginTable m_plugin;
298 typedef _QERPluginTable Type;
299 STRING_CONSTANT( Name, "bobToolz" );
301 BobToolzPluginModule(){
302 m_plugin.m_pfnQERPlug_Init = QERPlug_Init;
303 m_plugin.m_pfnQERPlug_GetName = QERPlug_GetName;
304 m_plugin.m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
305 m_plugin.m_pfnQERPlug_GetCommandTitleList = QERPlug_GetCommandTitleList;
306 m_plugin.m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
308 BobToolz_construct();
310 ~BobToolzPluginModule(){
313 _QERPluginTable* getTable(){
318 typedef SingletonModule<BobToolzPluginModule, BobToolzPluginDependencies> SingletonBobToolzPluginModule;
320 SingletonBobToolzPluginModule g_BobToolzPluginModule;
323 class BobToolzToolbarDependencies :
324 public ModuleRef<_QERPluginTable>
327 BobToolzToolbarDependencies() :
328 ModuleRef<_QERPluginTable>( "bobToolz" ){
332 class BobToolzToolbarModule : public TypeSystemRef
334 _QERPlugToolbarTable m_table;
336 typedef _QERPlugToolbarTable Type;
337 STRING_CONSTANT( Name, "bobToolz" );
339 BobToolzToolbarModule(){
340 m_table.m_pfnToolbarButtonCount = ToolbarButtonCount;
341 m_table.m_pfnGetToolbarButton = GetToolbarButton;
343 _QERPlugToolbarTable* getTable(){
348 typedef SingletonModule<BobToolzToolbarModule, BobToolzToolbarDependencies> SingletonBobToolzToolbarModule;
350 SingletonBobToolzToolbarModule g_BobToolzToolbarModule;
353 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){
354 initialiseModule( server );
356 g_BobToolzPluginModule.selfRegister();
357 g_BobToolzToolbarModule.selfRegister();