diff --git a/code/__defines/preferences.dm b/code/__defines/preferences.dm index 0bb289d2e1..880d9318d8 100644 --- a/code/__defines/preferences.dm +++ b/code/__defines/preferences.dm @@ -1,6 +1,15 @@ +// Modes for examine text output #define EXAMINE_MODE_DEFAULT 0 #define EXAMINE_MODE_INCLUDE_USAGE 1 #define EXAMINE_MODE_SWITCH_TO_PANEL 2 // Should be one higher than the above -#define EXAMINE_MODE_MAX 3 \ No newline at end of file +#define EXAMINE_MODE_MAX 3 + +// Modes for parsing multilingual speech +#define MULTILINGUAL_DEFAULT 0 +#define MULTILINGUAL_SPACE 1 +#define MULTILINGUAL_DOUBLE_DELIMITER 2 +#define MULTILINGUAL_OFF 3 + +#define MULTILINGUAL_MODE_MAX 4 \ No newline at end of file diff --git a/code/game/atoms.dm b/code/game/atoms.dm index 7d39676d51..ab703fa650 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -184,10 +184,10 @@ var/list/output = list("[bicon(src)] That's [f_name] [suffix]", desc) - if(user.client?.examine_text_mode == EXAMINE_MODE_INCLUDE_USAGE) + if(user.client?.prefs.examine_text_mode == EXAMINE_MODE_INCLUDE_USAGE) output += description_info - if(user.client?.examine_text_mode == EXAMINE_MODE_SWITCH_TO_PANEL) + if(user.client?.prefs.examine_text_mode == EXAMINE_MODE_SWITCH_TO_PANEL) user.client.statpanel = "Examine" // Switch to stat panel return output diff --git a/code/modules/client/client defines.dm b/code/modules/client/client defines.dm index 1d99f83b35..99d975c454 100644 --- a/code/modules/client/client defines.dm +++ b/code/modules/client/client defines.dm @@ -27,8 +27,6 @@ var/chatOutputLoadedAt var/adminhelped = 0 - var/examine_text_mode = 0 // Just examine text, include usage (description_info), switch to examine panel. - /////////////// //SOUND STUFF// diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 284198507a..de149d80ee 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -131,6 +131,10 @@ datum/preferences var/lastnews // Hash of last seen lobby news content. + var/examine_text_mode = 0 // Just examine text, include usage (description_info), switch to examine panel. + var/multilingual_mode = 0 // Default behaviour, delimiter-key-space, delimiter-key-delimiter, off + + /datum/preferences/New(client/C) player_setup = new(src) set_biological_gender(pick(MALE, FEMALE)) diff --git a/code/modules/client/preferences_toggle_procs.dm b/code/modules/client/preferences_toggle_procs.dm index b8e0ea3d5c..e33f3645d1 100644 --- a/code/modules/client/preferences_toggle_procs.dm +++ b/code/modules/client/preferences_toggle_procs.dm @@ -328,17 +328,34 @@ set category = "Preferences" set desc = "Control the additional behaviour of examining things" - examine_text_mode++ - examine_text_mode %= EXAMINE_MODE_MAX // This cycles through them because if you're already specifically being routed to the examine panel, you probably don't need to have the extra text printed to chat - switch(examine_text_mode) // ... And I only wanted to add one verb + prefs.examine_text_mode++ + prefs.examine_text_mode %= EXAMINE_MODE_MAX // This cycles through them because if you're already specifically being routed to the examine panel, you probably don't need to have the extra text printed to chat + switch(prefs.examine_text_mode) // ... And I only wanted to add one verb if(EXAMINE_MODE_DEFAULT) - to_chat(src, "Examining things will only output the base examine text, and you will not be redirected to the examine panel automatically.") + to_chat(src, "Examining things will only output the base examine text, and you will not be redirected to the examine panel automatically.") if(EXAMINE_MODE_INCLUDE_USAGE) - to_chat(src, "Examining things will also print any extra usage information normally included in the examine panel to the chat.") + to_chat(src, "Examining things will also print any extra usage information normally included in the examine panel to the chat.") if(EXAMINE_MODE_SWITCH_TO_PANEL) - to_chat(src, "Examining things will direct you to the examine panel, where you can view extended information about the thing.") + to_chat(src, "Examining things will direct you to the examine panel, where you can view extended information about the thing.") + +/client/verb/toggle_multilingual_mode() + set name = "Toggle Multilingual Mode" + set category = "Preferences" + set desc = "Control the behaviour of multilingual speech parsing" + + prefs.multilingual_mode++ + prefs.multilingual_mode %= MULTILINGUAL_MODE_MAX // Cycles through the various options + switch(prefs.multilingual_mode) + if(MULTILINGUAL_DEFAULT) + to_chat(src, "Multilingual parsing will only check for the delimiter-key combination (,0galcom-2tradeband).") + if(MULTILINGUAL_SPACE) + to_chat(src, "Multilingual parsing will enforce a space after the delimiter-key combination (,0 galcom -2still galcom). The extra space will be consumed by the pattern-matching.") + if(MULTILINGUAL_DOUBLE_DELIMITER) + to_chat(src, "Multilingual parsing will enforce the a language delimiter after the delimiter-key combination (,0,galcom -2 still galcom). The extra delimiter will be consumed by the pattern-matching.") + if(MULTILINGUAL_OFF) + to_chat(src, "Multilingual parsing is now disabled. Entire messages will be in the language specified at the start of the message.") //Toggles for Staff diff --git a/code/modules/mob/say.dm b/code/modules/mob/say.dm index 6db108fa6f..057b54df09 100644 --- a/code/modules/mob/say.dm +++ b/code/modules/mob/say.dm @@ -152,8 +152,13 @@ /mob/proc/find_valid_prefixes(message) var/list/prefixes = list() // [["Common", start, end], ["Gutter", start, end]] for(var/i in 1 to length(message)) +<<<<<<< HEAD // This grabs trimmed 3 character substrings, to allow for up to 1 prefix and 1 letter language keys var/selection = trim_right(copytext(message, i, i + 2)) // VOREStation Edit: We use uppercase keys to avoid Polaris key duplication, but this had lowertext() in it +======= + // This grabs 3 character substrings, to allow for up to 1 prefix, 1 letter language key, and one post-key character to more strictly control where the language breaks happen + var/selection = lowertext(copytext(message, i, i + 3)) +>>>>>>> 021f874... Adds preference to control multilingual behaviour (#7064) // The first character in the selection will always be the prefix (if this is a valid language invocation) var/prefix = copytext(selection, 1, 2) var/language_key = copytext(selection, 2, 3) @@ -161,6 +166,18 @@ // Okay, we're definitely now trying to invoke a language (probably) // This "[]" is probably unnecessary but BYOND will runtime if a number is used var/datum/language/L = GLOB.language_keys["[language_key]"] + + // MULTILINGUAL_SPACE enforces a space after the language key + if(client && (client.prefs.multilingual_mode == MULTILINGUAL_SPACE) && (text2ascii(copytext(selection, 3, 4)) != 32)) // If we're looking for a space and we don't find one + continue + + // MULTILINGUAL_DOUBLE_DELIMITER enforces a delimiter (valid prefix) after the language key + if(client && (client.prefs.multilingual_mode == MULTILINGUAL_DOUBLE_DELIMITER) && !is_language_prefix(copytext(selection, 3, 4))) + continue + + if(client && (client.prefs.multilingual_mode in list(MULTILINGUAL_DEFAULT))) + selection = copytext(selection, 1, 3) // These modes only use two characters, not three + // It's kinda silly that we have to check L != null and this isn't done for us by can_speak (it runtimes instead), but w/e if(L && can_speak(L)) // So we have a valid language invocation, and we can speak that language, let's make a piece for it @@ -174,6 +191,10 @@ // This covers the case of "no prefixes in use." prefixes[++prefixes.len] = list(get_default_language(), i, i) + // If multilingualism is disabled, then after the first pass we're guaranteed to have either found a language key at the start, or else there isn't one and we're using the default for the whole message + if(client && (client.prefs.multilingual_mode == MULTILINGUAL_OFF)) + break + return prefixes /mob/proc/strip_prefixes(message, mob/prefixer = null) diff --git a/html/changelogs/atermonera_multilingual_pref.yml b/html/changelogs/atermonera_multilingual_pref.yml new file mode 100644 index 0000000000..84552b9a13 --- /dev/null +++ b/html/changelogs/atermonera_multilingual_pref.yml @@ -0,0 +1,11 @@ +author: Atermonera +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - rscadd: "Added a preference to control multilingual parsing behaviour, with a few different modes. Should hopefully be less punishing to people who stutter and use hyphens as a language key." + - tweak: "The examine mode preference should now persist across reconnections during a single round, but if the server is fully restarted it still appears to reset. This issue is also present for the multilingual preference, and I'm still looking into it. Savefiles are crpytic."