From cf6ea3434c77ada5545fec91262f45d0ef9b29be Mon Sep 17 00:00:00 2001 From: Killian <49700375+KillianKirilenko@users.noreply.github.com> Date: Wed, 20 Sep 2023 12:35:19 +0100 Subject: [PATCH] convert throwmode messages to prefbased --- .../client/preference_setup/global/01_ui.dm | 8 ++++++++ code/modules/client/preferences.dm | 1 + code/modules/client/preferences_toggle_procs.dm | 10 ++++++++++ code/modules/mob/mob.dm | 14 +++++++++----- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/code/modules/client/preference_setup/global/01_ui.dm b/code/modules/client/preference_setup/global/01_ui.dm index 13a05070dd..d0f680c075 100644 --- a/code/modules/client/preference_setup/global/01_ui.dm +++ b/code/modules/client/preference_setup/global/01_ui.dm @@ -18,6 +18,7 @@ S["tgui_large_buttons"] >> pref.tgui_large_buttons S["tgui_swapped_buttons"] >> pref.tgui_swapped_buttons S["chat_timestamp"] >> pref.chat_timestamp + S["throwmode_loud"] >> pref.throwmode_loud /datum/category_item/player_setup_item/player_global/ui/save_preferences(var/savefile/S) S["UI_style"] << pref.UI_style @@ -35,6 +36,7 @@ S["tgui_large_buttons"] << pref.tgui_large_buttons S["tgui_swapped_buttons"] << pref.tgui_swapped_buttons S["chat_timestamp"] << pref.chat_timestamp + S["throwmode_loud"] << pref.throwmode_loud /datum/category_item/player_setup_item/player_global/ui/sanitize_preferences() pref.UI_style = sanitize_inlist(pref.UI_style, all_ui_styles, initial(pref.UI_style)) @@ -52,6 +54,7 @@ pref.tgui_large_buttons = sanitize_integer(pref.tgui_large_buttons, 0, 1, initial(pref.tgui_large_buttons)) pref.tgui_swapped_buttons = sanitize_integer(pref.tgui_swapped_buttons, 0, 1, initial(pref.tgui_swapped_buttons)) pref.chat_timestamp = sanitize_integer(pref.chat_timestamp, 0, 1, initial(pref.chat_timestamp)) + pref.throwmode_loud = sanitize_integer(pref.throwmode_loud, 0, 1, initial(pref.throwmode_loud)) /datum/category_item/player_setup_item/player_global/ui/content(var/mob/user) . = "UI Style: [pref.UI_style]
" @@ -69,6 +72,7 @@ . += "TGUI Large Buttons: [(pref.tgui_large_buttons) ? "Enabled (default)" : "Disabled"]
" . += "TGUI Swapped Buttons: [(pref.tgui_swapped_buttons) ? "Enabled" : "Disabled (default)"]
" . += "Chat Timestamps: [(pref.chat_timestamp) ? "Enabled" : "Disabled (default)"]
" + . += "Throw Mode Messages: [(pref.throwmode_loud) ? "Loud" : "Quiet (default)"]
" if(can_select_ooc_color(user)) . += "OOC Color:" if(pref.ooccolor == initial(pref.ooccolor)) @@ -158,6 +162,10 @@ pref.chat_timestamp = !pref.chat_timestamp return TOPIC_REFRESH + else if(href_list["throwmode_loudness"]) + pref.throwmode_loud = !pref.throwmode_loud + return TOPIC_REFRESH + else if(href_list["reset"]) switch(href_list["reset"]) if("ui") diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 06c43619ab..4241e7d7d7 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -33,6 +33,7 @@ var/list/preferences_datums = list() var/tgui_large_buttons = TRUE var/tgui_swapped_buttons = FALSE var/chat_timestamp = FALSE + var/throwmode_loud = FALSE //character preferences var/real_name //our character's name diff --git a/code/modules/client/preferences_toggle_procs.dm b/code/modules/client/preferences_toggle_procs.dm index dff1c3f5a2..454a5ec6ac 100644 --- a/code/modules/client/preferences_toggle_procs.dm +++ b/code/modules/client/preferences_toggle_procs.dm @@ -400,6 +400,16 @@ to_chat(src, span_notice("You have toggled chat timestamps: [prefs.chat_timestamp ? "ON" : "OFF"].")) +/client/verb/toggle_throwmode_messages() + set name = "Toggle Throw Mode Messages" + set category = "Preferences" + set desc = "Toggles whether or not activating throw mode (hotkey: R) will announce you're preparing to throw your current handheld item, or catch an incoming item if your hand is empty." + + prefs.throwmode_loud = !prefs.throwmode_loud //There is no preference datum for tgui input lock, nor for any TGUI prefs. + SScharacter_setup.queue_preferences_save(prefs) + + to_chat(src, span_notice("You have toggled throw mode messages: [prefs.throwmode_loud ? "ON" : "OFF"].")) + /client/verb/toggle_status_indicators() set name = "Toggle Status Indicators" set category = "Preferences" diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index f9a565bfb2..91423c838c 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1149,16 +1149,20 @@ /mob/proc/throw_mode_off() src.in_throw_mode = 0 - src.visible_message("[src] relaxes from their ready stance.","You relax from your ready stance.") + if(client) + if(client.prefs.throwmode_loud) + src.visible_message("[src] relaxes from their ready stance.","You relax from your ready stance.") if(src.throw_icon) //in case we don't have the HUD and we use the hotkey src.throw_icon.icon_state = "act_throw_off" /mob/proc/throw_mode_on() src.in_throw_mode = 1 - if(src.get_active_hand()) - src.visible_message("[src] winds up to throw [get_active_hand()]!","You wind up to throw [get_active_hand()].") - else - src.visible_message("[src] looks ready to catch anything thrown at them!","You get ready to catch anything thrown at you.") + if(client) + if(client.prefs.throwmode_loud) + if(src.get_active_hand()) + src.visible_message("[src] winds up to throw [get_active_hand()]!","You wind up to throw [get_active_hand()].") + else + src.visible_message("[src] looks ready to catch anything thrown at them!","You get ready to catch anything thrown at you.") if(src.throw_icon) src.throw_icon.icon_state = "act_throw_on"