Computer manager and more (#1406)

The downloader and the file manager no longer come default on any device.
A client enrollment app comes now with every console
The user has to select weather the device is a private or company device and select a software preset if its a work console
Work devices are locked down to a specific set of programs
Private devices get the downloader and the file manager to install programs as usual.
Threw out the backup of the old-old camera monitor.
Made software presets a generic thing that are not dependant on the form factor of a device.
Ported holowarrants from bay
Ported wall mounted consoles from bay
Ported various computer fixes from bay
Vending machines spawn now with the holowarrant "client"
Mapping changes:

CE and HoS dont get a modular computer with command preset (they did not have that before bay merge, so why should they now)
Added a modular computer with command preset to the head of staff briefing room
Replaced the camera monitoring console in the Engine Control room with a modular computer
Replaced the cam monitor in the CE´s office with a wall mounted console
Switched places of the bar sink and console
Replaced the consoles with obj/item consoles
Mapped in the ERT and Merc Console (Merc Shuttle, ERT Area)
Fixed the "border" at the heisters base
Also waiting for CCIA on a design for the warrants.
But that can be changed with a follow up pull
This commit is contained in:
Werner
2017-01-20 20:45:53 +01:00
committed by skull132
parent 58dc6dde9e
commit 9d134d8e15
56 changed files with 2095 additions and 1727 deletions
@@ -0,0 +1,113 @@
// This is special hardware configuration program.
// It is to be used only with modular computers.
// It allows you to toggle components of your device.
/datum/computer_file/program/clientmanager
filename = "clientmanager"
filedesc = "NTOS Client Manager"
extended_desc = "This program allows configuration of computer's software"
program_icon_state = "generic"
unsendable = 1
undeletable = 1
size = 4
available_on_ntnet = 0
requires_ntnet = 0
nanomodule_path = /datum/nano_module/program/clientmanager/
var/_dev_type = 1 //1 - Company Device ,2 - Private device
var/_dev_preset = "civilian"
var/_error_message = null
/datum/nano_module/program/clientmanager
name = "NTOS Client Manager"
var/obj/item/modular_computer/movable = null
/datum/computer_file/program/clientmanager/Topic(href, href_list)
if(..())
return 1
if(href_list["PRG_dev_type"])
_dev_type = text2num(href_list["PRG_dev_type"])
return 1
if(href_list["PRG_dev_preset"])
_dev_preset = href_list["PRG_dev_preset"]
return 1
if(href_list["PRG_enroll"])
if(ntnet_global.check_function(NTNET_SOFTWAREDOWNLOAD))
_error_message = null
if(_dev_type == 1)
enroll_company_device()
return 1
if(_dev_type == 2)
enroll_private_device()
return 1
return 0
else
_error_message = "NTNET unavailable. Unable to enroll device"
return 0
//Set´s up the computer with the file manager and the downloader and removes the lock
/datum/computer_file/program/clientmanager/proc/enroll_private_device()
if(!computer)
return 0
computer.enrolled = 2 // private devices
computer.hard_drive.store_file(new/datum/computer_file/program/filemanager())
computer.hard_drive.store_file(new/datum/computer_file/program/ntnetdownload())
return 1
//Set´s up the programs from the preset
/datum/computer_file/program/clientmanager/proc/enroll_company_device()
if(!computer || !_dev_type || !_dev_preset)
return 0
for (var/datum/modular_computer_app_presets/prs in ntnet_global.available_software_presets)
if(prs.name == _dev_preset && prs.available == 1)
var/list/prs_programs = prs.return_install_programs()
for (var/datum/computer_file/program/prog in prs_programs)
computer.hard_drive.store_file(prog)
computer.enrolled = 1 // enroll as company device after finding matching preset and storing software
return 1
return 0
/datum/nano_module/program/clientmanager/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)
movable = program.computer
data = program.get_header_data()
if(!istype(movable))
movable = null
var/datum/computer_file/program/clientmanager/PRG = program
// For now limited to execution by the downloader program
// No computer connection, we can't get data from that.
if(!PRG || !istype(PRG) || !movable )
return 0
data["status_enrollment"] = movable.enrolled
data["status_compliance"] = 1 // 0 - Not Complaint 1 - Compliant //For now. TODO-IT: Run actual compliance checks
data["status_remote"] = 1 // 0 - Disabled 1 - Enabled //For now. TODO-IT: ability to enable and disable remote control
if(!movable.enrolled)
data["dev_type"] = PRG._dev_type
var/list/all_presets = list()
for (var/datum/modular_computer_app_presets/prs in ntnet_global.available_software_presets)
if(prs.available)
all_presets.Add(list(list(
"name" = prs.name,
"display_name" = prs.display_name,
"description" = prs.description
)))
data["dev_presets"] = all_presets
data["dev_preset"] = PRG._dev_preset
else if(movable.enrolled > 2)
PRG._error_message = "Unable to determine enrollment status. Contact IT department"
data["error_message"] = PRG._error_message
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "ntnet_clientmanager.tmpl", "NTOS Client Manager", 575, 700, state = state)
ui.auto_update_layout = 1
ui.set_initial_data(data)
ui.open()
@@ -0,0 +1,62 @@
// This is special hardware configuration program.
// It is to be used only with modular computers.
// It allows you to toggle components of your device.
/datum/computer_file/program/computerconfig
filename = "compconfig"
filedesc = "Computer Configuration Tool"
extended_desc = "This program allows configuration of computer's hardware"
program_icon_state = "generic"
unsendable = 1
undeletable = 1
size = 4
available_on_ntnet = 0
requires_ntnet = 0
nanomodule_path = /datum/nano_module/program/computer_configurator/
/datum/nano_module/program/computer_configurator
name = "NTOS Computer Configuration Tool"
var/obj/item/modular_computer/movable = null
/datum/nano_module/program/computer_configurator/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/topic_state/state = default_state)
if(program)
movable = program.computer
if(!istype(movable))
movable = null
// No computer connection, we can't get data from that.
if(!movable)
return 0
var/list/data = list()
if(program)
data = program.get_header_data()
var/list/hardware = movable.get_all_components()
data["disk_size"] = movable.hard_drive.max_capacity
data["disk_used"] = movable.hard_drive.used_capacity
data["power_usage"] = movable.last_power_usage
data["battery_exists"] = movable.battery_module ? 1 : 0
if(movable.battery_module)
data["battery_rating"] = movable.battery_module.battery.maxcharge
data["battery_percent"] = round(movable.battery_module.battery.percent())
var/list/all_entries[0]
for(var/obj/item/weapon/computer_hardware/H in hardware)
all_entries.Add(list(list(
"name" = H.name,
"desc" = H.desc,
"enabled" = H.enabled,
"critical" = H.critical,
"powerusage" = H.power_usage
)))
data["hardware"] = all_entries
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "laptop_configuration.tmpl", "NTOS Configuration Utility", 575, 700, state = state)
ui.auto_update_layout = 1
ui.set_initial_data(data)
ui.open()
@@ -0,0 +1,208 @@
#define MAX_TEXTFILE_LENGTH 128000 // 512GQ file
/datum/computer_file/program/filemanager
filename = "filemanager"
filedesc = "NTOS File Manager"
extended_desc = "This program allows management of files."
program_icon_state = "generic"
size = 8
requires_ntnet = 0
available_on_ntnet = 0
undeletable = 1
nanomodule_path = /datum/nano_module/program/computer_filemanager/
var/open_file
var/error
/datum/computer_file/program/filemanager/Topic(href, href_list)
if(..())
return 1
if(href_list["PRG_openfile"])
. = 1
open_file = href_list["PRG_openfile"]
if(href_list["PRG_newtextfile"])
. = 1
var/newname = sanitize(input(usr, "Enter file name or leave blank to cancel:", "File rename"))
if(!newname)
return 1
var/obj/item/weapon/computer_hardware/hard_drive/HDD = computer.hard_drive
if(!HDD)
return 1
var/datum/computer_file/data/F = new/datum/computer_file/data()
F.filename = newname
F.filetype = "TXT"
HDD.store_file(F)
if(href_list["PRG_deletefile"])
. = 1
var/obj/item/weapon/computer_hardware/hard_drive/HDD = computer.hard_drive
if(!HDD)
return 1
var/datum/computer_file/file = HDD.find_file_by_name(href_list["PRG_deletefile"])
if(!file || file.undeletable)
return 1
HDD.remove_file(file)
if(href_list["PRG_usbdeletefile"])
. = 1
var/obj/item/weapon/computer_hardware/hard_drive/RHDD = computer.portable_drive
if(!RHDD)
return 1
var/datum/computer_file/file = RHDD.find_file_by_name(href_list["PRG_usbdeletefile"])
if(!file || file.undeletable)
return 1
RHDD.remove_file(file)
if(href_list["PRG_closefile"])
. = 1
open_file = null
error = null
if(href_list["PRG_clone"])
. = 1
var/obj/item/weapon/computer_hardware/hard_drive/HDD = computer.hard_drive
if(!HDD)
return 1
var/datum/computer_file/F = HDD.find_file_by_name(href_list["PRG_clone"])
if(!F || !istype(F))
return 1
var/datum/computer_file/C = F.clone(1)
HDD.store_file(C)
if(href_list["PRG_rename"])
. = 1
var/obj/item/weapon/computer_hardware/hard_drive/HDD = computer.hard_drive
if(!HDD)
return 1
var/datum/computer_file/file = HDD.find_file_by_name(href_list["PRG_rename"])
if(!file || !istype(file))
return 1
var/newname = sanitize(input(usr, "Enter new file name:", "File rename", file.filename))
if(file && newname)
file.filename = newname
if(href_list["PRG_edit"])
. = 1
if(!open_file)
return 1
var/obj/item/weapon/computer_hardware/hard_drive/HDD = computer.hard_drive
if(!HDD)
return 1
var/datum/computer_file/data/F = HDD.find_file_by_name(open_file)
if(!F || !istype(F))
return 1
if(F.do_not_edit && (alert("WARNING: This file is not compatible with editor. Editing it may result in permanently corrupted formatting or damaged data consistency. Edit anyway?", "Incompatible File", "No", "Yes") == "No"))
return 1
var/oldtext = html_decode(F.stored_data)
oldtext = replacetext(oldtext, "\[editorbr\]", "\n")
var/newtext = sanitize(replacetext(input(usr, "Editing file [open_file]. You may use most tags used in paper formatting:", "Text Editor", oldtext) as message|null, "\n", "\[editorbr\]"), MAX_TEXTFILE_LENGTH)
if(!newtext)
return
if(F)
var/datum/computer_file/data/backup = F.clone()
HDD.remove_file(F)
F.stored_data = newtext
F.calculate_size()
// We can't store the updated file, it's probably too large. Print an error and restore backed up version.
// This is mostly intended to prevent people from losing texts they spent lot of time working on due to running out of space.
// They will be able to copy-paste the text from error screen and store it in notepad or something.
if(!HDD.store_file(F))
error = "I/O error: Unable to overwrite file. Hard drive is probably full. You may want to backup your changes before closing this window:<br><br>[html_decode(F.stored_data)]<br><br>"
HDD.store_file(backup)
if(href_list["PRG_printfile"])
. = 1
if(!open_file)
return 1
var/obj/item/weapon/computer_hardware/hard_drive/HDD = computer.hard_drive
if(!HDD)
return 1
var/datum/computer_file/data/F = HDD.find_file_by_name(open_file)
if(!F || !istype(F))
return 1
if(!computer.nano_printer)
error = "Missing Hardware: Your computer does not have required hardware to complete this operation."
return 1
if(!computer.nano_printer.print_text(pencode2html(F.stored_data)))
error = "Hardware error: Printer was unable to print the file. It may be out of paper."
return 1
if(href_list["PRG_copytousb"])
. = 1
var/obj/item/weapon/computer_hardware/hard_drive/HDD = computer.hard_drive
var/obj/item/weapon/computer_hardware/hard_drive/portable/RHDD = computer.portable_drive
if(!HDD || !RHDD || computer.enrolled != 2)
return 1
var/datum/computer_file/F = HDD.find_file_by_name(href_list["PRG_copytousb"])
if(!F || !istype(F))
return 1
var/datum/computer_file/C = F.clone(0)
RHDD.store_file(C)
if(href_list["PRG_copyfromusb"])
. = 1
var/obj/item/weapon/computer_hardware/hard_drive/HDD = computer.hard_drive
var/obj/item/weapon/computer_hardware/hard_drive/portable/RHDD = computer.portable_drive
if(!HDD || !RHDD || computer.enrolled != 2)
return 1
var/datum/computer_file/F = RHDD.find_file_by_name(href_list["PRG_copyfromusb"])
if(!F || !istype(F))
return 1
var/datum/computer_file/C = F.clone(0)
HDD.store_file(C)
if(.)
nanomanager.update_uis(NM)
/datum/nano_module/program/computer_filemanager
name = "NTOS File Manager"
/datum/nano_module/program/computer_filemanager/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()
var/datum/computer_file/program/filemanager/PRG
//var/list/data = program.get_header_data()
PRG = program
var/obj/item/weapon/computer_hardware/hard_drive/HDD
var/obj/item/weapon/computer_hardware/hard_drive/portable/RHDD
if(PRG.error)
data["error"] = PRG.error
if(PRG.open_file)
var/datum/computer_file/data/file
if(!PRG.computer || !PRG.computer.hard_drive)
data["error"] = "I/O ERROR: Unable to access hard drive."
else
HDD = PRG.computer.hard_drive
file = HDD.find_file_by_name(PRG.open_file)
if(!istype(file))
data["error"] = "I/O ERROR: Unable to open file."
else
data["filedata"] = pencode2html(file.stored_data)
data["filename"] = "[file.filename].[file.filetype]"
else
if(!PRG.computer || !PRG.computer.hard_drive)
data["error"] = "I/O ERROR: Unable to access hard drive."
else
HDD = PRG.computer.hard_drive
RHDD = PRG.computer.portable_drive
var/list/files[0]
for(var/datum/computer_file/F in HDD.stored_files)
files.Add(list(list(
"name" = F.filename,
"type" = F.filetype,
"size" = F.size,
"undeletable" = F.undeletable
)))
data["files"] = files
if(RHDD)
data["usbconnected"] = 1
var/list/usbfiles[0]
for(var/datum/computer_file/F in RHDD.stored_files)
usbfiles.Add(list(list(
"name" = F.filename,
"type" = F.filetype,
"size" = F.size,
"undeletable" = F.undeletable
)))
data["usbfiles"] = usbfiles
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "file_manager.tmpl", "NTOS File Manager", 575, 700, state = state)
ui.auto_update_layout = 1
ui.set_initial_data(data)
ui.open()
#undef MAX_TEXTFILE_LENGTH
@@ -0,0 +1,232 @@
/datum/computer_file/program/ntnetdownload
filename = "ntndownloader"
filedesc = "NTNet Software Download Tool"
program_icon_state = "generic"
extended_desc = "This program allows downloads of software from official NT repositories"
unsendable = 1
undeletable = 1
size = 4
requires_ntnet = 1
requires_ntnet_feature = NTNET_SOFTWAREDOWNLOAD
available_on_ntnet = 0
nanomodule_path = /datum/nano_module/program/computer_ntnetdownload/
ui_header = "downloader_finished.gif"
var/datum/computer_file/program/downloaded_file = null
var/hacked_download = 0
var/download_completion = 0 //GQ of downloaded data.
var/download_netspeed = 0
var/download_last_update = 0 // For tracking download rates and completion.
var/downloaderror = ""
var/downstream_variance = 0.1
/datum/computer_file/program/ntnetdownload/proc/begin_file_download(var/filename, var/user = null)
if(downloaded_file)
return 0
var/datum/computer_file/program/PRG = ntnet_global.find_ntnet_file_by_name(filename)
if(!PRG || !istype(PRG))
return 0
// Attempting to download antag only program, but without having emagged computer. No.
if(PRG.available_on_syndinet && !computer_emagged)
return 0
if(!computer || !computer.hard_drive || !computer.hard_drive.try_store_file(PRG))
return 0
if(computer.enrolled == 1 && !computer_emagged)
return 0
ui_header = "downloader_running.gif"
if(PRG in ntnet_global.available_station_software)
generate_network_log("Began downloading file [PRG.filename].[PRG.filetype] from NTNet Software Repository.")
hacked_download = 0
else if(PRG in ntnet_global.available_antag_software)
generate_network_log("Began downloading file **ENCRYPTED**.[PRG.filetype] from unspecified server.")
hacked_download = 1
else
generate_network_log("Began downloading file [PRG.filename].[PRG.filetype] from unspecified server.")
hacked_download = 0
downloaded_file = PRG.clone()
if (user)
spawn()
ui_interact(user)
/datum/computer_file/program/ntnetdownload/proc/abort_file_download()
if(!downloaded_file)
return
generate_network_log("Aborted download of file [hacked_download ? "**ENCRYPTED**" : downloaded_file.filename].[downloaded_file.filetype].")
downloaded_file = null
download_completion = 0
download_last_update = 0
ui_header = "downloader_finished.gif"
/datum/computer_file/program/ntnetdownload/proc/complete_file_download()
if(!downloaded_file)
return
generate_network_log("Completed download of file [hacked_download ? "**ENCRYPTED**" : downloaded_file.filename].[downloaded_file.filetype].")
if(!computer || !computer.hard_drive || !computer.hard_drive.store_file(downloaded_file))
// The download failed
downloaderror = "I/O ERROR - Unable to save file. Check whether you have enough free space on your hard drive and whether your hard drive is properly connected. If the issue persists contact your system administrator for assistance."
downloaded_file = null
download_completion = 0
download_last_update = 0
ui_header = "downloader_finished.gif"
/datum/computer_file/program/ntnetdownload/process_tick()
if(!downloaded_file)
return
if(download_completion >= downloaded_file.size)
complete_file_download()
return
// Download speed according to connectivity state. NTNet server is assumed to be on unlimited speed so we're limited by our local connectivity
download_netspeed = 0
// Speed defines are found in misc.dm
switch(ntnet_status)
if(1)
download_netspeed = NTNETSPEED_LOWSIGNAL
downstream_variance = 0.3
if(2)
download_netspeed = NTNETSPEED_HIGHSIGNAL
downstream_variance = 0.2
if(3)
download_netspeed = NTNETSPEED_ETHERNET
// We recovered connection or started a new download.
// So we don't have any bytes yet. We'll get them next time!
if (!download_last_update)
download_last_update = world.time
return
var/delta = ((rand() - 0.5) * 2) * downstream_variance * download_netspeed
//Download speed varies +/- 10% each proc. Adds a more realistic feel
download_netspeed += delta
download_netspeed = round(download_netspeed, 0.002)//3 decimal places
var/delta_seconds = (world.time - download_last_update) / 10
download_completion = min(download_completion + delta_seconds * download_netspeed, downloaded_file.size)
// No connection, so cancel the download.
// This is done at the end because of logic reasons.
// Trust me, it's fine. - Skull132
if (!download_netspeed)
download_last_update = 0
else
download_last_update = world.time
/datum/computer_file/program/ntnetdownload/Topic(href, href_list)
if(..())
return 1
if(href_list["PRG_downloadfile"])
if(!downloaded_file)
begin_file_download(href_list["PRG_downloadfile"], usr)
return 1
if(href_list["PRG_reseterror"])
if(downloaderror)
download_completion = 0
download_netspeed = 0
downloaded_file = null
downloaderror = ""
return 1
return 0
/datum/nano_module/program/computer_ntnetdownload
name = "Network Downloader"
var/obj/item/modular_computer/my_computer = null
/datum/nano_module/program/computer_ntnetdownload/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/topic_state/state = default_state)
if(program)
my_computer = program.computer
if(!istype(my_computer))
return
var/list/data = list()
var/datum/computer_file/program/ntnetdownload/prog = program
// For now limited to execution by the downloader program
if(!prog || !istype(prog))
return
if(program)
data = program.get_header_data()
// This IF cuts on data transferred to client, so i guess it's worth it.
if(prog.downloaderror) // Download errored. Wait until user resets the program.
data["error"] = prog.downloaderror
else if(prog.downloaded_file) // Download running. Wait please..
if (ui)
ui.set_auto_update(1)
data["downloadname"] = prog.downloaded_file.filename
data["downloaddesc"] = prog.downloaded_file.filedesc
data["downloadsize"] = prog.downloaded_file.size
data["downloadspeed"] = prog.download_netspeed //Even if it does update every 2 seconds, this is bad coding on everyone's count. :ree:
data["downloadcompletion"] = round(prog.download_completion, 0.01)
else // No download running, pick file.
if (ui)
ui.set_auto_update(0)//No need for auto updating on the software menu
data["disk_size"] = my_computer.hard_drive.max_capacity
data["disk_used"] = my_computer.hard_drive.used_capacity
if(my_computer.enrolled == 2) //To lock installation of software on work computers until the IT Department is properly implemented - Then check for access on enrolled computers
data += get_programlist(user)
else
data["downloadable_programs"] = list()
data["locked"] = 1
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "ntnet_downloader.tmpl", "NTNet Download Program", 575, 700, state = state)
ui.auto_update_layout = 1
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)
/datum/nano_module/program/computer_ntnetdownload/proc/get_programlist(var/mob/user)
var/list/all_entries[0]
var/datum/computer_file/program/ntnetdownload/prog = program
var/list/data = list()
for(var/datum/computer_file/program/P in ntnet_global.available_station_software)
var/installed = 0
for(var/datum/computer_file/program/Q in program.holder.stored_files)
if (istype(P, Q.type))
installed = 1
break
if (!installed)
// Only those programs our user can run will show in the list
if(!P.can_download(user) && P.requires_access_to_download)
continue
all_entries.Add(list(list(
"filename" = P.filename,
"filedesc" = P.filedesc,
"fileinfo" = P.extended_desc,
"size" = P.size
)))
data["hackedavailable"] = 0
if(prog.computer_emagged) // If we are running on emagged computer we have access to some "bonus" software
var/list/hacked_programs[0]
for(var/datum/computer_file/program/P in ntnet_global.available_antag_software)
var/installed = 0
for(var/datum/computer_file/program/Q in program.holder.stored_files)
if (istype(P, Q.type))
installed = 1
break
if (!installed)
data["hackedavailable"] = 1
hacked_programs.Add(list(list(
"filename" = P.filename,
"filedesc" = P.filedesc,
"fileinfo" = P.extended_desc,
"size" = P.size
)))
data["hacked_programs"] = hacked_programs
data["downloadable_programs"] = all_entries
return data