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 #include "bobToolz-GTK.h"
39 void BobToolz_construct(){
42 void BobToolz_destroy(){
55 if ( g_TreePlanter ) {
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";
67 static const char *PLUGIN_ABOUT = "bobToolz for SDRadiant\n"
68 "by digibob (digibob@splashdamage.com)\n"
69 "http://www.splashdamage.com\n\n"
70 "Additional Contributors:\n"
71 "MarsMattel, RR2DO2\n";
73 extern "C" const char* QERPlug_Init( void* hApp, void* pMainWidget ) {
74 g_pRadiantWnd = ui::Window::from(pMainWidget);
76 return "bobToolz for GTKradiant";
79 extern "C" const char* QERPlug_GetName() {
83 extern "C" const char* QERPlug_GetCommandList() {
84 return PLUGIN_COMMANDS;
87 extern "C" void QERPlug_Dispatch( const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush ) {
90 if ( string_equal_nocase( p, "brush cleanup" ) ) {
93 else if ( string_equal_nocase( p, "polygon builder" ) ) {
96 else if ( string_equal_nocase( p, "caulk selection" ) ) {
99 else if ( string_equal_nocase( p, "tree planter" ) ) {
102 else if ( string_equal_nocase( p, "plot splines" ) ) {
105 else if ( string_equal_nocase( p, "drop entity" ) ) {
108 else if ( string_equal_nocase( p, "merge patches" ) ) {
111 else if ( string_equal_nocase( p, "split patches" ) ) {
114 else if ( string_equal_nocase( p, "split patches rows" ) ) {
117 else if ( string_equal_nocase( p, "split patches cols" ) ) {
120 else if ( string_equal_nocase( p, "turn edge" ) ) {
123 else if ( string_equal_nocase( p, "reset textures..." ) ) {
126 else if ( string_equal_nocase( p, "pitomatic" ) ) {
129 else if ( string_equal_nocase( p, "vis viewer" ) ) {
132 else if ( string_equal_nocase( p, "stair builder..." ) ) {
135 else if ( string_equal_nocase( p, "door builder..." ) ) {
138 else if ( string_equal_nocase( p, "intersect..." ) ) {
141 else if ( string_equal_nocase( p, "make chain..." ) ) {
144 else if ( string_equal_nocase( p, "path plotter..." ) ) {
147 else if ( string_equal_nocase( p, "about..." ) ) {
148 DoMessageBox( PLUGIN_ABOUT, "About", eMB_OK );
152 const char* QERPlug_GetCommandTitleList(){
157 const int NUM_TOOLBARBUTTONS = 13;
159 std::size_t ToolbarButtonCount( void ) {
160 return NUM_TOOLBARBUTTONS;
163 class CBobtoolzToolbarButton : public IToolbarButton
166 virtual const char* getImage() const {
168 case 0: return "bobtoolz_cleanup.png";
169 case 1: return "bobtoolz_poly.png";
170 // case 2: return "bobtoolz_caulk.png";
172 case 3: return "bobtoolz_treeplanter.png";
173 case 4: return "bobtoolz_trainpathplot.png";
174 case 5: return "bobtoolz_dropent.png";
176 case 7: return "bobtoolz_merge.png";
177 case 8: return "bobtoolz_split.png";
178 case 9: return "bobtoolz_splitrow.png";
179 case 10: return "bobtoolz_splitcol.png";
181 case 12: return "bobtoolz_turnedge.png";
185 virtual EType getType() const {
187 case 2: return eSpace;
188 case 3: return eToggleButton;
189 case 6: return eSpace;
190 case 11: return eSpace;
191 default: return eButton;
194 virtual const char* getText() const {
196 case 0: return "Cleanup";
197 case 1: return "Polygons";
198 // case 2: return "Caulk";
199 case 3: return "Tree Planter";
200 case 4: return "Plot Splines";
201 case 5: return "Drop Entity";
202 case 7: return "Merge 2 Patches";
203 case 8: return "Split Patch";
204 case 9: return "Split Patch Rows";
205 case 10: return "Split Patch Columns";
206 case 12: return "Flip Terrain";
210 virtual const char* getTooltip() const {
212 case 0: return "Brush Cleanup";
213 case 1: return "Polygons";
214 // case 2: return "Caulk selection";
215 case 3: return "Tree Planter";
216 case 4: return "Plot Splines";
217 case 5: return "Drop Entity";
218 case 7: return "Merge 2 Patches";
219 case 8: return "Split Patch";
220 case 9: return "Split Patch Rows";
221 case 10: return "Split Patch Columns";
222 case 12: return "Flip Terrain (Turn Edge)";
227 virtual void activate() const {
231 case 0: DoFixBrushes(); break;
232 case 1: DoPolygonsTB(); break;
233 // case 2: DoCaulkSelection(); break;
234 case 3: DoTreePlanter(); break;
235 case 4: DoTrainPathPlot(); break;
236 case 5: DoDropEnts(); break;
237 case 7: DoMergePatches(); break;
238 case 8: DoSplitPatch(); break;
239 case 9: DoSplitPatchRows(); break;
240 case 10: DoSplitPatchCols(); break;
241 case 12: DoFlipTerrain(); break;
248 CBobtoolzToolbarButton g_bobtoolzToolbarButtons[NUM_TOOLBARBUTTONS];
250 const IToolbarButton* GetToolbarButton( std::size_t index ){
251 g_bobtoolzToolbarButtons[index].mIndex = index;
252 return &g_bobtoolzToolbarButtons[index];
256 #include "modulesystem/singletonmodule.h"
258 #include "iscenegraph.h"
261 #include "ishaders.h"
266 #include "iglrender.h"
269 class BobToolzPluginDependencies :
270 public GlobalRadiantModuleRef,
271 public GlobalUndoModuleRef,
272 public GlobalSceneGraphModuleRef,
273 public GlobalSelectionModuleRef,
274 public GlobalEntityModuleRef,
275 public GlobalEntityClassManagerModuleRef,
276 public GlobalShadersModuleRef,
277 public GlobalShaderCacheModuleRef,
278 public GlobalBrushModuleRef,
279 public GlobalPatchModuleRef,
280 public GlobalOpenGLModuleRef,
281 public GlobalOpenGLStateLibraryModuleRef
284 BobToolzPluginDependencies() :
285 GlobalEntityModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entities" ) ),
286 GlobalEntityClassManagerModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entityclass" ) ),
287 GlobalShadersModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "shaders" ) ),
288 GlobalBrushModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "brushtypes" ) ),
289 GlobalPatchModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "patchtypes" ) ){
293 class BobToolzPluginModule : public TypeSystemRef
295 _QERPluginTable m_plugin;
297 typedef _QERPluginTable Type;
298 STRING_CONSTANT( Name, "bobToolz" );
300 BobToolzPluginModule(){
301 m_plugin.m_pfnQERPlug_Init = QERPlug_Init;
302 m_plugin.m_pfnQERPlug_GetName = QERPlug_GetName;
303 m_plugin.m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
304 m_plugin.m_pfnQERPlug_GetCommandTitleList = QERPlug_GetCommandTitleList;
305 m_plugin.m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
307 BobToolz_construct();
309 ~BobToolzPluginModule(){
312 _QERPluginTable* getTable(){
317 typedef SingletonModule<BobToolzPluginModule, BobToolzPluginDependencies> SingletonBobToolzPluginModule;
319 SingletonBobToolzPluginModule g_BobToolzPluginModule;
322 class BobToolzToolbarDependencies :
323 public ModuleRef<_QERPluginTable>
326 BobToolzToolbarDependencies() :
327 ModuleRef<_QERPluginTable>( "bobToolz" ){
331 class BobToolzToolbarModule : public TypeSystemRef
333 _QERPlugToolbarTable m_table;
335 typedef _QERPlugToolbarTable Type;
336 STRING_CONSTANT( Name, "bobToolz" );
338 BobToolzToolbarModule(){
339 m_table.m_pfnToolbarButtonCount = ToolbarButtonCount;
340 m_table.m_pfnGetToolbarButton = GetToolbarButton;
342 _QERPlugToolbarTable* getTable(){
347 typedef SingletonModule<BobToolzToolbarModule, BobToolzToolbarDependencies> SingletonBobToolzToolbarModule;
349 SingletonBobToolzToolbarModule g_BobToolzToolbarModule;
352 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){
353 initialiseModule( server );
355 g_BobToolzPluginModule.selfRegister();
356 g_BobToolzToolbarModule.selfRegister();