Skip to content

Commit

Permalink
Shift game/assets directory check from draw() to initialise()
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishan-002 committed Apr 5, 2022
1 parent 825ff43 commit 50d38f9
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions editor/editor_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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());
Expand All @@ -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"))
{
Expand All @@ -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()))
Expand Down

0 comments on commit 50d38f9

Please sign in to comment.