]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
* sample plugin
authormattn <mattn@8a3a26a2-13c4-0310-b231-cf6edde360e5>
Sun, 16 Mar 2008 08:05:56 +0000 (08:05 +0000)
committermattn <mattn@8a3a26a2-13c4-0310-b231-cf6edde360e5>
Sun, 16 Mar 2008 08:05:56 +0000 (08:05 +0000)
git-svn-id: https://zerowing.idsoftware.com/svn/radiant/GtkRadiant/branches/ZeroRadiant@205 8a3a26a2-13c4-0310-b231-cf6edde360e5

config.py
plugins/sample/plugin.cpp [new file with mode: 0644]
plugins/sample/plugin.h [new file with mode: 0644]
plugins/sample/sample.def [new file with mode: 0644]
plugins/sample/sample.vcproj [new file with mode: 0644]

index f6f22b06035eefbd817f8af1b9782efb050613d7..3256686e27927b75c5ad02b274069b8596348168 100644 (file)
--- a/config.py
+++ b/config.py
@@ -112,6 +112,7 @@ class Config:
                                         'plugins/imagem8/imagem8.vcproj',
                                         'plugins/spritemodel/spritemodel.vcproj',
                                         'plugins/textool/TexTool.vcproj',
+                                       # 'plugins/sample/sample.vcproj',
                                         'plugins/map/map.vcproj',
                                         'plugins/mapxml/mapxml.vcproj',
                                         'plugins/shaders/shaders.vcproj',
