From c5a8295619d1b803380b244e4162ca359740e3c1 Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 17 Feb 2023 18:43:09 +0100 Subject: Inspect window has more interactive widgets now --- kurator/src/inspect.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/kurator/src/inspect.cpp b/kurator/src/inspect.cpp index 97ca73c..2adcb6e 100644 --- a/kurator/src/inspect.cpp +++ b/kurator/src/inspect.cpp @@ -5,6 +5,9 @@ #include #include +#include +#include +#include #include @@ -12,6 +15,21 @@ namespace kurator { +template void inspect(entt::handle& entity); +template void inspect(entt::handle& entity, Type& component); + + +template +void +inspect(entt::handle& entity) +{ + if (entity.all_of()) { + inspect(entity, entity.get()); + ImGui::Separator(); + } +} + + void InspectionWindow::show() { @@ -19,8 +37,10 @@ InspectionWindow::show() return; if (ImGui::Begin("Inspect", &open)) { if (selected) { - const auto& identifier = selected.get(); - ImGui::Text("Selected: %d", identifier.id); + inspect(selected); + inspect(selected); + inspect(selected); + inspect(selected); } else { ImGui::Text("Nothing selected"); @@ -38,4 +58,40 @@ InspectionWindow::select(entt::handle entity) } +template <> +void +inspect(entt::handle&, universe::UniqueIdentifier& identifier) +{ + ImGui::Text("Selected: %d", identifier.id); +} + + +template <> +void +inspect(entt::handle&, universe::ShipType& type) +{ + ImGui::Text("Type: %s", type.name.c_str()); +} + + +template <> +void +inspect(entt::handle&, sim::FloatingMovement& movement) +{ + ImGui::Text("Speed: %.2f", movement.speed.magnitude()); + ImGui::InputDouble("Maximum Speed", &movement.max_speed, 0, 0, "%.1f"); +} + + +template <> +void +inspect(entt::handle&, sim::HitPoints& points) +{ + ImGui::Text("Total: %.2f", points.total()); + ImGui::InputDouble("Shield", &points.shield.points, 0, 0, "%.1f"); + ImGui::InputDouble("Armour", &points.armour.points, 0, 0, "%.1f"); + ImGui::InputDouble("Structure", &points.structure.points, 0, 0, "%.1f"); +} + + } // namespace kurator -- cgit v1.1