-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPluginRegistration.cpp
85 lines (78 loc) · 2.68 KB
/
PluginRegistration.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* @file PluginRegistration.cpp
* Declares and implements the MeshTexPluginDependencies class, and implements
* the plugin library's exported function Radiant_RegisterModules.
* @ingroup meshtex-plugin
*/
/*
* Copyright 2012 Joel Baxter
*
* This file is part of MeshTex.
*
* MeshTex 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.
*
* MeshTex 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 MeshTex. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PluginModule.h"
#include "iundo.h"
#include "iscenegraph.h"
#include "iselection.h"
#include "ishaders.h"
#include "ipatch.h"
#include "modulesystem/singletonmodule.h"
/**
* Definition (in the declared superclasses) of the Radiant systems that this
* plugin depends on. GlobalRadiantModule, GlobalUndoModule,
* GlobalSceneGraphModule, GlobalSelectionModule, GlobalShadersModule, and of
* course GlobalPatchModule.
*
* @ingroup meshtex-plugin.
*/
class MeshTexPluginDependencies :
public GlobalRadiantModuleRef,
public GlobalUndoModuleRef,
public GlobalSceneGraphModuleRef,
public GlobalSelectionModuleRef,
public GlobalShadersModuleRef,
public GlobalPatchModuleRef
{
public:
/**
* Default constructor. This function's only responsibility is to pass
* arguments to superclass constructors.
*/
MeshTexPluginDependencies() :
GlobalShadersModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("shaders")),
GlobalPatchModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("patchtypes"))
{
}
};
/**
* Register as a plugin with Radiant.
*
* @param server Radiant's module (library) manager.
*
* @relatesalso MeshTexPluginDependencies
*/
extern "C" void RADIANT_DLLEXPORT
Radiant_RegisterModules(ModuleServer& server)
{
// Set ourselves up as a plugin with the necessary dependences.
static SingletonModule<PluginModule, MeshTexPluginDependencies> singleton;
// Alert Radiant that there's at least one module to be managed, and
// initialize some necessary stuff.
// XXX As far as I can tell it's not necessary for EVERY library to do this
// but it doesn't hurt, and this way we ensure it gets done.
initialiseModule(server);
// Register this library. Now we're active as a plugin.
singleton.selfRegister();
}