This commit is contained in:
Antoine Pilote
2023-09-21 16:38:50 -04:00
15 changed files with 491 additions and 324 deletions

View File

@@ -49,6 +49,8 @@
#include "UIDemoWindow.h"
#include <src/Audio/AudioManager.h>
#include <src/UI/ImUI.h>
namespace Nuake {
Ref<UI::UserInterface> userInterface;
ImFont* normalFont;
@@ -60,6 +62,8 @@ namespace Nuake {
filesystem = new FileSystemUI(this);
_WelcomeWindow = new WelcomeWindow(this);
_audioWindow = new AudioWindow();
BuildFonts();
}
void EditorInterface::Init()
@@ -1053,39 +1057,19 @@ namespace Nuake {
ImGui::End();
std::string title = ICON_FA_TREE + std::string(" Hierarchy");
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(4, 0));
if (ImGui::Begin(title.c_str()))
{
// Buttons to add and remove entity.
if(ImGui::BeginChild("Buttons", ImVec2(ImGui::GetContentRegionAvail().x, 30), false))
{
// Add entity.
if (ImGui::Button(ICON_FA_PLUS, ImVec2(30, 30)))
Engine::GetCurrentScene()->CreateEntity("Entity");
//// Remove Entity
//if (ImGui::Button("Remove"))
//{
// scene->DestroyEntity(m_SelectedEntity);
//
// // Unselect delted entity.
// m_SelectedEntity = scene->GetAllEntities().at(0);
//}
}
ImGui::EndChild();
// Draw a tree of entities.
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(26.f / 255.0f, 26.f / 255.0f, 26.f / 255.0f, 1));
if (ImGui::BeginChild("Scene tree", ImGui::GetContentRegionAvail(), false))
{
if (ImGui::BeginTable("entity_table", 3, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_SizingStretchProp))
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, { 8, 4 });
if (ImGui::BeginTable("entity_table", 3, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_NoPadInnerX | ImGuiTableFlags_NoPadOuterX))
{
ImGui::TableSetupColumn("Label", ImGuiTableColumnFlags_IndentEnable);
ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_IndentEnable);
ImGui::TableSetupColumn("Visibility", ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_IndentDisable | ImGuiTableColumnFlags_WidthFixed);
ImGui::TableHeadersRow();
ImGui::TableNextRow();
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(0, 0));
std::vector<Entity> entities = scene->GetAllEntities();
@@ -1116,8 +1100,8 @@ namespace Nuake {
}
ImGui::PopStyleVar();
}
ImGui::EndTable();
ImGui::PopStyleVar();
}
ImGui::EndChild();
@@ -1147,8 +1131,6 @@ namespace Nuake {
}
}
ImGui::End();
ImGui::PopStyleVar();
ImGui::PopStyleVar();
}
bool EditorInterface::EntityContainsItself(Entity source, Entity target)
@@ -1703,4 +1685,30 @@ namespace Nuake {
return entityTypeName;
}
bool EditorInterface::LoadProject(const std::string& projectPath)
{
FileSystem::SetRootDirectory(FileSystem::GetParentPath(projectPath));
auto project = Project::New();
auto projectFileData = FileSystem::ReadFile(projectPath, true);
try
{
project->Deserialize(json::parse(projectFileData));
project->FullPath = projectPath;
Engine::LoadProject(project);
filesystem->m_CurrentDirectory = Nuake::FileSystem::RootDirectory;
}
catch (std::exception exception)
{
Logger::Log("Error loading project: " + projectPath, "editor", CRITICAL);
Logger::Log(exception.what());
return false;
}
return true;
}
}