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] 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! -----^^^")