From 099f0b55fc4f50ba95eeb2f3ba33dcddc99cdcc4 Mon Sep 17 00:00:00 2001 From: Malte Langkabel Date: Mon, 3 Aug 2026 21:54:02 +0200 Subject: [PATCH] make HeaderBar read the tick, artifacts and boss wave from the simulation The last three payloads HeaderBar still consumed as truth. All are backed by Simulation getters (getCurrentTick, getArtifactCount, getBossWaveCounter, getBossCountdownTicks) and the win count by world.artifacts.artifactWinCount, so the handlers now re-read rather than trust the event. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01YHcUerKAZKWNvSKJxYKbnG --- src/ui/HeaderBar.cpp | 20 ++++++++++++-------- src/ui/HeaderBar.h | 4 ++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/ui/HeaderBar.cpp b/src/ui/HeaderBar.cpp index 1a2458b..8227016 100644 --- a/src/ui/HeaderBar.cpp +++ b/src/ui/HeaderBar.cpp @@ -107,9 +107,9 @@ HeaderBar::~HeaderBar() unregisterForEvents(); } -void HeaderBar::handleEvent(std::shared_ptr event) +void HeaderBar::handleEvent(std::shared_ptr /*event*/) { - const int totalSeconds = static_cast(ticksToSeconds(event->tick)); + const int totalSeconds = static_cast(ticksToSeconds(m_sim->getCurrentTick())); m_timeLabel->setText( QString("%1:%2") .arg(totalSeconds / 60, 2, 10, QChar('0')) @@ -195,22 +195,26 @@ void HeaderBar::handleEvent(std::shared_ptr event) } } -void HeaderBar::handleEvent(std::shared_ptr event) +void HeaderBar::handleEvent(std::shared_ptr /*event*/) { - const int bossSeconds = static_cast( - ticksToSeconds(event->countdownTicks > 0 ? event->countdownTicks : 0)); + const Tick countdownTicks = m_sim->getBossCountdownTicks(); + const int bossSeconds = static_cast( + ticksToSeconds(countdownTicks > 0 ? countdownTicks : 0)); m_bossWaveLabel->setText( tr("Boss Wave #%1") - .arg(event->counter)); + .arg(m_sim->getBossWaveCounter())); m_nextBossLabel->setText( tr("Next boss: %1:%2") .arg(bossSeconds / 60) .arg(bossSeconds % 60, 2, 10, QChar('0'))); } -void HeaderBar::handleEvent(std::shared_ptr event) +void HeaderBar::handleEvent(std::shared_ptr /*event*/) { - m_artifactsLabel->setText(tr("Artifacts: %1/%2").arg(event->count).arg(event->winCount)); + m_artifactsLabel->setText( + tr("Artifacts: %1/%2") + .arg(m_sim->getArtifactCount()) + .arg(m_sim->getConfig().world.artifacts.artifactWinCount)); } void HeaderBar::onSpeedButton(int index) diff --git a/src/ui/HeaderBar.h b/src/ui/HeaderBar.h index 1bc7bea..2bb1f87 100644 --- a/src/ui/HeaderBar.h +++ b/src/ui/HeaderBar.h @@ -75,8 +75,8 @@ private: ItemIconCache* m_itemIcons; // Not owned; lives in MainWindow. - // The simulation is the single source of truth for the block stock and the - // expansion cost; the change events are only refresh signals. + // The simulation is the single source of truth for everything the header + // displays; the change events are only refresh signals. const Simulation* m_sim; static const double kSpeeds[];