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