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";
50 Sys_Printf("Sample button hit");
53 #define NUM_TOOLBAR_BUTTONS 1
54 typedef struct toolbar_button_info_s
60 IToolbarButton::EType type;
61 } toolbar_button_info_t;
63 static const toolbar_button_info_t toolbar_buttons[NUM_TOOLBAR_BUTTONS] =
70 IToolbarButton::eToggleButton
74 class SampleButton : public IToolbarButton
77 const toolbar_button_info_s *bi;
78 virtual const char* getImage() const
82 virtual const char* getText() const
86 virtual const char* getTooltip() const
90 virtual void activate() const
95 virtual EType getType() const
101 SampleButton g_samplebuttons[NUM_TOOLBAR_BUTTONS];
103 unsigned int ToolbarButtonCount (void)
105 return NUM_TOOLBAR_BUTTONS;
108 const IToolbarButton* GetToolbarButton (unsigned int index)
110 g_samplebuttons[index].bi = &toolbar_buttons[index];
111 return &g_samplebuttons[index];
114 extern "C" const char* QERPlug_Init (void *hApp, void* pMainWidget)
116 g_pMainWidget = pMainWidget;
121 extern "C" const char* QERPlug_GetName (void)
123 return (char *) PLUGIN_NAME;
126 extern "C" const char* QERPlug_GetCommandList (void)
128 return (char *) PLUGIN_COMMANDS;
131 extern "C" void QERPlug_Dispatch (const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)
133 if (!strcmp(p, CMD_ABOUT)) {
134 g_FuncTable.m_pfnMessageBox(NULL, PLUGIN_ABOUT, "About", MB_OK, NULL);
136 Sys_Printf("Message: %s\n", p);
140 // =============================================================================
143 CSynapseServer* g_pSynapseServer = NULL;
144 CSynapseClientSample g_SynapseClient;
147 #pragma GCC visibility push(default)
149 extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)
152 #pragma GCC visibility pop
154 if (strcmp(version, SYNAPSE_VERSION)) {
155 Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
158 g_pSynapseServer = pServer;
159 g_pSynapseServer->IncRef();
160 Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
162 g_SynapseClient.AddAPI(TOOLBAR_MAJOR, SAMPLE_MINOR, sizeof(_QERPlugToolbarTable));
163 g_SynapseClient.AddAPI(PLUGIN_MAJOR, SAMPLE_MINOR, sizeof(_QERPluginTable));
165 g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(g_FuncTable), SYN_REQUIRE, &g_FuncTable);
166 g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(g_QglTable), SYN_REQUIRE, &g_QglTable);
167 g_SynapseClient.AddAPI(VFS_MAJOR, "*", sizeof(g_FileSystemTable), SYN_REQUIRE, &g_FileSystemTable);
169 g_SynapseClient.AddAPI(ENTITY_MAJOR, NULL, sizeof(g_EntityTable), SYN_REQUIRE, &g_EntityTable);
171 g_SynapseClient.AddAPI(DATA_MAJOR, NULL, sizeof(g_DataTable), SYN_REQUIRE, &g_DataTable);
173 return &g_SynapseClient;
176 bool CSynapseClientSample::RequestAPI (APIDescriptor_t *pAPI)
178 if (!strcmp(pAPI->major_name, PLUGIN_MAJOR)) {
179 _QERPluginTable* pTable= static_cast<_QERPluginTable*>(pAPI->mpTable);
181 pTable->m_pfnQERPlug_Init = QERPlug_Init;
182 pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
183 pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
184 pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
186 } else if (!strcmp(pAPI->major_name, TOOLBAR_MAJOR)) {
187 _QERPlugToolbarTable* pTable= static_cast<_QERPlugToolbarTable*>(pAPI->mpTable);
189 pTable->m_pfnToolbarButtonCount = &ToolbarButtonCount;
190 pTable->m_pfnGetToolbarButton = &GetToolbarButton;
194 Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
200 const char* CSynapseClientSample::GetInfo()
202 return PLUGIN_NAME " plugin built " __DATE__ " " RADIANT_VERSION;
205 const char* CSynapseClientSample::GetName()