2 GenSurf plugin for GtkRadiant
3 Copyright (C) 2001 David Hyde, Loki software and qeradiant.com
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
22 // Global plugin FuncTable
23 _QERFuncTable_1 g_FuncTable;
24 _QERQglTable g_GLTable;
25 _QERUIGtkTable g_UIGtkTable;
26 _QEREntityTable g_EntityTable;
27 bool SingleBrushSelected;
32 const char* QERPlug_Init(void* hApp, void* pMainWidget)
34 g_pRadiantWnd = (GtkWidget*)pMainWidget;
36 return "GenSurf for Q3Radiant";
39 const char* QERPlug_GetName ()
44 const char* QERPlug_GetCommandList ()
46 return "Wall facing 270...;Wall facing 180...;Wall facing 90...;Wall facing 0...;"
47 "Ceiling...;Ground surface...;-;About...";
50 // vMin/vMax provide the bounds of the selection, they are zero if there is no selection
51 // if there is a selection, bSingleBrush will be true if a single brush is selected
52 // if so, typical plugin behaviour (such as primitive creation) would use the bounds as
53 // a rule to create the primitive, then delete the selection
54 void QERPlug_Dispatch (const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)
56 bool Generate = false;
64 if (!strcmp (p, "Ground surface..."))
66 SingleBrushSelected = bSingleBrush;
68 if (SingleBrushSelected)
74 Z00 = Z01 = Z10 = Z11 = vMax[2];
78 else if (!strcmp (p, "Ceiling..."))
80 SingleBrushSelected = bSingleBrush;
82 if(SingleBrushSelected)
88 Z00 = Z01 = Z10 = Z11 = vMin[2];
92 else if (!strcmp (p, "Wall facing 0..."))
94 SingleBrushSelected = bSingleBrush;
96 if (SingleBrushSelected)
102 Z00 = Z01 = Z10 = Z11 = vMax[0];
106 else if (!strcmp (p, "Wall facing 90..."))
108 SingleBrushSelected = bSingleBrush;
110 if (SingleBrushSelected)
116 Z00 = Z01 = Z10 = Z11 = vMax[1];
120 else if (!strcmp (p, "Wall facing 180..."))
122 SingleBrushSelected = bSingleBrush;
124 if (SingleBrushSelected)
130 Z00 = Z01 = Z10 = Z11 = vMin[0];
134 else if (!strcmp (p, "Wall facing 270..."))
136 SingleBrushSelected = bSingleBrush;
138 if (SingleBrushSelected)
144 Z00 = Z01 = Z10 = Z11 = vMin[1];
148 else if (!strcmp(p,"About..."))
149 About (g_pRadiantWnd);
153 if (SingleBrushSelected)
156 gtk_widget_show (g_pWnd);
160 extern "C" LPVOID WINAPI QERPlug_GetFuncTable()
165 // =============================================================================
170 class GenSurfSynapseClient : public CSynapseClient
173 // CSynapseClient API
174 bool RequestAPI(APIDescriptor_t *pAPI);
175 const char* GetInfo();
177 GenSurfSynapseClient() { }
178 virtual ~GenSurfSynapseClient() { }
181 CSynapseServer* g_pSynapseServer = NULL;
182 GenSurfSynapseClient g_SynapseClient;
184 extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)
186 if (strcmp(version, SYNAPSE_VERSION))
188 Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
191 g_pSynapseServer = pServer;
192 g_pSynapseServer->IncRef();
193 Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
195 g_SynapseClient.AddAPI(PLUGIN_MAJOR, "gtkgensurf", sizeof(_QERPluginTable));
197 g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(_QERFuncTable_1), SYN_REQUIRE, &g_FuncTable);
198 g_SynapseClient.AddAPI(UIGTK_MAJOR, NULL, sizeof(_QERUIGtkTable), SYN_REQUIRE, &g_UIGtkTable);
199 g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(_QERQglTable), SYN_REQUIRE, &g_GLTable);
200 g_SynapseClient.AddAPI(ENTITY_MAJOR, NULL, sizeof(_QEREntityTable), SYN_REQUIRE, &g_EntityTable);
202 return &g_SynapseClient;
205 bool GenSurfSynapseClient::RequestAPI(APIDescriptor_t *pAPI)
207 if (!strcmp(pAPI->major_name, PLUGIN_MAJOR))
209 _QERPluginTable* pTable= static_cast<_QERPluginTable*>(pAPI->mpTable);
211 pTable->m_pfnQERPlug_Init = QERPlug_Init;
212 pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
213 pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
214 pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
218 Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
224 const char* GenSurfSynapseClient::GetInfo()
226 return "GtkGenSurf - built " __DATE__ " " RADIANT_VERSION;