summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2023-12-13 15:53:52 -0500
committerJonathan Bradley <jcb@pikum.xyz>2023-12-23 11:41:03 -0500
commit064e9ba16e390b13566d0007ef367dcb1adacc8d (patch)
tree359be3c8de88da8544646bfc9a84a8c8b3f383cd /editor
parenta527dd1b773f14df140d3ac6a167339d7dc39e33 (diff)
checkpoint - add PkeLevel - editor removes on scene load
Diffstat (limited to 'editor')
-rw-r--r--editor/editor.cpp57
1 files changed, 49 insertions, 8 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp
index c4a2a20..2f3a7d4 100644
--- a/editor/editor.cpp
+++ b/editor/editor.cpp
@@ -1,20 +1,21 @@
#include "editor.hpp"
-#include "ecs.hpp"
-#include "project.hpp"
-#include "thread_pool.hpp"
-#include "game.hpp"
#include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.h"
-#include "math-helpers.hpp"
#include "camera.hpp"
+#include "ecs.hpp"
#include "entities.hpp"
#include "game-settings.hpp"
+#include "game.hpp"
+#include "imgui.h"
+#include "level.hpp"
+#include "math-helpers.hpp"
#include "player-input.hpp"
-#include "window.hpp"
+#include "project.hpp"
+#include "thread_pool.hpp"
#include "vendor/glm_include.hpp"
#include "vendor/tinyfiledialogs//tinyfiledialogs.h"
-#include "imgui.h"
+#include "window.hpp"
#include <GLFW/glfw3.h>
#include <compare>
@@ -77,6 +78,7 @@ bool shouldSaveScene = false;
bool shouldSaveProjectFile = false;
bool shouldRunCurrentScene = false;
bool subProgramRunning = false;
+LevelHandle levelHandle = LevelHandle_MAX;
glm::vec3 unproject(glm::vec3 windowCoords) {
double xDevNorm = (2.0f * windowCoords.x) / Extent.width - 1.0f;
@@ -138,7 +140,12 @@ void PkeEditor_Tick(double delta) {
}
if (shouldLoadScene && sceneName) {
shouldLoadScene = false;
- Game_LoadSceneFile(sceneName);
+ if (levelHandle != LevelHandle_MAX) {
+ PkeLevel_Remove(levelHandle);
+ ActiveCamera = &NullCamera;
+ }
+ levelHandle = PkeLevel_Create("editorLevel");
+ Game_LoadSceneFile(levelHandle, sceneName);
}
if (shouldOpenSaveSceneDialog) {
@@ -713,6 +720,39 @@ void RecordImGuiModalCreateEntityType() {
}
}
+void RecordImGuiLevels() {
+ if (!ImGui::Begin("Levels")) {
+ ImGui::End();
+ return;
+ }
+ static ImGuiTableFlags tableFlags{
+ ImGuiTableFlags_Borders |
+ ImGuiTableFlags_RowBg
+ };
+ if (ImGui::BeginTable("PkeLevels", 5, tableFlags)) {
+ ImGui::TableSetupColumn("Name");
+ ImGui::TableSetupColumn("Handle");
+ ImGui::TableSetupColumn("EntityCount");
+ ImGui::TableSetupColumn("CameraCount");
+ ImGui::TableHeadersRow();
+ for (long i = 0; i < MAX_LEVEL_COUNT; ++i) {
+ if (LEVELS[i].handle == LevelHandle_MAX)
+ continue;
+ ImGui::TableNextRow();
+ ImGui::TableSetColumnIndex(0);
+ ImGui::Text("%s", LEVELS[i].name);
+ ImGui::TableSetColumnIndex(1);
+ ImGui::Text("0x%04hx", LEVELS[i].handle);
+ ImGui::TableSetColumnIndex(2);
+ ImGui::Text("%u", LEVELS[i].wrappingEntities.next - 1);
+ ImGui::TableSetColumnIndex(3);
+ ImGui::Text("%u", LEVELS[i].cameras.next - 1);
+ }
+ ImGui::EndTable();
+ }
+ ImGui::End();
+}
+
void RecordImGui_CompGrBinds(bool readonly, CompGrBinds *component) {
if (component == nullptr) return;
int inputTextFlags = 0;
@@ -961,6 +1001,7 @@ void PkeEditor_RecordImGui() {
RecordImGuiSceneEditor();
RecordImGuiUBO();
RecordImGuiCameras();
+ RecordImGuiLevels();
Game_RecordImGui();
}
}