summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kurator/src/Battle.cpp2
-rw-r--r--kurator/src/inspect.cpp7
2 files changed, 6 insertions, 3 deletions
diff --git a/kurator/src/Battle.cpp b/kurator/src/Battle.cpp
index b0719ea..fe3c37b 100644
--- a/kurator/src/Battle.cpp
+++ b/kurator/src/Battle.cpp
@@ -103,12 +103,12 @@ Battle::update()
blink_crosses(ctx);
animate_lines(ctx);
balance.update(ctx.registry);
+ inspect.show();
ImGui::SetNextWindowPos({GetScreenWidth()/2.0f, GetScreenHeight()-100.0f}, ImGuiCond_Once, {0.5f, 0.5f});
ImGui::SetNextWindowSize({240.0f, 0.0f}, ImGuiCond_Once);
if (ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_NoFocusOnAppearing))
time_controls("TimeControls", ctx.clock.time_factor);
ImGui::End();
- inspect.show();
}
diff --git a/kurator/src/inspect.cpp b/kurator/src/inspect.cpp
index 4795068..062630c 100644
--- a/kurator/src/inspect.cpp
+++ b/kurator/src/inspect.cpp
@@ -43,11 +43,11 @@ InspectionWindow::show()
if (ImGui::Begin("Inspect", &open)) {
auto it = selected.begin();
while (it != selected.end()) {
- ImGui::PushID(it - selected.begin());
if (!it->valid()) {
it = selected.erase(it);
continue;
}
+ ImGui::PushID(it - selected.begin());
inspect<universe::UniqueIdentifier>(*it);
inspect<universe::ShipType>(*it);
inspect<universe::TurretType>(*it);
@@ -90,6 +90,8 @@ void
InspectionWindow::deselect()
{
for (auto&& entity_ : selected) {
+ if (!entity_.valid())
+ continue;
if (entity_.all_of<Marker>())
entity_.get<Marker>().selected = false;
if (entity_.all_of<TurretVisuals>())
@@ -154,12 +156,13 @@ inspect(entt::handle&, TurretVisuals& visuals)
static Color OPTIMAL {0x88, 0x22, 0x22, 0xff};
static Color EFFECTIVE {0x77, 0x50, 0x22, 0xff};
+
void
draw_turret_visuals(const sim::State& ctx)
{
const auto helpers = ctx.registry.view<TurretVisuals, universe::TurretType, sim::TurretControl>();
for (const auto& [entity, visuals, type, turret] : helpers.each()) {
- if (!visuals.visible)
+ if (!visuals.visible || !ctx.registry.valid(turret.owner))
continue;
const auto& transform = ctx.registry.get<sim::Transform>(turret.owner);
const auto center = ctx.camera.to_screen(transform.position);