| 1 |
#include "imodule.h" |
| 2 |
|
| 3 |
#include "itextstream.h" |
| 4 |
#include "ieclass.h" |
| 5 |
#include "iscenegraph.h" |
| 6 |
#include "icommandsystem.h" |
| 7 |
#include "ui/imenumanager.h" |
| 8 |
#include "iregistry.h" |
| 9 |
#include "iselection.h" |
| 10 |
#include "iradiant.h" |
| 11 |
#include "iundo.h" |
| 12 |
#include "i18n.h" |
| 13 |
#include "selectionlib.h" |
| 14 |
|
| 15 |
#include "StimResponseEditor.h" |
| 16 |
#include "ResponseEffectTypes.h" |
| 17 |
|
| 18 |
/** |
| 19 |
* Module to register the menu commands for the Stim/Response Editor class. |
| 20 |
*/ |
| 21 |
class StimResponseModule : |
| 22 |
public RegisterableModule |
| 23 |
{ |
| 24 |
public: |
| 25 |
// RegisterableModule implementation |
| 26 |
virtual const std::string& getName() const override |
| 27 |
{ |
| 28 |
static std::string _name("StimResponseEditor"); |
| 29 |
return _name; |
| 30 |
} |
| 31 |
|
| 32 |
const StringSet& getDependencies() const override |
| 33 |
{ |
| 34 |
static StringSet _dependencies |
| 35 |
{ |
| 36 |
MODULE_MENUMANAGER, |
| 37 |
MODULE_COMMANDSYSTEM |
| 38 |
}; |
| 39 |
|
| 40 |
return _dependencies; |
| 41 |
} |
| 42 |
|
| 43 |
void initialiseModule(const IApplicationContext& ctx) override |
| 44 |
{ |
| 45 |
// Add the callback event |
| 46 |
GlobalCommandSystem().addWithCheck("StimResponseEditor", |
| 47 |
cmd::noArgs(ui::StimResponseEditor::ShowDialog), |
| 48 |
[] { return selection::pred::haveEntitiesExact(1); }); |
| 49 |
|
| 50 |
// Add the menu item |
| 51 |
GlobalMenuManager().add("main/entity", // menu location path |
| 52 |
"StimResponse", // name |
| 53 |
ui::menu::ItemType::Item, // type |
| 54 |
_("Stim/Response..."), // caption |
| 55 |
"stimresponse.png", // icon |
| 56 |
"StimResponseEditor"); // event name |
| 57 |
} |
| 58 |
|
| 59 |
void shutdownModule() override |
| 60 |
{ |
| 61 |
// Free any resources, the effect types map holds eclass pointers |
| 62 |
ResponseEffectTypes::Clear(); |
| 63 |
} |
| 64 |
}; |
| 65 |
typedef std::shared_ptr<StimResponseModule> StimResponseModulePtr; |
| 66 |
|
| 67 |
extern "C" void DARKRADIANT_DLLEXPORT RegisterModule(IModuleRegistry& registry) |
| 68 |
{ |
| 69 |
module::performDefaultInitialisation(registry); |
| 70 |
|
| 71 |
registry.registerModule(StimResponseModulePtr(new StimResponseModule)); |
| 72 |
} |