From 29302c51edd5513a0c7d024ec7bd0f43e0401062 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Thu, 4 Jun 2020 22:58:42 -0700 Subject: [PATCH 1/9] ok --- code/modules/client/preferences.dm | 54 ++++++++++++-------- code/modules/client/preferences_savefile.dm | 12 ++++- code/modules/keybindings/bindings_client.dm | 5 ++ code/modules/keybindings/keybind/_keybind.dm | 2 + 4 files changed, 51 insertions(+), 22 deletions(-) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index c0ac79e449..0a7d838aa2 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -50,6 +50,8 @@ GLOBAL_LIST_EMPTY(preferences_datums) /// Custom Keybindings var/list/key_bindings = list() + /// 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 @@ -1098,6 +1100,8 @@ GLOBAL_LIST_EMPTY(preferences_datums) Input mode is the closest thing to the old input system.
\ IMPORTANT: While in input mode's non hotkey setting (tab toggled), Ctrl + KEY will send KEY to the keybind system as the key itself, not as Ctrl + KEY. This means Ctrl + T/W/A/S/D/all your familiar stuff still works, but you \ won't be able to access any regular Ctrl binds.
" + dat += "
Modifier-Independent binding - This is a singular bind that works regardless of if Ctrl/Shift/Alt are held down. For example, if combat mode is bound to C in modifier-independent binds, it'll trigger regardless of if you are \ + holding down shift for sprint. Each keybind can only have one independent binding, and each key can only have one keybind independently bound to it." // Create an inverted list of keybindings -> key var/list/user_binds = list() for (var/key in key_bindings) @@ -1110,21 +1114,23 @@ GLOBAL_LIST_EMPTY(preferences_datums) var/datum/keybinding/kb = GLOB.keybindings_by_name[name] kb_categories[kb.category] += list(kb) - dat += "" + dat += "" for (var/category in kb_categories) dat += "

[category]

" for (var/i in kb_categories[category]) var/datum/keybinding/kb = i + var/current_independent_binding = modless_key_bindings[kb.name] || "Unbound" if(!length(user_binds[kb.name])) - dat += " Unbound" + dat += "[kb.full_name] Unbound" var/list/default_keys = hotkeys ? kb.hotkey_keys : kb.classic_keys if(LAZYLEN(default_keys)) dat += "| Default: [default_keys.Join(", ")]" + dat += "Independent Binding: [current_independent_binding]" dat += "
" else var/bound_key = user_binds[kb.name][1] - dat += " [bound_key]" + dat += "[kb.full_name] [bound_key]" for(var/bound_key_index in 2 to length(user_binds[kb.name])) bound_key = user_binds[kb.name][bound_key_index] dat += " | [bound_key]" @@ -1133,6 +1139,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) var/list/default_keys = hotkeys ? kb.classic_keys : kb.hotkey_keys if(LAZYLEN(default_keys)) dat += "| Default: [default_keys.Join(", ")]" + dat += "Independent Binding: [current_independent_binding]" dat += "
" dat += "

" @@ -1158,7 +1165,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) #undef APPEARANCE_CATEGORY_COLUMN #undef MAX_MUTANT_ROWS -/datum/preferences/proc/CaptureKeybinding(mob/user, datum/keybinding/kb, var/old_key) +/datum/preferences/proc/CaptureKeybinding(mob/user, datum/keybinding/kb, old_key, independent = FALSE) var/HTML = {"
Keybinding: [kb.full_name]
[kb.description]

Press any key to change
Press ESC to clear