[MIRROR] Misc PDA code improvements [MDB IGNORE] (#17026)

* Misc PDA code improvements (#70555)

* How to conflict with PRs: A guide

* Removes unnecessary support for the now-removed job disks from Tablet's TGUI menu, and tablet's ui_act.
* Adds autodoc comments to computer files
* Removes the unused 'unsendable' var on computer files
* Generally improves code on tablets, now process isn't looping through every idle thread twice!
* Moves the check for program in idle_threads above checking if supported by hardware, because it's already running, so there's no need to check.

* eh

* revert a scipaper change

* Misc PDA code improvements

* updated contract_uplink

Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
Co-authored-by: Tastyfish <crazychris32@gmail.com>
This commit is contained in:
SkyratBot
2022-10-20 15:22:45 -04:00
committed by GitHub
co-authored by John Willard Tastyfish
parent eff29609cd
commit c023767b25
11 changed files with 58 additions and 130 deletions
@@ -177,7 +177,7 @@ GLOBAL_LIST_EMPTY(TabletMessengers) // a list of all active messengers, similar
if(!istype(src, /obj/item/modular_computer/tablet))
return FALSE
// Gets IDs/access levels from card slot. Would be useful when/if PDAs would become modular PCs.
// Gets IDs/access levels from card slot. Would be useful when/if PDAs would become modular PCs. //guess what
/obj/item/modular_computer/GetAccess()
var/obj/item/computer_hardware/card_slot/card_slot = all_components[MC_CARD]
if(card_slot)
@@ -423,7 +423,7 @@ GLOBAL_LIST_EMPTY(TabletMessengers) // a list of all active messengers, similar
to_chat(user, span_notice("You press the power button and start up \the [src]."))
if(looping_sound)
soundloop.start()
enabled = 1
enabled = TRUE
update_appearance()
if(open_ui)
ui_interact(user)
@@ -446,26 +446,23 @@ GLOBAL_LIST_EMPTY(TabletMessengers) // a list of all active messengers, similar
return
if(active_program && active_program.requires_ntnet && !get_ntnet_status(active_program.requires_ntnet_feature))
active_program.event_networkfailure(0) // Active program requires NTNet to run but we've just lost connection. Crash.
active_program.event_networkfailure(FALSE) // Active program requires NTNet to run but we've just lost connection. Crash.
for(var/I in idle_threads)
var/datum/computer_file/program/P = I
if(P.requires_ntnet && !get_ntnet_status(P.requires_ntnet_feature))
P.event_networkfailure(1)
for(var/datum/computer_file/program/idle_programs as anything in idle_threads)
if(idle_programs.program_state == PROGRAM_STATE_KILLED)
idle_threads.Remove(idle_programs)
continue
idle_programs.process_tick(delta_time)
idle_programs.ntnet_status = get_ntnet_status(idle_programs.requires_ntnet_feature)
if(idle_programs.requires_ntnet && !idle_programs.ntnet_status)
idle_programs.event_networkfailure(TRUE)
if(active_program)
if(active_program.program_state != PROGRAM_STATE_KILLED)
if(active_program.program_state == PROGRAM_STATE_KILLED)
active_program = null
else
active_program.process_tick(delta_time)
active_program.ntnet_status = get_ntnet_status()
else
active_program = null
for(var/datum/computer_file/program/P as anything in idle_threads)
if(P.program_state != PROGRAM_STATE_KILLED)
P.process_tick(delta_time)
P.ntnet_status = get_ntnet_status()
else
idle_threads.Remove(P)
handle_power(delta_time) // Handles all computer power interaction
//check_update_ui_need()
@@ -506,6 +503,7 @@ GLOBAL_LIST_EMPTY(TabletMessengers) // a list of all active messengers, similar
var/obj/item/computer_hardware/battery/battery_module = all_components[MC_CELL]
data["PC_showbatteryicon"] = !!battery_module
if(battery_module && battery_module.battery)
switch(battery_module.battery.percent())
if(80 to 200) // 100 should be maximal but just in case..
@@ -521,11 +519,9 @@ GLOBAL_LIST_EMPTY(TabletMessengers) // a list of all active messengers, similar
else
data["PC_batteryicon"] = "batt_5.gif"
data["PC_batterypercent"] = "[round(battery_module.battery.percent())]%"
data["PC_showbatteryicon"] = 1
else
data["PC_batteryicon"] = "batt_5.gif"
data["PC_batterypercent"] = "N/C"
data["PC_showbatteryicon"] = battery_module ? 1 : 0
switch(get_ntnet_status())
if(NTNET_NO_SIGNAL)
@@ -539,19 +535,15 @@ GLOBAL_LIST_EMPTY(TabletMessengers) // a list of all active messengers, similar
if(length(idle_threads))
var/list/program_headers = list()
for(var/I in idle_threads)
var/datum/computer_file/program/P = I
if(!P.ui_header)
for(var/datum/computer_file/program/idle_programs as anything in idle_threads)
if(!idle_programs.ui_header)
continue
program_headers.Add(list(list(
"icon" = P.ui_header
)))
program_headers.Add(list(list("icon" = idle_programs.ui_header)))
data["PC_programheaders"] = program_headers
data["PC_stationtime"] = station_time_timestamp()
data["PC_hasheader"] = 1
data["PC_showexitprogram"] = active_program ? 1 : 0 // Hides "Exit Program" button on mainscreen
data["PC_showexitprogram"] = !!active_program // Hides "Exit Program" button on mainscreen
return data
///Wipes the computer's current program. Doesn't handle any of the niceties around doing this
@@ -578,9 +570,6 @@ GLOBAL_LIST_EMPTY(TabletMessengers) // a list of all active messengers, similar
to_chat(user, span_danger("\The [src]'s screen shows \"I/O ERROR - Unable to run program\" warning."))
return FALSE
if(!program.is_supported_by_hardware(hardware_flag, 1, user))
return FALSE
// The program is already running. Resume it.
if(program in idle_threads)
program.program_state = PROGRAM_STATE_ACTIVE
@@ -591,6 +580,9 @@ GLOBAL_LIST_EMPTY(TabletMessengers) // a list of all active messengers, similar
updateUsrDialog()
return TRUE
if(!program.is_supported_by_hardware(hardware_flag, 1, user))
return FALSE
if(idle_threads.len > max_idle_programs)
to_chat(user, span_danger("\The [src] displays a \"Maximal CPU load reached. Unable to run another program.\" error."))
return FALSE
@@ -613,7 +605,6 @@ GLOBAL_LIST_EMPTY(TabletMessengers) // a list of all active messengers, similar
if(!SSnetworks.station_network || !SSnetworks.station_network.check_function(specific_action)) // NTNet is down and we are not connected via wired connection. No signal.
return NTNET_NO_SIGNAL
// computers are connected through ethernet
if(hardware_flag & PROGRAM_CONSOLE)
return NTNET_ETHERNET_SIGNAL
@@ -64,14 +64,10 @@
data["device_theme"] = device_theme
data["login"] = list()
data["disk"] = null
var/obj/item/computer_hardware/card_slot/cardholder = all_components[MC_CARD]
data["cardholder"] = FALSE
data["cardholder"] = !!cardholder
if(cardholder)
data["cardholder"] = TRUE
var/stored_name = saved_identification
var/stored_title = saved_job
if(!stored_name)
@@ -105,7 +101,13 @@
if(P in idle_threads)
running = TRUE
data["programs"] += list(list("name" = P.filename, "desc" = P.filedesc, "running" = running, "icon" = P.program_icon, "alert" = P.alert_pending))
data["programs"] += list(list(
"name" = P.filename,
"desc" = P.filedesc,
"running" = running,
"icon" = P.program_icon,
"alert" = P.alert_pending,
))
data["has_light"] = has_light
data["light_on"] = light_on
@@ -155,10 +157,6 @@
to_chat(user, span_notice("Program [P.filename].[P.filetype] with PID [rand(100,999)] has been killed."))
if("PC_runprogram")
// only function of the last implementation (?)
if(params["is_disk"])
return
open_program(usr, hard_drive.find_file_by_name(params["name"]))
if("PC_toggle_light")
@@ -1,13 +1,20 @@
/datum/computer_file
var/filename = "NewFile" // Placeholder. No spacebars
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/obj/item/modular_computer/computer
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
///The name of the internal file shown in file management.
var/filename = "NewFile"
///The type of file format the file is in, placed after filename. PNG, TXT, ect. This would be NewFile.XXX
var/filetype = "XXX"
///How much GQ storage space the file will take to store. Integers only!
var/size = 1
///Whether the file may be deleted. Setting to TRUE prevents deletion/renaming/etc.
var/undeletable = FALSE
///The computer file's personal ID
var/uid
///Static ID to ensure all IDs are unique.
var/static/file_uid = 0
///The hard drive that has this computer file stored.
var/obj/item/computer_hardware/hard_drive/holder
///The modular computer hosting the file.
var/obj/item/modular_computer/computer
/datum/computer_file/New()
..()
@@ -28,7 +35,6 @@
// Returns independent copy of this file.
/datum/computer_file/proc/clone(rename = FALSE)
var/datum/computer_file/temp = new type
temp.unsendable = unsendable
temp.undeletable = undeletable
temp.size = size
if(rename)
@@ -203,8 +203,8 @@
var/obj/item/computer_hardware/card_slot/card_holder = computer.all_components[MC_CARD]
if(card_holder)
ID = card_holder.GetID()
generate_network_log("Connection closed -- Program ID: [filename] User:[ID?"[ID.registered_name]":"None"]")
return 1
generate_network_log("Connection closed -- Program ID: [filename] User:[ID ? "[ID.registered_name]" : "None"]")
return TRUE
/datum/computer_file/program/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
@@ -248,7 +248,6 @@
if(user && istype(user))
computer.ui_interact(user) // Re-open the UI on this computer. It should show the main screen now.
/datum/computer_file/program/ui_host()
if(computer.physical)
return computer.physical
@@ -7,11 +7,10 @@
filedesc = "Hardware Configuration Tool"
extended_desc = "This program allows configuration of computer's hardware"
program_icon_state = "generic"
unsendable = 1
undeletable = 1
undeletable = TRUE
size = 4
available_on_ntnet = 0
requires_ntnet = 0
available_on_ntnet = FALSE
requires_ntnet = FALSE
tgui_id = "NtosConfiguration"
program_icon = "cog"
@@ -3,7 +3,6 @@
filedesc = "NT Software Hub"
program_icon_state = "generic"
extended_desc = "This program allows downloads of software from official NT repositories"
unsendable = TRUE
undeletable = TRUE
size = 4
requires_ntnet = TRUE
@@ -7,7 +7,6 @@
program_icon_state = "command"
requires_ntnet = FALSE
available_on_ntnet = FALSE
unsendable = TRUE
undeletable = TRUE
usage_flags = PROGRAM_TABLET
size = 5