schematic selection dialog

This commit is contained in:
2026-06-13 12:00:05 +02:00
parent 1641189b75
commit 49f7129bd5
25 changed files with 453 additions and 268 deletions

View File

@@ -1,6 +1,5 @@
#include "BuildButtonGrid.h"
#include <cctype>
#include <string>
#include <QGridLayout>
@@ -8,35 +7,7 @@
#include <QSignalMapper>
#include "BuildingType.h"
namespace
{
QString displayName(const std::string& id)
{
QString result;
bool nextUpper = true;
for (char c : id)
{
if (c == '_')
{
result += ' ';
nextUpper = true;
}
else if (nextUpper)
{
result += static_cast<char>(std::toupper(static_cast<unsigned char>(c)));
nextUpper = false;
}
else
{
result += c;
}
}
return result;
}
} // namespace
#include "DisplayName.h"
BuildButtonGrid::BuildButtonGrid(const GameConfig* config, QWidget* parent)
@@ -62,7 +33,7 @@ BuildButtonGrid::BuildButtonGrid(const GameConfig* config, QWidget* parent)
m_types.push_back(def.type);
m_costs[def.type] = def.cost;
const QString label = displayName(def.id)
const QString label = QString::fromStdString(toDisplayName(def.id))
+ "\n" + tr("%1 Blocks").arg(def.cost);
QPushButton* btn = new QPushButton(label, this);
btn->setCheckable(true);