diff --git a/plugins/sample/plugin.cpp b/plugins/sample/plugin.cpp
new file mode 100644 (file)
index 0000000..186e463
--- /dev/null
@@ -0,0 +1,209 @@
+/*
+Copyright (C) 1999-2007 id Software, Inc. and contributors.
+For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+This file is part of GtkRadiant.
+
+GtkRadiant is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+GtkRadiant is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GtkRadiant; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#include "plugin.h"
+
+#define CMD_SEP "-" 
+#define CMD_ABOUT "About..."
+// =============================================================================
+// Globals
+
+// function tables
+_QERFuncTable_1 g_FuncTable;
+_QERQglTable g_QglTable;
+_QERFileSystemTable g_FileSystemTable;
+_QEREntityTable g_EntityTable;
+_QERAppDataTable g_DataTable;
+
+// the gtk widget
+void *g_pMainWidget;
+
+// =============================================================================
+// plugin implementation
+
+#define PLUGIN_NAME "Sample plugin"
+
+//backwards for some reason
+static const char *PLUGIN_COMMANDS = CMD_ABOUT ";-";
+static const char *PLUGIN_ABOUT = "Sample plugin\n";
+
+void DoSample (void)
+{
+       Sys_Printf("Sample button hit");
+}
+
+#define NUM_TOOLBAR_BUTTONS 1
+typedef struct toolbar_button_info_s
+{
+       char *image;
+       char *text;
+       char *tip;
+       void (*func)();
+       IToolbarButton::EType type;
+} toolbar_button_info_t;
+
+static const toolbar_button_info_t toolbar_buttons[NUM_TOOLBAR_BUTTONS] = 
+{
+       {
+               "sample.bmp",
+               "Sample",
+       "Sample image",
+               DoSample,
+               IToolbarButton::eToggleButton
+       },
+};
+
+class SampleButton : public IToolbarButton
+{
+public:
+       const toolbar_button_info_s *bi;
+       virtual const char* getImage() const
+       {
+               return bi->image;
+       }
+       virtual const char* getText() const
+       {
+               return bi->text;
+       }
+       virtual const char* getTooltip() const
+       {
+               return bi->tip;
+       }
+       virtual void activate() const
+       {
+               bi->func();
+               return ;
+       }
+       virtual EType getType() const
+       {
+               return bi->type;
+       }
+};
+
+SampleButton g_samplebuttons[NUM_TOOLBAR_BUTTONS];
+
+unsigned int ToolbarButtonCount (void)
+{
+       return NUM_TOOLBAR_BUTTONS;
+}
+
+const IToolbarButton* GetToolbarButton (unsigned int index)
+{
+       g_samplebuttons[index].bi = &toolbar_buttons[index];
+       return &g_samplebuttons[index];
+}
+
+extern "C" const char* QERPlug_Init (void *hApp, void* pMainWidget)
+{
+       g_pMainWidget = pMainWidget;
+
+       return PLUGIN_NAME;
+}
+
+extern "C" const char* QERPlug_GetName (void)
+{
+       return (char *) PLUGIN_NAME;
+}
+
+extern "C" const char* QERPlug_GetCommandList (void)
+{
+       return (char *) PLUGIN_COMMANDS;
+}
+
+extern "C" void QERPlug_Dispatch (const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)
+{
+       if (!strcmp(p, CMD_ABOUT)) {
+               g_FuncTable.m_pfnMessageBox(NULL, PLUGIN_ABOUT, "About", MB_OK, NULL);
+       } else {
+               Sys_Printf("Message: %s\n", p);
+       }
+}
+
+// =============================================================================
+// SYNAPSE
+
+CSynapseServer* g_pSynapseServer = NULL;
+CSynapseClientSample g_SynapseClient;
+    
+#if __GNUC__ >= 4
+#pragma GCC visibility push(default)
+#endif
+extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer) 
+{
+#if __GNUC__ >= 4
+#pragma GCC visibility pop
+#endif
+       if (strcmp(version, SYNAPSE_VERSION)) {
+               Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
+               return NULL;
+       }
+       g_pSynapseServer = pServer;
+       g_pSynapseServer->IncRef();
+       Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
+
+       g_SynapseClient.AddAPI(TOOLBAR_MAJOR, SAMPLE_MINOR, sizeof(_QERPlugToolbarTable));
+       g_SynapseClient.AddAPI(PLUGIN_MAJOR, SAMPLE_MINOR, sizeof(_QERPluginTable));
+       
+       g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(g_FuncTable), SYN_REQUIRE, &g_FuncTable);
+       g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(g_QglTable), SYN_REQUIRE, &g_QglTable);
+       g_SynapseClient.AddAPI(VFS_MAJOR, "*", sizeof(g_FileSystemTable), SYN_REQUIRE, &g_FileSystemTable);
+       // get worldspawn
+       g_SynapseClient.AddAPI(ENTITY_MAJOR, NULL, sizeof(g_EntityTable), SYN_REQUIRE, &g_EntityTable);
+       // selected brushes
+       g_SynapseClient.AddAPI(DATA_MAJOR, NULL, sizeof(g_DataTable), SYN_REQUIRE, &g_DataTable);
+
+       return &g_SynapseClient;
+}
+
+bool CSynapseClientSample::RequestAPI (APIDescriptor_t *pAPI)
+{
+       if (!strcmp(pAPI->major_name, PLUGIN_MAJOR)) {
+               _QERPluginTable* pTable= static_cast<_QERPluginTable*>(pAPI->mpTable);
+       
+               pTable->m_pfnQERPlug_Init = QERPlug_Init;
+               pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
+               pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
+               pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
+               return true;
+       } else if (!strcmp(pAPI->major_name, TOOLBAR_MAJOR)) {
+               _QERPlugToolbarTable* pTable= static_cast<_QERPlugToolbarTable*>(pAPI->mpTable);
+       
+               pTable->m_pfnToolbarButtonCount = &ToolbarButtonCount;
+               pTable->m_pfnGetToolbarButton = &GetToolbarButton;
+               return true;
+       }
+       
+       Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
+       return false;
+}
+
+#include "version.h"
+
+const char* CSynapseClientSample::GetInfo()
+{
+       return PLUGIN_NAME " plugin built " __DATE__ " " RADIANT_VERSION;
+}
+
+const char* CSynapseClientSample::GetName()
+{
+       return PLUGIN_NAME;
+}
+
diff --git a/plugins/sample/plugin.h b/plugins/sample/plugin.h
new file mode 100644 (file)
index 0000000..85b6c7d
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+Copyright (C) 1999-2007 id Software, Inc. and contributors.
+For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+This file is part of GtkRadiant.
+
+GtkRadiant is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+GtkRadiant is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GtkRadiant; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#ifndef _PLUGIN_H_
+#define _PLUGIN_H_
+
+/*!
+\todo need general notice about lib purpose etc.
+and the external dependencies (such as GLib, STL, mathlib etc.)
+*/
+
+#include <stdio.h>
+// for CPtrArray for idata.h
+#include "missing.h"
+
+#include "synapse.h"
+#include "iplugin.h"
+#include "itoolbar.h"
+#define USE_QERTABLE_DEFINE
+#include "qerplugin.h"
+#include "igl.h"
+#include "ifilesystem.h"
+#include "ientity.h"
+#include "idata.h"
+
+extern _QERFuncTable_1 g_FuncTable;
+extern _QERQglTable g_QglTable;
+extern _QERFileSystemTable g_FileSystemTable;
+extern _QEREntityTable g_EntityTable;
+extern _QERAppDataTable g_DataTable;
+extern void *g_pMainWidget;
+
+extern CSynapseServer* g_pSynapseServer;
+
+class CSynapseClientSample : public CSynapseClient
+{
+public:
+  // CSynapseClient API
+  bool RequestAPI(APIDescriptor_t *pAPI);
+  const char* GetInfo();
+  const char* GetName();
+
+  CSynapseClientSample() { }
+  virtual ~CSynapseClientSample() { }
+};
+
+#define SAMPLE_MINOR "sample"
+
+#endif // _PLUGIN_H_
diff --git a/plugins/sample/sample.def b/plugins/sample/sample.def
new file mode 100644 (file)
index 0000000..f1f7a84
--- /dev/null
@@ -0,0 +1,8 @@
+; sample.def : Declares the module parameters for the DLL.
+
+LIBRARY      "SAMPLE"
+DESCRIPTION  'SAMPLE Windows Dynamic Link Library'
+
+EXPORTS
+    ; Explicit exports can go here
+       Synapse_EnumerateInterfaces @1
diff --git a/plugins/sample/sample.vcproj b/plugins/sample/sample.vcproj
new file mode 100644 (file)
index 0000000..7f196c7
--- /dev/null
@@ -0,0 +1,65 @@
+<?xml version="1.0" ?><VisualStudioProject Name="sample" ProjectGUID="{65D02375-63EE-4A8A-9F8E-504B1D5A1D02}" ProjectType="Visual C++" RootNamespace="sample" Version="8.00">\r
+       <Platforms>\r
+               <Platform Name="Win32"/>\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration CharacterSet="2" ConfigurationType="1" IntermediateDirectory="$(ConfigurationName)" Name="Debug|Win32" OutputDirectory="$(SolutionDir)$(ConfigurationName)">\r
+                       <Tool Name="VCPreBuildEventTool"/>\r
+                       <Tool Name="VCCustomBuildTool"/>\r
+                       <Tool Name="VCXMLDataGeneratorTool"/>\r
+                       <Tool Name="VCWebServiceProxyGeneratorTool"/>\r
+                       <Tool Name="VCMIDLTool"/>\r
+                       <Tool AdditionalIncludeDirectories="&quot;$(SolutionDir)\include&quot;;&quot;$(SolutionDir)\libs&quot;;&quot;$(SolutionDir)\..\STLPort\stlport&quot;;&quot;$(SolutionDir)\..\gtk2\include&quot;;&quot;$(SolutionDir)\..\gtk2\include\glib-2.0&quot;;&quot;$(SolutionDir)\..\gtk2\lib\glib-2.0\include&quot;;&quot;$(SolutionDir)\..\libxml2\include&quot;" BasicRuntimeChecks="3" DebugInformationFormat="4" Detect64BitPortabilityProblems="true" DisableSpecificWarnings="4996;4244;4267" MinimalRebuild="true" Name="VCCLCompilerTool" Optimization="0" PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS" RuntimeLibrary="3" WarningLevel="3"/>\r
+                       <Tool Name="VCManagedResourceCompilerTool"/>\r
+                       <Tool Name="VCResourceCompilerTool"/>\r
+                       <Tool Name="VCPreLinkEventTool"/>\r
+                       <Tool GenerateDebugInformation="true" Name="VCLinkerTool" TargetMachine="1"/>\r
+                       <Tool Name="VCALinkTool"/>\r
+                       <Tool Name="VCManifestTool"/>\r
+                       <Tool Name="VCXDCMakeTool"/>\r
+                       <Tool Name="VCBscMakeTool"/>\r
+                       <Tool Name="VCFxCopTool"/>\r
+                       <Tool Name="VCAppVerifierTool"/>\r
+                       <Tool Name="VCWebDeploymentTool"/>\r
+                       <Tool Name="VCPostBuildEventTool"/>\r
+               </Configuration>\r
+               <Configuration CharacterSet="2" ConfigurationType="1" IntermediateDirectory="$(ConfigurationName)" Name="Release|Win32" OutputDirectory="$(SolutionDir)$(ConfigurationName)" WholeProgramOptimization="1">\r
+                       <Tool Name="VCPreBuildEventTool"/>\r
+                       <Tool Name="VCCustomBuildTool"/>\r
+                       <Tool Name="VCXMLDataGeneratorTool"/>\r
+                       <Tool Name="VCWebServiceProxyGeneratorTool"/>\r
+                       <Tool Name="VCMIDLTool"/>\r
+                       <Tool AdditionalIncludeDirectories="&quot;$(SolutionDir)\include&quot;;&quot;$(SolutionDir)\libs&quot;;&quot;$(SolutionDir)\..\STLPort\stlport&quot;;&quot;$(SolutionDir)\..\gtk2\include&quot;;&quot;$(SolutionDir)\..\gtk2\include\glib-2.0&quot;;&quot;$(SolutionDir)\..\gtk2\lib\glib-2.0\include&quot;;&quot;$(SolutionDir)\..\libxml2\include&quot;" DebugInformationFormat="3" Detect64BitPortabilityProblems="true" DisableSpecificWarnings="4996;4244;4267" Name="VCCLCompilerTool" PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS" RuntimeLibrary="2" WarningLevel="3"/>\r
+                       <Tool Name="VCManagedResourceCompilerTool"/>\r
+                       <Tool Name="VCResourceCompilerTool"/>\r
+                       <Tool Name="VCPreLinkEventTool"/>\r
+                       <Tool EnableCOMDATFolding="2" GenerateDebugInformation="true" Name="VCLinkerTool" OptimizeReferences="2" TargetMachine="1"/>\r
+                       <Tool Name="VCALinkTool"/>\r
+                       <Tool Name="VCManifestTool"/>\r
+                       <Tool Name="VCXDCMakeTool"/>\r
+                       <Tool Name="VCBscMakeTool"/>\r
+                       <Tool Name="VCFxCopTool"/>\r
+                       <Tool Name="VCAppVerifierTool"/>\r
+                       <Tool Name="VCWebDeploymentTool"/>\r
+                       <Tool Name="VCPostBuildEventTool"/>\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" Name="Source Files">\r
+                       <File RelativePath=".\plugin.cpp">\r
+                       </File>\r
+               </Filter>\r
+               <Filter Filter="h;hpp;hxx;hm;inl" Name="Header Files">\r
+                       <File RelativePath=".\plugin.h">\r
+                       </File>\r
+               </Filter>\r
+               <Filter Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" Name="Resource Files">\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>
\ No newline at end of file