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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YHcUerKAZKWNvSKJxYKbnG
This commit is contained in:
2026-08-03 21:54:02 +02:00
parent b133a21914
commit 099f0b55fc
2 changed files with 14 additions and 10 deletions

View File

@@ -107,9 +107,9 @@ HeaderBar::~HeaderBar()
unregisterForEvents(); unregisterForEvents();
} }
void HeaderBar::handleEvent(std::shared_ptr<const TickAdvancedEvent> event) void HeaderBar::handleEvent(std::shared_ptr<const TickAdvancedEvent> /*event*/)
{ {
const int totalSeconds = static_cast<int>(ticksToSeconds(event->tick)); const int totalSeconds = static_cast<int>(ticksToSeconds(m_sim->getCurrentTick()));
m_timeLabel->setText( m_timeLabel->setText(
QString("%1:%2") QString("%1:%2")
.arg(totalSeconds / 60, 2, 10, QChar('0')) .arg(totalSeconds / 60, 2, 10, QChar('0'))
@@ -195,22 +195,26 @@ void HeaderBar::handleEvent(std::shared_ptr<const GameSpeedChangedEvent> event)
} }
} }
void HeaderBar::handleEvent(std::shared_ptr<const BossWaveUpdatedEvent> event) void HeaderBar::handleEvent(std::shared_ptr<const BossWaveUpdatedEvent> /*event*/)
{ {
const int bossSeconds = static_cast<int>( const Tick countdownTicks = m_sim->getBossCountdownTicks();
ticksToSeconds(event->countdownTicks > 0 ? event->countdownTicks : 0)); const int bossSeconds = static_cast<int>(
ticksToSeconds(countdownTicks > 0 ? countdownTicks : 0));
m_bossWaveLabel->setText( m_bossWaveLabel->setText(
tr("Boss Wave #%1") tr("Boss Wave #%1")
.arg(event->counter)); .arg(m_sim->getBossWaveCounter()));
m_nextBossLabel->setText( m_nextBossLabel->setText(
tr("Next boss: %1:%2") tr("Next boss: %1:%2")
.arg(bossSeconds / 60) .arg(bossSeconds / 60)
.arg(bossSeconds % 60, 2, 10, QChar('0'))); .arg(bossSeconds % 60, 2, 10, QChar('0')));
} }
void HeaderBar::handleEvent(std::shared_ptr<const ArtifactCountChangedEvent> event) void HeaderBar::handleEvent(std::shared_ptr<const ArtifactCountChangedEvent> /*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) void HeaderBar::onSpeedButton(int index)

View File

@@ -75,8 +75,8 @@ private:
ItemIconCache* m_itemIcons; // Not owned; lives in MainWindow. ItemIconCache* m_itemIcons; // Not owned; lives in MainWindow.
// The simulation is the single source of truth for the block stock and the // The simulation is the single source of truth for everything the header
// expansion cost; the change events are only refresh signals. // displays; the change events are only refresh signals.
const Simulation* m_sim; const Simulation* m_sim;
static const double kSpeeds[]; static const double kSpeeds[];