From 564766d11d93b7666be62f08164dfb1b6766e786 Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Fri, 27 Nov 2020 00:16:53 -0700 Subject: [PATCH] sigh --- code/modules/client/preferences.dm | 11 +++-- code/modules/client/preferences_savefile.dm | 4 +- code/modules/keybindings/setup.dm | 49 +++++++++++++++++---- 3 files changed, 47 insertions(+), 17 deletions(-) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 6993b6dfac..250a9de8a4 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -53,7 +53,6 @@ GLOBAL_LIST_EMPTY(preferences_datums) /// List with a key string associated to a list of keybindings. Unlike key_bindings, this one operates on raw key, allowing for binding a key that triggers regardless of if a modifier is depressed as long as the raw key is sent. var/list/modless_key_bindings = list() - var/tgui_fancy = TRUE var/tgui_lock = TRUE var/windowflashing = TRUE @@ -219,7 +218,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) //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. key_bindings = deepCopyList(GLOB.hotkey_keybinding_list_by_key) // give them default keybinds and update their movement keys - C?.full_macro_assert() + C?.ensure_keys_set() real_name = pref_species.random_name(gender,1) if(!loaded_preferences_successfully) save_preferences() @@ -2382,7 +2381,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) if(!length(key_bindings[old_key])) key_bindings -= old_key user << browse(null, "window=capturekeypress") - user.client.full_macro_assert() + user.client.ensure_keys_set() save_preferences() ShowChoices(user) return @@ -2417,7 +2416,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) key_bindings -= old_key key_bindings[full_key] += list(kb_name) key_bindings[full_key] = sortList(key_bindings[full_key]) - user.client.full_macro_assert() + user.client.ensure_keys_set() user << browse(null, "window=capturekeypress") save_preferences() @@ -2429,7 +2428,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) hotkeys = (choice == "Hotkey") key_bindings = (hotkeys) ? deepCopyList(GLOB.hotkey_keybinding_list_by_key) : deepCopyList(GLOB.classic_keybinding_list_by_key) modless_key_bindings = list() - user.client.full_macro_assert() + user.client.ensure_keys_set() if("chat_on_map") chat_on_map = !chat_on_map @@ -2843,7 +2842,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) for(var/key in oldkeys) if(!key_bindings[key]) key_bindings[key] = oldkeys[key] - parent.full_macro_assert(src) + parent.ensure_keys_set(src) /datum/preferences/proc/is_loadout_slot_available(slot) var/list/L diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index d3ef50d45a..acc24b13bd 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 45 +#define SAVEFILE_VERSION_MAX 46 /* SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn @@ -42,7 +42,7 @@ 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) - if(current_version < 45) //If you remove this, remove force_reset_keybindings() too. + if(current_version < 46) //If you remove this, remove force_reset_keybindings() too. force_reset_keybindings_direct(TRUE) addtimer(CALLBACK(src, .proc/force_reset_keybindings), 30) //No mob available when this is run, timer allows user choice. diff --git a/code/modules/keybindings/setup.dm b/code/modules/keybindings/setup.dm index 635db4bca1..3946ad77e1 100644 --- a/code/modules/keybindings/setup.dm +++ b/code/modules/keybindings/setup.dm @@ -38,7 +38,7 @@ apply_macro_set(SKIN_MACROSET_CLASSIC_HOTKEYS, SSinput.macroset_classic_hotkey) apply_macro_set(SKIN_MACROSET_CLASSIC_INPUT, SSinput.macroset_classic_input) - set_hotkeys_preference() + set_hotkeys_preference(prefs_override) /client/proc/set_hotkeys_preference(datum/preferences/prefs_override = prefs) if(prefs_override.hotkeys) @@ -54,6 +54,37 @@ set_macros(prefs_override) update_special_keybinds(prefs_override) +/* +/datum/controller/subsystem/input + /** KEEP THIS UP TO DATE WITH update_special_keybinds! + * We use this list to detect when to avoid binding a key twice. + */ + var/list/special_keybinds = list("North", "East", "West", "South", "Say", "OOC", "Me", "Subtle", "Subtler", "Whisper", "LOOC") + +/datum/preferences/proc/get_all_keys_for_special_keybinds() + for(var/key in key_bindings) +*/ + +/client/proc/do_special_keybind(key, command) + var/alt = findtext(key, "Alt") + if(alt) + key = copytext(key, 1, alt) + copytext(key, alt + 3, 0) + var/ctrl = findtext(key, "Ctrl") + if(ctrl) + key = copytext(key, 1, ctrl) + copytext(key, ctrl + 4, 0) + var/shift = findtext(key, "Shift") + if(shift) + key = copytext(key, 1, shift) + copytext(key, shift + 5, 0) + key = "[alt? "Alt+":""][ctrl? "Ctrl+":""][shift? "Shift+":""][key]" + /// KEEP THIS UP TO DATE! + var/static/list/all_macrosets = list( + SKIN_MACROSET_HOTKEYS, + SKIN_MACROSET_CLASSIC_HOTKEYS, + SKIN_MACROSET_CLASSIC_INPUT + ) + for(var/macroset in all_macrosets) + winset(src, "[macroset]-[REF(key)]", "parent=[macroset];name=[key];command=[command]") + /** * Updates the keybinds for special keys * @@ -64,7 +95,7 @@ * * direct_prefs - the preference we're going to get keybinds from */ /client/proc/update_special_keybinds(datum/preferences/direct_prefs) - var/datum/preferences/D = prefs || direct_prefs + var/datum/preferences/D = direct_prefs || prefs if(!D?.key_bindings) return movement_keys = list() @@ -80,16 +111,16 @@ if("South") movement_keys[key] = SOUTH if("Say") - winset(src, "default-[REF(key)]", "parent=default;name=[key];command=say") + do_special_keybind(key, "say") if("OOC") - winset(src, "default-[REF(key)]", "parent=default;name=[key];command=ooc") + do_special_keybind(key, "OOC") if("Me") - winset(src, "default-[REF(key)]", "parent=default;name=[key];command=me") + do_special_keybind(key, "me") if("Subtle") - winset(src, "default-[REF(key)]", "parent=default;name=[key];command=subtle") + do_special_keybind(key, "subtle") if("Subtler") - winset(src, "default-[REF(key)]", "parent=default;name=[key];command=subtler") + do_special_keybind(key, "Subtler-Anti-Ghost") if("Whisper") - winset(src, "default-[REF(key)]", "parent=default;name=[key];command=whisper") + do_special_keybind(key, "whisper") if("LOOC") - winset(src, "default-[REF(key)]", "parent=default;name=[key];command=looc") + do_special_keybind(key, "LOOC")