From 2e7beaaf4fb66ee064a8e80513a115fbd6409407 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sun, 22 Oct 2023 10:03:04 +0200 Subject: [PATCH] [MIRROR] Better looking ghost notifications [MDB IGNORE] (#24509) * Better looking ghost notifications * Update mob_helpers.dm --------- Co-authored-by: Jeremiah <42397676+jlsnow301@users.noreply.github.com> Co-authored-by: lessthanthree <83487515+lessthnthree@users.noreply.github.com> --- code/__HELPERS/priority_announce.dm | 9 ++- code/_onclick/hud/alert.dm | 16 +++--- code/modules/mob/mob_helpers.dm | 86 ++++++++++++++--------------- 3 files changed, 56 insertions(+), 55 deletions(-) diff --git a/code/__HELPERS/priority_announce.dm b/code/__HELPERS/priority_announce.dm index 0152358d94d..9bbb7e7f9a4 100644 --- a/code/__HELPERS/priority_announce.dm +++ b/code/__HELPERS/priority_announce.dm @@ -107,8 +107,9 @@ * players - optional, a list mobs to send the announcement to. If unset, sends to all palyers. * sound_override - optional, use the passed sound file instead of the default notice sounds. * should_play_sound - Whether the notice sound should be played or not. + * color_override - optional, use the passed color instead of the default notice color. */ -/proc/minor_announce(message, title = "Attention:", alert = FALSE, html_encode = TRUE, list/players = null, sound_override = null, should_play_sound = TRUE) +/proc/minor_announce(message, title = "Attention:", alert = FALSE, html_encode = TRUE, list/players, sound_override, should_play_sound = TRUE, color_override) if(!message) return @@ -120,7 +121,11 @@ minor_announcement_strings += MINOR_ANNOUNCEMENT_TITLE(title) minor_announcement_strings += MINOR_ANNOUNCEMENT_TEXT(message) - var/finalized_announcement = CHAT_ALERT_DEFAULT_SPAN(jointext(minor_announcement_strings, "
")) + var/finalized_announcement + if(color_override) + finalized_announcement = CHAT_ALERT_COLORED_SPAN(color_override, jointext(minor_announcement_strings, "
")) + else + finalized_announcement = CHAT_ALERT_DEFAULT_SPAN(jointext(minor_announcement_strings, "
")) var/custom_sound = sound_override || (alert ? 'modular_skyrat/modules/alerts/sound/alerts/alert1.ogg' : 'sound/misc/notice2.ogg') // SKYRAT EDIT CHANGE - CUSTOM ANNOUNCEMENTS - Original: 'sound/misc/notice1.ogg' dispatch_announcement_to_players(finalized_announcement, players, custom_sound, should_play_sound) diff --git a/code/_onclick/hud/alert.dm b/code/_onclick/hud/alert.dm index 7faf83a89fc..3bf16d1a726 100644 --- a/code/_onclick/hud/alert.dm +++ b/code/_onclick/hud/alert.dm @@ -776,22 +776,24 @@ or shoot a gun to move around via Newton's 3rd Law of Motion." dead_owner.reenter_corpse() /atom/movable/screen/alert/notify_action - name = "Body created" - desc = "A body was created. You can enter it." + name = "Something interesting is happening!" + desc = "This can be clicked on to perform an action." icon_state = "template" - timeout = 300 - var/atom/target = null + timeout = 30 SECONDS + /// The target to use the action on + var/atom/target + /// Which on click action to use var/action = NOTIFY_JUMP /atom/movable/screen/alert/notify_action/Click() . = ..() - if(!.) - return - if(!target) + if(isnull(target)) return + var/mob/dead/observer/ghost_owner = owner if(!istype(ghost_owner)) return + switch(action) if(NOTIFY_ATTACK) target.attack_ghost(ghost_owner) diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 8b8a8cff943..84d234a58d5 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -258,64 +258,58 @@ * * notify_suiciders If it should notify suiciders (who do not qualify for many ghost roles) * * notify_volume How loud the sound should be to spook the user */ -/proc/notify_ghosts(message, ghost_sound, enter_link, atom/source, mutable_appearance/alert_overlay, action = NOTIFY_JUMP, flashwindow = TRUE, ignore_mapload = TRUE, ignore_key, header, notify_suiciders = TRUE, notify_volume = 100) //Easy notification of ghosts. +/proc/notify_ghosts( + message, + ghost_sound, + enter_link, + atom/source, + mutable_appearance/alert_overlay, + action = NOTIFY_JUMP, + flashwindow = TRUE, + ignore_mapload = TRUE, + ignore_key, + header, + notify_suiciders = TRUE, + notify_volume = 100 +) if(ignore_mapload && SSatoms.initialized != INITIALIZATION_INNEW_REGULAR) //don't notify for objects created during a map load return + + var/list/viewers = list() for(var/mob/dead/observer/ghost in GLOB.player_list) if(!notify_suiciders && HAS_TRAIT(ghost, TRAIT_SUICIDED)) continue if(ignore_key && (ghost.ckey in GLOB.poll_ignore[ignore_key])) continue - var/orbit_link - if(source && action == NOTIFY_ORBIT) - orbit_link = " (Orbit)" - to_chat(ghost, span_ghostalert("[message][(enter_link) ? " [enter_link]" : ""][orbit_link]")) - if(ghost_sound) - SEND_SOUND(ghost, sound(ghost_sound, volume = notify_volume)) + + viewers += ghost // This mob will see the alert + if(flashwindow) window_flash(ghost.client) - if(!source) - continue - var/atom/movable/screen/alert/notify_action/alert = ghost.throw_alert("[REF(source)]_notify_action", /atom/movable/screen/alert/notify_action) - if(!alert) + + if(isnull(source)) continue - var/ui_style = ghost.client?.prefs?.read_preference(/datum/preference/choiced/ui_style) - var/erp_ui_style = ghost.client?.prefs?.read_preference(/datum/preference/choiced/ui_style) //SKYRAT EDIT - ADDITION - ERP ICONS FIX - if(ui_style) - alert.icon = ui_style2icon(ui_style) - alert.icon = erp_ui_style2icon(erp_ui_style) //SKYRAT EDIT - ADDITION - ERP ICONS FIX - if (header) - alert.name = header - alert.desc = message - alert.action = action - alert.target = source - if(!alert_overlay) - alert_overlay = new(source) - alert_overlay.pixel_x = 0 - alert_overlay.pixel_y = 0 - var/icon/size_check = icon(source.icon, source.icon_state) - var/scale = 1 - var/width = size_check.Width() - var/height = size_check.Height() - if(width > world.icon_size) - alert_overlay.pixel_x = -(world.icon_size / 2) * ((width - world.icon_size) / world.icon_size) - if(height > world.icon_size) - alert_overlay.pixel_y = -(world.icon_size / 2) * ((height - world.icon_size) / world.icon_size) - if(width > world.icon_size || height > world.icon_size) - if(width >= height) - scale = world.icon_size / width - else - scale = world.icon_size / height - alert_overlay.transform = alert_overlay.transform.Scale(scale) - alert_overlay.appearance_flags |= TILE_BOUND - alert_overlay.layer = FLOAT_LAYER - alert_overlay.plane = FLOAT_PLANE - alert.add_overlay(alert_overlay) -/** - * Heal a robotic body part on a mob - */ + var/atom/movable/screen/alert/notify_action/toast = ghost.throw_alert( + category = "[REF(source)]_notify_action", + type = /atom/movable/screen/alert/notify_action, + new_master = source, + ) + toast.action = action + toast.desc = "Click to [action]." + toast.name = header + toast.target = source + + var/orbit_link + if(source && action == NOTIFY_ORBIT) + orbit_link = " (Orbit)" + + var/text = "[message][(enter_link) ? " [enter_link]" : ""][orbit_link]" + + minor_announce(text, title = header, players = viewers, html_encode = FALSE, sound_override = ghost_sound, color_override = "purple") + +/// Heals a robotic limb on a mob /proc/item_heal_robotic(mob/living/carbon/human/human, mob/user, brute_heal, burn_heal) var/obj/item/bodypart/affecting = human.get_bodypart(check_zone(user.zone_selected)) if(!affecting || IS_ORGANIC_LIMB(affecting))