From 2351a3d8edfe1730502597bb0be79a63c8ee5337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=83=D0=BC=D0=B0=D1=81=D0=B0=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B0=D0=BD=20C=D0=B0=D0=BC=D0=B0=D0=BB=D0=B0=D0=BD=20?= =?UTF-8?q?=D0=91=D0=B0=D0=B1=D0=B0=D0=BD?= Date: Tue, 12 Dec 2023 20:48:12 +0700 Subject: [PATCH 1/7] some blurb shtukas some blurb shtukas linter is 3.14 RAS --- .../loc_blurb/code/location_blurb.dm | 43 +++++++++++++++++++ modular_ss220/loc_blurb/loc_blurb.dme | 9 ++++ modular_ss220/modular_ss220.dme | 1 + 3 files changed, 53 insertions(+) create mode 100644 modular_ss220/loc_blurb/code/location_blurb.dm create mode 100644 modular_ss220/loc_blurb/loc_blurb.dme diff --git a/modular_ss220/loc_blurb/code/location_blurb.dm b/modular_ss220/loc_blurb/code/location_blurb.dm new file mode 100644 index 000000000000..b252880f3986 --- /dev/null +++ b/modular_ss220/loc_blurb/code/location_blurb.dm @@ -0,0 +1,43 @@ + +/proc/show_location_blurb(client/C, duration = 3 SECONDS) + set waitfor = FALSE + + var/style = "font-family: 'Fixedsys'; -dm-text-outline: 1 black; font-size: 11px;" + var/area/A = get_area(C.mob) + var/text = "[GLOB.current_date_string], [station_time_timestamp()]\n[station_name()], [A.name]" + text = uppertext(text) + + var/atom/movable/screen/T = new /atom/movable/screen{ + maptext_height = 64; + maptext_width = 512; + layer = FLOAT_LAYER; + plane = HUD_PLANE; + appearance_flags = APPEARANCE_UI_IGNORE_ALPHA; + screen_loc = "LEFT+1,BOTTOM+2"; + alpha = 0; + } + + C.screen += T + animate(T, alpha = 255, time = 10) + for(var/i = 1 to length_char(text) + 1) + T.maptext = "[copytext_char(text, 1, i)] " + sleep(1) + + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(fade_location_blurb), C, T), duration) + +/proc/fade_location_blurb(client/C, obj/T) + animate(T, alpha = 0, time = 5) + sleep(5) + if(C) + C.screen -= T + qdel(T) + + +/datum/controller/subsystem/jobs/EquipRank(mob/living/carbon/human/H, rank, joined_late = 0) + . = ..() + INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(show_location_blurb), H.client, 30) + +/datum/controller/subsystem/ticker/reboot_helper(reason, end_string, delay) + for(var/mob/M as anything in GLOB.player_list) + show_blurb(M, 900, "Round is restarting...", null, "center", "center", COLOR_RED, null, null, 1) + . = ..() diff --git a/modular_ss220/loc_blurb/loc_blurb.dme b/modular_ss220/loc_blurb/loc_blurb.dme new file mode 100644 index 000000000000..45fe329192b0 --- /dev/null +++ b/modular_ss220/loc_blurb/loc_blurb.dme @@ -0,0 +1,9 @@ +#ifndef MODPACK_LOCBLURB +#define MODPACK_LOCBLURB + +#endif + +// BEGIN INCLUDE +#include "code/location_blurb.dm" +// END_INCLUDE + diff --git a/modular_ss220/modular_ss220.dme b/modular_ss220/modular_ss220.dme index 53a170e02283..e7da6bcad047 100644 --- a/modular_ss220/modular_ss220.dme +++ b/modular_ss220/modular_ss220.dme @@ -77,6 +77,7 @@ #include "phrases/_phrases.dme" #include "species_whitelist/_species_whitelist.dme" #include "antagonists/_antagonists.dme" +#include "loc_blurb/loc_blurb.dme" // --- PRIME --- // // #define MODPACK_MAIN_ONLY From 529228d76e8e088f513b36b037cf2dd4a4fa075e Mon Sep 17 00:00:00 2001 From: gaxeer Date: Tue, 12 Dec 2023 20:51:57 +0200 Subject: [PATCH 2/7] refactor: rewrite text blurb from the ground to subtype of `/obj/screen/text` --- .../loc_blurb/code/location_blurb.dm | 171 ++++++++++++++---- 1 file changed, 133 insertions(+), 38 deletions(-) diff --git a/modular_ss220/loc_blurb/code/location_blurb.dm b/modular_ss220/loc_blurb/code/location_blurb.dm index b252880f3986..f8e44bed044b 100644 --- a/modular_ss220/loc_blurb/code/location_blurb.dm +++ b/modular_ss220/loc_blurb/code/location_blurb.dm @@ -1,43 +1,138 @@ +/obj/screen/text/blurb + maptext_height = 64 + maptext_width = 512 + screen_loc = "LEFT+1,BOTTOM+2" + /// Font size in pixels + var/font_size = 11 + /// Font family + var/font_family = "Fixedsys" + /// Where text is aligned + var/text_alignment = "left" + /// Color of text in RGB + var/text_color = COLOR_WHITE + /// Color of text outline + var/text_outline_color = COLOR_BLACK + /// Width of text outline in pixels + var/text_outline_width = 1 + /// Text that will be shown in blurb + var/blurb_text = "" + /// Number of chars from the `text` that will be displayed per interval. Defaults to 1 + var/chars_per_interval = 1 + /// The interval between chars rendering + var/interval = 1 DECISECONDS + /// Amount of time the blurb will be present on the screen. 0 means that blurb will dissappear immediately + var/hold_for = 0 + /// Amount of time the blurbs appering (alpha changing from 0 to 255). 0 means blurb is fully opaque from the start + var/appear_animation_duration = 0 + /// Amount of time the blurb takes to fade (alpha changing from 255 to 0). 0 means blurb is instantly removed from the screen after finished + var/fade_animation_duration = 0 -/proc/show_location_blurb(client/C, duration = 3 SECONDS) - set waitfor = FALSE - - var/style = "font-family: 'Fixedsys'; -dm-text-outline: 1 black; font-size: 11px;" - var/area/A = get_area(C.mob) - var/text = "[GLOB.current_date_string], [station_time_timestamp()]\n[station_name()], [A.name]" - text = uppertext(text) - - var/atom/movable/screen/T = new /atom/movable/screen{ - maptext_height = 64; - maptext_width = 512; - layer = FLOAT_LAYER; - plane = HUD_PLANE; - appearance_flags = APPEARANCE_UI_IGNORE_ALPHA; - screen_loc = "LEFT+1,BOTTOM+2"; - alpha = 0; - } - - C.screen += T - animate(T, alpha = 255, time = 10) - for(var/i = 1 to length_char(text) + 1) - T.maptext = "[copytext_char(text, 1, i)] " - sleep(1) - - addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(fade_location_blurb), C, T), duration) - -/proc/fade_location_blurb(client/C, obj/T) - animate(T, alpha = 0, time = 5) - sleep(5) - if(C) - C.screen -= T - qdel(T) - - -/datum/controller/subsystem/jobs/EquipRank(mob/living/carbon/human/H, rank, joined_late = 0) + +/obj/screen/text/blurb/proc/show_to(list/client/viewers) + if(!blurb_text || !viewers) + return + + if(islist(viewers)) + if(!length(viewers)) + return + + else + viewers = list(viewers) + + for(var/client/viewer as anything in viewers) + viewer.screen += src + + appear() + print_text() + + if(hold_for) + addtimer(CALLBACK(src, TYPE_PROC_REF(/obj/screen/text/blurb, hide_from), viewers), hold_for) + else + hide_from(viewers) + + +/obj/screen/text/blurb/proc/get_text_style() + return {"\ + font-family: [font_family], [initial(font_family)]; \ + -dm-text-outline: [text_outline_width] [text_outline_color]; \ + font-size: [font_size]px; \ + text-align: [text_alignment]; \ + color: [text_color]; + "} + +/obj/screen/text/blurb/proc/hide_from(list/client/viewers) + PRIVATE_PROC(TRUE) + + fade() + addtimer(CALLBACK(src, TYPE_PROC_REF(/obj/screen/text/blurb, remove_from_viewers), viewers), fade_animation_duration) + +/obj/screen/text/blurb/proc/appear() + PRIVATE_PROC(TRUE) + + animate(src, alpha = 255, time = appear_animation_duration) + + +/obj/screen/text/blurb/proc/fade() + PRIVATE_PROC(TRUE) + + animate(src, alpha = 0, time = fade_animation_duration) + + +/obj/screen/text/blurb/proc/print_text() + PRIVATE_PROC(TRUE) + + var/text_style = get_text_style() + var/text_length = length_char(blurb_text) + for(var/segment_start = 1, segment_start <= text_length, segment_start += chars_per_interval) + var/segment_end = min(text_length + 1, segment_start + chars_per_interval) + maptext += get_formatted_text_segment(text_style, segment_start, segment_end) + sleep(interval) + +/obj/screen/text/blurb/proc/get_formatted_text_segment(style, segment_start, segment_end) + return "[copytext_char(blurb_text, segment_start, segment_end)]" + +/obj/screen/text/blurb/proc/remove_from_viewers(list/client/viewers) + PRIVATE_PROC(TRUE) + + for(var/client/viewer as anything in viewers) + viewer.screen -= src + + qdel(src) + +/datum/controller/subsystem/jobs/proc/show_location_blurb(client/show_blurb_to) + PRIVATE_PROC(TRUE) + + if(!show_blurb_to.mob) + return + + var/obj/screen/text/blurb/location_blurb = new() + location_blurb.blurb_text = uppertext("[GLOB.current_date_string], [station_time_timestamp()]\n[station_name()], [get_area_name(show_blurb_to.mob, TRUE)]") + location_blurb.hold_for = 3 SECONDS + location_blurb.appear_animation_duration = 1 SECONDS + location_blurb.fade_animation_duration = 0.5 SECONDS + + location_blurb.show_to(show_blurb_to) + +/datum/controller/subsystem/jobs/EquipRank(mob/living/carbon/human/human_to_equip, rank, joined_late) . = ..() - INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(show_location_blurb), H.client, 30) + INVOKE_ASYNC(src, TYPE_PROC_REF(/datum/controller/subsystem/jobs, show_location_blurb), human_to_equip.client) /datum/controller/subsystem/ticker/reboot_helper(reason, end_string, delay) - for(var/mob/M as anything in GLOB.player_list) - show_blurb(M, 900, "Round is restarting...", null, "center", "center", COLOR_RED, null, null, 1) + if(delay) + INVOKE_ASYNC(src, TYPE_PROC_REF(/datum/controller/subsystem/ticker, show_server_restart_blurb), reason) + . = ..() + + +/datum/controller/subsystem/ticker/proc/show_server_restart_blurb(reason) + if(!length(GLOB.clients)) + return + + var/obj/screen/text/blurb/server_restart_blurp = new() + server_restart_blurp.text_color = COLOR_RED + server_restart_blurp.blurb_text = "Round is restarting...\n[reason]" + server_restart_blurp.hold_for = 90 SECONDS + server_restart_blurp.appear_animation_duration = 1 SECONDS + server_restart_blurp.fade_animation_duration = 0.5 SECONDS + + server_restart_blurp.show_to(GLOB.clients) From dddbe8f13117619195ac5c01701e4e85992a9e96 Mon Sep 17 00:00:00 2001 From: gaxeer Date: Tue, 12 Dec 2023 20:53:39 +0200 Subject: [PATCH 3/7] refactor: mark more procs as `private` --- modular_ss220/loc_blurb/code/location_blurb.dm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modular_ss220/loc_blurb/code/location_blurb.dm b/modular_ss220/loc_blurb/code/location_blurb.dm index f8e44bed044b..34c333ee8721 100644 --- a/modular_ss220/loc_blurb/code/location_blurb.dm +++ b/modular_ss220/loc_blurb/code/location_blurb.dm @@ -52,6 +52,8 @@ /obj/screen/text/blurb/proc/get_text_style() + PRIVATE_PROC(TRUE) + return {"\ font-family: [font_family], [initial(font_family)]; \ -dm-text-outline: [text_outline_width] [text_outline_color]; \ @@ -125,6 +127,8 @@ /datum/controller/subsystem/ticker/proc/show_server_restart_blurb(reason) + PRIVATE_PROC(TRUE) + if(!length(GLOB.clients)) return From 0cf2f799709b7defb83ad383a745ad44d698aebc Mon Sep 17 00:00:00 2001 From: gaxeer Date: Wed, 31 Jan 2024 19:50:12 +0200 Subject: [PATCH 4/7] fix: fix runtime in client screen accessing --- modular_ss220/loc_blurb/code/location_blurb.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modular_ss220/loc_blurb/code/location_blurb.dm b/modular_ss220/loc_blurb/code/location_blurb.dm index 34c333ee8721..b11e4179c555 100644 --- a/modular_ss220/loc_blurb/code/location_blurb.dm +++ b/modular_ss220/loc_blurb/code/location_blurb.dm @@ -39,7 +39,7 @@ else viewers = list(viewers) - for(var/client/viewer as anything in viewers) + for(var/client/viewer in viewers) viewer.screen += src appear() @@ -96,7 +96,7 @@ /obj/screen/text/blurb/proc/remove_from_viewers(list/client/viewers) PRIVATE_PROC(TRUE) - for(var/client/viewer as anything in viewers) + for(var/client/viewer in viewers) viewer.screen -= src qdel(src) From 8716df5a861397b481ee5f217864e141f9ec919f Mon Sep 17 00:00:00 2001 From: gaxeer Date: Wed, 31 Jan 2024 20:11:52 +0200 Subject: [PATCH 5/7] refactor: clear redundant defines --- modular_ss220/loc_blurb/_loc_blurb.dm | 4 ++++ modular_ss220/loc_blurb/_loc_blurb.dme | 3 +++ modular_ss220/loc_blurb/loc_blurb.dme | 9 --------- 3 files changed, 7 insertions(+), 9 deletions(-) create mode 100644 modular_ss220/loc_blurb/_loc_blurb.dm create mode 100644 modular_ss220/loc_blurb/_loc_blurb.dme delete mode 100644 modular_ss220/loc_blurb/loc_blurb.dme diff --git a/modular_ss220/loc_blurb/_loc_blurb.dm b/modular_ss220/loc_blurb/_loc_blurb.dm new file mode 100644 index 000000000000..d9dd285357fe --- /dev/null +++ b/modular_ss220/loc_blurb/_loc_blurb.dm @@ -0,0 +1,4 @@ +/datum/modpack/loadout + name = "Location Blurb" + desc = "Добавляет кинематографиченое оповещение на экране о локации и времени" + author = "h1llway, Gaxeer" diff --git a/modular_ss220/loc_blurb/_loc_blurb.dme b/modular_ss220/loc_blurb/_loc_blurb.dme new file mode 100644 index 000000000000..50aac8b0e76e --- /dev/null +++ b/modular_ss220/loc_blurb/_loc_blurb.dme @@ -0,0 +1,3 @@ +#include "_loc_blurb.dm" + +#include "code/location_blurb.dm" diff --git a/modular_ss220/loc_blurb/loc_blurb.dme b/modular_ss220/loc_blurb/loc_blurb.dme deleted file mode 100644 index 45fe329192b0..000000000000 --- a/modular_ss220/loc_blurb/loc_blurb.dme +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef MODPACK_LOCBLURB -#define MODPACK_LOCBLURB - -#endif - -// BEGIN INCLUDE -#include "code/location_blurb.dm" -// END_INCLUDE - From 31af7d22b7e0b16d5b44ebaeae42c5dfe1afeff0 Mon Sep 17 00:00:00 2001 From: gaxeer Date: Wed, 31 Jan 2024 20:15:06 +0200 Subject: [PATCH 6/7] refactor: null check client instead of typecheck --- modular_ss220/loc_blurb/code/location_blurb.dm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modular_ss220/loc_blurb/code/location_blurb.dm b/modular_ss220/loc_blurb/code/location_blurb.dm index b11e4179c555..1790a645095c 100644 --- a/modular_ss220/loc_blurb/code/location_blurb.dm +++ b/modular_ss220/loc_blurb/code/location_blurb.dm @@ -39,8 +39,9 @@ else viewers = list(viewers) - for(var/client/viewer in viewers) - viewer.screen += src + for(var/client/viewer as anything in viewers) + if(viewer) + viewer.screen += src appear() print_text() @@ -96,8 +97,9 @@ /obj/screen/text/blurb/proc/remove_from_viewers(list/client/viewers) PRIVATE_PROC(TRUE) - for(var/client/viewer in viewers) - viewer.screen -= src + for(var/client/viewer as anything in viewers) + if(viewer) + viewer.screen -= src qdel(src) From ddaa7dadc7b5cf89a91c058ae89404f7cae8fee1 Mon Sep 17 00:00:00 2001 From: gaxeer Date: Wed, 31 Jan 2024 20:25:50 +0200 Subject: [PATCH 7/7] fix: fix compilation error --- modular_ss220/modular_ss220.dme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modular_ss220/modular_ss220.dme b/modular_ss220/modular_ss220.dme index e7da6bcad047..02e4efbf83e8 100644 --- a/modular_ss220/modular_ss220.dme +++ b/modular_ss220/modular_ss220.dme @@ -77,7 +77,7 @@ #include "phrases/_phrases.dme" #include "species_whitelist/_species_whitelist.dme" #include "antagonists/_antagonists.dme" -#include "loc_blurb/loc_blurb.dme" +#include "loc_blurb/_loc_blurb.dme" // --- PRIME --- // // #define MODPACK_MAIN_ONLY