]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/surface_quake2/surfdlg_plugin.cpp
some updates to the Linux build system - obtained a core binary and all required...
[xonotic/netradiant.git] / plugins / surface_quake2 / surfdlg_plugin.cpp
1 /*\r
2 Copyright (c) 2001, Loki software, inc.\r
3 All rights reserved.\r
4 \r
5 Redistribution and use in source and binary forms, with or without modification, \r
6 are permitted provided that the following conditions are met:\r
7 \r
8 Redistributions of source code must retain the above copyright notice, this list \r
9 of conditions and the following disclaimer.\r
10 \r
11 Redistributions in binary form must reproduce the above copyright notice, this\r
12 list of conditions and the following disclaimer in the documentation and/or\r
13 other materials provided with the distribution.\r
14 \r
15 Neither the name of Loki software nor the names of its contributors may be used \r
16 to endorse or promote products derived from this software without specific prior \r
17 written permission. \r
18 \r
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' \r
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \r
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
22 DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY\r
23 DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r
26 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
29 */\r
30 \r
31 #include <stdio.h>\r
32 #include "surfdlg_plugin.h"\r
33 #include "surfacedialog.h"\r
34 \r
35 #include "synapse.h"\r
36 \r
37 class CSynapseClient_SurfDLG : public CSynapseClient\r
38 {\r
39 public:\r
40   // CSynapseClient API\r
41   bool RequestAPI(APIDescriptor_t *pAPI);\r
42   const char* GetInfo();\r
43   const char* GetName();\r
44   bool OnActivate();\r
45 \r
46   CSynapseClient_SurfDLG() { }\r
47   virtual ~CSynapseClient_SurfDLG() { }\r
48 };\r
49 \r
50 // =============================================================================\r
51 // SYNAPSE\r
52 \r
53 _QERFuncTable_1 g_FuncTable;\r
54 _QERUndoTable g_UndoTable;\r
55 _QERAppSurfaceTable g_AppSurfaceTable;\r
56 _QERSelectedFaceTable g_SelectedFaceTable;\r
57 _QERShadersTable g_ShadersTable;\r
58 _QERAppShadersTable g_AppShadersTable;\r
59 _QERAppDataTable g_AppDataTable;\r
60 \r
61 CSynapseServer* g_pSynapseServer = NULL;\r
62 CSynapseClient_SurfDLG g_SynapseClient;\r
63 \r
64 #if __GNUC__ >= 4\r
65 #pragma GCC visibility push(default)\r
66 #endif\r
67 extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {\r
68 #if __GNUC__ >= 4\r
69 #pragma GCC visibility pop\r
70 #endif\r
71   if (strcmp(version, SYNAPSE_VERSION))\r
72   {\r
73     Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);\r
74     return NULL;\r
75   }\r
76   g_pSynapseServer = pServer;\r
77   g_pSynapseServer->IncRef();\r
78   Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());\r
79 \r
80   g_SynapseClient.AddAPI(SURFACEDIALOG_MAJOR, "quake2", sizeof(_QERPlugSurfaceTable));\r
81   g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(_QERFuncTable_1), SYN_REQUIRE, &g_FuncTable);\r
82   g_SynapseClient.AddAPI(UNDO_MAJOR, NULL, sizeof(_QERUndoTable), SYN_REQUIRE, &g_UndoTable);\r
83   g_SynapseClient.AddAPI(APPSURFACEDIALOG_MAJOR, NULL, sizeof(_QERAppSurfaceTable), SYN_REQUIRE, &g_AppSurfaceTable);\r
84   g_SynapseClient.AddAPI(SELECTEDFACE_MAJOR, NULL, sizeof(_QERSelectedFaceTable), SYN_REQUIRE, &g_SelectedFaceTable);\r
85   g_SynapseClient.AddAPI(SHADERS_MAJOR, "quake2", sizeof(_QERShadersTable), SYN_REQUIRE, &g_ShadersTable);\r
86   g_SynapseClient.AddAPI(APPSHADERS_MAJOR, NULL, sizeof(_QERAppShadersTable), SYN_REQUIRE, &g_AppShadersTable);\r
87   g_SynapseClient.AddAPI(DATA_MAJOR, NULL, sizeof(_QERAppDataTable), SYN_REQUIRE, &g_AppDataTable);\r
88 \r
89   return &g_SynapseClient;\r
90 }\r
91 \r
92 bool CSynapseClient_SurfDLG::RequestAPI(APIDescriptor_t *pAPI)\r
93 {\r
94   if (!strcmp(pAPI->major_name, SURFACEDIALOG_MAJOR))\r
95   {\r
96     _QERPlugSurfaceTable* pSurfDialogTable= static_cast<_QERPlugSurfaceTable*>(pAPI->mpTable);\r
97     if (!strcmp(pAPI->minor_name, "quake2"))\r
98     {\r
99       pSurfDialogTable->m_pfnToggleSurface = &ToggleSurface;\r
100       pSurfDialogTable->m_pfnDoSurface = &DoSurface;\r
101       pSurfDialogTable->m_pfnUpdateSurfaceDialog = &UpdateSurfaceDialog;\r
102       pSurfDialogTable->m_pfnSurfaceDlgFitAll = &SurfaceDlgFitAll;\r
103       pSurfDialogTable->m_pfnGet_SI_Module_Widget = &Get_SI_Module_Widget;\r
104       return true;\r
105     }\r
106   }\r
107 \r
108   Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());\r
109   return false;\r
110 }\r
111 \r
112 #include "version.h"\r
113 \r
114 const char* CSynapseClient_SurfDLG::GetInfo()\r
115 {\r
116   return "Surface Dialog (Quake 2) module built " __DATE__ " " RADIANT_VERSION;\r
117 }\r
118 \r
119 const char* CSynapseClient_SurfDLG::GetName()\r
120 {\r
121   return "surface";\r
122 }\r
123 \r
124 bool CSynapseClient_SurfDLG::OnActivate()\r
125 {\r
126   return true;\r
127 }\r