From 2408e2db2c2bd376f7defc1fd430ae189a1653db Mon Sep 17 00:00:00 2001 From: mojsior Date: Mon, 9 Feb 2026 16:19:46 +0100 Subject: [PATCH] access: migrate TAB binding for stash focus --- Source/options.cpp | 49 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/Source/options.cpp b/Source/options.cpp index 42873ec6d..a3318bbdf 100644 --- a/Source/options.cpp +++ b/Source/options.cpp @@ -1194,12 +1194,23 @@ void KeymapperOptions::Action::LoadFromIni(std::string_view category) return; // Use the default key if no key has been set. } - const std::string_view iniValue = iniValues.back().value; - if (iniValue.empty()) { - if (key == "SpeakCurrentLocation") { - const std::span chatLogValues = ini->get(category, "ChatLog"); - if (!chatLogValues.empty() && chatLogValues.back().value == "L") { - SetValue(defaultKey); + const std::string_view iniValue = iniValues.back().value; + if (iniValue.empty()) { + // Migration: `ToggleAutomap` could have been saved as unbound due to a key + // conflict when `ToggleStashFocus` was also bound to TAB. Restore the default + // key in that case so TAB works consistently. + if (key == "ToggleAutomap") { + const std::span stashFocusValues = ini->get(category, "ToggleStashFocus"); + if (!stashFocusValues.empty() && stashFocusValues.back().value == "TAB") { + SetValue(defaultKey); + return; + } + } + + if (key == "SpeakCurrentLocation") { + const std::span chatLogValues = ini->get(category, "ChatLog"); + if (!chatLogValues.empty() && chatLogValues.back().value == "L") { + SetValue(defaultKey); return; } } @@ -1219,15 +1230,23 @@ void KeymapperOptions::Action::LoadFromIni(std::string_view category) SetValue(defaultKey); return; } - - SetValue(SDLK_UNKNOWN); - return; - } - - auto keyIt = GetOptions().Keymapper.keyNameToKeyID.find(iniValue); - if (keyIt == GetOptions().Keymapper.keyNameToKeyID.end()) { - // Use the default key if the key is unknown. - Log("Keymapper: unknown key '{}'", iniValue); + + SetValue(SDLK_UNKNOWN); + return; + } + + // Migration: `ToggleStashFocus` previously defaulted to `TAB`, which conflicts + // with `ToggleAutomap` and can result in TAB doing nothing (e.g. when the action + // is disabled by a menu state). Unbind it when configured as TAB. + if (key == "ToggleStashFocus" && iniValue == "TAB") { + SetValue(defaultKey); + return; + } + + auto keyIt = GetOptions().Keymapper.keyNameToKeyID.find(iniValue); + if (keyIt == GetOptions().Keymapper.keyNameToKeyID.end()) { + // Use the default key if the key is unknown. + Log("Keymapper: unknown key '{}'", iniValue); SetValue(defaultKey); return; }