mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-12 08:36:00 +01:00
155 lines
5.1 KiB
Plaintext
155 lines
5.1 KiB
Plaintext
/**
|
|
* Alters text when players are injured.
|
|
* Adds text, trims left and right side
|
|
*
|
|
* Arguments:
|
|
* payload - a string list containing entry & channel
|
|
* Returns:
|
|
* string - the altered entry
|
|
*/
|
|
/datum/tgui_say/proc/alter_entry(payload)
|
|
var/entry = payload["entry"]
|
|
var/list/phrases = alter_phrases || hurt_phrases
|
|
|
|
/// No OOC leaks
|
|
if(!entry || payload["channel"] == OOC_CHANNEL || payload["channel"] == ME_CHANNEL || payload["channel"] == PRAY_CHANNEL || payload["channel"] == LOOC_CHANNEL) // BUBBER EDIT - CHANGE - ORIGINAL: if(!entry || payload["channel"] == OOC_CHANNEL || payload["channel"] == ME_CHANNEL || payload["channel"] == PRAY_CHANNEL)
|
|
return pick(phrases)
|
|
/// Random trimming for larger sentences
|
|
if(length(entry) > 50)
|
|
entry = trim(entry, rand(40, 50))
|
|
else
|
|
/// Otherwise limit trim to just last letter
|
|
if(length(entry) > 1)
|
|
entry = trim(entry, length(entry))
|
|
return entry + "-" + pick(phrases)
|
|
|
|
/**
|
|
* Delegates the speech to the proper channel.
|
|
*
|
|
* Arguments:
|
|
* entry - the text to broadcast
|
|
* channel - the channel to broadcast in
|
|
* Returns:
|
|
* boolean - on success or failure
|
|
*/
|
|
/datum/tgui_say/proc/delegate_speech(entry, channel)
|
|
switch(channel)
|
|
if(SAY_CHANNEL)
|
|
client.mob.say_verb(entry)
|
|
return TRUE
|
|
if(RADIO_CHANNEL)
|
|
client.mob.say_verb(";" + entry)
|
|
return TRUE
|
|
if(ME_CHANNEL)
|
|
client.mob.me_verb(entry)
|
|
return TRUE
|
|
if(OOC_CHANNEL)
|
|
ASYNC
|
|
client.ooc(entry)
|
|
return TRUE
|
|
if(ADMIN_CHANNEL)
|
|
INVOKE_ASYNC(SSadmin_verbs, TYPE_PROC_REF(/datum/controller/subsystem/admin_verbs, dynamic_invoke_verb), client, /datum/admin_verb/cmd_admin_say, entry)
|
|
return TRUE
|
|
// BUBBER EDIT - ADDITION - START
|
|
if(LOOC_CHANNEL)
|
|
INVOKE_ASYNC(client, TYPE_PROC_REF(/client, looc_message), entry)
|
|
return TRUE
|
|
if(WHIS_CHANNEL)
|
|
client.mob.whisper_verb(entry)
|
|
return TRUE
|
|
// BUBBER EDIT - ADDITION - END
|
|
if(PRAY_CHANNEL)
|
|
client.mob.pray(entry)
|
|
return TRUE
|
|
return FALSE
|
|
|
|
/**
|
|
* Force say handler.
|
|
* Sends a message to the say modal to send its current value.
|
|
* Arguments:
|
|
* alter_phrases - Optional list of alternate suffixes to blurt out
|
|
* immediate - If [TRUE], the say must be invoked inline due to side effects that may cause the mob to be unable to speak
|
|
*/
|
|
/datum/tgui_say/proc/force_say(list/alter_phrases = null, immediate = FALSE)
|
|
src.alter_phrases = alter_phrases
|
|
if(immediate)
|
|
if(!saved_text)
|
|
saved_text = ""
|
|
if(!saved_channel)
|
|
saved_channel = SAY_CHANNEL
|
|
|
|
handle_entry("force", list("type" = "force", "entry" = saved_text, "channel" = saved_channel))
|
|
window.send_message("close")
|
|
else
|
|
window.send_message("force")
|
|
|
|
stop_typing()
|
|
|
|
/**
|
|
* Exports whatever text is currently in the input box to this datum
|
|
*/
|
|
/datum/tgui_say/proc/save_text()
|
|
saved_text = null
|
|
window.send_message("save")
|
|
|
|
/**
|
|
* Makes the player force say what's in their current input box.
|
|
* Arguments:
|
|
* alter_phrases - Optional list of alternate suffixes to blurt out
|
|
* immediate - If [TRUE], the say must be invoked inline due to side effects that may cause the mob to be unable to speak
|
|
*/
|
|
/mob/living/carbon/human/proc/force_say(list/alter_phrases = null, immediate = FALSE)
|
|
if(stat != CONSCIOUS || !client?.tgui_say?.window_open)
|
|
return FALSE
|
|
client.tgui_say.force_say(alter_phrases, immediate)
|
|
if(client.typing_indicators)
|
|
log_speech_indicators("[key_name(client)] FORCED to stop typing, indicators enabled.")
|
|
else
|
|
log_speech_indicators("[key_name(client)] FORCED to stop typing, indicators DISABLED.")
|
|
SEND_SIGNAL(src, COMSIG_HUMAN_FORCESAY)
|
|
|
|
/**
|
|
* Gets whatever text is currently in this mob's say box and returns it.
|
|
*
|
|
* Note: Sleeps, due to waiting for say to respond.
|
|
*/
|
|
/mob/proc/get_typing_text()
|
|
if(!client?.tgui_say?.window_open)
|
|
return
|
|
client.tgui_say.save_text()
|
|
var/safety = world.time
|
|
UNTIL(istext(client?.tgui_say?.saved_text) || world.time - safety > 2 SECONDS)
|
|
return client?.tgui_say?.saved_text
|
|
|
|
/**
|
|
* Handles text entry and forced speech.
|
|
*
|
|
* Arguments:
|
|
* type - a string "entry" or "force" based on how this function is called
|
|
* payload - a string list containing entry & channel
|
|
* Returns:
|
|
* boolean - success or failure
|
|
*/
|
|
/datum/tgui_say/proc/handle_entry(type, payload)
|
|
if(!payload?["channel"] || isnull(payload["entry"]))
|
|
CRASH("[usr] entered in a null payload to the chat window.")
|
|
if(length(payload["entry"]) > max_length)
|
|
CRASH("[usr] has entered more characters than allowed into a TGUI-Say")
|
|
if(type == "entry")
|
|
delegate_speech(payload["entry"], payload["channel"])
|
|
return TRUE
|
|
if(type == "force")
|
|
var/target_channel = payload["channel"]
|
|
if(target_channel == ME_CHANNEL || target_channel == OOC_CHANNEL || target_channel == PRAY_CHANNEL)
|
|
target_channel = SAY_CHANNEL // No ooc leaks
|
|
delegate_speech(alter_entry(payload), target_channel)
|
|
return TRUE
|
|
if(type == "save")
|
|
saved_text = "" // so we can differentiate null (nothing saved) and empty (nothing typed)
|
|
var/target_channel = payload["channel"]
|
|
if(target_channel == SAY_CHANNEL || target_channel == RADIO_CHANNEL)
|
|
saved_text = payload["entry"] // only save IC text
|
|
saved_channel = target_channel
|
|
return TRUE
|
|
return FALSE
|