Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 188d1b6

Browse files
Fixes languages
1 parent 6f7b900 commit 188d1b6

File tree

8 files changed

+40
-32
lines changed

8 files changed

+40
-32
lines changed

code/__DEFINES/chat.dm

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
/// Adds a generic box around whatever message you're sending in chat. Really makes things stand out.
3232
#define EXAMINE_BLOCK(str) ("<div class='examine_block'>" + str + "</div>")
3333

34-
/// Max length of chat message in characters
35-
#define CHAT_MESSAGE_MAX_LENGTH 110
36-
3734
//debug printing macros (for development and testing)
3835
/// Used for debug messages to the world
3936
#define debug_world(msg) if (GLOB.Debug2) to_chat(world, \

code/__DEFINES/text.dm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
/// Prepares a text to be used for maptext. Use this so it doesn't look hideous.
66
#define MAPTEXT(text) {"<span class='maptext'>[##text]</span>"}
77

8+
/// Removes characters incompatible with file names.
9+
#define SANITIZE_FILENAME(text) (GLOB.filename_forbidden_chars.Replace(text, ""))
10+
11+
/// Simply removes the < and > characters, and limits the length of the message.
12+
#define STRIP_HTML_SIMPLE(text, limit) (GLOB.angular_brackets.Replace(copytext(text, 1, limit), ""))
13+
14+
/// Removes everything enclose in < and > inclusive of the bracket, and limits the length of the message.
15+
#define STRIP_HTML_FULL(text, limit) (GLOB.html_tags.Replace(copytext(text, 1, limit), ""))
16+
817
/**
918
* Pixel-perfect scaled fonts for use in the MAP element as defined in skin.dmf
1019
*

code/__DEFINES/traits/declarations.dm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,9 @@
10121012
/// this object has been frozen
10131013
#define TRAIT_FROZEN "frozen"
10141014

1015+
/// Is runechat for this atom/movable currently disabled, regardless of prefs or anything?
1016+
#define TRAIT_RUNECHAT_HIDDEN "runechat_hidden"
1017+
10151018
/// Currently fishing
10161019
#define TRAIT_GONE_FISHING "fishing"
10171020

@@ -1024,9 +1027,6 @@
10241027
/// Makes a species be better/worse at defending against tackling depending on their tail's status
10251028
#define TRAIT_TACKLING_TAILED_DEFENDER "tackling_tailed_defender"
10261029

1027-
/// Is runechat for this atom/movable currently disabled, regardless of prefs or anything?
1028-
#define TRAIT_RUNECHAT_HIDDEN "runechat_hidden"
1029-
10301030
/// the object has a label applied
10311031
#define TRAIT_HAS_LABEL "labeled"
10321032

code/datums/chatmessage.dm

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@
2626
/// The number of z-layer 'slices' usable by the chat message layering
2727
#define CHAT_LAYER_MAX_Z (CHAT_LAYER_MAX - CHAT_LAYER) / CHAT_LAYER_Z_STEP
2828

29-
///Base layer of chat elements
30-
#define CHAT_LAYER 1
31-
///Highest possible layer of chat elements
32-
#define CHAT_LAYER_MAX 2
33-
/// Maximum precision of float before rounding errors occur (in this context)
34-
#define CHAT_LAYER_Z_STEP 0.0001
35-
/// The number of z-layer 'slices' usable by the chat message layering
36-
#define CHAT_LAYER_MAX_Z (CHAT_LAYER_MAX - CHAT_LAYER) / CHAT_LAYER_Z_STEP
37-
3829
/**
3930
* # Chat Message Overlay
4031
*
@@ -83,8 +74,7 @@
8374
stack_trace("/datum/chatmessage created with [isnull(owner) ? "null" : "invalid"] mob owner")
8475
qdel(src)
8576
return
86-
if(!SSlag_switch.measures[DISABLE_RUNECHAT] && !HAS_TRAIT(owner, TRAIT_BYPASS_MEASURES))
87-
INVOKE_ASYNC(src, PROC_REF(generate_image), text, target, owner, language, extra_classes, lifespan)
77+
INVOKE_ASYNC(src, PROC_REF(generate_image), text, target, owner, language, extra_classes, lifespan)
8878

8979
/datum/chatmessage/Destroy()
9080
if (!QDELING(owned_by))
@@ -124,7 +114,7 @@
124114

125115
// Register client who owns this message
126116
owned_by = owner.client
127-
RegisterSignal(owned_by, COMSIG_QDELETING, PROC_REF(on_parent_qdel), src)
117+
RegisterSignal(owned_by, COMSIG_QDELETING, PROC_REF(on_parent_qdel))
128118

129119
// Remove spans in the message from things like the recorder
130120
var/static/regex/span_check = new(@"<\/?span[^>]*>", "gi")
@@ -185,15 +175,11 @@
185175
var/tgt_color = extra_classes.Find("italics") ? target.chat_color_darkened : target.chat_color
186176

187177
// Approximate text height
188-
var/complete_text = "<span class='center maptext [extra_classes.Join(" ")]' style='color: [tgt_color]'>[text]</span>"
189-
var/mheight
190-
WXH_TO_HEIGHT(owned_by.MeasureText(complete_text, null, CHAT_MESSAGE_WIDTH), mheight)
191-
approx_lines = max(1, mheight / CHAT_MESSAGE_APPROX_LHEIGHT)
178+
var/complete_text = "<span style='color: [tgt_color]'><span class='center [extra_classes.Join(" ")]'>[owner.say_emphasis(text)]</span></span>"
192179

193180
var/mheight
194181
WXH_TO_HEIGHT(owned_by.MeasureText(complete_text, null, CHAT_MESSAGE_WIDTH), mheight)
195182

196-
197183
if(!VERB_SHOULD_YIELD)
198184
return finish_image_generation(mheight, target, owner, complete_text, lifespan)
199185

@@ -281,15 +267,18 @@
281267
// Fade out
282268
animate(alpha = 0, time = CHAT_MESSAGE_EOL_FADE)
283269

284-
// Register with the runechat SS to handle EOL and destruction
285-
scheduled_destruction = world.time + (lifespan - CHAT_MESSAGE_EOL_FADE)
286-
RegisterSignal(message_loc, COMSIG_MOVABLE_Z_CHANGED, PROC_REF(loc_z_changed))
287-
enter_subsystem()
270+
// Register with the runechat SS to handle destruction
271+
addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(qdel), src), lifespan + CHAT_MESSAGE_GRACE_PERIOD, TIMER_DELETE_ME, SSrunechat)
288272

273+
/datum/chatmessage/proc/get_current_alpha(time_spent)
274+
if(time_spent < CHAT_MESSAGE_SPAWN_TIME)
275+
return (time_spent / CHAT_MESSAGE_SPAWN_TIME) * 255
289276

290-
/datum/chatmessage/proc/loc_z_changed(datum/source, turf/old_turf, turf/new_turf, same_z_layer)
291-
SIGNAL_HANDLER
292-
SET_PLANE(message, RUNECHAT_PLANE, new_turf)
277+
var/time_before_fade = animate_lifespan - CHAT_MESSAGE_EOL_FADE
278+
if(time_spent <= time_before_fade)
279+
return 255
280+
281+
return (1 - ((time_spent - time_before_fade) / CHAT_MESSAGE_EOL_FADE)) * 255
293282

294283
/**
295284
* Creates a message overlay at a defined location for a given speaker
@@ -325,7 +314,7 @@
325314
if(runechat_flags & EMOTE_MESSAGE)
326315
new /datum/chatmessage(raw_message, speaker, src, message_language, list("emote", "italics"))
327316
else
328-
new /datum/chatmessage(raw_message, speaker, src, message_language, spans)
317+
new /datum/chatmessage(translate_language(speaker, message_language, raw_message, spans), speaker, src, message_language, spans)
329318

330319
// Tweak these defines to change the available color ranges
331320
#define CM_COLOR_SAT_MIN 0.6

code/game/say.dm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@ GLOBAL_LIST_INIT(freqtospan, list(
134134
else
135135
return "makes a strange sound."
136136

137+
/// Modifies the message by comparing the languages of the speaker with the languages of the hearer. Called on the hearer.
138+
/atom/movable/proc/translate_language(atom/movable/speaker, datum/language/language, raw_message, list/spans, list/message_mods)
139+
if(!language)
140+
return "makes a strange sound."
141+
142+
if(!has_language(language))
143+
var/datum/language/dialect = GLOB.language_datum_instances[language]
144+
raw_message = dialect.scramble(raw_message)
145+
146+
return raw_message
147+
137148
/proc/get_radio_span(freq)
138149
var/returntext = GLOB.freqtospan["[freq]"]
139150
if(returntext)

code/modules/client/client_procs.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
11021102
src << output("[url_encode(json_encode(panel_tabs))];[url_encode(json_encode(verblist))]", "statbrowser:init_verbs")
11031103

11041104
/client/proc/check_panel_loaded()
1105-
to_chat(src, span_userdanger("If statpanel failed to load, click <a href='byond://?src=[REF(src)];reload_statbrowser=1'>here</a> to reload the panel "))
1105+
to_chat(src, span_userdanger("If statpanel failed to load, click <a href='byond://?src=[REF(src)];reload_statbrowser=1'>here</a> to reload it."))
11061106

11071107
/client/verb/reload_statpanel()
11081108
set name = "Reload Statpanel"

code/modules/mob/living/say.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ GLOBAL_LIST_INIT(special_radio_keys, list(
261261
else
262262
deaf_message = span_notice("You can't hear yourself!")
263263
deaf_type = 2 // Since you should be able to hear yourself without looking
264+
264265
// Create map text prior to modifying message for goonchat
265266
if (client?.prefs.read_preference(/datum/preference/toggle/enable_runechat) && stat != UNCONSCIOUS && (client.prefs.read_preference(/datum/preference/toggle/enable_runechat_non_mobs) || ismob(speaker)) && can_hear())
266267
create_chat_message(speaker, message_language, raw_message, spans)

yogstation.dme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4026,6 +4026,7 @@
40264026
#include "interface\fonts\spess_font.dm"
40274027
#include "interface\fonts\tiny_unicode.dm"
40284028
#include "interface\fonts\vcr_osd_mono.dm"
4029+
#include "tgui\states\greyscale_menu.dm"
40294030
#include "yogstation\code\__HELPERS\_lists.dm"
40304031
#include "yogstation\code\__HELPERS\_logging.dm"
40314032
#include "yogstation\code\__HELPERS\game.dm"

0 commit comments

Comments
 (0)