From 614dda8daf9039f9bba49f9769f6c8441f7f1e59 Mon Sep 17 00:00:00 2001 From: Malte Langkabel Date: Wed, 22 Jul 2026 19:47:58 +0200 Subject: [PATCH] Undo build button grid icons Remove the per-building SVG icons and all their wiring (the icon assets, the QtSvg-based icon loading in BuildButtonGrid, the icon dir plumbing in MainWindow, and the Qt5::Svg dependency), leaving only the Demolish -> Deconstruct rename from the previous commit. This is the inverse of the icon half of the previous commit, paired with a following revert that re-adds the icons. Cherry-picking the previous "rename + icons" commit together with this undo reconstructs the rename on its own. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Y7N59FsLA5e2kuVdqe4Uhc --- CMakeLists.txt | 3 +- bin/app/data/icons/buildings/assembler.svg | 6 -- bin/app/data/icons/buildings/belt.svg | 6 -- bin/app/data/icons/buildings/deconstruct.svg | 6 -- bin/app/data/icons/buildings/miner.svg | 6 -- .../icons/buildings/reprocessing_plant.svg | 6 -- bin/app/data/icons/buildings/salvage_bay.svg | 6 -- bin/app/data/icons/buildings/shipyard.svg | 6 -- bin/app/data/icons/buildings/smelter.svg | 6 -- bin/app/data/icons/buildings/splitter.svg | 6 -- bin/app/data/icons/buildings/tunnel_entry.svg | 6 -- src/CMakeLists.txt | 1 - src/ui/BuildButtonGrid.cpp | 69 +------------------ src/ui/BuildButtonGrid.h | 7 +- src/ui/MainWindow.cpp | 8 +-- 15 files changed, 4 insertions(+), 144 deletions(-) delete mode 100644 bin/app/data/icons/buildings/assembler.svg delete mode 100644 bin/app/data/icons/buildings/belt.svg delete mode 100644 bin/app/data/icons/buildings/deconstruct.svg delete mode 100644 bin/app/data/icons/buildings/miner.svg delete mode 100644 bin/app/data/icons/buildings/reprocessing_plant.svg delete mode 100644 bin/app/data/icons/buildings/salvage_bay.svg delete mode 100644 bin/app/data/icons/buildings/shipyard.svg delete mode 100644 bin/app/data/icons/buildings/smelter.svg delete mode 100644 bin/app/data/icons/buildings/splitter.svg delete mode 100644 bin/app/data/icons/buildings/tunnel_entry.svg diff --git a/CMakeLists.txt b/CMakeLists.txt index d5e3cb9..e51d757 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ set(CMAKE_BUILD_TYPE_INIT "Release") # Qt --------------------------------------------------------------------------- -find_package(Qt5 COMPONENTS Widgets Network Multimedia Charts Svg REQUIRED) +find_package(Qt5 COMPONENTS Widgets Network Multimedia Charts REQUIRED) if(Qt5Widgets_FOUND) message(STATUS "Found Qt ${Qt5Widgets_VERSION_STRING}") @@ -64,7 +64,6 @@ function(COPY_QT_BINARIES TARGET_DIR IS_DEBUG) configure_file("${QT_BINARY_DIR}/Qt5Network${SUFFIX}.dll" "${TARGET_DIR}/Qt5Network${SUFFIX}.dll" COPYONLY) configure_file("${QT_BINARY_DIR}/Qt5Widgets${SUFFIX}.dll" "${TARGET_DIR}/Qt5Widgets${SUFFIX}.dll" COPYONLY) configure_file("${QT_BINARY_DIR}/Qt5Multimedia${SUFFIX}.dll" "${TARGET_DIR}/Qt5Multimedia${SUFFIX}.dll" COPYONLY) - configure_file("${QT_BINARY_DIR}/Qt5Svg${SUFFIX}.dll" "${TARGET_DIR}/Qt5Svg${SUFFIX}.dll" COPYONLY) endfunction(COPY_QT_BINARIES) diff --git a/bin/app/data/icons/buildings/assembler.svg b/bin/app/data/icons/buildings/assembler.svg deleted file mode 100644 index 8fcf9f2..0000000 --- a/bin/app/data/icons/buildings/assembler.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/bin/app/data/icons/buildings/belt.svg b/bin/app/data/icons/buildings/belt.svg deleted file mode 100644 index 9739134..0000000 --- a/bin/app/data/icons/buildings/belt.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/bin/app/data/icons/buildings/deconstruct.svg b/bin/app/data/icons/buildings/deconstruct.svg deleted file mode 100644 index a07a642..0000000 --- a/bin/app/data/icons/buildings/deconstruct.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/bin/app/data/icons/buildings/miner.svg b/bin/app/data/icons/buildings/miner.svg deleted file mode 100644 index 30123a2..0000000 --- a/bin/app/data/icons/buildings/miner.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/bin/app/data/icons/buildings/reprocessing_plant.svg b/bin/app/data/icons/buildings/reprocessing_plant.svg deleted file mode 100644 index f5024ba..0000000 --- a/bin/app/data/icons/buildings/reprocessing_plant.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/bin/app/data/icons/buildings/salvage_bay.svg b/bin/app/data/icons/buildings/salvage_bay.svg deleted file mode 100644 index 844cbcd..0000000 --- a/bin/app/data/icons/buildings/salvage_bay.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/bin/app/data/icons/buildings/shipyard.svg b/bin/app/data/icons/buildings/shipyard.svg deleted file mode 100644 index cf8043a..0000000 --- a/bin/app/data/icons/buildings/shipyard.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/bin/app/data/icons/buildings/smelter.svg b/bin/app/data/icons/buildings/smelter.svg deleted file mode 100644 index 3697779..0000000 --- a/bin/app/data/icons/buildings/smelter.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/bin/app/data/icons/buildings/splitter.svg b/bin/app/data/icons/buildings/splitter.svg deleted file mode 100644 index 9ab41fa..0000000 --- a/bin/app/data/icons/buildings/splitter.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/bin/app/data/icons/buildings/tunnel_entry.svg b/bin/app/data/icons/buildings/tunnel_entry.svg deleted file mode 100644 index b31390d..0000000 --- a/bin/app/data/icons/buildings/tunnel_entry.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 929bc42..2f71a4e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -117,7 +117,6 @@ target_link_libraries(${TARGET_UI_NAME} Qt5::Network Qt5::Multimedia Qt5::Charts - Qt5::Svg ) target_compile_definitions(${TARGET_UI_NAME} PRIVATE TOML_FLOAT_CHARCONV=0) diff --git a/src/ui/BuildButtonGrid.cpp b/src/ui/BuildButtonGrid.cpp index 465866a..92aeef8 100644 --- a/src/ui/BuildButtonGrid.cpp +++ b/src/ui/BuildButtonGrid.cpp @@ -2,18 +2,9 @@ #include -#include -#include #include -#include -#include -#include #include -#include #include -#include -#include -#include #include "BuildingType.h" #include "BuildingTypeSelectedEvent.h" @@ -23,60 +14,11 @@ #include "ExitBuilderModeRequestedEvent.h" #include "Simulation.h" -namespace -{ - // Pixel size the SVG chips are rasterized at; downscaled to the button icon size. - const int kIconRenderSize = 64; - const QSize kIconSize(28, 28); - QPixmap renderChip(const QByteArray& svg) - { - QSvgRenderer renderer(svg); - QPixmap pixmap(kIconRenderSize, kIconRenderSize); - pixmap.fill(Qt::transparent); - QPainter painter(&pixmap); - renderer.render(&painter); - return pixmap; - } - - // Builds a build-button icon from a ".svg" chip file. The returned QIcon also - // carries a Disabled-mode pixmap whose chip background is recolored grey, so an - // unaffordable (disabled) button shows the grey variant automatically - // (REQ-UI-BUILD-DISABLED) without any extra work in updateAffordability(). - QIcon loadBuildingIcon(const QString& path) - { - QFile file(path); - if (!file.open(QIODevice::ReadOnly)) - { - return QIcon(); - } - const QByteArray svg = file.readAll(); - - QIcon icon; - icon.addPixmap(renderChip(svg), QIcon::Normal); - - // Recolor only the chip background: the first "#rrggbb" fill in the file is the - // rounded background rect; the white glyph uses fill="none" and is left alone. - QString greyed = QString::fromUtf8(svg); - static const QRegularExpression fillPattern(QStringLiteral("fill=\"#[0-9a-fA-F]{6}\"")); - const QRegularExpressionMatch match = fillPattern.match(greyed); - if (match.hasMatch()) - { - greyed.replace(match.capturedStart(), match.capturedLength(), - QStringLiteral("fill=\"#5f636e\"")); - } - icon.addPixmap(renderChip(greyed.toUtf8()), QIcon::Disabled); - return icon; - } -} - - -BuildButtonGrid::BuildButtonGrid(Simulation* sim, const GameConfig* config, - const std::string& iconDir, QWidget* parent) +BuildButtonGrid::BuildButtonGrid(Simulation* sim, const GameConfig* config, QWidget* parent) : QWidget(parent) , m_sim(sim) , m_config(config) - , m_iconDir(iconDir) { QGridLayout* layout = new QGridLayout(this); layout->setSpacing(4); @@ -111,12 +53,6 @@ BuildButtonGrid::BuildButtonGrid(Simulation* sim, const GameConfig* config, QPushButton* btn = new QPushButton(label, this); btn->setCheckable(true); btn->setFixedHeight(48); - // Icon file name matches the building id (REQ-UI-BUILD-GRID); Tunnel Entry's - // "tunnel_entry.svg" serves the shared Tunnel button. - const QString iconPath = QString::fromStdString(m_iconDir) + "/" - + QString::fromStdString(def.id) + ".svg"; - btn->setIcon(loadBuildingIcon(iconPath)); - btn->setIconSize(kIconSize); if (def.tooltip) { btn->setToolTip(QString::fromStdString(*def.tooltip)); @@ -140,9 +76,6 @@ BuildButtonGrid::BuildButtonGrid(Simulation* sim, const GameConfig* config, m_deconstructButton = new QPushButton(tr("Deconstruct"), this); m_deconstructButton->setCheckable(true); m_deconstructButton->setFixedHeight(48); - m_deconstructButton->setIcon(loadBuildingIcon( - QString::fromStdString(m_iconDir) + "/deconstruct.svg")); - m_deconstructButton->setIconSize(kIconSize); layout->addWidget(m_deconstructButton, row, col); connect(m_deconstructButton, &QPushButton::clicked, this, [this]() { EventManager::getInstance()->sendEventImmediately( diff --git a/src/ui/BuildButtonGrid.h b/src/ui/BuildButtonGrid.h index 3cc4c62..b9578dc 100644 --- a/src/ui/BuildButtonGrid.h +++ b/src/ui/BuildButtonGrid.h @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -29,10 +28,7 @@ class BuildButtonGrid : public QWidget, Q_OBJECT public: - // iconDir is the directory holding the per-building ".svg" chip icons - // (REQ-UI-BUILD-GRID); read from disk at runtime, like the config files. - BuildButtonGrid(Simulation* sim, const GameConfig* config, - const std::string& iconDir, QWidget* parent = nullptr); + BuildButtonGrid(Simulation* sim, const GameConfig* config, QWidget* parent = nullptr); ~BuildButtonGrid() override; void clearActiveButton(); @@ -59,7 +55,6 @@ private slots: private: Simulation* m_sim; const GameConfig* m_config; - std::string m_iconDir; std::vector m_types; std::vector m_buttons; std::map m_costs; diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp index 14fe5f5..c6c53ff 100644 --- a/src/ui/MainWindow.cpp +++ b/src/ui/MainWindow.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -52,13 +51,8 @@ MainWindow::MainWindow(Simulation* sim, const std::string& configDir, sideLayout->setContentsMargins(1, 1, 1, 1); sideLayout->setSpacing(1); - // Building icons live alongside the config (a sibling of the config dir), read - // from disk at runtime the same way visuals.toml is. - const std::string iconDir = QDir::cleanPath( - QString::fromStdString(m_configDir) + "/../icons/buildings").toStdString(); - m_selectedBuildingPanel = new SelectedBuildingPanel(sim, &sim->getConfig(), m_sidePanel); - m_buildButtonGrid = new BuildButtonGrid(sim, &sim->getConfig(), iconDir, m_sidePanel); + m_buildButtonGrid = new BuildButtonGrid(sim, &sim->getConfig(), m_sidePanel); m_blueprintPanel = new BlueprintPanel(sim, &sim->getConfig(), m_sidePanel); sideLayout->addWidget(m_selectedBuildingPanel, 1);