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.
/🆑
This commit is contained in:
John Willard
2023-05-06 08:56:14 +00:00
committed by GitHub
parent 11603a78c3
commit 4ffef6be6d
20 changed files with 88 additions and 98 deletions
@@ -30,7 +30,7 @@
examine_text += span_info("Alt-click to eject the intelliCard.")
return examine_text
/datum/computer_file/program/ai_restorer/kill_program(forced)
/datum/computer_file/program/ai_restorer/kill_program()
try_eject(forced = TRUE)
return ..()
@@ -51,6 +51,6 @@
. = ..(user)
GLOB.alarmdisplay += src
/datum/computer_file/program/alarm_monitor/kill_program(forced = FALSE)
/datum/computer_file/program/alarm_monitor/kill_program()
GLOB.alarmdisplay -= src
return ..()
@@ -32,13 +32,12 @@
target = null
error = "Connection to destination relay lost."
/datum/computer_file/program/ntnet_dos/kill_program(forced = FALSE)
/datum/computer_file/program/ntnet_dos/kill_program()
if(target)
target.dos_sources.Remove(src)
target = null
executed = FALSE
..()
return ..()
/datum/computer_file/program/ntnet_dos/ui_act(action, params, datum/tgui/ui, datum/ui_state/state)
switch(action)
@@ -19,7 +19,7 @@
DL_source = null
return ..()
/datum/computer_file/program/borg_monitor/kill_program(forced = FALSE)
/datum/computer_file/program/borg_monitor/kill_program()
loglist = null //Not everything is saved if you close an app
DL_source = null
DL_progress = 0
@@ -79,7 +79,7 @@
return FALSE
computer.crew_manifest_update = TRUE
/datum/computer_file/program/card_mod/kill_program(forced)
/datum/computer_file/program/card_mod/kill_program()
computer.crew_manifest_update = FALSE
var/obj/item/card/id/inserted_auth_card = computer.computer_id_slot
if(inserted_auth_card)
@@ -162,6 +162,6 @@
return TRUE
return FALSE
/datum/computer_file/program/ntnetdownload/kill_program(forced)
/datum/computer_file/program/ntnetdownload/kill_program()
abort_file_download()
return ..()
@@ -3,7 +3,6 @@
filedesc = "Direct Messenger"
category = PROGRAM_CATEGORY_MISC
program_icon_state = "command"
program_state = PROGRAM_STATE_BACKGROUND
extended_desc = "This program allows old-school communication with other modular devices."
size = 0
undeletable = TRUE // It comes by default in tablets, can't be downloaded, takes no space and should obviously not be able to be deleted.
@@ -414,7 +413,7 @@
if(!computer.turn_on(usr, open_ui = FALSE))
return
if(computer.active_program != src)
if(!computer.open_program(usr, src))
if(!computer.open_program(usr, src, open_ui = FALSE))
return
if(!href_list["close"] && usr.can_perform_action(computer, FORBID_TELEKINESIS_REACH))
switch(href_list["choice"])
@@ -176,7 +176,7 @@
/datum/computer_file/program/chatclient/process_tick(seconds_per_tick)
. = ..()
var/datum/ntnet_conversation/channel = SSmodular_computers.get_chat_channel_by_id(active_channel)
if(program_state != PROGRAM_STATE_KILLED)
if(src in computer.idle_threads)
ui_header = "ntnrc_idle.gif"
if(channel)
// Remember the last message. If there is no message in the channel remember null.
@@ -198,7 +198,7 @@
channel.offline_clients.Remove(src)
channel.active_clients.Add(src)
/datum/computer_file/program/chatclient/kill_program(forced = FALSE)
/datum/computer_file/program/chatclient/kill_program()
for(var/datum/ntnet_conversation/channel as anything in SSmodular_computers.chat_channels)
channel.go_offline(src)
active_channel = null
@@ -236,7 +236,8 @@
authed = TRUE
clients.Add(list(list(
"name" = channel_client.username,
"status" = channel_client.program_state,
"online" = (channel_client == channel_client.computer.active_program),
"away" = (channel_client in channel_client.computer.idle_threads),
"muted" = (channel_client in channel.muted_clients),
"operator" = (channel.channel_operator == channel_client),
"ref" = REF(channel_client),
@@ -29,7 +29,7 @@
return
return FALSE
/datum/computer_file/program/radar/kill_program(forced = FALSE)
/datum/computer_file/program/radar/kill_program()
objects = list()
selected = null
STOP_PROCESSING(SSfastprocess, src)
@@ -313,7 +313,7 @@
RegisterSignal(SSdcs, COMSIG_GLOB_NUKE_DEVICE_ARMED, PROC_REF(on_nuke_armed))
/datum/computer_file/program/radar/fission360/kill_program(forced)
/datum/computer_file/program/radar/fission360/kill_program()
UnregisterSignal(SSdcs, COMSIG_GLOB_NUKE_DEVICE_ARMED)
return ..()
@@ -19,7 +19,7 @@
. = ..()
set_frequency(signal_frequency)
/datum/computer_file/program/signal_commander/kill_program(forced)
/datum/computer_file/program/signal_commander/kill_program()
. = ..()
SSradio.remove_object(computer, signal_frequency)
@@ -22,7 +22,7 @@
refresh()
/// Apparently destroy calls this [/datum/computer_file/Destroy]. Here just to clean our references.
/datum/computer_file/program/supermatter_monitor/kill_program(forced = FALSE)
/datum/computer_file/program/supermatter_monitor/kill_program()
for(var/supermatter in supermatters)
clear_supermatter(supermatter)
return ..()