Merge pull request #11851 from atlantiscze/31-12-2015-consolepresets

Modular Consoles, Tweaks
This commit is contained in:
Chinsky
2016-01-02 01:25:50 +03:00
16 changed files with 619 additions and 627 deletions

View File

@@ -10,6 +10,12 @@
var/obj/machinery/modular_computer/machinery_computer = null
/obj/item/modular_computer/processor/Destroy()
if(machinery_computer && (machinery_computer.cpu == src))
machinery_computer.cpu = null
machinery_computer = null
return ..()
// Due to how processes work, we'd receive two process calls - one from machinery type and one from our own type.
// Since we want this to be in-sync with machinery (as it's hidden type for machinery-based computers) we'll ignore
// non-relayed process calls.

View File

@@ -0,0 +1,17 @@
// Available as custom loadout item, this is literally the worst possible cheap tablet
/obj/item/modular_computer/tablet/preset/custom_loadout/cheap/New()
. = ..()
desc = "A low-end tablet often seen among low ranked station personnel"
battery_module = new/obj/item/weapon/computer_hardware/battery_module/nano(src)
hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/micro(src)
network_card = new/obj/item/weapon/computer_hardware/network_card(src)
// Alternative version, an average one, for higher ranked positions mostly
/obj/item/modular_computer/tablet/preset/custom_loadout/advanced/New()
. = ..()
battery_module = new/obj/item/weapon/computer_hardware/battery_module(src)
hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/small(src)
network_card = new/obj/item/weapon/computer_hardware/network_card(src)
nano_printer = new/obj/item/weapon/computer_hardware/nano_printer(src)
card_slot = new/obj/item/weapon/computer_hardware/card_slot(src)

View File

@@ -0,0 +1,83 @@
/obj/machinery/modular_computer/console/preset/
// Can be changed to give devices specific hardware
var/_has_id_slot = 0
var/_has_printer = 0
var/_has_battery = 0
/obj/machinery/modular_computer/console/preset/New()
. = ..()
if(!cpu)
return
if(_has_id_slot)
cpu.card_slot = new/obj/item/weapon/computer_hardware/card_slot(cpu)
if(_has_printer)
cpu.nano_printer = new/obj/item/weapon/computer_hardware/nano_printer(cpu)
if(_has_battery)
cpu.battery_module = new/obj/item/weapon/computer_hardware/battery_module/super(cpu)
install_programs()
// Override in child types to install preset-specific programs.
/obj/machinery/modular_computer/console/preset/proc/install_programs()
return
// ===== ENGINEERING CONSOLE =====
/obj/machinery/modular_computer/console/preset/engineering
console_department = "Engineering"
desc = "A stationary computer. This one comes preloaded with engineering programs."
/obj/machinery/modular_computer/console/preset/engineering/install_programs()
cpu.hard_drive.store_file(new/datum/computer_file/program/power_monitor())
cpu.hard_drive.store_file(new/datum/computer_file/program/alarm_monitor())
cpu.hard_drive.store_file(new/datum/computer_file/program/atmos_control())
cpu.hard_drive.store_file(new/datum/computer_file/program/rcon_console())
// ===== MEDICAL CONSOLE =====
/obj/machinery/modular_computer/console/preset/medical
console_department = "Medbay"
desc = "A stationary computer. This one comes preloaded with medical programs."
/obj/machinery/modular_computer/console/preset/medical/install_programs()
cpu.hard_drive.store_file(new/datum/computer_file/program/suit_sensors())
// ===== RESEARCH CONSOLE =====
/obj/machinery/modular_computer/console/preset/research
console_department = "Medbay"
desc = "A stationary computer. This one comes preloaded with research programs."
/obj/machinery/modular_computer/console/preset/research/install_programs()
cpu.hard_drive.store_file(new/datum/computer_file/program/ntnetmonitor())
cpu.hard_drive.store_file(new/datum/computer_file/program/nttransfer())
cpu.hard_drive.store_file(new/datum/computer_file/program/chatclient())
// ===== COMMAND CONSOLE =====
/obj/machinery/modular_computer/console/preset/command
console_department = "Command"
desc = "A stationary computer. This one comes preloaded with command programs."
_has_id_slot = 1
/obj/machinery/modular_computer/console/preset/command/install_programs()
cpu.hard_drive.store_file(new/datum/computer_file/program/chatclient())
cpu.hard_drive.store_file(new/datum/computer_file/program/card_mod())
// ===== SECURITY CONSOLE =====
/obj/machinery/modular_computer/console/preset/security
console_department = "Security"
desc = "A stationary computer. This one comes preloaded with security programs."
/obj/machinery/modular_computer/console/preset/security/install_programs()
return // No security programs exist, yet, but the preset is ready so it may be mapped in.
// ===== CIVILIAN CONSOLE =====
/obj/machinery/modular_computer/console/preset/civilian
console_department = "Civilian"
desc = "A stationary computer. This one comes preloaded with generic programs."
/obj/machinery/modular_computer/console/preset/civilian/install_programs()
cpu.hard_drive.store_file(new/datum/computer_file/program/chatclient())
cpu.hard_drive.store_file(new/datum/computer_file/program/nttransfer())

