]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/surface_quake2/surfdlg_plugin.cpp
more eol-style
[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 extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)
65 {
66   if (strcmp(version, SYNAPSE_VERSION))
67   {
68     Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
69     return NULL;
70   }
71   g_pSynapseServer = pServer;
72   g_pSynapseServer->IncRef();
73   Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
74
75   g_SynapseClient.AddAPI(SURFACEDIALOG_MAJOR, "quake2", sizeof(_QERPlugSurfaceTable));
76   g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(_QERFuncTable_1), SYN_REQUIRE, &g_FuncTable);
77   g_SynapseClient.AddAPI(UNDO_MAJOR, NULL, sizeof(_QERUndoTable), SYN_REQUIRE, &g_UndoTable);
78   g_SynapseClient.AddAPI(APPSURFACEDIALOG_MAJOR, NULL, sizeof(_QERAppSurfaceTable), SYN_REQUIRE, &g_AppSurfaceTable);
79   g_SynapseClient.AddAPI(SELECTEDFACE_MAJOR, NULL, sizeof(_QERSelectedFaceTable), SYN_REQUIRE, &g_SelectedFaceTable);
80   g_SynapseClient.AddAPI(SHADERS_MAJOR, "quake2", sizeof(_QERShadersTable), SYN_REQUIRE, &g_ShadersTable);
81   g_SynapseClient.AddAPI(APPSHADERS_MAJOR, NULL, sizeof(_QERAppShadersTable), SYN_REQUIRE, &g_AppShadersTable);
82   g_SynapseClient.AddAPI(DATA_MAJOR, NULL, sizeof(_QERAppDataTable), SYN_REQUIRE, &g_AppDataTable);
83
84   return &g_SynapseClient;
85 }
86
87 bool CSynapseClient_SurfDLG::RequestAPI(APIDescriptor_t *pAPI)
88 {
89   if (!strcmp(pAPI->major_name, SURFACEDIALOG_MAJOR))
90   {
91     _QERPlugSurfaceTable* pSurfDialogTable= static_cast<_QERPlugSurfaceTable*>(pAPI->mpTable);
92     if (!strcmp(pAPI->minor_name, "quake2"))
93     {
94       pSurfDialogTable->m_pfnToggleSurface = &ToggleSurface;
95       pSurfDialogTable->m_pfnDoSurface = &DoSurface;
96       pSurfDialogTable->m_pfnUpdateSurfaceDialog = &UpdateSurfaceDialog;
97       pSurfDialogTable->m_pfnSurfaceDlgFitAll = &SurfaceDlgFitAll;
98       pSurfDialogTable->m_pfnGet_SI_Module_Widget = &Get_SI_Module_Widget;
99       return true;
100     }
101   }
102
103   Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
104   return false;
105 }
106
107 #include "version.h"
108
109 const char* CSynapseClient_SurfDLG::GetInfo()
110 {
111   return "Surface Dialog (Quake 2) module built " __DATE__ " " RADIANT_VERSION;
112 }
113
114 const char* CSynapseClient_SurfDLG::GetName()
115 {
116   return "surface";
117 }
118
119 bool CSynapseClient_SurfDLG::OnActivate()
120 {
121   return true;
122 }