Skip to content

Commit

Permalink
feat(tesseratos): load asset metadata from loaded project
Browse files Browse the repository at this point in the history
  • Loading branch information
RiscadoA committed Sep 27, 2024
1 parent 25fb024 commit d1d8d95
Showing 1 changed file with 41 additions and 29 deletions.
70 changes: 41 additions & 29 deletions tools/tesseratos/src/tesseratos/project/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <cubos/core/data/fs/standard_archive.hpp>
#include <cubos/core/reflection/external/string.hpp>

#include <cubos/engine/assets/plugin.hpp>
#include <cubos/engine/imgui/plugin.hpp>
#include <cubos/engine/settings/plugin.hpp>
#include <cubos/engine/tools/toolbox/plugin.hpp>
Expand All @@ -20,44 +21,55 @@ void tesseratos::projectPlugin(Cubos& cubos)
cubos.depends(toolboxPlugin);
cubos.depends(imguiPlugin);
cubos.depends(settingsPlugin);
cubos.depends(assetsPlugin);

cubos.resource<Project>();

cubos.system("show Project").tagged(imguiTag).call([](Toolbox& toolbox, Project& project, Settings& settings) {
if (!toolbox.isOpen("Project"))
{
return;
}

if (!ImGui::Begin("Project"))
{
ImGui::End();
return;
}

if (!project.open())
{
// If the project is not open, only show the open dialog.
auto projectOSPath = settings.getString("project.path", "");
if (ImGui::InputText("Project Path", &projectOSPath))
cubos.system("show Project")
.tagged(imguiTag)
.call([](Toolbox& toolbox, Project& project, Settings& settings, Assets& assets) {
if (!toolbox.isOpen("Project"))
{
settings.setString("project.path", projectOSPath);
return;
}

if (ImGui::Button("Open") && !project.open(projectOSPath))
if (!ImGui::Begin("Project"))
{
CUBOS_ERROR("Failed to open project");
ImGui::End();
return;
}

ImGui::End();
return;
}
if (!project.open())
{
// If the project is not open, only show the open dialog.
auto projectOSPath = settings.getString("project.path", "");
if (ImGui::InputText("Project Path", &projectOSPath))
{
settings.setString("project.path", projectOSPath);
}

if (ImGui::Button("Open"))
{
if (project.open(projectOSPath))
{
assets.loadMeta("/project/assets");
}
else
{
CUBOS_ERROR("Failed to open project");
}
}

if (ImGui::Button("Close"))
{
project.close();
}
ImGui::End();
return;
}

ImGui::End();
});
if (ImGui::Button("Close"))
{
assets.unloadMeta("/project/assets");
project.close();
}

ImGui::End();
});
}

0 comments on commit d1d8d95

Please sign in to comment.