diff --git a/code/__HELPERS/time.dm b/code/__HELPERS/time.dm
index 83347c20d3b..f205c7cf0ce 100644
--- a/code/__HELPERS/time.dm
+++ b/code/__HELPERS/time.dm
@@ -95,7 +95,7 @@ proc/isDay(var/month, var/day)
/proc/seconds_to_time(var/seconds as num)
var/numSeconds = seconds % 60
var/numMinutes = (seconds - numSeconds) / 60
- return "[numMinutes] [numMinutes > 1 ? "minutes" : "minute"] and [numSeconds] seconds."
+ return "[numMinutes] [numMinutes > 1 ? "minutes" : "minute"] and [numSeconds] seconds"
//Take a value in seconds and makes it display like a clock
/proc/seconds_to_clock(var/seconds as num)
diff --git a/code/game/machinery/doors/brigdoors.dm b/code/game/machinery/doors/brigdoors.dm
index 36eba1a6ee5..268f2ede9fb 100644
--- a/code/game/machinery/doors/brigdoors.dm
+++ b/code/game/machinery/doors/brigdoors.dm
@@ -36,9 +36,10 @@
var/crimes = CELL_NONE
var/time = 0
var/officer = CELL_NONE
- var/prisoner_name = ""
- var/prisoner_charge = ""
- var/prisoner_time = ""
+ var/prisoner_name
+ var/prisoner_charge
+ var/prisoner_time
+ var/prisoner_hasrecord = FALSE
/obj/machinery/door_timer/New()
GLOB.celltimers_list += src
@@ -82,10 +83,15 @@
var/datum/data/record/R = find_security_record("name", occupant)
- var/announcetext = "Detainee [occupant] ([prisoner_drank]) has been incarcerated for [seconds_to_time(timetoset / 10)] for the charges of: '[crimes]'. \
+ var/timetext = seconds_to_time(timetoset / 10)
+ var/announcetext = "Detainee [occupant] ([prisoner_drank]) has been incarcerated for [timetext] for the crime of: '[crimes]'. \
Arresting Officer: [usr.name].[R ? "" : " Detainee record not found, manual record update required."]"
Radio.autosay(announcetext, name, "Security", list(z))
+ // Notify the actual criminal being brigged. This is a QOL thing to ensure they always know the charges against them.
+ // Announcing it on radio isn't enough, as they're unlikely to have sec radio.
+ notify_prisoner("You have been incarcerated for [timetext] for the crime of: '[crimes]'.")
+
if(prisoner_trank != "unknown" && prisoner_trank != "Civilian")
SSjobs.notify_dept_head(prisoner_trank, announcetext)
@@ -104,6 +110,13 @@
update_all_mob_security_hud()
return 1
+/obj/machinery/door_timer/proc/notify_prisoner(notifytext)
+ for(var/mob/living/carbon/human/H in range(4, get_turf(src)))
+ if(occupant == H.name)
+ to_chat(H, "[src] beeps, \"[notifytext]\"")
+ return
+ atom_say("[src] beeps, \"[occupant]: [notifytext]\"")
+
/obj/machinery/door_timer/Initialize()
..()
@@ -261,13 +274,11 @@
return
-//Allows AIs to use door_timer, see human attack_hand function below
/obj/machinery/door_timer/attack_ai(mob/user)
- attack_hand(user)
- ui_interact(user)
+ tgui_interact(user)
/obj/machinery/door_timer/attack_ghost(mob/user)
- ui_interact(user)
+ tgui_interact(user)
//Allows humans to use door_timer
//Opens dialog window when someone clicks on door timer
@@ -276,71 +287,109 @@
/obj/machinery/door_timer/attack_hand(mob/user)
if(..())
return
- ui_interact(user)
+ tgui_interact(user)
-/obj/machinery/door_timer/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
- ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
+/obj/machinery/door_timer/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = TRUE, datum/tgui/master_ui = null, datum/tgui_state/state = GLOB.tgui_default_state)
+ ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
- ui = new(user, src, ui_key, "brig_timer.tmpl", "Brig Timer", 500, 400)
+ ui = new(user, src, ui_key, "BrigTimer", name, 500, 450, master_ui, state)
ui.open()
- ui.set_auto_update(TRUE)
-/obj/machinery/door_timer/ui_data(mob/user, ui_key = "main", datum/topic_state/state = GLOB.default_state)
- var/data[0]
+/obj/machinery/door_timer/tgui_static_data(mob/user)
+ var/list/data = list()
+ data["spns"] = list()
+ for(var/mob/living/carbon/human/H in range(4, get_turf(src)))
+ if(H.handcuffed)
+ data["spns"] += H.name
+ return data
+
+/obj/machinery/door_timer/tgui_data(mob/user)
+ var/list/data = list()
data["cell_id"] = name
data["occupant"] = occupant
data["crimes"] = crimes
data["brigged_by"] = officer
- data["time_set"] = seconds_to_clock(time / 10)
+ data["time_set"] = seconds_to_clock(timetoset / 10)
data["time_left"] = seconds_to_clock(timeleft())
data["timing"] = timing
data["isAllowed"] = allowed(user)
data["prisoner_name"] = prisoner_name
data["prisoner_charge"] = prisoner_charge
data["prisoner_time"] = prisoner_time
-
+ data["prisoner_hasrec"] = prisoner_hasrecord
return data
-/obj/machinery/door_timer/Topic(href, href_list)
- if(!allowed(usr) && !usr.can_admin_interact())
- return 1
+/obj/machinery/door_timer/allowed(mob/user)
+ if(user.can_admin_interact())
+ return TRUE
+ return ..()
- if(href_list["flash"])
- for(var/obj/machinery/flasher/F in targets)
- if(F.last_flash && (F.last_flash + 150) > world.time)
- to_chat(usr, "Flash still charging.")
+/obj/machinery/door_timer/tgui_act(action, params)
+ if(..())
+ return
+ if(!allowed(usr))
+ to_chat(usr, "Access denied.")
+ return
+ . = TRUE
+ switch(action)
+ if("prisoner_name")
+ if(params["prisoner_name"])
+ prisoner_name = params["prisoner_name"]
else
- F.flash()
-
- if(href_list["release"])
- if(timing)
- timer_end()
- Radio.autosay("Timer stopped manually from cell control.", name, "Security", list(z))
- ui_interact(usr)
-
- if(href_list["prisoner_name"])
- prisoner_name = input("Prisoner Name:", name, prisoner_name) as text|null
-
- if(href_list["prisoner_charge"])
- prisoner_charge = input("Prisoner Charge:", name, prisoner_charge) as text|null
-
- if(href_list["prisoner_time"])
- prisoner_time = input("Prisoner Time (in minutes):", name, prisoner_time) as num|null
- prisoner_time = min(max(round(prisoner_time), 0), 60)
-
- if(href_list["set_timer"])
- if(!prisoner_name || !prisoner_charge || !prisoner_time)
- return
- timeset(prisoner_time * 60)
- occupant = prisoner_name
- crimes = prisoner_charge
- prisoner_name = ""
- prisoner_charge = ""
- prisoner_time = ""
- timing = TRUE
- timer_start()
- ui_interact(usr)
- update_icon()
+ prisoner_name = input("Prisoner Name:", name, prisoner_name) as text|null
+ if(prisoner_name)
+ var/datum/data/record/R = find_security_record("name", prisoner_name)
+ if(istype(R))
+ prisoner_hasrecord = TRUE
+ else
+ prisoner_hasrecord = FALSE
+ if("prisoner_charge")
+ prisoner_charge = input("Prisoner Charge:", name, prisoner_charge) as text|null
+ if("prisoner_time")
+ prisoner_time = input("Prisoner Time (in minutes):", name, prisoner_time) as num|null
+ prisoner_time = min(max(round(prisoner_time), 0), 60)
+ if("start")
+ if(!prisoner_name || !prisoner_charge || !prisoner_time)
+ return FALSE
+ timeset(prisoner_time * 60)
+ occupant = prisoner_name
+ crimes = prisoner_charge
+ prisoner_name = null
+ prisoner_charge = null
+ prisoner_time = null
+ timing = TRUE
+ timer_start()
+ update_icon()
+ if("restart_timer")
+ if(timing)
+ var/reset_reason = sanitize(copytext(input(usr, "Reason for resetting timer:", name, "") as text|null, 1, MAX_MESSAGE_LEN))
+ if(!reset_reason)
+ to_chat(usr, "Cancelled reset: reason field is required.")
+ return FALSE
+ releasetime = world.timeofday + timetoset
+ var/resettext = isobserver(usr) ? "for: [reset_reason]." : "by [usr.name] for: [reset_reason]."
+ Radio.autosay("Prisoner [occupant] had their timer reset [resettext]", name, "Security", list(z))
+ notify_prisoner("Your brig timer has been reset for: '[reset_reason]'.")
+ var/datum/data/record/R = find_security_record("name", occupant)
+ if(istype(R))
+ R.fields["comments"] += "Autogenerated by [name] on [GLOB.current_date_string] [station_time_timestamp()]
Timer reset [resettext]"
+ else
+ . = FALSE
+ if("stop")
+ if(timing)
+ timer_end()
+ var/stoptext = isobserver(usr) ? "from cell control." : "by [usr.name]."
+ Radio.autosay("Timer stopped manually [stoptext]", name, "Security", list(z))
+ else
+ . = FALSE
+ if("flash")
+ for(var/obj/machinery/flasher/F in targets)
+ if(F.last_flash && (F.last_flash + 150) > world.time)
+ to_chat(usr, "Flash still charging.")
+ else
+ F.flash()
+ else
+ . = FALSE
//icon update function
diff --git a/nano/templates/brig_timer.tmpl b/nano/templates/brig_timer.tmpl
deleted file mode 100644
index 2cd1ab73a23..00000000000
--- a/nano/templates/brig_timer.tmpl
+++ /dev/null
@@ -1,91 +0,0 @@
-
-