diff options
| -rw-r--r-- | src/game.cpp | 64 | ||||
| -rw-r--r-- | src/game.hpp | 5 | ||||
| -rw-r--r-- | src/window.cpp | 4 |
3 files changed, 65 insertions, 8 deletions
diff --git a/src/game.cpp b/src/game.cpp index 64ccc0a..57740e0 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1,6 +1,5 @@ #include "game.hpp" -#include "imgui.h" GameSettings pkeSettings{}; @@ -18,9 +17,21 @@ void Game_Tick(double delta) { ECS_Tick(delta); } -void RecordImGuiConsole(bool *pOpen) { +void RecordImGuiEditorWrapper() { + ImGui::DockSpaceOverViewport(nullptr, ImGuiDockNodeFlags_PassthruCentralNode); + ImGui::BeginMainMenuBar(); + if (ImGui::BeginMenu("File")) { + if (ImGui::MenuItem("Exit")) { + glfwSetWindowShouldClose(window, true); + } + ImGui::EndMenu(); + } + ImGui::EndMainMenuBar(); +} + +void RecordImGuiConsole() { static bool scrollToBottom = true; - if (!ImGui::Begin("Console", pOpen)) { + if (!ImGui::Begin("Console", &pkeSettings.editorSettings.isShowingConsole)) { ImGui::End(); return; } @@ -51,8 +62,53 @@ void RecordImGuiConsole(bool *pOpen) { ImGui::End(); } +void RecordImGuiEntityList() { + if (!ImGui::Begin("EntityList", &pkeSettings.editorSettings.isShowingEntityList)) { + ImGui::End(); + return; + } + static ImGuiTableFlags tableFlags{ + ImGuiTableFlags_Borders | + ImGuiTableFlags_RowBg + }; + if (ImGui::BeginTable("Entities", 5, tableFlags)) { + ImGui::TableSetupColumn("EntityHandle"); + ImGui::TableSetupColumn("ParentEntityHandle"); + ImGui::TableSetupColumn("GrBindsHandle"); + ImGui::TableSetupColumn("InstanceHandle"); + ImGui::TableSetupColumn("IsMarkedForRemoval"); + ImGui::TableHeadersRow(); + + uint64_t bucketCount = ECS_GetEntities_BucketCount(); + for (long bucket = 0; bucket <= bucketCount; ++bucket) { + uint64_t itemCount = 0; + auto *entities = ECS_GetEntities(bucket, itemCount); + for (long row = 0; row < itemCount; row++) { + auto *entity = &entities[row]; + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::Text("%lu", entity->handle); + ImGui::TableSetColumnIndex(1); + ImGui::Text("%lu", entity->parentHandle); + ImGui::TableSetColumnIndex(2); + ImGui::Text("%lu", entity->grBindsHandle); + ImGui::TableSetColumnIndex(3); + ImGui::Text("%lu", entity->instanceHandle); + ImGui::TableSetColumnIndex(4); + ImGui::Text("%u", entity->isMarkedForRemoval); + } + } + ImGui::EndTable(); + } + ImGui::End(); +} + void RecordImGuiEditor() { - RecordImGuiConsole(&pkeSettings.isShowingEditor); + if (pkeSettings.isShowingEditor) { + RecordImGuiEditorWrapper(); + RecordImGuiConsole(); + RecordImGuiEntityList(); + } } void Game_Init() { diff --git a/src/game.hpp b/src/game.hpp index d8e1833..b780b4a 100644 --- a/src/game.hpp +++ b/src/game.hpp @@ -7,6 +7,7 @@ #include "event.hpp" #include "imgui.h" #include "ecs.hpp" +#include "window.hpp" using GameTimeDuration = std::chrono::duration<int64_t, std::nano>; using GameTimePoint = std::chrono::steady_clock::time_point; @@ -22,6 +23,10 @@ struct GameSettings { int64_t minFPS = 20; double deltaPerFrame = 1 / double(targetFPS); double minimumDeltaPerFrame = 1 / double(minFPS); + struct { + bool isShowingConsole = true; + bool isShowingEntityList = true; + } editorSettings; }; extern GameSettings pkeSettings; diff --git a/src/window.cpp b/src/window.cpp index 8293c81..3eea64c 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1,4 +1,3 @@ -#include <vulkan/vulkan_core.h> #define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_VULKAN @@ -1020,9 +1019,6 @@ void RecordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex) { ImGui_ImplGlfw_NewFrame(); ImGui::NewFrame(); - ImGui::DockSpaceOverViewport(nullptr, ImGuiDockNodeFlags_PassthruCentralNode); - - ImGui::ShowDemoWindow(); Event_Dispatch("RenderImGui"); ImGui::Render(); |
