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 #define PLUGIN_NAME "bobToolz"
39 void BobToolz_construct(){
42 void BobToolz_destroy(){
55 if ( g_TreePlanter ) {
61 // commands in the menu
62 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";
65 ui::Window g_pRadiantWnd{ui::null};
67 static const char *PLUGIN_ABOUT =
69 RADIANT_NAME " " RADIANT_VERSION "\n\n"
70 "by digibob <digibob@splashdamage.com> (http://www.splashdamage.com)\n\n"
71 "Additional Contributors: MarsMattel, RR2DO2\n\n"
73 RADIANT_NAME " " RADIANT_VERSION_STRING "\n"
76 extern "C" const char* QERPlug_Init( void* hApp, void* pMainWidget ) {
77 g_pRadiantWnd = ui::Window::from(pMainWidget);
79 return PLUGIN_NAME " for " RADIANT_NAME;
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" ) ) {
96 else if ( string_equal_nocase( p, "polygon builder" ) ) {
99 else if ( string_equal_nocase( p, "caulk selection" ) ) {
102 else if ( string_equal_nocase( p, "tree planter" ) ) {
105 else if ( string_equal_nocase( p, "plot splines" ) ) {
108 else if ( string_equal_nocase( p, "drop entity" ) ) {
111 else if ( string_equal_nocase( p, "merge patches" ) ) {
114 else if ( string_equal_nocase( p, "split patches" ) ) {
117 else if ( string_equal_nocase( p, "split patches rows" ) ) {
120 else if ( string_equal_nocase( p, "split patches cols" ) ) {
123 else if ( string_equal_nocase( p, "turn edge" ) ) {
126 else if ( string_equal_nocase( p, "reset textures..." ) ) {
129 else if ( string_equal_nocase( p, "pitomatic" ) ) {
132 else if ( string_equal_nocase( p, "vis viewer" ) ) {
135 else if ( string_equal_nocase( p, "stair builder..." ) ) {
138 else if ( string_equal_nocase( p, "door builder..." ) ) {
141 else if ( string_equal_nocase( p, "intersect..." ) ) {
144 else if ( string_equal_nocase( p, "make chain..." ) ) {
147 else if ( string_equal_nocase( p, "path plotter..." ) ) {
150 else if ( string_equal_nocase( p, "about..." ) ) {
151 DoMessageBox( PLUGIN_ABOUT, "About", eMB_OK );
155 const char* QERPlug_GetCommandTitleList(){
160 const int NUM_TOOLBARBUTTONS = 14;
162 std::size_t ToolbarButtonCount( void ) {
163 return NUM_TOOLBARBUTTONS;
166 class CBobtoolzToolbarButton : public IToolbarButton
169 virtual const char* getImage() const {
171 case 0: return "bobtoolz_cleanup.png";
172 case 1: return "bobtoolz_poly.png";
173 case 2: return "bobtoolz_caulk.png";
175 case 4: return "bobtoolz_treeplanter.png";
176 case 5: return "bobtoolz_trainpathplot.png";
177 case 6: return "bobtoolz_dropent.png";
179 case 8: return "bobtoolz_merge.png";
180 case 9: return "bobtoolz_split.png";
181 case 10: return "bobtoolz_splitrow.png";
182 case 11: return "bobtoolz_splitcol.png";
184 case 13: return "bobtoolz_turnedge.png";
188 virtual EType getType() const {
190 case 3: return eSpace;
191 case 4: return eToggleButton;
192 case 7: return eSpace;
193 case 12: return eSpace;
194 default: return eButton;
197 virtual const char* getText() const {
199 case 0: return "Cleanup";
200 case 1: return "Polygons";
201 case 2: return "Caulk";
202 case 4: return "Tree Planter";
203 case 5: return "Plot Splines";
204 case 6: return "Drop Entity";
205 case 8: return "Merge 2 Patches";
206 case 9: return "Split Patch";
207 case 10: return "Split Patch Rows";
208 case 11: return "Split Patch Columns";
209 case 13: return "Flip Terrain";
213 virtual const char* getTooltip() const {
215 case 0: return "Brush Cleanup";
216 case 1: return "Polygons";
217 case 2: return "Caulk selection";
218 case 4: return "Tree Planter";
219 case 5: return "Plot Splines";
220 case 6: return "Drop Entity";
221 case 8: return "Merge 2 Patches";
222 case 9: return "Split Patch";
223 case 10: return "Split Patch Rows";
224 case 11: return "Split Patch Columns";
225 case 13: return "Flip Terrain (Turn Edge)";
230 virtual void activate() const {
234 case 0: DoFixBrushes(); break;
235 case 1: DoPolygonsTB(); break;
236 case 2: DoCaulkSelection(); break;
237 case 4: DoTreePlanter(); break;
238 case 5: DoTrainPathPlot(); break;
239 case 6: DoDropEnts(); break;
240 case 8: DoMergePatches(); break;
241 case 9: DoSplitPatch(); break;
242 case 10: DoSplitPatchRows(); break;
243 case 11: DoSplitPatchCols(); break;
244 case 13: DoFlipTerrain(); break;
251 CBobtoolzToolbarButton g_bobtoolzToolbarButtons[NUM_TOOLBARBUTTONS];
253 const IToolbarButton* GetToolbarButton( std::size_t index ){
254 g_bobtoolzToolbarButtons[index].mIndex = index;
255 return &g_bobtoolzToolbarButtons[index];
259 #include "modulesystem/singletonmodule.h"
261 #include "iscenegraph.h"
264 #include "ishaders.h"
269 #include "iglrender.h"
272 class BobToolzPluginDependencies :
273 public GlobalRadiantModuleRef,
274 public GlobalUndoModuleRef,
275 public GlobalSceneGraphModuleRef,
276 public GlobalSelectionModuleRef,
277 public GlobalEntityModuleRef,
278 public GlobalEntityClassManagerModuleRef,
279 public GlobalShadersModuleRef,
280 public GlobalShaderCacheModuleRef,
281 public GlobalBrushModuleRef,
282 public GlobalPatchModuleRef,
283 public GlobalOpenGLModuleRef,
284 public GlobalOpenGLStateLibraryModuleRef
287 BobToolzPluginDependencies() :
288 GlobalEntityModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entities" ) ),
289 GlobalEntityClassManagerModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entityclass" ) ),
290 GlobalShadersModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "shaders" ) ),
291 GlobalBrushModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "brushtypes" ) ),
292 GlobalPatchModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "patchtypes" ) ){
296 class BobToolzPluginModule : public TypeSystemRef
298 _QERPluginTable m_plugin;
300 typedef _QERPluginTable Type;
301 STRING_CONSTANT( Name, "bobToolz" );
303 BobToolzPluginModule(){
304 m_plugin.m_pfnQERPlug_Init = QERPlug_Init;
305 m_plugin.m_pfnQERPlug_GetName = QERPlug_GetName;
306 m_plugin.m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
307 m_plugin.m_pfnQERPlug_GetCommandTitleList = QERPlug_GetCommandTitleList;
308 m_plugin.m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
310 BobToolz_construct();
312 ~BobToolzPluginModule(){
315 _QERPluginTable* getTable(){
320 typedef SingletonModule<BobToolzPluginModule, BobToolzPluginDependencies> SingletonBobToolzPluginModule;
322 SingletonBobToolzPluginModule g_BobToolzPluginModule;
325 class BobToolzToolbarDependencies :
326 public ModuleRef<_QERPluginTable>
329 BobToolzToolbarDependencies() :
330 ModuleRef<_QERPluginTable>( "bobToolz" ){
334 class BobToolzToolbarModule : public TypeSystemRef
336 _QERPlugToolbarTable m_table;
338 typedef _QERPlugToolbarTable Type;
339 STRING_CONSTANT( Name, "bobToolz" );
341 BobToolzToolbarModule(){
342 m_table.m_pfnToolbarButtonCount = ToolbarButtonCount;
343 m_table.m_pfnGetToolbarButton = GetToolbarButton;
345 _QERPlugToolbarTable* getTable(){
350 typedef SingletonModule<BobToolzToolbarModule, BobToolzToolbarDependencies> SingletonBobToolzToolbarModule;
352 SingletonBobToolzToolbarModule g_BobToolzToolbarModule;
355 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){
356 initialiseModule( server );
358 g_BobToolzPluginModule.selfRegister();
359 g_BobToolzToolbarModule.selfRegister();