mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-07-20 04:17:33 +01:00
Rock the UI Away - Removes VueUI and adds TGUI (#16509)
* tgui the beginning * binaries and the like * Bring in the last of it * Example radio UI * delete example * NTOS Main Menu, start on manifest, tgui states * tasks.json * gunnery ui pt 1 * okay * fix everything * scss update * oops * manifest gigablast * downloader part 1 * download prt 2 * NTOSDownloader final * mfw committing to_worlds * gunnery console pt2 * i cooked * targeting (finished) * one vueui down * voting ui almost done * MY MIND FEELS LIKE AN ARCH ENEMYYYY * voting ui down * photocopier * ntos config + download fixes * photocopier 2 * refactor define * NTOS client manager + fixes * fax machine final (it also uses toner now) * marching forwards... left behind... * ntnrc part 1 * canister * add quotes * portable pumps pt1 + more backgrounds * oops * finish the portable pump * freezers so I'll keep on pushing forward... you haven't seen the last of me... oooooooh... * doors ui pt1 * finish doors UI (forgive me wildkins it's a bit of shitcode) * vitals monitor, make things use labeled lists, new backgrounds * mais j'envoyé aucun mayday... * maglock pt1 * pour ça je me suis perdu... * infrared * fix that * prox sensor pt1 * prox sensor * signaler (this was actually pretty hard) * atmos control pt1 * atmos control pt1.1 * atmos pt 2 * fuel injector * multitool UI * jammer * list viewer * APC * portgen * targeting console updates + SMES ui * new themes, shield generator * supermatter * Add ore detector and (shitty) NTNet Relay * orderterminal pt1 * orderterminal pt2 * smartfridge * Add (air-)tank GUI update ore detector size * Adds Transfer Valves * Add AtmoScrubber * analyzer pt1 * weapons analyzer pt2 * bodyscanner pt1 * bodyscanner pt2 * fix this shitcode * seed storage * appearance changer * appearance changer final * sleeper pt1 * sleeper * gps * vehicles * chem dispenser * lily request * holopad * tgui modules pt1 * ppanel * damage menu * fixes * im here too now * follow menu, search bars * quikpay * quikpay fixes * circuit printer * ppanel * ppanel updates * pai * turret controls (i want to kill myself) * tweak * remove the boardgame * guntracker * implant tracker * penal mechs come close to me, come close to me * chem codex * pai radio * doorjack * pai directives * signaler removal, sensors * ghost spawner * spawnpoint * fixes * teleporter * one more to the chopping block * account database * remove divider * scanner, atmos * latejoin ui pt1 * latejoin * records pt1 * RECORDS UI DONE * delete interpreter & records * CHAT FUCKING CLIENT * data updates * fix some things * final UI, log * basic nanoui fix * antag panel * remove vueui * atm update * vending update * warrants, cameras * ntmonitor * time comes for all * preserve this legacy * bring that back (oops) * rcon, ui auto update for computer UIs, remove rcon computers * alarm monitoring (a bit broke and also todo: add custom alarm monitoring programs to a few consoles) * A LIKE SUPREME * a * power monitor * lights on * fuck this code, fuck nanoui modules, and fuck nanoui * LEAVE IT OH SO FAR BEHIND * fix alarm monitoring for synths * I SAW IN YOU WHAT LIFE WAS MISSING * comms console * idcard and record updates * turn the light on * arcade * pt2 * news browser * static * crusher * f * COULD I JUST SLEIGH THE GOLD FROM THE BALLS? I'M SO FRUSTRATED OH COULD YOU TELL? IF I HEAR ONE MORE VUEUI OR ONE NANOUI I'M GONNA LOSE IT SO LET ME GOOOOOOOOOOOOOOOOO * codeowners & suit sensors * html ui style removal * make lint happy * resist and disorder * i slowly get up and turn off the noise, already fed up... * pleaseeeeeeeeeeeeeee * THE CREDIT LARP IS NECESSARY * i hold the keys * RISE UP * fix that? * harry's suggestions xoxo * runtime fix pt2 * You are the only thing that I still care about * adds build workflow * Update update_tgui.yml * adds some needed steps * ATM * misc fixes and tweaks * fixes 2 * make newscasters usable and fix use power on freezers * turret control is clearer --------- Co-authored-by: John Wildkins <john.wildkins@gmail.com> Co-authored-by: Matt Atlas <liermattia@gmail.com> Co-authored-by: harryob <55142896+harryob@users.noreply.github.com> Co-authored-by: Werner <Arrow768@users.noreply.github.com> Co-authored-by: Geeves <ggrobler447@gmail.com> Co-authored-by: harryob <me@harryob.live>
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
// This is special hardware configuration program.
|
||||
// It is to be used only with modular computers.
|
||||
// It allows you to toggle components of your device.
|
||||
/// Special software that allows for the configuration of software, and the device's status as a personal/company device.
|
||||
|
||||
/datum/computer_file/program/clientmanager
|
||||
filename = "clientmanager"
|
||||
@@ -15,77 +13,58 @@
|
||||
available_on_ntnet = FALSE
|
||||
requires_ntnet = FALSE
|
||||
|
||||
/datum/computer_file/program/clientmanager/ui_interact(mob/user)
|
||||
var/datum/vueui/ui = SSvueui.get_open_ui(user, src)
|
||||
if (!ui)
|
||||
ui = new /datum/vueui/modularcomputer(user, src, "mcomputer-system-manager", 575, 700, "NTOS Client Manager")
|
||||
ui.open()
|
||||
tgui_id = "NTOSClientManager"
|
||||
|
||||
/datum/computer_file/program/clientmanager/vueui_transfer(oldobj)
|
||||
SSvueui.transfer_uis(oldobj, src, "mcomputer-system-manager", 575, 700, "NTOS Client Manager")
|
||||
return TRUE
|
||||
|
||||
// Gaters data for ui
|
||||
/datum/computer_file/program/clientmanager/vueui_data_change(var/list/data, var/mob/user, var/datum/vueui/ui)
|
||||
. = ..()
|
||||
data = . || data || list()
|
||||
// Gather data for computer header
|
||||
var/headerdata = get_header_data(data["_PC"])
|
||||
if(headerdata)
|
||||
data["_PC"] = headerdata
|
||||
. = data
|
||||
if(!computer)
|
||||
return
|
||||
VUEUI_SET_CHECK_IFNOTSET(data["device_type"], 0, ., data)
|
||||
VUEUI_SET_CHECK_IFNOTSET(data["device_preset"], "", ., data)
|
||||
|
||||
VUEUI_SET_CHECK(data["enrollment_status"], computer.enrolled, ., data)
|
||||
VUEUI_SET_CHECK(data["ntnet_status"], ntnet_global.check_function(NTNET_SOFTWAREDOWNLOAD), ., data)
|
||||
|
||||
LAZYINITLIST(data["presets"])
|
||||
for (var/datum/modular_computer_app_presets/p in ntnet_global.available_software_presets)
|
||||
/datum/computer_file/program/clientmanager/ui_static_data(mob/user)
|
||||
var/list/data = list()
|
||||
data["enrollment"] = computer.enrolled
|
||||
data["available_presets"] = list()
|
||||
for(var/datum/modular_computer_app_presets/p in ntnet_global.available_software_presets)
|
||||
if(p.available)
|
||||
LAZYINITLIST(data["presets"][p.name])
|
||||
VUEUI_SET_CHECK(data["presets"][p.name]["name"], p.display_name, ., data)
|
||||
VUEUI_SET_CHECK(data["presets"][p.name]["description"], p.description, ., data)
|
||||
data["available_presets"][p.display_name] = p.description
|
||||
return data
|
||||
|
||||
/datum/computer_file/program/clientmanager/ui_data(mob/user)
|
||||
var/list/data = list()
|
||||
data["ntnet_status"] = ntnet_global.check_function(NTNET_SOFTWAREDOWNLOAD)
|
||||
return data
|
||||
|
||||
/datum/computer_file/program/clientmanager/Topic(href, href_list)
|
||||
/datum/computer_file/program/clientmanager/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
||||
if(..())
|
||||
return TRUE
|
||||
|
||||
if(href_list["enroll"])
|
||||
if(ntnet_global.check_function(NTNET_SOFTWAREDOWNLOAD))
|
||||
if(href_list["enroll"]["type"] == 1)
|
||||
enroll_company_device(href_list["enroll"]["preset"])
|
||||
return TRUE
|
||||
if(href_list["enroll"]["type"] == 2)
|
||||
enroll_private_device()
|
||||
return TRUE
|
||||
return FALSE
|
||||
if(action == "enroll")
|
||||
. = TRUE
|
||||
if(!ntnet_global.check_function(NTNET_SOFTWAREDOWNLOAD))
|
||||
to_chat(ui.user, SPAN_WARNING("Cannot connect to NTNet download servers. Please try again later."))
|
||||
return
|
||||
if(params["enroll_type"] & DEVICE_COMPANY)
|
||||
enroll_company_device(params["enroll_preset"])
|
||||
else
|
||||
enroll_private_device()
|
||||
|
||||
//Set´s up the computer with the file manager and the downloader and removes the lock
|
||||
/// Sets up the device as a generic, personal device, with only basic programs (file manager, downloads, chat client)
|
||||
/datum/computer_file/program/clientmanager/proc/enroll_private_device()
|
||||
if(!computer)
|
||||
return FALSE
|
||||
computer.enrolled = 2 // private devices
|
||||
return
|
||||
computer.enrolled = DEVICE_PRIVATE // private devices
|
||||
computer.hard_drive.store_file(new /datum/computer_file/program/filemanager(computer))
|
||||
computer.hard_drive.store_file(new /datum/computer_file/program/ntnetdownload(computer))
|
||||
computer.hard_drive.store_file(new /datum/computer_file/program/chat_client(computer))
|
||||
return TRUE
|
||||
update_static_data_for_all_viewers()
|
||||
|
||||
//Set´s up the programs from the preset
|
||||
/// Enrolls the device as a given software preset, and sets it as a company device
|
||||
/datum/computer_file/program/clientmanager/proc/enroll_company_device(var/preset)
|
||||
if(!computer)
|
||||
return FALSE
|
||||
return
|
||||
|
||||
for (var/datum/modular_computer_app_presets/prs in ntnet_global.available_software_presets)
|
||||
if(prs.name == preset && prs.available == 1)
|
||||
if(prs.display_name == preset && prs.available == 1)
|
||||
var/list/prs_programs = prs.return_install_programs(computer)
|
||||
for (var/datum/computer_file/program/prog in prs_programs)
|
||||
if(!prog.is_supported_by_hardware(computer.hardware_flag, FALSE))
|
||||
continue
|
||||
computer.hard_drive.store_file(prog)
|
||||
computer.enrolled = 1 // enroll as company device after finding matching preset and storing software
|
||||
return TRUE
|
||||
return FALSE
|
||||
computer.enrolled = DEVICE_COMPANY // enroll as company device after finding matching preset and storing software
|
||||
break
|
||||
update_static_data_for_all_viewers()
|
||||
|
||||
@@ -15,65 +15,53 @@
|
||||
available_on_ntnet = FALSE
|
||||
requires_ntnet = FALSE
|
||||
|
||||
/datum/computer_file/program/computerconfig/ui_interact(mob/user)
|
||||
var/datum/vueui/ui = SSvueui.get_open_ui(user, src)
|
||||
if (!ui)
|
||||
ui = new /datum/vueui/modularcomputer(user, src, "mcomputer-system-config", 575, 700, "NTOS Configuration Utility")
|
||||
ui.open()
|
||||
tgui_id = "NTOSConfig"
|
||||
|
||||
/datum/computer_file/program/computerconfig/vueui_transfer(oldobj)
|
||||
SSvueui.transfer_uis(oldobj, src, "mcomputer-system-config", 575, 700, "NTOS Configuration Utility")
|
||||
return TRUE
|
||||
/datum/computer_file/program/computerconfig/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
||||
if(..())
|
||||
return TRUE
|
||||
|
||||
// Gaters data for ui
|
||||
/datum/computer_file/program/computerconfig/vueui_data_change(var/list/data, var/mob/user, var/datum/vueui/ui)
|
||||
. = ..()
|
||||
data = . || data || list()
|
||||
// Gather data for computer header
|
||||
var/headerdata = get_header_data(data["_PC"])
|
||||
if(headerdata)
|
||||
data["_PC"] = headerdata
|
||||
. = data
|
||||
if(action == "brightness" && computer.flashlight)
|
||||
var/new_brightness = Clamp(0, params["new_brightness"]/10, 1)
|
||||
computer.flashlight.tweak_brightness(new_brightness)
|
||||
. = TRUE
|
||||
|
||||
if(!computer)
|
||||
return
|
||||
if(action == "audmessage")
|
||||
computer.message_output_range = clamp(params["new_range"], 0, initial(computer.message_output_range) + 3)
|
||||
. = TRUE
|
||||
|
||||
var/list/hardware = computer.get_all_components()
|
||||
VUEUI_SET_CHECK(data["disk_size"], computer.hard_drive.max_capacity, ., data)
|
||||
VUEUI_SET_CHECK(data["disk_used"], computer.hard_drive.used_capacity, ., data)
|
||||
VUEUI_SET_CHECK(data["power_usage"], computer.last_power_usage * (CELLRATE / 2), ., data)
|
||||
VUEUI_SET_CHECK(data["card_slot"], computer.card_slot, ., data)
|
||||
if(computer.registered_id)
|
||||
VUEUI_SET_CHECK(data["registered"], computer.registered_id.registered_name, ., data)
|
||||
else
|
||||
VUEUI_SET_CHECK(data["registered"], 0, ., data)
|
||||
if(!computer.battery_module)
|
||||
VUEUI_SET_CHECK(data["battery"], 0, ., data)
|
||||
else
|
||||
LAZYINITLIST(data["battery"])
|
||||
VUEUI_SET_CHECK(data["battery"]["rating"], computer.battery_module.battery.maxcharge, ., data)
|
||||
VUEUI_SET_CHECK(data["battery"]["percent"], round(computer.battery_module.battery.percent()), ., data)
|
||||
/datum/computer_file/program/computerconfig/ui_static_data(mob/user)
|
||||
var/list/data = ..() || list()
|
||||
data["disk_size"] = computer.hard_drive.max_capacity
|
||||
data["disk_used"] = computer.hard_drive.used_capacity
|
||||
data["card_slot"] = !!computer.card_slot
|
||||
data["registered"] = computer.registered_id ? computer.registered_id.registered_name : ""
|
||||
|
||||
if(computer.flashlight)
|
||||
var/brightness = Clamp(0, round(computer.flashlight.power) * 10, 10)
|
||||
VUEUI_SET_CHECK_IFNOTSET(data["brightness"], brightness, ., data)
|
||||
data["max_message_range"] = initial(computer.message_output_range) + 3
|
||||
|
||||
if(data["brightness"])
|
||||
var/new_brightness = Clamp(0, data["brightness"]/10, 1)
|
||||
computer.flashlight.tweak_brightness(new_brightness)
|
||||
|
||||
VUEUI_SET_CHECK_IFNOTSET(data["message_range"], computer.message_output_range, ., data)
|
||||
VUEUI_SET_CHECK_IFNOTSET(data["max_message_range"], initial(computer.message_output_range) + 3, ., data)
|
||||
|
||||
if(data["message_range"])
|
||||
computer.message_output_range = clamp(data["message_range"], 0, initial(computer.message_output_range) + 3)
|
||||
|
||||
LAZYINITLIST(data["hardware"])
|
||||
for(var/obj/item/computer_hardware/H in hardware)
|
||||
LAZYINITLIST(data["hardware"][H.name])
|
||||
data["hardware"] = list()
|
||||
for(var/obj/item/computer_hardware/H in computer.get_all_components())
|
||||
var/list/hardware_data = list()
|
||||
for(var/v in list("name", "desc", "enabled", "critical", "power_usage"))
|
||||
if(v == "power_usage")
|
||||
var/watt_usage = H.vars[v] * (CELLRATE / 2)
|
||||
VUEUI_SET_CHECK(data["hardware"][H.name][v], watt_usage, ., data)
|
||||
hardware_data[v] = watt_usage
|
||||
else
|
||||
VUEUI_SET_CHECK(data["hardware"][H.name][v], H.vars[v], ., data)
|
||||
hardware_data[v] = H.vars[v]
|
||||
if(hardware_data.len)
|
||||
data["hardware"] += list(hardware_data)
|
||||
|
||||
return data
|
||||
|
||||
/datum/computer_file/program/computerconfig/ui_data(mob/user)
|
||||
var/list/data = list()
|
||||
data["power_usage"] = computer.last_power_usage * (CELLRATE / 2)
|
||||
data["message_range"] = computer.message_output_range
|
||||
|
||||
data["battery"] = computer.battery_module ? list("rating" = computer.battery_module.battery_rating, "percent" = computer.battery_module.battery.percent()) : null
|
||||
|
||||
if(computer.flashlight)
|
||||
var/brightness = Clamp(0, round(computer.flashlight.power, 0.1) * 10, 10)
|
||||
data["brightness"] = brightness
|
||||
|
||||
return data
|
||||
|
||||
@@ -10,236 +10,26 @@
|
||||
requires_ntnet = FALSE
|
||||
available_on_ntnet = FALSE
|
||||
undeletable = TRUE
|
||||
nanomodule_path = /datum/nano_module/program/computer_filemanager
|
||||
tgui_id = "FileManager"
|
||||
var/open_file
|
||||
var/error
|
||||
|
||||
/datum/computer_file/program/filemanager/Topic(href, href_list)
|
||||
if(..())
|
||||
return TRUE
|
||||
|
||||
if(href_list["PRG_openfile"])
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
var/datum/computer_file/F = HDD.find_file_by_name(href_list["PRG_openfile"])
|
||||
if(!F)
|
||||
return
|
||||
if(F.can_access_file(usr))
|
||||
open_file = href_list["PRG_openfile"]
|
||||
else
|
||||
return
|
||||
if(href_list["PRG_newtextfile"])
|
||||
. = TRUE
|
||||
var/newname = sanitize(input(usr, "Enter file name or leave blank to cancel:", "File rename"))
|
||||
if(!newname)
|
||||
return TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
if(!HDD)
|
||||
return TRUE
|
||||
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"])
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
if(!HDD)
|
||||
return TRUE
|
||||
var/datum/computer_file/file = HDD.find_file_by_name(href_list["PRG_deletefile"])
|
||||
if(!file || file.undeletable)
|
||||
return TRUE
|
||||
HDD.remove_file(file)
|
||||
if(href_list["PRG_usbdeletefile"])
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/RHDD = computer.portable_drive
|
||||
if(!RHDD)
|
||||
return TRUE
|
||||
var/datum/computer_file/file = RHDD.find_file_by_name(href_list["PRG_usbdeletefile"])
|
||||
if(!file || file.undeletable)
|
||||
return TRUE
|
||||
RHDD.remove_file(file)
|
||||
if(href_list["PRG_closefile"])
|
||||
. = TRUE
|
||||
open_file = null
|
||||
error = null
|
||||
if(href_list["PRG_clone"])
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
if(!HDD)
|
||||
return TRUE
|
||||
var/datum/computer_file/F = HDD.find_file_by_name(href_list["PRG_clone"])
|
||||
if(!F || !istype(F))
|
||||
return TRUE
|
||||
var/datum/computer_file/C = F.clone(1)
|
||||
HDD.store_file(C)
|
||||
if(href_list["PRG_rename"])
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
if(!HDD)
|
||||
return TRUE
|
||||
var/datum/computer_file/file = HDD.find_file_by_name(href_list["PRG_rename"])
|
||||
if(!file || !istype(file))
|
||||
return TRUE
|
||||
var/newname = sanitize(input(usr, "Enter new file name:", "File rename", file.filename))
|
||||
if(file && newname)
|
||||
file.filename = newname
|
||||
if(href_list["PRG_edit"])
|
||||
. = TRUE
|
||||
if(!open_file)
|
||||
return TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
if(!HDD)
|
||||
return TRUE
|
||||
var/datum/computer_file/data/F = HDD.find_file_by_name(open_file)
|
||||
if(!F || !istype(F))
|
||||
return TRUE
|
||||
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 TRUE
|
||||
|
||||
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"])
|
||||
. = TRUE
|
||||
if(!open_file)
|
||||
return TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
if(!HDD)
|
||||
return TRUE
|
||||
if(!computer.nano_printer)
|
||||
error = "Missing Hardware: Your computer does not have required hardware to complete this operation."
|
||||
return TRUE
|
||||
var/datum/computer_file/data/F = HDD.find_file_by_name(open_file)
|
||||
var/datum/computer_file/script/S = F
|
||||
if(!F)
|
||||
return TRUE
|
||||
if(istype(F))
|
||||
if(!computer.nano_printer.print_text(F.stored_data))
|
||||
error = "Hardware error: Printer was unable to print the file. It may be out of paper."
|
||||
return TRUE
|
||||
else if(istype(S))
|
||||
if(!computer.nano_printer.print_text(S.code))
|
||||
error = "Hardware error: Printer was unable to print the file. It may be out of paper."
|
||||
return TRUE
|
||||
if(href_list["PRG_copytousb"])
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
var/obj/item/computer_hardware/hard_drive/portable/RHDD = computer.portable_drive
|
||||
if(!HDD || !RHDD)
|
||||
return TRUE
|
||||
var/datum/computer_file/F = HDD.find_file_by_name(href_list["PRG_copytousb"])
|
||||
if(!F || !istype(F))
|
||||
return TRUE
|
||||
var/is_usr_tech_support = FALSE
|
||||
if(ishuman(usr))
|
||||
var/mob/living/carbon/human/H = usr
|
||||
var/obj/item/card/id/ID = H.GetIdCard()
|
||||
if(access_it in ID.access)
|
||||
is_usr_tech_support = TRUE
|
||||
if(!is_usr_tech_support && computer.enrolled != 2 && istype(F, /datum/computer_file/program))
|
||||
to_chat(usr, SPAN_WARNING("Work devices can't export programs to portable drives! Contact Tech Support to get them to load it."))
|
||||
return TRUE
|
||||
if(!RHDD.can_store_file(F.size))
|
||||
to_chat(usr, SPAN_WARNING("\The [RHDD] doesn't have enough space to import the file."))
|
||||
return
|
||||
var/datum/computer_file/C = F.clone(0, "Compless")
|
||||
for(var/datum/computer_file/installed_file in RHDD.stored_files)
|
||||
if(C.filename == installed_file.filename)
|
||||
to_chat(usr, SPAN_WARNING("A file with the same name is already installed on \the [computer]."))
|
||||
qdel(C)
|
||||
return
|
||||
RHDD.store_file(C)
|
||||
if(href_list["PRG_copyfromusb"])
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
var/obj/item/computer_hardware/hard_drive/portable/RHDD = computer.portable_drive
|
||||
if(!HDD || !RHDD)
|
||||
return TRUE
|
||||
var/datum/computer_file/F = RHDD.find_file_by_name(href_list["PRG_copyfromusb"])
|
||||
if(!F || !istype(F))
|
||||
return TRUE
|
||||
var/is_usr_tech_support = FALSE
|
||||
if(ishuman(usr))
|
||||
var/mob/living/carbon/human/H = usr
|
||||
var/obj/item/card/id/ID = H.GetIdCard()
|
||||
if(access_it in ID.access)
|
||||
is_usr_tech_support = TRUE
|
||||
if(!is_usr_tech_support && computer.enrolled != 2 && istype(F, /datum/computer_file/program))
|
||||
to_chat(usr, SPAN_WARNING("Work devices can't import programs from portable drives! Contact Tech Support to get them to load it."))
|
||||
return TRUE
|
||||
if(!HDD.can_store_file(F.size))
|
||||
to_chat(usr, SPAN_WARNING("\The [computer]'s hard drive doesn't have enough space to import the file."))
|
||||
return
|
||||
var/datum/computer_file/C = F.clone(0, computer)
|
||||
for(var/datum/computer_file/installed_file in HDD.stored_files)
|
||||
if(C.filename == installed_file.filename)
|
||||
to_chat(usr, SPAN_WARNING("A file with the same name is already installed on \the [computer]."))
|
||||
qdel(C)
|
||||
return
|
||||
HDD.store_file(C)
|
||||
if(href_list["PRG_encrypt"])
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
if (!HDD)
|
||||
return
|
||||
var/datum/computer_file/F = HDD.find_file_by_name(href_list["PRG_encrypt"])
|
||||
if(!F || F.undeletable)
|
||||
return
|
||||
if(F.password)
|
||||
return
|
||||
F.password = sanitize(input(usr, "Enter an encryption key:", "Encrypt File"))
|
||||
if(href_list["PRG_decrypt"])
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
if (!HDD)
|
||||
return
|
||||
var/datum/computer_file/F = HDD.find_file_by_name(href_list["PRG_encrypt"])
|
||||
if(!F || F.undeletable)
|
||||
return
|
||||
if (F.can_access_file(usr))
|
||||
F.password = ""
|
||||
else
|
||||
return
|
||||
if(.)
|
||||
SSnanoui.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 = list("_PC" = program.get_header_data())
|
||||
PRG = program
|
||||
/datum/computer_file/program/filemanager/ui_data(mob/user)
|
||||
var/list/data = initial_data()
|
||||
|
||||
var/obj/item/computer_hardware/hard_drive/HDD
|
||||
var/obj/item/computer_hardware/hard_drive/portable/RHDD
|
||||
if(PRG.error)
|
||||
data["error"] = PRG.error
|
||||
if(PRG.open_file)
|
||||
if(error)
|
||||
data["error"] = error
|
||||
if(open_file)
|
||||
var/datum/computer_file/data/file
|
||||
var/datum/computer_file/script/script
|
||||
|
||||
if(!PRG.computer || !PRG.computer.hard_drive)
|
||||
if(!computer || !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)
|
||||
HDD = computer.hard_drive
|
||||
file = HDD.find_file_by_name(open_file)
|
||||
script = file
|
||||
if(!istype(file))
|
||||
if(!istype(script))
|
||||
@@ -251,12 +41,12 @@
|
||||
data["filedata"] = pencode2html(file.stored_data)
|
||||
data["filename"] = "[file.filename].[file.filetype]"
|
||||
else
|
||||
if(!PRG.computer || !PRG.computer.hard_drive)
|
||||
if(!computer || !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]
|
||||
HDD = computer.hard_drive
|
||||
RHDD = computer.portable_drive
|
||||
var/list/files = list()
|
||||
for(var/datum/computer_file/F in HDD.stored_files)
|
||||
files.Add(list(list(
|
||||
"name" = F.filename,
|
||||
@@ -267,8 +57,8 @@
|
||||
)))
|
||||
data["files"] = files
|
||||
if(RHDD)
|
||||
data["usbconnected"] = 1
|
||||
var/list/usbfiles[0]
|
||||
data["usbconnected"] = TRUE
|
||||
var/list/usbfiles = list()
|
||||
for(var/datum/computer_file/F in RHDD.stored_files)
|
||||
usbfiles.Add(list(list(
|
||||
"name" = F.filename,
|
||||
@@ -278,12 +68,217 @@
|
||||
"encrypted" = !!F.password
|
||||
)))
|
||||
data["usbfiles"] = usbfiles
|
||||
return data
|
||||
|
||||
ui = SSnanoui.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 = TRUE
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
/datum/computer_file/program/filemanager/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
||||
if(..())
|
||||
return
|
||||
|
||||
switch(action)
|
||||
if("PRG_openfile")
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
var/datum/computer_file/F = HDD.find_file_by_name(params["PRG_openfile"])
|
||||
if(!F)
|
||||
return
|
||||
if(F.can_access_file(usr))
|
||||
open_file = params["PRG_openfile"]
|
||||
|
||||
if("PRG_newtextfile")
|
||||
. = TRUE
|
||||
var/newname = sanitize(input(usr, "Enter file name or leave blank to cancel:", "File rename"))
|
||||
if(!newname)
|
||||
return TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
if(!HDD)
|
||||
return TRUE
|
||||
var/datum/computer_file/data/F = new/datum/computer_file/data()
|
||||
F.filename = newname
|
||||
F.filetype = "TXT"
|
||||
HDD.store_file(F)
|
||||
|
||||
if("PRG_deletefile")
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
if(!HDD)
|
||||
return TRUE
|
||||
var/datum/computer_file/file = HDD.find_file_by_name(params["PRG_deletefile"])
|
||||
if(!file || file.undeletable)
|
||||
return TRUE
|
||||
HDD.remove_file(file)
|
||||
|
||||
if("PRG_usbdeletefile")
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/RHDD = computer.portable_drive
|
||||
if(!RHDD)
|
||||
return TRUE
|
||||
var/datum/computer_file/file = RHDD.find_file_by_name(params["PRG_usbdeletefile"])
|
||||
if(!file || file.undeletable)
|
||||
return TRUE
|
||||
RHDD.remove_file(file)
|
||||
|
||||
if("PRG_closefile")
|
||||
. = TRUE
|
||||
open_file = null
|
||||
error = null
|
||||
|
||||
if("PRG_clone")
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
if(!HDD)
|
||||
return TRUE
|
||||
var/datum/computer_file/F = HDD.find_file_by_name(params["PRG_clone"])
|
||||
if(!F || !istype(F))
|
||||
return TRUE
|
||||
var/datum/computer_file/C = F.clone(1)
|
||||
HDD.store_file(C)
|
||||
|
||||
if("PRG_rename")
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
if(!HDD)
|
||||
return TRUE
|
||||
var/datum/computer_file/file = HDD.find_file_by_name(params["PRG_rename"])
|
||||
if(!file || !istype(file))
|
||||
return TRUE
|
||||
var/newname = sanitize(input(usr, "Enter new file name:", "File rename", file.filename))
|
||||
if(file && newname)
|
||||
file.filename = newname
|
||||
|
||||
if("PRG_edit")
|
||||
. = TRUE
|
||||
if(!open_file)
|
||||
return TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
if(!HDD)
|
||||
return TRUE
|
||||
var/datum/computer_file/data/F = HDD.find_file_by_name(open_file)
|
||||
if(!F || !istype(F))
|
||||
return TRUE
|
||||
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 TRUE
|
||||
|
||||
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("PRG_printfile")
|
||||
. = TRUE
|
||||
if(!open_file)
|
||||
return TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
if(!HDD)
|
||||
return TRUE
|
||||
if(!computer.nano_printer)
|
||||
error = "Missing Hardware: Your computer does not have required hardware to complete this operation."
|
||||
return TRUE
|
||||
var/datum/computer_file/data/F = HDD.find_file_by_name(open_file)
|
||||
var/datum/computer_file/script/S = F
|
||||
if(!F)
|
||||
return TRUE
|
||||
if(istype(F))
|
||||
if(!computer.nano_printer.print_text(F.stored_data))
|
||||
error = "Hardware error: Printer was unable to print the file. It may be out of paper."
|
||||
return TRUE
|
||||
else if(istype(S))
|
||||
if(!computer.nano_printer.print_text(S.code))
|
||||
error = "Hardware error: Printer was unable to print the file. It may be out of paper."
|
||||
return TRUE
|
||||
|
||||
if("PRG_copytousb")
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
var/obj/item/computer_hardware/hard_drive/portable/RHDD = computer.portable_drive
|
||||
if(!HDD || !RHDD)
|
||||
return TRUE
|
||||
var/datum/computer_file/F = HDD.find_file_by_name(params["PRG_copytousb"])
|
||||
if(!F || !istype(F))
|
||||
return TRUE
|
||||
var/is_usr_tech_support = FALSE
|
||||
if(ishuman(usr))
|
||||
var/mob/living/carbon/human/H = usr
|
||||
var/obj/item/card/id/ID = H.GetIdCard()
|
||||
if(access_it in ID.access)
|
||||
is_usr_tech_support = TRUE
|
||||
if(!is_usr_tech_support && computer.enrolled != DEVICE_PRIVATE && istype(F, /datum/computer_file/program))
|
||||
to_chat(usr, SPAN_WARNING("Work devices can't export programs to portable drives! Contact Tech Support to get them to load it."))
|
||||
return TRUE
|
||||
if(!RHDD.can_store_file(F.size))
|
||||
to_chat(usr, SPAN_WARNING("\The [RHDD] doesn't have enough space to import the file."))
|
||||
return
|
||||
var/datum/computer_file/C = F.clone(0, "Compless")
|
||||
for(var/datum/computer_file/installed_file in RHDD.stored_files)
|
||||
if(C.filename == installed_file.filename)
|
||||
to_chat(usr, SPAN_WARNING("A file with the same name is already installed on \the [computer]."))
|
||||
qdel(C)
|
||||
return
|
||||
RHDD.store_file(C)
|
||||
|
||||
if("PRG_copyfromusb")
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
var/obj/item/computer_hardware/hard_drive/portable/RHDD = computer.portable_drive
|
||||
if(!HDD || !RHDD)
|
||||
return TRUE
|
||||
var/datum/computer_file/F = RHDD.find_file_by_name(params["PRG_copyfromusb"])
|
||||
if(!F || !istype(F))
|
||||
return TRUE
|
||||
var/is_usr_tech_support = FALSE
|
||||
if(ishuman(usr))
|
||||
var/mob/living/carbon/human/H = usr
|
||||
var/obj/item/card/id/ID = H.GetIdCard()
|
||||
if(access_it in ID.access)
|
||||
is_usr_tech_support = TRUE
|
||||
if(!is_usr_tech_support && computer.enrolled != DEVICE_PRIVATE && istype(F, /datum/computer_file/program))
|
||||
to_chat(usr, SPAN_WARNING("Work devices can't import programs from portable drives! Contact Tech Support to get them to load it."))
|
||||
return TRUE
|
||||
if(!HDD.can_store_file(F.size))
|
||||
to_chat(usr, SPAN_WARNING("\The [computer]'s hard drive doesn't have enough space to import the file."))
|
||||
return
|
||||
var/datum/computer_file/C = F.clone(0, computer)
|
||||
for(var/datum/computer_file/installed_file in HDD.stored_files)
|
||||
if(C.filename == installed_file.filename)
|
||||
to_chat(usr, SPAN_WARNING("A file with the same name is already installed on \the [computer]."))
|
||||
qdel(C)
|
||||
return
|
||||
HDD.store_file(C)
|
||||
|
||||
if("PRG_encrypt")
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
if (!HDD)
|
||||
return
|
||||
var/datum/computer_file/F = HDD.find_file_by_name(params["PRG_encrypt"])
|
||||
if(!F || F.undeletable)
|
||||
return
|
||||
if(F.password)
|
||||
return
|
||||
F.password = sanitize(input(usr, "Enter an encryption key:", "Encrypt File"))
|
||||
|
||||
if("PRG_decrypt")
|
||||
. = TRUE
|
||||
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
|
||||
if (!HDD)
|
||||
return
|
||||
var/datum/computer_file/F = HDD.find_file_by_name(params["PRG_encrypt"])
|
||||
if(!F || F.undeletable)
|
||||
return
|
||||
if (F.can_access_file(usr))
|
||||
F.password = ""
|
||||
|
||||
#undef MAX_TEXTFILE_LENGTH
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/// Nothing preventing download
|
||||
#define DL_OK 0
|
||||
/// Can't download due to insufficient access
|
||||
#define DL_ERR_ACCESS 1
|
||||
/// Can't download due to incompatible / missing hardware
|
||||
#define DL_ERR_HARDWARE 2
|
||||
/// Can't download without being emagged
|
||||
#define DL_ERR_SYNDIE 3
|
||||
|
||||
/datum/computer_file/program/ntnetdownload
|
||||
filename = "ntndownloader"
|
||||
filedesc = "NTNet Software Download Tool"
|
||||
@@ -12,6 +21,8 @@
|
||||
requires_ntnet_feature = NTNET_SOFTWAREDOWNLOAD
|
||||
available_on_ntnet = 0
|
||||
ui_header = "downloader_finished.gif"
|
||||
tgui_id = "NTOSDownloader"
|
||||
|
||||
var/list/download_queue = list()
|
||||
var/list/download_files = list()
|
||||
var/queue_size = 0
|
||||
@@ -19,87 +30,65 @@
|
||||
var/last_update = 0
|
||||
var/speed = 0
|
||||
|
||||
|
||||
/datum/computer_file/program/ntnetdownload/ui_interact(mob/user, var/datum/topic_state/state = default_state)
|
||||
var/datum/vueui/ui = SSvueui.get_open_ui(user, src)
|
||||
if (!ui)
|
||||
ui = new /datum/vueui/modularcomputer(user, src, "mcomputer-system-downloader", 575, 700, "NTNet Download Program", state = state)
|
||||
ui.open()
|
||||
|
||||
/datum/computer_file/program/ntnetdownload/vueui_transfer(oldobj)
|
||||
SSvueui.transfer_uis(oldobj, src, "mcomputer-system-downloader", 575, 700, "NTNet Download Program")
|
||||
return TRUE
|
||||
|
||||
// Gaters data for ui
|
||||
/datum/computer_file/program/ntnetdownload/vueui_data_change(var/list/data, var/mob/user, var/datum/vueui/ui)
|
||||
. = ..()
|
||||
data = . || data || list("queue" = download_queue)
|
||||
|
||||
if(!istype(computer))
|
||||
return
|
||||
|
||||
// Gather data for computer header
|
||||
var/headerdata = get_header_data(data["_PC"])
|
||||
if(headerdata)
|
||||
data["_PC"] = headerdata
|
||||
. = data
|
||||
|
||||
// Let's send all installed programs
|
||||
LAZYINITLIST(data["installed"])
|
||||
for(var/datum/computer_file/program/I in hard_drive.stored_files)
|
||||
LAZYINITLIST(data["installed"][I.filename])
|
||||
VUEUI_SET_CHECK(data["installed"][I.filename]["name"], I.filedesc, ., data)
|
||||
VUEUI_SET_CHECK(data["installed"][I.filename]["size"], I.size, ., data)
|
||||
|
||||
// Now lets send all available programs with their status.
|
||||
// Statuses (rest): 0 - ALL OK, 1 - can't download due to access, 2 - unsuported hardware, 3 - sindies only
|
||||
LAZYINITLIST(data["available"])
|
||||
/datum/computer_file/program/ntnetdownload/ui_static_data(mob/user)
|
||||
var/list/data = list()
|
||||
for(var/datum/computer_file/program/P in ntnet_global.available_software)
|
||||
LAZYINITLIST(data["available"][P.filename])
|
||||
VUEUI_SET_CHECK(data["available"][P.filename]["name"], P.filedesc, ., data)
|
||||
VUEUI_SET_CHECK(data["available"][P.filename]["desc"], P.extended_desc, ., data)
|
||||
VUEUI_SET_CHECK(data["available"][P.filename]["size"], P.size, ., data)
|
||||
if(computer_emagged)
|
||||
if(!P.is_supported_by_hardware(computer.hardware_flag))
|
||||
VUEUI_SET_CHECK(data["available"][P.filename]["rest"], 2, ., data)
|
||||
else
|
||||
VUEUI_SET_CHECK(data["available"][P.filename]["rest"], 0, ., data)
|
||||
else
|
||||
if(!P.available_on_ntnet)
|
||||
VUEUI_SET_CHECK(data["available"][P.filename]["rest"], 3, ., data)
|
||||
else if(!P.can_download(user) && P.requires_access_to_download)
|
||||
VUEUI_SET_CHECK(data["available"][P.filename]["rest"], 1, ., data)
|
||||
else if(!P.is_supported_by_hardware(computer.hardware_flag))
|
||||
VUEUI_SET_CHECK(data["available"][P.filename]["rest"], 2, ., data)
|
||||
else
|
||||
VUEUI_SET_CHECK(data["available"][P.filename]["rest"], 0, ., data)
|
||||
if(hard_drive.find_file_by_name(P.filename))
|
||||
continue
|
||||
|
||||
VUEUI_SET_CHECK(data["disk_size"], hard_drive.max_capacity, ., data)
|
||||
VUEUI_SET_CHECK(data["disk_used"], hard_drive.used_capacity, ., data)
|
||||
VUEUI_SET_CHECK(data["queue_size"], queue_size, ., data)
|
||||
VUEUI_SET_CHECK(data["speed"], speed, ., data)
|
||||
if(P.filename in download_queue)
|
||||
continue
|
||||
|
||||
data["available"] += list(list(
|
||||
"filename" = P.filename,
|
||||
"name" = P.filedesc,
|
||||
"desc" = P.extended_desc,
|
||||
"size" = P.size,
|
||||
"stat" = get_download_status(P, user)
|
||||
))
|
||||
|
||||
data["disk_size"] = hard_drive.max_capacity
|
||||
data["disk_used"] = hard_drive.used_capacity
|
||||
return data
|
||||
|
||||
/datum/computer_file/program/ntnetdownload/ui_data(mob/user)
|
||||
var/list/data = list()
|
||||
data["queue_size"] = queue_size
|
||||
data["speed"] = speed
|
||||
data["active_download"] = active_download
|
||||
data["queue"] = list()
|
||||
for(var/name in download_queue)
|
||||
VUEUI_SET_CHECK(data["queue"][name], download_queue[name], ., data)
|
||||
var/datum/computer_file/program/PRG = download_files[name]
|
||||
data["queue"] += list(list(
|
||||
"name" = PRG ? PRG.filedesc : name,
|
||||
"filename" = name,
|
||||
"progress" = download_queue[name],
|
||||
"size" = PRG?.size
|
||||
))
|
||||
return data
|
||||
|
||||
/datum/computer_file/program/ntnetdownload/proc/get_download_status(datum/computer_file/program/P, mob/user)
|
||||
if(!computer_emagged)
|
||||
if(!P.available_on_ntnet)
|
||||
return DL_ERR_SYNDIE
|
||||
if(!P.can_download(user) && P.requires_access_to_download)
|
||||
return DL_ERR_ACCESS
|
||||
|
||||
/datum/computer_file/program/ntnetdownload/Topic(href, href_list)
|
||||
return P.is_supported_by_hardware(computer.hardware_flag) ? DL_OK : DL_ERR_HARDWARE
|
||||
|
||||
/datum/computer_file/program/ntnetdownload/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
||||
if(..())
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
var/datum/vueui/ui = href_list["vueui"]
|
||||
if(!istype(ui))
|
||||
return
|
||||
if(action == "download")
|
||||
var/datum/computer_file/program/PRG = ntnet_global.find_ntnet_file_by_name(params["filename"])
|
||||
if(istype(PRG))
|
||||
add_to_queue(PRG, usr)
|
||||
. = TRUE
|
||||
|
||||
if(href_list["download"])
|
||||
var/datum/computer_file/program/PRG = ntnet_global.find_ntnet_file_by_name(href_list["download"])
|
||||
|
||||
if(!istype(PRG))
|
||||
return 1
|
||||
return add_to_queue(PRG, ui.user)
|
||||
|
||||
if(href_list["cancel"])
|
||||
return cancel_from_queue(href_list["cancel"])
|
||||
if(action == "cancel")
|
||||
cancel_from_queue(params["filename"])
|
||||
. = TRUE
|
||||
|
||||
/datum/computer_file/program/ntnetdownload/proc/add_to_queue(var/datum/computer_file/program/PRG, var/mob/user)
|
||||
// Attempting to download antag only program, but without having emagged computer. No.
|
||||
@@ -126,14 +115,13 @@
|
||||
else
|
||||
generate_network_log("Began downloading file [PRG.filename].[PRG.filetype] from unspecified server.")
|
||||
|
||||
if(!length(download_queue))
|
||||
last_update = world.time
|
||||
|
||||
download_files[PRG.filename] = PRG.clone(FALSE, computer)
|
||||
queue_size += PRG.size
|
||||
download_queue[PRG.filename] = 0
|
||||
for(var/i in SSvueui.get_open_uis(src))
|
||||
var/datum/vueui/ui = i
|
||||
ui.data["queue"][PRG.filename] = 0
|
||||
ui.push_change()
|
||||
computer.update_static_data_for_all_viewers()
|
||||
return TRUE
|
||||
|
||||
/datum/computer_file/program/ntnetdownload/proc/cancel_from_queue(var/name)
|
||||
@@ -145,10 +133,7 @@
|
||||
download_queue -= name
|
||||
download_files -= name
|
||||
queue_size -= PRG.size
|
||||
for(var/i in SSvueui.get_open_uis(src))
|
||||
var/datum/vueui/ui = i
|
||||
ui.data["queue"] -= name
|
||||
ui.push_change()
|
||||
computer.update_static_data_for_all_viewers()
|
||||
|
||||
/datum/computer_file/program/ntnetdownload/proc/finish_from_queue(var/name)
|
||||
if(!download_files[name])
|
||||
@@ -159,24 +144,20 @@
|
||||
generate_network_log("Completed download of file [hacked_download ? "**ENCRYPTED**" : PRG.filename].[PRG.filetype].")
|
||||
if(!computer?.hard_drive?.store_file(PRG))
|
||||
download_queue[name] = -1
|
||||
for(var/i in SSvueui.get_open_uis(src))
|
||||
var/datum/vueui/ui = i
|
||||
ui.data["queue"] = -1
|
||||
ui.push_change()
|
||||
computer.update_static_data_for_all_viewers()
|
||||
return
|
||||
|
||||
download_queue -= name
|
||||
download_files -= name
|
||||
queue_size -= PRG.size
|
||||
for(var/i in SSvueui.get_open_uis(src))
|
||||
var/datum/vueui/ui = i
|
||||
ui.data["queue"] -= name
|
||||
ui.push_change()
|
||||
|
||||
computer.update_static_data_for_all_viewers()
|
||||
|
||||
/datum/computer_file/program/ntnetdownload/process_tick()
|
||||
if(!queue_size)
|
||||
var/old_header = ui_header
|
||||
ui_header = "downloader_finished.gif"
|
||||
if(old_header != ui_header)
|
||||
computer.update_static_data_for_all_viewers()
|
||||
return
|
||||
ui_header = "downloader_running.gif"
|
||||
|
||||
@@ -229,4 +210,8 @@
|
||||
computer.output_message("[icon2html(computer, viewers(get_turf(computer)), computer.icon_state)] <b>[capitalize_first_letters(computer.name)]</b> pings: \"[active_download_file.filedesc ? active_download_file.filedesc : active_download_file.filename] downloaded successfully!\"", 1)
|
||||
active_download = null
|
||||
|
||||
SSvueui.check_uis_for_change(src)
|
||||
|
||||
#undef DL_OK
|
||||
#undef DL_ERR_ACCESS
|
||||
#undef DL_ERR_HARDWARE
|
||||
#undef DL_ERR_SYNDIE
|
||||
|
||||
Reference in New Issue
Block a user