-
Notifications
You must be signed in to change notification settings - Fork 47
/
RadiantModule.cpp
129 lines (97 loc) · 2.83 KB
/
RadiantModule.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include "RadiantModule.h"
#include <iostream>
#include <ctime>
#include "iregistry.h"
#include "icommandsystem.h"
#include "itextstream.h"
#include "iuimanager.h"
#include "ieventmanager.h"
#include "i18n.h"
#include "imainframe.h"
#include "ishaderclipboard.h"
#include "scene/Node.h"
#include "ui/mainframe/ScreenUpdateBlocker.h"
#include "module/StaticModule.h"
#include "ui/modelselector/ModelSelector.h"
#include "EventRateLimiter.h"
#include <wx/app.h>
namespace radiant
{
sigc::signal<void> RadiantModule::signal_radiantStarted() const
{
return _radiantStarted;
}
sigc::signal<void> RadiantModule::signal_radiantShutdown() const
{
return _radiantShutdown;
}
void RadiantModule::broadcastShutdownEvent()
{
_radiantShutdown.emit();
_radiantShutdown.clear();
}
// Broadcasts a "startup" event to all the listeners
void RadiantModule::broadcastStartupEvent()
{
_radiantStarted.emit();
}
// RegisterableModule implementation
const std::string& RadiantModule::getName() const
{
static std::string _name(MODULE_RADIANT_APP);
return _name;
}
const StringSet& RadiantModule::getDependencies() const
{
static StringSet _dependencies;
if (_dependencies.empty())
{
_dependencies.insert(MODULE_COMMANDSYSTEM);
_dependencies.insert(MODULE_XMLREGISTRY);
_dependencies.insert(MODULE_EVENTMANAGER);
}
return _dependencies;
}
void RadiantModule::initialiseModule(const ApplicationContext& ctx)
{
rMessage() << getName() << "::initialiseModule called." << std::endl;
// Reset the node id count
scene::Node::resetIds();
// Subscribe for the post-module init event
module::GlobalModuleRegistry().signal_allModulesInitialised().connect(
sigc::mem_fun(this, &RadiantModule::postModuleInitialisation));
}
void RadiantModule::shutdownModule()
{
rMessage() << getName() << "::shutdownModule called." << std::endl;
_radiantStarted.clear();
_radiantShutdown.clear();
}
void RadiantModule::postModuleInitialisation()
{
// Initialise the mainframe
GlobalMainFrame().construct();
// Initialise the shaderclipboard
GlobalShaderClipboard().clear();
// Broadcast the startup event
broadcastStartupEvent();
// Load the shortcuts from the registry
GlobalEventManager().loadAccelerators();
// Pre-load models
ui::ModelSelector::Populate();
// Show the top level window as late as possible
GlobalMainFrame().getWxTopLevelWindow()->Show();
time_t localtime;
time(&localtime);
rMessage() << "Startup complete at " << ctime(&localtime) << std::endl;
}
// Define the static Radiant module
module::StaticModule<RadiantModule> radiantCoreModule;
// Return the static Radiant module to other code within the main binary
RadiantModulePtr getGlobalRadiant()
{
return std::static_pointer_cast<RadiantModule>(
module::GlobalModuleRegistry().getModule(MODULE_RADIANT_APP)
);
}
} // namespace radiant