add boss wave counter and countdown to the title bar

This commit is contained in:
2026-06-03 22:44:56 +02:00
parent b5185b0906
commit 15d8fa4f2c
9 changed files with 54 additions and 6 deletions

View File

@@ -22,9 +22,11 @@ HeaderBar::HeaderBar(QWidget* parent)
m_timeLabel = new QLabel("00:00", this);
m_blocksLabel = new QLabel("Blocks: 0", this);
m_bossLabel = new QLabel("Boss Wave #1 Next boss: 5:00", this);
layout->addWidget(m_timeLabel);
layout->addWidget(m_blocksLabel);
layout->addStretch();
layout->addWidget(m_bossLabel);
const char* labels[] = { "0x", "0.5x", "1x", "2x", "4x" };
QSignalMapper* mapper = new QSignalMapper(this);
@@ -43,7 +45,8 @@ HeaderBar::HeaderBar(QWidget* parent)
setFixedHeight(sizeHint().height());
}
void HeaderBar::onStateUpdated(Tick tick, int buildingBlocks, double gameSpeed)
void HeaderBar::onStateUpdated(Tick tick, int buildingBlocks, double gameSpeed,
int bossCounter, Tick bossCountdownTicks)
{
const int totalSeconds = static_cast<int>(ticksToSeconds(tick));
const int minutes = totalSeconds / 60;
@@ -56,6 +59,16 @@ void HeaderBar::onStateUpdated(Tick tick, int buildingBlocks, double gameSpeed)
m_blocksLabel->setText(QString("Blocks: %1").arg(buildingBlocks));
const int bossSeconds = static_cast<int>(ticksToSeconds(
bossCountdownTicks > 0 ? bossCountdownTicks : 0));
const int bossMin = bossSeconds / 60;
const int bossSec = bossSeconds % 60;
m_bossLabel->setText(
QString("Boss Wave #%1 Next boss: %2:%3")
.arg(bossCounter)
.arg(bossMin)
.arg(bossSec, 2, 10, QChar('0')));
for (int i = 0; i < kSpeedCount; ++i)
{
const bool active = (std::abs(kSpeeds[i] - gameSpeed) < 0.001);