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