MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / registerControl

Method registerControl

radiant/ui/UserInterfaceModule.cpp:326–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324}
325
326void UserInterfaceModule::registerControl(IUserControlCreator::Ptr control)
327{
328 if (!_userControls.emplace(control->getControlName(), control).second)
329 {
330 throw std::logic_error("The Control with name " + control->getControlName() + " has already been registered");
331 }
332
333 // Check the name for validity
334 if (!string::isAlphaNumeric(control->getControlName()))
335 {
336 throw std::invalid_argument("Control name " + control->getControlName() + " contains invalid characters, only alphanumerics are allowed");
337 }
338
339 // Add a command shortcut toggling this control
340 GlobalCommandSystem().addStatement(fmt::format("{0}{1}", TOGGLE_CONTROL_STATEMENT_PREFIX, control->getControlName()),
341 fmt::format("{0} \"{1}\"", TOGGLE_CONTROL_COMMAND, control->getControlName()), false);
342
343 // Add a command shortcut for making this the main control
344 GlobalCommandSystem().addStatement(fmt::format("{0}{1}", TOGGLE_MAIN_CONTROL_STATEMENT_PREFIX, control->getControlName()),
345 fmt::format("{0} \"{1}\"", TOGGLE_MAIN_CONTROL_COMMAND, control->getControlName()), false);
346}
347
348IUserControlCreator::Ptr UserInterfaceModule::findControl(const std::string& name)
349{

Callers 4

initialiseModuleMethod · 0.45
initialiseModuleMethod · 0.45
initialiseModuleMethod · 0.45
initialiseModuleMethod · 0.45

Calls 4

isAlphaNumericFunction · 0.85
formatFunction · 0.50
getControlNameMethod · 0.45
addStatementMethod · 0.45

Tested by

no test coverage detected