add boss wave counter and countdown to the title bar
This commit is contained in:
@@ -240,7 +240,9 @@ void GameWorldView::onFrame()
|
||||
// Emit state update for header bar / build grid
|
||||
emit stateUpdated(m_sim->currentTick(),
|
||||
m_sim->buildingBlocksStock(),
|
||||
m_gameSpeedMultiplier);
|
||||
m_gameSpeedMultiplier,
|
||||
m_sim->bossWaveCounter(),
|
||||
m_sim->bossCountdownTicks());
|
||||
|
||||
// Game over check
|
||||
if (m_sim->isGameOver() && !m_gameOverShown)
|
||||
@@ -1390,7 +1392,9 @@ void GameWorldView::setGameSpeed(double multiplier)
|
||||
m_gameSpeedMultiplier = multiplier;
|
||||
emit stateUpdated(m_sim->currentTick(),
|
||||
m_sim->buildingBlocksStock(),
|
||||
m_gameSpeedMultiplier);
|
||||
m_gameSpeedMultiplier,
|
||||
m_sim->bossWaveCounter(),
|
||||
m_sim->bossCountdownTicks());
|
||||
}
|
||||
|
||||
void GameWorldView::resetForNewGame()
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
|
||||
signals:
|
||||
void selectionChanged(const std::vector<BuildingId>& ids);
|
||||
void stateUpdated(Tick tick, int blocks, double speed);
|
||||
void stateUpdated(Tick tick, int blocks, double speed, int bossCounter, Tick bossCountdownTicks);
|
||||
void gameOver();
|
||||
void builderModeExited();
|
||||
void blueprintModeExited();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -17,7 +17,8 @@ public:
|
||||
explicit HeaderBar(QWidget* parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void onStateUpdated(Tick tick, int buildingBlocks, double gameSpeed);
|
||||
void onStateUpdated(Tick tick, int buildingBlocks, double gameSpeed,
|
||||
int bossCounter, Tick bossCountdownTicks);
|
||||
|
||||
signals:
|
||||
void speedChanged(double multiplier);
|
||||
@@ -28,6 +29,7 @@ private slots:
|
||||
private:
|
||||
QLabel* m_timeLabel;
|
||||
QLabel* m_blocksLabel;
|
||||
QLabel* m_bossLabel;
|
||||
std::vector<QPushButton*> m_speedButtons;
|
||||
|
||||
static const double kSpeeds[];
|
||||
|
||||
Reference in New Issue
Block a user