summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2023-12-08 14:47:03 -0500
committerJonathan Bradley <jcb@pikum.xyz>2023-12-08 14:47:03 -0500
commit8047197b62894cb1f7bb6a6871870e4b91fde992 (patch)
tree95da0f95b36541e88fe61c5c4e2f0ebfe9219045 /editor
parent838df109b72265d4ac2606112086ff6c12d73eca (diff)
editor use delete key for removing entities
Diffstat (limited to 'editor')
-rw-r--r--editor/editor.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp
index c198bae..9b79155 100644
--- a/editor/editor.cpp
+++ b/editor/editor.cpp
@@ -1,6 +1,7 @@
#include "editor.hpp"
+#include "ecs.hpp"
#include "project.hpp"
#include "thread_pool.hpp"
#include "game.hpp"
@@ -15,6 +16,7 @@
#include "vendor/tinyfiledialogs//tinyfiledialogs.h"
#include "imgui.h"
+#include <GLFW/glfw3.h>
#include <filesystem>
#include <future>
#include <regex>
@@ -38,6 +40,7 @@ const char* const dbgCtrl_CameraRot = "debug-camera-rot";
const char* const dbgCtrl_CameraButtonMask = "debug-camera-button-mask";
const char* const dbgCtrl_SelectHovered = "debug-select-hovered";
const char* const dbgCtrl_ClearSelection = "debug-clear-selection";
+const char* const dbgCtrl_DeleteSelectedItem = "debug-delete-selected-item";
ThreadPoolHandle threadPoolHandle = ThreadPoolHandle_MAX;
@@ -374,6 +377,15 @@ void PkeEditor_Tick(double delta) {
}
}
+ holder = PkeInput_Query(dbgCtrl_DeleteSelectedItem);
+ if (holder.type != InputEventHash{0} && selectedEntity != EntityHandle_MAX) {
+ PkeKeyEvent *delSelectedItemEvent;
+ delSelectedItemEvent = static_cast<PkeKeyEvent *>(holder.ptr);
+ if (delSelectedItemEvent->isPressed == true) {
+ ECS_MarkForRemoval(selectedEntity);
+ selectedEntity = EntityHandle_MAX;
+ }
+ }
}
void RecordImGui_GLM(const char *label, glm::mat4 &mat) {
@@ -456,6 +468,9 @@ void RecordImGuiEntityList() {
ImGui::PushID(bucket);
for (long row = 0; row < itemCount; row++) {
auto *entity = &entities[row];
+ if (entity->handle == EntityHandle_MAX) {
+ continue;
+ }
ImGui::PushID(row);
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
@@ -926,7 +941,7 @@ void PkeEditor_Teardown() {
void PkeEditor_Init() {
PkeInputSet debugControlsSet;
debugControlsSet.title = "debug-editor-controls";
- debugControlsSet.actionCount = 12;
+ debugControlsSet.actionCount = 13;
debugControlsSet.actions = Pke_New<PkeInputAction>(debugControlsSet.actionCount);
debugControlsSet.actions[0].name = dbgCtrl_CameraLeft;
@@ -988,6 +1003,11 @@ void PkeEditor_Init() {
.computedHash = PKE_INPUT_HASH_ALL_MOUSE_BUTTON_EVENTS,
.button = GLFW_MOUSE_BUTTON_RIGHT,
};
+ debugControlsSet.actions[12].name = dbgCtrl_DeleteSelectedItem;
+ debugControlsSet.actions[12].primaryHash = PkeInputEventMask {
+ .computedHash = PKE_INPUT_HASH_ALL_KEY_EVENTS,
+ .button = GLFW_KEY_DELETE,
+ };
debugControlsHandle = PkeInput_RegisterSet(debugControlsSet);