diff options
author | Aki <please@ignore.pl> | 2023-02-17 18:43:09 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2023-02-17 18:43:09 +0100 |
commit | c5a8295619d1b803380b244e4162ca359740e3c1 (patch) | |
tree | 5fec8a6892d5ead22a3dcad47db9393e9a3669e7 | |
parent | e587befed3f13db9e2f84c8a3dccfc67d6bad292 (diff) | |
download | kurator-c5a8295619d1b803380b244e4162ca359740e3c1.zip kurator-c5a8295619d1b803380b244e4162ca359740e3c1.tar.gz kurator-c5a8295619d1b803380b244e4162ca359740e3c1.tar.bz2 |
Inspect window has more interactive widgets now
-rw-r--r-- | kurator/src/inspect.cpp | 60 |
1 files 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 <entt/entt.hpp> #include <imgui.h> +#include <kurator/sim/FloatingMovement.h> +#include <kurator/sim/HitPoints.h> +#include <kurator/universe/ShipType.h> #include <kurator/universe/UniqueIdentifier.h> @@ -12,6 +15,21 @@ namespace kurator { +template <typename Type> void inspect(entt::handle& entity); +template <typename Type> void inspect(entt::handle& entity, Type& component); + + +template <typename Type> +void +inspect(entt::handle& entity) +{ + if (entity.all_of<Type>()) { + inspect(entity, entity.get<Type>()); + ImGui::Separator(); + } +} + + void InspectionWindow::show() { @@ -19,8 +37,10 @@ InspectionWindow::show() return; if (ImGui::Begin("Inspect", &open)) { if (selected) { - const auto& identifier = selected.get<universe::UniqueIdentifier>(); - ImGui::Text("Selected: %d", identifier.id); + inspect<universe::UniqueIdentifier>(selected); + inspect<universe::ShipType>(selected); + inspect<sim::FloatingMovement>(selected); + inspect<sim::HitPoints>(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 |