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,6 +1,7 @@
#pragma once
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <vector>
@@ -18,6 +19,7 @@
class QPushButton;
class Simulation;
class ItemIconCache;
class BuildButtonGrid : public QWidget,
public CombinedEventHandler<BuilderModeExitedEvent,
@@ -30,9 +32,12 @@ class BuildButtonGrid : public QWidget,
public:
// iconDir is the directory holding the per-building "<id>.svg" chip icons
// (REQ-UI-BUILD-GRID); read from disk at runtime, like the config files.
// (REQ-UI-BUILD-GRID); itemsIconDir holds the per-item icons and supplies the
// building_block icon shown in each button's cost (REQ-UI-BUILD-COST). Both are
// read from disk at runtime, like the config files.
BuildButtonGrid(Simulation* sim, const GameConfig* config,
const std::string& iconDir, QWidget* parent = nullptr);
const std::string& iconDir, const std::string& itemsIconDir,
QWidget* parent = nullptr);
~BuildButtonGrid() override;
void clearActiveButton();
@@ -60,6 +65,7 @@ private:
Simulation* m_sim;
const GameConfig* m_config;
std::string m_iconDir;
std::unique_ptr<ItemIconCache> m_itemIcons;
std::vector<BuildingType> m_types;
std::vector<QPushButton*> m_buttons;
std::map<BuildingType, int> m_costs;