From 842bede50d0bc23b2e8595ea812854a11028c765 Mon Sep 17 00:00:00 2001 From: codereader Date: Sun, 17 May 2020 17:35:25 +0200 Subject: [PATCH] #5231: Rename EntityCreator to EntityModule --- include/ientity.h | 16 +++++++------- libs/entitylib.h | 2 +- libs/scene/BasicRootNode.h | 2 +- libs/wxutil/preview/ModelPreview.cpp | 4 ++-- libs/wxutil/preview/ParticlePreview.cpp | 2 +- .../dm.conversation/ConversationDialog.cpp | 2 +- .../DifficultySettingsManager.cpp | 2 +- plugins/dm.objectives/ObjectivesEditor.cpp | 2 +- plugins/script/interfaces/EntityInterface.cpp | 4 ++-- radiant/Makefile.am | 2 +- .../{EntityCreator.cpp => EntityModule.cpp} | 22 +++++++++---------- .../{EntityCreator.h => EntityModule.h} | 8 +++---- radiant/map/Map.cpp | 2 +- radiant/map/RegionManager.cpp | 2 +- radiant/map/RootNode.cpp | 2 +- radiant/map/format/Doom3MapReader.cpp | 2 +- radiant/map/format/Quake3MapReader.cpp | 2 +- .../map/format/portable/PortableMapReader.cpp | 2 +- radiant/selection/algorithm/Curves.cpp | 2 +- radiant/selection/algorithm/Entity.cpp | 2 +- .../animationpreview/AnimationPreview.cpp | 2 +- tools/msvc/DarkRadiant.vcxproj | 4 ++-- tools/msvc/DarkRadiant.vcxproj.filters | 12 +++++----- 23 files changed, 50 insertions(+), 52 deletions(-) rename radiant/entity/{EntityCreator.cpp => EntityModule.cpp} (82%) rename radiant/entity/{EntityCreator.h => EntityModule.h} (75%) diff --git a/include/ientity.h b/include/ientity.h index dd6f8806b7..33319074ca 100644 --- a/include/ientity.h +++ b/include/ientity.h @@ -317,17 +317,17 @@ class ITargetManager }; typedef std::shared_ptr ITargetManagerPtr; -const char* const MODULE_ENTITYCREATOR("Doom3EntityCreator"); +const char* const MODULE_ENTITY("EntityModule"); /** * \brief - * Interface for the entity creator module. + * Interface for the entity module. */ -class EntityCreator : +class IEntityModule : public RegisterableModule { public: - virtual ~EntityCreator() {} + virtual ~IEntityModule() {} /// Create an entity node with the given entity class. virtual IEntityNodePtr createEntity(const IEntityClassPtr& eclass) = 0; @@ -336,12 +336,12 @@ class EntityCreator : virtual ITargetManagerPtr createTargetManager() = 0; }; -inline EntityCreator& GlobalEntityCreator() +inline IEntityModule& GlobalEntityModule() { // Cache the reference locally - static EntityCreator& _entityCreator( - *std::static_pointer_cast( - module::GlobalModuleRegistry().getModule(MODULE_ENTITYCREATOR) + static IEntityModule& _entityCreator( + *std::static_pointer_cast( + module::GlobalModuleRegistry().getModule(MODULE_ENTITY) ) ); return _entityCreator; diff --git a/libs/entitylib.h b/libs/entitylib.h index 45a31b5c46..e84a6ec18a 100644 --- a/libs/entitylib.h +++ b/libs/entitylib.h @@ -436,7 +436,7 @@ inline scene::INodePtr changeEntityClassname(const scene::INodePtr& node, assert(eclass); // Create a new entity with the given class - IEntityNodePtr newNode(GlobalEntityCreator().createEntity(eclass)); + IEntityNodePtr newNode(GlobalEntityModule().createEntity(eclass)); Entity* oldEntity = Node_getEntity(oldNode); diff --git a/libs/scene/BasicRootNode.h b/libs/scene/BasicRootNode.h index a37ceca843..0eecaa7c45 100644 --- a/libs/scene/BasicRootNode.h +++ b/libs/scene/BasicRootNode.h @@ -34,7 +34,7 @@ class BasicRootNode : BasicRootNode() { _namespace = GlobalNamespaceFactory().createNamespace(); - _targetManager = GlobalEntityCreator().createTargetManager(); + _targetManager = GlobalEntityModule().createTargetManager(); _selectionGroupManager = GlobalSelectionGroupModule().createSelectionGroupManager(); _selectionSetManager = GlobalSelectionSetModule().createSelectionSetManager(); _layerManager = GlobalLayerModule().createLayerManager(); diff --git a/libs/wxutil/preview/ModelPreview.cpp b/libs/wxutil/preview/ModelPreview.cpp index d09a4e6c44..22c2d8b71c 100644 --- a/libs/wxutil/preview/ModelPreview.cpp +++ b/libs/wxutil/preview/ModelPreview.cpp @@ -90,7 +90,7 @@ void ModelPreview::setupSceneGraph() { _rootNode = std::make_shared(); - _entity = GlobalEntityCreator().createEntity( + _entity = GlobalEntityModule().createEntity( GlobalEntityClassManager().findClass(FUNC_STATIC_CLASS)); _rootNode->addChildNode(_entity); @@ -101,7 +101,7 @@ void ModelPreview::setupSceneGraph() getScene()->setRoot(_rootNode); // Set up the light - _light = GlobalEntityCreator().createEntity( + _light = GlobalEntityModule().createEntity( GlobalEntityClassManager().findClass("light")); Node_getEntity(_light)->setKeyValue("light_radius", "600 600 600"); diff --git a/libs/wxutil/preview/ParticlePreview.cpp b/libs/wxutil/preview/ParticlePreview.cpp index 40b82426c5..27e4f0c768 100644 --- a/libs/wxutil/preview/ParticlePreview.cpp +++ b/libs/wxutil/preview/ParticlePreview.cpp @@ -167,7 +167,7 @@ void ParticlePreview::setupSceneGraph() { _rootNode = std::make_shared(); - _entity = GlobalEntityCreator().createEntity( + _entity = GlobalEntityModule().createEntity( GlobalEntityClassManager().findClass(FUNC_EMITTER_CLASS)); _rootNode->addChildNode(_entity); diff --git a/plugins/dm.conversation/ConversationDialog.cpp b/plugins/dm.conversation/ConversationDialog.cpp index 2559170e56..311e26f522 100644 --- a/plugins/dm.conversation/ConversationDialog.cpp +++ b/plugins/dm.conversation/ConversationDialog.cpp @@ -277,7 +277,7 @@ void ConversationDialog::onAddEntity(wxCommandEvent& ev) if (eclass) { // Construct a Node of this entity type - IEntityNodePtr node(GlobalEntityCreator().createEntity(eclass)); + IEntityNodePtr node(GlobalEntityModule().createEntity(eclass)); // Create a random offset node->getEntity().setKeyValue( diff --git a/plugins/dm.difficulty/DifficultySettingsManager.cpp b/plugins/dm.difficulty/DifficultySettingsManager.cpp index fa07f1cf97..440250a132 100644 --- a/plugins/dm.difficulty/DifficultySettingsManager.cpp +++ b/plugins/dm.difficulty/DifficultySettingsManager.cpp @@ -212,7 +212,7 @@ void DifficultySettingsManager::saveSettings() } // Create and insert a new entity node into the scenegraph root - IEntityNodePtr entNode = GlobalEntityCreator().createEntity(diffEclass); + IEntityNodePtr entNode = GlobalEntityModule().createEntity(diffEclass); GlobalSceneGraph().root()->addChildNode(entNode); // Add the entity to the list diff --git a/plugins/dm.objectives/ObjectivesEditor.cpp b/plugins/dm.objectives/ObjectivesEditor.cpp index 8dbf8f2c50..8896a932ba 100644 --- a/plugins/dm.objectives/ObjectivesEditor.cpp +++ b/plugins/dm.objectives/ObjectivesEditor.cpp @@ -447,7 +447,7 @@ void ObjectivesEditor::_onAddEntity(wxCommandEvent& ev) if (eclass) { // Construct a Node of this entity type - IEntityNodePtr node(GlobalEntityCreator().createEntity(eclass)); + IEntityNodePtr node(GlobalEntityModule().createEntity(eclass)); // Create a random offset node->getEntity().setKeyValue("origin", RandomOrigin::generate(128)); diff --git a/plugins/script/interfaces/EntityInterface.cpp b/plugins/script/interfaces/EntityInterface.cpp index 109616b75c..5ee3f3d92b 100644 --- a/plugins/script/interfaces/EntityInterface.cpp +++ b/plugins/script/interfaces/EntityInterface.cpp @@ -91,7 +91,7 @@ ScriptEntityNode ScriptEntityNode::getEntity(const ScriptSceneNode& node) { // Creates a new entity for the given entityclass ScriptSceneNode EntityInterface::createEntity(const ScriptEntityClass& eclass) { - scene::INodePtr node = GlobalEntityCreator().createEntity(eclass); + scene::INodePtr node = GlobalEntityModule().createEntity(eclass); // Add the node to the buffer otherwise it will be deleted immediately, // as ScriptSceneNodes are using weak_ptrs. @@ -110,7 +110,7 @@ ScriptSceneNode EntityInterface::createEntity(const std::string& eclassName) { return ScriptSceneNode(scene::INodePtr()); } - scene::INodePtr node = GlobalEntityCreator().createEntity(eclass); + scene::INodePtr node = GlobalEntityModule().createEntity(eclass); // Add the node to the buffer otherwise it will be deleted immediately, // as ScriptSceneNodes are using weak_ptrs. diff --git a/radiant/Makefile.am b/radiant/Makefile.am index 60c9dc6c9f..0961f335d1 100644 --- a/radiant/Makefile.am +++ b/radiant/Makefile.am @@ -93,7 +93,7 @@ darkradiant_SOURCES = main.cpp \ entity/curve/CurveEditInstance.cpp \ entity/curve/CurveNURBS.cpp \ entity/AngleKey.cpp \ - entity/EntityCreator.cpp \ + entity/EntityModule.cpp \ eventmanager/Accelerator.cpp \ eventmanager/EventManager.cpp \ eventmanager/GlobalKeyEventFilter.cpp \ diff --git a/radiant/entity/EntityCreator.cpp b/radiant/entity/EntityModule.cpp similarity index 82% rename from radiant/entity/EntityCreator.cpp rename to radiant/entity/EntityModule.cpp index 28c0a07365..e0987acb57 100644 --- a/radiant/entity/EntityCreator.cpp +++ b/radiant/entity/EntityModule.cpp @@ -1,4 +1,4 @@ -#include "EntityCreator.h" +#include "EntityModule.h" #include "EntitySettings.h" #include "itextstream.h" @@ -70,7 +70,7 @@ IEntityNodePtr createNodeForEntity(const IEntityClassPtr& eclass) return node; } -IEntityNodePtr Doom3EntityCreator::createEntity(const IEntityClassPtr& eclass) +IEntityNodePtr Doom3EntityModule::createEntity(const IEntityClassPtr& eclass) { IEntityNodePtr node = createNodeForEntity(eclass); @@ -102,19 +102,19 @@ IEntityNodePtr Doom3EntityCreator::createEntity(const IEntityClassPtr& eclass) return node; } -ITargetManagerPtr Doom3EntityCreator::createTargetManager() +ITargetManagerPtr Doom3EntityModule::createTargetManager() { return std::make_shared(); } // RegisterableModule implementation -const std::string& Doom3EntityCreator::getName() const +const std::string& Doom3EntityModule::getName() const { - static std::string _name(MODULE_ENTITYCREATOR); + static std::string _name(MODULE_ENTITY); return _name; } -const StringSet& Doom3EntityCreator::getDependencies() const +const StringSet& Doom3EntityModule::getDependencies() const { static StringSet _dependencies; @@ -128,9 +128,9 @@ const StringSet& Doom3EntityCreator::getDependencies() const return _dependencies; } -void Doom3EntityCreator::initialiseModule(const ApplicationContext& ctx) +void Doom3EntityModule::initialiseModule(const ApplicationContext& ctx) { - rMessage() << "Doom3EntityCreator::initialiseModule called." << std::endl; + rMessage() << getName() << "::initialiseModule called." << std::endl; LightShader::m_defaultShader = game::current::getValue("/defaults/lightShader"); @@ -139,15 +139,15 @@ void Doom3EntityCreator::initialiseModule(const ApplicationContext& ctx) GlobalEventManager().addRegistryToggle("ToggleDragResizeEntitiesSymmetrically", RKEY_DRAG_RESIZE_SYMMETRICALLY); } -void Doom3EntityCreator::shutdownModule() +void Doom3EntityModule::shutdownModule() { - rMessage() << "Doom3EntityCreator::shutdownModule called." << std::endl; + rMessage() << getName() << "::shutdownModule called." << std::endl; // Destroy the settings instance EntitySettings::destroy(); } // Static module instance -module::StaticModule entityCreatorModule; +module::StaticModule entityModule; } // namespace entity diff --git a/radiant/entity/EntityCreator.h b/radiant/entity/EntityModule.h similarity index 75% rename from radiant/entity/EntityCreator.h rename to radiant/entity/EntityModule.h index f94b97af01..02a53e0858 100644 --- a/radiant/entity/EntityCreator.h +++ b/radiant/entity/EntityModule.h @@ -6,12 +6,11 @@ namespace entity { -/// Implementation of the EntityCreator interface for Doom 3 -class Doom3EntityCreator : - public EntityCreator +/// Implementation of the IEntityModule interface for Doom 3 +class Doom3EntityModule : + public IEntityModule { public: - // EntityCreator implementation IEntityNodePtr createEntity(const IEntityClassPtr& eclass) override; ITargetManagerPtr createTargetManager() override; @@ -22,6 +21,5 @@ class Doom3EntityCreator : virtual void initialiseModule(const ApplicationContext& ctx) override; virtual void shutdownModule() override; }; -typedef std::shared_ptr Doom3EntityCreatorPtr; } // namespace entity diff --git a/radiant/map/Map.cpp b/radiant/map/Map.cpp index b7433283fc..1186f9fd20 100644 --- a/radiant/map/Map.cpp +++ b/radiant/map/Map.cpp @@ -255,7 +255,7 @@ scene::INodePtr Map::findWorldspawn() scene::INodePtr Map::createWorldspawn() { - scene::INodePtr worldspawn(GlobalEntityCreator().createEntity( + scene::INodePtr worldspawn(GlobalEntityModule().createEntity( GlobalEntityClassManager().findOrInsert("worldspawn", true))); // We want the world spawn entity to go for the pole position diff --git a/radiant/map/RegionManager.cpp b/radiant/map/RegionManager.cpp index 060a76cd95..39eda3a82a 100644 --- a/radiant/map/RegionManager.cpp +++ b/radiant/map/RegionManager.cpp @@ -152,7 +152,7 @@ void RegionManager::addRegionBrushes() IEntityClassPtr playerStart = GlobalEntityClassManager().findOrInsert(eClassPlayerStart, false); // Create the info_player_start entity - _playerStart = GlobalEntityCreator().createEntity(playerStart); + _playerStart = GlobalEntityModule().createEntity(playerStart); ui::CamWndPtr camWnd = GlobalCamera().getActiveCamWnd(); diff --git a/radiant/map/RootNode.cpp b/radiant/map/RootNode.cpp index 91d5708ed2..5f5172722a 100644 --- a/radiant/map/RootNode.cpp +++ b/radiant/map/RootNode.cpp @@ -17,7 +17,7 @@ RootNode::RootNode(const std::string& name) : _namespace = GlobalNamespaceFactory().createNamespace(); assert(_namespace); - _targetManager = GlobalEntityCreator().createTargetManager(); + _targetManager = GlobalEntityModule().createTargetManager(); assert(_targetManager); _selectionGroupManager = GlobalSelectionGroupModule().createSelectionGroupManager(); diff --git a/radiant/map/format/Doom3MapReader.cpp b/radiant/map/format/Doom3MapReader.cpp index 4a58062544..1d33cd5e90 100644 --- a/radiant/map/format/Doom3MapReader.cpp +++ b/radiant/map/format/Doom3MapReader.cpp @@ -179,7 +179,7 @@ scene::INodePtr Doom3MapReader::createEntity(const EntityKeyValues& keyValues) } // Create the actual entity node - IEntityNodePtr node(GlobalEntityCreator().createEntity(classPtr)); + IEntityNodePtr node(GlobalEntityModule().createEntity(classPtr)); for (EntityKeyValues::const_iterator i = keyValues.begin(); i != keyValues.end(); diff --git a/radiant/map/format/Quake3MapReader.cpp b/radiant/map/format/Quake3MapReader.cpp index b51b236d37..6336856829 100644 --- a/radiant/map/format/Quake3MapReader.cpp +++ b/radiant/map/format/Quake3MapReader.cpp @@ -137,7 +137,7 @@ scene::INodePtr Quake3MapReader::createEntity(const EntityKeyValues& keyValues) } // Create the actual entity node - IEntityNodePtr node(GlobalEntityCreator().createEntity(classPtr)); + IEntityNodePtr node(GlobalEntityModule().createEntity(classPtr)); for (EntityKeyValues::const_iterator i = keyValues.begin(); i != keyValues.end(); diff --git a/radiant/map/format/portable/PortableMapReader.cpp b/radiant/map/format/portable/PortableMapReader.cpp index 9458c143ae..39b8d5a636 100644 --- a/radiant/map/format/portable/PortableMapReader.cpp +++ b/radiant/map/format/portable/PortableMapReader.cpp @@ -375,7 +375,7 @@ void PortableMapReader::readEntity(const xml::Node& entityTag) } // Create the actual entity node - auto entityNode = GlobalEntityCreator().createEntity(eclass); + auto entityNode = GlobalEntityModule().createEntity(eclass); for (const auto& pair : entityKeyValues) { diff --git a/radiant/selection/algorithm/Curves.cpp b/radiant/selection/algorithm/Curves.cpp index bf4f6e25ff..3de8772594 100644 --- a/radiant/selection/algorithm/Curves.cpp +++ b/radiant/selection/algorithm/Curves.cpp @@ -54,7 +54,7 @@ void createCurve(const std::string& key) ); // Create a new entity node deriving from this entityclass - IEntityNodePtr curve(GlobalEntityCreator().createEntity(entityClass)); + IEntityNodePtr curve(GlobalEntityModule().createEntity(entityClass)); // Insert this new node into the scenegraph root GlobalSceneGraph().root()->addChildNode(curve); diff --git a/radiant/selection/algorithm/Entity.cpp b/radiant/selection/algorithm/Entity.cpp index 603d9e6bd6..cab41dd871 100644 --- a/radiant/selection/algorithm/Entity.cpp +++ b/radiant/selection/algorithm/Entity.cpp @@ -275,7 +275,7 @@ scene::INodePtr createEntityFromSelection(const std::string& name, const Vector3 AABB workzone = GlobalSelectionSystem().getWorkZone().bounds; // Create the new node for the entity - IEntityNodePtr node(GlobalEntityCreator().createEntity(entityClass)); + IEntityNodePtr node(GlobalEntityModule().createEntity(entityClass)); GlobalSceneGraph().root()->addChildNode(node); diff --git a/radiant/uimanager/animationpreview/AnimationPreview.cpp b/radiant/uimanager/animationpreview/AnimationPreview.cpp index a5947287e2..4bfe9c3f80 100644 --- a/radiant/uimanager/animationpreview/AnimationPreview.cpp +++ b/radiant/uimanager/animationpreview/AnimationPreview.cpp @@ -152,7 +152,7 @@ void AnimationPreview::setupSceneGraph() _root = std::make_shared(); - _entity = GlobalEntityCreator().createEntity( + _entity = GlobalEntityModule().createEntity( GlobalEntityClassManager().findClass(FUNC_STATIC_CLASS) ); diff --git a/tools/msvc/DarkRadiant.vcxproj b/tools/msvc/DarkRadiant.vcxproj index 4f2808b18b..8c5d949900 100644 --- a/tools/msvc/DarkRadiant.vcxproj +++ b/tools/msvc/DarkRadiant.vcxproj @@ -205,7 +205,7 @@ - + @@ -976,7 +976,7 @@ - + diff --git a/tools/msvc/DarkRadiant.vcxproj.filters b/tools/msvc/DarkRadiant.vcxproj.filters index d22d501066..483465896b 100644 --- a/tools/msvc/DarkRadiant.vcxproj.filters +++ b/tools/msvc/DarkRadiant.vcxproj.filters @@ -967,9 +967,6 @@ src\entity - - src\entity - src\entity @@ -1363,6 +1360,9 @@ src\render + + src\entity + @@ -2262,9 +2262,6 @@ src\entity - - src\entity - src\entity @@ -2697,6 +2694,9 @@ src\render + + src\entity +