ask the icon cache for the inline block icon
This commit is contained in:
@@ -266,9 +266,7 @@ void BlueprintSelectionDialog::rebuildGrid()
|
||||
|
||||
// Block icon shown to the right of each cost (REQ-UI-BLUEPRINT-CARD); null when no
|
||||
// building_block icon exists, in which case the cost is the bare number.
|
||||
const QPixmap blockIcon = m_itemIcons->hasIcon(kBlockItemId)
|
||||
? m_itemIcons->getPixmap(kBlockItemId, QFontMetrics(font()).height())
|
||||
: QPixmap();
|
||||
const QPixmap blockIcon = m_itemIcons->getInlineIcon(kBlockItemId, font());
|
||||
|
||||
const QSize cardSize = getCardSize(font());
|
||||
|
||||
|
||||
@@ -175,9 +175,7 @@ BuildButtonBar::BuildButtonBar(Simulation* sim, const GameConfig* config,
|
||||
|
||||
// Block icon shown to the right of each button's cost (REQ-UI-BUILD-COST); null
|
||||
// when no building_block icon exists, in which case the cost is the bare number.
|
||||
const QPixmap blockIcon = m_itemIcons->hasIcon(kBlockItemId)
|
||||
? m_itemIcons->getPixmap(kBlockItemId, QFontMetrics(font()).height())
|
||||
: QPixmap();
|
||||
const QPixmap blockIcon = m_itemIcons->getInlineIcon(kBlockItemId, font());
|
||||
|
||||
for (const BuildingDef& def : config->buildings.buildings)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
|
||||
#include <QFontMetrics>
|
||||
#include <QHBoxLayout>
|
||||
#include <QIcon>
|
||||
#include <QLabel>
|
||||
@@ -120,19 +119,11 @@ void HeaderBar::handleEvent(std::shared_ptr<const ExpansionCostChangedEvent> /*e
|
||||
updateExpandButton();
|
||||
}
|
||||
|
||||
QPixmap HeaderBar::blockIcon() const
|
||||
{
|
||||
if (!m_itemIcons->hasIcon(kBlockItemId)) { return QPixmap(); }
|
||||
// Sized to the header text height so it sits inline with the caption.
|
||||
const int sizePx = QFontMetrics(font()).height();
|
||||
return m_itemIcons->getPixmap(kBlockItemId, sizePx);
|
||||
}
|
||||
|
||||
void HeaderBar::updateBlocksLabel()
|
||||
{
|
||||
const int blocks = m_sim->getBuildingBlocksStock();
|
||||
|
||||
const QPixmap icon = blockIcon();
|
||||
const QPixmap icon = m_itemIcons->getInlineIcon(kBlockItemId, font());
|
||||
if (icon.isNull())
|
||||
{
|
||||
// Fallback text form when no building_block icon exists (REQ-UI-BLOCKS-ICON).
|
||||
@@ -151,7 +142,7 @@ void HeaderBar::updateExpandButton()
|
||||
|
||||
m_expandButton->setEnabled(blocks >= expansionCost);
|
||||
|
||||
const QPixmap icon = blockIcon();
|
||||
const QPixmap icon = m_itemIcons->getInlineIcon(kBlockItemId, font());
|
||||
if (icon.isNull())
|
||||
{
|
||||
// Fallback text form when no building_block icon exists (REQ-UI-EXPAND-BUTTON).
|
||||
|
||||
@@ -61,10 +61,6 @@ private:
|
||||
// (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;
|
||||
|
||||
Reference in New Issue
Block a user