| 1 |
// Project related |
| 2 |
#include "ReadableEditorDialog.h" |
| 3 |
#include "ReadableReloader.h" |
| 4 |
#include "gui/GuiManager.h" |
| 5 |
|
| 6 |
// General |
| 7 |
#include "debugging/debugging.h" |
| 8 |
#include "i18n.h" |
| 9 |
|
| 10 |
// Modules |
| 11 |
#include "icommandsystem.h" |
| 12 |
#include "ientity.h" |
| 13 |
#include "ifilesystem.h" |
| 14 |
#include "ifonts.h" |
| 15 |
#include "igame.h" |
| 16 |
#include "igl.h" |
| 17 |
#include "ui/imainframe.h" |
| 18 |
#include "imap.h" |
| 19 |
#include "ipreferencesystem.h" |
| 20 |
#include "iradiant.h" |
| 21 |
#include "iregistry.h" |
| 22 |
#include "irender.h" |
| 23 |
#include "ishaders.h" |
| 24 |
#include "ui/imenumanager.h" |
| 25 |
#include "iarchive.h" |
| 26 |
|
| 27 |
class GuiModule : |
| 28 |
public RegisterableModule, |
| 29 |
public std::enable_shared_from_this<GuiModule> |
| 30 |
{ |
| 31 |
public: |
| 32 |
// RegisterableModule implementation |
| 33 |
const std::string& getName() const override |
| 34 |
{ |
| 35 |
static std::string _name("GUI Editing"); |
| 36 |
return _name; |
| 37 |
} |
| 38 |
|
| 39 |
const StringSet& getDependencies() const override |
| 40 |
{ |
| 41 |
static StringSet _dependencies |
| 42 |
{ |
| 43 |
MODULE_COMMANDSYSTEM, |
| 44 |
MODULE_FONTMANAGER, |
| 45 |
MODULE_GAMEMANAGER, |
| 46 |
MODULE_MAINFRAME, |
| 47 |
MODULE_MAP, |
| 48 |
MODULE_OPENGL, |
| 49 |
MODULE_PREFERENCESYSTEM, |
| 50 |
MODULE_RENDERSYSTEM, |
| 51 |
MODULE_SHADERSYSTEM, |
| 52 |
MODULE_MENUMANAGER, |
| 53 |
MODULE_VIRTUALFILESYSTEM, |
| 54 |
MODULE_XMLREGISTRY, |
| 55 |
}; |
| 56 |
|
| 57 |
return _dependencies; |
| 58 |
} |
| 59 |
|
| 60 |
void initialiseModule(const IApplicationContext& ctx) override |
| 61 |
{ |
| 62 |
GlobalCommandSystem().addCommand("ReadableEditorDialog", ui::ReadableEditorDialog::RunDialog); |
| 63 |
GlobalCommandSystem().addCommand("ReloadReadables", ui::ReadableReloader::run); |
| 64 |
|
| 65 |
GlobalMainFrame().signal_MainFrameConstructed().connect( |
| 66 |
sigc::mem_fun(this, &GuiModule::onMainFrameConstructed) |
| 67 |
); |
| 68 |
|
| 69 |
// Create the Readable Editor Preferences |
| 70 |
constructPreferences(); |
| 71 |
} |
| 72 |
|
| 73 |
private: |
| 74 |
void onMainFrameConstructed() |
| 75 |
{ |
| 76 |
// Add menu items on radiant startup, to ensure that all menu items are existent at this point |
| 77 |
ui::menu::IMenuManager& mm = GlobalMenuManager(); |
| 78 |
|
| 79 |
mm.add("main/entity", |
| 80 |
"ReadableEditorDialog", ui::menu::ItemType::Item, |
| 81 |
_("Readable Editor"), // caption |
| 82 |
"book.png", // icon |
| 83 |
"ReadableEditorDialog" |
| 84 |
); |
| 85 |
|
| 86 |
mm.insert("main/file/reloadDecls", |
| 87 |
"ReloadReadables", ui::menu::ItemType::Item, |
| 88 |
_("Reload Readable Guis"), // caption |
| 89 |
"book.png", // icon |
| 90 |
"ReloadReadables" |
| 91 |
); |
| 92 |
} |
| 93 |
|
| 94 |
// Adds the preference settings to the prefdialog |
| 95 |
void constructPreferences() |
| 96 |
{ |
| 97 |
// Add a page to the given group |
| 98 |
IPreferencePage& page = GlobalPreferenceSystem().getPage(_("Settings/Readable Editor")); |
| 99 |
|
| 100 |
ComboBoxValueList options; |
| 101 |
|
| 102 |
options.push_back(_("Mod/xdata")); |
| 103 |
options.push_back(_("Mod Base/xdata")); |
| 104 |
options.push_back(_("Custom Folder")); |
| 105 |
|
| 106 |
page.appendCombo(_("XData Storage Folder"), ui::RKEY_READABLES_STORAGE_FOLDER, options); |
| 107 |
|
| 108 |
page.appendPathEntry(_("Custom Folder"), ui::RKEY_READABLES_CUSTOM_FOLDER, true); |
| 109 |
} |
| 110 |
}; |
| 111 |
typedef std::shared_ptr<GuiModule> GuiModulePtr; |
| 112 |
|
| 113 |
extern "C" void DARKRADIANT_DLLEXPORT RegisterModule(IModuleRegistry& registry) |
| 114 |
{ |
| 115 |
module::performDefaultInitialisation(registry); |
| 116 |
|
| 117 |
registry.registerModule(std::make_shared<GuiModule>()); |
| 118 |
registry.registerModule(std::make_shared<gui::GuiManager>()); |
| 119 |
} |