diff --git a/include/itransformnode.h b/include/itransformnode.h index 0059473e60..18a1aab707 100644 --- a/include/itransformnode.h +++ b/include/itransformnode.h @@ -20,6 +20,6 @@ class IMatrixTransform: public ITransformNode { public: - /// Return a modifiable reference to a contained transformation matrix - virtual Matrix4& localToParent() = 0; + /// Set the value of the contained transformation matrix + virtual void setLocalToParent(const Matrix4& localToParent) = 0; }; \ No newline at end of file diff --git a/libs/module/StaticModule.h b/libs/module/StaticModule.h index 294a9d6d10..063c1d4118 100644 --- a/libs/module/StaticModule.h +++ b/libs/module/StaticModule.h @@ -3,22 +3,6 @@ #include #include "imodule.h" -/** - * greebo: Use a StaticModule to define a static RegisterableModule, - * which enlists itself automatically during application startup. - * - * The template parameter must be a RegisterModule class and - * is automatically registered with the ModuleRegistry by - * the StaticModule constructor. - * - * Since immediate registering is not desired, the constructor - * adds the incoming modules to a static std::list - * for a later routine to add the modules to the registry. - * - * Note: does NOT hold actual shared_ptrs of the RegisterableModule. - * - * Usage: StaticModule myStaticModule; - */ namespace module { @@ -27,12 +11,12 @@ namespace internal /** * Static container holding the modules registered by - * the StaticModule helper. They will be picked up - * and acquired by the ModuleRegistry. - * To support scenarios like the unit test runner (where the + * the StaticModuleRegistration helper. They will be picked up + * and acquired by the ModuleRegistry. + * To support scenarios like the unit test runner (where the * modules are repeatedly loaded, initialised and shut down * again) the module list is not cleared after registration, - * such that another startup event will have the full set of + * such that another startup event will have the full set of * modules properly registered. */ typedef std::function ModuleCreationFunc; @@ -52,20 +36,34 @@ class StaticModuleList : } -template -class StaticModule +/** + * @brief Helper object to register a specific RegisterableModule subclass. + * + * This class is intended to be used statically in the .cpp file of a particular module's + * implementing class, to register the module implementation with the ModuleRegistry. Since + * immediate registering is not desired, the constructor adds the incoming modules to a static + * std::list for a later routine to add the modules to the registry. + * + * Note that this object does NOT hold any reference or pointer to the actual module instance. It + * registers the TYPE of module which will later be instantiated and owned by the ModuleRegistry. + * + * @tparam ModuleType + * A RegisterableModule class which is automatically registered with the ModuleRegistry by the + * StaticModuleRegistration constructor. + */ +template class StaticModuleRegistration { - static_assert(std::is_base_of::value, "ModuleType must be of type RegisterableModule"); + static_assert(std::is_base_of::value, + "ModuleType must be of type RegisterableModule"); public: - StaticModule() + StaticModuleRegistration() { // Add a creator to the list in the backend, it will be called by the registry later - internal::StaticModuleList::Add([]()->RegisterableModulePtr - { - return std::make_shared(); - }); - } + internal::StaticModuleList::Add( + []() -> RegisterableModulePtr { return std::make_shared(); } + ); + } }; } // namespace module diff --git a/libs/registry/Widgets.h b/libs/registry/Widgets.h index b5660e345c..6a3082e37b 100644 --- a/libs/registry/Widgets.h +++ b/libs/registry/Widgets.h @@ -13,131 +13,119 @@ namespace registry { +namespace detail +{ + +template +void setWidgetValueIfKeyExists(const std::string& key, Widget_T& widget) +{ + if (GlobalRegistry().keyExists(key)) + widget.SetValue(registry::getValue(key)); +} + +} // namespace detail + /** * Various bind() overloads to let widgets export their values to the registry * as soon as they fire their changes signal. The value * will be initialised with the one currently present in the registry. * - * Note: due to the use of lambdas it's not possible to disconnect - * the widget's after calling bind(). The widget will keep writing + * Note: due to the use of lambdas it's not possible to disconnect + * the widget's after calling bind(). The widget will keep writing * its value to the registry, unless it's destroyed. */ inline void bindWidget(wxSpinCtrlDouble* spinCtrl, const std::string& key) { - // Set initial value then connect to changed signal - if (GlobalRegistry().keyExists(key)) - { - spinCtrl->SetValue(registry::getValue(key)); - } - - spinCtrl->Bind(wxEVT_SPINCTRLDOUBLE, [=] (wxSpinDoubleEvent& ev) - { - registry::setValue(key, spinCtrl->GetValue()); - ev.Skip(); - }); + detail::setWidgetValueIfKeyExists(key, *spinCtrl); + spinCtrl->Bind(wxEVT_SPINCTRLDOUBLE, [=](wxSpinDoubleEvent& ev) { + registry::setValue(key, spinCtrl->GetValue()); + ev.Skip(); + }); } inline void bindWidget(wxTextCtrl* text, const std::string& key) { - // Set initial value then connect to changed signal - if (GlobalRegistry().keyExists(key)) - { - text->SetValue(registry::getValue(key)); - } - - text->Bind(wxEVT_TEXT, [=] (wxCommandEvent& ev) - { - registry::setValue(key, text->GetValue().ToStdString()); - ev.Skip(); - }); + detail::setWidgetValueIfKeyExists(key, *text); + text->Bind(wxEVT_TEXT, [=](wxCommandEvent& ev) { + registry::setValue(key, text->GetValue().ToStdString()); + ev.Skip(); + }); } inline void bindWidget(wxCheckBox* checkbox, const std::string& key) { - // Set initial value then connect to changed signal - if (GlobalRegistry().keyExists(key)) - { - checkbox->SetValue(registry::getValue(key)); - } - - checkbox->Bind(wxEVT_CHECKBOX, [=] (wxCommandEvent& ev) - { - registry::setValue(key, checkbox->GetValue() ? "1" : "0"); - ev.Skip(); - }); + detail::setWidgetValueIfKeyExists(key, *checkbox); + checkbox->Bind(wxEVT_CHECKBOX, [=](wxCommandEvent& ev) { + registry::setValue(key, checkbox->GetValue() ? "1" : "0"); + ev.Skip(); + }); } inline void bindWidget(wxToggleButton* toggleButton, const std::string& key) { - // Set initial value then connect to changed signal - if (GlobalRegistry().keyExists(key)) - { - toggleButton->SetValue(registry::getValue(key)); - } - - toggleButton->Bind(wxEVT_TOGGLEBUTTON, [=](wxCommandEvent& ev) - { - registry::setValue(key, toggleButton->GetValue() ? "1" : "0"); - ev.Skip(); - }); + detail::setWidgetValueIfKeyExists(key, *toggleButton); + toggleButton->Bind(wxEVT_TOGGLEBUTTON, [=](wxCommandEvent& ev) { + registry::setValue(key, toggleButton->GetValue() ? "1" : "0"); + ev.Skip(); + }); } // ------------- Variants supporting registry::Buffer --------------------- -inline void bindWidgetToBufferedKey(wxCheckBox* checkbox, const std::string& key, +inline void bindWidgetToBufferedKey(wxCheckBox* checkbox, const std::string& key, Buffer& buffer, sigc::signal& resetSignal) { // Set initial value then connect to changed signal checkbox->SetValue(registry::getValue(key) == "1"); checkbox->Bind(wxEVT_CHECKBOX, [=, &buffer] (wxCommandEvent& ev) - { - buffer.set(key, checkbox->GetValue() ? "1" : "0"); + { + buffer.set(key, checkbox->GetValue() ? "1" : "0"); ev.Skip(); }); resetSignal.connect([=, &buffer] { if (buffer.keyExists(key)) { checkbox->SetValue(registry::getValue(key) == "1"); } }); } -inline void bindWidgetToBufferedKey(wxSlider* slider, const std::string& key, +inline void bindWidgetToBufferedKey(wxSlider* slider, const std::string& key, Buffer& buffer, sigc::signal& resetSignal, int factor) { // Set initial value then connect to changed signal slider->SetValue(registry::getValue(key) * factor); slider->Bind(wxEVT_SCROLL_CHANGED, [=, &buffer] (wxScrollEvent& ev) - { - buffer.set(key, string::to_string(static_cast(slider->GetValue()) / factor)); + { + buffer.set(key, string::to_string(static_cast(slider->GetValue()) / factor)); ev.Skip(); }); slider->Bind(wxEVT_SCROLL_THUMBTRACK, [=, &buffer] (wxScrollEvent& ev) - { - buffer.set(key, string::to_string(static_cast(slider->GetValue()) / factor)); + { + buffer.set(key, string::to_string(static_cast(slider->GetValue()) / factor)); ev.Skip(); }); resetSignal.connect([=, &buffer] - { - if (buffer.keyExists(key)) - { - slider->SetValue(registry::getValue(key) * factor); - } + { + if (buffer.keyExists(key)) + { + slider->SetValue(registry::getValue(key) * factor); + } }); } -inline void bindWidgetToBufferedKey(wxChoice* choice, const std::string& key, +inline void bindWidgetToBufferedKey(wxChoice* choice, const std::string& key, Buffer& buffer, sigc::signal& resetSignal, bool storeValueNotIndex) { // Set initial value then connect to changed signal - choice->Select(storeValueNotIndex ? + choice->Select(storeValueNotIndex ? choice->FindString(registry::getValue(key)): registry::getValue(key)); choice->Bind(wxEVT_CHOICE, [=, &buffer] (wxCommandEvent& ev) - { + { if (storeValueNotIndex) { - buffer.set(key, choice->GetStringSelection().ToStdString()); + buffer.set(key, choice->GetStringSelection().ToStdString()); } else { @@ -150,15 +138,15 @@ inline void bindWidgetToBufferedKey(wxChoice* choice, const std::string& key, resetSignal.connect([=, &buffer] { if (buffer.keyExists(key)) - { - choice->Select(storeValueNotIndex ? + { + choice->Select(storeValueNotIndex ? choice->FindString(registry::getValue(key)): registry::getValue(key)); } }); } -inline void bindWidgetToBufferedKey(wxTextCtrl* entry, const std::string& key, +inline void bindWidgetToBufferedKey(wxTextCtrl* entry, const std::string& key, Buffer& buffer, sigc::signal& resetSignal) { // Set initial value then connect to changed signal @@ -168,7 +156,7 @@ inline void bindWidgetToBufferedKey(wxTextCtrl* entry, const std::string& key, } entry->Bind(wxEVT_TEXT, [=, &buffer] (wxCommandEvent& ev) - { + { buffer.set(key, entry->GetValue().ToStdString()); ev.Skip(); }); @@ -176,13 +164,13 @@ inline void bindWidgetToBufferedKey(wxTextCtrl* entry, const std::string& key, resetSignal.connect([=, &buffer] { if (buffer.keyExists(key)) - { + { entry->SetValue(registry::getValue(key)); } }); } -inline void bindWidgetToBufferedKey(wxSpinCtrl* spinCtrl, const std::string& key, +inline void bindWidgetToBufferedKey(wxSpinCtrl* spinCtrl, const std::string& key, Buffer& buffer, sigc::signal& resetSignal) { // Set initial value then connect to changed signal @@ -191,7 +179,7 @@ inline void bindWidgetToBufferedKey(wxSpinCtrl* spinCtrl, const std::string& key spinCtrl->SetValue(registry::getValue(key)); } - spinCtrl->Bind(wxEVT_SPINCTRL, [=, &buffer] (wxSpinEvent& ev) + spinCtrl->Bind(wxEVT_SPINCTRL, [=, &buffer] (wxSpinEvent& ev) { buffer.set(key, string::to_string(spinCtrl->GetValue())); ev.Skip(); @@ -200,13 +188,13 @@ inline void bindWidgetToBufferedKey(wxSpinCtrl* spinCtrl, const std::string& key resetSignal.connect([=, &buffer] { if (buffer.keyExists(key)) - { + { spinCtrl->SetValue(registry::getValue(key)); } }); } -inline void bindWidgetToBufferedKey(wxSpinCtrlDouble* spinCtrl, const std::string& key, +inline void bindWidgetToBufferedKey(wxSpinCtrlDouble* spinCtrl, const std::string& key, Buffer& buffer, sigc::signal& resetSignal) { // Set initial value then connect to changed signal @@ -215,7 +203,7 @@ inline void bindWidgetToBufferedKey(wxSpinCtrlDouble* spinCtrl, const std::strin spinCtrl->SetValue(registry::getValue(key)); } - spinCtrl->Bind(wxEVT_SPINCTRLDOUBLE, [=, &buffer] (wxSpinDoubleEvent& ev) + spinCtrl->Bind(wxEVT_SPINCTRLDOUBLE, [=, &buffer] (wxSpinDoubleEvent& ev) { buffer.set(key, string::to_string(spinCtrl->GetValue())); ev.Skip(); @@ -224,7 +212,7 @@ inline void bindWidgetToBufferedKey(wxSpinCtrlDouble* spinCtrl, const std::strin resetSignal.connect([=, &buffer] { if (buffer.keyExists(key)) - { + { spinCtrl->SetValue(registry::getValue(key)); } }); diff --git a/libs/string/string.h b/libs/string/string.h index aeb4e0ee24..14ee8f65dc 100644 --- a/libs/string/string.h +++ b/libs/string/string.h @@ -8,16 +8,20 @@ namespace string { -/// \brief Returns <0 if \p string is lexicographically less than \p other after converting both to lower-case. -/// Returns >0 if \p string is lexicographically greater than \p other after converting both to lower-case. -/// Returns 0 if \p string is lexicographically equal to \p other after converting both to lower-case. -/// O(n) -inline int icmp(const char* string, const char* other) +/** + * @brief Case-insensitive string comparison. + * + * Behaves like the standard strcmp() but ignores case. + * + * @return A negative integer if lhs is lexicographically less than rhs (ignoring case), 0 if both + * are equal, or a positive integer if lhs is greater than rhs. + */ +inline int icmp(const char* lhs, const char* rhs) { #ifdef WIN32 - return _stricmp(string, other); + return _stricmp(lhs, rhs); #else - return strcasecmp(string, other); + return strcasecmp(lhs, rhs); #endif } diff --git a/libs/wxutil/dialog/DialogBase.h b/libs/wxutil/dialog/DialogBase.h index a57319c24b..d2076f297a 100644 --- a/libs/wxutil/dialog/DialogBase.h +++ b/libs/wxutil/dialog/DialogBase.h @@ -11,14 +11,12 @@ namespace wxutil { /** - * \brief - * Base class for many DarkRadiant dialogs. + * \brief Base class for many DarkRadiant dialogs. * * It comes with a panel/sizer combination pre-populated, use the _mainPanel * member to add more stuff. */ -class DialogBase : - public wxDialog +class DialogBase: public wxDialog { public: /// Construct and initialise diff --git a/radiant/camera/CameraWndManager.cpp b/radiant/camera/CameraWndManager.cpp index 756733818a..054f053f22 100644 --- a/radiant/camera/CameraWndManager.cpp +++ b/radiant/camera/CameraWndManager.cpp @@ -163,7 +163,7 @@ FloatingCamWndPtr CameraWndManager::createFloatingWindow() void CameraWndManager::resetCameraAngles(const cmd::ArgumentList& args) { - doWithActiveCamWnd([](CamWnd& camWnd) + doWithActiveCamWnd([](CamWnd& camWnd) { Vector3 angles; angles[camera::CAMERA_ROLL] = angles[camera::CAMERA_PITCH] = 0; @@ -196,7 +196,7 @@ void CameraWndManager::decreaseCameraSpeed(const cmd::ArgumentList& args) { registry::setValue(RKEY_MOVEMENT_SPEED, movementSpeed); } -void CameraWndManager::benchmark() +void CameraWndManager::benchmark() { doWithActiveCamWnd([](CamWnd& camWnd) { camWnd.benchmark(); }); } @@ -274,19 +274,19 @@ void CameraWndManager::moveCameraCmd(const cmd::ArgumentList& args) return; } - if (arg == "up") + if (arg == "up") { camWnd->moveUpDiscrete(amount); } - else if (arg == "down") + else if (arg == "down") { camWnd->moveDownDiscrete(amount); } - else if (arg == "left") + else if (arg == "left") { camWnd->moveLeftDiscrete(amount); } - if (arg == "right") + if (arg == "right") { camWnd->moveRightDiscrete(amount); } @@ -316,7 +316,7 @@ void CameraWndManager::foreachCamWnd(const std::function& action) _cameras.erase(i++); continue; } - + ++i; action(*cam); } @@ -325,7 +325,7 @@ void CameraWndManager::foreachCamWnd(const std::function& action) void CameraWndManager::doWithActiveCamWnd(const std::function& action) { auto camWnd = getActiveCamWnd(); - + if (camWnd) { action(*camWnd); @@ -437,7 +437,7 @@ void CameraWndManager::loadCameraStrafeDefinitions() } // RegisterableModule implementation -const std::string& CameraWndManager::getName() const +const std::string& CameraWndManager::getName() const { static std::string _name("CameraWndManager"); return _name; @@ -497,7 +497,7 @@ void CameraWndManager::shutdownModule() } // Define the static Camera module -module::StaticModule cameraWndManagerModule; +module::StaticModuleRegistration cameraWndManagerModule; } // namespace diff --git a/radiant/clipboard/ClipboardModule.cpp b/radiant/clipboard/ClipboardModule.cpp index 5313159203..1b20bf8325 100644 --- a/radiant/clipboard/ClipboardModule.cpp +++ b/radiant/clipboard/ClipboardModule.cpp @@ -104,6 +104,6 @@ void ClipboardModule::onAppActivated(wxActivateEvent& ev) ev.Skip(); } -module::StaticModule clipboardModule; +module::StaticModuleRegistration clipboardModule; } diff --git a/radiant/eventmanager/EventManager.cpp b/radiant/eventmanager/EventManager.cpp index 455a89f43a..5b11a67f0e 100644 --- a/radiant/eventmanager/EventManager.cpp +++ b/radiant/eventmanager/EventManager.cpp @@ -119,7 +119,7 @@ void EventManager::resetAcceleratorBindings() loadAcceleratorFromList(shortcutList); } -IEventPtr EventManager::findEvent(const std::string& name) +IEventPtr EventManager::findEvent(const std::string& name) { // Try to lookup the command auto found = _events.find(name); @@ -162,7 +162,7 @@ bool EventManager::alreadyRegistered(const std::string& eventName) { return false; } - + rWarning() << "EventManager: Event " << eventName << " already registered!" << std::endl; return true; } @@ -190,7 +190,7 @@ IEventPtr EventManager::addKeyEvent(const std::string& name, const KeyStateChang { return _emptyEvent; } - + IEventPtr event = std::make_shared(keyStateChangeCallback); // Add the new keyevent to the list @@ -206,7 +206,7 @@ IEventPtr EventManager::addWidgetToggle(const std::string& name) { { return _emptyEvent; } - + IEventPtr event = std::make_shared(); // Add the command to the list @@ -224,10 +224,10 @@ IEventPtr EventManager::addRegistryToggle(const std::string& name, const std::st } IEventPtr event = std::make_shared(registryKey); - - // Add the command to the list + + // Add the command to the list _events[name] = event; - + // Return the pointer to the newly created event return event; } @@ -264,7 +264,7 @@ void EventManager::registerMenuItem(const std::string& eventName, wxMenuItem* it // Set the accelerator of this menu item auto& accelerator = findAccelerator(eventName); - + Event::setMenuItemAccelerator(item, accelerator); // Check if we have an event object corresponding to this event name @@ -282,7 +282,7 @@ void EventManager::registerMenuItem(const std::string& eventName, wxMenuItem* it void EventManager::unregisterMenuItem(const std::string& eventName, wxMenuItem* item) { - for (auto it = _menuItems.lower_bound(eventName); + for (auto it = _menuItems.lower_bound(eventName); it != _menuItems.end() && it != _menuItems.upper_bound(eventName); ++it) { if (it->second != item) continue; @@ -418,7 +418,7 @@ void EventManager::connectAccelerator(wxKeyEvent& keyEvent, const std::string& c connectAccelerator(keyCode, modifierFlags, command); } -void EventManager::disconnectAccelerator(const std::string& command) +void EventManager::disconnectAccelerator(const std::string& command) { auto existing = _accelerators.find(command); @@ -439,7 +439,7 @@ void EventManager::disconnectAccelerator(const std::string& command) void EventManager::setToolItemAccelerator(const std::string& command, const std::string& acceleratorStr) { - for (auto it = _toolItems.lower_bound(command); + for (auto it = _toolItems.lower_bound(command); it != _toolItems.end() && it != _toolItems.upper_bound(command); ++it) { Event::setToolItemAccelerator(it->second, acceleratorStr); @@ -448,19 +448,19 @@ void EventManager::setToolItemAccelerator(const std::string& command, const std: void EventManager::setMenuItemAccelerator(const std::string& command, const std::string& acceleratorStr) { - for (auto it = _menuItems.lower_bound(command); + for (auto it = _menuItems.lower_bound(command); it != _menuItems.end() && it != _menuItems.upper_bound(command); ++it) { Event::setMenuItemAccelerator(it->second, acceleratorStr); } } -void EventManager::disableEvent(const std::string& eventName) +void EventManager::disableEvent(const std::string& eventName) { findEvent(eventName)->setEnabled(false); } -void EventManager::enableEvent(const std::string& eventName) +void EventManager::enableEvent(const std::string& eventName) { findEvent(eventName)->setEnabled(true); } @@ -480,7 +480,7 @@ void EventManager::renameEvent(const std::string& oldEventName, const std::strin _events.insert(std::make_pair(newEventName, existingEvent)); } -void EventManager::removeEvent(const std::string& eventName) +void EventManager::removeEvent(const std::string& eventName) { // Try to lookup the command auto found = _events.find(eventName); @@ -543,7 +543,7 @@ void EventManager::loadAcceleratorFromList(const xml::NodeList& shortcutList) if (replacement != commandRemap.end()) { - rMessage() << "Mapping shortcut of legacy command " << replacement->first << + rMessage() << "Mapping shortcut of legacy command " << replacement->first << " to " << replacement->second << std::endl; cmd = replacement->second; } @@ -579,7 +579,7 @@ void EventManager::foreachEvent(IEventVisitor& eventVisitor) for (const auto& pair : _events) { auto accel = _accelerators.find(pair.first); - eventVisitor.visit(pair.first, + eventVisitor.visit(pair.first, accel != _accelerators.end() ? *accel->second : _emptyAccelerator); } @@ -596,7 +596,7 @@ void EventManager::foreachEvent(IEventVisitor& eventVisitor) if (signatureIsEmptyOrOptional(signature)) { auto accel = _accelerators.find(command); - eventVisitor.visit(command, + eventVisitor.visit(command, accel != _accelerators.end() ? *accel->second : _emptyAccelerator); } }); @@ -655,7 +655,7 @@ EventManager::AcceleratorMap::iterator EventManager::findAccelerator(unsigned in Accelerator& EventManager::findAccelerator(wxKeyEvent& ev) { int keyval = ev.GetKeyCode(); // is always uppercase - + auto it = findAccelerator(keyval, wxutil::Modifier::GetStateForKeyEvent(ev)); return it != _accelerators.end() ? *it->second : _emptyAccelerator; @@ -756,6 +756,6 @@ std::string EventManager::getEventStr(wxKeyEvent& ev) } // Static module registration -module::StaticModule eventManagerModule; +module::StaticModuleRegistration eventManagerModule; } diff --git a/radiant/eventmanager/MouseToolManager.cpp b/radiant/eventmanager/MouseToolManager.cpp index 08c86541be..4782702110 100644 --- a/radiant/eventmanager/MouseToolManager.cpp +++ b/radiant/eventmanager/MouseToolManager.cpp @@ -281,6 +281,6 @@ void MouseToolManager::onCloseTimerIntervalReached(wxTimerEvent& ev) } } -module::StaticModule mouseToolManagerModule; +module::StaticModuleRegistration mouseToolManagerModule; } // namespace diff --git a/radiant/map/StartupMapLoader.cpp b/radiant/map/StartupMapLoader.cpp index 26b6dbade7..b0a5b67d35 100644 --- a/radiant/map/StartupMapLoader.cpp +++ b/radiant/map/StartupMapLoader.cpp @@ -16,7 +16,7 @@ #include "os/file.h" #include "registry/registry.h" -namespace map +namespace map { void StartupMapLoader::onMainFrameReady() @@ -29,7 +29,7 @@ void StartupMapLoader::onMainFrameReady() for (const std::string& candidate : args) { - if (os::getExtension(candidate) != "map" && + if (os::getExtension(candidate) != "map" && os::getExtension(candidate) != "mapx") continue; // We have a map file, check if it exists (and where) @@ -115,6 +115,6 @@ void StartupMapLoader::initialiseModule(const IApplicationContext& ctx) ); } -module::StaticModule startupMapLoader; +module::StaticModuleRegistration startupMapLoader; } // namespace map diff --git a/radiant/settings/LocalisationModule.cpp b/radiant/settings/LocalisationModule.cpp index 0bae21a50c..44ac7e906d 100644 --- a/radiant/settings/LocalisationModule.cpp +++ b/radiant/settings/LocalisationModule.cpp @@ -59,6 +59,6 @@ void LocalisationModule::shutdownModule() LocalisationProvider::Instance()->saveLanguageSetting(); } -module::StaticModule localisationModule; +module::StaticModuleRegistration localisationModule; } diff --git a/radiant/ui/UserInterfaceModule.cpp b/radiant/ui/UserInterfaceModule.cpp index 39b7a7d1b0..2769280aec 100644 --- a/radiant/ui/UserInterfaceModule.cpp +++ b/radiant/ui/UserInterfaceModule.cpp @@ -450,7 +450,7 @@ void UserInterfaceModule::registerUICommands() } // Static module registration -module::StaticModule userInterfaceModule; +module::StaticModuleRegistration userInterfaceModule; UserInterfaceModule& GetUserInterfaceModule() { diff --git a/radiant/ui/common/DialogManager.cpp b/radiant/ui/common/DialogManager.cpp index 31914ed8e7..d02eba41b2 100644 --- a/radiant/ui/common/DialogManager.cpp +++ b/radiant/ui/common/DialogManager.cpp @@ -119,6 +119,6 @@ IAnimationChooser* DialogManager::createAnimationChooser(wxWindow* parent) return new MD5AnimationChooser(parent); } -module::StaticModule dialogManagerModule; +module::StaticModuleRegistration dialogManagerModule; } // namespace ui diff --git a/radiant/ui/einspector/EntityInspector.cpp b/radiant/ui/einspector/EntityInspector.cpp index add7ba463f..d14c8cac4e 100644 --- a/radiant/ui/einspector/EntityInspector.cpp +++ b/radiant/ui/einspector/EntityInspector.cpp @@ -159,7 +159,7 @@ void EntityInspector::construct() // Stimulate initial redraw to get the correct status requestIdleCallback(); - + _defsReloadedHandler = GlobalEntityClassManager().defsReloadedSignal().connect( sigc::mem_fun(this, &EntityInspector::onDefsReloaded) ); @@ -363,6 +363,8 @@ void EntityInspector::applyMergeActionStyle(const std::string& key, wxDataViewIt case scene::merge::ActionType::RemoveKeyValue: wxutil::TreeViewItemStyle::ApplyKeyValueRemovedStyle(style); break; + default: + break; } } @@ -800,7 +802,7 @@ void EntityInspector::updatePrimitiveNumber() rWarning() << ex.what() << std::endl; } } - + _primitiveNumLabel->SetLabelText(""); } @@ -813,7 +815,7 @@ void EntityInspector::onIdle() // Fire the selection update. This will invoke onKeyAdded/onKeyChanged etc. // on ourselves for every spawnarg that should be listed or removed _entitySelection->update(); - + // After selection rescan, trigger an update of the key types // of all listed key/value pairs. Not all information is fully available // during the above update @@ -1171,7 +1173,7 @@ void EntityInspector::_onRejectMergeAction() wxutil::TreeModel::Row row(item, *_kvStore); auto key = row[_columns.name].getString().ToStdString(); - + auto conflict = _conflictActions.find(key); if (conflict != _conflictActions.end()) @@ -1182,7 +1184,7 @@ void EntityInspector::_onRejectMergeAction() } auto action = _mergeActions.find(key); - + if (action != _mergeActions.end()) { action->second->deactivate(); @@ -1386,7 +1388,7 @@ void EntityInspector::updateHelpText(const wxutil::TreeModel::Row& row) // Check the entityclass (which will return blank if not found) auto eclass = _entitySelection->getSingleSharedEntityClass(); - + if (!eclass) { setHelpText(""); @@ -1591,8 +1593,8 @@ void EntityInspector::addClassProperties() } // Visit the entity class - eclass->forEachAttribute([&] (const EntityClassAttribute& a, bool) - { + eclass->forEachAttribute([&] (const EntityClassAttribute& a, bool) + { addClassAttribute(a); }); } @@ -1707,6 +1709,6 @@ void EntityInspector::toggle(const cmd::ArgumentList& args) } // Define the static EntityInspector module -module::StaticModule entityInspectorModule; +module::StaticModuleRegistration entityInspectorModule; } // namespace ui diff --git a/radiant/ui/einspector/EntityInspector.h b/radiant/ui/einspector/EntityInspector.h index aeccacc27e..580a485296 100644 --- a/radiant/ui/einspector/EntityInspector.h +++ b/radiant/ui/einspector/EntityInspector.h @@ -214,7 +214,7 @@ class EntityInspector final : void onKeyAdded(const std::string& key, const std::string& value); void onKeyRemoved(const std::string& key); void onKeyValueSetChanged(const std::string& key, const std::string& uniqueValue); - + // Routines shared by onKeyAdded, onKeyRemoved and onKeyValueSetChanged void onKeyUpdatedCommon(const std::string& key); @@ -264,23 +264,24 @@ class EntityInspector final : protected: // Called when the app is idle - void onIdle(); + void onIdle() override; public: // Constructor EntityInspector(); // Get the main widget for packing - wxPanel* getWidget(); + wxPanel* getWidget() override; /** greebo: Gets called by the RadiantSelectionSystem upon selection change. */ - void selectionChanged(const scene::INodePtr& node, bool isComponent); - - void registerPropertyEditor(const std::string& key, const IPropertyEditor::CreationFunc& creator) override; - void unregisterPropertyEditor(const std::string& key) override; + void selectionChanged(const scene::INodePtr& node, bool isComponent) override; - void registerPropertyEditorDialog(const std::string& key, const IPropertyEditorDialog::CreationFunc& create) override; + void registerPropertyEditor(const std::string& key, + const IPropertyEditor::CreationFunc& creator) override; + void unregisterPropertyEditor(const std::string& key) override; + void registerPropertyEditorDialog(const std::string& key, + const IPropertyEditorDialog::CreationFunc& create) override; IPropertyEditorDialog::Ptr createDialog(const std::string& key) override; void unregisterPropertyEditorDialog(const std::string& key) override; @@ -290,7 +291,7 @@ class EntityInspector final : void onKeyChange(const std::string& key, const std::string& value, bool isMultiValue = false); // greebo: Tells the inspector to reload the window settings from the registry. - void restoreSettings(); + void restoreSettings() override; /** * greebo: Static command target for toggling the Entity Inspector in the GroupDialog. diff --git a/radiant/ui/favourites/FavouritesUserInterfaceModule.cpp b/radiant/ui/favourites/FavouritesUserInterfaceModule.cpp index b0848f48e5..aaeb41bc15 100644 --- a/radiant/ui/favourites/FavouritesUserInterfaceModule.cpp +++ b/radiant/ui/favourites/FavouritesUserInterfaceModule.cpp @@ -76,6 +76,6 @@ class FavouritesUserInterfaceModule : } }; -module::StaticModule favouritesUserInterfaceModule; +module::StaticModuleRegistration favouritesUserInterfaceModule; } diff --git a/radiant/ui/filters/FilterUserInterface.cpp b/radiant/ui/filters/FilterUserInterface.cpp index 06b441ca30..8c5412991a 100644 --- a/radiant/ui/filters/FilterUserInterface.cpp +++ b/radiant/ui/filters/FilterUserInterface.cpp @@ -111,6 +111,6 @@ void FilterUserInterface::toggleFilter(const std::string& filterName, bool newSt GlobalFilterSystem().setFilterState(filterName, newState); } -module::StaticModule filterUserInterfaceModule; +module::StaticModuleRegistration filterUserInterfaceModule; } diff --git a/radiant/ui/gl/WxGLWidgetManager.cpp b/radiant/ui/gl/WxGLWidgetManager.cpp index 58e6645cd2..4a7be3316f 100644 --- a/radiant/ui/gl/WxGLWidgetManager.cpp +++ b/radiant/ui/gl/WxGLWidgetManager.cpp @@ -55,6 +55,6 @@ void WxGLWidgetManager::shutdownModule() _wxGLWidgets.clear(); } -module::StaticModule wxGLWidgetManagerModule; +module::StaticModuleRegistration wxGLWidgetManagerModule; } diff --git a/radiant/ui/grid/GridUserInterface.cpp b/radiant/ui/grid/GridUserInterface.cpp index f7eb46705c..4c680825a9 100644 --- a/radiant/ui/grid/GridUserInterface.cpp +++ b/radiant/ui/grid/GridUserInterface.cpp @@ -46,7 +46,7 @@ void GridUserInterface::initialiseModule(const IApplicationContext& ctx) rMessage() << getName() << "::initialiseModule called." << std::endl; // Add the grid status bar element - GlobalStatusBarManager().addTextElement("GridStatus", "grid_up.png", + GlobalStatusBarManager().addTextElement("GridStatus", "grid_up.png", statusbar::StandardPosition::GridSize, _("Current Grid Size")); GlobalStatusBarManager().setText("GridStatus", getGridStatusText()); @@ -91,6 +91,6 @@ void GridUserInterface::toggleGrid(GridSize size, bool newState) GlobalGrid().setGridSize(size); } -module::StaticModule gridUiModule; +module::StaticModuleRegistration gridUiModule; } diff --git a/radiant/ui/groupdialog/GroupDialogManager.cpp b/radiant/ui/groupdialog/GroupDialogManager.cpp index bcb4cf6451..70991edde1 100644 --- a/radiant/ui/groupdialog/GroupDialogManager.cpp +++ b/radiant/ui/groupdialog/GroupDialogManager.cpp @@ -29,6 +29,6 @@ void GroupDialogManager::initialiseModule(const IApplicationContext& ctx) rMessage() << getName() << "::initialiseModule called" << std::endl; } -module::StaticModule groupDialogManagerModule; +module::StaticModuleRegistration groupDialogManagerModule; } // namespace ui diff --git a/radiant/ui/mainframe/MainFrame.cpp b/radiant/ui/mainframe/MainFrame.cpp index 42b013754d..5062afe4ae 100644 --- a/radiant/ui/mainframe/MainFrame.cpp +++ b/radiant/ui/mainframe/MainFrame.cpp @@ -154,7 +154,7 @@ void MainFrame::initialiseModule(const IApplicationContext& ctx) ); GlobalEntityClassManager().defsLoadedSignal().connect([this]() - { + { _defLoadingBlocksUpdates = false; } ); @@ -606,6 +606,6 @@ sigc::signal& MainFrame::signal_MainFrameShuttingDown() } // Define the static MainFrame module -module::StaticModule mainFrameModule; +module::StaticModuleRegistration mainFrameModule; } // namespace ui diff --git a/radiant/ui/mainframe/MainFrameLayoutManager.cpp b/radiant/ui/mainframe/MainFrameLayoutManager.cpp index b06a764d01..9b05102111 100644 --- a/radiant/ui/mainframe/MainFrameLayoutManager.cpp +++ b/radiant/ui/mainframe/MainFrameLayoutManager.cpp @@ -93,6 +93,6 @@ void MainFrameLayoutManager::shutdownModule() { } // Define the static MainFrameLayoutManager module -module::StaticModule mainFrameLayoutManagerModule; +module::StaticModuleRegistration mainFrameLayoutManagerModule; } // namespace ui diff --git a/radiant/ui/materials/editor/MaterialEditorModule.cpp b/radiant/ui/materials/editor/MaterialEditorModule.cpp index 9ad18adf2d..438ccbf5c7 100644 --- a/radiant/ui/materials/editor/MaterialEditorModule.cpp +++ b/radiant/ui/materials/editor/MaterialEditorModule.cpp @@ -48,6 +48,6 @@ class MaterialEditorModule : } }; -module::StaticModule materialEditorModule; +module::StaticModuleRegistration materialEditorModule; } diff --git a/radiant/ui/mediabrowser/MediaBrowser.cpp b/radiant/ui/mediabrowser/MediaBrowser.cpp index 38be7038b8..d188e1deab 100644 --- a/radiant/ui/mediabrowser/MediaBrowser.cpp +++ b/radiant/ui/mediabrowser/MediaBrowser.cpp @@ -35,7 +35,7 @@ namespace ui { // Constructor -MediaBrowser::MediaBrowser() : +MediaBrowser::MediaBrowser() : _tempParent(nullptr), _mainWidget(nullptr), _treeView(nullptr), @@ -53,7 +53,7 @@ void MediaBrowser::construct() _tempParent = new wxFrame(nullptr, wxID_ANY, ""); _tempParent->Hide(); - _mainWidget = new wxPanel(_tempParent, wxID_ANY); + _mainWidget = new wxPanel(_tempParent, wxID_ANY); _mainWidget->SetSizer(new wxBoxSizer(wxVERTICAL)); _treeView = new MediaBrowserTreeView(_mainWidget); @@ -70,11 +70,11 @@ void MediaBrowser::construct() _mainWidget->GetSizer()->Add(_preview, 0, wxEXPAND); // When destroying the main widget clear out the held references. - // The dying populator thread might have posted a finished message which + // The dying populator thread might have posted a finished message which // runs into problems when the _treeView is still valid _mainWidget->Bind(wxEVT_DESTROY, [&](wxWindowDestroyEvent& ev) { - // In wxGTK the destroy event might bubble from a child window + // In wxGTK the destroy event might bubble from a child window // like the search popup, so check the event object if (ev.GetEventObject() == _mainWidget) { @@ -241,6 +241,6 @@ void MediaBrowser::onShaderClipboardSourceChanged() } // Static module -module::StaticModule mediaBrowserModule; +module::StaticModuleRegistration mediaBrowserModule; } // namespace diff --git a/radiant/ui/menu/MenuManager.cpp b/radiant/ui/menu/MenuManager.cpp index 8eb540e9fc..fc4f867432 100644 --- a/radiant/ui/menu/MenuManager.cpp +++ b/radiant/ui/menu/MenuManager.cpp @@ -9,13 +9,13 @@ #include "MenuRootElement.h" #include "module/StaticModule.h" -namespace ui +namespace ui { namespace menu { -namespace +namespace { // The menu root key in the registry const char* const RKEY_MENU_ROOT = "user/ui/menu"; @@ -42,12 +42,12 @@ void MenuManager::loadFromRegistry() for (const xml::Node& menuNode : menuNodes) { MenuElementPtr menubar = MenuElement::CreateFromNode(menuNode); - + // Add the menubar as child of the root _root->addChild(menubar); } } - else + else { rError() << "MenuManager: Could not find menu root in registry." << std::endl; } @@ -79,14 +79,14 @@ wxMenuBar* MenuManager::getMenuBar(const std::string& name) if (!_root) return nullptr; // root has already been removed MenuElementPtr menuBar = _root->find(name); - + if (menuBar) { assert(std::dynamic_pointer_cast(menuBar)); return std::static_pointer_cast(menuBar)->getMenuBar(); } - + rError() << "MenuManager: Warning: Menubar with name " << name << " not found!" << std::endl; return nullptr; } @@ -133,7 +133,7 @@ void MenuManager::insert(const std::string& insertPath, if (!insertBefore || !insertBefore->getParent()) { - rWarning() << "Cannot insert before non-existent item or item doesn't have a parent" + rWarning() << "Cannot insert before non-existent item or item doesn't have a parent" << insertPath << std::endl; return; } @@ -279,7 +279,7 @@ void MenuManager::shutdownModule() clear(); } -module::StaticModule menuManagerModule; +module::StaticModuleRegistration menuManagerModule; } // namespace ui diff --git a/radiant/ui/modelselector/ModelSelector.cpp b/radiant/ui/modelselector/ModelSelector.cpp index f240aa7b9f..1a775bdf28 100644 --- a/radiant/ui/modelselector/ModelSelector.cpp +++ b/radiant/ui/modelselector/ModelSelector.cpp @@ -21,11 +21,14 @@ #include "string/convert.h" #include +#include #include #include #include #include "wxutil/dataview/ResourceTreeViewToolbar.h" +#include "wxutil/Bitmap.h" #include "ui/UserInterfaceModule.h" +#include "registry/Widgets.h" #include @@ -39,11 +42,12 @@ namespace const std::string RKEY_BASE = "user/ui/modelSelector/"; const std::string RKEY_SPLIT_POS = RKEY_BASE + "splitPos"; + const std::string RKEY_SHOW_SKINS = RKEY_BASE + "showSkinsInTree"; } // Constructor. -ModelSelector::ModelSelector() : +ModelSelector::ModelSelector() : DialogBase(_(MODELSELECTOR_TITLE)), _dialogPanel(loadNamedPanel(this, "ModelSelectorPanel")), _treeView(nullptr), @@ -66,7 +70,7 @@ ModelSelector::ModelSelector() : // allow vertical shrinking) _modelPreview->setSize(static_cast(_position.getSize()[0]*0.4f), static_cast(_position.getSize()[1]*0.2f)); - + wxPanel* leftPanel = findNamedObject(this, "ModelSelectorLeftPanel"); // Set up view widgets @@ -183,36 +187,36 @@ ModelSelectorResult ModelSelector::showAndBlock(const std::string& curModel, bool showOptions, bool showSkins) { - _treeView->SetShowSkins(showSkins); - _treeView->SetSelectedFullname(curModel); + // Hide the Show Skins button if skins should not be shown for this invocation + if (showSkins) { + _showSkinsBtn->Show(); + _treeView->SetShowSkins(_showSkinsBtn->GetValue()); + } + else { + _showSkinsBtn->Hide(); + _treeView->SetShowSkins(false); + } + _treeView->SetSelectedFullname(curModel); showInfoForSelectedModel(); _showOptions = showOptions; - // Conditionally hide the options - findNamedObject(this, "ModelSelectorOptionsPanel")->Show(_showOptions); + // Conditionally hide the options + findNamedObject(this, "ModelSelectorOptionsPanel")->Show(_showOptions); // show and enter recursive main loop. int returnCode = ShowModal(); - // Remove the model from the preview's scenegraph before returning - _modelPreview->setModel(""); + // Remove the model from the preview's scenegraph before returning + _modelPreview->setModel(""); + // Return selected model/skin, or an empty result if the dialog was cancelled if (returnCode == wxID_OK) - { - // Construct the model/skin combo and return it - return ModelSelectorResult( - _lastModel, - _lastSkin, - findNamedObject(this, "ModelSelectorMonsterClipOption")->GetValue() - ); - } + return {_lastModel, _lastSkin, + findNamedObject(this, "ModelSelectorMonsterClipOption")->GetValue()}; else - { - // Return empty result on cancel - return ModelSelectorResult("", "", false); - } + return {}; } // Static function to display the instance, and return the selected model to the @@ -264,30 +268,45 @@ void ModelSelector::onModelLoaded(const model::ModelNodePtr& modelNode) _materialsList->updateFromModel(model); } -// Helper function to create the TreeView +wxWindow* ModelSelector::setupTreeViewToolbar(wxWindow* parent) +{ + // Set up the top treeview toolbar, including a custom button to enable/disable the showing of + // skins in the tree. + auto* toolbar = new wxutil::ResourceTreeViewToolbar(parent, _treeView); + _showSkinsBtn = new wxBitmapToggleButton(toolbar, wxID_ANY, + wxutil::GetLocalBitmap("skin16.png")); + _showSkinsBtn->SetValue(true); + _showSkinsBtn->SetToolTip(_("List model skins in the tree underneath their associated models")); + _showSkinsBtn->Bind(wxEVT_TOGGLEBUTTON, + [this](auto& ev) { _treeView->SetShowSkins(ev.IsChecked()); }); + registry::bindWidget(_showSkinsBtn, RKEY_SHOW_SKINS); + toolbar->GetRightSizer()->Add(_showSkinsBtn, wxSizerFlags().Border(wxLEFT, 6)); + + return toolbar; +} + void ModelSelector::setupTreeView(wxWindow* parent) { - _treeView = new ModelTreeView(parent); + _treeView = new ModelTreeView(parent); _treeView->SetMinSize(wxSize(200, 200)); - // Get selection and connect the changed callback - _treeView->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &ModelSelector::onSelectionChanged, this); - _treeView->Bind(wxutil::EV_TREEVIEW_POPULATION_FINISHED, &ModelSelector::onTreeViewPopulationFinished, this); - - auto* toolbar = new wxutil::ResourceTreeViewToolbar(parent, _treeView); + // Get selection and connect the changed callback + _treeView->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &ModelSelector::onSelectionChanged, this); + _treeView->Bind(wxutil::EV_TREEVIEW_POPULATION_FINISHED, + &ModelSelector::onTreeViewPopulationFinished, this); - parent->GetSizer()->Prepend(_treeView, 1, wxEXPAND); - parent->GetSizer()->Prepend(toolbar, 0, wxEXPAND | wxALIGN_LEFT | wxBOTTOM | wxLEFT | wxRIGHT, 6); + // Pack in tree view and its toolbar + parent->GetSizer()->Prepend(_treeView, 1, wxEXPAND); + parent->GetSizer()->Prepend(setupTreeViewToolbar(parent), 0, + wxEXPAND | wxALIGN_LEFT | wxBOTTOM | wxLEFT | wxRIGHT, 6); parent->GetSizer()->Layout(); - Bind( wxEVT_DATAVIEW_ITEM_ACTIVATED, &ModelSelector::_onItemActivated, this ); -} - -void ModelSelector::_onItemActivated( wxDataViewEvent& ev ) { - std::string modelName = _treeView->GetSelectedModelPath(); - if ( !modelName.empty() ) { - onOK( ev ); - } + // Accept the dialog on double-clicking on a model in the list + _treeView->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, [this](wxDataViewEvent& ev) { + if (auto modelName = _treeView->GetSelectedModelPath(); !modelName.empty()) { + onOK(ev); + } + }); } void ModelSelector::populateModels() @@ -315,7 +334,7 @@ void ModelSelector::showInfoForSelectedModel() // Get the model name, if this is blank we are looking at a directory, // so leave the table empty std::string modelName = _treeView->GetSelectedModelPath(); - + if (modelName.empty()) return; // Get the skin if set diff --git a/radiant/ui/modelselector/ModelSelector.h b/radiant/ui/modelselector/ModelSelector.h index 54cee41632..b29adca694 100644 --- a/radiant/ui/modelselector/ModelSelector.h +++ b/radiant/ui/modelselector/ModelSelector.h @@ -28,16 +28,12 @@ namespace ui */ struct ModelSelectorResult { - // Model and skin strings - std::string model; - std::string skin; + // Model and skin strings + std::string model; + std::string skin; - // options - bool createClip; - - // Constructor - ModelSelectorResult(const std::string& m, const std::string& s, const bool clip) - : model(m), skin(s), createClip(clip) {} + // Model creation options + bool createClip = false; }; class ModelPopulator; @@ -46,11 +42,8 @@ class ModelSelector; typedef std::shared_ptr ModelSelectorPtr; /// Dialog for browsing and selecting a model and/or skin -class ModelSelector : - public wxutil::DialogBase, - private wxutil::XmlResourceBasedWidget +class ModelSelector: public wxutil::DialogBase, private wxutil::XmlResourceBasedWidget { -private: wxPanel* _dialogPanel; // Model preview widget @@ -58,6 +51,7 @@ class ModelSelector : // Main tree view with model hierarchy ModelTreeView* _treeView; + wxToggleButton* _showSkinsBtn = nullptr; // Key/value table for model information wxutil::KeyValueTable* _infoTable; @@ -98,6 +92,7 @@ class ModelSelector : // Helper functions to configure GUI components void setupAdvancedPanel(wxWindow* parent); void setupTreeView(wxWindow* parent); + wxWindow* setupTreeViewToolbar(wxWindow* parent); // Populate the tree view with models void populateModels(); @@ -114,8 +109,6 @@ class ModelSelector : void onRescanFolders(wxCommandEvent& ev); void onTreeViewPopulationFinished(wxutil::ResourceTreeView::PopulationFinishedEvent& ev); - void _onItemActivated( wxDataViewEvent& ev ); - // Update the info table with information from the currently-selected model, and // update the displayed model. void onSelectionChanged(wxDataViewEvent& ev); diff --git a/radiant/ui/ortho/OrthoContextMenu.cpp b/radiant/ui/ortho/OrthoContextMenu.cpp index fe68d14208..3ac5ee2d92 100644 --- a/radiant/ui/ortho/OrthoContextMenu.cpp +++ b/radiant/ui/ortho/OrthoContextMenu.cpp @@ -70,7 +70,7 @@ namespace { } // Define the static OrthoContextMenu module -module::StaticModule orthoContextMenuModule; +module::StaticModuleRegistration orthoContextMenuModule; OrthoContextMenu& OrthoContextMenu::Instance() { @@ -248,7 +248,7 @@ void OrthoContextMenu::addEntity() // Display the chooser to select an entity classname std::string cName = wxutil::EntityClassChooser::chooseEntityClass(); - if (!cName.empty()) + if (!cName.empty()) { UndoableCommand command("createEntity"); @@ -274,7 +274,7 @@ void OrthoContextMenu::callbackAddLight() { UndoableCommand command("addLight"); - try + try { GlobalEntityModule().createEntityFromSelection(LIGHT_CLASSNAME, _lastPoint); } @@ -291,7 +291,7 @@ void OrthoContextMenu::callbackAddPrefab() if (!result.prefabPath.empty()) { // Pass the call to the map algorithm and give the lastPoint coordinate as argument - GlobalCommandSystem().executeCommand(LOAD_PREFAB_AT_CMD, + GlobalCommandSystem().executeCommand(LOAD_PREFAB_AT_CMD, result.prefabPath, _lastPoint, result.insertAsGroup); } } diff --git a/radiant/ui/script/ScriptUserInterfaceModule.cpp b/radiant/ui/script/ScriptUserInterfaceModule.cpp index a0b08b40cf..d456149823 100644 --- a/radiant/ui/script/ScriptUserInterfaceModule.cpp +++ b/radiant/ui/script/ScriptUserInterfaceModule.cpp @@ -92,6 +92,6 @@ class ScriptUserInterfaceModule : } }; -module::StaticModule scriptUserInterfaceModule; +module::StaticModuleRegistration scriptUserInterfaceModule; } diff --git a/radiant/ui/statusbar/StatusBarManager.cpp b/radiant/ui/statusbar/StatusBarManager.cpp index a4471b6a14..1811977c59 100644 --- a/radiant/ui/statusbar/StatusBarManager.cpp +++ b/radiant/ui/statusbar/StatusBarManager.cpp @@ -97,7 +97,7 @@ wxWindow* StatusBarManager::getElement(const std::string& name) return found != _elements.end() ? found->second->toplevel : nullptr; } -void StatusBarManager::addTextElement(const std::string& name, const std::string& icon, +void StatusBarManager::addTextElement(const std::string& name, const std::string& icon, int pos, const std::string& description) { // Get a free position @@ -192,7 +192,7 @@ void StatusBarManager::onIdle() } }); - // Post a size event + // Post a size event _statusBar->PostSizeEvent(); } @@ -243,7 +243,7 @@ void StatusBarManager::rebuildStatusBar() // The first and the last status bar widget get a smaller left/right border auto spacing = col == 0 || col == _positions.size() - 1 ? 6 : 24; - + // A few default elements don't need to use 1 as proportion auto proportion = i->first == StandardPosition::MapStatistics || i->first == StandardPosition::GridSize || i->first == StandardPosition::MapEditStopwatch || i->first == StandardPosition::OrthoViewPosition || @@ -266,7 +266,7 @@ void StatusBarManager::onMainFrameShuttingDown() _tempParent = nullptr; } -module::StaticModule statusBarManagerModule; +module::StaticModuleRegistration statusBarManagerModule; } // namespace diff --git a/radiant/ui/texturebrowser/TextureBrowserManager.cpp b/radiant/ui/texturebrowser/TextureBrowserManager.cpp index 2f5b5ba8fc..f36331d1c0 100644 --- a/radiant/ui/texturebrowser/TextureBrowserManager.cpp +++ b/radiant/ui/texturebrowser/TextureBrowserManager.cpp @@ -136,7 +136,7 @@ void TextureBrowserManager::onShaderClipboardSourceChanged() } // Define the static module -module::StaticModule texBrowserManagerModule; +module::StaticModuleRegistration texBrowserManagerModule; TextureBrowserManager& TextureBrowserManager::Instance() { diff --git a/radiant/ui/toolbar/ToolbarManager.cpp b/radiant/ui/toolbar/ToolbarManager.cpp index 53f7b77ff1..6d0ffc3f13 100644 --- a/radiant/ui/toolbar/ToolbarManager.cpp +++ b/radiant/ui/toolbar/ToolbarManager.cpp @@ -72,7 +72,7 @@ wxToolBar* ToolbarManager::createToolbar(const std::string& toolbarName, wxWindo rError() << "ToolbarManager: Critical: Could not instantiate " << toolbarName << std::endl; return nullptr; } - + return createToolbarFromNode(toolbarList[0], parent); } @@ -100,19 +100,19 @@ wxToolBarToolBase* ToolbarManager::createToolItem(wxToolBar* toolbar, const xml: { name.clear(); } - + if (nodeName == "toolbutton") { // Create a new ToolButton and assign the right callback toolItem = toolbar->AddTool(_nextToolItemId++, name, - wxutil::GetLocalBitmap(icon), + wxutil::GetLocalBitmap(icon), tooltip); } else { // Create a new ToggleToolButton and assign the right callback toolItem = toolbar->AddTool(_nextToolItemId++, name, - wxutil::GetLocalBitmap(icon), + wxutil::GetLocalBitmap(icon), tooltip, wxITEM_CHECK); } @@ -139,11 +139,11 @@ wxToolBar* ToolbarManager::createToolbarFromNode(xml::Node& node, wxWindow* pare auto align = node.getAttributeValue("align"); // Create a new toolbar - toolbar = new wxToolBar(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, + toolbar = new wxToolBar(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, align == "vertical" ? wxTB_VERTICAL : wxTB_HORIZONTAL, node.getAttributeValue("name")); - // Adjust the toolbar bitmap size to add some padding - despite its name + // Adjust the toolbar bitmap size to add some padding - despite its name // this will not resize the actual icons, just the buttons toolbar->SetToolBitmapSize(wxSize(20, 20)); @@ -215,6 +215,6 @@ void ToolbarManager::loadToolbars() } } -module::StaticModule toolbarManagerModule; +module::StaticModuleRegistration toolbarManagerModule; } // namespace ui diff --git a/radiant/xyview/GlobalXYWnd.cpp b/radiant/xyview/GlobalXYWnd.cpp index a388412197..0b5d6cad7d 100644 --- a/radiant/xyview/GlobalXYWnd.cpp +++ b/radiant/xyview/GlobalXYWnd.cpp @@ -159,7 +159,7 @@ void XYWndManager::destroyViews() _activeXY = XYWndPtr(); } -void XYWndManager::registerCommands() +void XYWndManager::registerCommands() { GlobalCommandSystem().addCommand("NewOrthoView", std::bind(&XYWndManager::createXYFloatingOrthoView, this, std::placeholders::_1)); GlobalCommandSystem().addCommand("NextView", std::bind(&XYWndManager::toggleActiveView, this, std::placeholders::_1)); @@ -314,7 +314,7 @@ void XYWndManager::updateAllViews(bool force) { i.second->forceRedraw(); } - else + else { i.second->queueDraw(); } @@ -349,7 +349,7 @@ void XYWndManager::setOrigin(const Vector3& origin) { Vector3 XYWndManager::getActiveViewOrigin() { - if (!_activeXY) + if (!_activeXY) { throw std::runtime_error("No active view found"); } @@ -377,7 +377,7 @@ IOrthoView& XYWndManager::getViewByType(EViewType viewType) return *pair.second; } } - + throw std::runtime_error("No matching view found"); } @@ -641,7 +641,7 @@ Vector3 XYWndManager::getFocusPosition() { Vector3 position(0,0,0); - if (GlobalSelectionSystem().countSelected() != 0) + if (GlobalSelectionSystem().countSelected() != 0) { position = GlobalSelectionSystem().getCurrentSelectionCenter(); } @@ -759,7 +759,7 @@ void XYWndManager::foreachMouseTool(const std::function xyWndModule; +module::StaticModuleRegistration xyWndModule; } // namespace diff --git a/radiantcore/brush/BrushModule.cpp b/radiantcore/brush/BrushModule.cpp index 7d8685d13c..713f35575b 100644 --- a/radiantcore/brush/BrushModule.cpp +++ b/radiantcore/brush/BrushModule.cpp @@ -148,14 +148,14 @@ void BrushModuleImpl::registerBrushCommands() GlobalCommandSystem().addCommand("MakeVisportal", selection::algorithm::makeVisportal); GlobalCommandSystem().addCommand("SurroundWithMonsterclip", selection::algorithm::surroundWithMonsterclip); - GlobalCommandSystem().addCommand("ResizeSelectedBrushesToBounds", selection::algorithm::resizeSelectedBrushesToBounds, + GlobalCommandSystem().addCommand("ResizeSelectedBrushesToBounds", selection::algorithm::resizeSelectedBrushesToBounds, { cmd::ARGTYPE_VECTOR3, cmd::ARGTYPE_VECTOR3, cmd::ARGTYPE_STRING }); } // ------------------------------------------------------------------------------------- // Define a static BrushModule -module::StaticModule staticBrushModule; +module::StaticModuleRegistration staticBrushModule; } diff --git a/radiantcore/camera/CameraManager.cpp b/radiantcore/camera/CameraManager.cpp index b6436bc4ef..3bfa772b94 100644 --- a/radiantcore/camera/CameraManager.cpp +++ b/radiantcore/camera/CameraManager.cpp @@ -113,6 +113,6 @@ void CameraManager::setActiveCameraAngles(const cmd::ArgumentList& args) } } -module::StaticModule cameraManagerModule; +module::StaticModuleRegistration cameraManagerModule; } diff --git a/radiantcore/clipper/Clipper.cpp b/radiantcore/clipper/Clipper.cpp index a9414c7e24..b71b269faa 100644 --- a/radiantcore/clipper/Clipper.cpp +++ b/radiantcore/clipper/Clipper.cpp @@ -137,7 +137,7 @@ void Clipper::getPlanePoints(Vector3 planepts[3], const AABB& bounds) const { } } -void Clipper::setClipPlane(const Plane3& plane) +void Clipper::setClipPlane(const Plane3& plane) { algorithm::setBrushClipPlane(plane); } @@ -298,4 +298,4 @@ void Clipper::flipClipperCmd(const cmd::ArgumentList& args) { } // Define the static Clipper module -module::StaticModule clipperModule; +module::StaticModuleRegistration clipperModule; diff --git a/radiantcore/commandsystem/CommandSystem.cpp b/radiantcore/commandsystem/CommandSystem.cpp index 0973ef4e06..362629a655 100644 --- a/radiantcore/commandsystem/CommandSystem.cpp +++ b/radiantcore/commandsystem/CommandSystem.cpp @@ -417,6 +417,6 @@ AutoCompletionInfo CommandSystem::getAutoCompletionInfo(const std::string& prefi } // Static module instance -module::StaticModule commandSystemModule; +module::StaticModuleRegistration commandSystemModule; } // namespace cmd diff --git a/radiantcore/decl/FavouritesManager.cpp b/radiantcore/decl/FavouritesManager.cpp index 27e72ce83e..2df9e9d959 100644 --- a/radiantcore/decl/FavouritesManager.cpp +++ b/radiantcore/decl/FavouritesManager.cpp @@ -113,7 +113,7 @@ void FavouritesManager::initialiseModule(const IApplicationContext&) { // Up to version 2.10.0, the MediaBrowser favourites were stored in this path _favouritesByType[Type::Material].loadFromRegistry(RKEY_MEDIABROWSER_LEGACY_ROOT); - + // Get rid of this old key after importing its data GlobalRegistry().deleteXPath(RKEY_MEDIABROWSER_LEGACY_ROOT); @@ -145,6 +145,6 @@ void FavouritesManager::shutdownModule() } } -module::StaticModule favouritesManagerModule; +module::StaticModuleRegistration favouritesManagerModule; } diff --git a/radiantcore/eclass/EClassColourManager.cpp b/radiantcore/eclass/EClassColourManager.cpp index 97ba36e82b..e3988ab7bb 100644 --- a/radiantcore/eclass/EClassColourManager.cpp +++ b/radiantcore/eclass/EClassColourManager.cpp @@ -76,6 +76,6 @@ void EClassColourManager::initialiseModule(const IApplicationContext& ctx) rMessage() << getName() << "::initialiseModule called." << std::endl; } -module::StaticModule eclassColourManagerModule; +module::StaticModuleRegistration eclassColourManagerModule; } diff --git a/radiantcore/eclass/EClassManager.cpp b/radiantcore/eclass/EClassManager.cpp index fdebdcb21a..20afb79c55 100644 --- a/radiantcore/eclass/EClassManager.cpp +++ b/radiantcore/eclass/EClassManager.cpp @@ -520,6 +520,6 @@ void EClassManager::onDefLoadingCompleted() } // Static module instance -module::StaticModule eclassModule; +module::StaticModuleRegistration eclassModule; } // namespace eclass diff --git a/radiantcore/entity/EntityModule.cpp b/radiantcore/entity/EntityModule.cpp index f21e877802..77a80f4c0c 100644 --- a/radiantcore/entity/EntityModule.cpp +++ b/radiantcore/entity/EntityModule.cpp @@ -306,6 +306,6 @@ void Doom3EntityModule::shutdownModule() } // Static module instance -module::StaticModule entityModule; +module::StaticModuleRegistration entityModule; } // namespace entity diff --git a/radiantcore/entity/EntityNode.cpp b/radiantcore/entity/EntityNode.cpp index 92564c566b..0b22a5e922 100644 --- a/radiantcore/entity/EntityNode.cpp +++ b/radiantcore/entity/EntityNode.cpp @@ -137,7 +137,7 @@ void EntityNode::createAttachedEntities() // Construct and store the attached entity auto attachedEnt = GlobalEntityModule().createEntity(cls); assert(attachedEnt); - _attachedEnts.push_back(attachedEnt); + _attachedEnts.push_back({attachedEnt, a.offset}); // Set ourselves as the parent of the attached entity (for // localToParent transforms) @@ -145,7 +145,7 @@ void EntityNode::createAttachedEntities() // Set the attached entity's transform matrix according to the // required offset - attachedEnt->localToParent() = Matrix4::getTranslation(a.offset); + attachedEnt->setLocalToParent(Matrix4::getTranslation(a.offset)); } ); } @@ -156,8 +156,8 @@ void EntityNode::transformChanged() // Broadcast transformChanged to all attached entities so they can update // their position - for (auto attached: _attachedEnts) - attached->transformChanged(); + for (auto [node, offset]: _attachedEnts) + node->transformChanged(); } void EntityNode::onEntityClassChanged() @@ -395,7 +395,7 @@ void EntityNode::setRenderSystem(const RenderSystemPtr& renderSystem) _colourKey.setRenderSystem(renderSystem); // Make sure any attached entities have a render system too - for (IEntityNodePtr node: _attachedEnts) + for (auto [node, offset]: _attachedEnts) node->setRenderSystem(renderSystem); } diff --git a/radiantcore/entity/EntityNode.h b/radiantcore/entity/EntityNode.h index 40bd700900..03319d14fe 100644 --- a/radiantcore/entity/EntityNode.h +++ b/radiantcore/entity/EntityNode.h @@ -87,7 +87,8 @@ class EntityNode : // sure that everything will play nicely with entities as children of other // entities, and (2) storing entity node pointers instead of generic node // pointers avoids some extra dynamic_casting. - using AttachedEntities = std::list; + using AttachedEntity = std::pair; + using AttachedEntities = std::list; AttachedEntities _attachedEnts; protected: @@ -111,7 +112,10 @@ class EntityNode : // IMatrixTransform implementation Matrix4 localToParent() const override { return _localToParent; } - Matrix4& localToParent() override { return _localToParent; } + void setLocalToParent(const Matrix4& localToParent) override + { + _localToParent = localToParent; + } // IComparableNode implementation std::string getFingerprint() override; @@ -195,8 +199,11 @@ class EntityNode : // Render all attached entities template void renderAttachments(RenderFunc func) const { - for (const IEntityNodePtr& ent: _attachedEnts) + for (auto [entityNode, offset]: _attachedEnts) { + // Before rendering the attached entity, ensure its offset is correct + entityNode->setLocalToParent(Matrix4::getTranslation(offset)); + // Attached entities might themselves have child nodes (e.g. func_static // which has its model as a child node), so we must traverse() the // attached entities, not just render them alone @@ -212,9 +219,8 @@ class EntityNode : return true; } }; - ChildRenderer cr(func); - ent->traverse(cr); + entityNode->traverse(cr); } } diff --git a/radiantcore/entity/doom3group/StaticGeometryNode.cpp b/radiantcore/entity/doom3group/StaticGeometryNode.cpp index 5ba16b2b5b..d8ca6e8fdb 100644 --- a/radiantcore/entity/doom3group/StaticGeometryNode.cpp +++ b/radiantcore/entity/doom3group/StaticGeometryNode.cpp @@ -674,16 +674,13 @@ void StaticGeometryNode::modelChanged(const std::string& value) void StaticGeometryNode::updateTransform() { - localToParent() = Matrix4::getIdentity(); + if (isModel()) + setLocalToParent(Matrix4::getTranslation(m_origin) * m_rotation.getMatrix4()); + else + setLocalToParent(Matrix4::getIdentity()); - if (isModel()) - { - localToParent().translateBy(m_origin); - localToParent().multiplyBy(m_rotation.getMatrix4()); - } - - // Notify the Node about this transformation change to update the local2World matrix - transformChanged(); + // Notify the Node about this transformation change to update the local2World matrix + transformChanged(); } void StaticGeometryNode::translateChildren(const Vector3& childTranslation) diff --git a/radiantcore/entity/eclassmodel/EclassModelNode.cpp b/radiantcore/entity/eclassmodel/EclassModelNode.cpp index 452784cebb..f40b1335e7 100644 --- a/radiantcore/entity/eclassmodel/EclassModelNode.cpp +++ b/radiantcore/entity/eclassmodel/EclassModelNode.cpp @@ -159,10 +159,7 @@ const Vector3& EclassModelNode::getUntransformedOrigin() void EclassModelNode::updateTransform() { - localToParent() = Matrix4::getIdentity(); - localToParent().translateBy(_origin); - - localToParent().multiplyBy(_rotation.getMatrix4()); + setLocalToParent(Matrix4::getTranslation(_origin) * _rotation.getMatrix4()); EntityNode::transformChanged(); } diff --git a/radiantcore/entity/generic/GenericEntityNode.cpp b/radiantcore/entity/generic/GenericEntityNode.cpp index 1183f19f54..f99d550dd3 100644 --- a/radiantcore/entity/generic/GenericEntityNode.cpp +++ b/radiantcore/entity/generic/GenericEntityNode.cpp @@ -190,7 +190,7 @@ void GenericEntityNode::_freezeTransform() void GenericEntityNode::updateTransform() { - localToParent() = Matrix4::getTranslation(m_origin); + setLocalToParent(Matrix4::getTranslation(m_origin)); if (_allow3Drotations) { diff --git a/radiantcore/entity/light/LightNode.cpp b/radiantcore/entity/light/LightNode.cpp index 0d2d0867ec..6cd293dea0 100644 --- a/radiantcore/entity/light/LightNode.cpp +++ b/radiantcore/entity/light/LightNode.cpp @@ -663,9 +663,7 @@ void LightNode::updateOrigin() { projectionChanged(); // Update the transformation matrix - localToParent() = Matrix4::getIdentity(); - localToParent().translateBy(_originTransformed); - localToParent().multiplyBy(m_rotation.getMatrix4()); + setLocalToParent(Matrix4::getTranslation(_originTransformed) * m_rotation.getMatrix4()); // Notify all child nodes m_transformChanged(); @@ -794,9 +792,7 @@ void LightNode::rotationChanged() m_rotation = m_useLightRotation ? m_lightRotation : m_rotationKey.m_rotation; // Update the transformation matrix - localToParent() = Matrix4::getIdentity(); - localToParent().translateBy(_originTransformed); - localToParent().multiplyBy(m_rotation.getMatrix4()); + setLocalToParent(Matrix4::getTranslation(_originTransformed) * m_rotation.getMatrix4()); // Notify owner about this m_transformChanged(); diff --git a/radiantcore/entity/speaker/SpeakerNode.cpp b/radiantcore/entity/speaker/SpeakerNode.cpp index 427be21003..ee4da4080b 100644 --- a/radiantcore/entity/speaker/SpeakerNode.cpp +++ b/radiantcore/entity/speaker/SpeakerNode.cpp @@ -265,7 +265,7 @@ void SpeakerNode::translate(const Vector3& translation) void SpeakerNode::updateTransform() { - localToParent() = Matrix4::getTranslation(m_origin); + setLocalToParent(Matrix4::getTranslation(m_origin)); transformChanged(); } diff --git a/radiantcore/filetypes/FileTypeRegistry.cpp b/radiantcore/filetypes/FileTypeRegistry.cpp index bff9f5cbbe..f1df5147e2 100644 --- a/radiantcore/filetypes/FileTypeRegistry.cpp +++ b/radiantcore/filetypes/FileTypeRegistry.cpp @@ -91,4 +91,4 @@ void FileTypeRegistry::initialiseModule(const IApplicationContext& ctx) } // Static module instance -module::StaticModule fileTypesModule; +module::StaticModuleRegistration fileTypesModule; diff --git a/radiantcore/filters/BasicFilterSystem.cpp b/radiantcore/filters/BasicFilterSystem.cpp index b724cdcb42..59cac9e7db 100644 --- a/radiantcore/filters/BasicFilterSystem.cpp +++ b/radiantcore/filters/BasicFilterSystem.cpp @@ -166,12 +166,12 @@ void BasicFilterSystem::initialiseModule(const IApplicationContext& ctx) addFiltersFromXML(userFilters, false); // Add the (de-)activate all commands - GlobalCommandSystem().addCommand("SetAllFilterStates", + GlobalCommandSystem().addCommand("SetAllFilterStates", std::bind(&BasicFilterSystem::setAllFilterStatesCmd, this, std::placeholders::_1), { cmd::ARGTYPE_INT }); // Command to activate/deactivate a named filter GlobalCommandSystem().addCommand("SetFilterState", - std::bind(&BasicFilterSystem::setFilterStateCmd, this, std::placeholders::_1), + std::bind(&BasicFilterSystem::setFilterStateCmd, this, std::placeholders::_1), { cmd::ARGTYPE_STRING, cmd::ARGTYPE_INT }); // Command to toggle a named filter's state @@ -190,7 +190,7 @@ void BasicFilterSystem::initialiseModule(const IApplicationContext& ctx) std::bind(&BasicFilterSystem::deselectObjectsByFilterCmd, this, std::placeholders::_1), { cmd::ARGTYPE_STRING }); } -void BasicFilterSystem::addFiltersFromXML(const xml::NodeList& nodes, bool readOnly) +void BasicFilterSystem::addFiltersFromXML(const xml::NodeList& nodes, bool readOnly) { // Load the list of active filter names from the user tree. There is no // guarantee that these are actually valid filters in the .game file @@ -262,14 +262,14 @@ XmlFilterEventAdapter::Ptr BasicFilterSystem::ensureEventAdapter(XMLFilter& filt return existing->second; } - auto result = _eventAdapters.emplace(filter.getName(), + auto result = _eventAdapters.emplace(filter.getName(), std::make_shared(filter)); return result.first->second; } // Shut down the Filters module, saving active filters to registry -void BasicFilterSystem::shutdownModule() +void BasicFilterSystem::shutdownModule() { // Remove the existing set of active filter nodes GlobalRegistry().deleteXPath(RKEY_USER_ACTIVE_FILTERS); @@ -310,8 +310,8 @@ void BasicFilterSystem::shutdownModule() case FilterRule::TYPE_TEXTURE: typeStr = "texture"; break; case FilterRule::TYPE_OBJECT: typeStr = "object"; break; case FilterRule::TYPE_ENTITYCLASS: typeStr = "entityclass"; break; - case FilterRule::TYPE_ENTITYKEYVALUE: - typeStr = "entitykeyvalue"; + case FilterRule::TYPE_ENTITYKEYVALUE: + typeStr = "entitykeyvalue"; criterion.setAttributeValue("key", rule.entityKey); break; default: continue; @@ -360,7 +360,7 @@ void BasicFilterSystem::forEachFilter(const std::functionsecond); } - else + else { assert(!_activeFilters.empty()); // Remove filter from active filters list @@ -402,7 +402,7 @@ void BasicFilterSystem::setFilterState(const std::string& filter, bool state) GlobalSceneGraph().sceneChanged(); } -bool BasicFilterSystem::filterIsReadOnly(const std::string& filter) +bool BasicFilterSystem::filterIsReadOnly(const std::string& filter) { auto f = _availableFilters.find(filter); @@ -414,7 +414,7 @@ bool BasicFilterSystem::addFilter(const std::string& filterName, const FilterRul { auto f = _availableFilters.find(filterName); - if (f != _availableFilters.end()) + if (f != _availableFilters.end()) { return false; // already exists } @@ -433,7 +433,7 @@ bool BasicFilterSystem::addFilter(const std::string& filterName, const FilterRul return true; } -bool BasicFilterSystem::removeFilter(const std::string& filter) +bool BasicFilterSystem::removeFilter(const std::string& filter) { auto f = _availableFilters.find(filter); @@ -477,7 +477,7 @@ bool BasicFilterSystem::renameFilter(const std::string& oldFilterName, const std // Check if the new name is already used auto c = _availableFilters.find(newFilterName); - if (c != _availableFilters.end()) + if (c != _availableFilters.end()) { // Can't rename, name is already in use return false; @@ -541,7 +541,7 @@ bool BasicFilterSystem::isVisible(const FilterRule::Type type, const std::string // Check if this item is in the visibility cache, returning // its cached value if found auto cacheIter = _visibilityCache.find(name); - + if (cacheIter != _visibilityCache.end()) { return cacheIter->second; @@ -619,7 +619,7 @@ bool BasicFilterSystem::setFilterRules(const std::string& filter, const FilterRu return false; // not found or readonly } -void BasicFilterSystem::updateSubgraph(const scene::INodePtr& root) +void BasicFilterSystem::updateSubgraph(const scene::INodePtr& root) { // Construct an InstanceUpdateWalker and traverse the scenegraph to update // all instances @@ -628,14 +628,14 @@ void BasicFilterSystem::updateSubgraph(const scene::INodePtr& root) } // Update scenegraph instances with filtered status -void BasicFilterSystem::updateScene() +void BasicFilterSystem::updateScene() { // pass scenegraph root to specialised routine updateSubgraph(GlobalSceneGraph().root()); } // Update scenegraph instances with filtered status -void BasicFilterSystem::updateShaders() +void BasicFilterSystem::updateShaders() { // Construct a ShaderVisitor to traverse the shaders GlobalMaterialManager().foreachMaterial([this] (const MaterialPtr& material) @@ -648,13 +648,13 @@ void BasicFilterSystem::updateShaders() } // RegisterableModule implementation -const std::string& BasicFilterSystem::getName() const +const std::string& BasicFilterSystem::getName() const { static std::string _name(MODULE_FILTERSYSTEM); return _name; } -const StringSet& BasicFilterSystem::getDependencies() const +const StringSet& BasicFilterSystem::getDependencies() const { static StringSet _dependencies; @@ -669,6 +669,6 @@ const StringSet& BasicFilterSystem::getDependencies() const } // Module instance -module::StaticModule filterSystemModule; +module::StaticModuleRegistration filterSystemModule; } diff --git a/radiantcore/fonts/FontManager.cpp b/radiantcore/fonts/FontManager.cpp index 4a8bf6c836..5118cb1c42 100644 --- a/radiantcore/fonts/FontManager.cpp +++ b/radiantcore/fonts/FontManager.cpp @@ -143,6 +143,6 @@ FontInfoPtr FontManager::findOrCreateFontInfo(const std::string& name) } // Static module instance -module::StaticModule fontManagerModule; +module::StaticModuleRegistration fontManagerModule; } // namespace fonts diff --git a/radiantcore/grid/GridManager.cpp b/radiantcore/grid/GridManager.cpp index a81698f5d2..9ebdbc6a29 100644 --- a/radiantcore/grid/GridManager.cpp +++ b/radiantcore/grid/GridManager.cpp @@ -96,7 +96,7 @@ void GridManager::populateGridItems() for (int size = GRID_0125; size <= GRID_256; size++) { _gridItems.emplace_back( - grid::getStringForSize(static_cast(size)), + grid::getStringForSize(static_cast(size)), GridItem(static_cast(size), *this) ); } @@ -188,7 +188,7 @@ void GridManager::setGridCmd(const cmd::ArgumentList& args) rError() << "Unknown grid size: " << gridStr << std::endl; } -void GridManager::gridDownCmd(const cmd::ArgumentList& args) +void GridManager::gridDownCmd(const cmd::ArgumentList& args) { gridDown(); } @@ -210,7 +210,7 @@ void GridManager::gridUpCmd(const cmd::ArgumentList& args) void GridManager::gridUp() { - if (_activeGridSize < GRID_256) + if (_activeGridSize < GRID_256) { int _activeGridIndex = static_cast(_activeGridSize); _activeGridIndex++; @@ -218,7 +218,7 @@ void GridManager::gridUp() } } -void GridManager::setGridSize(GridSize gridSize) +void GridManager::setGridSize(GridSize gridSize) { if (_activeGridSize != gridSize) { @@ -274,6 +274,6 @@ GridLook GridManager::getMinorLook() const return getLookFromNumber(registry::getValue(RKEY_GRID_LOOK_MINOR)); } -module::StaticModule staticGridManagerModule; +module::StaticModuleRegistration staticGridManagerModule; } diff --git a/radiantcore/imagefile/ImageLoader.cpp b/radiantcore/imagefile/ImageLoader.cpp index a493e60f25..3c9316e7b1 100644 --- a/radiantcore/imagefile/ImageLoader.cpp +++ b/radiantcore/imagefile/ImageLoader.cpp @@ -155,6 +155,6 @@ void ImageLoader::initialiseModule(const IApplicationContext&) } // Static module instance -module::StaticModule imageLoaderModule; +module::StaticModuleRegistration imageLoaderModule; } // namespace shaders diff --git a/radiantcore/layers/LayerModule.cpp b/radiantcore/layers/LayerModule.cpp index 0df88ab2fa..d6de5ef992 100644 --- a/radiantcore/layers/LayerModule.cpp +++ b/radiantcore/layers/LayerModule.cpp @@ -72,7 +72,7 @@ class LayerModule : GlobalCommandSystem().addCommand(COMMAND_MOVETOLAYER, std::bind(&LayerModule::moveSelectionToLayer, this, std::placeholders::_1), { cmd::ARGTYPE_INT }); - + GlobalCommandSystem().addCommand(COMMAND_REMOVEFROMLAYER, std::bind(&LayerModule::removeSelectionFromLayer, this, std::placeholders::_1), { cmd::ARGTYPE_INT }); @@ -241,6 +241,6 @@ class LayerModule : } }; -module::StaticModule layerManagerFactoryModule; +module::StaticModuleRegistration layerManagerFactoryModule; } diff --git a/radiantcore/map/CounterManager.cpp b/radiantcore/map/CounterManager.cpp index d6e49ba341..f3471932a4 100644 --- a/radiantcore/map/CounterManager.cpp +++ b/radiantcore/map/CounterManager.cpp @@ -75,6 +75,6 @@ void CounterManager::initialiseModule(const IApplicationContext& ctx) } // Register the counter module in the registry -module::StaticModule counterManagerModule; +module::StaticModuleRegistration counterManagerModule; } // namespace map diff --git a/radiantcore/map/EditingStopwatch.cpp b/radiantcore/map/EditingStopwatch.cpp index ecdc73f935..1e01c482ea 100644 --- a/radiantcore/map/EditingStopwatch.cpp +++ b/radiantcore/map/EditingStopwatch.cpp @@ -20,7 +20,7 @@ namespace map namespace { const int TIMER_INTERVAL_SECS = 1; - + const char* const MAP_PROPERTY_KEY = "EditTimeInSeconds"; } @@ -109,7 +109,7 @@ void EditingStopwatch::onMapEvent(IMap::MapEvent ev) readFromMapProperties(); start(); break; - + // When a map is unloaded, we reset the value to 0 again // to prevent leaving stuff behind. case IMap::MapUnloaded: @@ -126,7 +126,7 @@ void EditingStopwatch::onMapEvent(IMap::MapEvent ev) case IMap::MapSaved: start(); break; - + default: break; }; @@ -163,7 +163,7 @@ unsigned long EditingStopwatch::getTotalSecondsEdited() void EditingStopwatch::setTotalSecondsEdited(unsigned long newValue) { std::lock_guard lock(_timingMutex); - + _secondsEdited = newValue; _sigTimerChanged.emit(); } @@ -196,6 +196,6 @@ void EditingStopwatch::writeToMapProperties(const scene::IMapRootNodePtr& root) } // Static module registration -module::StaticModule _stopwatchModule; +module::StaticModuleRegistration _stopwatchModule; } diff --git a/radiantcore/map/Map.cpp b/radiantcore/map/Map.cpp index fc80de401f..9af39b4944 100644 --- a/radiantcore/map/Map.cpp +++ b/radiantcore/map/Map.cpp @@ -312,21 +312,16 @@ bool Map::isUnnamed() const { namespace { - bool pointfileNameMatch(const std::string& candidate, - const std::string& mapStem) - { - // A matching point file either has an identical stem to the map file, - // or the map file stem with an underscore suffix (e.g. - // "mapfile_portal_123_456.lin") - if (candidate == mapStem) - return true; - else if (candidate.rfind(mapStem + "_", 0) == 0) - return true; - else - return false; - } + +bool pointfileNameMatch(const std::string& candidate, const std::string& mapStem) +{ + // A matching point file either has an identical stem to the map file, or the map file stem + // with an underscore suffix (e.g. "mapfile_portal_123_456.lin") + return string::iequals(candidate, mapStem) || string::istarts_with(candidate, mapStem + "_"); } +} // namespace + void Map::forEachPointfile(PointfileFunctor func) const { static const char* LIN_EXT = ".lin"; @@ -597,7 +592,7 @@ bool Map::save(const MapFormatPtr& mapFormat) } // Check if the map file has been modified in the meantime - if (_resource->fileOnDiskHasBeenModifiedSinceLastSave() && + if (_resource->fileOnDiskHasBeenModifiedSinceLastSave() && !radiant::FileOverwriteConfirmation::SendAndReceiveAnswer( fmt::format(_("The file {0} has been modified since it was last saved,\nperhaps by another application. " "Do you really want to overwrite the file?"), _mapName), _("File modification detected"))) @@ -964,11 +959,11 @@ void Map::registerCommands() GlobalCommandSystem().addCommand("OpenMap", Map::openMap, { cmd::ARGTYPE_STRING | cmd::ARGTYPE_OPTIONAL }); GlobalCommandSystem().addCommand("OpenMapFromArchive", Map::openMapFromArchive, { cmd::ARGTYPE_STRING, cmd::ARGTYPE_STRING }); GlobalCommandSystem().addCommand("ImportMap", Map::importMap); - GlobalCommandSystem().addCommand("StartMergeOperation", std::bind(&Map::startMergeOperationCmd, this, std::placeholders::_1), + GlobalCommandSystem().addCommand("StartMergeOperation", std::bind(&Map::startMergeOperationCmd, this, std::placeholders::_1), { cmd::ARGTYPE_STRING | cmd::ARGTYPE_OPTIONAL, cmd::ARGTYPE_STRING | cmd::ARGTYPE_OPTIONAL }); GlobalCommandSystem().addCommand("AbortMergeOperation", std::bind(&Map::abortMergeOperationCmd, this, std::placeholders::_1)); GlobalCommandSystem().addCommand("FinishMergeOperation", std::bind(&Map::finishMergeOperationCmd, this, std::placeholders::_1)); - GlobalCommandSystem().addCommand(LOAD_PREFAB_AT_CMD, std::bind(&Map::loadPrefabAt, this, std::placeholders::_1), + GlobalCommandSystem().addCommand(LOAD_PREFAB_AT_CMD, std::bind(&Map::loadPrefabAt, this, std::placeholders::_1), { cmd::ARGTYPE_STRING, cmd::ARGTYPE_VECTOR3, cmd::ARGTYPE_INT|cmd::ARGTYPE_OPTIONAL, cmd::ARGTYPE_INT | cmd::ARGTYPE_OPTIONAL }); GlobalCommandSystem().addCommand("SaveSelectedAsPrefab", Map::saveSelectedAsPrefab); GlobalCommandSystem().addCommand("SaveMap", std::bind(&Map::saveMapCmd, this, std::placeholders::_1)); diff --git a/radiantcore/map/MapModules.cpp b/radiantcore/map/MapModules.cpp index 11f1a481b6..02355527c6 100644 --- a/radiantcore/map/MapModules.cpp +++ b/radiantcore/map/MapModules.cpp @@ -3,7 +3,7 @@ #include "Map.h" // Creates the static module instance -module::StaticModule staticMapModule; +module::StaticModuleRegistration staticMapModule; // Accessor method containing the singleton Map instance map::Map& GlobalMap() diff --git a/radiantcore/map/MapResourceManager.cpp b/radiantcore/map/MapResourceManager.cpp index 98736aab26..99662015a9 100644 --- a/radiantcore/map/MapResourceManager.cpp +++ b/radiantcore/map/MapResourceManager.cpp @@ -65,7 +65,7 @@ void MapResourceManager::initialiseModule(const IApplicationContext& ctx) } // Define the MapResourceManager registerable module -module::StaticModule mapResourceManagerModule; +module::StaticModuleRegistration mapResourceManagerModule; } // namespace diff --git a/radiantcore/map/RegionManager.cpp b/radiantcore/map/RegionManager.cpp index e6b970caac..590adef3c7 100644 --- a/radiantcore/map/RegionManager.cpp +++ b/radiantcore/map/RegionManager.cpp @@ -45,7 +45,7 @@ RegionManager::RegionManager() : _active(false) {} -bool RegionManager::isEnabled() const +bool RegionManager::isEnabled() const { return _active; } @@ -231,7 +231,7 @@ void RegionManager::constructRegionBrushes(scene::INodePtr brushes[6], const Vec Vector3 mins(region_mins[0]-THICKNESS, region_mins[1]-THICKNESS, region_mins[2]-THICKNESS); mins[i] = region_maxs[i]; Brush& brush = *Node_getBrush(brushes[i+3]); - + brush.constructCuboid(AABB::createFromMinMax(mins, maxs), texdef_name_default()); } @@ -315,7 +315,7 @@ void RegionManager::setRegionFromBrush(const cmd::ArgumentList& args) SceneChangeNotify(); } - else + else { disable(); throw cmd::ExecutionFailure(_("Could not set Region: please select a single Brush.")); @@ -465,7 +465,7 @@ void RegionManager::onMapEvent(IMap::MapEvent ev) } else if (ev == IMap::MapLoaded) { - // Disable when a new map has been loaded + // Disable when a new map has been loaded disable(); } } @@ -487,6 +487,6 @@ AABB RegionManager::getVisibleBounds() return returnValue; } -module::StaticModule staticRegionManagerModule; +module::StaticModuleRegistration staticRegionManagerModule; } // namespace diff --git a/radiantcore/map/aas/AasFileManager.cpp b/radiantcore/map/aas/AasFileManager.cpp index 8f862886bc..85232b833b 100644 --- a/radiantcore/map/aas/AasFileManager.cpp +++ b/radiantcore/map/aas/AasFileManager.cpp @@ -49,7 +49,7 @@ IAasFileLoaderPtr AasFileManager::getLoaderForStream(std::istream& stream) // Rewind the stream when we're done stream.seekg(0, std::ios_base::beg); - + return loader; } @@ -161,6 +161,6 @@ void AasFileManager::initialiseModule(const IApplicationContext& ctx) } // Define the static AasFileManager module -module::StaticModule aasFileManagerModule; +module::StaticModuleRegistration aasFileManagerModule; } diff --git a/radiantcore/map/aas/Doom3AasFileLoader.cpp b/radiantcore/map/aas/Doom3AasFileLoader.cpp index 2fff17feb9..afee8efabd 100644 --- a/radiantcore/map/aas/Doom3AasFileLoader.cpp +++ b/radiantcore/map/aas/Doom3AasFileLoader.cpp @@ -86,7 +86,7 @@ void Doom3AasFileLoader::parseVersion(parser::DefTokeniser& tok) const // Require a "Version" token tok.assertNextToken("DewmAAS"); - // Require specific version, return true on success + // Require specific version, return true on success if (std::stof(tok.nextToken()) != DEWM3_AAS_VERSION) { throw parser::ParseException("AAS File version mismatch"); @@ -126,6 +126,6 @@ void Doom3AasFileLoader::shutdownModule() } // Static module instances -module::StaticModule d3AasModule; +module::StaticModuleRegistration d3AasModule; } diff --git a/radiantcore/map/autosaver/AutoSaver.cpp b/radiantcore/map/autosaver/AutoSaver.cpp index faac5544ff..9ad7aecdb9 100644 --- a/radiantcore/map/autosaver/AutoSaver.cpp +++ b/radiantcore/map/autosaver/AutoSaver.cpp @@ -30,10 +30,10 @@ #include -namespace map +namespace map { -namespace +namespace { // Registry key names const char* GKEY_MAP_EXTENSION = "/mapFormat/fileExtension"; @@ -70,7 +70,7 @@ void AutoMapSaver::clearChanges() _savedChangeCount = 0; } -void AutoMapSaver::saveSnapshot() +void AutoMapSaver::saveSnapshot() { // Original GtkRadiant comments: // we need to do the following @@ -108,14 +108,14 @@ void AutoMapSaver::saveSnapshot() handleSnapshotSizeLimit(existingSnapshots, snapshotPath, mapName); } - else + else { rError() << "Snapshot save failed.. unable to create directory"; rError() << snapshotPath << std::endl; } } -void AutoMapSaver::handleSnapshotSizeLimit(const std::map& existingSnapshots, +void AutoMapSaver::handleSnapshotSizeLimit(const std::map& existingSnapshots, const fs::path& snapshotPath, const std::string& mapName) { std::size_t maxSnapshotFolderSize = @@ -160,7 +160,7 @@ void AutoMapSaver::handleSnapshotSizeLimit(const std::map& exi return; } - rMessage() << "AutoSaver: The snapshot files in " << snapshotPath << + rMessage() << "AutoSaver: The snapshot files in " << snapshotPath << " take up more than " << maxSnapshotFolderSize << " MB. You might consider cleaning it up." << std::endl; // Notify the user @@ -175,7 +175,7 @@ void AutoMapSaver::handleSnapshotSizeLimit(const std::map& exi } } -void AutoMapSaver::collectExistingSnapshots(std::map& existingSnapshots, +void AutoMapSaver::collectExistingSnapshots(std::map& existingSnapshots, const fs::path& snapshotPath, const std::string& mapName) { for (int num = 0; num < INT_MAX; num++) @@ -348,6 +348,6 @@ void AutoMapSaver::shutdownModule() _signalConnections.clear(); } -module::StaticModule staticAutoSaverModule; +module::StaticModuleRegistration staticAutoSaverModule; } // namespace map diff --git a/radiantcore/map/format/Doom3MapFormat.cpp b/radiantcore/map/format/Doom3MapFormat.cpp index 162c21b2a4..a02becd3ef 100644 --- a/radiantcore/map/format/Doom3MapFormat.cpp +++ b/radiantcore/map/format/Doom3MapFormat.cpp @@ -83,7 +83,7 @@ bool Doom3MapFormat::canLoad(std::istream& stream) const // Require a "Version" token tok.assertNextToken("Version"); - // Require specific version, return true on success + // Require specific version, return true on success return (std::stof(tok.nextToken()) == MAP_VERSION_D3); } catch (parser::ParseException&) @@ -94,6 +94,6 @@ bool Doom3MapFormat::canLoad(std::istream& stream) const return false; } -module::StaticModule d3MapModule; +module::StaticModuleRegistration d3MapModule; } // namespace map diff --git a/radiantcore/map/format/Doom3PrefabFormat.cpp b/radiantcore/map/format/Doom3PrefabFormat.cpp index eff09e29d2..f34d5c7df5 100644 --- a/radiantcore/map/format/Doom3PrefabFormat.cpp +++ b/radiantcore/map/format/Doom3PrefabFormat.cpp @@ -39,6 +39,6 @@ bool Doom3PrefabFormat::allowInfoFileCreation() const return false; } -module::StaticModule d3PrefabModule; +module::StaticModuleRegistration d3PrefabModule; } // namespace diff --git a/radiantcore/map/format/MapFormatManager.cpp b/radiantcore/map/format/MapFormatManager.cpp index 0a6d3ed5a3..aa0fda22f1 100644 --- a/radiantcore/map/format/MapFormatManager.cpp +++ b/radiantcore/map/format/MapFormatManager.cpp @@ -31,7 +31,7 @@ void MapFormatManager::unregisterMapFormat(const MapFormatPtr& mapFormat) } } -MapFormatPtr MapFormatManager::getMapFormatByName(const std::string& mapFormatName) +MapFormatPtr MapFormatManager::getMapFormatByName(const std::string& mapFormatName) { for (const auto& pair : _mapFormats) { @@ -44,7 +44,7 @@ MapFormatPtr MapFormatManager::getMapFormatByName(const std::string& mapFormatNa return MapFormatPtr(); // nothing found } -MapFormatPtr MapFormatManager::getMapFormatForGameType(const std::string& gameType, +MapFormatPtr MapFormatManager::getMapFormatForGameType(const std::string& gameType, const std::string& extension) { std::string extLower = string::to_lower_copy(extension); @@ -76,12 +76,12 @@ MapFormatPtr MapFormatManager::getMapFormatForFilename(const std::string& filena std::set MapFormatManager::getAllMapFormats() { std::set set; - + for (const auto& fmt : _mapFormats) { set.insert(fmt.second); } - + return set; } @@ -119,6 +119,6 @@ void MapFormatManager::initialiseModule(const IApplicationContext& ctx) } // Creates the static module instance -module::StaticModule staticMapFormatManagerModule; +module::StaticModuleRegistration staticMapFormatManagerModule; } diff --git a/radiantcore/map/format/Quake3MapFormat.cpp b/radiantcore/map/format/Quake3MapFormat.cpp index 23b1fed875..b27fffc5e5 100644 --- a/radiantcore/map/format/Quake3MapFormat.cpp +++ b/radiantcore/map/format/Quake3MapFormat.cpp @@ -60,7 +60,7 @@ bool Quake3MapFormatBase::canLoad(std::istream& stream) const { // Require the opening brace of the first entity as first token tok.assertNextToken("{"); - + // That's it for the moment being return true; } @@ -118,7 +118,7 @@ IMapWriterPtr Quake3AlternateMapFormat::getMapWriter() const return std::make_shared(); } -module::StaticModule q3MapModule; -module::StaticModule q3AlternateMapModule; +module::StaticModuleRegistration q3MapModule; +module::StaticModuleRegistration q3AlternateMapModule; } // namespace map diff --git a/radiantcore/map/format/Quake4MapFormat.cpp b/radiantcore/map/format/Quake4MapFormat.cpp index 637570d5e9..40a627518c 100644 --- a/radiantcore/map/format/Quake4MapFormat.cpp +++ b/radiantcore/map/format/Quake4MapFormat.cpp @@ -84,7 +84,7 @@ bool Quake4MapFormat::canLoad(std::istream& stream) const // Require a "Version" token tok.assertNextToken("Version"); - // Require specific version, return true on success + // Require specific version, return true on success return (std::stof(tok.nextToken()) == MAP_VERSION_Q4); } catch (parser::ParseException&) @@ -95,6 +95,6 @@ bool Quake4MapFormat::canLoad(std::istream& stream) const return false; } -module::StaticModule q4MapModule; +module::StaticModuleRegistration q4MapModule; } // namespace map diff --git a/radiantcore/map/format/portable/PortableMapFormat.cpp b/radiantcore/map/format/portable/PortableMapFormat.cpp index c2e3695573..410f5be3c6 100644 --- a/radiantcore/map/format/portable/PortableMapFormat.cpp +++ b/radiantcore/map/format/portable/PortableMapFormat.cpp @@ -82,7 +82,7 @@ bool PortableMapFormat::canLoad(std::istream& stream) const return PortableMapReader::CanLoad(stream); } -module::StaticModule portableMapModule; +module::StaticModuleRegistration portableMapModule; } diff --git a/radiantcore/map/infofile/InfoFileManager.cpp b/radiantcore/map/infofile/InfoFileManager.cpp index eb2f7ef688..681e94049d 100644 --- a/radiantcore/map/infofile/InfoFileManager.cpp +++ b/radiantcore/map/infofile/InfoFileManager.cpp @@ -62,6 +62,6 @@ void InfoFileManager::shutdownModule() } // Define the static InfoFileManager module -module::StaticModule infoFileManagerModule; +module::StaticModuleRegistration infoFileManagerModule; } diff --git a/radiantcore/map/mru/MRU.cpp b/radiantcore/map/mru/MRU.cpp index 10ec95305c..03e3a2d1e6 100644 --- a/radiantcore/map/mru/MRU.cpp +++ b/radiantcore/map/mru/MRU.cpp @@ -178,6 +178,6 @@ void MRU::shutdownModule() saveRecentFiles(); } -module::StaticModule mruModule; +module::StaticModuleRegistration mruModule; } // namespace diff --git a/radiantcore/map/namespace/NamespaceFactory.cpp b/radiantcore/map/namespace/NamespaceFactory.cpp index 0f7bec3ecf..c9a3084739 100644 --- a/radiantcore/map/namespace/NamespaceFactory.cpp +++ b/radiantcore/map/namespace/NamespaceFactory.cpp @@ -29,4 +29,4 @@ void NamespaceFactory::initialiseModule(const IApplicationContext& ctx) } // Define the static NamespaceFactoryModule -module::StaticModule namespaceFactoryModule; +module::StaticModuleRegistration namespaceFactoryModule; diff --git a/radiantcore/model/ModelCache.cpp b/radiantcore/model/ModelCache.cpp index 572280529f..50e31796c9 100644 --- a/radiantcore/model/ModelCache.cpp +++ b/radiantcore/model/ModelCache.cpp @@ -17,7 +17,7 @@ #include "map/algorithm/Models.h" -namespace model +namespace model { ModelCache::ModelCache() : @@ -186,17 +186,17 @@ sigc::signal ModelCache::signal_modelsReloaded() } // RegisterableModule implementation -const std::string& ModelCache::getName() const +const std::string& ModelCache::getName() const { static std::string _name(MODULE_MODELCACHE); return _name; } -const StringSet& ModelCache::getDependencies() const +const StringSet& ModelCache::getDependencies() const { static StringSet _dependencies; - if (_dependencies.empty()) + if (_dependencies.empty()) { _dependencies.insert(MODULE_MODELFORMATMANAGER); _dependencies.insert(MODULE_COMMANDSYSTEM); @@ -209,9 +209,9 @@ void ModelCache::initialiseModule(const IApplicationContext& ctx) { rMessage() << getName() << "::initialiseModule called." << std::endl; - GlobalCommandSystem().addCommand("RefreshModels", + GlobalCommandSystem().addCommand("RefreshModels", std::bind(&ModelCache::refreshModelsCmd, this, std::placeholders::_1)); - GlobalCommandSystem().addCommand("RefreshSelectedModels", + GlobalCommandSystem().addCommand("RefreshSelectedModels", std::bind(&ModelCache::refreshSelectedModelsCmd, this, std::placeholders::_1)); } @@ -241,6 +241,6 @@ void ModelCache::refreshSelectedModelsCmd(const cmd::ArgumentList& args) } // The static module -module::StaticModule modelCacheModule; +module::StaticModuleRegistration modelCacheModule; } // namespace model diff --git a/radiantcore/model/ModelFormatManager.cpp b/radiantcore/model/ModelFormatManager.cpp index 8076321ba8..849077ffbe 100644 --- a/radiantcore/model/ModelFormatManager.cpp +++ b/radiantcore/model/ModelFormatManager.cpp @@ -76,7 +76,7 @@ void ModelFormatManager::postModuleInitialisation() std::string extLower = string::to_lower_copy(pair.second->getExtension()); GlobalFiletypes().registerPattern(filetype::TYPE_MODEL_EXPORT, FileTypePattern( - pair.second->getDisplayName(), + pair.second->getDisplayName(), extLower, "*." + extLower)); } @@ -235,6 +235,6 @@ void ModelFormatManager::convertModelCmd(const cmd::ArgumentList& args) } } -module::StaticModule _staticModelFormatManagerModule; +module::StaticModuleRegistration _staticModelFormatManagerModule; } diff --git a/radiantcore/model/md5/MD5Module.cpp b/radiantcore/model/md5/MD5Module.cpp index b8245b10e1..788e1e4025 100644 --- a/radiantcore/model/md5/MD5Module.cpp +++ b/radiantcore/model/md5/MD5Module.cpp @@ -38,7 +38,7 @@ class MD5Module : }; // Static module instances -module::StaticModule md5Module; -module::StaticModule md5AnimationCache; +module::StaticModuleRegistration md5Module; +module::StaticModuleRegistration md5AnimationCache; } diff --git a/radiantcore/model/picomodel/PicoModelModule.cpp b/radiantcore/model/picomodel/PicoModelModule.cpp index 17795527ff..bf6eab34cf 100644 --- a/radiantcore/model/picomodel/PicoModelModule.cpp +++ b/radiantcore/model/picomodel/PicoModelModule.cpp @@ -6,6 +6,6 @@ namespace model { // Static module instance -module::StaticModule picoModelModule; +module::StaticModuleRegistration picoModelModule; } diff --git a/radiantcore/particles/ParticlesManager.cpp b/radiantcore/particles/ParticlesManager.cpp index 6d2a9ef427..ab6262d5bb 100644 --- a/radiantcore/particles/ParticlesManager.cpp +++ b/radiantcore/particles/ParticlesManager.cpp @@ -257,7 +257,7 @@ void ParticlesManager::reloadParticleDefs() if (file != NULL) { // File is open, so parse the tokens - try + try { std::istream is(&(file->getInputStream())); parseStream(is, fileInfo.name); @@ -303,7 +303,7 @@ void ParticlesManager::saveParticleDef(const std::string& particleName) { targetPath = GlobalGameManager().getUserEnginePath(); - rMessage() << "No mod base path found, falling back to user engine path to save particle file: " << + rMessage() << "No mod base path found, falling back to user engine path to save particle file: " << targetPath.string() << std::endl; } @@ -397,6 +397,6 @@ void ParticlesManager::saveParticleDef(const std::string& particleName) tempStream.closeAndReplaceTargetFile(); } -module::StaticModule particlesManagerModule; +module::StaticModuleRegistration particlesManagerModule; } // namespace particles diff --git a/radiantcore/patch/PatchModule.cpp b/radiantcore/patch/PatchModule.cpp index 171f06341b..ce4f7ee550 100644 --- a/radiantcore/patch/PatchModule.cpp +++ b/radiantcore/patch/PatchModule.cpp @@ -111,13 +111,13 @@ void PatchModule::registerPatchCommands() GlobalCommandSystem().addCommand("RedisperseCols", selection::algorithm::redispersePatchCols); GlobalCommandSystem().addCommand("MatrixTranspose", selection::algorithm::transposePatch); GlobalCommandSystem().addCommand("CapSelectedPatches", selection::algorithm::capPatch, { cmd::ARGTYPE_STRING }); - GlobalCommandSystem().addCommand("ThickenSelectedPatches", selection::algorithm::thickenPatches, + GlobalCommandSystem().addCommand("ThickenSelectedPatches", selection::algorithm::thickenPatches, { cmd::ARGTYPE_DOUBLE, cmd::ARGTYPE_INT, cmd::ARGTYPE_INT }); // thickness, create_seams, axis GlobalCommandSystem().addCommand("StitchPatchTexture", patch::algorithm::stitchTextures); GlobalCommandSystem().addCommand("BulgePatch", patch::algorithm::bulge, { cmd::ARGTYPE_DOUBLE }); GlobalCommandSystem().addCommand("WeldSelectedPatches", patch::algorithm::weldSelectedPatches); } -module::StaticModule patchModule; +module::StaticModuleRegistration patchModule; } diff --git a/radiantcore/rendersystem/OpenGLModule.cpp b/radiantcore/rendersystem/OpenGLModule.cpp index 4559b9e4b0..2a71403cb5 100644 --- a/radiantcore/rendersystem/OpenGLModule.cpp +++ b/radiantcore/rendersystem/OpenGLModule.cpp @@ -12,7 +12,7 @@ OpenGLModule::OpenGLModule() : {} #ifdef ENABLE_KHR_DEBUG_EXTENSION -void OpenGLModule::onGLDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, +void OpenGLModule::onGLDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam) { rError() << "OpenGL says: " << message << std::endl; @@ -49,7 +49,7 @@ IGLFont::Ptr OpenGLModule::getFont(IGLFont::Style style, std::size_t size) if (cachedFont != _fontCache.end()) { auto locked = cachedFont->second.lock(); - + if (locked) { return locked; @@ -60,7 +60,7 @@ IGLFont::Ptr OpenGLModule::getFont(IGLFont::Style style, std::size_t size) auto font = std::make_shared(style, static_cast(size)); _fontCache[cacheKey] = font; - + return font; } @@ -72,7 +72,7 @@ void OpenGLModule::drawString(const std::string& string) const } } -int OpenGLModule::getFontHeight() +int OpenGLModule::getFontHeight() { return _font ? static_cast(_font->getLineHeight()) : 0; } @@ -114,4 +114,4 @@ void OpenGLModule::shutdownModule() } // Define the static OpenGLModule module -module::StaticModule openGLModule; +module::StaticModuleRegistration openGLModule; diff --git a/radiantcore/rendersystem/OpenGLRenderSystem.cpp b/radiantcore/rendersystem/OpenGLRenderSystem.cpp index 8761030d2d..fdbacb2f2d 100644 --- a/radiantcore/rendersystem/OpenGLRenderSystem.cpp +++ b/radiantcore/rendersystem/OpenGLRenderSystem.cpp @@ -60,7 +60,7 @@ OpenGLRenderSystem::OpenGLRenderSystem() : if (GlobalMaterialManager().isRealised()) { - // Hold back with the realise() call until we know whether we can call + // Hold back with the realise() call until we know whether we can call // extensionsInitialised() below - this should happen before realise() shouldRealise = true; } @@ -261,8 +261,8 @@ void OpenGLRenderSystem::unrealise() sp->unrealise(); } - if (GlobalOpenGLContext().getSharedContext() && - shaderProgramsAvailable() && + if (GlobalOpenGLContext().getSharedContext() && + shaderProgramsAvailable() && getCurrentShaderProgram() != SHADER_PROGRAM_NONE) { // Unrealise the GLPrograms @@ -398,7 +398,7 @@ const StringSet& OpenGLRenderSystem::getDependencies() const { static StringSet _dependencies; - if (_dependencies.empty()) + if (_dependencies.empty()) { _dependencies.insert(MODULE_SHADERSYSTEM); _dependencies.insert(MODULE_SHARED_GL_CONTEXT); @@ -440,6 +440,6 @@ void OpenGLRenderSystem::shutdownModule() } // Define the static OpenGLRenderSystem module -module::StaticModule openGLRenderSystemModule; +module::StaticModuleRegistration openGLRenderSystemModule; } // namespace render diff --git a/radiantcore/rendersystem/RenderSystemFactory.cpp b/radiantcore/rendersystem/RenderSystemFactory.cpp index 2d4a1ad293..c121f3b40a 100644 --- a/radiantcore/rendersystem/RenderSystemFactory.cpp +++ b/radiantcore/rendersystem/RenderSystemFactory.cpp @@ -31,6 +31,6 @@ void RenderSystemFactory::initialiseModule(const IApplicationContext& ctx) } // Define the static RenderSystemFactory module -module::StaticModule renderSystemFactory; +module::StaticModuleRegistration renderSystemFactory; } // namespace diff --git a/radiantcore/rendersystem/SharedOpenGLContextModule.cpp b/radiantcore/rendersystem/SharedOpenGLContextModule.cpp index e7949df5a6..685dbf5cb6 100644 --- a/radiantcore/rendersystem/SharedOpenGLContextModule.cpp +++ b/radiantcore/rendersystem/SharedOpenGLContextModule.cpp @@ -73,6 +73,6 @@ void SharedOpenGLContextModule::shutdownModule() _sharedContext.reset(); } -module::StaticModule sharedContextModule; +module::StaticModuleRegistration sharedContextModule; } diff --git a/radiantcore/rendersystem/debug/SpacePartitionRenderer.cpp b/radiantcore/rendersystem/debug/SpacePartitionRenderer.cpp index 51eb6ed094..07a981d9fe 100644 --- a/radiantcore/rendersystem/debug/SpacePartitionRenderer.cpp +++ b/radiantcore/rendersystem/debug/SpacePartitionRenderer.cpp @@ -85,7 +85,7 @@ void SpacePartitionRenderer::uninstallRenderer() #ifdef _DEBUG // The module is only active in debug builds -module::StaticModule spacePartitionModule; +module::StaticModuleRegistration spacePartitionModule; #endif } // namespace render diff --git a/radiantcore/scenegraph/SceneGraph.cpp b/radiantcore/scenegraph/SceneGraph.cpp index 70b0e8a62f..93444cfc4c 100644 --- a/radiantcore/scenegraph/SceneGraph.cpp +++ b/radiantcore/scenegraph/SceneGraph.cpp @@ -32,9 +32,9 @@ SceneGraph::~SceneGraph() } } -void SceneGraph::addSceneObserver(Graph::Observer* observer) +void SceneGraph::addSceneObserver(Graph::Observer* observer) { - if (observer != nullptr) + if (observer != nullptr) { // Add the passed observer to the list _sceneObservers.push_back(observer); @@ -96,7 +96,7 @@ void SceneGraph::setRoot(const IMapRootNodePtr& newRoot) GraphPtr self = shared_from_this(); InstanceSubgraphWalker instanceWalker(self); _root->traverse(instanceWalker); - + _undoEventHandler = _root->getUndoSystem().signal_undoEvent().connect( sigc::mem_fun(this, &SceneGraph::onUndoEvent) ); @@ -269,20 +269,20 @@ void SceneGraph::foreachNodeInVolume(const VolumeTest& volume, const INode::Visi void SceneGraph::foreachNodeInVolume(const VolumeTest& volume, Walker& walker) { // Use a small adaptor lambda to dispatch calls to the walker - foreachNodeInVolume(volume, - [&] (const INodePtr& node) { return walker.visit(node); }, + foreachNodeInVolume(volume, + [&] (const INodePtr& node) { return walker.visit(node); }, true); // visit hidden } void SceneGraph::foreachVisibleNodeInVolume(const VolumeTest& volume, Walker& walker) { // Use a small adaptor lambda to dispatch calls to the walker - foreachNodeInVolume(volume, - [&] (const INodePtr& node) { return walker.visit(node); }, + foreachNodeInVolume(volume, + [&] (const INodePtr& node) { return walker.visit(node); }, false); // don't visit hidden } -bool SceneGraph::foreachNodeInVolume_r(const ISPNode& node, const VolumeTest& volume, +bool SceneGraph::foreachNodeInVolume_r(const ISPNode& node, const VolumeTest& volume, const INode::VisitorFunc& functor, bool visitHidden) { _visitedSPNodes++; @@ -376,7 +376,7 @@ void SceneGraphModule::initialiseModule(const IApplicationContext& ctx) } // Static module instances -module::StaticModule sceneGraphModule; -module::StaticModule sceneGraphFactory; +module::StaticModuleRegistration sceneGraphModule; +module::StaticModuleRegistration sceneGraphFactory; } // namespace scene diff --git a/radiantcore/selection/RadiantSelectionSystem.cpp b/radiantcore/selection/RadiantSelectionSystem.cpp index 1d8e77fb5c..57142cb5aa 100644 --- a/radiantcore/selection/RadiantSelectionSystem.cpp +++ b/radiantcore/selection/RadiantSelectionSystem.cpp @@ -1431,6 +1431,6 @@ void RadiantSelectionSystem::onMapEvent(IMap::MapEvent ev) } // Define the static SelectionSystem module -module::StaticModule radiantSelectionSystemModule; +module::StaticModuleRegistration radiantSelectionSystemModule; } diff --git a/radiantcore/selection/group/SelectionGroupModule.cpp b/radiantcore/selection/group/SelectionGroupModule.cpp index 62bc4f32ad..261e19c54f 100644 --- a/radiantcore/selection/group/SelectionGroupModule.cpp +++ b/radiantcore/selection/group/SelectionGroupModule.cpp @@ -70,7 +70,7 @@ class SelectionGroupModule : } }; -module::StaticModule selGroupModule; +module::StaticModuleRegistration selGroupModule; } diff --git a/radiantcore/selection/selectionset/SelectionSetModule.cpp b/radiantcore/selection/selectionset/SelectionSetModule.cpp index fd0524fef6..552c459616 100644 --- a/radiantcore/selection/selectionset/SelectionSetModule.cpp +++ b/radiantcore/selection/selectionset/SelectionSetModule.cpp @@ -69,6 +69,6 @@ class SelectionSetModule : } }; -module::StaticModule selectionSetModule; +module::StaticModuleRegistration selectionSetModule; } diff --git a/radiantcore/selection/shaderclipboard/ShaderClipboard.cpp b/radiantcore/selection/shaderclipboard/ShaderClipboard.cpp index 1fb5e1bfac..903ad2466b 100644 --- a/radiantcore/selection/shaderclipboard/ShaderClipboard.cpp +++ b/radiantcore/selection/shaderclipboard/ShaderClipboard.cpp @@ -15,7 +15,7 @@ #include "module/StaticModule.h" #include "../clipboard/Clipboard.h" -namespace selection +namespace selection { namespace @@ -57,7 +57,7 @@ void ShaderClipboard::sourceChanged() _signalSourceChanged.emit(); } -void ShaderClipboard::clear() +void ShaderClipboard::clear() { if (_updatesDisabled) return; @@ -141,7 +141,7 @@ void ShaderClipboard::setSource(Patch& sourcePatch) sourceChanged(); } -void ShaderClipboard::setSource(Face& sourceFace) +void ShaderClipboard::setSource(Face& sourceFace) { if (_updatesDisabled) return; // loopback guard @@ -184,7 +184,7 @@ void ShaderClipboard::onMapEvent(IMap::MapEvent ev) if (GlobalMapModule().getRoot()) { auto shader = GlobalMapModule().getRoot()->getProperty(LAST_USED_MATERIAL_KEY); - + if (!shader.empty()) { setSourceShader(shader); @@ -263,6 +263,6 @@ void ShaderClipboard::onSystemClipboardContentsChanged() } // Define the static module -module::StaticModule shaderClipboardModule; +module::StaticModuleRegistration shaderClipboardModule; } // namespace diff --git a/radiantcore/selection/textool/ColourSchemeManager.cpp b/radiantcore/selection/textool/ColourSchemeManager.cpp index aecc4dd5a6..60d33bc395 100644 --- a/radiantcore/selection/textool/ColourSchemeManager.cpp +++ b/radiantcore/selection/textool/ColourSchemeManager.cpp @@ -107,6 +107,6 @@ class ColourSchemeManager final : } }; -module::StaticModule _textureToolColourSchemeManager; +module::StaticModuleRegistration _textureToolColourSchemeManager; } diff --git a/radiantcore/selection/textool/TextureToolSceneGraph.cpp b/radiantcore/selection/textool/TextureToolSceneGraph.cpp index eb8d451a5b..93d367172f 100644 --- a/radiantcore/selection/textool/TextureToolSceneGraph.cpp +++ b/radiantcore/selection/textool/TextureToolSceneGraph.cpp @@ -93,7 +93,7 @@ void TextureToolSceneGraph::ensureSceneIsAnalysed() } if (!_selectionNeedsRescan) return; - + _selectionNeedsRescan = false; clearFaceObservers(); _nodes.clear(); @@ -160,6 +160,6 @@ void TextureToolSceneGraph::onTextureChanged(radiant::TextureChangedMessage& msg _activeMaterialNeedsRescan = true; } -module::StaticModule _textureToolSceneGraphModule; +module::StaticModuleRegistration _textureToolSceneGraphModule; } diff --git a/radiantcore/selection/textool/TextureToolSelectionSystem.cpp b/radiantcore/selection/textool/TextureToolSelectionSystem.cpp index 378a7cbffc..9e0d36d7dc 100644 --- a/radiantcore/selection/textool/TextureToolSelectionSystem.cpp +++ b/radiantcore/selection/textool/TextureToolSelectionSystem.cpp @@ -26,7 +26,7 @@ const std::string& TextureToolSelectionSystem::getName() const const StringSet& TextureToolSelectionSystem::getDependencies() const { - static StringSet _dependencies{ MODULE_TEXTOOL_SCENEGRAPH, + static StringSet _dependencies{ MODULE_TEXTOOL_SCENEGRAPH, MODULE_COMMANDSYSTEM, MODULE_RADIANT_CORE }; return _dependencies; } @@ -50,13 +50,13 @@ void TextureToolSelectionSystem::initialiseModule(const IApplicationContext& ctx GlobalCommandSystem().addCommand("ToggleTextureToolSelectionMode", std::bind(&TextureToolSelectionSystem::toggleSelectionModeCmd, this, std::placeholders::_1), { cmd::ARGTYPE_STRING }); - GlobalCommandSystem().addCommand("TexToolSelectRelated", + GlobalCommandSystem().addCommand("TexToolSelectRelated", std::bind(&TextureToolSelectionSystem::selectRelatedCmd, this, std::placeholders::_1)); - GlobalCommandSystem().addCommand("TexToolSnapToGrid", + GlobalCommandSystem().addCommand("TexToolSnapToGrid", std::bind(&TextureToolSelectionSystem::snapSelectionToGridCmd, this, std::placeholders::_1)); GlobalCommandSystem().addCommand("TexToolNormaliseItems", std::bind(&TextureToolSelectionSystem::normaliseSelectionCmd, this, std::placeholders::_1)); - GlobalCommandSystem().addCommand("TexToolMergeItems", + GlobalCommandSystem().addCommand("TexToolMergeItems", std::bind(&TextureToolSelectionSystem::mergeSelectionCmd, this, std::placeholders::_1), { cmd::ARGTYPE_VECTOR2 | cmd::ARGTYPE_OPTIONAL }); @@ -70,9 +70,9 @@ void TextureToolSelectionSystem::initialiseModule(const IApplicationContext& ctx std::bind(&TextureToolSelectionSystem::rotateSelectionCmd, this, std::placeholders::_1), { cmd::ARGTYPE_DOUBLE }); - GlobalCommandSystem().addCommand("TexToolFlipS", + GlobalCommandSystem().addCommand("TexToolFlipS", std::bind(&TextureToolSelectionSystem::flipHorizontallyCmd, this, std::placeholders::_1)); - GlobalCommandSystem().addCommand("TexToolFlipT", + GlobalCommandSystem().addCommand("TexToolFlipT", std::bind(&TextureToolSelectionSystem::flipVerticallyCmd, this, std::placeholders::_1)); _unselectListener = GlobalRadiantCore().getMessageBus().addListener( @@ -687,7 +687,7 @@ void TextureToolSelectionSystem::mergeSelectionCmd(const cmd::ArgumentList& args node->commitTransformation(); return true; }); - + radiant::TextureChangedMessage::Send(); } } @@ -856,6 +856,6 @@ void TextureToolSelectionSystem::rotateSelectionCmd(const cmd::ArgumentList& arg foreachSelectedNode(rotator); } -module::StaticModule _textureToolSelectionSystemModule; +module::StaticModuleRegistration _textureToolSelectionSystemModule; } diff --git a/radiantcore/settings/ColourSchemeManager.cpp b/radiantcore/settings/ColourSchemeManager.cpp index e1e96eeb7e..f9a2665141 100644 --- a/radiantcore/settings/ColourSchemeManager.cpp +++ b/radiantcore/settings/ColourSchemeManager.cpp @@ -48,7 +48,7 @@ void ColourSchemeManager::setActive(const std::string& name) } } -void ColourSchemeManager::restoreColourSchemes() +void ColourSchemeManager::restoreColourSchemes() { // Clear the whole colourScheme map and reload it from the registry _colourSchemes.clear(); @@ -87,7 +87,7 @@ void ColourSchemeManager::saveScheme(const std::string& name) } // Set the active attribute, if this is the active scheme - if (name == _activeScheme) + if (name == _activeScheme) { schemeNode.setAttributeValue("active", "1"); } @@ -237,6 +237,6 @@ void ColourSchemeManager::emitEclassOverrides() colourManager.addOverrideColour("light", activeScheme.getColour("light_volumes").getColour()); } -module::StaticModule colourSchemeManagerModule; +module::StaticModuleRegistration colourSchemeManagerModule; } // namespace ui diff --git a/radiantcore/settings/GameManager.cpp b/radiantcore/settings/GameManager.cpp index 50b4b1b17f..acd4c26369 100644 --- a/radiantcore/settings/GameManager.cpp +++ b/radiantcore/settings/GameManager.cpp @@ -48,11 +48,11 @@ const std::string& Manager::getName() const return _name; } -const StringSet& Manager::getDependencies() const +const StringSet& Manager::getDependencies() const { static StringSet _dependencies; - if (_dependencies.empty()) + if (_dependencies.empty()) { _dependencies.insert(MODULE_XMLREGISTRY); _dependencies.insert(MODULE_VIRTUALFILESYSTEM); @@ -89,7 +89,7 @@ void Manager::initialiseModule(const IApplicationContext& ctx) rMessage() << "Found fs_game command line argument, overriding existing mod path." << std::endl; // Remove starting slash from argument and convert to standard paths - config.modPath = os::standardPathWithSlash(config.enginePath) + + config.modPath = os::standardPathWithSlash(config.enginePath) + os::standardPath(string::trim_left_copy(arg.substr(8), "/")); registry::setValue(RKEY_MOD_PATH, config.modPath); @@ -107,7 +107,7 @@ void Manager::initialiseModule(const IApplicationContext& ctx) } } - // Check validity of the saved game configuration + // Check validity of the saved game configuration // and invoke the UI if it's not a valid one. if (GameConfigUtil::PathsValid(config)) { @@ -186,7 +186,7 @@ void Manager::initialiseGameType() { rMessage() << "GameManager: Selected game type: " << _config.gameType << std::endl; } - else + else { // No game type selected, bail out, the program would crash anyway on module load throw std::runtime_error(_("No game type selected.")); @@ -269,7 +269,7 @@ void Manager::setMapAndPrefabPaths(const std::string& baseGamePath) mapFolder = "maps/"; } - if (_config.modPath.empty() && _config.modBasePath.empty()) + if (_config.modPath.empty() && _config.modBasePath.empty()) { _mapPath = baseGamePath + mapFolder; } @@ -278,7 +278,7 @@ void Manager::setMapAndPrefabPaths(const std::string& baseGamePath) _mapPath = _config.modPath + mapFolder; } else // _config.modBasePath is not empty - { + { _mapPath = _config.modBasePath + mapFolder; } @@ -309,7 +309,7 @@ void Manager::initialiseVfs() for (const auto& extension : extensions) { auto extLower = string::to_lower_copy(extension); - GlobalFiletypes().registerPattern(filetype::TYPE_PAK, + GlobalFiletypes().registerPattern(filetype::TYPE_PAK, FileTypePattern(fmt::format(_("{0} File"), string::to_upper_copy(extension)), extLower, "*." + extLower, PAK_ICON)); } @@ -363,7 +363,7 @@ void Manager::initialiseVfs() GlobalFileSystem().initialise(vfsSearchPaths, extensions); } -const Manager::PathList& Manager::getVFSSearchPaths() const +const Manager::PathList& Manager::getVFSSearchPaths() const { return GlobalFileSystem().getVfsSearchPaths(); } @@ -390,7 +390,7 @@ void Manager::loadGameFiles(const std::string& appPath) try { - // Invoke a functor on every file in the games/ dir, + // Invoke a functor on every file in the games/ dir, // function gets called with the file (without path) os::foreachItemInDirectory(gamePath, [&](const fs::path& file) { @@ -420,7 +420,7 @@ void Manager::loadGameFiles(const std::string& appPath) // Populate the sorted games list _sortedGames.clear(); - + // Sort the games by their index std::multimap sortedGameMap; @@ -444,6 +444,6 @@ void Manager::loadGameFiles(const std::string& appPath) } // The static module definition (self-registers) -module::StaticModule gameManagerModule; +module::StaticModuleRegistration gameManagerModule; } // namespace game diff --git a/radiantcore/settings/PreferenceSystem.cpp b/radiantcore/settings/PreferenceSystem.cpp index cd2a0cf5a8..b39df4a518 100644 --- a/radiantcore/settings/PreferenceSystem.cpp +++ b/radiantcore/settings/PreferenceSystem.cpp @@ -49,6 +49,6 @@ void PreferenceSystem::initialiseModule(const IApplicationContext& ctx) } // Define the static PreferenceSystem module -module::StaticModule preferenceSystemModule; +module::StaticModuleRegistration preferenceSystemModule; } diff --git a/radiantcore/shaders/Doom3ShaderSystem.cpp b/radiantcore/shaders/Doom3ShaderSystem.cpp index 0d383388e8..4e426f7457 100644 --- a/radiantcore/shaders/Doom3ShaderSystem.cpp +++ b/radiantcore/shaders/Doom3ShaderSystem.cpp @@ -511,8 +511,8 @@ void Doom3ShaderSystem::saveMaterial(const std::string& name) // Update the template in our library // Re-acquire the vfs::FileInfo structure which might still be empty for a newly created material _library->replaceDefinition(material->getName(), ShaderDefinition - { - material->getTemplate(), + { + material->getTemplate(), GlobalFileSystem().getFileInfo(material->getShaderFileInfo().fullPath()) }); } @@ -745,6 +745,6 @@ GLTextureManager& GetTextureManager() } // Static module instance -module::StaticModule d3ShaderSystemModule; +module::StaticModuleRegistration d3ShaderSystemModule; } // namespace shaders diff --git a/radiantcore/skins/Doom3SkinCache.cpp b/radiantcore/skins/Doom3SkinCache.cpp index e39b4ac579..cf446d1d68 100644 --- a/radiantcore/skins/Doom3SkinCache.cpp +++ b/radiantcore/skins/Doom3SkinCache.cpp @@ -30,7 +30,7 @@ ModelSkin& Doom3SkinCache::capture(const std::string& name) return i != _namedSkins.end() ? *(i->second) : _nullSkin; } -const StringList& Doom3SkinCache::getSkinsForModel(const std::string& model) +const StringList& Doom3SkinCache::getSkinsForModel(const std::string& model) { ensureDefsLoaded(); return _modelSkins[model]; @@ -62,7 +62,7 @@ sigc::signal Doom3SkinCache::signal_skinsReloaded() // Realise the skin cache void Doom3SkinCache::ensureDefsLoaded() { - // The worker function contained in the def loader will + // The worker function contained in the def loader will // fill the local structures when it's done _defLoader.ensureFinished(); } @@ -85,7 +85,7 @@ void Doom3SkinCache::loadSkinFiles() std::istream is(&(file->getInputStream())); - try + try { // Pass the contents back to the SkinCache module for parsing parseFile(is, fileInfo.name); @@ -128,7 +128,7 @@ void Doom3SkinCache::parseFile(std::istream& contents, const std::string& filena auto found = _namedSkins.find(skinName); // Is this already defined? - if (found != _namedSkins.end()) + if (found != _namedSkins.end()) { rWarning() << "[skins] in " << filename << ": skin " + skinName + " previously defined in " + @@ -151,7 +151,7 @@ void Doom3SkinCache::parseFile(std::istream& contents, const std::string& filena } // Parse an individual skin declaration -Doom3ModelSkinPtr Doom3SkinCache::parseSkin(parser::DefTokeniser& tok) +Doom3ModelSkinPtr Doom3SkinCache::parseSkin(parser::DefTokeniser& tok) { // [ "skin" ] "{" // [ "model" ] @@ -209,7 +209,7 @@ const std::string& Doom3SkinCache::getName() const return _name; } -const StringSet& Doom3SkinCache::getDependencies() const +const StringSet& Doom3SkinCache::getDependencies() const { static StringSet _dependencies; @@ -241,6 +241,6 @@ void Doom3SkinCache::initialiseModule(const IApplicationContext& ctx) } // Module instance -module::StaticModule skinCacheModule; +module::StaticModuleRegistration skinCacheModule; } // namespace skins diff --git a/radiantcore/undo/UndoSystemFactory.cpp b/radiantcore/undo/UndoSystemFactory.cpp index 02558d5b0c..3b3e07ee1c 100644 --- a/radiantcore/undo/UndoSystemFactory.cpp +++ b/radiantcore/undo/UndoSystemFactory.cpp @@ -46,6 +46,6 @@ class UndoSystemFactory final : }; // Static module instance -module::StaticModule _undoSystemFactoryModule; +module::StaticModuleRegistration _undoSystemFactoryModule; } diff --git a/radiantcore/versioncontrol/VersionControlManager.cpp b/radiantcore/versioncontrol/VersionControlManager.cpp index dab4d6374a..34650f107f 100644 --- a/radiantcore/versioncontrol/VersionControlManager.cpp +++ b/radiantcore/versioncontrol/VersionControlManager.cpp @@ -45,6 +45,6 @@ void VersionControlManager::initialiseModule(const IApplicationContext& ctx) rMessage() << getName() << "::initialiseModule called." << std::endl; } -module::StaticModule versionControlManagerModule; +module::StaticModuleRegistration versionControlManagerModule; } diff --git a/radiantcore/vfs/Doom3FileSystemModule.cpp b/radiantcore/vfs/Doom3FileSystemModule.cpp index 7f93925fe5..a5f8a7ffe9 100644 --- a/radiantcore/vfs/Doom3FileSystemModule.cpp +++ b/radiantcore/vfs/Doom3FileSystemModule.cpp @@ -5,6 +5,6 @@ namespace vfs { // Static module instance -module::StaticModule doom3FileSystemModule; +module::StaticModuleRegistration doom3FileSystemModule; } diff --git a/radiantcore/xmlregistry/XMLRegistry.cpp b/radiantcore/xmlregistry/XMLRegistry.cpp index d364531554..5fb3c3634b 100644 --- a/radiantcore/xmlregistry/XMLRegistry.cpp +++ b/radiantcore/xmlregistry/XMLRegistry.cpp @@ -39,7 +39,7 @@ void XMLRegistry::saveToDisk() { return; } - + std::lock_guard lock(_writeLock); // Make a deep copy of the user tree by copy-constructing it @@ -118,7 +118,7 @@ bool XMLRegistry::keyExists(const std::string& key) return !result.empty(); } -void XMLRegistry::deleteXPath(const std::string& path) +void XMLRegistry::deleteXPath(const std::string& path) { std::lock_guard lock(_writeLock); @@ -203,11 +203,11 @@ std::string XMLRegistry::get(const std::string& key) // Convert the UTF-8 string back to locale and return return string::utf8_to_mb(nodeList[0].getAttributeValue("value")); } - + return std::string(); } -void XMLRegistry::set(const std::string& key, const std::string& value) +void XMLRegistry::set(const std::string& key, const std::string& value) { { std::lock_guard lock(_writeLock); @@ -231,7 +231,7 @@ void XMLRegistry::import(const std::string& importFilePath, const std::string& p assert(!_shutdown); - switch (tree) + switch (tree) { case treeUser: _userTree.importFromFile(importFilePath, parentKey); @@ -277,7 +277,7 @@ void XMLRegistry::loadUserFileFromSettingsPath(const IApplicationContext& ctx, } else { - rMessage() << "XMLRegistry: file " << filename << " not present in " + rMessage() << "XMLRegistry: file " << filename << " not present in " << ctx.getSettingsPath() << std::endl; } } @@ -314,7 +314,7 @@ void XMLRegistry::initialiseModule(const IApplicationContext& ctx) import(base + "commandsystem.xml", "user/ui", Registry::treeStandard); // Load the debug.xml file only if the relevant key is set in user.xml - if (get("user/debug") == "1") + if (get("user/debug") == "1") { import(base + "debug.xml", "", Registry::treeStandard); } @@ -325,7 +325,7 @@ void XMLRegistry::initialiseModule(const IApplicationContext& ctx) } // Load user preferences, these overwrite any values that have defined before - + loadUserFileFromSettingsPath(ctx, "user.xml", ""); loadUserFileFromSettingsPath(ctx, "colours.xml", "user/ui"); loadUserFileFromSettingsPath(ctx, "input.xml", "user/ui"); @@ -337,7 +337,7 @@ void XMLRegistry::initialiseModule(const IApplicationContext& ctx) _autosaveTimer.reset(new util::Timer(2000, sigc::mem_fun(this, &XMLRegistry::onAutoSaveTimerIntervalReached))); - + module::GlobalModuleRegistry().signal_allModulesInitialised().connect([this]() { _autosaveTimer->start(); @@ -366,6 +366,6 @@ void XMLRegistry::onAutoSaveTimerIntervalReached() } // Static module instance -module::StaticModule xmlRegistryModule; +module::StaticModuleRegistration xmlRegistryModule; } diff --git a/test/Entity.cpp b/test/Entity.cpp index e0787e3b7f..63a54ba076 100644 --- a/test/Entity.cpp +++ b/test/Entity.cpp @@ -1035,16 +1035,14 @@ TEST_F(EntityTest, CreateAttachedLightEntity) TEST_F(EntityTest, RenderAttachedLightEntity) { - auto torch = createByClassName("atdm:torch_brazier"); - ASSERT_TRUE(torch); + auto torch = TestEntity::create("atdm:torch_brazier"); // Confirm that def has the right model - auto& spawnArgs = torch->getEntity(); - EXPECT_EQ(spawnArgs.getKeyValue("model"), "models/torch.lwo"); + EXPECT_EQ(torch.args().getKeyValue("model"), "models/torch.lwo"); // We must render in solid mode to get the light source RenderFixture rf(true /* solid mode */); - rf.renderSubGraph(torch); + rf.renderSubGraph(torch.node); // There should be 3 renderables from the torch (because the entity has a // shadowmesh and a collision mesh as well as the main model) and one from @@ -1083,6 +1081,30 @@ TEST_F(EntityTest, AttachedLightAtCorrectPosition) EXPECT_EQ(rLight->lightAABB().origin, ORIGIN + EXPECTED_OFFSET); } +TEST_F(EntityTest, ReloadDefsDoesNotChangeAttachPos) +{ + const Vector3 ORIGIN(-10, 25, 320); + const Vector3 EXPECTED_OFFSET(0, 0, 10); + + // Create a torch node at the origin + auto torch = createByClassName("atdm:torch_brazier"); + torch->getEntity().setKeyValue("origin", string::to_string(ORIGIN)); + + // Reload all entity defs + GlobalEntityClassManager().reloadDefs(); + + // Render the torch + RenderFixture rf(true /* solid mode */); + rf.renderSubGraph(torch); + ASSERT_FALSE(rf.collector.lightPtrs.empty()); + const RendererLight* rLight = rf.collector.lightPtrs.front(); + ASSERT_TRUE(rLight); + + // The light source should still have the expected offset + EXPECT_EQ(rLight->getLightOrigin(), ORIGIN + EXPECTED_OFFSET); + EXPECT_EQ(rLight->lightAABB().origin, ORIGIN + EXPECTED_OFFSET); +} + TEST_F(EntityTest, AttachedLightMovesWithEntity) { const Vector3 ORIGIN(12, -0.5, 512); diff --git a/test/PointTrace.cpp b/test/PointTrace.cpp index bdaa11fa68..34741c2b26 100644 --- a/test/PointTrace.cpp +++ b/test/PointTrace.cpp @@ -64,9 +64,10 @@ TEST_F(PointTraceTest, IdentifyMapPointfiles) // Check the pointfiles for this map auto pfs = pointfiles(); - ASSERT_EQ(pfs.size(), 2); - EXPECT_EQ(pfs[0].filename(), "altar.lin"); - EXPECT_EQ(pfs[1].filename(), "altar_portalL_544_64_112.lin"); + ASSERT_EQ(pfs.size(), 3); + EXPECT_EQ(pfs[0].filename(), "ALTAr.lin"); + EXPECT_EQ(pfs[1].filename(), "altar.lin"); + EXPECT_EQ(pfs[2].filename(), "altar_portalL_544_64_112.lin"); } TEST_F(PointTraceTest, PointFilesAssociatedWithCorrectMap) diff --git a/test/resources/tdm/maps/ALTAr.lin b/test/resources/tdm/maps/ALTAr.lin new file mode 100644 index 0000000000..f6212fb863 --- /dev/null +++ b/test/resources/tdm/maps/ALTAr.lin @@ -0,0 +1,5 @@ +544.000000 64.000000 112.000000 +544.000000 64.000000 240.000000 +512.000000 64.000000 240.000000 +512.000000 64.000000 112.000000 +544.000000 64.000000 112.000000