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 __ENTITYTABLENAME;
27 _QERBrushTable __BRUSHTABLENAME;
28 _QERPatchTable __PATCHTABLENAME;
29 bool SingleBrushSelected;
34 const char *QERPlug_Init(void *hApp, void *pMainWidget)
36 g_pRadiantWnd = (GtkWidget *) pMainWidget;
38 return "GenSurf for Q3Radiant";
41 const char *QERPlug_GetName()
46 const char *QERPlug_GetCommandList()
48 return "Wall facing 270...;Wall facing 180...;Wall facing 90...;Wall facing 0...;"
49 "Ceiling...;Ground surface...;-;About...";
52 // vMin/vMax provide the bounds of the selection, they are zero if there is no selection
53 // if there is a selection, bSingleBrush will be true if a single brush is selected
54 // if so, typical plugin behaviour (such as primitive creation) would use the bounds as
55 // a rule to create the primitive, then delete the selection
56 void QERPlug_Dispatch(const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)
58 bool Generate = false;
66 if (!strcmp(p, "Ground surface...")) {
67 SingleBrushSelected = bSingleBrush;
69 if (SingleBrushSelected) {
74 Z00 = Z01 = Z10 = Z11 = vMax[2];
77 } else if (!strcmp(p, "Ceiling...")) {
78 SingleBrushSelected = bSingleBrush;
80 if (SingleBrushSelected) {
85 Z00 = Z01 = Z10 = Z11 = vMin[2];
88 } else if (!strcmp(p, "Wall facing 0...")) {
89 SingleBrushSelected = bSingleBrush;
91 if (SingleBrushSelected) {
96 Z00 = Z01 = Z10 = Z11 = vMax[0];
99 } else if (!strcmp(p, "Wall facing 90...")) {
100 SingleBrushSelected = bSingleBrush;
102 if (SingleBrushSelected) {
107 Z00 = Z01 = Z10 = Z11 = vMax[1];
110 } else if (!strcmp(p, "Wall facing 180...")) {
111 SingleBrushSelected = bSingleBrush;
113 if (SingleBrushSelected) {
118 Z00 = Z01 = Z10 = Z11 = vMin[0];
121 } else if (!strcmp(p, "Wall facing 270...")) {
122 SingleBrushSelected = bSingleBrush;
124 if (SingleBrushSelected) {
129 Z00 = Z01 = Z10 = Z11 = vMin[1];
132 } else if (!strcmp(p, "About...")) {
133 About(g_pRadiantWnd);
137 if (SingleBrushSelected) {
145 // =============================================================================
150 class GenSurfSynapseClient : public CSynapseClient {
152 // CSynapseClient API
153 bool RequestAPI(APIDescriptor_t *pAPI);
155 const char *GetInfo();
157 GenSurfSynapseClient()
160 virtual ~GenSurfSynapseClient()
164 CSynapseServer *g_pSynapseServer = NULL;
165 GenSurfSynapseClient g_SynapseClient;
167 extern "C" CSynapseClient *SYNAPSE_DLL_EXPORT
169 Synapse_EnumerateInterfaces(const char *version, CSynapseServer *pServer)
171 if (strcmp(version, SYNAPSE_VERSION)) {
172 Syn_Printf("ERROR: synapse API version mismatch: should be '"
174 "', got '%s'\n", version );
177 g_pSynapseServer = pServer;
178 g_pSynapseServer->IncRef();
179 Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
181 g_SynapseClient.AddAPI(PLUGIN_MAJOR, "gtkgensurf", sizeof(_QERPluginTable));
183 g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(_QERFuncTable_1), SYN_REQUIRE, &g_FuncTable);
184 g_SynapseClient.AddAPI(UIGTK_MAJOR, NULL, sizeof(_QERUIGtkTable), SYN_REQUIRE, &g_UIGtkTable);
185 g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(_QERQglTable), SYN_REQUIRE, &g_GLTable);
186 g_SynapseClient.AddAPI(ENTITY_MAJOR, NULL, sizeof(_QEREntityTable), SYN_REQUIRE, &g_EntityTable);
188 return &g_SynapseClient;
191 bool GenSurfSynapseClient::RequestAPI(APIDescriptor_t *pAPI)
193 if (!strcmp(pAPI->major_name, PLUGIN_MAJOR)) {
194 _QERPluginTable *pTable = static_cast<_QERPluginTable *>( pAPI->mpTable );
196 pTable->m_pfnQERPlug_Init = QERPlug_Init;
197 pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
198 pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
199 pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
203 Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
209 const char *GenSurfSynapseClient::GetInfo()
211 return "GtkGenSurf - built " __DATE__ " "