diff --git a/code/modules/modular_computers/computers/item/laptop_presets.dm b/code/modules/modular_computers/computers/item/laptop_presets.dm index 7a2697ab12e..6ae8d1346ee 100644 --- a/code/modules/modular_computers/computers/item/laptop_presets.dm +++ b/code/modules/modular_computers/computers/item/laptop_presets.dm @@ -20,4 +20,3 @@ /obj/item/modular_computer/laptop/preset/civillian/install_programs() var/obj/item/computer_hardware/hard_drive/hard_drive = all_components[MC_HDD] hard_drive.store_file(new/datum/computer_file/program/chatclient()) - hard_drive.store_file(new/datum/computer_file/program/nttransfer()) diff --git a/code/modules/modular_computers/computers/machinery/console_presets.dm b/code/modules/modular_computers/computers/machinery/console_presets.dm index d2465cf85bc..8c6def18e05 100644 --- a/code/modules/modular_computers/computers/machinery/console_presets.dm +++ b/code/modules/modular_computers/computers/machinery/console_presets.dm @@ -49,7 +49,6 @@ /obj/machinery/modular_computer/console/preset/research/install_programs() var/obj/item/computer_hardware/hard_drive/hard_drive = cpu.all_components[MC_HDD] hard_drive.store_file(new/datum/computer_file/program/ntnetmonitor()) - hard_drive.store_file(new/datum/computer_file/program/nttransfer()) hard_drive.store_file(new/datum/computer_file/program/chatclient()) hard_drive.store_file(new/datum/computer_file/program/aidiag()) @@ -76,5 +75,4 @@ /obj/machinery/modular_computer/console/preset/civilian/install_programs() var/obj/item/computer_hardware/hard_drive/hard_drive = cpu.all_components[MC_HDD] hard_drive.store_file(new/datum/computer_file/program/chatclient()) - hard_drive.store_file(new/datum/computer_file/program/nttransfer()) hard_drive.store_file(new/datum/computer_file/program/arcade()) diff --git a/code/modules/modular_computers/file_system/computer_file.dm b/code/modules/modular_computers/file_system/computer_file.dm index 2e2aa8e9eb3..4e862c4ae35 100644 --- a/code/modules/modular_computers/file_system/computer_file.dm +++ b/code/modules/modular_computers/file_system/computer_file.dm @@ -3,8 +3,8 @@ var/filetype = "XXX" // File full names are [filename].[filetype] so like NewFile.XXX in this case var/size = 1 // File size in GQ. Integers only! var/obj/item/computer_hardware/hard_drive/holder // Holder that contains this file. - var/unsendable = 0 // Whether the file may be sent to someone via NTNet transfer or other means. - var/undeletable = 0 // Whether the file may be deleted. Setting to 1 prevents deletion/renaming/etc. + var/unsendable = FALSE // Whether the file may be sent to someone via NTNet transfer or other means. + var/undeletable = FALSE // Whether the file may be deleted. Setting to TRUE prevents deletion/renaming/etc. var/uid // UID of this file var/static/file_uid = 0 @@ -24,7 +24,7 @@ return ..() // Returns independent copy of this file. -/datum/computer_file/proc/clone(rename = 0) +/datum/computer_file/proc/clone(rename = FALSE) var/datum/computer_file/temp = new type temp.unsendable = unsendable temp.undeletable = undeletable diff --git a/code/modules/modular_computers/file_system/programs/airestorer.dm b/code/modules/modular_computers/file_system/programs/airestorer.dm index 4a40b3cf86e..af1d88fb80b 100644 --- a/code/modules/modular_computers/file_system/programs/airestorer.dm +++ b/code/modules/modular_computers/file_system/programs/airestorer.dm @@ -4,12 +4,12 @@ program_icon_state = "generic" extended_desc = "This program is capable of reconstructing damaged AI systems. Requires direct AI connection via intellicard slot." size = 12 - requires_ntnet = 0 + requires_ntnet = FALSE usage_flags = PROGRAM_CONSOLE transfer_access = ACCESS_HEADS - available_on_ntnet = 1 + available_on_ntnet = TRUE tgui_id = "ntos_ai_restorer" - ui_x = 600 + ui_x = 370 ui_y = 400 var/restoring = FALSE @@ -30,11 +30,11 @@ if(ai_slot.stored_card.AI) return ai_slot.stored_card.AI - return null + return /datum/computer_file/program/aidiag/ui_act(action, params) if(..()) - return TRUE + return var/mob/living/silicon/ai/A = get_ai() if(!A) @@ -54,7 +54,7 @@ return TRUE /datum/computer_file/program/aidiag/process_tick() - ..() + . = ..() if(!restoring) //Put the check here so we don't check for an ai all the time return var/obj/item/aicard/cardhold = get_ai(2) @@ -91,9 +91,7 @@ /datum/computer_file/program/aidiag/ui_data(mob/user) var/list/data = get_header_data() - var/mob/living/silicon/ai/AI - // A shortcut for getting the AI stored inside the computer. The program already does necessary checks. - AI = get_ai() + var/mob/living/silicon/ai/AI = get_ai() var/obj/item/aicard/aicard = get_ai(2) @@ -119,4 +117,4 @@ /datum/computer_file/program/aidiag/kill_program(forced) restoring = FALSE - return ..(forced) + return ..() diff --git a/code/modules/modular_computers/file_system/programs/antagonist/dos.dm b/code/modules/modular_computers/file_system/programs/antagonist/dos.dm index 140b9d30f7a..004b86ef81d 100644 --- a/code/modules/modular_computers/file_system/programs/antagonist/dos.dm +++ b/code/modules/modular_computers/file_system/programs/antagonist/dos.dm @@ -4,9 +4,9 @@ program_icon_state = "hostile" extended_desc = "This advanced script can perform denial of service attacks against NTNet quantum relays. The system administrator will probably notice this. Multiple devices can run this program together against same relay for increased effect" size = 20 - requires_ntnet = 1 - available_on_ntnet = 0 - available_on_syndinet = 1 + requires_ntnet = TRUE + available_on_ntnet = FALSE + available_on_syndinet = TRUE tgui_id = "ntos_net_dos" ui_x = 400 ui_y = 250 @@ -36,61 +36,52 @@ if(target) target.dos_sources.Remove(src) target = null - executed = 0 + executed = FALSE ..() /datum/computer_file/program/ntnet_dos/ui_act(action, params) if(..()) - return 1 + return switch(action) if("PRG_target_relay") for(var/obj/machinery/ntnet_relay/R in SSnetworks.station_network.relays) if("[R.uid]" == params["targid"]) target = R - return 1 + break + return TRUE if("PRG_reset") if(target) target.dos_sources.Remove(src) target = null - executed = 0 + executed = FALSE error = "" - return 1 + return TRUE if("PRG_execute") if(target) - executed = 1 + executed = TRUE target.dos_sources.Add(src) if(SSnetworks.station_network.intrusion_detection_enabled) var/obj/item/computer_hardware/network_card/network_card = computer.all_components[MC_NET] SSnetworks.station_network.add_log("IDS WARNING - Excess traffic flood targeting relay [target.uid] detected from device: [network_card.get_network_tag()]") - SSnetworks.station_network.intrusion_detection_alarm = 1 - return 1 + SSnetworks.station_network.intrusion_detection_alarm = TRUE + return TRUE /datum/computer_file/program/ntnet_dos/ui_data(mob/user) if(!SSnetworks.station_network) return - var/list/data = list() + var/list/data = get_header_data() - data = get_header_data() - - if(error) - data["error"] = error - else if(target && executed) - data["target"] = 1 + data["error"] = error + if(target && executed) + data["target"] = TRUE data["speed"] = dos_speed - // This is mostly visual, generate some strings of 1s and 0s - // Probability of 1 is equal of completion percentage of DoS attack on this relay. - // Combined with UI updates this adds quite nice effect to the UI - var/percentage = target.dos_overload * 100 / target.dos_capacity - data["dos_strings"] = list() - for(var/j, j<10, j++) - var/string = "" - for(var/i, i<20, i++) - string = "[string][prob(percentage)]" - data["dos_strings"] += list(list("nums" = string)) + data["overload"] = target.dos_overload + data["capacity"] = target.dos_capacity else + data["target"] = FALSE data["relays"] = list() for(var/obj/machinery/ntnet_relay/R in SSnetworks.station_network.relays) data["relays"] += list(list("id" = R.uid)) diff --git a/code/modules/modular_computers/file_system/programs/antagonist/revelation.dm b/code/modules/modular_computers/file_system/programs/antagonist/revelation.dm index af2d3f099d9..5b85e5a67bb 100644 --- a/code/modules/modular_computers/file_system/programs/antagonist/revelation.dm +++ b/code/modules/modular_computers/file_system/programs/antagonist/revelation.dm @@ -4,9 +4,9 @@ program_icon_state = "hostile" extended_desc = "This virus can destroy hard drive of system it is executed on. It may be obfuscated to look like another non-malicious program. Once armed, it will destroy the system upon next execution." size = 13 - requires_ntnet = 0 - available_on_ntnet = 0 - available_on_syndinet = 1 + requires_ntnet = FALSE + available_on_ntnet = FALSE + available_on_syndinet = TRUE tgui_id = "ntos_revelation" ui_x = 400 ui_y = 250 @@ -21,7 +21,7 @@ /datum/computer_file/program/revelation/proc/activate() if(computer) computer.visible_message("\The [computer]'s screen brightly flashes and loud electrical buzzing is heard.") - computer.enabled = 0 + computer.enabled = FALSE computer.update_icon() var/obj/item/computer_hardware/hard_drive/hard_drive = computer.all_components[MC_HDD] var/obj/item/computer_hardware/battery/battery_module = computer.all_components[MC_CELL] @@ -43,18 +43,20 @@ /datum/computer_file/program/revelation/ui_act(action, params) if(..()) - return 1 + return switch(action) if("PRG_arm") armed = !armed + return TRUE if("PRG_activate") activate() + return TRUE if("PRG_obfuscate") - var/mob/living/user = usr - var/newname = sanitize(input(user, "Enter new program name: ")) + var/newname = params["new_name"] if(!newname) return filedesc = newname + return TRUE /datum/computer_file/program/revelation/clone() diff --git a/code/modules/modular_computers/file_system/programs/file_browser.dm b/code/modules/modular_computers/file_system/programs/file_browser.dm index fb90ecbfad1..52ba479c049 100644 --- a/code/modules/modular_computers/file_system/programs/file_browser.dm +++ b/code/modules/modular_computers/file_system/programs/file_browser.dm @@ -4,9 +4,9 @@ extended_desc = "This program allows management of files." program_icon_state = "generic" size = 8 - requires_ntnet = 0 - available_on_ntnet = 0 - undeletable = 1 + requires_ntnet = FALSE + available_on_ntnet = FALSE + undeletable = TRUE tgui_id = "ntos_file_manager" var/open_file @@ -14,176 +14,57 @@ /datum/computer_file/program/filemanager/ui_act(action, params) if(..()) - return 1 + return var/obj/item/computer_hardware/hard_drive/HDD = computer.all_components[MC_HDD] var/obj/item/computer_hardware/hard_drive/RHDD = computer.all_components[MC_SDD] - var/obj/item/computer_hardware/printer/printer = computer.all_components[MC_PRINT] switch(action) - if("PRG_openfile") - . = 1 - open_file = params["name"] - if("PRG_newtextfile") - . = 1 - var/newname = stripped_input(usr, "Enter file name or leave blank to cancel:", "File rename", max_length=50) - if(!newname) - return 1 - 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("PRG_deletefile") - . = 1 if(!HDD) - return 1 + return var/datum/computer_file/file = HDD.find_file_by_name(params["name"]) if(!file || file.undeletable) - return 1 + return HDD.remove_file(file) + return TRUE if("PRG_usbdeletefile") - . = 1 if(!RHDD) - return 1 + return var/datum/computer_file/file = RHDD.find_file_by_name(params["name"]) if(!file || file.undeletable) - return 1 - RHDD.remove_file(file) - if("PRG_closefile") - . = 1 - open_file = null - error = null - if("PRG_clone") - . = 1 - if(!HDD) - return 1 - var/datum/computer_file/F = HDD.find_file_by_name(params["name"]) - if(!F || !istype(F)) - return 1 - var/datum/computer_file/C = F.clone(1) - HDD.store_file(C) - if("PRG_rename") - . = 1 - if(!HDD) - return 1 - var/datum/computer_file/file = HDD.find_file_by_name(params["name"]) - if(!file || !istype(file)) - return 1 - var/newname = stripped_input(usr, "Enter new file name:", "File rename", file.filename, max_length=50) - if(file && newname) - file.filename = newname - if("PRG_edit") - . = 1 - if(!open_file) - return 1 - 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 - // 16384 is the limit for file length in characters. Currently, papers have value of 2048 so this is 8 times as long, since we can't edit parts of the file independently. - var/newtext = stripped_multiline_input(usr, "Editing file [open_file]. You may use most tags used in paper formatting:", "Text Editor", html_decode(F.stored_data), 16384, TRUE) - 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:

