Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Better looking ghost notifications #221

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions code/__HELPERS/priority_announce.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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, "<br>"))
var/finalized_announcement
if(color_override)
finalized_announcement = CHAT_ALERT_COLORED_SPAN(color_override, jointext(minor_announcement_strings, "<br>"))
else
finalized_announcement = CHAT_ALERT_DEFAULT_SPAN(jointext(minor_announcement_strings, "<br>"))

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)
Expand Down
16 changes: 9 additions & 7 deletions code/_onclick/hud/alert.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
86 changes: 40 additions & 46 deletions code/modules/mob/mob_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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 = " <a href='?src=[REF(ghost)];follow=[REF(source)]'>(Orbit)</a>"
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 = " <a href='?src=[REF(usr)];follow=[REF(source)]'>(Orbit)</a>"

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))
Expand Down
Loading