]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/brushexport/plugin.cpp
Merge remote-tracking branch 'github/master'
[xonotic/netradiant.git] / contrib / brushexport / plugin.cpp
1 /*
2    Copyright (C) 2006, Thomas Nitschke.
3    All Rights Reserved.
4
5    This file is part of GtkRadiant.
6
7    GtkRadiant is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    GtkRadiant is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GtkRadiant; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 #include "plugin.h"
22
23 #include "iplugin.h"
24 #include "qerplugin.h"
25
26 #include <gtk/gtk.h>
27 #include <gtk/gtktreeview.h>
28
29 #include "debugging/debugging.h"
30 #include "string/string.h"
31 #include "modulesystem/singletonmodule.h"
32 #include "stream/textfilestream.h"
33 #include "stream/stringstream.h"
34 #include "gtkutil/messagebox.h"
35 #include "gtkutil/filechooser.h"
36
37 #include "ibrush.h"
38 #include "iscenegraph.h"
39 #include "iselection.h"
40 #include "ifilesystem.h"
41 #include "ifiletypes.h"
42
43 #include "support.h"
44
45 #include "typesystem.h"
46
47 void CreateWindow( void );
48 void DestroyWindow( void );
49 bool IsWindowOpen( void );
50
51 namespace BrushExport
52 {
53 GtkWindow* g_mainwnd;
54
55 const char* init( void* hApp, void* pMainWidget ){
56         g_mainwnd = (GtkWindow*)pMainWidget;
57         ASSERT_NOTNULL( g_mainwnd );
58         return "";
59 }
60 const char* getName(){
61         return "Brush export Plugin";
62 }
63 const char* getCommandList(){
64         return "Export selected as Wavefront Object;About";
65 }
66 const char* getCommandTitleList(){
67         return "";
68 }
69
70 void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){
71         if ( string_equal( command, "About" ) ) {
72                 GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_mainwnd ), "Brushexport plugin v 2.0 by namespace (www.codecreator.net)\n"
73                                                                                                                                   "Enjoy!\n\nSend feedback to spam@codecreator.net", "About me...",
74                                                                                  eMB_OK,
75                                                                                  eMB_ICONDEFAULT );
76         }
77         else if ( string_equal( command, "Export selected as Wavefront Object" ) ) {
78                 if ( IsWindowOpen() ) {
79                         DestroyWindow();
80                 }
81                 CreateWindow();
82         }
83 }
84 }
85
86 class BrushExportDependencies :
87         public GlobalRadiantModuleRef,
88         public GlobalFiletypesModuleRef,
89         public GlobalBrushModuleRef,
90         public GlobalFileSystemModuleRef,
91         public GlobalSceneGraphModuleRef,
92         public GlobalSelectionModuleRef
93 {
94 public:
95 BrushExportDependencies( void )
96         : GlobalBrushModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "brushtypes" ) )
97 {}
98 };
99
100 class BrushExportModule : public TypeSystemRef
101 {
102 _QERPluginTable m_plugin;
103 public:
104 typedef _QERPluginTable Type;
105 STRING_CONSTANT( Name, "brushexport2" );
106
107 BrushExportModule(){
108         m_plugin.m_pfnQERPlug_Init = &BrushExport::init;
109         m_plugin.m_pfnQERPlug_GetName = &BrushExport::getName;
110         m_plugin.m_pfnQERPlug_GetCommandList = &BrushExport::getCommandList;
111         m_plugin.m_pfnQERPlug_GetCommandTitleList = &BrushExport::getCommandTitleList;
112         m_plugin.m_pfnQERPlug_Dispatch = &BrushExport::dispatch;
113 }
114 _QERPluginTable* getTable(){
115         return &m_plugin;
116 }
117 };
118
119 typedef SingletonModule<BrushExportModule, BrushExportDependencies> SingletonBrushExportModule;
120 SingletonBrushExportModule g_BrushExportModule;
121
122 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){
123         initialiseModule( server );
124         g_BrushExportModule.selfRegister();
125 }