[F.stored_data]

" - HDD.store_file(backup) - if("PRG_printfile") - . = 1 - if(!open_file) - return 1 + RHDD.remove_file(file) + return TRUE + if("PRG_rename") if(!HDD) - return 1 - var/datum/computer_file/data/F = HDD.find_file_by_name(open_file) - if(!F || !istype(F)) - return 1 - if(!printer) - error = "Missing Hardware: Your computer does not have required hardware to complete this operation." - return 1 - if(!printer.print_text("" + prepare_printjob(F.stored_data) + "", open_file)) - error = "Hardware error: Printer was unable to print the file. It may be out of paper." - return 1 + return + var/datum/computer_file/file = HDD.find_file_by_name(params["name"]) + if(!file) + return + var/newname = params["new_name"] + if(!newname) + return + file.filename = newname + return TRUE if("PRG_copytousb") - . = 1 if(!HDD || !RHDD) - return 1 + return var/datum/computer_file/F = HDD.find_file_by_name(params["name"]) - if(!F || !istype(F)) - return 1 - var/datum/computer_file/C = F.clone(0) + if(!F) + return + var/datum/computer_file/C = F.clone(FALSE) RHDD.store_file(C) + return TRUE if("PRG_copyfromusb") - . = 1 if(!HDD || !RHDD) - return 1 + return var/datum/computer_file/F = RHDD.find_file_by_name(params["name"]) if(!F || !istype(F)) - return 1 - var/datum/computer_file/C = F.clone(0) + return + var/datum/computer_file/C = F.clone(FALSE) HDD.store_file(C) - -/datum/computer_file/program/filemanager/proc/parse_tags(t) - t = replacetext(t, "\[center\]", "
") - t = replacetext(t, "\[/center\]", "
") - t = replacetext(t, "\[br\]", "
") - t = replacetext(t, "\n", "
") - t = replacetext(t, "\[b\]", "") - t = replacetext(t, "\[/b\]", "") - t = replacetext(t, "\[i\]", "") - t = replacetext(t, "\[/i\]", "") - t = replacetext(t, "\[u\]", "") - t = replacetext(t, "\[/u\]", "") - t = replacetext(t, "\[time\]", "[station_time_timestamp()]") - t = replacetext(t, "\[date\]", "[time2text(world.realtime, "MMM DD")] [GLOB.year_integer+540]") - t = replacetext(t, "\[large\]", "") - t = replacetext(t, "\[/large\]", "") - t = replacetext(t, "\[h1\]", "

