From 55ab4b5b0739117df132979ac70f8575ff4ee9d2 Mon Sep 17 00:00:00 2001 From: CHOMPStation2 <58959929+CHOMPStation2@users.noreply.github.com> Date: Sun, 29 Sep 2024 02:08:21 -0700 Subject: [PATCH] [MIRROR] Automatic Punctuation pref (#9087) Co-authored-by: Heroman3003 <31296024+Heroman3003@users.noreply.github.com> Co-authored-by: CHOMPStation2 --- code/modules/client/preferences/types/misc.dm | 6 ++++++ code/modules/mob/living/say.dm | 7 +++++++ .../preferences/features/game_preferences/misc.tsx | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/code/modules/client/preferences/types/misc.dm b/code/modules/client/preferences/types/misc.dm index 5341737eb5..54a85477e3 100644 --- a/code/modules/client/preferences/types/misc.dm +++ b/code/modules/client/preferences/types/misc.dm @@ -75,3 +75,9 @@ savefile_key = "MessengerEmbeds" default_value = TRUE savefile_identifier = PREFERENCE_PLAYER + +/datum/preference/toggle/autopunctuation + category = PREFERENCE_CATEGORY_GAME_PREFERENCES + savefile_key = "AutoPunctuation" + default_value = FALSE + savefile_identifier = PREFERENCE_PLAYER diff --git a/code/modules/mob/living/say.dm b/code/modules/mob/living/say.dm index b8ea8c0728..025f2c7bfa 100644 --- a/code/modules/mob/living/say.dm +++ b/code/modules/mob/living/say.dm @@ -197,6 +197,13 @@ var/list/channel_to_radio_key = new return // VOREStation Edit End + // If the message ends in an alphanumeric character (therefore, not punctuation), + // and autopunctuation is turned on, add a period. + // This must be done right here, before parse_languages is called, to make sure it's in the last multilingual say piece. + if(contains_az09(copytext(message, length(message)))) + if(client?.prefs?.read_preference(/datum/preference/toggle/autopunctuation)) + message += "." + //Parse the language code and consume it var/list/message_pieces = parse_languages(message) if(istype(message_pieces, /datum/multilingual_say_piece)) // Little quark for dealing with hivemind/signlang languages. diff --git a/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/misc.tsx b/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/misc.tsx index 9a7a92d86a..8361e5cca2 100644 --- a/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/misc.tsx +++ b/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/misc.tsx @@ -80,3 +80,11 @@ export const MessengerEmbeds: FeatureToggle = { 'When enabled, PDAs and Communicators will attempt to embed links from discord & imgur.', component: CheckboxInput, }; + +export const AutoPunctuation: FeatureToggle = { + name: 'Automatic Punctuation', + category: 'GAMEPLAY', + description: + 'When enabled, if your message ends in a letter with no punctuation, a period will be added.', + component: CheckboxInput, +};