mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2025-12-17 05:31:53 +00:00
Adds preference to control multilingual behaviour (#7064)
* Adds preference to control multilingual behaviour Examine mode preference should persist across reconnections to a single round Still looking into how to properly get these to go into the savefile * typos
This commit is contained in:
@@ -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
|
||||
#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
|
||||
@@ -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
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
var/chatOutputLoadedAt
|
||||
|
||||
var/adminhelped = 0
|
||||
var/examine_text_mode = 0 // Just examine text, include usage (description_info), switch to examine panel.
|
||||
|
||||
|
||||
///////////////
|
||||
//SOUND STUFF//
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -313,17 +313,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, "<span class='filter_system'>Examining things will only output the base examine text, and you will not be redirected to the examine panel automatically.</span>")
|
||||
|
||||
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, "<span class='filter_system'>Examining things will also print any extra usage information normally included in the examine panel to the chat.</span>")
|
||||
|
||||
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, "<span class='filter_system'>Examining things will direct you to the examine panel, where you can view extended information about the thing.</span>")
|
||||
|
||||
/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, "<span class='filter_system'>Multilingual parsing will only check for the delimiter-key combination (,0galcom-2tradeband).</span>")
|
||||
if(MULTILINGUAL_SPACE)
|
||||
to_chat(src, "<span class='filter_system'>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.</span>")
|
||||
if(MULTILINGUAL_DOUBLE_DELIMITER)
|
||||
to_chat(src, "<span class='filter_system'>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.</span>")
|
||||
if(MULTILINGUAL_OFF)
|
||||
to_chat(src, "<span class='filter_system'>Multilingual parsing is now disabled. Entire messages will be in the language specified at the start of the message.</span>")
|
||||
|
||||
|
||||
//Toggles for Staff
|
||||
|
||||
@@ -148,8 +148,8 @@
|
||||
/mob/proc/find_valid_prefixes(message)
|
||||
var/list/prefixes = list() // [["Common", start, end], ["Gutter", start, end]]
|
||||
for(var/i in 1 to length(message))
|
||||
// This grabs trimmed 3 character substrings, to allow for up to 1 prefix and 1 letter language keys
|
||||
var/selection = trim_right(lowertext(copytext(message, i, i + 2)))
|
||||
// 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))
|
||||
// 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)
|
||||
@@ -157,6 +157,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
|
||||
@@ -170,6 +182,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)
|
||||
|
||||
Reference in New Issue
Block a user