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
106 _( "Filter level3" ),
109 IToolbarButton::eToggleButton
113 _( "Filter level4" ),
116 IToolbarButton::eToggleButton
120 _( "Filter level5" ),
123 IToolbarButton::eToggleButton
127 _( "Filter level6" ),
130 IToolbarButton::eToggleButton
134 _( "Filter level7" ),
137 IToolbarButton::eToggleButton
141 _( "Filter level8" ),
144 IToolbarButton::eToggleButton
148 class UFOAIButton : public IToolbarButton
151 const toolbar_button_info_s *bi;
152 virtual const char* getImage() const {
155 virtual const char* getText() const {
158 virtual const char* getTooltip() const {
161 virtual void activate() const {
165 virtual EType getType() const {
170 UFOAIButton g_ufoaibuttons[NUM_TOOLBAR_BUTTONS];
172 unsigned int ToolbarButtonCount( void ){
173 return NUM_TOOLBAR_BUTTONS;
176 const IToolbarButton* GetToolbarButton( unsigned int index ){
177 g_ufoaibuttons[index].bi = &toolbar_buttons[index];
178 return &g_ufoaibuttons[index];
181 extern "C" const char* QERPlug_Init( void *hApp, void* pMainWidget ){
182 g_pMainWidget = pMainWidget;
189 extern "C" const char* QERPlug_GetName( void ){
190 return (char *) PLUGIN_NAME;
193 extern "C" const char* QERPlug_GetCommandList( void ){
194 return (char *) PLUGIN_COMMANDS;
197 extern "C" void QERPlug_Dispatch( const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush ){
198 if ( !strcmp( p, CMD_ABOUT ) ) {
199 g_FuncTable.m_pfnMessageBox( NULL, PLUGIN_ABOUT, _( "About" ), MB_OK, NULL );
202 Sys_Printf( "Message: %s\n", p );
206 // =============================================================================
209 CSynapseServer* g_pSynapseServer = NULL;
210 CSynapseClientUFOAI g_SynapseClient;
213 #pragma GCC visibility push(default)
215 extern "C" CSynapseClient * SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ){
217 #pragma GCC visibility pop
219 if ( strcmp( version, SYNAPSE_VERSION ) ) {
220 Syn_Printf( "ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version );
223 g_pSynapseServer = pServer;
224 g_pSynapseServer->IncRef();
225 Set_Syn_Printf( g_pSynapseServer->Get_Syn_Printf() );
227 g_SynapseClient.AddAPI( TOOLBAR_MAJOR, UFOAI_MINOR, sizeof( _QERPlugToolbarTable ) );
228 g_SynapseClient.AddAPI( PLUGIN_MAJOR, UFOAI_MINOR, sizeof( _QERPluginTable ) );
230 g_SynapseClient.AddAPI( RADIANT_MAJOR, NULL, sizeof( g_FuncTable ), SYN_REQUIRE, &g_FuncTable );
231 g_SynapseClient.AddAPI( QGL_MAJOR, NULL, sizeof( g_QglTable ), SYN_REQUIRE, &g_QglTable );
232 g_SynapseClient.AddAPI( VFS_MAJOR, "*", sizeof( g_FileSystemTable ), SYN_REQUIRE, &g_FileSystemTable );
234 g_SynapseClient.AddAPI( ENTITY_MAJOR, NULL, sizeof( g_EntityTable ), SYN_REQUIRE, &g_EntityTable );
236 g_SynapseClient.AddAPI( DATA_MAJOR, NULL, sizeof( g_DataTable ), SYN_REQUIRE, &g_DataTable );
238 return &g_SynapseClient;
241 bool CSynapseClientUFOAI::RequestAPI( APIDescriptor_t *pAPI ){
242 if ( !strcmp( pAPI->major_name, PLUGIN_MAJOR ) ) {
243 _QERPluginTable* pTable = static_cast<_QERPluginTable*>( pAPI->mpTable );
245 pTable->m_pfnQERPlug_Init = QERPlug_Init;
246 pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
247 pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
248 pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
251 else if ( !strcmp( pAPI->major_name, TOOLBAR_MAJOR ) ) {
252 _QERPlugToolbarTable* pTable = static_cast<_QERPlugToolbarTable*>( pAPI->mpTable );
254 pTable->m_pfnToolbarButtonCount = &ToolbarButtonCount;
255 pTable->m_pfnGetToolbarButton = &GetToolbarButton;
259 Syn_Printf( "ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo() );
265 const char* CSynapseClientUFOAI::GetInfo(){
266 return PLUGIN_NAME " plugin built " __DATE__ " " RADIANT_VERSION;
269 const char* CSynapseClientUFOAI::GetName(){