From f73d8a2bae2e2ab5060c243b78e394cc0be5d551 Mon Sep 17 00:00:00 2001 From: Gamer025 <33846895+Gamer025@users.noreply.github.com> Date: Sat, 5 Jun 2021 15:55:33 +0200 Subject: [PATCH] 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 --- code/datums/keybinding/emote.dm | 1 + code/modules/client/preferences_savefile.dm | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/code/datums/keybinding/emote.dm b/code/datums/keybinding/emote.dm index 5d6e7895ed9..157a45af51f 100644 --- a/code/datums/keybinding/emote.dm +++ b/code/datums/keybinding/emote.dm @@ -6,6 +6,7 @@ /datum/keybinding/emote/proc/link_to_emote(datum/emote/faketype) hotkey_keys = list("Unbound") + classic_keys = list("Unbound") emote_key = initial(faketype.key) name = initial(faketype.key) full_name = capitalize(initial(faketype.key)) diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 3bdda004e13..651750b1ef4 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -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, "[conflicted.category]: [conflicted.full_name] needs updating") LAZYADD(key_bindings["Unbound"], conflicted.name) // set it to unbound to prevent this from opening up again in the future + save_preferences()