diff --git a/src/entities/EntitiesManager.cpp b/src/entities/EntitiesManager.cpp index c13abace..8e3d08fe 100644 --- a/src/entities/EntitiesManager.cpp +++ b/src/entities/EntitiesManager.cpp @@ -109,6 +109,25 @@ Entity* EntitiesManager::CreateMesh(const QString& mesh) { SceneComponent* conponent = ComponentFactory::Create("MeshComponent", nullptr); conponent->SetAttribute("mesh", mesh.toStdString().c_str()); conponent->AttachEntity(entity); + // Also add PathComponent so the entity has a path attribute by default + SceneComponent* rootComponent = entity->GetRootComponent(); + if (rootComponent) { + SceneComponent* pathComponent = ComponentFactory::Create("PathComponent", rootComponent); + if (pathComponent) { + pathComponent->AttachTo(rootComponent); + LOG_INFO("EntitiesManager::CreateMesh - Added PathComponent"); + } else { + LOG_WARN("EntitiesManager::CreateMesh - Failed to create PathComponent"); + } + } else { + SceneComponent* pathComponent = ComponentFactory::Create("PathComponent", nullptr); + if (pathComponent) { + pathComponent->AttachEntity(entity); + LOG_INFO("EntitiesManager::CreateMesh - Added PathComponent with no root"); + } else { + LOG_WARN("EntitiesManager::CreateMesh - Failed to create PathComponent with no root"); + } + } return entity; } diff --git a/src/entities/EntityFactory.cpp b/src/entities/EntityFactory.cpp index 9a46e28a..7da7a48e 100644 --- a/src/entities/EntityFactory.cpp +++ b/src/entities/EntityFactory.cpp @@ -66,6 +66,28 @@ Entity* EntityFactory::CreateEntityWithComponents(const QString& type, const QSt } } + // Always add PathComponent so entity has path attribute editable in PropertyBrowser + { + SceneComponent* rootComponent = entity->GetRootComponent(); + if (nullptr == rootComponent) { + SceneComponent* pathComponent = ComponentFactory::Create("PathComponent", nullptr); + if (pathComponent) { + pathComponent->AttachEntity(entity); + LOG_INFO("EntityFactory::CreateEntityWithComponents - Added PathComponent"); + } else { + LOG_WARN("EntityFactory::CreateEntityWithComponents - Failed to create PathComponent"); + } + } else { + SceneComponent* pathComponent = ComponentFactory::Create("PathComponent", rootComponent); + if (pathComponent) { + pathComponent->AttachTo(rootComponent); + LOG_INFO("EntityFactory::CreateEntityWithComponents - Added PathComponent"); + } else { + LOG_WARN("EntityFactory::CreateEntityWithComponents - Failed to create PathComponent"); + } + } + } + // Add required components QStringList requiredComponents = it->second->GetRequiredComponents(); SceneComponent* rootComponent = entity->GetRootComponent(); diff --git a/src/ui/PropertyBrowser/qtpropertymanager.cpp b/src/ui/PropertyBrowser/qtpropertymanager.cpp index 5bc2a0cf..bf99e9fd 100644 --- a/src/ui/PropertyBrowser/qtpropertymanager.cpp +++ b/src/ui/PropertyBrowser/qtpropertymanager.cpp @@ -9308,7 +9308,7 @@ void QtMeshComponetManager::SetPropertyValue(QtProperty* property, SceneComponen } QString QtMeshComponetManager::GetPropertyId() const { - return tr("MeshComponent"); + return QStringLiteral("MeshComponent"); } /*! @@ -9467,9 +9467,8 @@ void QtPathComponentManager::SetPropertyValue(QtProperty* property, SceneCompone } QString QtPathComponentManager::GetPropertyId() const { - return tr("PathComponent"); + return QStringLiteral("PathComponent"); } - /*! Returns the given \a property's value. @@ -9732,7 +9731,7 @@ void QtConeWaveComponentManager::SetPropertyValue(QtProperty* property, SceneCom } QString QtConeWaveComponentManager::GetPropertyId() const { - return tr("ConeWaveComponent"); + return QStringLiteral("ConeWaveComponent"); } /*! @@ -10073,7 +10072,7 @@ void QtDashedLineComponentManager::SetPropertyValue(QtProperty* property, SceneC } QString QtDashedLineComponentManager::GetPropertyId() const { - return tr("DashedLineComponent"); + return QStringLiteral("DashedLineComponent"); } QDashedLineComponentAttribute QtDashedLineComponentManager::value(const QtProperty* property) const {