#pragma once #include #include #include #include #include #include "ArtifactCountChangedEvent.h" #include "BossWaveUpdatedEvent.h" #include "BuildingBlocksChangedEvent.h" #include "EventHandler.h" #include "ExpansionCostChangedEvent.h" #include "GameConfig.h" #include "GameSpeedChangedEvent.h" #include "Tick.h" #include "TickAdvancedEvent.h" class QLabel; class QPushButton; class ItemIconCache; class HeaderBar : public QWidget, public CombinedEventHandler { Q_OBJECT public: // itemsIconDir holds the per-item icon SVGs (REQ-UI-ITEM-ICON); used to show the // building_block icon in the stock display and expand button (REQ-UI-BLOCKS-ICON, // REQ-UI-EXPAND-BUTTON). HeaderBar(const GameConfig* config, const std::string& itemsIconDir, QWidget* parent = nullptr); ~HeaderBar() override; private slots: void onSpeedButton(int index); private: void handleEvent(std::shared_ptr event) override; void handleEvent(std::shared_ptr event) override; void handleEvent(std::shared_ptr event) override; void handleEvent(std::shared_ptr event) override; void handleEvent(std::shared_ptr event) override; void handleEvent(std::shared_ptr event) override; // Refreshes the Expand button caption and enabled state from the current // expansion cost and building block stock (REQ-UI-EXPAND-BUTTON). void updateExpandButton(); // Refreshes the building blocks stock display from m_blocks: `Stock: ` with // the building_block icon after it, or the `Stock: Blocks` text fallback when // no icon file exists (REQ-UI-BLOCKS-ICON). void updateBlocksLabel(); // The building_block icon at the header's text height, or a null pixmap when no // icon file exists. Loaded once via m_itemIcons on first use. QPixmap blockIcon() const; QLabel* m_timeLabel; QLabel* m_blocksLabel; QLabel* m_artifactsLabel; QLabel* m_bossWaveLabel; QLabel* m_nextBossLabel; QPushButton* m_expandButton; std::vector m_speedButtons; std::unique_ptr m_itemIcons; int m_blocks = 0; int m_expansionCost = 0; static const double kSpeeds[]; static const int kSpeedCount; };