update keyboard shortcuts

This commit is contained in:
2026-06-23 21:43:34 +02:00
parent f818c90af0
commit 31a8915b0f
9 changed files with 151 additions and 81 deletions

View File

@@ -130,3 +130,20 @@ void BuildButtonGrid::handleEvent(std::shared_ptr<const DemolishModeChangedEvent
{
m_demolishButton->setChecked(event->active);
}
void BuildButtonGrid::handleEvent(std::shared_ptr<const BuildHotkeyPressedEvent> event)
{
for (std::size_t i = 0; i < m_types.size(); ++i)
{
if (m_types[i] == event->type)
{
// Equivalent to clicking the build button: a disabled (unaffordable)
// button cannot be clicked, so the hotkey is likewise inert.
if (m_buttons[i]->isEnabled())
{
onBuildButton(static_cast<int>(i));
}
return;
}
}
}