[MIRROR] Tablets don't close their UI when changing program (and some fixes) [MDB IGNORE] (#19600)

* Tablets don't close their UI when changing program (and some fixes) (#73635)

## About The Pull Request

- Tablets now refresh their page when changing programs, this means the
UI will no longer close and reopen itself several times (or even have
several UIs open if shit broke hard enough).
- Removed tablet's attack self because interact already does everything
it had to do.
- Header programs now close when minimized (as there's no button to
close them in the main menu.
- Removed a lot of program UI stuff, it's now handled by the PC itself,
such as header data and ui host.
- Cut off asset sending from TGUI into it's own proc so I can re-send
assets when changing programs
- Added an ejection button for machine computers
- Fixed ID not ejecting into the user's hand when using 'Eject ID'
- Fixes a minor runtime when opening the MODsuit application without a
MODsuit already connected.

## Why It's Good For The Game

Fixes some bugs that I found with tablets

UIS now won't be flickering as bad in front of them, or have
inconsistent placement (like when you move your main menu UI, go to
Messenger, then it's back to the center of the screen).

Video of it in action

https://user-images.githubusercontent.com/53777086/221301417-78321149-0c10-475e-bd29-79f5a4ba0597.mp4

## Changelog

🆑
fix: Being in an application now properly uses the tablet's battery.
fix: Messenger and Themify apps now close when minimized, so don't count
towards the running app limit.
fix: Tablet UIs will now no longer spam open/close the UI when changing
applications
fix: Using the Eject ID button on tablets now ejects into your hand.
fix: Computers now have an Eject ID button
refactor: Cut down a lot of copy paste in tablet & program code, now
it's mostly done by the tablet.
/🆑

* Tablets don't close their UI when changing program (and some fixes)

* Update contractor_tablet.dm

* wew

---------

Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
Co-authored-by: Zonespace <41448081+Zonespace27@users.noreply.github.com>
Co-authored-by: Gandalf <9026500+Gandalf2k15@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-03-10 07:09:10 +01:00
committed by GitHub
parent d240a2a0af
commit cb3b675bae
46 changed files with 135 additions and 220 deletions
@@ -143,17 +143,6 @@
to_chat(user, span_danger("\The [computer] flashes an \"Access Denied\" warning."))
return FALSE
/**
* This attempts to retrieve header data for UIs.
*
* If implementing completely new device of different type than existing ones
* always include the device here in this proc. This proc basically relays the request to whatever is running the program.
**/
/datum/computer_file/program/proc/get_header_data()
if(computer)
return computer.get_header_data()
return list()
/**
* Called on program startup.
*
@@ -188,62 +177,3 @@
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"]")
return TRUE
/datum/computer_file/program/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui && tgui_id)
ui = new(user, src, tgui_id, filedesc)
if(ui.open())
ui.send_asset(get_asset_datum(/datum/asset/simple/headers))
// CONVENTIONS, READ THIS WHEN CREATING NEW PROGRAM AND OVERRIDING THIS PROC:
// Topic calls are automagically forwarded from NanoModule this program contains.
// Calls beginning with "PRG_" are reserved for programs handling.
// Calls beginning with "PC_" are reserved for computer handling (by whatever runs the program)
// ALWAYS INCLUDE PARENT CALL ..() OR DIE IN FIRE.
/datum/computer_file/program/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return
if(ishuman(usr) && !computer.allow_chunky) //in /obj/item/modular_computer/ui_act() too
var/mob/living/carbon/human/human_user = usr
if(human_user.check_chunky_fingers())
computer.balloon_alert(human_user, "fingers are too big!")
return TRUE
if(computer)
switch(action)
if("PC_exit")
computer.kill_program()
ui.close()
return TRUE
if("PC_shutdown")
computer.shutdown_computer()
ui.close()
return TRUE
if("PC_minimize")
var/mob/user = usr
if(!computer.active_program)
return
computer.idle_threads.Add(computer.active_program)
program_state = PROGRAM_STATE_BACKGROUND // Should close any existing UIs
computer.active_program = null
computer.update_appearance()
ui.close()
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
else
return computer
/datum/computer_file/program/ui_status(mob/user)
if(program_state != PROGRAM_STATE_ACTIVE) // Our program was closed. Close the ui if it exists.
return UI_CLOSE
return ..()