Show building_block icon in header stock, expand button and build costs

This commit is contained in:
2026-07-23 21:13:37 +02:00
parent 0bba7686e6
commit 79b79ab7c3
9 changed files with 313 additions and 18 deletions

View File

@@ -1,7 +1,10 @@
#pragma once
#include <memory>
#include <string>
#include <vector>
#include <QPixmap>
#include <QWidget>
#include "ArtifactCountChangedEvent.h"
@@ -16,6 +19,7 @@
class QLabel;
class QPushButton;
class ItemIconCache;
class HeaderBar : public QWidget,
public CombinedEventHandler<TickAdvancedEvent,
@@ -28,7 +32,11 @@ class HeaderBar : public QWidget,
Q_OBJECT
public:
explicit HeaderBar(const GameConfig* config, QWidget* parent = nullptr);
// 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:
@@ -46,6 +54,15 @@ private:
// expansion cost and building block stock (REQ-UI-EXPAND-BUTTON).
void updateExpandButton();
// Refreshes the building blocks stock display from m_blocks: `Stock: <n>` with
// the building_block icon after it, or the `Stock: <n> 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;
@@ -53,6 +70,8 @@ private:
QPushButton* m_expandButton;
std::vector<QPushButton*> m_speedButtons;
std::unique_ptr<ItemIconCache> m_itemIcons;
int m_blocks = 0;
int m_expansionCost = 0;