") - t = replacetext(t, "\[/h1\]", "

") - t = replacetext(t, "\[h2\]", "

") - t = replacetext(t, "\[/h2\]", "

") - t = replacetext(t, "\[h3\]", "

") - t = replacetext(t, "\[/h3\]", "

") - t = replacetext(t, "\[*\]", "
  • ") - t = replacetext(t, "\[hr\]", "
    ") - t = replacetext(t, "\[small\]", "") - t = replacetext(t, "\[/small\]", "") - t = replacetext(t, "\[list\]", "") - t = replacetext(t, "\[table\]", "") - t = replacetext(t, "\[/table\]", "
    ") - t = replacetext(t, "\[grid\]", "") - t = replacetext(t, "\[/grid\]", "
    ") - t = replacetext(t, "\[row\]", "") - t = replacetext(t, "\[tr\]", "") - t = replacetext(t, "\[td\]", "") - t = replacetext(t, "\[cell\]", "") - t = replacetext(t, "\[tab\]", "    ") - - t = parsemarkdown_basic(t) - - return t - -/datum/computer_file/program/filemanager/proc/prepare_printjob(t) // Additional stuff to parse if we want to print it and make a happy Head of Personnel. Forms FTW. - t = replacetext(t, "\[field\]", "") - t = replacetext(t, "\[sign\]", "") - - t = parse_tags(t) - - t = replacetext(t, regex("(?:%s(?:ign)|%f(?:ield))(?=\\s|$)", "ig"), "") - - return t + return TRUE /datum/computer_file/program/filemanager/ui_data(mob/user) var/list/data = get_header_data() @@ -192,41 +73,28 @@ var/obj/item/computer_hardware/hard_drive/portable/RHDD = computer.all_components[MC_SDD] if(error) data["error"] = error - if(open_file) - var/datum/computer_file/data/file - - if(!computer || !HDD) - data["error"] = "I/O ERROR: Unable to access hard drive." - else - file = HDD.find_file_by_name(open_file) - if(!istype(file)) - data["error"] = "I/O ERROR: Unable to open file." - else - data["filedata"] = parse_tags(file.stored_data) - data["filename"] = "[file.filename].[file.filetype]" + if(!computer || !HDD) + data["error"] = "I/O ERROR: Unable to access hard drive." else - if(!computer || !HDD) - data["error"] = "I/O ERROR: Unable to access hard drive." - else - var/list/files[0] - for(var/datum/computer_file/F in HDD.stored_files) - files.Add(list(list( + var/list/files = list() + for(var/datum/computer_file/F in HDD.stored_files) + files += list(list( + "name" = F.filename, + "type" = F.filetype, + "size" = F.size, + "undeletable" = F.undeletable + )) + data["files"] = files + if(RHDD) + data["usbconnected"] = TRUE + var/list/usbfiles = list() + for(var/datum/computer_file/F in RHDD.stored_files) + usbfiles += 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 + )) + data["usbfiles"] = usbfiles return data diff --git a/code/modules/modular_computers/file_system/programs/ntmonitor.dm b/code/modules/modular_computers/file_system/programs/ntmonitor.dm index 226686fc042..1932f671f9b 100644 --- a/code/modules/modular_computers/file_system/programs/ntmonitor.dm +++ b/code/modules/modular_computers/file_system/programs/ntmonitor.dm @@ -4,58 +4,48 @@ program_icon_state = "comm_monitor" extended_desc = "This program monitors stationwide NTNet network, provides access to logging systems, and allows for configuration changes" size = 12 - requires_ntnet = 1 + requires_ntnet = TRUE required_access = ACCESS_NETWORK //NETWORK CONTROL IS A MORE SECURE PROGRAM. - available_on_ntnet = 1 + available_on_ntnet = TRUE tgui_id = "ntos_net_monitor" /datum/computer_file/program/ntnetmonitor/ui_act(action, params) if(..()) - return 1 + return switch(action) if("resetIDS") - . = 1 if(SSnetworks.station_network) SSnetworks.station_network.resetIDS() - return 1 + return TRUE if("toggleIDS") - . = 1 if(SSnetworks.station_network) SSnetworks.station_network.toggleIDS() - return 1 + return TRUE if("toggleWireless") - . = 1 if(!SSnetworks.station_network) - return 1 + return // NTNet is disabled. Enabling can be done without user prompt if(SSnetworks.station_network.setting_disabled) - SSnetworks.station_network.setting_disabled = 0 - return 1 + SSnetworks.station_network.setting_disabled = FALSE + return TRUE - // NTNet is enabled and user is about to shut it down. Let's ask them if they really want to do it, as wirelessly connected computers won't connect without NTNet being enabled (which may prevent people from turning it back on) - var/mob/user = usr - if(!user) - return 1 - var/response = alert(user, "Really disable NTNet wireless? If your computer is connected wirelessly you won't be able to turn it back on! This will affect all connected wireless devices.", "NTNet shutdown", "Yes", "No") - if(response == "Yes") - SSnetworks.station_network.setting_disabled = 1 - return 1 + SSnetworks.station_network.setting_disabled = TRUE + return TRUE if("purgelogs") - . = 1 if(SSnetworks.station_network) SSnetworks.station_network.purge_logs() + return TRUE if("updatemaxlogs") - . = 1 - var/mob/user = usr - var/logcount = text2num(input(user,"Enter amount of logs to keep in memory ([MIN_NTNET_LOGS]-[MAX_NTNET_LOGS]):")) + var/logcount = params["new_number"] if(SSnetworks.station_network) SSnetworks.station_network.update_max_log_count(logcount) + return TRUE if("toggle_function") - . = 1 if(!SSnetworks.station_network) - return 1 + return SSnetworks.station_network.toggle_function(text2num(params["id"])) + return TRUE /datum/computer_file/program/ntnetmonitor/ui_data(mob/user) if(!SSnetworks.station_network) @@ -73,6 +63,8 @@ data["config_systemcontrol"] = SSnetworks.station_network.setting_systemcontrol data["ntnetlogs"] = list() + data["minlogs"] = MIN_NTNET_LOGS + data["maxlogs"] = MAX_NTNET_LOGS for(var/i in SSnetworks.station_network.logs) data["ntnetlogs"] += list(list("entry" = i)) diff --git a/code/modules/modular_computers/file_system/programs/nttransfer.dm b/code/modules/modular_computers/file_system/programs/nttransfer.dm deleted file mode 100644 index eef2eedd531..00000000000 --- a/code/modules/modular_computers/file_system/programs/nttransfer.dm +++ /dev/null @@ -1,183 +0,0 @@ -/datum/computer_file/program/nttransfer - filename = "nttransfer" - filedesc = "P2P Transfer Client" - extended_desc = "This program allows for simple file transfer via direct peer to peer connection." - program_icon_state = "comm_logs" - size = 7 - requires_ntnet = 1 - requires_ntnet_feature = NTNET_PEERTOPEER - network_destination = "other device via P2P tunnel" - available_on_ntnet = 1 - tgui_id = "ntos_net_transfer" - - var/error = "" // Error screen - var/server_password = "" // Optional password to download the file. - var/datum/computer_file/provided_file = null // File which is provided to clients. - var/datum/computer_file/downloaded_file = null // File which is being downloaded - var/list/connected_clients = list() // List of connected clients. - var/datum/computer_file/program/nttransfer/remote // Client var, specifies who are we downloading from. - var/download_completion = 0 // Download progress in GQ - var/download_netspeed = 0 // Our connectivity speed in GQ/s - var/actual_netspeed = 0 // Displayed in the UI, this is the actual transfer speed. - var/unique_token // UID of this program - var/upload_menu = 0 // Whether we show the program list and upload menu - var/static/nttransfer_uid = 0 - -/datum/computer_file/program/nttransfer/New() - unique_token = nttransfer_uid++ - ..() - -/datum/computer_file/program/nttransfer/process_tick() - // Server mode - update_netspeed() - if(provided_file) - for(var/datum/computer_file/program/nttransfer/C in connected_clients) - // Transfer speed is limited by device which uses slower connectivity. - // We can have multiple clients downloading at same time, but let's assume we use some sort of multicast transfer - // so they can all run on same speed. - C.actual_netspeed = min(C.download_netspeed, download_netspeed) - C.download_completion += C.actual_netspeed - if(C.download_completion >= provided_file.size) - C.finish_download() - else if(downloaded_file) // Client mode - if(!remote) - crash_download("Connection to remote server lost") - -/datum/computer_file/program/nttransfer/kill_program(forced = FALSE) - if(downloaded_file) // Client mode, clean up variables for next use - finalize_download() - - if(provided_file) // Server mode, disconnect all clients - for(var/datum/computer_file/program/nttransfer/P in connected_clients) - P.crash_download("Connection terminated by remote server") - downloaded_file = null - ..(forced) - -/datum/computer_file/program/nttransfer/proc/update_netspeed() - download_netspeed = 0 - switch(ntnet_status) - if(1) - download_netspeed = NTNETSPEED_LOWSIGNAL - if(2) - download_netspeed = NTNETSPEED_HIGHSIGNAL - if(3) - download_netspeed = NTNETSPEED_ETHERNET - -// Finishes download and attempts to store the file on HDD -/datum/computer_file/program/nttransfer/proc/finish_download() - var/obj/item/computer_hardware/hard_drive/hard_drive = computer.all_components[MC_HDD] - if(!computer || !hard_drive || !hard_drive.store_file(downloaded_file)) - error = "I/O Error: Unable to save file. Check your hard drive and try again." - finalize_download() - -// Crashes the download and displays specific error message -/datum/computer_file/program/nttransfer/proc/crash_download(var/message) - error = message ? message : "An unknown error has occurred during download" - finalize_download() - -// Cleans up variables for next use -/datum/computer_file/program/nttransfer/proc/finalize_download() - if(remote) - remote.connected_clients.Remove(src) - downloaded_file = null - remote = null - download_completion = 0 - -/datum/computer_file/program/nttransfer/ui_act(action, params) - if(..()) - return 1 - switch(action) - if("PRG_downloadfile") - for(var/datum/computer_file/program/nttransfer/P in SSnetworks.station_network.fileservers) - if("[P.unique_token]" == params["id"]) - remote = P - break - if(!remote || !remote.provided_file) - return - if(remote.server_password) - var/pass = reject_bad_text(input(usr, "Code 401 Unauthorized. Please enter password:", "Password required")) - if(pass != remote.server_password) - error = "Incorrect Password" - return - downloaded_file = remote.provided_file.clone() - remote.connected_clients.Add(src) - return 1 - if("PRG_reset") - error = "" - upload_menu = 0 - finalize_download() - if(src in SSnetworks.station_network.fileservers) - SSnetworks.station_network.fileservers.Remove(src) - for(var/datum/computer_file/program/nttransfer/T in connected_clients) - T.crash_download("Remote server has forcibly closed the connection") - provided_file = null - return 1 - if("PRG_setpassword") - var/pass = reject_bad_text(input(usr, "Enter new server password. Leave blank to cancel, input 'none' to disable password.", "Server security", "none")) - if(!pass) - return - if(pass == "none") - server_password = "" - return - server_password = pass - return 1 - if("PRG_uploadfile") - var/obj/item/computer_hardware/hard_drive/hard_drive = computer.all_components[MC_HDD] - for(var/datum/computer_file/F in hard_drive.stored_files) - if("[F.uid]" == params["id"]) - if(F.unsendable) - error = "I/O Error: File locked." - return - if(istype(F, /datum/computer_file/program)) - var/datum/computer_file/program/P = F - if(!P.can_run(usr,transfer = 1)) - error = "Access Error: Insufficient rights to upload file." - provided_file = F - SSnetworks.station_network.fileservers.Add(src) - return - error = "I/O Error: Unable to locate file on hard drive." - return 1 - if("PRG_uploadmenu") - upload_menu = 1 - - -/datum/computer_file/program/nttransfer/ui_data(mob/user) - - var/list/data = get_header_data() - - if(error) - data["error"] = error - else if(downloaded_file) - data["downloading"] = 1 - data["download_size"] = downloaded_file.size - data["download_progress"] = download_completion - data["download_netspeed"] = actual_netspeed - data["download_name"] = "[downloaded_file.filename].[downloaded_file.filetype]" - else if (provided_file) - data["uploading"] = 1 - data["upload_uid"] = unique_token - data["upload_clients"] = connected_clients.len - data["upload_haspassword"] = server_password ? 1 : 0 - data["upload_filename"] = "[provided_file.filename].[provided_file.filetype]" - else if (upload_menu) - var/list/all_files[0] - var/obj/item/computer_hardware/hard_drive/hard_drive = computer.all_components[MC_HDD] - for(var/datum/computer_file/F in hard_drive.stored_files) - all_files.Add(list(list( - "uid" = F.uid, - "filename" = "[F.filename].[F.filetype]", - "size" = F.size - ))) - data["upload_filelist"] = all_files - else - var/list/all_servers[0] - for(var/datum/computer_file/program/nttransfer/P in SSnetworks.station_network.fileservers) - all_servers.Add(list(list( - "uid" = P.unique_token, - "filename" = "[P.provided_file.filename].[P.provided_file.filetype]", - "size" = P.provided_file.size, - "haspassword" = P.server_password ? 1 : 0 - ))) - data["servers"] = all_servers - - return data diff --git a/tgstation.dme b/tgstation.dme index 069d4d6bee7..9da559403c9 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -2372,7 +2372,6 @@ #include "code\modules\modular_computers\file_system\programs\ntdownloader.dm" #include "code\modules\modular_computers\file_system\programs\ntmonitor.dm" #include "code\modules\modular_computers\file_system\programs\ntnrc_client.dm" -#include "code\modules\modular_computers\file_system\programs\nttransfer.dm" #include "code\modules\modular_computers\file_system\programs\powermonitor.dm" #include "code\modules\modular_computers\file_system\programs\sm_monitor.dm" #include "code\modules\modular_computers\file_system\programs\antagonist\contract_uplink.dm" diff --git a/tgui-next/packages/tgui/components/Button.js b/tgui-next/packages/tgui/components/Button.js index 5ed0c8648bc..e4ff945d1a3 100644 --- a/tgui-next/packages/tgui/components/Button.js +++ b/tgui-next/packages/tgui/components/Button.js @@ -138,8 +138,10 @@ export class ButtonConfirm extends Component { render() { const { - confirmMessage = "Confirm?", + confirmContent = "Confirm?", confirmColor = "bad", + confirmIcon, + icon, color, content, onClick, @@ -147,7 +149,8 @@ export class ButtonConfirm extends Component { } = this.props; return (