From c95f566cd1ebae05eb726834afc03ff7e613b502 Mon Sep 17 00:00:00 2001 From: dearmochi <1496804+dearmochi@users.noreply.github.com> Date: Wed, 28 Jul 2021 11:06:43 +0200 Subject: [PATCH] Custom emotes display on runechat (#16355) * Custom emotes display on runechat * document symbol arg * Update code/__DEFINES/misc.dm --- code/__DEFINES/misc.dm | 3 +++ code/datums/chatmessage.dm | 24 ++++++++++++++++++------ code/modules/mob/emote.dm | 2 ++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index 3382177f2a5..e30c9a73d21 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -491,3 +491,6 @@ #define HALLUCINATE_MINOR 1 #define HALLUCINATE_MODERATE 2 #define HALLUCINATE_MAJOR 3 + +// Runechat symbol types +#define RUNECHAT_SYMBOL_EMOTE 1 diff --git a/code/datums/chatmessage.dm b/code/datums/chatmessage.dm index 32fca2cb249..ea64c708f55 100644 --- a/code/datums/chatmessage.dm +++ b/code/datums/chatmessage.dm @@ -55,8 +55,9 @@ * * owner - The mob that owns this overlay, only this mob will be able to view it * * italics - Should we use italics or not * * lifespan - The lifespan of the message in deciseconds + * * symbol - The symbol type of the message */ -/datum/chatmessage/New(text, atom/target, mob/owner, italics, size, lifespan = CHAT_MESSAGE_LIFESPAN) +/datum/chatmessage/New(text, atom/target, mob/owner, italics, size, lifespan = CHAT_MESSAGE_LIFESPAN, symbol) . = ..() if (!istype(target)) CRASH("Invalid target given for chatmessage") @@ -64,7 +65,7 @@ stack_trace("/datum/chatmessage created with [isnull(owner) ? "null" : "invalid"] mob owner") qdel(src) return - INVOKE_ASYNC(src, .proc/generate_image, text, target, owner, lifespan, italics, size) + INVOKE_ASYNC(src, .proc/generate_image, text, target, owner, lifespan, italics, size, symbol) /datum/chatmessage/Destroy() if (owned_by) @@ -93,8 +94,10 @@ * * radio_speech - Fancy shmancy radio icon represents that we use radio * * lifespan - The lifespan of the message in deciseconds * * italics - Just copy and paste, sir + * * size - Size of the message + * * symbol - The symbol type of the message */ -/datum/chatmessage/proc/generate_image(text, atom/target, mob/owner, lifespan, italics, size) +/datum/chatmessage/proc/generate_image(text, atom/target, mob/owner, lifespan, italics, size, symbol) // Register client who owns this message owned_by = owner.client RegisterSignal(owned_by, COMSIG_PARENT_QDELETING, .proc/on_parent_qdel) @@ -123,9 +126,17 @@ var/output_color = sanitize_color(target.get_runechat_color()) // Get_runechat_color can be overriden on atoms to display a specific one (Example: Humans having their hair colour as runechat colour) + // Symbol for special runechats (emote) + switch(symbol) + if(RUNECHAT_SYMBOL_EMOTE) + symbol = "* " + size = size || "small" + else + symbol = null + // Approximate text height var/static/regex/html_metachars = new(@"&[A-Za-z]{1,7};", "g") - var/complete_text = "[text]" + var/complete_text = "[symbol][text]" var/mheight = WXH_TO_HEIGHT(owned_by.MeasureText(complete_text, null, CHAT_MESSAGE_WIDTH)) approx_lines = max(1, mheight / CHAT_MESSAGE_APPROX_LHEIGHT) @@ -183,15 +194,16 @@ * * raw_message - The text content of the message * * italics - Vacuum and other things * * size - Size of the message + * * symbol - The symbol type of the message */ -/mob/proc/create_chat_message(atom/movable/speaker, raw_message, italics=FALSE, size) +/mob/proc/create_chat_message(atom/movable/speaker, raw_message, italics = FALSE, size, symbol) if(isobserver(src)) return // Display visual above source - new /datum/chatmessage(raw_message, speaker, src, italics, size) + new /datum/chatmessage(raw_message, speaker, src, italics, size, CHAT_MESSAGE_LIFESPAN, symbol) // Tweak these defines to change the available color ranges diff --git a/code/modules/mob/emote.dm b/code/modules/mob/emote.dm index beb9564ef86..aa8936f7682 100644 --- a/code/modules/mob/emote.dm +++ b/code/modules/mob/emote.dm @@ -90,6 +90,8 @@ M.show_message(message, m_type) O.show_message(message, m_type) + if(O.client?.prefs.toggles2 & PREFTOGGLE_2_RUNECHAT) + O.create_chat_message(src, input, symbol = RUNECHAT_SYMBOL_EMOTE) // Type 2 (Audible) emotes are sent to anyone in hear range // of the *LOCATION* -- this is important for pAIs to be heard