Modular Computer Revival (#5542)

Co-authored-by: silicons <no@you.cat>
This commit is contained in:
Mazian
2023-07-22 16:14:00 +02:00
committed by GitHub
co-authored by silicons
parent 07fd8d8c66
commit e1ddf62d06
57 changed files with 2470 additions and 4310 deletions
@@ -2,5 +2,5 @@
filename = "alarmmonitorsec"
filedesc = "Alarm Monitoring (Security)"
extended_desc = "This program provides visual interface for the security alarm system."
nanomodule_path = /datum/nano_module/alarm_monitor/security
required_access = ACCESS_SECURITY_EQUIPMENT
tguimodule_path = /datum/tgui_module_old/alarm_monitor/security/ntos
required_access = ACCESS_SECURITY_MAIN
@@ -1,5 +1,7 @@
var/warrant_uid = 0
/datum/datacore/var/list/warrants[] = list()
var/global/warrant_uid = 0
/datum/datacore
var/list/warrants = list()
/datum/data/record/warrant
var/warrant_id
@@ -7,7 +9,6 @@ var/warrant_uid = 0
..()
warrant_id = warrant_uid++
/datum/computer_file/program/digitalwarrant
filename = "digitalwarrant"
filedesc = "Warrant Assistant"
@@ -18,126 +19,119 @@ var/warrant_uid = 0
program_menu_icon = "star"
requires_ntnet = 1
available_on_ntnet = 1
required_access = ACCESS_SECURITY_EQUIPMENT
required_access = ACCESS_SECURITY_MAIN
usage_flags = PROGRAM_ALL
nanomodule_path = /datum/nano_module/program/digitalwarrant/
tgui_id = "NtosDigitalWarrant"
/datum/nano_module/program/digitalwarrant/
name = "Warrant Assistant"
var/datum/data/record/warrant/activewarrant
/datum/nano_module/program/digitalwarrant/nano_ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/topic_state/state = default_state)
var/list/data = host.initial_data()
/datum/computer_file/program/digitalwarrant/ui_data(mob/user, datum/tgui/ui, datum/ui_state/state)
var/list/data = get_header_data()
data["warrantname"] = null
data["warrantcharges"] = null
data["warrantauth"] = null
data["type"] = null
if(activewarrant)
data["warrantname"] = activewarrant.fields["namewarrant"]
data["warrantcharges"] = activewarrant.fields["charges"]
data["warrantauth"] = activewarrant.fields["auth"]
data["type"] = activewarrant.fields["arrestsearch"]
else
var/list/allwarrants = list()
for(var/datum/data/record/warrant/W in data_core.warrants)
allwarrants.Add(list(list(
var/list/allwarrants = list()
for(var/datum/data/record/warrant/W in data_core.warrants)
allwarrants.Add(list(list(
"warrantname" = W.fields["namewarrant"],
"charges" = "[copytext(W.fields["charges"],1,min(length(W.fields["charges"]) + 1, 50))]...",
"auth" = W.fields["auth"],
"id" = W.warrant_id,
"arrestsearch" = W.fields["arrestsearch"]
)))
data["allwarrants"] = allwarrants
data["allwarrants"] = allwarrants
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "digitalwarrant.tmpl", name, 500, 350, state = state)
ui.auto_update_layout = 1
ui.set_initial_data(data)
ui.open()
return data
/datum/nano_module/program/digitalwarrant/Topic(href, href_list)
/datum/computer_file/program/digitalwarrant/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
if(..())
return 1
return TRUE
if(href_list["sw_menu"])
activewarrant = null
switch(action)
if("back")
. = TRUE
activewarrant = null
if(href_list["editwarrant"])
. = 1
for(var/datum/data/record/warrant/W in data_core.warrants)
if(W.warrant_id == text2num(href_list["editwarrant"]))
activewarrant = W
break
if("editwarrant")
. = TRUE
for(var/datum/data/record/warrant/W in data_core.warrants)
if(W.warrant_id == text2num(params["id"]))
activewarrant = W
break
// The following actions will only be possible if the user has an ID with security access equipped. This is in line with modular computer framework's authentication methods,
// which also use RFID scanning to allow or disallow access to some functions. Anyone can view warrants, editing requires ID. This also prevents situations where you show a tablet
// to someone who is to be arrested, which allows them to change the stuff there.
var/mob/user = usr
if(!istype(user))
return
var/obj/item/card/id/I = user.GetIdCard()
if(!istype(I) || !I.registered_name || !(ACCESS_SECURITY_EQUIPMENT in I.access))
to_chat(user, "Authentication error: Unable to locate ID with apropriate access to allow this operation.")
var/obj/item/card/id/I = usr.GetIdCard()
if(!istype(I) || !I.registered_name || !(ACCESS_SECURITY_MAIN in I.access))
to_chat(usr, "Authentication error: Unable to locate ID with appropriate access to allow this operation.")
return
if(href_list["addwarrant"])
. = 1
var/datum/data/record/warrant/W = new()
var/temp = sanitize(input(usr, "Do you want to create a search-, or an arrest warrant?") as null|anything in list("search","arrest"))
if(CanInteract(user, default_state))
if(temp == "arrest")
W.fields["namewarrant"] = "Unknown"
W.fields["charges"] = "No charges present"
W.fields["auth"] = "Unauthorized"
W.fields["arrestsearch"] = "arrest"
if(temp == "search")
W.fields["namewarrant"] = "No location given"
W.fields["charges"] = "No reason given"
W.fields["auth"] = "Unauthorized"
W.fields["arrestsearch"] = "search"
activewarrant = W
switch(action)
if("addwarrant")
. = TRUE
var/datum/data/record/warrant/W = new()
var/temp = sanitize(input(usr, "Do you want to create a search-, or an arrest warrant?") as null|anything in list("search","arrest"))
if(ui_status(usr, state) == UI_INTERACTIVE)
if(temp == "arrest")
W.fields["namewarrant"] = "Unknown"
W.fields["charges"] = "No charges present"
W.fields["auth"] = "Unauthorized"
W.fields["arrestsearch"] = "arrest"
if(temp == "search")
W.fields["namewarrant"] = "No suspect/location given"
W.fields["charges"] = "No reason given"
W.fields["auth"] = "Unauthorized"
W.fields["arrestsearch"] = "search"
activewarrant = W
if(href_list["savewarrant"])
. = 1
data_core.warrants |= activewarrant
activewarrant = null
if("savewarrant")
. = TRUE
data_core.warrants |= activewarrant
activewarrant = null
if(href_list["deletewarrant"])
. = 1
data_core.warrants -= activewarrant
activewarrant = null
if("deletewarrant")
. = TRUE
data_core.warrants -= activewarrant
activewarrant = null
if(href_list["editwarrantname"])
. = 1
var/namelist = list()
for(var/datum/data/record/t in data_core.general)
namelist += t.fields["name"]
var/new_name = sanitize(input(usr, "Please input name") as null|anything in namelist)
if(CanInteract(user, default_state))
if (!new_name)
return
activewarrant.fields["namewarrant"] = new_name
if("editwarrantname")
. = TRUE
var/namelist = list()
for(var/datum/data/record/t in data_core.general)
namelist += t.fields["name"]
var/new_name = sanitize(input(usr, "Please input name") as null|anything in namelist)
if(ui_status(usr, state) == UI_INTERACTIVE)
if (!new_name)
return
activewarrant.fields["namewarrant"] = new_name
if(href_list["editwarrantnamecustom"])
. = 1
var/new_name = sanitize(input("Please input name") as null|text)
if(CanInteract(user, default_state))
if (!new_name)
return
activewarrant.fields["namewarrant"] = new_name
if("editwarrantnamecustom")
. = TRUE
var/new_name = sanitize(input("Please input name") as null|text)
if(ui_status(usr, state) == UI_INTERACTIVE)
if (!new_name)
return
activewarrant.fields["namewarrant"] = new_name
if(href_list["editwarrantcharges"])
. = 1
var/new_charges = sanitize(input("Please input charges", "Charges", activewarrant.fields["charges"]) as null|text)
if(CanInteract(user, default_state))
if (!new_charges)
return
activewarrant.fields["charges"] = new_charges
if("editwarrantcharges")
. = TRUE
var/new_charges = sanitize(input("Please input charges", "Charges", activewarrant.fields["charges"]) as null|text)
if(ui_status(usr, state) == UI_INTERACTIVE)
if (!new_charges)
return
activewarrant.fields["charges"] = new_charges
if(href_list["editwarrantauth"])
. = 1
if("editwarrantauth")
. = TRUE
activewarrant.fields["auth"] = "[I.registered_name] - [I.assignment ? I.assignment : "(Unknown)"]"
if(href_list["back"])
. = 1
activewarrant = null
activewarrant.fields["auth"] = "[I.registered_name] - [I.assignment ? I.assignment : "(Unknown)"]"