Notification support in modular computer apps and CIMS (#54724)

Allows modPC programs to send alerts, and adds a proc in the computer object to handle playing the sound effect and sending a message to visible users. These notifications can be muted on a per-program basis. Programs can also set themselves to highlighted in the NTOS Main menu; this is intended to be used along side alerts, but really can be used any time a program wishes to tell the user there is new information.

NT CIMS (SM monitor) now plays an alert during SM delaminations if the app is closed. The app must have had an SM selected before closing, or it will not send alerts. Notifications are sent when the SM makes a radio alert. If the app is currently the active program, the app will instead send a notification just once, when the SM begins delamination, so as to not annoy engineers that are already aware of the issue.
This commit is contained in:
zxaber
2020-11-17 23:43:19 -08:00
committed by GitHub
parent d1c0b74e8b
commit 185e85f32b
12 changed files with 143 additions and 6 deletions
@@ -263,6 +263,28 @@
handle_power(delta_time) // Handles all computer power interaction
//check_update_ui_need()
/**
* Displays notification text alongside a soundbeep when requested to by a program.
*
* After checking tha the requesting program is allowed to send an alert, creates
* a visible message of the requested text alongside a soundbeep. This proc adds
* text to indicate that the message is coming from this device and the program
* on it, so the supplied text should be the exact message and ending punctuation.
*
* Arguments:
* The program calling this proc.
* The message that the program wishes to display.
*/
/obj/item/modular_computer/proc/alert_call(datum/computer_file/program/caller, alerttext, sound = 'sound/machines/twobeep_high.ogg')
if(!caller || !caller.alert_able || caller.alert_silenced || !alerttext) //Yeah, we're checking alert_able. No, you don't get to make alerts that the user can't silence.
return
playsound(src, sound, 50, TRUE)
visible_message("<span class='notice'>The [src] displays a [caller.filedesc] notification: [alerttext]</span>")
var/mob/living/holder = loc
if(istype(holder))
to_chat(holder, "[icon2html(src)] <span class='notice'>The [src] displays a [caller.filedesc] notification: [alerttext]</span>")
// Function used by NanoUI's to obtain data for header. All relevant entries begin with "PC_"
/obj/item/modular_computer/proc/get_header_data()
var/list/data = list()
@@ -80,7 +80,7 @@
if(P in idle_threads)
running = TRUE
data["programs"] += list(list("name" = P.filename, "desc" = P.filedesc, "running" = running, "icon" = P.program_icon))
data["programs"] += list(list("name" = P.filename, "desc" = P.filedesc, "running" = running, "icon" = P.program_icon, "alert" = P.alert_pending))
data["has_light"] = has_light
data["light_on"] = light_on
@@ -148,6 +148,7 @@
if(P in idle_threads)
P.program_state = PROGRAM_STATE_ACTIVE
active_program = P
P.alert_pending = FALSE
idle_threads.Remove(P)
update_icon()
return
@@ -163,6 +164,7 @@
return
if(P.run_program(user))
active_program = P
P.alert_pending = FALSE
update_icon()
return 1
@@ -52,3 +52,9 @@
/obj/item/modular_computer/processor/attack_ghost(mob/user)
ui_interact(user)
/obj/item/modular_computer/processor/alert_call(datum/computer_file/program/caller, alerttext)
if(!caller || !caller.alert_able || caller.alert_silenced || !alerttext)
return
playsound(src, 'sound/machines/twobeep_high.ogg', 50, TRUE)
machinery_computer.visible_message("<span class='notice'>The [src] displays a [caller.filedesc] notification: [alerttext]</span>")
@@ -130,6 +130,13 @@
borgo.toggle_headlamp(FALSE, TRUE)
return TRUE
/obj/item/modular_computer/tablet/integrated/alert_call(datum/computer_file/program/caller, alerttext, sound = 'sound/machines/twobeep_high.ogg')
if(!caller || !caller.alert_able || caller.alert_silenced || !alerttext) //Yeah, we're checking alert_able. No, you don't get to make alerts that the user can't silence.
return
borgo.playsound_local(src, sound, 50, TRUE)
to_chat(borgo, "<span class='notice'>The [src] displays a [caller.filedesc] notification: [alerttext]</span>")
/obj/item/modular_computer/tablet/integrated/syndicate
icon_state = "tablet-silicon-syndicate"
device_theme = "syndicate"