]> git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/meshtex/PluginRegistration.cpp
* added MeshTex plugin src to project (can't compile)
[xonotic/netradiant.git] / contrib / meshtex / PluginRegistration.cpp
1 /**
2  * @file PluginRegistration.cpp
3  * Declares and implements the MeshTexPluginDependencies class, and implements
4  * the plugin library's exported function Radiant_RegisterModules.
5  * @ingroup meshtex-plugin
6  */
7
8 /*
9  * Copyright 2012 Joel Baxter
10  *
11  * This file is part of MeshTex.
12  *
13  * MeshTex is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation, either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * MeshTex is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
25  */
26
27 #include "PluginModule.h"
28
29 #include "iundo.h"
30 #include "iscenegraph.h"
31 #include "iselection.h"
32 #include "ishaders.h"
33 #include "ipatch.h"
34 #include "modulesystem/singletonmodule.h"
35
36
37 /**
38  * Definition (in the declared superclasses) of the Radiant systems that this
39  * plugin depends on. GlobalRadiantModule, GlobalUndoModule,
40  * GlobalSceneGraphModule, GlobalSelectionModule, GlobalShadersModule, and of
41  * course GlobalPatchModule.
42  *
43  * @ingroup meshtex-plugin.
44  */
45 class MeshTexPluginDependencies :
46    public GlobalRadiantModuleRef,
47    public GlobalUndoModuleRef,
48    public GlobalSceneGraphModuleRef,
49    public GlobalSelectionModuleRef,
50    public GlobalShadersModuleRef,
51    public GlobalPatchModuleRef
52 {
53 public:
54    /**
55     * Default constructor. This function's only responsibility is to pass
56     * arguments to superclass constructors.
57     */
58    MeshTexPluginDependencies() :
59       GlobalShadersModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("shaders")),
60       GlobalPatchModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("patchtypes"))
61    {
62    }
63 };
64
65
66 /**
67  * Register as a plugin with Radiant.
68  *
69  * @param server Radiant's module (library) manager.
70  *
71  * @relatesalso MeshTexPluginDependencies
72  */
73
74  typedef SingletonModule<PluginModule, MeshTexPluginDependencies> SingletonMeshTexPluginModule;
75
76 SingletonMeshTexPluginModule g_MeshTexPluginModule;
77
78 extern "C" void RADIANT_DLLEXPORT
79 Radiant_RegisterModules(ModuleServer& server)
80 {
81    // Set ourselves up as a plugin with the necessary dependences.
82    //static SingletonModule<PluginModule, MeshTexPluginDependencies> singleton;
83    // Alert Radiant that there's at least one module to be managed, and
84    // initialize some necessary stuff.
85    // XXX As far as I can tell it's not necessary for EVERY library to do this
86    // but it doesn't hurt, and this way we ensure it gets done.
87    initialiseModule(server);
88    // Register this library. Now we're active as a plugin.
89    g_MeshTexPluginModule.selfRegister();
90 }