[MIRROR] Fixes issues with closing apps on tablets [MDB IGNORE] (#20969)

* Fixes issues with closing apps on tablets (#75117)

## About The Pull Request

- Fixes background apps not reloading the UI
- Standardizes opening/closing/backgrounding apps
- Simplifies the way apps are closed instead of having 2 procs, one on
the PC and one on the program, being named the same thing (wtf)
- Removes program states. They existed so computers can know to update
their UI every process tick, but since we now do this event based, this
is no longer needed, which is good.
- Replaces the 'forced' arg from kill_program as it was completely
unused, with ``reload_ui``, which is now used to open the UI on close,
and not to when we don't want it to.
- Closing background apps no longer reloads the entire UI
- Responding to an NT Message will no longer open the UI on your face.

## Why It's Good For The Game

Closes https://github.com/tgstation/tgstation/issues/75046
Closes https://github.com/tgstation/tgstation/issues/75108

Makes tablet UIs more responsive and lag less, not checking if a program
is closed every process to close it, and makes responding to messages
not a hassle every time.
Also makes the code easier to understand/read,

## Changelog

🆑
fix: Tablets' minimize apps feature works again.
/🆑

* Fixes issues with closing apps on tablets

* Update tablet.dm

---------

Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
Co-authored-by: Gandalf <9026500+Gandalf2k15@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-05-08 23:02:51 +01:00
committed by GitHub
parent f1b1e8b109
commit c50e7c03b6
21 changed files with 88 additions and 99 deletions
@@ -7,8 +7,6 @@
var/list/required_access = list()
/// List of required access to download or file host the program. Any match will do.
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
/// User-friendly name of this program.
var/filedesc = "Unknown Program"
/// Short description of this program's function.
@@ -158,23 +156,43 @@
if(requires_ntnet)
var/obj/item/card/id/ID = computer.computer_id_slot?.GetID()
generate_network_log("Connection opened -- Program ID:[filename] User:[ID?"[ID.registered_name]":"None"]")
program_state = PROGRAM_STATE_ACTIVE
return TRUE
return FALSE
/**
* Kills the running program
*
* Use this proc to kill the program. Designed to be implemented by each program if it requires on-quit logic, such as the NTNRC client.
* Arguments:
* * forced - Boolean to determine if this was a forced close. Should be TRUE if the user did not willingly close the program.
* Use this proc to kill the program.
* Designed to be implemented by each program if it requires on-quit logic, such as the NTNRC client.
* Args:
* - reload_ui - Whether we reload the UI on computer's shutdown.
**/
/datum/computer_file/program/proc/kill_program(forced = FALSE)
/datum/computer_file/program/proc/kill_program()
SHOULD_CALL_PARENT(TRUE)
program_state = PROGRAM_STATE_KILLED
if(src == computer.active_program)
computer.active_program = null
if(computer.enabled)
computer.update_tablet_open_uis(usr)
if(src in computer.idle_threads)
computer.idle_threads.Remove(src)
if(requires_ntnet)
var/obj/item/card/id/ID = computer.computer_id_slot?.GetID()
generate_network_log("Connection closed -- Program ID: [filename] User:[ID ? "[ID.registered_name]" : "None"]")
computer.update_appearance(UPDATE_ICON)
return TRUE
///Sends the running program to the background/idle threads. Header programs can't be minimized and will kill instead.
/datum/computer_file/program/proc/background_program()
SHOULD_CALL_PARENT(TRUE)
if(header_program)
return kill_program()
computer.idle_threads.Add(src)
computer.active_program = null
computer.update_tablet_open_uis(usr)
computer.update_appearance(UPDATE_ICON)
return TRUE