mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-31 20:11:56 +00:00
* Enforce preserving parent proc return values across ui_act call stacks (#53964) All ui_act procs should call parent by default. All procs should preserve the value of the parent proc when it's TRUTHY and pass it down the call stack. No UI should be interactible when its flags or state indicate it should not be, except when explicity overriden by child procs intentionally disregarding parent return values to achieve a specific goal. * Enforce preserving parent proc return values across ui_act call stacks Co-authored-by: Timberpoes <silent_insomnia_pp@hotmail.co.uk>
51 lines
1.2 KiB
Plaintext
51 lines
1.2 KiB
Plaintext
/mob/dead/observer/verb/show_notificationprefs()
|
|
set category = "Ghost"
|
|
set name = "Notification preferences"
|
|
set desc = "Notification preferences"
|
|
|
|
var/datum/notificationpanel/panel = new(usr)
|
|
|
|
panel.ui_interact(usr)
|
|
|
|
/datum/notificationpanel
|
|
var/client/user
|
|
|
|
/datum/notificationpanel/New(user)
|
|
if (ismob(user))
|
|
var/mob/M = user
|
|
if (!M.client)
|
|
CRASH("Ghost role notification panel attempted to open to a mob without a client")
|
|
src.user = M.client
|
|
else
|
|
src.user = user
|
|
|
|
/datum/notificationpanel/ui_state(mob/user)
|
|
return GLOB.observer_state
|
|
|
|
/datum/notificationpanel/ui_interact(mob/user, datum/tgui/ui)
|
|
ui = SStgui.try_update_ui(user, src, ui)
|
|
if(!ui)
|
|
ui = new(user, src, "NotificationPreferences")
|
|
ui.open()
|
|
|
|
/datum/notificationpanel/ui_data(mob/user)
|
|
. = list()
|
|
.["ignore"] = list()
|
|
for(var/key in GLOB.poll_ignore_desc)
|
|
.["ignore"] += list(list(
|
|
"key" = key,
|
|
"enabled" = (user.ckey in GLOB.poll_ignore[key]),
|
|
"desc" = GLOB.poll_ignore_desc[key]
|
|
))
|
|
|
|
/datum/notificationpanel/ui_act(action, params)
|
|
. = ..()
|
|
if(.)
|
|
return
|
|
switch (action)
|
|
if ("toggle_ignore")
|
|
var/key = params["key"]
|
|
if (key && islist(GLOB.poll_ignore[key]))
|
|
GLOB.poll_ignore[key] ^= list(user.ckey)
|
|
. = TRUE
|