From 30452999b8afb37cb224661545570cd882880e95 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 18 Feb 2023 23:09:13 +0100 Subject: Inspection tool will select ship turrets additionally when available --- kurator/src/inspect.cpp | 39 +++++++++++++++++++++++++++++++-------- kurator/src/inspect.h | 4 +++- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/kurator/src/inspect.cpp b/kurator/src/inspect.cpp index 2adcb6e..4dff0a6 100644 --- a/kurator/src/inspect.cpp +++ b/kurator/src/inspect.cpp @@ -7,7 +7,9 @@ #include #include +#include #include +#include #include @@ -36,15 +38,21 @@ InspectionWindow::show() if (!open) return; if (ImGui::Begin("Inspect", &open)) { - if (selected) { - inspect(selected); - inspect(selected); - inspect(selected); - inspect(selected); + auto it = selected.begin(); + while (it != selected.end()) { + if (!it->valid()) { + it = selected.erase(it); + continue; + } + inspect(*it); + inspect(*it); + inspect(*it); + inspect(*it); + inspect(*it); + it = std::next(it); } - else { + if (selected.empty()) ImGui::Text("Nothing selected"); - } } ImGui::End(); } @@ -53,7 +61,14 @@ InspectionWindow::show() void InspectionWindow::select(entt::handle entity) { - selected = std::move(entity); + selected.clear(); + auto* registry = entity.registry(); + auto turrets = registry->view(); + selected.push_back(std::move(entity)); + for (auto&& [entity_, turret] : turrets.each()) { + if (turret.owner == entity) + selected.push_back(entt::handle{*registry, entity_}); + } open = true; } @@ -76,6 +91,14 @@ inspect(entt::handle&, universe::ShipType& type) template <> void +inspect(entt::handle&, universe::TurretType& type) +{ + ImGui::Text("Type: %s", type.name.c_str()); +} + + +template <> +void inspect(entt::handle&, sim::FloatingMovement& movement) { ImGui::Text("Speed: %.2f", movement.speed.magnitude()); diff --git a/kurator/src/inspect.h b/kurator/src/inspect.h index a8b206f..77daa76 100644 --- a/kurator/src/inspect.h +++ b/kurator/src/inspect.h @@ -1,5 +1,7 @@ #pragma once +#include + #include @@ -10,7 +12,7 @@ namespace kurator struct InspectionWindow { bool open = false; - entt::handle selected = {}; + std::vector selected = {}; void show(); void select(entt::handle entity); }; -- cgit v1.1