From 60077f028e82e5d63bbfe753074952d16da56232 Mon Sep 17 00:00:00 2001 From: timothyteakettle <59849408+timothyteakettle@users.noreply.github.com> Date: Tue, 17 Nov 2020 01:41:19 +0000 Subject: [PATCH 01/15] port --- code/controllers/subsystem/input.dm | 11 ++--------- code/modules/client/client_procs.dm | 18 ++++++++++++++++-- code/modules/client/preferences.dm | 10 ++++++---- code/modules/keybindings/keybind/__defines.dm | 1 + .../keybindings/keybind/communication.dm | 17 +++++++++++++++++ code/modules/keybindings/setup.dm | 1 + tgstation.dme | 1 + 7 files changed, 44 insertions(+), 15 deletions(-) create mode 100644 code/modules/keybindings/keybind/communication.dm diff --git a/code/controllers/subsystem/input.dm b/code/controllers/subsystem/input.dm index bc3f6cf51b..203c6e3646 100644 --- a/code/controllers/subsystem/input.dm +++ b/code/controllers/subsystem/input.dm @@ -52,10 +52,7 @@ SUBSYSTEM_DEF(input) for(var/i in 65 to 90) classic_ctrl_override_keys += ascii2text(i) // let's play the game of clientside bind overrides! - classic_ctrl_override_keys -= list("T", "O", "M", "L") - macroset_classic_input["Ctrl+T"] = "say" - macroset_classic_input["Ctrl+O"] = "ooc" - macroset_classic_input["Ctrl+L"] = "looc" + classic_ctrl_override_keys -= list("M") // let's play the list iteration game x2 for(var/key in classic_ctrl_override_keys) // make sure to double double quote to ensure things are treated as a key combo instead of addition/semicolon logic. @@ -70,10 +67,7 @@ SUBSYSTEM_DEF(input) // HAHA - SIKE. Because of BYOND weirdness (tl;dr not specifically binding this way results in potentially duplicate chatboxes when // conflicts occur with something like say indicator vs say), we're going to snowflake this anyways var/list/hard_binds = list( - "O" = "ooc", - "T" = "say", - "L" = "looc", - "M" = "me" + "L" = "looc" ) var/list/hard_bind_anti_collision = list() var/list/anti_collision_modifiers = list("Ctrl", "Alt", "Shift", "Ctrl+Alt", "Ctrl+Shift", "Alt+Shift", "Ctrl+Alt+Shift") @@ -110,7 +104,6 @@ SUBSYSTEM_DEF(input) for(var/i in 1 to clients.len) var/client/user = clients[i] user.set_macros() - user.update_movement_keys() /datum/controller/subsystem/input/fire() var/list/clients = GLOB.clients // Let's sing the list cache song diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index c581e402a6..660e4ccdbe 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -478,7 +478,6 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( /client/proc/ensure_keys_set() if(SSinput.initialized) set_macros() - update_movement_keys(prefs) ////////////// //DISCONNECT// @@ -937,7 +936,16 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( y = clamp(y+change, min,max) view_size.setDefault("[x]x[y]") -/client/proc/update_movement_keys(datum/preferences/direct_prefs) +/** + * Updates the keybinds for special keys + * + * Handles adding macros for the keys that need it + * And adding movement keys to the clients movement_keys list + * At the time of writing this, communication(OOC, Say, IC) require macros + * Arguments: + * * 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 if(!D?.key_bindings) return @@ -953,6 +961,12 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( movement_keys[key] = WEST if("South") movement_keys[key] = SOUTH + if("Say") + winset(src, "default-[REF(key)]", "parent=default;name=[key];command=say") + if("OOC") + winset(src, "default-[REF(key)]", "parent=default;name=[key];command=ooc") + if("Me") + winset(src, "default-[REF(key)]", "parent=default;name=[key];command=me") /client/proc/change_view(new_size) if (isnull(new_size)) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 196c1ce0ed..dfa7dc8a0d 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -284,7 +284,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?.update_movement_keys(src) + C?.set_macros() real_name = pref_species.random_name(gender,1) if(!loaded_preferences_successfully) save_preferences() @@ -2370,9 +2370,11 @@ GLOBAL_LIST_EMPTY(preferences_datums) else if(key_bindings[old_key]) key_bindings[old_key] -= kb_name + LAZYADD(key_bindings["Unbound"], kb_name) if(!length(key_bindings[old_key])) key_bindings -= old_key user << browse(null, "window=capturekeypress") + user.client.set_macros() save_preferences() ShowChoices(user) return @@ -2407,7 +2409,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.update_movement_keys() + user.client.set_macros() user << browse(null, "window=capturekeypress") save_preferences() @@ -2419,7 +2421,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.update_movement_keys() + user.client.set_macros() if("chat_on_map") chat_on_map = !chat_on_map @@ -2831,7 +2833,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) for(var/key in oldkeys) if(!key_bindings[key]) key_bindings[key] = oldkeys[key] - parent.update_movement_keys() + parent.update_special_keybinds() /datum/preferences/proc/is_loadout_slot_available(slot) var/list/L diff --git a/code/modules/keybindings/keybind/__defines.dm b/code/modules/keybindings/keybind/__defines.dm index 93d033eea5..23538ac441 100644 --- a/code/modules/keybindings/keybind/__defines.dm +++ b/code/modules/keybindings/keybind/__defines.dm @@ -9,6 +9,7 @@ #define CATEGORY_MOVEMENT "MOVEMENT" #define CATEGORY_TARGETING "TARGETING" #define CATEGORY_COMBAT "COMBAT" +#define CATEGORY_COMMUNICATION "COMMUNICATION" #define WEIGHT_HIGHEST 0 #define WEIGHT_ADMIN 10 diff --git a/code/modules/keybindings/keybind/communication.dm b/code/modules/keybindings/keybind/communication.dm new file mode 100644 index 0000000000..d46d6523d7 --- /dev/null +++ b/code/modules/keybindings/keybind/communication.dm @@ -0,0 +1,17 @@ +/datum/keybinding/client/communication + category = CATEGORY_COMMUNICATION + +/datum/keybinding/client/communication/say + hotkey_keys = list("T") + name = "Say" + full_name = "IC Say" + +/datum/keybinding/client/communication/ooc + hotkey_keys = list("O") + name = "OOC" + full_name = "Out Of Character Say (OOC)" + +/datum/keybinding/client/communication/me + hotkey_keys = list("M") + name = "Me" + full_name = "Custom Emote (/Me)" diff --git a/code/modules/keybindings/setup.dm b/code/modules/keybindings/setup.dm index 47dbfd855f..c361074559 100644 --- a/code/modules/keybindings/setup.dm +++ b/code/modules/keybindings/setup.dm @@ -25,6 +25,7 @@ var/key = macroset[i] var/command = macroset[key] winset(src, "[name]-[REF(key)]", "parent=[name];name=[key];command=[command]") + update_special_keybinds() /client/proc/set_macros(datum/preferences/prefs_override = prefs) set waitfor = FALSE diff --git a/tgstation.dme b/tgstation.dme index 2008f39c3d..50f85ef993 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -2298,6 +2298,7 @@ #include "code\modules\keybindings\keybind\carbon.dm" #include "code\modules\keybindings\keybind\client.dm" #include "code\modules\keybindings\keybind\combat.dm" +#include "code\modules\keybindings\keybind\communication.dm" #include "code\modules\keybindings\keybind\emote.dm" #include "code\modules\keybindings\keybind\human.dm" #include "code\modules\keybindings\keybind\living.dm" From 0c65359f421eab6ba5683447e90061bc0554aa3e Mon Sep 17 00:00:00 2001 From: Timothy Teakettle <59849408+timothyteakettle@users.noreply.github.com> Date: Sun, 22 Nov 2020 00:00:24 +0000 Subject: [PATCH 02/15] functionality --- .../keybindings/keybind/communication.dm | 39 +++++++++++++++++++ code/modules/keybindings/keybind/mob.dm | 22 ----------- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/code/modules/keybindings/keybind/communication.dm b/code/modules/keybindings/keybind/communication.dm index d46d6523d7..d93125710e 100644 --- a/code/modules/keybindings/keybind/communication.dm +++ b/code/modules/keybindings/keybind/communication.dm @@ -6,12 +6,51 @@ name = "Say" full_name = "IC Say" +/datum/keybinding/client/communication/say/down(client/user) + var/mob/M = user.mob + var/speech = input(user, "", "say") + M.say_verb(speech) + /datum/keybinding/client/communication/ooc hotkey_keys = list("O") name = "OOC" full_name = "Out Of Character Say (OOC)" +/datum/keybinding/client/communication/ooc/down(client/user) + var/speech = input(user, "", "OOC") + user.ooc(speech) + return TRUE + /datum/keybinding/client/communication/me hotkey_keys = list("M") name = "Me" full_name = "Custom Emote (/Me)" + +/datum/keybinding/client/communication/me/down(client/user) + var/mob/M = user.mob + var/emote = input(user, "", "Me") + M.me_verb(emote) + return TRUE + +//indicators +/datum/keybinding/mob/say_with_indicator + hotkey_keys = list("CtrlT") + classic_keys = list() + name = "say_with_indicator" + full_name = "Say with Typing Indicator" + +/datum/keybinding/mob/say_with_indicator/down(client/user) + var/mob/M = user.mob + M.say_typing_indicator() + return TRUE + +/datum/keybinding/mob/me_with_indicator + hotkey_keys = list("CtrlM") + classic_keys = list() + name = "me_with_indicator" + full_name = "Me (emote) with Typing Indicator" + +/datum/keybinding/mob/me_with_indicator/down(client/user) + var/mob/M = user.mob + M.me_typing_indicator() + return TRUE \ No newline at end of file diff --git a/code/modules/keybindings/keybind/mob.dm b/code/modules/keybindings/keybind/mob.dm index c19fd62dee..6d88b53714 100644 --- a/code/modules/keybindings/keybind/mob.dm +++ b/code/modules/keybindings/keybind/mob.dm @@ -77,28 +77,6 @@ user.mob.dropItemToGround(I) return TRUE -/datum/keybinding/mob/say_with_indicator - hotkey_keys = list("CtrlT") - classic_keys = list() - name = "say_with_indicator" - full_name = "Say with Typing Indicator" - -/datum/keybinding/mob/say_with_indicator/down(client/user) - var/mob/M = user.mob - M.say_typing_indicator() - return TRUE - -/datum/keybinding/mob/me_with_indicator - hotkey_keys = list("CtrlM") - classic_keys = list() - name = "me_with_indicator" - full_name = "Me (emote) with Typing Indicator" - -/datum/keybinding/mob/me_with_indicator/down(client/user) - var/mob/M = user.mob - M.me_typing_indicator() - return TRUE - /datum/keybinding/living/subtle hotkey_keys = list("5") classic_keys = list() From 5de801ac40b396add616673547ab91cfdd4441da Mon Sep 17 00:00:00 2001 From: Timothy Teakettle <59849408+timothyteakettle@users.noreply.github.com> Date: Sun, 22 Nov 2020 21:08:58 +0000 Subject: [PATCH 03/15] communication hotkeys --- code/modules/client/preferences_savefile.dm | 10 +++++++++ .../keybindings/keybind/communication.dm | 22 +++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 64e49fea8d..7989e818f5 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -226,6 +226,16 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car left_eye_color = "#BAB99E" right_eye_color = "#BAB99E" + if(current_version < 5000) + var/ctrl_t_binding = S["key_bindings"]["CtrlT"] + var/ctrl_m_binding = S["key_bindings"]["CtrlM"] + if(length(ctrl_t_binding) && "say_with_indicator" in ctrl_t_binding) + S["key_bindings"]["T"] = "say_with_indicator" + S["key_bindings"]["CtrlT"] = "say" + if(length(ctrl_m_binding) && "me_with_indicator" in ctrl_m_binding) + S["key_bindings"]["M"] = "me_with_indicator" + S["key_bindings"]["CtrlM"] = "me" + /datum/preferences/proc/load_path(ckey,filename="preferences.sav") if(!ckey) return diff --git a/code/modules/keybindings/keybind/communication.dm b/code/modules/keybindings/keybind/communication.dm index d93125710e..f3a7028c58 100644 --- a/code/modules/keybindings/keybind/communication.dm +++ b/code/modules/keybindings/keybind/communication.dm @@ -2,8 +2,8 @@ category = CATEGORY_COMMUNICATION /datum/keybinding/client/communication/say - hotkey_keys = list("T") - name = "Say" + hotkey_keys = list("CtrlT") + name = "say" full_name = "IC Say" /datum/keybinding/client/communication/say/down(client/user) @@ -22,9 +22,9 @@ return TRUE /datum/keybinding/client/communication/me - hotkey_keys = list("M") - name = "Me" - full_name = "Custom Emote (/Me)" + hotkey_keys = list("CtrlM") + name = "me" + full_name = "Me (emote)" /datum/keybinding/client/communication/me/down(client/user) var/mob/M = user.mob @@ -33,24 +33,24 @@ return TRUE //indicators -/datum/keybinding/mob/say_with_indicator - hotkey_keys = list("CtrlT") +/datum/keybinding/client/communication/say_with_indicator + hotkey_keys = list("T") classic_keys = list() name = "say_with_indicator" full_name = "Say with Typing Indicator" -/datum/keybinding/mob/say_with_indicator/down(client/user) +/datum/keybinding/client/communication/say_with_indicator/down(client/user) var/mob/M = user.mob M.say_typing_indicator() return TRUE -/datum/keybinding/mob/me_with_indicator - hotkey_keys = list("CtrlM") +/datum/keybinding/client/communication/me_with_indicator + hotkey_keys = list("M") classic_keys = list() name = "me_with_indicator" full_name = "Me (emote) with Typing Indicator" -/datum/keybinding/mob/me_with_indicator/down(client/user) +/datum/keybinding/client/communication/me_with_indicator/down(client/user) var/mob/M = user.mob M.me_typing_indicator() return TRUE \ No newline at end of file From 8d41c15b75d4ddc97c9aba20138a9ab9863704a7 Mon Sep 17 00:00:00 2001 From: Timothy Teakettle <59849408+timothyteakettle@users.noreply.github.com> Date: Sun, 22 Nov 2020 21:42:14 +0000 Subject: [PATCH 04/15] webedit adds spaces for some reason --- code/modules/client/preferences_savefile.dm | 20 ++++++++++---------- tgstation.dme | 2 -- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 69f9f0bb98..dbec162247 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -265,19 +265,19 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car var/ctrl_t_binding = S["key_bindings"]["CtrlT"] var/ctrl_m_binding = S["key_bindings"]["CtrlM"] if(length(ctrl_t_binding) && "say_with_indicator" in ctrl_t_binding) - if(!length(S["key_bindings"]["T"])) - S["key_bindings"]["T"] = list("say_with_indicator") - else - S["key_bindings"]["T"] += "say_with_indicator" + if(!length(S["key_bindings"]["T"])) + S["key_bindings"]["T"] = list("say_with_indicator") + else + S["key_bindings"]["T"] += "say_with_indicator" S["key_bindings"]["CtrlT"] -= "say_with_indicator" - S["key_bindings"]["CtrlT"] += "say" + S["key_bindings"]["CtrlT"] += "say" if(length(ctrl_m_binding) && "me_with_indicator" in ctrl_m_binding) - if(!length(S["key_bindings"]["M"]) - S["key_bindings"]["M"] = list("me_with_indicator") - else - S["key_bindings"]["M"] += "me_with_indicator" + if(!length(S["key_bindings"]["M"]) + S["key_bindings"]["M"] = list("me_with_indicator") + else + S["key_bindings"]["M"] += "me_with_indicator" S["key_bindings"]["CtrlM"] -= "me_with_indicator" - S["key_bindings"]["CtrlM"] == "me" + S["key_bindings"]["CtrlM"] == "me" /datum/preferences/proc/load_path(ckey,filename="preferences.sav") if(!ckey) diff --git a/tgstation.dme b/tgstation.dme index 1387748839..50f85ef993 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -2496,7 +2496,6 @@ #include "code\modules\mob\living\carbon\death.dm" #include "code\modules\mob\living\carbon\emote.dm" #include "code\modules\mob\living\carbon\examine.dm" -#include "code\modules\mob\living\carbon\handle_corruption.dm" #include "code\modules\mob\living\carbon\inventory.dm" #include "code\modules\mob\living\carbon\life.dm" #include "code\modules\mob\living\carbon\say.dm" @@ -3420,7 +3419,6 @@ #include "code\modules\surgery\organic_steps.dm" #include "code\modules\surgery\plastic_surgery.dm" #include "code\modules\surgery\prosthetic_replacement.dm" -#include "code\modules\surgery\purge_corruption.dm" #include "code\modules\surgery\remove_embedded_object.dm" #include "code\modules\surgery\repair_puncture.dm" #include "code\modules\surgery\robot_brain_surgery.dm" From a976d423051d127c3c19acea91d8aa8bfe3696fb Mon Sep 17 00:00:00 2001 From: Timothy Teakettle <59849408+timothyteakettle@users.noreply.github.com> Date: Sun, 22 Nov 2020 21:42:36 +0000 Subject: [PATCH 05/15] Revert "webedit adds spaces for some reason" This reverts commit 8d41c15b75d4ddc97c9aba20138a9ab9863704a7. --- code/modules/client/preferences_savefile.dm | 20 ++++++++++---------- tgstation.dme | 2 ++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index dbec162247..69f9f0bb98 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -265,19 +265,19 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car var/ctrl_t_binding = S["key_bindings"]["CtrlT"] var/ctrl_m_binding = S["key_bindings"]["CtrlM"] if(length(ctrl_t_binding) && "say_with_indicator" in ctrl_t_binding) - if(!length(S["key_bindings"]["T"])) - S["key_bindings"]["T"] = list("say_with_indicator") - else - S["key_bindings"]["T"] += "say_with_indicator" + if(!length(S["key_bindings"]["T"])) + S["key_bindings"]["T"] = list("say_with_indicator") + else + S["key_bindings"]["T"] += "say_with_indicator" S["key_bindings"]["CtrlT"] -= "say_with_indicator" - S["key_bindings"]["CtrlT"] += "say" + S["key_bindings"]["CtrlT"] += "say" if(length(ctrl_m_binding) && "me_with_indicator" in ctrl_m_binding) - if(!length(S["key_bindings"]["M"]) - S["key_bindings"]["M"] = list("me_with_indicator") - else - S["key_bindings"]["M"] += "me_with_indicator" + if(!length(S["key_bindings"]["M"]) + S["key_bindings"]["M"] = list("me_with_indicator") + else + S["key_bindings"]["M"] += "me_with_indicator" S["key_bindings"]["CtrlM"] -= "me_with_indicator" - S["key_bindings"]["CtrlM"] == "me" + S["key_bindings"]["CtrlM"] == "me" /datum/preferences/proc/load_path(ckey,filename="preferences.sav") if(!ckey) diff --git a/tgstation.dme b/tgstation.dme index 50f85ef993..1387748839 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -2496,6 +2496,7 @@ #include "code\modules\mob\living\carbon\death.dm" #include "code\modules\mob\living\carbon\emote.dm" #include "code\modules\mob\living\carbon\examine.dm" +#include "code\modules\mob\living\carbon\handle_corruption.dm" #include "code\modules\mob\living\carbon\inventory.dm" #include "code\modules\mob\living\carbon\life.dm" #include "code\modules\mob\living\carbon\say.dm" @@ -3419,6 +3420,7 @@ #include "code\modules\surgery\organic_steps.dm" #include "code\modules\surgery\plastic_surgery.dm" #include "code\modules\surgery\prosthetic_replacement.dm" +#include "code\modules\surgery\purge_corruption.dm" #include "code\modules\surgery\remove_embedded_object.dm" #include "code\modules\surgery\repair_puncture.dm" #include "code\modules\surgery\robot_brain_surgery.dm" From 5075aec151980a61beac25833111f30d05a896b9 Mon Sep 17 00:00:00 2001 From: Timothy Teakettle <59849408+timothyteakettle@users.noreply.github.com> Date: Sun, 22 Nov 2020 21:43:15 +0000 Subject: [PATCH 06/15] webedit adds spaces for some reason --- code/modules/client/preferences_savefile.dm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 69f9f0bb98..206239fa63 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -265,19 +265,19 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car var/ctrl_t_binding = S["key_bindings"]["CtrlT"] var/ctrl_m_binding = S["key_bindings"]["CtrlM"] if(length(ctrl_t_binding) && "say_with_indicator" in ctrl_t_binding) - if(!length(S["key_bindings"]["T"])) - S["key_bindings"]["T"] = list("say_with_indicator") - else - S["key_bindings"]["T"] += "say_with_indicator" + if(!length(S["key_bindings"]["T"])) + S["key_bindings"]["T"] = list("say_with_indicator") + else + S["key_bindings"]["T"] += "say_with_indicator" S["key_bindings"]["CtrlT"] -= "say_with_indicator" - S["key_bindings"]["CtrlT"] += "say" + S["key_bindings"]["CtrlT"] += "say" if(length(ctrl_m_binding) && "me_with_indicator" in ctrl_m_binding) - if(!length(S["key_bindings"]["M"]) - S["key_bindings"]["M"] = list("me_with_indicator") - else - S["key_bindings"]["M"] += "me_with_indicator" + if(!length(S["key_bindings"]["M"])) + S["key_bindings"]["M"] = list("me_with_indicator") + else + S["key_bindings"]["M"] += "me_with_indicator" S["key_bindings"]["CtrlM"] -= "me_with_indicator" - S["key_bindings"]["CtrlM"] == "me" + S["key_bindings"]["CtrlM"] == "me" /datum/preferences/proc/load_path(ckey,filename="preferences.sav") if(!ckey) From 8a2e9968179f4fe6b45aa4d33034a4ec4b10b4b8 Mon Sep 17 00:00:00 2001 From: timothyteakettle <59849408+timothyteakettle@users.noreply.github.com> Date: Tue, 24 Nov 2020 01:55:36 +0000 Subject: [PATCH 07/15] migration runtimes --- code/modules/client/preferences_savefile.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 206239fa63..f45f7389bf 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -264,20 +264,20 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car if(current_version < 44) var/ctrl_t_binding = S["key_bindings"]["CtrlT"] var/ctrl_m_binding = S["key_bindings"]["CtrlM"] - if(length(ctrl_t_binding) && "say_with_indicator" in ctrl_t_binding) + if(length(ctrl_t_binding) && ("say_with_indicator" in ctrl_t_binding)) if(!length(S["key_bindings"]["T"])) S["key_bindings"]["T"] = list("say_with_indicator") else S["key_bindings"]["T"] += "say_with_indicator" S["key_bindings"]["CtrlT"] -= "say_with_indicator" S["key_bindings"]["CtrlT"] += "say" - if(length(ctrl_m_binding) && "me_with_indicator" in ctrl_m_binding) + if(length(ctrl_m_binding) && ("me_with_indicator" in ctrl_m_binding)) if(!length(S["key_bindings"]["M"])) S["key_bindings"]["M"] = list("me_with_indicator") else S["key_bindings"]["M"] += "me_with_indicator" S["key_bindings"]["CtrlM"] -= "me_with_indicator" - S["key_bindings"]["CtrlM"] == "me" + S["key_bindings"]["CtrlM"] = "me" /datum/preferences/proc/load_path(ckey,filename="preferences.sav") if(!ckey) From 5e965d099f5d1850a389dc77488fe4557cb7d7b4 Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Thu, 26 Nov 2020 23:37:27 -0700 Subject: [PATCH 08/15] COME ON --- code/controllers/subsystem/input.dm | 15 +----- code/modules/client/client_procs.dm | 37 -------------- code/modules/client/preferences.dm | 16 ++++--- code/modules/client/preferences_savefile.dm | 23 ++------- .../keybindings/keybind/communication.dm | 46 ++++++++++-------- code/modules/keybindings/keybind/mob.dm | 34 ------------- code/modules/keybindings/setup.dm | 48 +++++++++++++++++++ code/modules/mob/say.dm | 2 +- 8 files changed, 90 insertions(+), 131 deletions(-) diff --git a/code/controllers/subsystem/input.dm b/code/controllers/subsystem/input.dm index 203c6e3646..98ebf36c74 100644 --- a/code/controllers/subsystem/input.dm +++ b/code/controllers/subsystem/input.dm @@ -51,8 +51,6 @@ SUBSYSTEM_DEF(input) // let's play the ascii game of A to Z (UPPERCASE) for(var/i in 65 to 90) classic_ctrl_override_keys += ascii2text(i) - // let's play the game of clientside bind overrides! - classic_ctrl_override_keys -= list("M") // let's play the list iteration game x2 for(var/key in classic_ctrl_override_keys) // make sure to double double quote to ensure things are treated as a key combo instead of addition/semicolon logic. @@ -64,17 +62,6 @@ SUBSYSTEM_DEF(input) // FINALLY, WE CAN DO SOMETHING MORE NORMAL FOR THE SNOWFLAKE-BUT-LESS KEYSET. - // HAHA - SIKE. Because of BYOND weirdness (tl;dr not specifically binding this way results in potentially duplicate chatboxes when - // conflicts occur with something like say indicator vs say), we're going to snowflake this anyways - var/list/hard_binds = list( - "L" = "looc" - ) - var/list/hard_bind_anti_collision = list() - var/list/anti_collision_modifiers = list("Ctrl", "Alt", "Shift", "Ctrl+Alt", "Ctrl+Shift", "Alt+Shift", "Ctrl+Alt+Shift") - for(var/key in hard_binds) - for(var/modifier in anti_collision_modifiers) - hard_bind_anti_collision["[modifier]+[key]"] = ".NONSENSICAL_VERB_THAT_DOES_NOTHING" - macroset_classic_hotkey = list( "Any" = "\"KeyDown \[\[*\]\]\"", "Any+UP" = "\"KeyUp \[\[*\]\]\"", @@ -103,7 +90,7 @@ SUBSYSTEM_DEF(input) var/list/clients = GLOB.clients for(var/i in 1 to clients.len) var/client/user = clients[i] - user.set_macros() + user.full_macro_assert() /datum/controller/subsystem/input/fire() var/list/clients = GLOB.clients // Let's sing the list cache song diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index 660e4ccdbe..cd8aca134a 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -443,7 +443,6 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( if(!winexists(src, "asset_cache_browser")) // The client is using a custom skin, tell them. to_chat(src, "Unable to access asset cache browser, if you are using a custom skin file, please allow DS to download the updated version, if you are not, then make a bug report. This is not a critical issue but can cause issues with resource downloading, as it is impossible to know when extra resources arrived to you.") - //This is down here because of the browse() calls in tooltip/New() if(!tooltips) tooltips = new /datum/tooltip(src) @@ -475,10 +474,6 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( fit_viewport() Master.UpdateTickRate() -/client/proc/ensure_keys_set() - if(SSinput.initialized) - set_macros() - ////////////// //DISCONNECT// ////////////// @@ -936,38 +931,6 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( y = clamp(y+change, min,max) view_size.setDefault("[x]x[y]") -/** - * Updates the keybinds for special keys - * - * Handles adding macros for the keys that need it - * And adding movement keys to the clients movement_keys list - * At the time of writing this, communication(OOC, Say, IC) require macros - * Arguments: - * * 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 - if(!D?.key_bindings) - return - movement_keys = list() - for(var/key in D.key_bindings) - for(var/kb_name in D.key_bindings[key]) - switch(kb_name) - if("North") - movement_keys[key] = NORTH - if("East") - movement_keys[key] = EAST - if("West") - movement_keys[key] = WEST - if("South") - movement_keys[key] = SOUTH - if("Say") - winset(src, "default-[REF(key)]", "parent=default;name=[key];command=say") - if("OOC") - winset(src, "default-[REF(key)]", "parent=default;name=[key];command=ooc") - if("Me") - winset(src, "default-[REF(key)]", "parent=default;name=[key];command=me") - /client/proc/change_view(new_size) if (isnull(new_size)) CRASH("change_view called without argument.") diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index b29dc67d71..6993b6dfac 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -219,7 +219,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?.set_macros() + C?.full_macro_assert() real_name = pref_species.random_name(gender,1) if(!loaded_preferences_successfully) save_preferences() @@ -2382,7 +2382,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) if(!length(key_bindings[old_key])) key_bindings -= old_key user << browse(null, "window=capturekeypress") - user.client.set_macros() + user.client.full_macro_assert() save_preferences() ShowChoices(user) return @@ -2417,7 +2417,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.set_macros() + user.client.full_macro_assert() user << browse(null, "window=capturekeypress") save_preferences() @@ -2429,7 +2429,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.set_macros() + user.client.full_macro_assert() if("chat_on_map") chat_on_map = !chat_on_map @@ -2829,17 +2829,21 @@ GLOBAL_LIST_EMPTY(preferences_datums) cached_holoform_icons[filter_type] = process_holoform_icon_filter(custom_holoform_icon, filter_type) return cached_holoform_icons[filter_type] -//Used in savefile update 32, can be removed once that is no longer relevant. +/// Resets the client's keybindings. Asks them for which /datum/preferences/proc/force_reset_keybindings() var/choice = tgalert(parent.mob, "Your basic keybindings need to be reset, emotes will remain as before. Would you prefer 'hotkey' or 'classic' mode?", "Reset keybindings", "Hotkey", "Classic") hotkeys = (choice != "Classic") + force_reset_keybindings_direct(hotkeys) + +/// Does the actual reset +/datum/preferences/proc/force_reset_keybindings_direct(hotkeys = TRUE) var/list/oldkeys = key_bindings key_bindings = (hotkeys) ? deepCopyList(GLOB.hotkey_keybinding_list_by_key) : deepCopyList(GLOB.classic_keybinding_list_by_key) for(var/key in oldkeys) if(!key_bindings[key]) key_bindings[key] = oldkeys[key] - parent.update_special_keybinds() + parent.full_macro_assert(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 f45f7389bf..d3ef50d45a 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 44 +#define SAVEFILE_VERSION_MAX 45 /* SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn @@ -42,7 +42,8 @@ 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 < 32) //If you remove this, remove force_reset_keybindings() too. + if(current_version < 45) //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. /datum/preferences/proc/update_character(current_version, savefile/S) @@ -261,24 +262,6 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car features["color_scheme"] = OLD_CHARACTER_COLORING //advanced is off by default - if(current_version < 44) - var/ctrl_t_binding = S["key_bindings"]["CtrlT"] - var/ctrl_m_binding = S["key_bindings"]["CtrlM"] - if(length(ctrl_t_binding) && ("say_with_indicator" in ctrl_t_binding)) - if(!length(S["key_bindings"]["T"])) - S["key_bindings"]["T"] = list("say_with_indicator") - else - S["key_bindings"]["T"] += "say_with_indicator" - S["key_bindings"]["CtrlT"] -= "say_with_indicator" - S["key_bindings"]["CtrlT"] += "say" - if(length(ctrl_m_binding) && ("me_with_indicator" in ctrl_m_binding)) - if(!length(S["key_bindings"]["M"])) - S["key_bindings"]["M"] = list("me_with_indicator") - else - S["key_bindings"]["M"] += "me_with_indicator" - S["key_bindings"]["CtrlM"] -= "me_with_indicator" - S["key_bindings"]["CtrlM"] = "me" - /datum/preferences/proc/load_path(ckey,filename="preferences.sav") if(!ckey) return diff --git a/code/modules/keybindings/keybind/communication.dm b/code/modules/keybindings/keybind/communication.dm index f3a7028c58..4fdf0b53c4 100644 --- a/code/modules/keybindings/keybind/communication.dm +++ b/code/modules/keybindings/keybind/communication.dm @@ -3,35 +3,19 @@ /datum/keybinding/client/communication/say hotkey_keys = list("CtrlT") - name = "say" + name = "Say" full_name = "IC Say" -/datum/keybinding/client/communication/say/down(client/user) - var/mob/M = user.mob - var/speech = input(user, "", "say") - M.say_verb(speech) - /datum/keybinding/client/communication/ooc hotkey_keys = list("O") name = "OOC" full_name = "Out Of Character Say (OOC)" -/datum/keybinding/client/communication/ooc/down(client/user) - var/speech = input(user, "", "OOC") - user.ooc(speech) - return TRUE - /datum/keybinding/client/communication/me hotkey_keys = list("CtrlM") - name = "me" + name = "Me" full_name = "Me (emote)" -/datum/keybinding/client/communication/me/down(client/user) - var/mob/M = user.mob - var/emote = input(user, "", "Me") - M.me_verb(emote) - return TRUE - //indicators /datum/keybinding/client/communication/say_with_indicator hotkey_keys = list("T") @@ -53,4 +37,28 @@ /datum/keybinding/client/communication/me_with_indicator/down(client/user) var/mob/M = user.mob M.me_typing_indicator() - return TRUE \ No newline at end of file + return TRUE + +/datum/keybinding/client/communication/subtle + hotkey_keys = list("5") + classic_keys = list() + name = "Subtle" + full_name = "Subtle Emote" + +/datum/keybinding/client/communication/subtler + hotkey_keys = list("6") + classic_keys = list() + name = "Subtler" + full_name = "Subtler Anti-Ghost Emote" + +/datum/keybinding/client/communication/whisper + hotkey_keys = list("Y") + classic_keys = list() + name = "Whisper" + full_name = "Whisper" + +/datum/keybinding/client/communication/looc + hotkey_keys = list("L") + classic_keys = list() + name = "LOOC" + full_name = "Local Out of Character chat" diff --git a/code/modules/keybindings/keybind/mob.dm b/code/modules/keybindings/keybind/mob.dm index 6d88b53714..257ccc37e6 100644 --- a/code/modules/keybindings/keybind/mob.dm +++ b/code/modules/keybindings/keybind/mob.dm @@ -76,37 +76,3 @@ else user.mob.dropItemToGround(I) return TRUE - -/datum/keybinding/living/subtle - hotkey_keys = list("5") - classic_keys = list() - name = "subtle_emote" - full_name = "Subtle Emote" - -/datum/keybinding/living/subtle/down(client/user) - var/mob/living/L = user.mob - L.subtle() - return TRUE - -/datum/keybinding/living/subtler - hotkey_keys = list("6") - classic_keys = list() - name = "subtler_emote" - full_name = "Subtler Anti-Ghost Emote" - -/datum/keybinding/living/subtler/down(client/user) - var/mob/living/L = user.mob - L.subtler() - return TRUE - -/datum/keybinding/mob/whisper - hotkey_keys = list("Y") - classic_keys = list() - name = "whisper" - full_name = "Whisper" - -/datum/keybinding/mob/whisper/down(client/user) - var/mob/M = user.mob - M.whisper_keybind() - return TRUE - diff --git a/code/modules/keybindings/setup.dm b/code/modules/keybindings/setup.dm index 1e2820c93f..0e3ebc6097 100644 --- a/code/modules/keybindings/setup.dm +++ b/code/modules/keybindings/setup.dm @@ -45,3 +45,51 @@ winset(src, null, "map.focus=true input.background-color=[COLOR_INPUT_DISABLED] mainwindow.macro=[SKIN_MACROSET_HOTKEYS]") else winset(src, null, "input.focus=true input.background-color=[COLOR_INPUT_ENABLED] mainwindow.macro=[SKIN_MACROSET_CLASSIC_INPUT]") + +/client/proc/ensure_keys_set() + if(SSinput.initialized) + full_macro_assert() + +/client/proc/full_macro_assert(datum/preferences/prefs_override = refs) + set_macros(prefs_override) + update_special_keybinds(prefs_override) + +/** + * Updates the keybinds for special keys + * + * Handles adding macros for the keys that need it + * And adding movement keys to the clients movement_keys list + * At the time of writing this, communication(OOC, Say, IC) require macros + * Arguments: + * * 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 + if(!D?.key_bindings) + return + movement_keys = list() + for(var/key in D.key_bindings) + for(var/kb_name in D.key_bindings[key]) + switch(kb_name) + if("North") + movement_keys[key] = NORTH + if("East") + movement_keys[key] = EAST + if("West") + movement_keys[key] = WEST + if("South") + movement_keys[key] = SOUTH + if("Say") + winset(src, "default-[REF(key)]", "parent=default;name=[key];command=say") + if("OOC") + winset(src, "default-[REF(key)]", "parent=default;name=[key];command=ooc") + if("Me") + winset(src, "default-[REF(key)]", "parent=default;name=[key];command=me") + if("Subtle") + winset(src, "default-[REF(key)]", "parent=default;name=[key];command=subtle") + if("Subtler") + winset(src, "default-[REF(key)]", "parent=default;name=[key];command=subtler") + if("Whisper") + winset(src, "default-[REF(key)]", "parent=default;name=[key];command=whisper") + if("LOOC") + winset(src, "default-[REF(key)]", "parent=default;name=[key];command=looc") diff --git a/code/modules/mob/say.dm b/code/modules/mob/say.dm index 7d97270808..3b6f37184a 100644 --- a/code/modules/mob/say.dm +++ b/code/modules/mob/say.dm @@ -43,7 +43,7 @@ if(GLOB.say_disabled) //This is here to try to identify lag problems to_chat(usr, "Speech is currently admin-disabled.") return - + if(length(message) > MAX_MESSAGE_LEN) to_chat(usr, message) to_chat(usr, "^^^----- The preceeding message has been DISCARDED for being over the maximum length of [MAX_MESSAGE_LEN]. It has NOT been sent! -----^^^") From 9f4e0ac4dfd66565a93b75584acc67d29028beb4 Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Thu, 26 Nov 2020 23:38:39 -0700 Subject: [PATCH 09/15] woops --- code/controllers/subsystem/input.dm | 6 ------ 1 file changed, 6 deletions(-) diff --git a/code/controllers/subsystem/input.dm b/code/controllers/subsystem/input.dm index 98ebf36c74..7650d46049 100644 --- a/code/controllers/subsystem/input.dm +++ b/code/controllers/subsystem/input.dm @@ -70,9 +70,6 @@ SUBSYSTEM_DEF(input) "Back" = "\".winset \\\"input.text=\\\"\\\"\\\"\"", ) - macroset_classic_hotkey |= hard_binds - macroset_classic_hotkey |= hard_bind_anti_collision - // And finally, the modern set. macroset_hotkey = list( "Any" = "\"KeyDown \[\[*\]\]\"", @@ -82,9 +79,6 @@ SUBSYSTEM_DEF(input) "Back" = "\".winset \\\"input.text=\\\"\\\"\\\"\"", ) - macroset_hotkey |= hard_binds - macroset_hotkey |= hard_bind_anti_collision - // Badmins just wanna have fun ♪ /datum/controller/subsystem/input/proc/refresh_client_macro_sets() var/list/clients = GLOB.clients From 134fd0f858e894d23b5829c3a080ee533d02c408 Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Thu, 26 Nov 2020 23:42:39 -0700 Subject: [PATCH 10/15] k --- code/modules/keybindings/setup.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/keybindings/setup.dm b/code/modules/keybindings/setup.dm index 0e3ebc6097..635db4bca1 100644 --- a/code/modules/keybindings/setup.dm +++ b/code/modules/keybindings/setup.dm @@ -50,7 +50,7 @@ if(SSinput.initialized) full_macro_assert() -/client/proc/full_macro_assert(datum/preferences/prefs_override = refs) +/client/proc/full_macro_assert(datum/preferences/prefs_override = prefs) set_macros(prefs_override) update_special_keybinds(prefs_override) 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 11/15] 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") From a6d73e034447b2d17edfd9e823d3a8cfaf5b9d38 Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Fri, 27 Nov 2020 04:25:22 -0700 Subject: [PATCH 12/15] fix --- code/controllers/subsystem/input.dm | 6 +++++ code/modules/keybindings/setup.dm | 42 ++++++++++------------------- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/code/controllers/subsystem/input.dm b/code/controllers/subsystem/input.dm index 7650d46049..8c4fba367d 100644 --- a/code/controllers/subsystem/input.dm +++ b/code/controllers/subsystem/input.dm @@ -6,6 +6,12 @@ SUBSYSTEM_DEF(input) priority = FIRE_PRIORITY_INPUT runlevels = RUNLEVELS_DEFAULT | RUNLEVEL_LOBBY + /// KEEP THIS UP TO DATE! + var/static/list/all_macrosets = list( + SKIN_MACROSET_HOTKEYS, + SKIN_MACROSET_CLASSIC_HOTKEYS, + SKIN_MACROSET_CLASSIC_INPUT + ) /// Classic mode input focused macro set. Manually set because we can't define ANY or ANY+UP for classic. var/static/list/macroset_classic_input /// Classic mode map focused macro set. Manually set because it needs to be clientside and go to macroset_classic_input. diff --git a/code/modules/keybindings/setup.dm b/code/modules/keybindings/setup.dm index 3946ad77e1..3ed411e693 100644 --- a/code/modules/keybindings/setup.dm +++ b/code/modules/keybindings/setup.dm @@ -10,7 +10,9 @@ // removes all the existing macros /client/proc/erase_all_macros() var/erase_output = "" - var/list/macro_set = params2list(winget(src, "default.*", "command")) // The third arg doesnt matter here as we're just removing them all + var/list/macro_set = list() + for(var/macroset in SSinput.all_macrosets) // WE HAVE THREE AAAAAAAA + macro_set |= params2list(winget(src, "[macroset].*", "command")) // The third arg doesnt matter here as we're just removing them all for(var/k in 1 to length(macro_set)) var/list/split_name = splittext(macro_set[k], ".") var/macro_name = "[split_name[1]].[split_name[2]]" // [3] is "command" @@ -25,7 +27,6 @@ var/key = macroset[i] var/command = macroset[key] winset(src, "[name]-[REF(key)]", "parent=[name];name=[key];command=[command]") - update_special_keybinds() /client/proc/set_macros(datum/preferences/prefs_override = prefs) set waitfor = FALSE @@ -54,18 +55,7 @@ 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) +/client/proc/do_special_keybind(key, command, datum/preferences/prefs_override = prefs) var/alt = findtext(key, "Alt") if(alt) key = copytext(key, 1, alt) + copytext(key, alt + 3, 0) @@ -75,14 +65,10 @@ var/shift = findtext(key, "Shift") if(shift) key = copytext(key, 1, shift) + copytext(key, shift + 5, 0) + if(!alt && !ctrl && !shift && !prefs_override.hotkeys) + return /// DO NOT. 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) + for(var/macroset in SSinput.all_macrosets) winset(src, "[macroset]-[REF(key)]", "parent=[macroset];name=[key];command=[command]") /** @@ -111,16 +97,16 @@ if("South") movement_keys[key] = SOUTH if("Say") - do_special_keybind(key, "say") + do_special_keybind(key, "say", D) if("OOC") - do_special_keybind(key, "OOC") + do_special_keybind(key, "ooc", D) if("Me") - do_special_keybind(key, "me") + do_special_keybind(key, "me", D) if("Subtle") - do_special_keybind(key, "subtle") + do_special_keybind(key, "subtle", D) if("Subtler") - do_special_keybind(key, "Subtler-Anti-Ghost") + do_special_keybind(key, "subtler-anti-ghost", D) if("Whisper") - do_special_keybind(key, "whisper") + do_special_keybind(key, "whisper", D) if("LOOC") - do_special_keybind(key, "LOOC") + do_special_keybind(key, "looc", D) From ae756749ccc46ac5e0341138c39942b67ce04083 Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Fri, 27 Nov 2020 05:15:40 -0700 Subject: [PATCH 13/15] woops --- code/modules/client/preferences.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 250a9de8a4..73486958d6 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -2353,7 +2353,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) if("hotkeys") hotkeys = !hotkeys - user.client.set_macros() + user.client.ensure_keys_set() if("keybindings_capture") var/datum/keybinding/kb = GLOB.keybindings_by_name[href_list["keybinding"]] @@ -2842,7 +2842,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) for(var/key in oldkeys) if(!key_bindings[key]) key_bindings[key] = oldkeys[key] - parent.ensure_keys_set(src) + parent.ensure_keys_set() /datum/preferences/proc/is_loadout_slot_available(slot) var/list/L From ead209f5071e10611cbdf3c55828c96ecd1aea80 Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Fri, 27 Nov 2020 06:31:05 -0700 Subject: [PATCH 14/15] sigh --- code/modules/client/client_defines.dm | 2 + code/modules/client/client_procs.dm | 2 +- code/modules/client/preferences.dm | 26 +++++---- code/modules/keybindings/keybind/_keybind.dm | 4 ++ .../keybindings/keybind/communication.dm | 7 +++ code/modules/keybindings/keybind/movement.dm | 1 + code/modules/keybindings/setup.dm | 56 ++++++++++--------- 7 files changed, 61 insertions(+), 37 deletions(-) diff --git a/code/modules/client/client_defines.dm b/code/modules/client/client_defines.dm index 53ab7f7abb..b71521121b 100644 --- a/code/modules/client/client_defines.dm +++ b/code/modules/client/client_defines.dm @@ -89,6 +89,8 @@ var/list/char_render_holders //Should only be a key-value list of north/south/east/west = obj/screen. + /// Last time they used fix macros + var/last_macro_fix = 0 /// Keys currently held var/list/keys_held = list() /// These next two vars are to apply movement for keypresses and releases made while move delayed. diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index cd8aca134a..267ee3a5e1 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -269,7 +269,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( prefs = new /datum/preferences(src) GLOB.preferences_datums[ckey] = prefs - addtimer(CALLBACK(src, .proc/ensure_keys_set), 10) //prevents possible race conditions + addtimer(CALLBACK(src, .proc/ensure_keys_set, prefs), 10) //prevents possible race conditions prefs.last_ip = address //these are gonna be used for banning prefs.last_id = computer_id //these are gonna be used for banning diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 73486958d6..87adc31d8c 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -218,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?.ensure_keys_set() + C?.ensure_keys_set(src) real_name = pref_species.random_name(gender,1) if(!loaded_preferences_successfully) save_preferences() @@ -951,7 +951,8 @@ GLOBAL_LIST_EMPTY(preferences_datums) 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]" + if(!kb.special && !kb.clientside) + dat += "Independent Binding: [current_independent_binding]" dat += "
" else var/bound_key = user_binds[kb.name][1] @@ -964,7 +965,8 @@ 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]" + if(!kb.special && !kb.clientside) + dat += "Independent Binding: [current_independent_binding]" dat += "
" dat += "

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

Press any key to change
Press ESC to clear