Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BaseID : implementation and minor changes #586

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions editor/editor_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") && !Scene::isReservedName(newSceneName))
{
if (SceneLoader::GetSingleton()->getCurrentScene())
Expand Down Expand Up @@ -985,8 +988,7 @@ int EditorSystem::exportScene(const String& sceneName, const String& sceneFilePa
{
return;
}
m_IsCopyFailed = !OS::RelativeCopyFile(filePair.first, m_CurrExportDir + filePair.second);
}));
m_IsCopyFailed = !OS::RelativeCopyFile(filePair.first, m_CurrExportDir + filePair.second); }));
}

/// TODO: Fix the need for this dummy task (blocks the main thread while tasks are running)
Expand Down
12 changes: 11 additions & 1 deletion rootex/framework/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
#include "components/visual/camera_component.h"
#include "components/audio/audio_listener_component.h"

static SceneID NextSceneID = ROOT_SCENE_ID + 1;
ashpect marked this conversation as resolved.
Show resolved Hide resolved
Vector<Scene*> Scene::s_Scenes;
SceneID Scene::BaseID;
static SceneID NextSceneID = ROOT_SCENE_ID + 1;

void to_json(JSON::json& j, const SceneSettings& s)
{
Expand Down Expand Up @@ -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> Scene::Create(const JSON::json& sceneData, const bool assignNewIDs)
{
// Decide ID
Expand Down Expand Up @@ -335,6 +343,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();
Expand All @@ -359,6 +368,7 @@ Scene::Scene(SceneID id, const String& name, const SceneSettings& settings, Impo
, m_Entity(this)
{
setName(m_Name);
setBaseID();
s_Scenes.push_back(this);
}

Expand Down
5 changes: 4 additions & 1 deletion rootex/framework/scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ class Scene
bool m_IsScenePaused;

static Vector<Scene*> 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
Expand All @@ -57,6 +58,7 @@ class Scene

public:
static void ResetNextID();
static void SetBaseID(const SceneID& inputBaseID);

static Ptr<Scene> Create(const JSON::json& sceneData, const bool assignNewIDs);
static Ptr<Scene> CreateFromFile(const String& sceneFile);
Expand All @@ -81,6 +83,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; }
Expand Down