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
@@ -67,6 +67,13 @@
var/datum/computer_file/C = F.clone(FALSE)
HDD.store_file(C)
return TRUE
if("PRG_togglesilence")
if(!HDD)
return
var/datum/computer_file/program/binary = HDD.find_file_by_name(params["name"])
if(!binary || !istype(binary))
return
binary.alert_silenced = !binary.alert_silenced
/datum/computer_file/program/filemanager/ui_data(mob/user)
var/list/data = get_header_data()
@@ -80,11 +87,19 @@
else
var/list/files = list()
for(var/datum/computer_file/F in HDD.stored_files)
var/noisy = FALSE
var/silenced = FALSE
var/datum/computer_file/program/binary = F
if(istype(binary))
noisy = binary.alert_able
silenced = binary.alert_silenced
files += list(list(
"name" = F.filename,
"type" = F.filetype,
"size" = F.size,
"undeletable" = F.undeletable
"undeletable" = F.undeletable,
"alert_able" = noisy,
"alert_silenced" = silenced
))
data["files"] = files
if(RHDD)
@@ -9,10 +9,15 @@
size = 5
tgui_id = "NtosSupermatterMonitor"
program_icon = "radiation"
alert_able = TRUE
var/last_status = SUPERMATTER_INACTIVE
var/list/supermatters
var/obj/machinery/power/supermatter_crystal/active // Currently selected supermatter crystal.
/datum/computer_file/program/supermatter_monitor/Destroy()
clear_signals()
active = null
return ..()
/datum/computer_file/program/supermatter_monitor/process_tick()
..()
@@ -26,10 +31,11 @@
/datum/computer_file/program/supermatter_monitor/run_program(mob/living/user)
. = ..(user)
if(!(active in GLOB.machines))
active = null
refresh()
/datum/computer_file/program/supermatter_monitor/kill_program(forced = FALSE)
active = null
supermatters = null
..()
@@ -53,6 +59,58 @@
for(var/obj/machinery/power/supermatter_crystal/S in supermatters)
. = max(., S.get_status())
/**
* Sets up the signal listener for Supermatter delaminations.
*
* Unregisters any old listners for SM delams, and then registers one for the SM refered
* to in the `active` variable. This proc is also used with no active SM to simply clear
* the signal and exit.
*/
/datum/computer_file/program/supermatter_monitor/proc/set_signals()
if(active)
RegisterSignal(active, COMSIG_SUPERMATTER_DELAM_ALARM, .proc/send_alert, override = TRUE)
RegisterSignal(active, COMSIG_SUPERMATTER_DELAM_START_ALARM, .proc/send_start_alert, override = TRUE)
/**
* Removes the signal listener for Supermatter delaminations from the selected supermatter.
*
* Pretty much does what it says.
*/
/datum/computer_file/program/supermatter_monitor/proc/clear_signals()
if(active)
UnregisterSignal(active, COMSIG_SUPERMATTER_DELAM_ALARM)
UnregisterSignal(active, COMSIG_SUPERMATTER_DELAM_START_ALARM)
/**
* Sends an SM delam alert to the computer.
*
* Triggered by a signal from the selected supermatter, this proc sends a notification
* to the computer if the program is either closed or minimized. We do not send these
* notifications to the comptuer if we're the active program, because engineers fixing
* the supermatter probably don't need constant beeping to distract them.
*/
/datum/computer_file/program/supermatter_monitor/proc/send_alert()
if(!computer.get_ntnet_status())
return
if(computer.active_program != src)
computer.alert_call(src, "Crystal delamination in progress!")
alert_pending = TRUE
/**
* Sends an SM delam start alert to the computer.
*
* Triggered by a signal from the selected supermatter at the start of a delamination,
* this proc sends a notification to the computer if this program is the active one.
* We do this so that people carrying a tablet with NT CIMS open but with the NTOS window
* closed will still get one audio alert. This is not sent to computers with the program
* minimized or closed to avoid double-notifications.
*/
/datum/computer_file/program/supermatter_monitor/proc/send_start_alert()
if(!computer.get_ntnet_status())
return
if(computer.active_program == src)
computer.alert_call(src, "Crystal delamination in progress!")
/datum/computer_file/program/supermatter_monitor/ui_data()
var/list/data = get_header_data()
@@ -112,6 +170,7 @@
switch(action)
if("PRG_clear")
clear_signals()
active = null
return TRUE
if("PRG_refresh")
@@ -122,4 +181,5 @@
for(var/obj/machinery/power/supermatter_crystal/S in supermatters)
if(S.uid == newuid)
active = S
set_signals()
return TRUE