summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp64
1 files changed, 60 insertions, 4 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() {