Fixes a bunch of hotkey preferences bugs (#59492)

This fixes the problem of the keybind conflict message being shown over and over again until you manually save your preferences with correct keybinds + resetting to classic keys works now
You had to manually save your prefs because the code didn't save the new unbound keys to the prefs file
Classic mode was broken because the emote hotkeys didn't have classic_keys set to Unbound by default

New hotkeys are now actually set to Unbound if no default key is set
This was broken for emote hotkeys because classic_keys = list("Unbound") was missing for them
It was also broken because the code assumed conflicting keys if some Unbound key already existed ...
The code also used classic key defaults even if you had hotkey mode enabled thats fixed now too
This commit is contained in:
Gamer025
2021-06-05 10:55:33 -03:00
committed by GitHub
parent 83c03b2161
commit f73d8a2bae
2 changed files with 6 additions and 3 deletions
+5 -3
View File
@@ -111,17 +111,18 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
continue // key is unbound and or bound to something
var/addedbind = FALSE
if(hotkeys)
for(var/hotkeytobind in kb.classic_keys)
if(!length(key_bindings[hotkeytobind]))
for(var/hotkeytobind in kb.hotkey_keys)
if(!length(key_bindings[hotkeytobind]) || hotkeytobind == "Unbound") //Only bind to the key if nothing else is bound expect for Unbound
LAZYADD(key_bindings[hotkeytobind], kb.name)
addedbind = TRUE
else
for(var/classickeytobind in kb.classic_keys)
if(!length(key_bindings[classickeytobind]))
if(!length(key_bindings[classickeytobind]) || classickeytobind == "Unbound") //Only bind to the key if nothing else is bound expect for Unbound
LAZYADD(key_bindings[classickeytobind], kb.name)
addedbind = TRUE
if(!addedbind)
notadded += kb
save_preferences() //Save the players pref so that new keys that were set to Unbound as default are permanently stored
if(length(notadded))
addtimer(CALLBACK(src, .proc/announce_conflict, notadded), 5 SECONDS)
@@ -132,6 +133,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
var/datum/keybinding/conflicted = item
to_chat(parent, "<span class='danger'>[conflicted.category]: [conflicted.full_name] needs updating</span>")
LAZYADD(key_bindings["Unbound"], conflicted.name) // set it to unbound to prevent this from opening up again in the future
save_preferences()