Skip to content

Commit 404fb85

Browse files
committed
Implement BaseID to avoid clashes
1 parent 0eabdfc commit 404fb85

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

editor/editor_system.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,10 @@ void EditorSystem::drawDefaultUI(float deltaMilliseconds)
318318
ImGui::Separator();
319319
if (ImGui::BeginMenu("Create Scene"))
320320
{
321+
SceneID inputBaseID = 0;
321322
ImGui::InputText("Scene Name", &newSceneName, ImGuiInputTextFlags_AlwaysInsertMode);
323+
ImGui::InputScalar("Scene BaseID", ImGuiDataType_U32, &inputBaseID);
324+
Scene::SetBaseID(inputBaseID);
322325
if (!newSceneName.empty() && ImGui::Button("Create"))
323326
{
324327
if (SceneLoader::GetSingleton()->getCurrentScene())

rootex/framework/scene.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
#include "components/visual/camera_component.h"
88
#include "components/audio/audio_listener_component.h"
99

10-
static SceneID NextSceneID = ROOT_SCENE_ID + 1;
1110
Vector<Scene*> Scene::s_Scenes;
11+
SceneID Scene::BaseID;
12+
static SceneID NextSceneID = ROOT_SCENE_ID + 1;
1213

1314
void to_json(JSON::json& j, const SceneSettings& s)
1415
{
@@ -50,6 +51,13 @@ void Scene::ResetNextID()
5051
NextSceneID = ROOT_SCENE_ID + 1;
5152
}
5253

54+
void Scene::SetBaseID(const SceneID& inputBaseID)
55+
{
56+
BaseID = inputBaseID;
57+
SceneID SceneIDOffset = 4;
58+
NextSceneID = std::max(std::max(BaseID, NextSceneID), SceneIDOffset);
59+
}
60+
5361
Ptr<Scene> Scene::Create(const JSON::json& sceneData, const bool assignNewIDs)
5462
{
5563
// Decide ID
@@ -321,6 +329,7 @@ JSON::json Scene::getJSON() const
321329

322330
j["ID"] = m_ID;
323331
j["name"] = m_Name;
332+
j["BaseID"] = m_BaseID;
324333
j["importStyle"] = m_ImportStyle;
325334
j["sceneFile"] = m_SceneFile;
326335
j["entity"] = m_Entity.getJSON();
@@ -345,6 +354,7 @@ Scene::Scene(SceneID id, const String& name, const SceneSettings& settings, Impo
345354
, m_Entity(this)
346355
{
347356
setName(m_Name);
357+
setBaseID();
348358
s_Scenes.push_back(this);
349359
}
350360

rootex/framework/scene.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ class Scene
4040
bool m_IsScenePaused;
4141

4242
static Vector<Scene*> s_Scenes;
43-
43+
static SceneID BaseID;
4444
SceneID m_ID;
4545
String m_Name;
46+
SceneID m_BaseID;
4647
String m_FullName;
4748
ImportStyle m_ImportStyle;
4849
/// Contains the current file name if local, else contains the linked scene file
@@ -57,6 +58,7 @@ class Scene
5758

5859
public:
5960
static void ResetNextID();
61+
static void SetBaseID(const SceneID& inputBaseID);
6062

6163
static Ptr<Scene> Create(const JSON::json& sceneData, const bool assignNewIDs);
6264
static Ptr<Scene> CreateFromFile(const String& sceneFile);
@@ -80,6 +82,7 @@ class Scene
8082
bool removeChild(Scene* toRemove);
8183

8284
void setName(const String& name);
85+
void setBaseID() { m_BaseID = BaseID; }
8386

8487
JSON::json getJSON() const;
8588
bool& getIsScenePaused() { return m_IsScenePaused; }

0 commit comments

Comments
 (0)