From 404fb853be2914574d667171bdb1494a71a96af8 Mon Sep 17 00:00:00 2001 From: Ashpect Date: Tue, 30 Aug 2022 22:09:58 +0530 Subject: [PATCH 1/3] Implement BaseID to avoid clashes --- editor/editor_system.cpp | 3 +++ rootex/framework/scene.cpp | 12 +++++++++++- rootex/framework/scene.h | 5 ++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/editor/editor_system.cpp b/editor/editor_system.cpp index 8fc0e2723..5036b815e 100644 --- a/editor/editor_system.cpp +++ b/editor/editor_system.cpp @@ -318,7 +318,10 @@ void EditorSystem::drawDefaultUI(float deltaMilliseconds) ImGui::Separator(); if (ImGui::BeginMenu("Create Scene")) { + SceneID inputBaseID = 0; ImGui::InputText("Scene Name", &newSceneName, ImGuiInputTextFlags_AlwaysInsertMode); + ImGui::InputScalar("Scene BaseID", ImGuiDataType_U32, &inputBaseID); + Scene::SetBaseID(inputBaseID); if (!newSceneName.empty() && ImGui::Button("Create")) { if (SceneLoader::GetSingleton()->getCurrentScene()) diff --git a/rootex/framework/scene.cpp b/rootex/framework/scene.cpp index 14d3acd77..bb2e86981 100644 --- a/rootex/framework/scene.cpp +++ b/rootex/framework/scene.cpp @@ -7,8 +7,9 @@ #include "components/visual/camera_component.h" #include "components/audio/audio_listener_component.h" -static SceneID NextSceneID = ROOT_SCENE_ID + 1; Vector Scene::s_Scenes; +SceneID Scene::BaseID; +static SceneID NextSceneID = ROOT_SCENE_ID + 1; void to_json(JSON::json& j, const SceneSettings& s) { @@ -50,6 +51,13 @@ void Scene::ResetNextID() NextSceneID = ROOT_SCENE_ID + 1; } +void Scene::SetBaseID(const SceneID& inputBaseID) +{ + BaseID = inputBaseID; + SceneID SceneIDOffset = 4; + NextSceneID = std::max(std::max(BaseID, NextSceneID), SceneIDOffset); +} + Ptr Scene::Create(const JSON::json& sceneData, const bool assignNewIDs) { // Decide ID @@ -321,6 +329,7 @@ JSON::json Scene::getJSON() const j["ID"] = m_ID; j["name"] = m_Name; + j["BaseID"] = m_BaseID; j["importStyle"] = m_ImportStyle; j["sceneFile"] = m_SceneFile; j["entity"] = m_Entity.getJSON(); @@ -345,6 +354,7 @@ Scene::Scene(SceneID id, const String& name, const SceneSettings& settings, Impo , m_Entity(this) { setName(m_Name); + setBaseID(); s_Scenes.push_back(this); } diff --git a/rootex/framework/scene.h b/rootex/framework/scene.h index 566d49afe..32256414e 100644 --- a/rootex/framework/scene.h +++ b/rootex/framework/scene.h @@ -40,9 +40,10 @@ class Scene bool m_IsScenePaused; static Vector s_Scenes; - + static SceneID BaseID; SceneID m_ID; String m_Name; + SceneID m_BaseID; String m_FullName; ImportStyle m_ImportStyle; /// Contains the current file name if local, else contains the linked scene file @@ -57,6 +58,7 @@ class Scene public: static void ResetNextID(); + static void SetBaseID(const SceneID& inputBaseID); static Ptr Create(const JSON::json& sceneData, const bool assignNewIDs); static Ptr CreateFromFile(const String& sceneFile); @@ -80,6 +82,7 @@ class Scene bool removeChild(Scene* toRemove); void setName(const String& name); + void setBaseID() { m_BaseID = BaseID; } JSON::json getJSON() const; bool& getIsScenePaused() { return m_IsScenePaused; } From 02d5025932f7281967565ea741e2ea71743b3646 Mon Sep 17 00:00:00 2001 From: Ashish Date: Tue, 27 Sep 2022 21:17:27 +0530 Subject: [PATCH 2/3] Fix lint --- editor/editor_system.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/editor/editor_system.cpp b/editor/editor_system.cpp index 5ac1bc0a8..2074745bc 100644 --- a/editor/editor_system.cpp +++ b/editor/editor_system.cpp @@ -982,8 +982,7 @@ int EditorSystem::exportScene(const String& sceneName, const String& sceneFilePa for (auto& filePair : toCopy) { - tasks.push_back(std::make_shared([=, &progress]() - { + tasks.push_back(std::make_shared([=, &progress]() { progress++; if (m_IsCopyFailed) { From 20b78f885a4d5d325164393f28361e7306eedfd0 Mon Sep 17 00:00:00 2001 From: Ashpect Date: Tue, 27 Sep 2022 22:43:22 +0530 Subject: [PATCH 3/3] Resolve merge conflict --- editor/editor_system.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/editor_system.cpp b/editor/editor_system.cpp index 2074745bc..25eb19a99 100644 --- a/editor/editor_system.cpp +++ b/editor/editor_system.cpp @@ -322,7 +322,7 @@ void EditorSystem::drawDefaultUI(float deltaMilliseconds) ImGui::InputText("Scene Name", &newSceneName, ImGuiInputTextFlags_AlwaysInsertMode); ImGui::InputScalar("Scene BaseID", ImGuiDataType_U32, &inputBaseID); Scene::SetBaseID(inputBaseID); - if (!newSceneName.empty() && ImGui::Button("Create")) + if (!newSceneName.empty() && ImGui::Button("Create") && !Scene::isReservedName(newSceneName)) { if (SceneLoader::GetSingleton()->getCurrentScene()) {