PDAs open their messenger when replying to messages through chat (#68355)

* Clicking Reply in PDA messages now opens your PDA messenger app.

* Additionally does a ton of PDA code improvement.
This commit is contained in:
distributivgesetz
2022-07-18 05:53:33 +02:00
committed by GitHub
parent a8b911a549
commit 9c0ac84ba6
18 changed files with 132 additions and 120 deletions

View File

@@ -345,7 +345,7 @@ GLOBAL_LIST_EMPTY(TabletMessengers) // a list of all active messengers, similar
user.put_in_hands(ssd)
playsound(src, 'sound/machines/card_slide.ogg', 50)
/obj/item/modular_computer/proc/turn_on(mob/user)
/obj/item/modular_computer/proc/turn_on(mob/user, open_ui = TRUE)
var/issynth = issilicon(user) // Robots and AIs get different activation messages.
if(atom_integrity <= integrity_failure * max_integrity)
if(issynth)
@@ -368,6 +368,7 @@ GLOBAL_LIST_EMPTY(TabletMessengers) // a list of all active messengers, similar
soundloop.start()
enabled = 1
update_appearance()
if(open_ui)
ui_interact(user)
return TRUE
else // Unpowered
@@ -521,6 +522,44 @@ GLOBAL_LIST_EMPTY(TabletMessengers) // a list of all active messengers, similar
INVOKE_ASYNC(src, /datum/proc/ui_interact, user) // Re-open the UI on this computer. It should show the main screen now.
update_appearance()
/obj/item/modular_computer/proc/open_program(mob/user, datum/computer_file/program/program)
if(program.computer != src)
CRASH("tried to open program that does not belong to this computer")
if(!program || !istype(program)) // Program not found or it's not executable program.
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
active_program = program
program.alert_pending = FALSE
idle_threads.Remove(program)
update_appearance()
updateUsrDialog()
return TRUE
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
if(program.requires_ntnet && !get_ntnet_status(program.requires_ntnet_feature)) // The program requires NTNet connection, but we are not connected to NTNet.
to_chat(user, span_danger("\The [src]'s screen shows \"Unable to connect to NTNet. Please retry. If problem persists contact your system administrator.\" warning."))
return FALSE
if(!program.on_start(user))
return FALSE
active_program = program
program.alert_pending = FALSE
update_appearance()
updateUsrDialog()
return TRUE
// Returns 0 for No Signal, 1 for Low Signal and 2 for Good Signal. 3 is for wired connection (always-on)
/obj/item/modular_computer/proc/get_ntnet_status(specific_action = 0)
var/obj/item/computer_hardware/network_card/network_card = all_components[MC_NET]

View File

@@ -156,44 +156,11 @@
to_chat(user, span_notice("Program [P.filename].[P.filetype] with PID [rand(100,999)] has been killed."))
if("PC_runprogram")
var/prog = params["name"]
var/is_disk = params["is_disk"]
var/datum/computer_file/program/P = null
var/mob/user = usr
if(hard_drive && !is_disk)
P = hard_drive.find_file_by_name(prog)
if(!P || !istype(P)) // Program not found or it's not executable program.
to_chat(user, span_danger("\The [src]'s screen shows \"I/O ERROR - Unable to run program\" warning."))
// only function of the last implementation (?)
if(params["is_disk"])
return
P.computer = src
if(!P.is_supported_by_hardware(hardware_flag, 1, user))
return
// The program is already running. Resume it.
if(P in idle_threads)
P.program_state = PROGRAM_STATE_ACTIVE
active_program = P
P.alert_pending = FALSE
idle_threads.Remove(P)
update_appearance()
return
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
if(P.requires_ntnet && !get_ntnet_status(P.requires_ntnet_feature)) // The program requires NTNet connection, but we are not connected to NTNet.
to_chat(user, span_danger("\The [src]'s screen shows \"Unable to connect to NTNet. Please retry. If problem persists contact your system administrator.\" warning."))
return
if(P.run_program(user))
active_program = P
P.alert_pending = FALSE
update_appearance()
return 1
open_program(usr, hard_drive.find_file_by_name(params["name"]))
if("PC_toggle_light")
return toggle_flashlight()

View File

@@ -199,7 +199,7 @@
borgo = null
return ..()
/obj/item/modular_computer/tablet/integrated/turn_on(mob/user)
/obj/item/modular_computer/tablet/integrated/turn_on(mob/user, open_ui = FALSE)
if(borgo?.stat != DEAD)
return ..()
return FALSE

View File

@@ -3,6 +3,7 @@
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
@@ -18,9 +19,10 @@
holder.remove_file(src)
// holder.holder is the computer that has drive installed. If we are Destroy()ing program that's currently running kill it.
if(holder.holder && holder.holder.active_program == src)
holder.holder.kill_program(forced = TRUE)
if(computer && computer.active_program == src)
computer.kill_program(forced = TRUE)
holder = null
computer = null
return ..()
// Returns independent copy of this file.

View File

@@ -9,8 +9,6 @@
var/list/transfer_access = list()
/// PROGRAM_STATE_KILLED or PROGRAM_STATE_BACKGROUND or PROGRAM_STATE_ACTIVE - specifies whether this program is running.
var/program_state = PROGRAM_STATE_KILLED
/// Device that runs this program.
var/obj/item/modular_computer/computer
/// User-friendly name of this program.
var/filedesc = "Unknown Program"
/// Short description of this program's function.
@@ -46,15 +44,6 @@
/// How well this program will help combat detomatix viruses.
var/detomatix_resistance = NONE
/datum/computer_file/program/New(obj/item/modular_computer/comp = null)
..()
if(comp && istype(comp))
computer = comp
/datum/computer_file/program/Destroy()
computer = null
. = ..()
/datum/computer_file/program/clone()
var/datum/computer_file/program/temp = ..()
temp.required_access = required_access
@@ -108,7 +97,7 @@
return TRUE
/**
*Check if the user can run program. Only humans and silicons can operate computer. Automatically called in run_program()
*Check if the user can run program. Only humans and silicons can operate computer. Automatically called in on_start()
*ID must be inserted into a card slot to be read. If the program is not currently installed (as is the case when
*NT Software Hub is checking available software), a list can be given to be used instead.
*Arguments:
@@ -167,7 +156,7 @@
// This is performed on program startup. May be overridden to add extra logic. Remember to include ..() call. Return 1 on success, 0 on failure.
// When implementing new program based device, use this to run the program.
/datum/computer_file/program/proc/run_program(mob/living/user)
/datum/computer_file/program/proc/on_start(mob/living/user)
if(can_run(user, 1))
if(requires_ntnet)
var/obj/item/card/id/ID

View File

@@ -51,7 +51,7 @@
if(length(alert_control.listener.alarms))
has_alert = TRUE
/datum/computer_file/program/alarm_monitor/run_program(mob/user)
/datum/computer_file/program/alarm_monitor/on_start(mob/user)
. = ..(user)
GLOB.alarmdisplay += src

View File

@@ -12,7 +12,7 @@
program_icon = "magnet"
var/armed = 0
/datum/computer_file/program/revelation/run_program(mob/living/user)
/datum/computer_file/program/revelation/on_start(mob/living/user)
. = ..(user)
if(armed)
activate()

View File

@@ -29,7 +29,7 @@
PROGRAM_CATEGORY_MISC,
)
/datum/computer_file/program/ntnetdownload/run_program()
/datum/computer_file/program/ntnetdownload/on_start()
. = ..()
main_repo = SSnetworks.station_network.available_station_software
antag_repo = SSnetworks.station_network.available_antag_software
@@ -203,7 +203,7 @@
tgui_id = "NtosNetDownloader"
emagged = TRUE
/datum/computer_file/program/ntnetdownload/syndicate/run_program()
/datum/computer_file/program/ntnetdownload/syndicate/on_start()
. = ..()
main_repo = SSnetworks.station_network.available_antag_software
antag_repo = null

View File

@@ -358,10 +358,18 @@
if (ringer_status)
computer.ring(ringtone)
/// topic call that answers to people pressing "(Reply)" in chat
/datum/computer_file/program/messenger/Topic(href, href_list)
..()
if(QDELETED(src))
return
// send an activation message, open the messenger, kill whoever reads this nesting mess
if(!computer.enabled)
if(!computer.turn_on(usr, open_ui = FALSE))
return
if(computer.active_program != src)
if(!computer.open_program(usr, src))
return
if(!href_list["close"] && usr.canUseTopic(computer, BE_CLOSE, FALSE, NO_TK))
switch(href_list["choice"])
if("Message")

View File

@@ -187,7 +187,7 @@
else
ui_header = "ntnrc_idle.gif"
/datum/computer_file/program/chatclient/run_program(mob/living/user)
/datum/computer_file/program/chatclient/on_start(mob/living/user)
. = ..()
if(!.)
return

View File

@@ -24,7 +24,7 @@
var/next_record = 0
/datum/computer_file/program/power_monitor/run_program(mob/living/user)
/datum/computer_file/program/power_monitor/on_start(mob/living/user)
. = ..(user)
search()
history["supply"] = list()

View File

@@ -22,7 +22,7 @@
///Used by the tgui interface, themed for NT or Syndicate colors.
var/pointercolor = "green"
/datum/computer_file/program/radar/run_program(mob/living/user)
/datum/computer_file/program/radar/on_start(mob/living/user)
. = ..()
if(.)
START_PROCESSING(SSfastprocess, src)
@@ -310,7 +310,7 @@
arrowstyle = "ntosradarpointerS.png"
pointercolor = "red"
/datum/computer_file/program/radar/fission360/run_program(mob/living/user)
/datum/computer_file/program/radar/fission360/on_start(mob/living/user)
. = ..()
if(!.)
return

View File

@@ -14,7 +14,7 @@
tgui_id = "NtosRobotact"
program_icon = "terminal"
/datum/computer_file/program/robotact/run_program(mob/living/user)
/datum/computer_file/program/robotact/on_start(mob/living/user)
if(!istype(computer, /obj/item/modular_computer/tablet/integrated))
to_chat(user, span_warning("A warning flashes across \the [computer]: Device Incompatible."))
return FALSE

View File

@@ -30,7 +30,7 @@
if(istype(computer))
computer.update_appearance()
/datum/computer_file/program/supermatter_monitor/run_program(mob/living/user)
/datum/computer_file/program/supermatter_monitor/on_start(mob/living/user)
. = ..(user)
if(!(active in GLOB.machines))
active = null

View File

@@ -21,7 +21,7 @@
/// Sequence var for the id cache
var/id_cache_seq = 1
/datum/computer_file/program/science/run_program(mob/living/user)
/datum/computer_file/program/science/on_start(mob/living/user)
. = ..()
stored_research = SSresearch.science_tech

View File

@@ -11,15 +11,32 @@
var/list/stored_files = list() // List of stored files on this drive. DO NOT MODIFY DIRECTLY!
var/default_installs = TRUE // install the default progs
/obj/item/computer_hardware/hard_drive/Initialize(mapload)
. = ..()
if(default_installs)
install_default_programs()
/obj/item/computer_hardware/hard_drive/Destroy()
QDEL_LIST(stored_files)
return ..()
/obj/item/computer_hardware/hard_drive/on_install(obj/item/modular_computer/install_into, mob/living/user)
. = ..()
// whoever tried to set the ref to the computer in new, is it okay if i could come to your house someday, yeah?
for(var/datum/computer_file/file as anything in stored_files)
file.computer = holder
/obj/item/computer_hardware/hard_drive/on_remove(obj/item/modular_computer/remove_from, mob/user)
remove_from.shutdown_computer()
for(var/datum/computer_file/program/program in stored_files)
for(var/datum/computer_file/program in stored_files)
program.computer = null
return ..()
/obj/item/computer_hardware/hard_drive/proc/install_default_programs()
store_file(new /datum/computer_file/program/computerconfig(src)) // Computer configuration utility, allows hardware control and displays more info than status bar
store_file(new /datum/computer_file/program/ntnetdownload(src)) // NTNet Downloader Utility, allows users to download more software from NTNet repository
store_file(new /datum/computer_file/program/filemanager(src)) // File manager, allows text editor functions and basic file manipulation.
store_file(new /datum/computer_file/program/computerconfig) // Computer configuration utility, allows hardware control and displays more info than status bar
store_file(new /datum/computer_file/program/ntnetdownload) // NTNet Downloader Utility, allows users to download more software from NTNet repository
store_file(new /datum/computer_file/program/filemanager) // File manager, allows text editor functions and basic file manipulation.
/obj/item/computer_hardware/hard_drive/examine(user)
. = ..()
@@ -52,6 +69,7 @@
SEND_SIGNAL(F, COMSIG_MODULAR_COMPUTER_FILE_ADDING)
F.holder = src
F.computer = holder
stored_files.Add(F)
recalculate_size()
@@ -120,22 +138,11 @@
if(!stored_files)
return null
for(var/datum/computer_file/F in stored_files)
for(var/datum/computer_file/F as anything in stored_files)
if(F.filename == filename)
return F
return null
/obj/item/computer_hardware/hard_drive/Destroy()
QDEL_LIST(stored_files)
return ..()
/obj/item/computer_hardware/hard_drive/Initialize(mapload)
. = ..()
if(default_installs)
install_default_programs()
/obj/item/computer_hardware/hard_drive/advanced
name = "advanced hard disk drive"
desc = "A hybrid HDD, for use in higher grade computers where balance between power efficiency and capacity is desired."
@@ -173,19 +180,19 @@
/obj/item/computer_hardware/hard_drive/small/install_default_programs()
. = ..()
store_file(new /datum/computer_file/program/messenger(src))
store_file(new /datum/computer_file/program/notepad(src))
store_file(new /datum/computer_file/program/messenger)
store_file(new /datum/computer_file/program/notepad)
// For borg integrated tablets. No downloader.
/obj/item/computer_hardware/hard_drive/small/ai/install_default_programs()
var/datum/computer_file/program/messenger/messenger = new(src)
var/datum/computer_file/program/messenger/messenger = new
messenger.is_silicon = TRUE
store_file(messenger)
/obj/item/computer_hardware/hard_drive/small/robot/install_default_programs()
store_file(new /datum/computer_file/program/computerconfig(src)) // Computer configuration utility, allows hardware control and displays more info than status bar
store_file(new /datum/computer_file/program/filemanager(src)) // File manager, allows text editor functions and basic file manipulation.
store_file(new /datum/computer_file/program/robotact(src))
store_file(new /datum/computer_file/program/computerconfig) // Computer configuration utility, allows hardware control and displays more info than status bar
store_file(new /datum/computer_file/program/filemanager) // File manager, allows text editor functions and basic file manipulation.
store_file(new /datum/computer_file/program/robotact)
// Syndicate variant - very slight better
/obj/item/computer_hardware/hard_drive/portable/syndicate
@@ -200,10 +207,10 @@
max_capacity = 70
/obj/item/computer_hardware/hard_drive/small/nukeops/install_default_programs()
store_file(new/datum/computer_file/program/computerconfig(src))
store_file(new/datum/computer_file/program/ntnetdownload/syndicate(src)) // Syndicate version; automatic access to syndicate apps and no NT apps
store_file(new/datum/computer_file/program/filemanager(src))
store_file(new/datum/computer_file/program/radar/fission360(src)) //I am legitimately afraid if I don't do this, Ops players will think they just don't get a pinpointer anymore.
store_file(new/datum/computer_file/program/computerconfig)
store_file(new/datum/computer_file/program/ntnetdownload/syndicate) // Syndicate version; automatic access to syndicate apps and no NT apps
store_file(new/datum/computer_file/program/filemanager)
store_file(new/datum/computer_file/program/radar/fission360) //I am legitimately afraid if I don't do this, Ops players will think they just don't get a pinpointer anymore.
/obj/item/computer_hardware/hard_drive/micro
name = "micro solid state drive"

View File

@@ -7,9 +7,9 @@
/obj/item/computer_hardware/hard_drive/portable/command/install_default_programs()
. = ..()
store_file(new /datum/computer_file/program/crew_manifest(src))
store_file(new /datum/computer_file/program/science(src))
store_file(new /datum/computer_file/program/status(src))
store_file(new /datum/computer_file/program/crew_manifest)
store_file(new /datum/computer_file/program/science)
store_file(new /datum/computer_file/program/status)
/obj/item/computer_hardware/hard_drive/portable/command/captain
name = "captain data disk"
@@ -18,9 +18,9 @@
/obj/item/computer_hardware/hard_drive/portable/command/captain/install_default_programs()
. = ..()
store_file(new /datum/computer_file/program/records/security(src))
store_file(new /datum/computer_file/program/records/medical(src))
store_file(new /datum/computer_file/program/phys_scanner/all(src))
store_file(new /datum/computer_file/program/records/security)
store_file(new /datum/computer_file/program/records/medical)
store_file(new /datum/computer_file/program/phys_scanner/all)
/obj/item/computer_hardware/hard_drive/portable/command/cmo
name = "chief medical officer data disk"
@@ -28,8 +28,8 @@
/obj/item/computer_hardware/hard_drive/portable/command/cmo/install_default_programs()
. = ..()
store_file(new /datum/computer_file/program/phys_scanner/all(src))
store_file(new /datum/computer_file/program/records/medical(src))
store_file(new /datum/computer_file/program/phys_scanner/all)
store_file(new /datum/computer_file/program/records/medical)
/obj/item/computer_hardware/hard_drive/portable/command/rd
name = "research director data disk"
@@ -37,8 +37,8 @@
/obj/item/computer_hardware/hard_drive/portable/command/rd/install_default_programs()
. = ..()
store_file(new /datum/computer_file/program/signal_commander(src))
store_file(new /datum/computer_file/program/phys_scanner/chemistry(src))
store_file(new /datum/computer_file/program/signal_commander)
store_file(new /datum/computer_file/program/phys_scanner/chemistry)
/obj/item/computer_hardware/hard_drive/portable/command/hos
name = "head of security data disk"
@@ -47,7 +47,7 @@
/obj/item/computer_hardware/hard_drive/portable/command/hos/install_default_programs()
. = ..()
store_file(new /datum/computer_file/program/records/security(src))
store_file(new /datum/computer_file/program/records/security)
/obj/item/computer_hardware/hard_drive/portable/command/hop
name = "head of personnel data disk"
@@ -55,8 +55,8 @@
/obj/item/computer_hardware/hard_drive/portable/command/hop/install_default_programs()
. = ..()
store_file(new /datum/computer_file/program/records/security(src))
store_file(new /datum/computer_file/program/job_management(src))
store_file(new /datum/computer_file/program/records/security)
store_file(new /datum/computer_file/program/job_management)
/obj/item/computer_hardware/hard_drive/portable/command/ce
name = "chief engineer data disk"
@@ -64,9 +64,9 @@
/obj/item/computer_hardware/hard_drive/portable/command/ce/install_default_programs()
. = ..()
store_file(new /datum/computer_file/program/supermatter_monitor(src))
store_file(new /datum/computer_file/program/atmosscan(src))
store_file(new /datum/computer_file/program/alarm_monitor(src))
store_file(new /datum/computer_file/program/supermatter_monitor)
store_file(new /datum/computer_file/program/atmosscan)
store_file(new /datum/computer_file/program/alarm_monitor)
/**
* Security
@@ -78,8 +78,8 @@
/obj/item/computer_hardware/hard_drive/portable/security/install_default_programs()
. = ..()
store_file(new /datum/computer_file/program/records/security(src))
store_file(new /datum/computer_file/program/crew_manifest(src))
store_file(new /datum/computer_file/program/records/security)
store_file(new /datum/computer_file/program/crew_manifest)
/**
* Medical
@@ -91,8 +91,8 @@
/obj/item/computer_hardware/hard_drive/portable/medical/install_default_programs()
. = ..()
store_file(new /datum/computer_file/program/phys_scanner/medical(src))
store_file(new /datum/computer_file/program/records/medical(src))
store_file(new /datum/computer_file/program/phys_scanner/medical)
store_file(new /datum/computer_file/program/records/medical)
/obj/item/computer_hardware/hard_drive/portable/chemistry
name = "chemistry data disk"
@@ -101,7 +101,7 @@
/obj/item/computer_hardware/hard_drive/portable/chemistry/install_default_programs()
. = ..()
store_file(new /datum/computer_file/program/phys_scanner/chemistry(src))
store_file(new /datum/computer_file/program/phys_scanner/chemistry)
/**
* Supply
@@ -113,8 +113,8 @@
/obj/item/computer_hardware/hard_drive/portable/quartermaster/install_default_programs()
. = ..()
store_file(new /datum/computer_file/program/shipping(src))
store_file(new /datum/computer_file/program/budgetorders(src))
store_file(new /datum/computer_file/program/shipping)
store_file(new /datum/computer_file/program/budgetorders)
/**
* Science
@@ -126,7 +126,7 @@
/obj/item/computer_hardware/hard_drive/portable/ordnance/install_default_programs()
. = ..()
store_file(new /datum/computer_file/program/signal_commander(src))
store_file(new /datum/computer_file/program/signal_commander)
/obj/item/computer_hardware/hard_drive/portable/scipaper_program
name = "NT Frontier data disk"
@@ -135,7 +135,7 @@
/obj/item/computer_hardware/hard_drive/portable/scipaper_program/install_default_programs()
. = ..()
store_file(new /datum/computer_file/program/scipaper_program(src))
store_file(new /datum/computer_file/program/scipaper_program)
/**
* Engineering
@@ -147,7 +147,7 @@
/obj/item/computer_hardware/hard_drive/portable/engineering/install_default_programs()
. = ..()
store_file(new /datum/computer_file/program/supermatter_monitor(src))
store_file(new /datum/computer_file/program/supermatter_monitor)
/obj/item/computer_hardware/hard_drive/portable/atmos
name = "atmospheric technician data disk"
@@ -157,5 +157,5 @@
/obj/item/computer_hardware/hard_drive/portable/atmos/install_default_programs()
. = ..()
store_file(new /datum/computer_file/program/atmosscan(src))
store_file(new /datum/computer_file/program/alarm_monitor(src))
store_file(new /datum/computer_file/program/atmosscan)
store_file(new /datum/computer_file/program/alarm_monitor)

View File

@@ -22,7 +22,7 @@
. = ..()
paper_to_be = new
/datum/computer_file/program/scipaper_program/run_program(mob/living/user)
/datum/computer_file/program/scipaper_program/on_start(mob/living/user)
. = ..()
linked_techweb = SSresearch.science_tech