diff --git a/code/modules/client/tgui_macro.dm b/code/modules/client/tgui_macro.dm index d441cfcb662f6..43bfe235f73e6 100644 --- a/code/modules/client/tgui_macro.dm +++ b/code/modules/client/tgui_macro.dm @@ -10,6 +10,16 @@ GLOBAL_LIST_EMPTY(ui_data_keybindings) "classic" = kb.classic_keys, )) +/proc/keybind_to_keyboardMap(keybind, list/mods) + var/list/tempList = list() + for(var/i in mods) + tempList += GLOB._kbMap[i] + if(GLOB._kbMap[keybind]) + tempList += GLOB._kbMap[keybind] + else + tempList += keybind + return tempList.Join("+") + /datum/tgui_macro var/client/owner var/datum/preferences/prefs @@ -66,12 +76,6 @@ GLOBAL_LIST_EMPTY(ui_data_keybindings) var/old_key = params["old_key"] - var/mods = sortList(params["key_mods"]).Join("+") - - var/full_key = params["key"] - if(mods) - full_key = "[mods]+[full_key]" - if(!params["key"]) if(kbinds[old_key]) kbinds[old_key] -= kb_name @@ -82,17 +86,7 @@ GLOBAL_LIST_EMPTY(ui_data_keybindings) prefs.save_preferences() return - var/list/tempList = list() - for(var/i in splittext(full_key, "+")) - if(full_key == "+") - i = "+" //we split by + so empty means input was + - tempList += GLOB._kbMap[i] - break - if(GLOB._kbMap[i]) - tempList += GLOB._kbMap[i] - else - tempList += i - full_key = tempList.Join("+") + var/full_key = keybind_to_keyboardMap(params["key"], params["key_mods"]) if(kb_name in kbinds[full_key]) //We pressed the same key combination that was already bound here, so let's remove to re-add and re-sort. kbinds[full_key] -= kb_name @@ -139,10 +133,9 @@ GLOBAL_LIST_EMPTY(ui_data_keybindings) var/keybind_type = params["keybind_type"] if(!(keybind_type in list(KEYBIND_TYPE_SAY, KEYBIND_TYPE_ME, KEYBIND_TYPE_PICKSAY))) return TRUE - - var/keybind = params["keybind"] + var/keybind = keybind_to_keyboardMap(params["key"], params["key_mods"]) if(!keybind) - return TRUE + keybind = params["keybind"] var/contents = params["contents"] @@ -168,9 +161,6 @@ GLOBAL_LIST_EMPTY(ui_data_keybindings) contents = jointext(contents, ", ") contents = strip_html(contents, MAX_MESSAGE_LEN) - for(var/i in GLOB._kbMap) - keybind = replacetext(keybind, i, GLOB._kbMap[i]) - var/when_human = sanitize_integer(params["when_human"], FALSE, TRUE, TRUE) var/when_xeno = sanitize_integer(params["when_xeno"], FALSE, TRUE, TRUE) var/when_yautja = sanitize_integer(params["when_yautja"], FALSE, TRUE, TRUE) diff --git a/tgui/packages/tgui/interfaces/KeyBinds.tsx b/tgui/packages/tgui/interfaces/KeyBinds.tsx index d5ddf8cf07681..e7eec2f3962bc 100644 --- a/tgui/packages/tgui/interfaces/KeyBinds.tsx +++ b/tgui/packages/tgui/interfaces/KeyBinds.tsx @@ -63,6 +63,8 @@ type Data = { type CustomKeybind = { keybinding?: string; + key?: string; + key_mods?: string; type?: string; contents?: string | string[]; when_xeno?: boolean; @@ -503,12 +505,16 @@ const CustomKeybinds = (props: { return { ...keybind, keybinding: kb, + key: keys[0], + key_mods: mods, }; } return { ...pending, keybinding: kb, + key: keys[0], + key_mods: mods, }; }); }} @@ -631,6 +637,8 @@ const CustomKeybinds = (props: { act('set_custom_keybinds', { index: index + 1, keybind: pendingKeybind.keybinding, + key: pendingKeybind.key, + key_mods: pendingKeybind.key_mods, keybind_type: pendingKeybind.type?.toLowerCase(), contents: pendingKeybind.contents, when_xeno: pendingKeybind.when_xeno ?? false,