mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-22 19:47:22 +01:00
@@ -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)
|
||||
|
||||
@@ -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, "<span class='warning'>Flash still charging.</span>")
|
||||
/obj/machinery/door_timer/tgui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
if(!allowed(usr))
|
||||
to_chat(usr, "<span class='warning'>Access denied.</span>")
|
||||
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, "<span class='warning'>Cancelled reset: reason field is required.</span>")
|
||||
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()]<BR>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, "<span class='warning'>Flash still charging.</span>")
|
||||
else
|
||||
F.flash()
|
||||
else
|
||||
. = FALSE
|
||||
|
||||
|
||||
//icon update function
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
<!--
|
||||
Title: Brig Timer
|
||||
Used In File(s): \code\game\machinery\doors\brigdoors.dm
|
||||
-->
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Cell:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{:data.cell_id}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Occupant:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{:data.occupant}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Crimes:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{:data.crimes}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Brigged By:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{:data.brigged_by}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Time Brigged For:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{:data.time_set}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Time Left:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{:data.time_left}}
|
||||
</div>
|
||||
</div>
|
||||
{{if data.isAllowed}}
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Actions:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{:helper.link('Flash', 'flash', {'flash' : 1}, null, data.isAllowed ? '' : 'dsabled')}}
|
||||
{{:helper.link('Release', null, {'release' : 1}, null, data.isAllowed ? '' : 'disabled')}}
|
||||
</div>
|
||||
</div>
|
||||
{{if !data.timing}}
|
||||
<h3>Inmate Information</h3>
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Name:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{:helper.link('Set', 'pencil', {'prisoner_name' : 'input'})}} {{:data.prisoner_name}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Charge:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{:helper.link('Set', 'pencil', {'prisoner_charge' : 'input'})}} {{:data.prisoner_charge}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Time (in minutes):
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{:helper.link('Set', 'pencil', {'prisoner_time' : 'input'})}} {{:data.prisoner_time}}
|
||||
</div>
|
||||
</div>
|
||||
{{:helper.link('Submit', null, {'set_timer' : 1}, null, data.isAllowed ? '' : 'disabled')}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
@@ -0,0 +1,123 @@
|
||||
import { Fragment } from 'inferno';
|
||||
import { useBackend } from '../backend';
|
||||
import { Button, LabeledList, Dropdown, Box, Section } from '../components';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
export const BrigTimer = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
data.nameText = data.occupant;
|
||||
if (data.timing) {
|
||||
if (data.prisoner_hasrec) {
|
||||
data.nameText = (<Box color="green">{data.occupant}</Box>);
|
||||
} else {
|
||||
data.nameText = (<Box color="red">{data.occupant}</Box>);
|
||||
}
|
||||
}
|
||||
let nameIcon = "pencil-alt";
|
||||
if (data.prisoner_name) {
|
||||
if (!data.prisoner_hasrec) {
|
||||
nameIcon = "exclamation-triangle";
|
||||
}
|
||||
}
|
||||
let nameOptions = [];
|
||||
let i = 0;
|
||||
for (i = 0; i < data.spns.length; i++) {
|
||||
nameOptions.push(data.spns[i]);
|
||||
}
|
||||
return (
|
||||
<Window resizable>
|
||||
<Window.Content>
|
||||
<Section title="Cell Information">
|
||||
<LabeledList>
|
||||
<LabeledList.Item label="Cell ID">
|
||||
{data.cell_id}
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Occupant">
|
||||
{data.nameText}
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Crimes">
|
||||
{data.crimes}
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Brigged By">
|
||||
{data.brigged_by}
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Time Brigged For">
|
||||
{data.time_set}
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Time Left">
|
||||
{data.time_left}
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Actions">
|
||||
<Fragment>
|
||||
<Button
|
||||
icon="lightbulb-o"
|
||||
content="Flash"
|
||||
disabled={!data.isAllowed}
|
||||
onClick={() => act('flash')} />
|
||||
<Button
|
||||
icon="sync"
|
||||
content="Reset Timer"
|
||||
disabled={!data.timing || !data.isAllowed}
|
||||
onClick={() => act('restart_timer')} />
|
||||
<Button
|
||||
icon="eject"
|
||||
content="Release Prisoner"
|
||||
disabled={!data.timing || !data.isAllowed}
|
||||
onClick={() => act('stop')} />
|
||||
</Fragment>
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
</Section>
|
||||
{!data.timing && (
|
||||
<Section title="New Prisoner">
|
||||
<LabeledList>
|
||||
<LabeledList.Item label="Prisoner Name">
|
||||
<Button
|
||||
icon={nameIcon}
|
||||
content={data.prisoner_name ? data.prisoner_name : "-----"}
|
||||
disabled={!data.isAllowed}
|
||||
onClick={() => act('prisoner_name')} />
|
||||
{!!data.spns.length && (
|
||||
<Dropdown
|
||||
disabled={!data.isAllowed || !data.spns.length}
|
||||
options={data.spns}
|
||||
width="250px"
|
||||
onSelected={value => act('prisoner_name',
|
||||
{
|
||||
prisoner_name: value,
|
||||
})} />
|
||||
)}
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Prisoner Crimes">
|
||||
<Button
|
||||
icon="pencil-alt"
|
||||
content={data.prisoner_charge
|
||||
? data.prisoner_charge
|
||||
: "-----"}
|
||||
disabled={!data.isAllowed}
|
||||
onClick={() => act('prisoner_charge')} />
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Prisoner Time">
|
||||
<Button
|
||||
icon="pencil-alt"
|
||||
content={data.prisoner_time ? data.prisoner_time : "-----"}
|
||||
disabled={!data.isAllowed}
|
||||
onClick={() => act('prisoner_time')} />
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Start">
|
||||
<Button
|
||||
icon="gavel"
|
||||
content="Start Sentence"
|
||||
disabled={!data.prisoner_name
|
||||
|| !data.prisoner_charge
|
||||
|| !data.prisoner_time
|
||||
|| !data.isAllowed}
|
||||
onClick={() => act('start')} />
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
</Section>
|
||||
)}
|
||||
</Window.Content>
|
||||
</Window>
|
||||
);
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user