diff --git a/engine/includes/editor/assetconverter.h b/engine/includes/editor/assetconverter.h index 42cfb9ea1..ccb8a4c13 100644 --- a/engine/includes/editor/assetconverter.h +++ b/engine/includes/editor/assetconverter.h @@ -93,7 +93,7 @@ class ENGINE_EXPORT AssetConverterSettings : public Object { void setCurrentVersion(uint32_t version); const StringList subKeys() const; - TString subItem(const TString &key) const; + TString subItem(const TString &key, bool create = false) const; virtual Variant subItemData(const TString &key) const; TString subTypeName(const TString &key) const; int32_t subType(const TString &key) const; @@ -103,8 +103,8 @@ class ENGINE_EXPORT AssetConverterSettings : public Object { void setSubItem(const TString &name, const TString &uuid, const TString &type); virtual void setSubItemData(const TString &name, const Variant &data); - AssetConverter::ReturnCode saveBinary(const Variant &data); - TString saveSubData(const Variant &data, const TString &path, const TString &type); + AssetConverter::ReturnCode saveBinary(const Variant &data, const TString &path); + AssetConverter::ReturnCode saveSubData(Resource *resource, const TString &name, const TString &type); bool loadSettings(); void saveSettings(); diff --git a/engine/includes/editor/converters/assimpconverter.h b/engine/includes/editor/converters/assimpconverter.h index 7ece42682..0166e63d7 100644 --- a/engine/includes/editor/converters/assimpconverter.h +++ b/engine/includes/editor/converters/assimpconverter.h @@ -73,8 +73,6 @@ class AssimpImportSettings : public AssetConverterSettings { Object::ObjectList m_renders; - StringList m_resources; - BonesList m_bones; MeshMap m_meshes; diff --git a/engine/includes/editor/viewport/tasks/gizmorender.h b/engine/includes/editor/viewport/tasks/gizmorender.h index 69a0d9912..b2cf96727 100644 --- a/engine/includes/editor/viewport/tasks/gizmorender.h +++ b/engine/includes/editor/viewport/tasks/gizmorender.h @@ -55,7 +55,7 @@ class GizmoRender : public PipelineTask { m_solidCube->setColors(Vector4Vector(m_solidCube->vertices().size(), Vector4(0.0f, 0.46f, 0.74f, 0.25f))); } - Actor *cameraActor = Engine::composeActor("Camera", "Camera"); + Actor *cameraActor = Engine::composeActor("Camera"); m_camera = cameraActor->getComponent(); m_camera->setFar(4.0f); m_camera->setNear(0.1f); diff --git a/engine/includes/engine.h b/engine/includes/engine.h index 0fa646561..3cf44df0a 100644 --- a/engine/includes/engine.h +++ b/engine/includes/engine.h @@ -107,12 +107,15 @@ class ENGINE_EXPORT Engine : public ObjectSystem { static TString organizationName(); - static void setResource(Object *object, const TString &uuid); - static bool setPlatformAdaptor(PlatformAdaptor *platform); static Actor *composeActor(const TString &component, const TString &name, Object *parent = nullptr); + template + static Actor *composeActor(const TString &name, Object *parent = nullptr) { + return composeActor(T::metaClass()->name(), name, parent); + } + Object::ObjectList getAllObjectsByType(const TString &type) const override; void addNativeBehaviour(NativeBehaviour *native); diff --git a/engine/src/editor/assetconverter.cpp b/engine/src/editor/assetconverter.cpp index 3e2cb6d52..3d142a82c 100644 --- a/engine/src/editor/assetconverter.cpp +++ b/engine/src/editor/assetconverter.cpp @@ -301,11 +301,14 @@ const StringList AssetConverterSettings::subKeys() const { /*! Returns UUID of a sub-item by \a key. */ -TString AssetConverterSettings::subItem(const TString &key) const { +TString AssetConverterSettings::subItem(const TString &key, bool create) const { auto it = m_subItems.find(key); if(it != m_subItems.end()) { return it->second.uuid; } + if(create) { + return QUuid::createUuid().toString().toStdString(); + } return TString(); } /*! @@ -357,8 +360,8 @@ void AssetConverterSettings::setSubItemData(const TString &name, const Variant & Q_UNUSED(data) } -AssetConverter::ReturnCode AssetConverterSettings::saveBinary(const Variant &data) { - File file(absoluteDestination()); +AssetConverter::ReturnCode AssetConverterSettings::saveBinary(const Variant &data, const TString &path) { + File file(path); if(file.open(File::WriteOnly)) { std::set types; for(auto &it : data.toList()) { @@ -376,25 +379,20 @@ AssetConverter::ReturnCode AssetConverterSettings::saveBinary(const Variant &dat return AssetConverter::InternalError; } /*! - Saves binary \a data as a sub-item with given destination \a path and asset \a type. - This method generated UUID id needed and registers a new sub-item. + Saves binary data of \a resource as a sub-item with given destination \a name and asset \a type. \sa AssetConverterSettings::setSubItem() */ -TString AssetConverterSettings::saveSubData(const Variant &data, const TString &path, const TString &type) { - TString uuid(subItem(path)); - if(uuid.isEmpty()) { - uuid = QUuid::createUuid().toString().toStdString(); - } +AssetConverter::ReturnCode AssetConverterSettings::saveSubData(Resource *resource, const TString &name, const TString &type) { + TString uuid(subItem(name)); Url dst(absoluteDestination()); - File file(dst.absoluteDir() + "/" + uuid); - if(file.open(File::WriteOnly)) { - file.write(Bson::save(data)); - file.close(); - setSubItem(path, uuid, type); + AssetConverter::ReturnCode result = saveBinary(Engine::toVariant(resource), dst.absoluteDir() + "/" + uuid); + if(result == AssetConverter::Success) { + setSubItem(name, uuid, type); } - return uuid; + + return result; } /*! Loads settings from metadata file ([source].set) diff --git a/engine/src/editor/converters/animconverter.cpp b/engine/src/editor/converters/animconverter.cpp index 4152d582d..4cd11f206 100644 --- a/engine/src/editor/converters/animconverter.cpp +++ b/engine/src/editor/converters/animconverter.cpp @@ -30,7 +30,7 @@ AssetConverter::ReturnCode AnimConverter::convertFile(AssetConverterSettings *se if(src.open(File::ReadOnly)) { AnimationClip *clip = Engine::loadResource(settings->destination()); if(clip == nullptr) { - clip = Engine::objectCreate(); + clip = Engine::objectCreate(settings->destination()); } VariantMap map; @@ -38,7 +38,7 @@ AssetConverter::ReturnCode AnimConverter::convertFile(AssetConverterSettings *se clip->loadUserData(map); src.close(); - return settings->saveBinary(Engine::toVariant(clip)); + return settings->saveBinary(Engine::toVariant(clip), settings->absoluteDestination()); } return InternalError; diff --git a/engine/src/editor/converters/assimpconverter.cpp b/engine/src/editor/converters/assimpconverter.cpp index aa2b63b6e..3c5f3d73f 100644 --- a/engine/src/editor/converters/assimpconverter.cpp +++ b/engine/src/editor/converters/assimpconverter.cpp @@ -196,8 +196,8 @@ Actor *AssimpConverter::createActor(const AssetConverterSettings *settings, cons if(dynamic_cast(resource) != nullptr) { return static_cast(static_cast(resource)->actor()->clone()); } else if(dynamic_cast(resource) != nullptr) { - Actor *object = Engine::composeActor("MeshRender", ""); - MeshRender *render = static_cast(object->component("MeshRender")); + Actor *object = Engine::composeActor(""); + MeshRender *render = object->getComponent(); if(render) { render->setMesh(static_cast(resource)); } @@ -210,7 +210,6 @@ AssetConverter::ReturnCode AssimpConverter::convertFile(AssetConverterSettings * AssimpImportSettings *fbxSettings = static_cast(settings); fbxSettings->m_renders.clear(); - fbxSettings->m_resources.clear(); fbxSettings->m_bones.clear(); fbxSettings->m_actors.clear(); fbxSettings->m_meshes.clear(); @@ -247,8 +246,16 @@ AssetConverter::ReturnCode AssimpConverter::convertFile(AssetConverterSettings * } } + Prefab *prefab = Engine::loadResource(settings->destination()); + if(prefab == nullptr) { + prefab = Engine::objectCreate(settings->destination()); + } + + /// \todo We need to reuse actors if possible Actor *root = importObject(scene, scene->mRootNode, nullptr, fbxSettings); + prefab->setActor(root); + if(!fbxSettings->m_bones.empty()) { importPose(fbxSettings); } else { @@ -266,12 +273,12 @@ AssetConverter::ReturnCode AssimpConverter::convertFile(AssetConverterSettings * aiReleaseImport(scene); + TString name(root->name()); + root->setName(settings->destination()); // fixes the same name of root in the different files issue stabilizeUUID(root); + root->setName(name); - Prefab *prefab = Engine::objectCreate(""); - prefab->setActor(root); - - return settings->saveBinary(Engine::toVariant(prefab)); + return settings->saveBinary(Engine::toVariant(prefab), settings->absoluteDestination()); } return InternalError; } @@ -374,7 +381,11 @@ Mesh *AssimpConverter::importMesh(const aiScene *scene, const aiNode *element, A const aiMesh *item = scene->mMeshes[element->mMeshes[index]]; if(mesh == nullptr) { - mesh = Engine::objectCreate(item->mName.C_Str()); + TString uuid = fbxSettings->subItem(actor->name(), true); + mesh = Engine::loadResource(uuid); + if(mesh == nullptr) { + mesh = Engine::objectCreate(uuid); + } } count_v += item->mNumVertices; @@ -509,18 +520,10 @@ Mesh *AssimpConverter::importMesh(const aiScene *scene, const aiNode *element, A total_i += indexCount; } - TString uuid = fbxSettings->saveSubData(Engine::toVariant(mesh), actor->name(), MetaType::name()); + fbxSettings->saveSubData(mesh, actor->name(), MetaType::name()); + fbxSettings->m_meshes[hash] = mesh; - Mesh *resource = Engine::loadResource(uuid); - if(resource == nullptr) { - Engine::setResource(mesh, uuid); - fbxSettings->m_resources.push_back(uuid); - resource = mesh; - } - - fbxSettings->m_meshes[hash] = resource; - - return resource; + return mesh; } return nullptr; } @@ -614,7 +617,11 @@ void AssimpConverter::importAnimation(const aiScene *scene, AssimpImportSettings for(uint32_t a = 0; a < scene->mNumAnimations; a++) { aiAnimation *animation = scene->mAnimations[a]; - AnimationClip clip; + TString uuid = fbxSettings->subItem(animation->mName.C_Str(), true); + AnimationClip *clip = Engine::loadResource(uuid); + if(clip == nullptr) { + clip = Engine::objectCreate(uuid); + } double animRate = (animation->mTicksPerSecond > 0) ? animation->mTicksPerSecond : 1; @@ -660,7 +667,7 @@ void AssimpConverter::importAnimation(const aiScene *scene, AssimpImportSettings optimizeVectorTrack(track, fbxSettings->positionError()); } - clip.m_tracks.push_back(track); + clip->m_tracks.push_back(track); } if(channel->mNumRotationKeys > 1) { @@ -692,7 +699,7 @@ void AssimpConverter::importAnimation(const aiScene *scene, AssimpImportSettings optimizeQuaternionTrack(track, fbxSettings->rotationError()); } - clip.m_tracks.push_back(track); + clip->m_tracks.push_back(track); } if(channel->mNumScalingKeys > 1) { @@ -724,19 +731,23 @@ void AssimpConverter::importAnimation(const aiScene *scene, AssimpImportSettings optimizeVectorTrack(track, fbxSettings->scaleError()); } - clip.m_tracks.push_back(track); + clip->m_tracks.push_back(track); } } } - clip.m_tracks.sort(compare); + clip->m_tracks.sort(compare); - fbxSettings->saveSubData(Engine::toVariant(&clip), animation->mName.C_Str(), MetaType::name()); + fbxSettings->saveSubData(clip, animation->mName.C_Str(), MetaType::name()); } } void AssimpConverter::importPose(AssimpImportSettings *fbxSettings) { - Pose *pose = new Pose; + TString uuid = fbxSettings->subItem("Pose", true); + Pose *pose = Engine::loadResource(uuid); + if(pose == nullptr) { + pose = Engine::objectCreate(uuid); + } for(auto it : fbxSettings->m_bones) { aiVector3D scl, rot, pos; @@ -755,20 +766,11 @@ void AssimpConverter::importPose(AssimpImportSettings *fbxSettings) { pose->addBone(&b); } - TString uuid = fbxSettings->saveSubData(Engine::toVariant(pose), "Pose", MetaType::name()); - - Pose *resource = Engine::loadResource(uuid); - if(resource == nullptr) { - Engine::setResource(pose, uuid); - fbxSettings->m_resources.push_back(uuid); - resource = pose; - } - - fbxSettings->m_resources.push_back(uuid); + fbxSettings->saveSubData(pose, "Pose", MetaType::name()); if(fbxSettings->m_rootBone) { Armature *armature = static_cast(fbxSettings->m_rootBone->addComponent("Armature")); - armature->setBindPose(resource); + armature->setBindPose(pose); for(auto r : fbxSettings->m_renders) { SkinnedMeshRender *render = static_cast(r); diff --git a/engine/src/editor/converters/controlschemeconverter.cpp b/engine/src/editor/converters/controlschemeconverter.cpp index 6e2b60937..ccd5a0bc1 100644 --- a/engine/src/editor/converters/controlschemeconverter.cpp +++ b/engine/src/editor/converters/controlschemeconverter.cpp @@ -22,7 +22,7 @@ AssetConverter::ReturnCode ControlSchemeConverter::convertFile(AssetConverterSet if(src.open(File::ReadOnly)) { ControlScheme *scheme = Engine::loadResource(settings->destination()); if(scheme == nullptr) { - scheme = Engine::objectCreate(); + scheme = Engine::objectCreate(settings->destination()); } VariantMap map; @@ -31,7 +31,7 @@ AssetConverter::ReturnCode ControlSchemeConverter::convertFile(AssetConverterSet src.close(); - return settings->saveBinary(Engine::toVariant(scheme)); + return settings->saveBinary(Engine::toVariant(scheme), settings->absoluteDestination()); } return InternalError; } diff --git a/engine/src/editor/converters/fontconverter.cpp b/engine/src/editor/converters/fontconverter.cpp index 0f2c1f1b8..cce1a36e5 100644 --- a/engine/src/editor/converters/fontconverter.cpp +++ b/engine/src/editor/converters/fontconverter.cpp @@ -25,7 +25,7 @@ AssetConverter::ReturnCode FontConverter::convertFile(AssetConverterSettings *se if(src.open(File::ReadOnly)) { Font *font = Engine::loadResource(settings->destination()); if(font == nullptr) { - font = Engine::objectCreate(); + font = Engine::objectCreate(settings->destination()); } VariantMap map; @@ -34,7 +34,7 @@ AssetConverter::ReturnCode FontConverter::convertFile(AssetConverterSettings *se font->loadUserData(map); - return settings->saveBinary(Engine::toVariant(font)); + return settings->saveBinary(Engine::toVariant(font), settings->absoluteDestination()); } return InternalError; } diff --git a/engine/src/editor/converters/prefabconverter.cpp b/engine/src/editor/converters/prefabconverter.cpp index ff51d02a0..b9e2c7eb2 100644 --- a/engine/src/editor/converters/prefabconverter.cpp +++ b/engine/src/editor/converters/prefabconverter.cpp @@ -73,14 +73,13 @@ void PrefabConverter::createFromTemplate(const TString &destination) { void PrefabConverter::makePrefab(Actor *actor, AssetConverterSettings *settings) { File file(settings->source()); if(file.open(File::WriteOnly)) { - Prefab *fab = Engine::objectCreate(""); + Prefab *fab = Engine::objectCreate(settings->destination()); fab->setActor(actor); file.write(Json::save(Engine::toVariant(fab), 0)); file.close(); settings->saveSettings(); - Engine::setResource(fab, settings->destination()); } } @@ -104,7 +103,7 @@ AssetConverter::ReturnCode PrefabConverter::convertFile(AssetConverterSettings * Variant variant = readJson(src.readAll(), settings); src.close(); - return settings->saveBinary(variant); + return settings->saveBinary(variant, settings->absoluteDestination()); } return result; } diff --git a/engine/src/editor/converters/textconverter.cpp b/engine/src/editor/converters/textconverter.cpp index ac43f3ef5..69f0d118f 100644 --- a/engine/src/editor/converters/textconverter.cpp +++ b/engine/src/editor/converters/textconverter.cpp @@ -23,7 +23,7 @@ AssetConverter::ReturnCode TextConverter::convertFile(AssetConverterSettings *se if(src.open(File::ReadOnly)) { Text *text = Engine::loadResource(settings->destination()); if(text == nullptr) { - text = Engine::objectCreate(); + text = Engine::objectCreate(settings->destination()); } TString content(src.readAll()); @@ -33,7 +33,7 @@ AssetConverter::ReturnCode TextConverter::convertFile(AssetConverterSettings *se memcpy(text->data(), content.data(), content.size()); } - return settings->saveBinary(Engine::toVariant(text)); + return settings->saveBinary(Engine::toVariant(text), settings->absoluteDestination()); } return InternalError; diff --git a/engine/src/editor/converters/translatorconverter.cpp b/engine/src/editor/converters/translatorconverter.cpp index bcdf2a63f..de74da529 100644 --- a/engine/src/editor/converters/translatorconverter.cpp +++ b/engine/src/editor/converters/translatorconverter.cpp @@ -21,7 +21,7 @@ AssetConverter::ReturnCode TranslatorConverter::convertFile(AssetConverterSettin if(src.open(QIODevice::ReadOnly)) { Translator *loc = Engine::loadResource(settings->destination()); if(loc == nullptr) { - loc = Engine::objectCreate(); + loc = Engine::objectCreate(settings->destination()); } while(!src.atEnd()) { @@ -31,7 +31,7 @@ AssetConverter::ReturnCode TranslatorConverter::convertFile(AssetConverterSettin } src.close(); - return settings->saveBinary(Engine::toVariant(loc)); + return settings->saveBinary(Engine::toVariant(loc), settings->absoluteDestination()); } return InternalError; diff --git a/engine/src/editor/viewport/cameracontroller.cpp b/engine/src/editor/viewport/cameracontroller.cpp index 5b0454153..4433993b0 100644 --- a/engine/src/editor/viewport/cameracontroller.cpp +++ b/engine/src/editor/viewport/cameracontroller.cpp @@ -46,8 +46,8 @@ CameraController::CameraController() : m_activeRootObject(nullptr), m_zoomLimit(0.001f, 10000.0f) { - Actor *actor = Engine::composeActor(gCamera, gCamera, nullptr); - m_activeCamera = static_cast(actor->component(gCamera)); + Actor *actor = Engine::composeActor(gCamera); + m_activeCamera = actor->getComponent(); m_activeCamera->setFocal(10.0f); m_activeCamera->setOrthoSize(10.0f); diff --git a/engine/src/engine.cpp b/engine/src/engine.cpp index 9a0364f88..2230f96fa 100644 --- a/engine/src/engine.cpp +++ b/engine/src/engine.cpp @@ -254,7 +254,7 @@ void Engine::update() { if(camera == nullptr) { aDebug() << "Camera not found creating a new one."; - Actor *cameraActor = Engine::composeActor("Camera", "ActiveCamera", m_world); + Actor *cameraActor = Engine::composeActor("ActiveCamera", m_world); camera = cameraActor->getComponent(); } @@ -431,16 +431,6 @@ void Engine::reloadResource(const TString &path) { bool Engine::isResourceExist(const TString &path) { return m_resourceSystem->isResourceExist(path); } -/*! - Register resource \a object by \a uuid path. - - \sa setResource() -*/ -void Engine::setResource(Object *object, const TString &uuid) { - PROFILE_FUNCTION(); - - m_resourceSystem->setResource(static_cast(object), uuid); -} /*! Replaces a current \a platform adaptor with new one; Returns true if replacement been succeeded; otherwise returns false. @@ -459,8 +449,6 @@ bool Engine::setPlatformAdaptor(PlatformAdaptor *platform) { } /*! Returns resource path for the provided resource \a object. - - \sa setResource() */ TString Engine::reference(Object *object) { PROFILE_FUNCTION(); diff --git a/engine/tests/tst_actor.h b/engine/tests/tst_actor.h index 569b109b1..95497147c 100644 --- a/engine/tests/tst_actor.h +++ b/engine/tests/tst_actor.h @@ -323,7 +323,7 @@ TEST_F(ActorTest, Update_prefab_instance) { switchStatePrefab(*prefab, Resource::Ready); // Check instance state from Step 1 - TestComponent *resultTestComponent = dynamic_cast(clone->component("TestComponent")); + TestComponent *resultTestComponent = clone->getComponent(); ASSERT_TRUE(resultTestComponent != nullptr); ASSERT_TRUE(resultTestComponent->parent()->name() == "Root"); diff --git a/modules/editor/grapheditor/editor/graph/graphnode.cpp b/modules/editor/grapheditor/editor/graph/graphnode.cpp index 956a9e4b9..fc2a5dbf2 100644 --- a/modules/editor/grapheditor/editor/graph/graphnode.cpp +++ b/modules/editor/grapheditor/editor/graph/graphnode.cpp @@ -10,8 +10,6 @@ #include "graphwidgets/nodewidget.h" namespace { - const char *gNodeWidget("NodeWidget"); - const char *gType("type"); const char *gName("name"); @@ -90,7 +88,7 @@ void GraphNode::setPosition(const Vector2 &position) { Widget *GraphNode::widget() { if(m_nodeWidget == nullptr) { - Actor *nodeActor = Engine::composeActor(gNodeWidget, name()); + Actor *nodeActor = Engine::composeActor(name()); if(nodeActor) { NodeWidget *nodeWidget = nodeActor->getComponent(); nodeWidget->setGraphNode(this); diff --git a/modules/editor/grapheditor/editor/graph/graphview.cpp b/modules/editor/grapheditor/editor/graph/graphview.cpp index 07508ae6b..08207af89 100644 --- a/modules/editor/grapheditor/editor/graph/graphview.cpp +++ b/modules/editor/grapheditor/editor/graph/graphview.cpp @@ -134,12 +134,12 @@ void GraphView::setWorld(World *scene) { Viewport::setWorld(scene); m_scene = Engine::objectCreate("Scene", m_world); - m_view = Engine::composeActor("Widget", "View", m_scene); + m_view = Engine::composeActor("View", m_scene); - Actor *actor = Engine::composeActor(gLinksRender, gLinksRender, m_view); + Actor *actor = Engine::composeActor(gLinksRender, m_view); m_linksRender = actor->getComponent(); - actor = Engine::composeActor(gFrame, gFrame, m_view); + actor = Engine::composeActor(gFrame, m_view); m_rubberBand = actor->getComponent(); m_rubberBand->setColor(Vector4(0.376f, 0.376f, 0.376f, 0.3f)); m_rubberBand->setBorderColor(Vector4(0.6f, 0.6f, 0.6f, 1.0f)); diff --git a/modules/editor/grapheditor/editor/graph/graphwidgets/groupwidget.cpp b/modules/editor/grapheditor/editor/graph/graphwidgets/groupwidget.cpp index 0d6479232..9cb061d0a 100644 --- a/modules/editor/grapheditor/editor/graph/graphwidgets/groupwidget.cpp +++ b/modules/editor/grapheditor/editor/graph/graphwidgets/groupwidget.cpp @@ -142,9 +142,9 @@ void GroupWidget::composeComponent() { setColor(Vector4(1.0f, 1.0f, 1.0f, 0.5f)); - Actor *title = Engine::composeActor("Frame", "Title", actor()); + Actor *title = Engine::composeActor("Title", actor()); if(title) { - m_title = static_cast(title->component("Frame")); + m_title = title->getComponent(); if(m_title) { RectTransform *rect = m_title->rectTransform(); rect->setAnchors(Vector2(0.0f, 1.0f), Vector2(1.0f, 1.0f)); diff --git a/modules/editor/grapheditor/editor/graph/graphwidgets/nodewidget.cpp b/modules/editor/grapheditor/editor/graph/graphwidgets/nodewidget.cpp index 39de26750..0c12ed0e4 100644 --- a/modules/editor/grapheditor/editor/graph/graphwidgets/nodewidget.cpp +++ b/modules/editor/grapheditor/editor/graph/graphwidgets/nodewidget.cpp @@ -26,13 +26,6 @@ const float row = 20.0f; -namespace { - const char *gPortWidget("PortWidget"); - const char *gImage("Image"); - const char *gFrame("Frame"); - const char *gToolButton("ToolButton"); -}; - NodeWidget::NodeWidget() : m_node(nullptr), m_label(nullptr), @@ -162,7 +155,7 @@ void NodeWidget::composeComponent() { rect->setHorizontalPolicy(RectTransform::Fixed); rect->setBorder(2.0f); - Actor *title = Engine::composeActor(gFrame, "Title", actor()); + Actor *title = Engine::composeActor("Title", actor()); if(title) { m_title = title->getComponent(); if(m_title) { @@ -193,9 +186,9 @@ void NodeWidget::composeComponent() { } void NodeWidget::composePort(NodePort &port) { - Actor *portActor = Engine::composeActor(gPortWidget, port.m_name, actor()); + Actor *portActor = Engine::composeActor(port.m_name, actor()); if(portActor) { - PortWidget *portWidget = static_cast(portActor->component(gPortWidget)); + PortWidget *portWidget = portActor->getComponent(); if(portWidget) { RectTransform *portRect = portWidget->rectTransform(); portRect->setSize(Vector2(0, row)); diff --git a/modules/editor/grapheditor/editor/graph/graphwidgets/portwidget.cpp b/modules/editor/grapheditor/editor/graph/graphwidgets/portwidget.cpp index 9760a1f2f..a89f44b43 100644 --- a/modules/editor/grapheditor/editor/graph/graphwidgets/portwidget.cpp +++ b/modules/editor/grapheditor/editor/graph/graphwidgets/portwidget.cpp @@ -11,11 +11,6 @@ #include -namespace { - const char *gLabel("Label"); - const char *gWidget("Widget"); -}; - PortWidget::PortWidget() : m_port(nullptr), m_label(nullptr), @@ -68,7 +63,7 @@ void PortWidget::setNodePort(NodePort *port) { // Create editor (only for inputs) if(!m_port->m_out) { if(m_editor) { - Widget *widget = static_cast(m_editor->component(gWidget)); + Widget *widget = m_editor->getComponent(); RectTransform *widgetRect = widget->rectTransform(); widgetRect->setMargin(Vector4(0.0f, 10.0f, 0.0f, 10.0f)); @@ -76,8 +71,8 @@ void PortWidget::setNodePort(NodePort *port) { } } - m_label = Engine::composeActor(gLabel, m_port->m_name, actor()); - Label *label = static_cast