2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
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.
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.
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
23 #include "ufoai_filters.h"
26 #define CMD_ABOUT "About..."
27 // =============================================================================
31 _QERFuncTable_1 g_FuncTable;
32 _QERQglTable g_QglTable;
33 _QERFileSystemTable g_FileSystemTable;
34 _QEREntityTable g_EntityTable;
35 _QERAppDataTable g_DataTable;
40 // =============================================================================
41 // plugin implementation
43 #define PLUGIN_NAME "UFO:AI plugin"
44 #define PLUGIN_VERSION "0.1"
46 //backwards for some reason
47 static const char *PLUGIN_COMMANDS = CMD_ABOUT ";" CMD_SEP;
48 static const char *PLUGIN_ABOUT = _("UFO: Alien Invasion plugin " PLUGIN_VERSION "\nby Martin Gerhardy");
50 #define NUM_TOOLBAR_BUTTONS FILTER_MAX
51 typedef struct toolbar_button_info_s
57 IToolbarButton::EType type;
58 } toolbar_button_info_t;
60 static const toolbar_button_info_t toolbar_buttons[NUM_TOOLBAR_BUTTONS] =
63 "ufoai_actorclip.bmp",
64 _("Filter actorclip"),
67 IToolbarButton::eToggleButton
70 "ufoai_weaponclip.bmp",
71 _("Filter weaponclip"),
73 DoWeaponClipFiltering,
74 IToolbarButton::eToggleButton
81 IToolbarButton::eToggleButton
88 IToolbarButton::eToggleButton
95 IToolbarButton::eToggleButton
102 IToolbarButton::eToggleButton
109 IToolbarButton::eToggleButton
116 IToolbarButton::eToggleButton
123 IToolbarButton::eToggleButton
130 IToolbarButton::eToggleButton
137 IToolbarButton::eToggleButton
144 IToolbarButton::eToggleButton
148 class UFOAIButton : public IToolbarButton
151 const toolbar_button_info_s *bi;
152 virtual const char* getImage() const
156 virtual const char* getText() const
160 virtual const char* getTooltip() const
164 virtual void activate() const
169 virtual EType getType() const
175 UFOAIButton g_ufoaibuttons[NUM_TOOLBAR_BUTTONS];
177 unsigned int ToolbarButtonCount (void)
179 return NUM_TOOLBAR_BUTTONS;
182 const IToolbarButton* GetToolbarButton (unsigned int index)
184 g_ufoaibuttons[index].bi = &toolbar_buttons[index];
185 return &g_ufoaibuttons[index];
188 extern "C" const char* QERPlug_Init (void *hApp, void* pMainWidget)
190 g_pMainWidget = pMainWidget;
197 extern "C" const char* QERPlug_GetName (void)
199 return (char *) PLUGIN_NAME;
202 extern "C" const char* QERPlug_GetCommandList (void)
204 return (char *) PLUGIN_COMMANDS;
207 extern "C" void QERPlug_Dispatch (const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)
209 if (!strcmp(p, CMD_ABOUT)) {
210 g_FuncTable.m_pfnMessageBox(NULL, PLUGIN_ABOUT, _("About"), MB_OK, NULL);
212 Sys_Printf("Message: %s\n", p);
216 // =============================================================================
219 CSynapseServer* g_pSynapseServer = NULL;
220 CSynapseClientUFOAI g_SynapseClient;
223 #pragma GCC visibility push(default)
225 extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)
228 #pragma GCC visibility pop
230 if (strcmp(version, SYNAPSE_VERSION)) {
231 Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
234 g_pSynapseServer = pServer;
235 g_pSynapseServer->IncRef();
236 Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
238 g_SynapseClient.AddAPI(TOOLBAR_MAJOR, UFOAI_MINOR, sizeof(_QERPlugToolbarTable));
239 g_SynapseClient.AddAPI(PLUGIN_MAJOR, UFOAI_MINOR, sizeof(_QERPluginTable));
241 g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(g_FuncTable), SYN_REQUIRE, &g_FuncTable);
242 g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(g_QglTable), SYN_REQUIRE, &g_QglTable);
243 g_SynapseClient.AddAPI(VFS_MAJOR, "*", sizeof(g_FileSystemTable), SYN_REQUIRE, &g_FileSystemTable);
245 g_SynapseClient.AddAPI(ENTITY_MAJOR, NULL, sizeof(g_EntityTable), SYN_REQUIRE, &g_EntityTable);
247 g_SynapseClient.AddAPI(DATA_MAJOR, NULL, sizeof(g_DataTable), SYN_REQUIRE, &g_DataTable);
249 return &g_SynapseClient;
252 bool CSynapseClientUFOAI::RequestAPI (APIDescriptor_t *pAPI)
254 if (!strcmp(pAPI->major_name, PLUGIN_MAJOR)) {
255 _QERPluginTable* pTable= static_cast<_QERPluginTable*>(pAPI->mpTable);
257 pTable->m_pfnQERPlug_Init = QERPlug_Init;
258 pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
259 pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
260 pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
262 } else if (!strcmp(pAPI->major_name, TOOLBAR_MAJOR)) {
263 _QERPlugToolbarTable* pTable= static_cast<_QERPlugToolbarTable*>(pAPI->mpTable);
265 pTable->m_pfnToolbarButtonCount = &ToolbarButtonCount;
266 pTable->m_pfnGetToolbarButton = &GetToolbarButton;
270 Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
276 const char* CSynapseClientUFOAI::GetInfo()
278 return PLUGIN_NAME " plugin built " __DATE__ " " RADIANT_VERSION;
281 const char* CSynapseClientUFOAI::GetName()