From 825ff4343178afb4ab1d4d769c028a3108df2891 Mon Sep 17 00:00:00 2001 From: Ishan-002 Date: Tue, 15 Mar 2022 21:23:56 +0530 Subject: [PATCH 1/2] Fix infinte warn logging on broken game/assets directory --- editor/editor_system.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/editor/editor_system.cpp b/editor/editor_system.cpp index 232d68f0b..f5dc90e15 100644 --- a/editor/editor_system.cpp +++ b/editor/editor_system.cpp @@ -258,6 +258,11 @@ void EditorSystem::drawDefaultUI(float deltaMilliseconds) { if (ImGui::BeginMenu("Create Resource")) { + if (!OS::IsDirectory("game/assets/materials")) + { + OS::CreateDirectoryName("game/assets/materials"); + } + if (ImGui::BeginCombo("Resource Type", newFileTypeName.c_str())) { for (auto& [type, typeName] : ResourceFile::s_TypeNames) @@ -294,6 +299,11 @@ void EditorSystem::drawDefaultUI(float deltaMilliseconds) if (ImGui::BeginMenu("Create Script")) { ImGui::InputText("Script Name", &newScript); + + if (!OS::IsDirectory("game/assets/scripts")) + { + OS::CreateDirectoryName("game/assets/scripts"); + } String finalNewScriptName = "game/assets/scripts/" + newScript + ".lua"; ImGui::Text("File Name: %s", finalNewScriptName.c_str()); @@ -319,6 +329,10 @@ void EditorSystem::drawDefaultUI(float deltaMilliseconds) ImGui::Separator(); if (ImGui::BeginMenu("Create Scene")) { + if (!OS::IsDirectory("game/assets/scenes")) + { + OS::CreateDirectoryName("game/assets/scenes"); + } ImGui::InputText("Scene Name", &newSceneName, ImGuiInputTextFlags_AlwaysInsertMode); if (!newSceneName.empty() && ImGui::Button("Create")) { @@ -337,6 +351,10 @@ void EditorSystem::drawDefaultUI(float deltaMilliseconds) } if (ImGui::BeginMenu("Open Scene")) { + if (!OS::IsDirectory("game/assets/scenes")) + { + OS::CreateDirectoryName("game/assets/scenes"); + } for (auto&& levelName : OS::GetFilesInDirectory("game/assets/scenes/")) { if (ImGui::MenuItem(levelName.generic_string().c_str())) From 50d38f9d8772f91366b24ea60cffd84e2050dc9b Mon Sep 17 00:00:00 2001 From: Ishan-002 Date: Wed, 6 Apr 2022 01:33:12 +0530 Subject: [PATCH 2/2] Shift game/assets directory check from draw() to initialise() --- editor/editor_system.cpp | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/editor/editor_system.cpp b/editor/editor_system.cpp index f5dc90e15..78126b1cc 100644 --- a/editor/editor_system.cpp +++ b/editor/editor_system.cpp @@ -48,6 +48,23 @@ bool EditorSystem::initialize(const JSON::json& systemData) m_Inspector.reset(new InspectorDock()); m_FileViewer.reset(new FileViewer()); m_FileEditor.reset(new FileEditor()); + + { + if (!OS::IsDirectory("game/assets/materials")) + { + OS::CreateDirectoryName("game/assets/materials"); + } + + if (!OS::IsDirectory("game/assets/scripts")) + { + OS::CreateDirectoryName("game/assets/scripts"); + } + + if (!OS::IsDirectory("game/assets/scenes")) + { + OS::CreateDirectoryName("game/assets/scenes"); + } + } IMGUI_CHECKVERSION(); ImGui::CreateContext(); @@ -258,11 +275,6 @@ void EditorSystem::drawDefaultUI(float deltaMilliseconds) { if (ImGui::BeginMenu("Create Resource")) { - if (!OS::IsDirectory("game/assets/materials")) - { - OS::CreateDirectoryName("game/assets/materials"); - } - if (ImGui::BeginCombo("Resource Type", newFileTypeName.c_str())) { for (auto& [type, typeName] : ResourceFile::s_TypeNames) @@ -298,12 +310,7 @@ void EditorSystem::drawDefaultUI(float deltaMilliseconds) static String newScript; if (ImGui::BeginMenu("Create Script")) { - ImGui::InputText("Script Name", &newScript); - - if (!OS::IsDirectory("game/assets/scripts")) - { - OS::CreateDirectoryName("game/assets/scripts"); - } + ImGui::InputText("Script Name", &newScript); String finalNewScriptName = "game/assets/scripts/" + newScript + ".lua"; ImGui::Text("File Name: %s", finalNewScriptName.c_str()); @@ -329,10 +336,6 @@ void EditorSystem::drawDefaultUI(float deltaMilliseconds) ImGui::Separator(); if (ImGui::BeginMenu("Create Scene")) { - if (!OS::IsDirectory("game/assets/scenes")) - { - OS::CreateDirectoryName("game/assets/scenes"); - } ImGui::InputText("Scene Name", &newSceneName, ImGuiInputTextFlags_AlwaysInsertMode); if (!newSceneName.empty() && ImGui::Button("Create")) { @@ -351,10 +354,6 @@ void EditorSystem::drawDefaultUI(float deltaMilliseconds) } if (ImGui::BeginMenu("Open Scene")) { - if (!OS::IsDirectory("game/assets/scenes")) - { - OS::CreateDirectoryName("game/assets/scenes"); - } for (auto&& levelName : OS::GetFilesInDirectory("game/assets/scenes/")) { if (ImGui::MenuItem(levelName.generic_string().c_str()))