From 0b4d5918b92bc6719b7d5b9c49be8790bd55c1d6 Mon Sep 17 00:00:00 2001 From: Coul Date: Fri, 15 Nov 2019 03:46:31 -0500 Subject: [PATCH] keybindings save file fix --- code/modules/client/preferences.dm | 15 +++------------ code/modules/client/preferences_savefile.dm | 14 +++++--------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 57ce866f112..b8988242aa8 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -27,7 +27,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) var/UI_style = null var/buttons_locked = FALSE - var/hotkeys = FALSE + var/hotkeys = TRUE // Custom Keybindings var/list/key_bindings = list() @@ -128,7 +128,8 @@ GLOBAL_LIST_EMPTY(preferences_datums) return //we couldn't load character data so just randomize the character appearance + name random_character() //let's create a random character then - rather than a fat, bald and naked man. - addtimer(CALLBACK(src, .proc/load_default_keybindings, C), 5 SECONDS) + key_bindings = deepCopyList(GLOB.hotkey_keybinding_list_by_key) // give them default keybinds and update their movement keys + C.update_movement_keys() real_name = pref_species.random_name(gender,1) if(!loaded_preferences_successfully) save_preferences() @@ -136,16 +137,6 @@ GLOBAL_LIST_EMPTY(preferences_datums) menuoptions = list() return - -/datum/preferences/proc/load_default_keybindings(client/C) - if(QDELETED(C)) - return - to_chat(C, "Empty keybindings, setting default to hotkey mode") - hotkeys = TRUE - key_bindings = deepCopyList(GLOB.hotkey_keybinding_list_by_key) - C.update_movement_keys() - save_preferences() - #define APPEARANCE_CATEGORY_COLUMN "" #define MAX_MUTANT_ROWS 4 diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index a811f7bd8df..7f97c6defbd 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -5,7 +5,7 @@ // You do not need to raise this if you are adding new values that have sane defaults. // Only raise this value when changing the meaning/format/name/layout of an existing value // where you would want the updater procs below to run -#define SAVEFILE_VERSION_MAX 28 +#define SAVEFILE_VERSION_MAX 29 /* SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn @@ -42,7 +42,10 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car //if your savefile is 3 months out of date, then 'tough shit'. /datum/preferences/proc/update_preferences(current_version, savefile/S) - return + if(current_version < 29) + key_bindings = (hotkeys) ? deepCopyList(GLOB.hotkey_keybinding_list_by_key) : deepCopyList(GLOB.classic_keybinding_list_by_key) + parent.update_movement_keys() + to_chat(parent, "Empty keybindings, setting default to [hotkeys ? "Hotkeys" : "Classic"] mode") /datum/preferences/proc/update_character(current_version, savefile/S) if(current_version < 19) @@ -126,9 +129,6 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car S["hair_style_name"] >> hairstyle if(S["facial_style_name"]) S["facial_style_name"] >> facial_hairstyle - - if(current_version < 28) - WRITE_FILE(S["key_bindings"], null) /datum/preferences/proc/load_path(ckey,filename="preferences.sav") if(!ckey) @@ -220,10 +220,6 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car pda_color = sanitize_hexcolor(pda_color, 6, 1, initial(pda_color)) key_bindings = sanitize_islist(key_bindings, list()) - if(!length(key_bindings)) - key_bindings = (hotkeys) ? deepCopyList(GLOB.hotkey_keybinding_list_by_key) : deepCopyList(GLOB.classic_keybinding_list_by_key) - parent.update_movement_keys() - addtimer(CALLBACK(src, .proc/load_default_keybindings, parent), 5 SECONDS) return TRUE