Commit 24dc7a1b authored by Johannes Braun's avatar Johannes Braun
Browse files

Fix keyboard shortcut del-removal for fields and lights

parent 87fef2e6
......@@ -506,7 +506,7 @@ void Editor::drawLightsTab()
m_selectedLightIndices.end(),
[&](uint32_t index) { return index == light_index; });
bool sel = it != m_selectedLightIndices.end();
ImGui::PushID((std::string("light") + std::to_string(light_index)).c_str());
ImGui::PushID((std::string("light") + std::to_string(light_id)).c_str());
std::string lightName = "";
auto currentLight = m_renderer->getLights().at(light_id);
......@@ -566,7 +566,7 @@ void Editor::drawLightsTab()
bool temp_sel = sel;
if(ImGui::Selectable(
(lightName + std::string(" Light [ID: ") + std::to_string(light_index) + "]")
(lightName + std::string(" Light [ID: ") + std::to_string(light_id) + "]")
.c_str(),
&temp_sel))
{
......@@ -942,7 +942,7 @@ void Editor::processInputsLights()
for (auto index : m_selectedLightIndices)
{
m_renderer->removeLight(m_allLightIds[index - erased]);
m_allLightIds.erase(m_allLightIds.begin() + index - erased);
m_allLightIds.erase(m_allLightIds.begin() + (index - erased));
++erased;
}
m_selectedLightIndices.clear();
......@@ -975,9 +975,11 @@ void Editor::processInputsFields()
{
if (glfwGetKey(*m_window, GLFW_KEY_DELETE) == GLFW_PRESS)
{
int erased = 0;
for (auto index : m_selectedFieldIndices)
{
deleteField(0);
deleteField(index - erased);
++erased;
}
m_selectedFieldIndices.clear();
select(std::nullopt, false);
......
......@@ -5,6 +5,7 @@
#include <dino/input/Window.h>
#include <optional>
#include <unordered_set>
#include <set>
#include <vector>
namespace dino
......@@ -86,8 +87,8 @@ private:
std::shared_ptr<Window> m_window = nullptr;
std::shared_ptr<RendererDeferred> m_renderer;
std::unique_ptr<Window> m_editorWindow;
std::unordered_set<uint32_t> m_selectedFieldIndices;
std::unordered_set<uint32_t> m_selectedLightIndices;
std::set<uint32_t> m_selectedFieldIndices;
std::set<uint32_t> m_selectedLightIndices;
std::vector<uint32_t> m_selectedLightIds;
std::vector<std::optional<uint32_t>> m_allFieldIds;
std::vector<uint32_t> m_allLightIds;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment