/
UserInterfaceModule.cpp
194 lines (153 loc) · 6.97 KB
/
UserInterfaceModule.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#include "UserInterfaceModule.h"
#include "i18n.h"
#include "ilayer.h"
#include "ifilter.h"
#include "iorthocontextmenu.h"
#include "ieventmanager.h"
#include "wxutil/menu/CommandMenuItem.h"
#include "wxutil/MultiMonitor.h"
#include "module/StaticModule.h"
#include "ui/prefdialog/GameSetupDialog.h"
#include "ui/layers/LayerOrthoContextMenuItem.h"
#include "ui/layers/LayerControlDialog.h"
#include "ui/overlay/OverlayDialog.h"
#include "ui/prefdialog/PrefDialog.h"
#include "ui/Documentation.h"
#include "log/Console.h"
#include "ui/lightinspector/LightInspector.h"
#include "ui/patch/PatchInspector.h"
#include "ui/surfaceinspector/SurfaceInspector.h"
#include "ui/transform/TransformDialog.h"
#include "ui/findshader/FindShader.h"
#include "map/FindMapElements.h"
#include "ui/mapinfo/MapInfoDialog.h"
#include "ui/commandlist/CommandList.h"
#include "ui/filters/editor/FilterDialog.h"
#include "ui/mousetool/ToolMappingDialog.h"
#include "ui/about/AboutDialog.h"
#include "ui/eclasstree/EClassTree.h"
#include "ui/entitylist/EntityList.h"
#include "textool/TexTool.h"
#include "modelexport/ExportAsModelDialog.h"
#include "ui/filters/FilterOrthoContextMenuItem.h"
namespace ui
{
namespace
{
const char* const LAYER_ICON = "layers.png";
const char* const CREATE_LAYER_TEXT = N_("Create Layer...");
const char* const ADD_TO_LAYER_TEXT = N_("Add to Layer...");
const char* const MOVE_TO_LAYER_TEXT = N_("Move to Layer...");
const char* const REMOVE_FROM_LAYER_TEXT = N_("Remove from Layer...");
const char* const SELECT_BY_FILTER_TEXT = N_("Select by Filter...");
const char* const DESELECT_BY_FILTER_TEXT = N_("Deselect by Filter...");
}
const std::string& UserInterfaceModule::getName() const
{
static std::string _name("UserInterfaceModule");
return _name;
}
const StringSet& UserInterfaceModule::getDependencies() const
{
static StringSet _dependencies;
if (_dependencies.empty())
{
_dependencies.insert(MODULE_LAYERS);
_dependencies.insert(MODULE_ORTHOCONTEXTMENU);
_dependencies.insert(MODULE_UIMANAGER);
_dependencies.insert(MODULE_FILTERSYSTEM);
}
return _dependencies;
}
void UserInterfaceModule::initialiseModule(const ApplicationContext& ctx)
{
rMessage() << getName() << "::initialiseModule called." << std::endl;
wxutil::MultiMonitor::printMonitorInfo();
registerUICommands();
// Register LayerControlDialog
GlobalCommandSystem().addCommand("ToggleLayerControlDialog", LayerControlDialog::toggle);
GlobalEventManager().addCommand("ToggleLayerControlDialog", "ToggleLayerControlDialog");
// Create a new menu item connected to the CreateNewLayer command
GlobalOrthoContextMenu().addItem(std::make_shared<wxutil::CommandMenuItem>(
new wxutil::IconTextMenuItem(_(CREATE_LAYER_TEXT), LAYER_ICON), "CreateNewLayer"),
IOrthoContextMenu::SECTION_LAYER
);
// Add the orthocontext menu's layer actions
GlobalOrthoContextMenu().addItem(
std::make_shared<LayerOrthoContextMenuItem>(_(ADD_TO_LAYER_TEXT),
LayerOrthoContextMenuItem::AddToLayer),
IOrthoContextMenu::SECTION_LAYER
);
GlobalOrthoContextMenu().addItem(
std::make_shared<LayerOrthoContextMenuItem>(_(MOVE_TO_LAYER_TEXT),
LayerOrthoContextMenuItem::MoveToLayer),
IOrthoContextMenu::SECTION_LAYER
);
GlobalOrthoContextMenu().addItem(
std::make_shared<LayerOrthoContextMenuItem>(_(REMOVE_FROM_LAYER_TEXT),
LayerOrthoContextMenuItem::RemoveFromLayer),
IOrthoContextMenu::SECTION_LAYER
);
GlobalRadiant().signal_radiantStarted().connect(
sigc::ptr_fun(LayerControlDialog::onRadiantStartup));
// Add the filter actions
GlobalOrthoContextMenu().addItem(
std::make_shared<FilterOrthoContextMenuItem>(_(SELECT_BY_FILTER_TEXT),
FilterOrthoContextMenuItem::SelectByFilter),
IOrthoContextMenu::SECTION_FILTER
);
GlobalOrthoContextMenu().addItem(
std::make_shared<FilterOrthoContextMenuItem>(_(DESELECT_BY_FILTER_TEXT),
FilterOrthoContextMenuItem::DeselectByFilter),
IOrthoContextMenu::SECTION_FILTER
);
}
void UserInterfaceModule::shutdownModule()
{
}
void UserInterfaceModule::registerUICommands()
{
TexTool::registerCommands();
GlobalCommandSystem().addCommand("ProjectSettings", GameSetupDialog::Show);
GlobalCommandSystem().addCommand("Preferences", PrefDialog::ShowPrefDialog);
GlobalCommandSystem().addCommand("ToggleConsole", Console::toggle);
GlobalCommandSystem().addCommand("ToggleLightInspector", LightInspector::toggleInspector);
GlobalCommandSystem().addCommand("SurfaceInspector", SurfaceInspector::toggle);
GlobalCommandSystem().addCommand("PatchInspector", PatchInspector::toggle);
GlobalCommandSystem().addCommand("OverlayDialog", OverlayDialog::toggle);
GlobalCommandSystem().addCommand("TransformDialog", TransformDialog::toggle);
GlobalCommandSystem().addCommand("FindBrush", DoFind);
GlobalCommandSystem().addCommand("MapInfo", MapInfoDialog::ShowDialog);
GlobalCommandSystem().addCommand("EditFiltersDialog", FilterDialog::ShowDialog);
GlobalCommandSystem().addCommand("MouseToolMappingDialog", ToolMappingDialog::ShowDialog);
GlobalCommandSystem().addCommand("FindReplaceTextures", FindAndReplaceShader::ShowDialog);
GlobalCommandSystem().addCommand("ShowCommandList", CommandList::ShowDialog);
GlobalCommandSystem().addCommand("About", AboutDialog::showDialog);
GlobalCommandSystem().addCommand("ShowUserGuide", Documentation::showUserGuide);
GlobalCommandSystem().addCommand("ExportSelectedAsModelDialog", ExportAsModelDialog::ShowDialog);
GlobalCommandSystem().addCommand("EntityClassTree", EClassTree::ShowDialog);
GlobalCommandSystem().addCommand("EntityList", EntityList::toggle);
// ----------------------- Bind Events ---------------------------------------
GlobalEventManager().addCommand("ProjectSettings", "ProjectSettings");
GlobalEventManager().addCommand("Preferences", "Preferences");
GlobalEventManager().addCommand("ToggleConsole", "ToggleConsole");
GlobalEventManager().addCommand("ToggleLightInspector", "ToggleLightInspector");
GlobalEventManager().addCommand("SurfaceInspector", "SurfaceInspector");
GlobalEventManager().addCommand("PatchInspector", "PatchInspector");
GlobalEventManager().addCommand("OverlayDialog", "OverlayDialog");
GlobalEventManager().addCommand("TransformDialog", "TransformDialog");
GlobalEventManager().addCommand("FindBrush", "FindBrush");
GlobalEventManager().addCommand("MapInfo", "MapInfo");
GlobalEventManager().addCommand("EditFiltersDialog", "EditFiltersDialog");
GlobalEventManager().addCommand("MouseToolMappingDialog", "MouseToolMappingDialog");
GlobalEventManager().addCommand("FindReplaceTextures", "FindReplaceTextures");
GlobalEventManager().addCommand("ShowCommandList", "ShowCommandList");
GlobalEventManager().addCommand("About", "About");
GlobalEventManager().addCommand("ShowUserGuide", "ShowUserGuide");
GlobalEventManager().addCommand("ExportSelectedAsModelDialog", "ExportSelectedAsModelDialog");
GlobalEventManager().addCommand("EntityClassTree", "EntityClassTree");
GlobalEventManager().addCommand("EntityList", "EntityList");
}
// Static module registration
module::StaticModule<UserInterfaceModule> userInterfaceModule;
}