Floating Messages (#8724)

What's the worst that could happen?
This commit is contained in:
Geeves
2020-04-25 16:13:24 +02:00
committed by GitHub
parent 0ea3ed9f87
commit 01c26be826
11 changed files with 96 additions and 6 deletions
@@ -94,6 +94,7 @@
"<b>Space Parallax:</b> <a href='?src=\ref[src];paratoggle=[PARALLAX_SPACE]'><b>[(pref.toggles_secondary & PARALLAX_SPACE) ? "Yes" : "No"]</b></a><br>",
"<b>Space Dust:</b> <a href='?src=\ref[src];paratoggle=[PARALLAX_DUST]'><b>[(pref.toggles_secondary & PARALLAX_DUST) ? "Yes" : "No"]</b></a><br>",
"<b>Progress Bars:</b> <a href='?src=\ref[src];paratoggle=[PROGRESS_BARS]'><b>[(pref.toggles_secondary & PROGRESS_BARS) ? "Yes" : "No"]</b></a><br>",
"<b>Floating Messages:</b> <a href='?src=\ref[src];paratoggle=[FLOATING_MESSAGES]'><b>[(pref.toggles_secondary & FLOATING_MESSAGES) ? "Yes" : "No"]</b></a><br>",
"<b>Static Space:</b> <a href='?src=\ref[src];paratoggle=[PARALLAX_IS_STATIC]'><b>[(pref.toggles_secondary & PARALLAX_IS_STATIC) ? "Yes" : "No"]</b></a><br>"
)
+1 -1
View File
@@ -128,7 +128,7 @@ datum/preferences
// SPAAAACE
var/parallax_speed = 2
var/toggles_secondary = PARALLAX_SPACE | PARALLAX_DUST | PROGRESS_BARS
var/toggles_secondary = PARALLAX_SPACE | PARALLAX_DUST | PROGRESS_BARS | FLOATING_MESSAGES
var/clientfps = 0
var/list/pai = list() // A list for holding pAI related data.
@@ -203,6 +203,15 @@
else
to_chat(src, "You will no longer see progress bars on delayed actions.")
/client/verb/toggle_floating_messages()
set name = "Toggle Floating Messages"
set desc = "Toggles messages appearing above mobs when they speak."
set category = "Preferences"
prefs.toggles_secondary ^= FLOATING_MESSAGES
prefs.save_preferences()
to_chat(src, SPAN_NOTICE("Floating messages are now [prefs.toggles_secondary & FLOATING_MESSAGES ? "enabled" : "disabled"]."))
/client/verb/toggle_static_spess()
set name = "Toggle Parallax Movement"
set category = "Preferences"
+1 -1
View File
@@ -8,7 +8,7 @@
var/orig_message = message
message = pick(SShallucinations.hallucinated_phrases)
log_say("Hallucination level changed [orig_message] by [speaker] to [message] for [key_name(src)].", ckey=key_name(src))
..()
return ..()
/mob/living/carbon/hear_radio(var/message, var/verb="says", var/datum/language/language, var/part_a, var/part_b, var/mob/speaker, var/hard_to_hear = 0, var/vname ="")
if(hallucination >= 60 && prob(1))
+70
View File
@@ -0,0 +1,70 @@
// Thanks to Burger from Burgerstation for the foundation for this
var/list/floating_chat_colors = list()
/atom/movable
var/list/stored_chat_text
/atom/movable/proc/animate_chat(message, datum/language/language, small, list/show_to, duration)
set waitfor = FALSE
var/style //additional style params for the message
var/fontsize = 6
if(small)
fontsize = 5
var/limit = 50
if(copytext(message, length(message) - 1) == "!!")
fontsize = 8
limit = 30
style += "font-weight: bold;"
if(length(message) > limit)
message = "[copytext(message, 1, limit)]..."
if(!floating_chat_colors[name])
floating_chat_colors[name] = get_random_colour(0, 160, 230)
style += "color: [floating_chat_colors[name]];"
// create 2 messages, one that appears if you know the language, and one that appears when you don't know the language
var/image/understood = generate_floating_text(src, capitalize(message), style, fontsize, duration, show_to)
var/image/gibberish
if(!isnull(language))
gibberish = generate_floating_text(src, language.scramble(message), style, fontsize, duration, show_to)
for(var/client/C in show_to)
if(!(C.prefs.toggles_secondary & FLOATING_MESSAGES))
continue
if(isnull(language))
C.images += understood
continue
if(C.mob.say_understands(null, language))
C.images += understood
else
C.images += gibberish
/proc/generate_floating_text(atom/movable/holder, message, style, size, duration, show_to)
var/image/I = image(null, holder)
I.layer = FLY_LAYER
I.alpha = 0
I.maptext_width = 80
I.maptext_height = 64
I.plane = FLOAT_PLANE
I.pixel_x = -round(I.maptext_width/2) + 16
style = "font-family: 'Small Fonts'; -dm-text-outline: 1 black; font-size: [size]px; [style]"
I.maptext = "<center><span style=\"[style]\">[message]</span></center>"
animate(I, 1, alpha = 255, pixel_y = 16)
for(var/image/old in holder.stored_chat_text)
animate(old, 2, pixel_y = old.pixel_y + 8)
LAZYADD(holder.stored_chat_text, I)
addtimer(CALLBACK(GLOBAL_PROC, .proc/remove_floating_text, holder, I), duration)
addtimer(CALLBACK(GLOBAL_PROC, .proc/remove_images_from_clients, I, show_to), duration + 2)
return I
/proc/remove_floating_text(atom/movable/holder, image/I)
animate(I, 2, pixel_y = I.pixel_y + 10, alpha = 0)
LAZYREMOVE(holder.stored_chat_text, I)
+1
View File
@@ -78,6 +78,7 @@
if (speech_sound && (get_dist(speaker, src) <= world.view && src.z == speaker.z))
var/turf/source = speaker? get_turf(speaker) : get_turf(src)
playsound_simple(source, speech_sound, sound_vol, use_random_freq = TRUE)
return TRUE
/mob/proc/on_hear_say(var/message)
to_chat(src, message)
+1 -1
View File
@@ -220,7 +220,7 @@
var/datum/brain_trauma/trauma = T
if(!trauma.suppressed)
message = trauma.on_hear(message, verb, language, alt_name, italics, speaker)
..()
return ..()
/mob/living/carbon/human/proc/handle_speech_muts(var/message, var/verb)
if(message)
+4 -3
View File
@@ -269,15 +269,16 @@ proc/get_radio_key_from_channel(var/channel)
var/list/hear_clients = list()
for(var/m in listening)
for(var/m in listening)
var/mob/M = m
M.hear_say(message, verb, speaking, alt_name, italics, src, speech_sound, sound_vol)
if (M.client)
var/heard_say = M.hear_say(message, verb, speaking, alt_name, italics, src, speech_sound, sound_vol)
if(heard_say && M.client)
hear_clients += M.client
var/speech_bubble_test = say_test(message)
var/image/speech_bubble = image('icons/mob/talk.dmi',src,"h[speech_bubble_test]")
INVOKE_ASYNC(GLOBAL_PROC, /proc/animate_speechbubble, speech_bubble, hear_clients, 30)
INVOKE_ASYNC(src, /atom/movable/proc/animate_chat, message, speaking, italics, hear_clients, 30)
for(var/o in listening_obj)
var/obj/O = o