2 GenSurf plugin for GtkRadiant
\r
3 Copyright (C) 2001 David Hyde, Loki software and qeradiant.com
\r
5 This library is free software; you can redistribute it and/or
\r
6 modify it under the terms of the GNU Lesser General Public
\r
7 License as published by the Free Software Foundation; either
\r
8 version 2.1 of the License, or (at your option) any later version.
\r
10 This library is distributed in the hope that it will be useful,
\r
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
13 Lesser General Public License for more details.
\r
15 You should have received a copy of the GNU Lesser General Public
\r
16 License along with this library; if not, write to the Free Software
\r
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
20 #include "gensurf.h"
\r
22 // Global plugin FuncTable
\r
23 _QERFuncTable_1 g_FuncTable;
\r
24 _QERQglTable g_GLTable;
\r
25 _QERUIGtkTable g_UIGtkTable;
\r
26 _QEREntityTable g_EntityTable;
\r
27 bool SingleBrushSelected;
\r
30 #include "iplugin.h"
\r
32 const char* QERPlug_Init(void* hApp, void* pMainWidget)
\r
34 g_pRadiantWnd = (GtkWidget*)pMainWidget;
\r
36 return "GenSurf for Q3Radiant";
\r
39 const char* QERPlug_GetName ()
\r
41 return "GtkGenSurf";
\r
44 const char* QERPlug_GetCommandList ()
\r
46 return "Wall facing 270...;Wall facing 180...;Wall facing 90...;Wall facing 0...;"
\r
47 "Ceiling...;Ground surface...;-;About...";
\r
50 // vMin/vMax provide the bounds of the selection, they are zero if there is no selection
\r
51 // if there is a selection, bSingleBrush will be true if a single brush is selected
\r
52 // if so, typical plugin behaviour (such as primitive creation) would use the bounds as
\r
53 // a rule to create the primitive, then delete the selection
\r
54 void QERPlug_Dispatch (const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)
\r
56 bool Generate = false;
\r
64 if (!strcmp (p, "Ground surface..."))
\r
66 SingleBrushSelected = bSingleBrush;
\r
68 if (SingleBrushSelected)
\r
74 Z00 = Z01 = Z10 = Z11 = vMax[2];
\r
78 else if (!strcmp (p, "Ceiling..."))
\r
80 SingleBrushSelected = bSingleBrush;
\r
82 if(SingleBrushSelected)
\r
88 Z00 = Z01 = Z10 = Z11 = vMin[2];
\r
92 else if (!strcmp (p, "Wall facing 0..."))
\r
94 SingleBrushSelected = bSingleBrush;
\r
96 if (SingleBrushSelected)
\r
102 Z00 = Z01 = Z10 = Z11 = vMax[0];
\r
106 else if (!strcmp (p, "Wall facing 90..."))
\r
108 SingleBrushSelected = bSingleBrush;
\r
110 if (SingleBrushSelected)
\r
116 Z00 = Z01 = Z10 = Z11 = vMax[1];
\r
120 else if (!strcmp (p, "Wall facing 180..."))
\r
122 SingleBrushSelected = bSingleBrush;
\r
124 if (SingleBrushSelected)
\r
130 Z00 = Z01 = Z10 = Z11 = vMin[0];
\r
134 else if (!strcmp (p, "Wall facing 270..."))
\r
136 SingleBrushSelected = bSingleBrush;
\r
138 if (SingleBrushSelected)
\r
144 Z00 = Z01 = Z10 = Z11 = vMin[1];
\r
148 else if (!strcmp(p,"About..."))
\r
149 About (g_pRadiantWnd);
\r
153 if (SingleBrushSelected)
\r
156 gtk_widget_show (g_pWnd);
\r
160 extern "C" LPVOID WINAPI QERPlug_GetFuncTable()
\r
162 return &g_FuncTable;
\r
165 // =============================================================================
\r
168 #include "synapse.h"
\r
170 class GenSurfSynapseClient : public CSynapseClient
\r
173 // CSynapseClient API
\r
174 bool RequestAPI(APIDescriptor_t *pAPI);
\r
175 const char* GetInfo();
\r
177 GenSurfSynapseClient() { }
\r
178 virtual ~GenSurfSynapseClient() { }
\r
181 CSynapseServer* g_pSynapseServer = NULL;
\r
182 GenSurfSynapseClient g_SynapseClient;
\r
184 extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)
\r
186 if (strcmp(version, SYNAPSE_VERSION))
\r
188 Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
\r
191 g_pSynapseServer = pServer;
\r
192 g_pSynapseServer->IncRef();
\r
193 Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
\r
195 g_SynapseClient.AddAPI(PLUGIN_MAJOR, "gtkgensurf", sizeof(_QERPluginTable));
\r
197 g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(_QERFuncTable_1), SYN_REQUIRE, &g_FuncTable);
\r
198 g_SynapseClient.AddAPI(UIGTK_MAJOR, NULL, sizeof(_QERUIGtkTable), SYN_REQUIRE, &g_UIGtkTable);
\r
199 g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(_QERQglTable), SYN_REQUIRE, &g_GLTable);
\r
200 g_SynapseClient.AddAPI(ENTITY_MAJOR, NULL, sizeof(_QEREntityTable), SYN_REQUIRE, &g_EntityTable);
\r
202 return &g_SynapseClient;
\r
205 bool GenSurfSynapseClient::RequestAPI(APIDescriptor_t *pAPI)
\r
207 if (!strcmp(pAPI->major_name, PLUGIN_MAJOR))
\r
209 _QERPluginTable* pTable= static_cast<_QERPluginTable*>(pAPI->mpTable);
\r
211 pTable->m_pfnQERPlug_Init = QERPlug_Init;
\r
212 pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
\r
213 pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
\r
214 pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
\r
218 Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
\r
222 #include "version.h"
\r
224 const char* GenSurfSynapseClient::GetInfo()
\r
226 return "GtkGenSurf - built " __DATE__ " " RADIANT_VERSION;
\r