View File

@@ -0,0 +1,218 @@
/datum/computer_file/program/card_mod
filename = "cardmod"
filedesc = "ID card modification program"
nanomodule_path = /datum/nano_module/card_mod
program_icon_state = "id"
extended_desc = "Program for programming employee ID cards to access parts of the station."
required_access = access_hop
requires_ntnet = 0
size = 8
/datum/nano_module/card_mod
name = "ID card modification program"
var/mod_mode = 1
var/is_centcom = 0
var/show_assignments = 0
/datum/nano_module/card_mod/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 = list()
if(program)
data = program.get_header_data()
data["src"] = "\ref[src]"
data["station_name"] = station_name()
data["manifest"] = data_core ? data_core.get_manifest(0) : null
data["assignments"] = show_assignments
if(program && program.computer)
data["have_id_slot"] = !!program.computer.card_slot
data["have_printer"] = !!program.computer.nano_printer
data["authenticated"] = program.can_run(user)
if(!program.computer.card_slot)
mod_mode = 0 //We can't modify IDs when there is no card reader
else
data["have_id_slot"] = 0
data["have_printer"] = 0
data["authenticated"] = 0
data["mmode"] = mod_mode
data["centcom_access"] = is_centcom
if(program && program.computer && program.computer.card_slot)
var/obj/item/weapon/card/id/id_card = program.computer.card_slot.stored_card
data["has_id"] = !!id_card
data["id_account_number"] = id_card ? id_card.associated_account_number : null
data["id_rank"] = id_card && id_card.assignment ? id_card.assignment : "Unassigned"
data["id_owner"] = id_card && id_card.registered_name ? id_card.registered_name : "-----"
data["id_name"] = id_card ? id_card.name : "-----"
data["engineering_jobs"] = format_jobs(engineering_positions)
data["medical_jobs"] = format_jobs(medical_positions)
data["science_jobs"] = format_jobs(science_positions)
data["security_jobs"] = format_jobs(security_positions)
data["cargo_jobs"] = format_jobs(cargo_positions)
data["civilian_jobs"] = format_jobs(civilian_positions)
data["centcom_jobs"] = format_jobs(get_all_centcom_jobs())
data["all_centcom_access"] = is_centcom ? get_accesses(1) : null
data["regions"] = get_accesses()
if(program.computer.card_slot.stored_card)
var/obj/item/weapon/card/id/id_card = program.computer.card_slot.stored_card
if(is_centcom)
var/list/all_centcom_access = list()
for(var/access in get_all_centcom_access())
all_centcom_access.Add(list(list(
"desc" = replacetext(get_centcom_access_desc(access), " ", "&nbsp"),
"ref" = access,
"allowed" = (access in id_card.access) ? 1 : 0)))
data["all_centcom_access"] = all_centcom_access
else
var/list/regions = list()
for(var/i = 1; i <= 7; i++)
var/list/accesses = list()
for(var/access in get_region_accesses(i))
if (get_access_desc(access))
accesses.Add(list(list(
"desc" = replacetext(get_access_desc(access), " ", "&nbsp"),
"ref" = access,
"allowed" = (access in id_card.access) ? 1 : 0)))
regions.Add(list(list(
"name" = get_region_accesses_name(i),
"accesses" = accesses)))
data["regions"] = regions
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "identification_computer.tmpl", name, 600, 700, state = state)
ui.auto_update_layout = 1
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)
/datum/nano_module/card_mod/proc/format_jobs(list/jobs)
var/obj/item/weapon/card/id/id_card = program.computer.card_slot.stored_card
var/list/formatted = list()
for(var/job in jobs)
formatted.Add(list(list(
"display_name" = replacetext(job, " ", "&nbsp"),
"target_rank" = id_card && id_card.assignment ? id_card.assignment : "Unassigned",
"job" = job)))
return formatted
/datum/nano_module/card_mod/proc/get_accesses(var/is_centcom = 0)
return null
/datum/computer_file/program/card_mod/Topic(href, href_list)
var/mob/living/user = usr
var/obj/item/weapon/card/id/user_id_card = user.GetIdCard()
var/obj/item/weapon/card/id/id_card = computer.card_slot.stored_card
var/datum/nano_module/card_mod/module = NM
switch(href_list["action"])
if("switchm")
if(href_list["target"] == "mod")
module.mod_mode = 1
else if (href_list["target"] == "manifest")
module.mod_mode = 0
if("togglea")
if(module.show_assignments)
module.show_assignments = 0
else
module.show_assignments = 1
if("print")
if(computer && computer.nano_printer) //This option should never be called if there is no printer
if(module.mod_mode)
if(can_run(user, 1))
var/contents = {"<h4>Access Report</h4>
<u>Prepared By:</u> [user_id_card.registered_name ? user_id_card.registered_name : "Unknown"]<br>
<u>For:</u> [id_card.registered_name ? id_card.registered_name : "Unregistered"]<br>
<hr>
<u>Assignment:</u> [id_card.assignment]<br>
<u>Account Number:</u> #[id_card.associated_account_number]<br>
<u>Blood Type:</u> [id_card.blood_type]<br><br>
<u>Access:</u><br>
"}
for(var/A in id_card.access)
contents += " [get_access_desc(A)]"
if(!computer.nano_printer.print_text(contents,"access report"))
usr << "<span class='notice'>Hardware error: Printer was unable to print the file. It may be out of paper.</span>"
return
else
computer.visible_message("<span class='notice'>[computer] prints out paper.</span>")
else
var/contents = {"<h4>Crew Manifest</h4>
<br>
[data_core ? data_core.get_manifest(0) : ""]
"}
if(!computer.nano_printer.print_text(contents,text("crew manifest ([])", worldtime2text())))
usr << "<span class='notice'>Hardware error: Printer was unable to print the file. It may be out of paper.</span>"
return
else
computer.visible_message("<span class='notice'>[computer] prints out paper.</span>")
if("eject")
if(computer && computer.card_slot)
computer.proc_eject_id(user)
if("terminate")
if(computer && can_run(user, 1))
id_card.assignment = "Terminated"
id_card.access = list()
callHook("terminate_employee", list(id_card))
if("edit")
if(computer && can_run(user, 1))
if(href_list["name"])
var/temp_name = sanitizeName(input("Enter name.", "Name", id_card.registered_name))
if(temp_name)
id_card.registered_name = temp_name
else
computer.visible_message("<span class='notice'>[computer] buzzes rudely.</span>")
else if(href_list["account"])
var/account_num = text2num(input("Enter account number.", "Account", id_card.associated_account_number))
id_card.associated_account_number = account_num
if("assign")
if(computer && can_run(user, 1) && id_card)
var/t1 = href_list["assign_target"]
if(t1 == "Custom")
var/temp_t = sanitize(input("Enter a custom job assignment.","Assignment", id_card.assignment), 45)
//let custom jobs function as an impromptu alt title, mainly for sechuds
if(temp_t)
id_card.assignment = temp_t
else
var/list/access = list()
if(module.is_centcom)
access = get_centcom_access(t1)
else
var/datum/job/jobdatum
for(var/jobtype in typesof(/datum/job))
var/datum/job/J = new jobtype
if(ckey(J.title) == ckey(t1))
jobdatum = J
break
if(!jobdatum)
usr << "<span class='warning'>No log exists for this job: [t1]</span>"
return
access = jobdatum.get_access()
id_card.access = access
id_card.assignment = t1
id_card.rank = t1
callHook("reassign_employee", list(id_card))
if("access")
if(href_list["allowed"] && computer && can_run(user, 1))
var/access_type = text2num(href_list["access_target"])
var/access_allowed = text2num(href_list["allowed"])
if(access_type in (get_all_centcom_access() + get_all_station_access()))
id_card.access -= access_type
if(!access_allowed)
id_card.access += access_type
if(id_card)
id_card.name = text("[id_card.registered_name]'s ID Card ([id_card.assignment])")
nanomanager.update_uis(NM)
..(href, href_list)
return 1

View File

@@ -11,6 +11,7 @@
/obj/item/weapon/computer_hardware/card_slot/Destroy()
if(holder2 && (holder2.card_slot == src))
holder2.card_slot = null
stored_card.loc = get_turf(holder2)
if(stored_card)
stored_card.forceMove(get_turf(holder2))
holder2 = null
..()

View File

@@ -2,6 +2,7 @@
name = "nano printer"
desc = "Small integrated printer with scanner and paper recycling module."
power_usage = 50
critical = 0
icon_state = "printer"
hardware_size = 1
var/stored_paper = 5
@@ -9,7 +10,7 @@
var/obj/item/weapon/paper/P = null // Currently stored paper for scanning.
/obj/item/weapon/computer_hardware/nano_printer/proc/print_text(var/text_to_print)
/obj/item/weapon/computer_hardware/nano_printer/proc/print_text(var/text_to_print, var/paper_title = null)
if(!stored_paper)
return 0
@@ -21,6 +22,8 @@
P = new/obj/item/weapon/paper(get_turf(holder2))
P.info = text_to_print
if(paper_title)
P.name = paper_title
P.update_icon()
stored_paper--
P = null