Debian Codegraph @

plugins/dm.objectives/objectives.cpp

raw
1 #include "ObjectivesEditor.h"
2
3 #include "i18n.h"
4 #include "imodule.h"
5 #include "ui/imenumanager.h"
6 #include "iradiant.h"
7 #include "iscenegraph.h"
8 #include "ieclass.h"
9 #include "ientity.h"
10 #include "itextstream.h"
11
12 #include "ce/ComponentEditorFactory.h"
13 #include <iostream>
14
15 /**
16 * \defgroup objectives Objectives Editor (Dark Mod only)
17 *
18 * \file objectives.cpp
19 * Main plugin file for the Objectives Editor.
20 *
21 * \namespace objectives
22 * \ingroup objectives
23 * Classes and types comprising the Objectives Editor.
24 */
25
26 /**
27 * API module to register the menu commands for the ObjectivesEditor class.
28 */
29 class ObjectivesEditorModule :
30 public RegisterableModule
31 {
32 public:
33 // RegisterableModule implementation
34 virtual const std::string& getName() const {
35 static std::string _name("ObjectivesEditor");
36 return _name;
37 }
38
39 virtual const StringSet& getDependencies() const {
40 static StringSet _dependencies;
41
42 if (_dependencies.empty()) {
43 _dependencies.insert(MODULE_MENUMANAGER);
44 _dependencies.insert(MODULE_COMMANDSYSTEM);
45 }
46
47 return _dependencies;
48 }
49
50 virtual void initialiseModule(const IApplicationContext& ctx) {
51
52 // Add the callback event
53 GlobalCommandSystem().addCommand(
54 "ObjectivesEditor",
55 objectives::ObjectivesEditor::DisplayDialog
56 );
57
58 // Add the menu item
59 ui::menu::IMenuManager& mm = GlobalMenuManager();
60 mm.add("main/map",
61 "ObjectivesEditor",
62 ui::menu::ItemType::Item,
63 _("Objectives..."),
64 "objectives16.png",
65 "ObjectivesEditor");
66 }
67
68 virtual void shutdownModule() {
69 rMessage() << "ObjectivesEditorModule shutting down.\n";
70
71 // Remove all the registered Component Editors from memory
72 objectives::ce::ComponentEditorFactory::clear();
73 }
74 };
75 typedef std::shared_ptr<ObjectivesEditorModule> ObjectivesEditorModulePtr;
76
77 extern "C" void DARKRADIANT_DLLEXPORT RegisterModule(IModuleRegistry& registry)
78 {
79 module::performDefaultInitialisation(registry);
80
81 registry.registerModule(ObjectivesEditorModulePtr(new ObjectivesEditorModule));
82 }