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
25 #define CMD_ABOUT "About..."
26 // =============================================================================
30 _QERFuncTable_1 g_FuncTable;
31 _QERQglTable g_QglTable;
32 _QERFileSystemTable g_FileSystemTable;
33 _QEREntityTable g_EntityTable;
34 _QERAppDataTable g_DataTable;
39 // =============================================================================
40 // plugin implementation
42 #define PLUGIN_NAME "Sample plugin"
44 //backwards for some reason
45 static const char *PLUGIN_COMMANDS = CMD_ABOUT ";" CMD_SEP;
46 static const char *PLUGIN_ABOUT = "Sample plugin\n";
48 void DoSample( void ){
49 Sys_Printf( "Sample button hit" );
52 #define NUM_TOOLBAR_BUTTONS 1
53 typedef struct toolbar_button_info_s
59 IToolbarButton::EType type;
60 } toolbar_button_info_t;
62 static const toolbar_button_info_t toolbar_buttons[NUM_TOOLBAR_BUTTONS] =
69 IToolbarButton::eToggleButton
73 class SampleButton : public IToolbarButton
76 const toolbar_button_info_s *bi;
77 virtual const char* getImage() const {
80 virtual const char* getText() const {
83 virtual const char* getTooltip() const {
86 virtual void activate() const {
90 virtual EType getType() const {
95 SampleButton g_samplebuttons[NUM_TOOLBAR_BUTTONS];
97 unsigned int ToolbarButtonCount( void ){
98 return NUM_TOOLBAR_BUTTONS;
101 const IToolbarButton* GetToolbarButton( unsigned int index ){
102 g_samplebuttons[index].bi = &toolbar_buttons[index];
103 return &g_samplebuttons[index];
106 extern "C" const char* QERPlug_Init( void *hApp, void* pMainWidget ){
107 g_pMainWidget = pMainWidget;
112 extern "C" const char* QERPlug_GetName( void ){
113 return (char *) PLUGIN_NAME;
116 extern "C" const char* QERPlug_GetCommandList( void ){
117 return (char *) PLUGIN_COMMANDS;
120 extern "C" void QERPlug_Dispatch( const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush ){
121 if ( !strcmp( p, CMD_ABOUT ) ) {
122 g_FuncTable.m_pfnMessageBox( NULL, PLUGIN_ABOUT, "About", MB_OK, NULL );
125 Sys_Printf( "Message: %s\n", p );
129 // =============================================================================
132 CSynapseServer* g_pSynapseServer = NULL;
133 CSynapseClientSample g_SynapseClient;
136 #pragma GCC visibility push(default)
138 extern "C" CSynapseClient * SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ){
140 #pragma GCC visibility pop
142 if ( strcmp( version, SYNAPSE_VERSION ) ) {
143 Syn_Printf( "ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version );
146 g_pSynapseServer = pServer;
147 g_pSynapseServer->IncRef();
148 Set_Syn_Printf( g_pSynapseServer->Get_Syn_Printf() );
150 g_SynapseClient.AddAPI( TOOLBAR_MAJOR, SAMPLE_MINOR, sizeof( _QERPlugToolbarTable ) );
151 g_SynapseClient.AddAPI( PLUGIN_MAJOR, SAMPLE_MINOR, sizeof( _QERPluginTable ) );
153 g_SynapseClient.AddAPI( RADIANT_MAJOR, NULL, sizeof( g_FuncTable ), SYN_REQUIRE, &g_FuncTable );
154 g_SynapseClient.AddAPI( QGL_MAJOR, NULL, sizeof( g_QglTable ), SYN_REQUIRE, &g_QglTable );
155 g_SynapseClient.AddAPI( VFS_MAJOR, "*", sizeof( g_FileSystemTable ), SYN_REQUIRE, &g_FileSystemTable );
157 g_SynapseClient.AddAPI( ENTITY_MAJOR, NULL, sizeof( g_EntityTable ), SYN_REQUIRE, &g_EntityTable );
159 g_SynapseClient.AddAPI( DATA_MAJOR, NULL, sizeof( g_DataTable ), SYN_REQUIRE, &g_DataTable );
161 return &g_SynapseClient;
164 bool CSynapseClientSample::RequestAPI( APIDescriptor_t *pAPI ){
165 if ( !strcmp( pAPI->major_name, PLUGIN_MAJOR ) ) {
166 _QERPluginTable* pTable = static_cast<_QERPluginTable*>( pAPI->mpTable );
168 pTable->m_pfnQERPlug_Init = QERPlug_Init;
169 pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
170 pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
171 pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
174 else if ( !strcmp( pAPI->major_name, TOOLBAR_MAJOR ) ) {
175 _QERPlugToolbarTable* pTable = static_cast<_QERPlugToolbarTable*>( pAPI->mpTable );
177 pTable->m_pfnToolbarButtonCount = &ToolbarButtonCount;
178 pTable->m_pfnGetToolbarButton = &GetToolbarButton;
182 Syn_Printf( "ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo() );
188 const char* CSynapseClientSample::GetInfo(){
189 return PLUGIN_NAME " plugin built " __DATE__ " " RADIANT_VERSION;
192 const char* CSynapseClientSample::GetName(){