forked from BoHBranch/BoH-Bay
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters