float the build buttons as a horizontal bar over the game world and show key bindings inside build buttons

This commit is contained in:
2026-08-06 08:28:40 +02:00
parent f39fe9a118
commit c1af58d80c
14 changed files with 575 additions and 477 deletions

View File

@@ -51,6 +51,29 @@ std::optional<BuildingType> buildHotkeyType(int digit, bool shiftHeld)
} // namespace
QString InputMapper::getBuildHotkeyLabel(BuildingType type)
{
// Searched out of the binding table above rather than spelled out a second time,
// so a badge can never claim a key the handler does not act on. The shift glyph
// is written as a code point because the sources are not guaranteed to be read
// as UTF-8 by every compiler this builds with. A plain stroke arrow rather than
// U+21E7 UPWARDS WHITE ARROW: the standard UI fonts do not all carry the outlined
// shift glyph, and the substitute they fall back to is unreadable at badge size.
const QChar shiftGlyph(0x2191); // U+2191 UPWARDS ARROW
for (int digit = 1; digit <= 9; ++digit)
{
if (buildHotkeyType(digit, false) == type)
{
return QString::number(digit);
}
if (buildHotkeyType(digit, true) == type)
{
return shiftGlyph + QString::number(digit);
}
}
return QString();
}
bool InputMapper::handleKeyPress(QKeyEvent* event)
{
// Auto-repeat says nothing new about which keys are down, and a held action is