|
26 | 26 | /// The number of z-layer 'slices' usable by the chat message layering |
27 | 27 | #define CHAT_LAYER_MAX_Z (CHAT_LAYER_MAX - CHAT_LAYER) / CHAT_LAYER_Z_STEP |
28 | 28 |
|
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 | | - |
38 | 29 | /** |
39 | 30 | * # Chat Message Overlay |
40 | 31 | * |
|
83 | 74 | stack_trace("/datum/chatmessage created with [isnull(owner) ? "null" : "invalid"] mob owner") |
84 | 75 | qdel(src) |
85 | 76 | 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) |
88 | 78 |
|
89 | 79 | /datum/chatmessage/Destroy() |
90 | 80 | if (!QDELING(owned_by)) |
|
124 | 114 |
|
125 | 115 | // Register client who owns this message |
126 | 116 | 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)) |
128 | 118 |
|
129 | 119 | // Remove spans in the message from things like the recorder |
130 | 120 | var/static/regex/span_check = new(@"<\/?span[^>]*>", "gi") |
|
185 | 175 | var/tgt_color = extra_classes.Find("italics") ? target.chat_color_darkened : target.chat_color |
186 | 176 |
|
187 | 177 | // 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>" |
192 | 179 |
|
193 | 180 | var/mheight |
194 | 181 | WXH_TO_HEIGHT(owned_by.MeasureText(complete_text, null, CHAT_MESSAGE_WIDTH), mheight) |
195 | 182 |
|
196 | | - |
197 | 183 | if(!VERB_SHOULD_YIELD) |
198 | 184 | return finish_image_generation(mheight, target, owner, complete_text, lifespan) |
199 | 185 |
|
|
281 | 267 | // Fade out |
282 | 268 | animate(alpha = 0, time = CHAT_MESSAGE_EOL_FADE) |
283 | 269 |
|
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) |
288 | 272 |
|
| 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 |
289 | 276 |
|
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 |
293 | 282 |
|
294 | 283 | /** |
295 | 284 | * Creates a message overlay at a defined location for a given speaker |
|
325 | 314 | if(runechat_flags & EMOTE_MESSAGE) |
326 | 315 | new /datum/chatmessage(raw_message, speaker, src, message_language, list("emote", "italics")) |
327 | 316 | 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) |
329 | 318 |
|
330 | 319 | // Tweak these defines to change the available color ranges |
331 | 320 | #define CM_COLOR_SAT_MIN 0.6 |
|
0 commit comments