summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kurator/src/inspect.cpp60
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