Skip to content

Commit

Permalink
yeah ok
Browse files Browse the repository at this point in the history
  • Loading branch information
Pariah919 committed Apr 8, 2022
1 parent d32ac43 commit 4604422
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 0 deletions.
1 change: 1 addition & 0 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -2141,6 +2141,7 @@
#include "code\modules\mob\living\damage_procs.dm"
#include "code\modules\mob\living\death.dm"
#include "code\modules\mob\living\default_language.dm"
#include "code\modules\mob\living\floating_say.dm"
#include "code\modules\mob\living\life.dm"
#include "code\modules\mob\living\living.dm"
#include "code\modules\mob\living\living_defense.dm"
Expand Down
4 changes: 4 additions & 0 deletions code/__defines/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@
// NULL_OR_EQUAL define, ported from Aurora
#define NULL_OR_EQUAL(self,other) (!(self) || (self) == (other))

// Literal punctuation

#define PUNCTUATION list("!", ".", "\"", ")", "'", ",", "?", ":", ";")


#define FOURSPACES "    "
#define CLIENT_FROM_VAR(I) (ismob(I) ? I:client : (isclient(I) ? I : (istype(I, /datum/mind) ? I:current?:client : null)))
5 changes: 5 additions & 0 deletions code/modules/client/preference_setup/global/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ var/list/_client_preferences_by_type
winset(C, "output", "is-visible=true;is-disabled=false")
winset(C, "browseroutput", "is-visible=false")

/datum/client_preference/floating_messages
description ="Floating chat messages"
key = "FLOATING_CHAT"
options = list(GLOB.PREF_SHOW, GLOB.PREF_HIDE)

/********************
* General Staff Preferences *
********************/
Expand Down
67 changes: 67 additions & 0 deletions code/modules/mob/living/floating_say.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Code by Chinsky. I've just changed some stuff around to fix some runtimes. Made by Matt.
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 = language ? generate_floating_text(src, language.scramble(message), style, fontsize, duration, show_to) : understood

for(var/client/C in show_to)
if(!C.mob.is_deaf() && C.get_preference_value(/datum/client_preference/floating_messages) == GLOB.PREF_SHOW)
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.plane = HUD_PLANE//Want to show this above most things.
I.layer = 10
I.alpha = 0
I.maptext_width = 80
I.maptext_height = 64
I.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA
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)

/proc/remove_images_from_clients(image/I, list/show_to)
for(var/client/C in show_to)
C.images -= I
qdel(I)
7 changes: 7 additions & 0 deletions code/modules/mob/living/say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,13 @@ proc/get_radio_key_from_channel(var/channel)
log_whisper("[name]/[key] : [message]")
else
log_say("[name]/[key] : [message]")

//Rune stuff.

var/new_message = message//Need a copy of the original message here

INVOKE_ASYNC(src, /atom/movable/proc/animate_chat, new_message, speaking, italics, speech_bubble_recipients, 40)

return 1

/mob/living/proc/say_signlang(var/message, var/verb="gestures", var/datum/language/language)
Expand Down

0 comments on commit 4604422

Please sign in to comment.