Files
Bubberstation/code/modules/modular_computers/file_system/programs/atmosscan.dm
T
SkyratBot cb3b675bae [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>
2023-03-10 06:09:10 +00:00

88 lines
3.3 KiB
Plaintext

/// Scan the turf where the computer is on.
#define ATMOZPHERE_SCAN_ENV "env"
/// Scan the objects that the tablet clicks.
#define ATMOZPHERE_SCAN_CLICK "click"
/datum/computer_file/program/atmosscan
filename = "atmosscan"
filedesc = "AtmoZphere"
category = PROGRAM_CATEGORY_ENGI
program_icon_state = "air"
extended_desc = "A small built-in sensor reads out the atmospheric conditions around the device."
size = 4
tgui_id = "NtosGasAnalyzer"
program_icon = "thermometer-half"
/// Whether we scan the current turf automatically (env) or scan tapped objects manually (click).
var/atmozphere_mode = ATMOZPHERE_SCAN_ENV
/// Saved [GasmixParser][/proc/gas_mixture_parser] data of the last thing we scanned.
var/list/last_gasmix_data
/// Secondary attack self.
/datum/computer_file/program/atmosscan/proc/turf_analyze(datum/source, mob/user)
SIGNAL_HANDLER
if(atmozphere_mode != ATMOZPHERE_SCAN_CLICK)
return
atmos_scan(user=user, target=get_turf(computer), silent=FALSE)
on_analyze(source=source, target=get_turf(computer))
return COMPONENT_CANCEL_ATTACK_CHAIN
/// Keep this in sync with it's tool based counterpart [/obj/proc/analyzer_act] and [/atom/proc/tool_act]
/datum/computer_file/program/atmosscan/tap(atom/A, mob/living/user, params)
if(atmozphere_mode != ATMOZPHERE_SCAN_CLICK)
return FALSE
if(!atmos_scan(user=user, target=A, silent=FALSE))
return FALSE
on_analyze(source=computer, target=A)
return TRUE
/// Updates our gasmix data if on click mode.
/datum/computer_file/program/atmosscan/proc/on_analyze(datum/source, atom/target)
var/mixture = target.return_analyzable_air()
if(!mixture)
return FALSE
var/list/airs = islist(mixture) ? mixture : list(mixture)
var/list/new_gasmix_data = list()
for(var/datum/gas_mixture/air as anything in airs)
var/mix_name = capitalize(lowertext(target.name))
if(airs.len != 1) //not a unary gas mixture
mix_name += " - Node [airs.Find(air)]"
new_gasmix_data += list(gas_mixture_parser(air, mix_name))
last_gasmix_data = new_gasmix_data
/datum/computer_file/program/atmosscan/ui_static_data(mob/user)
return return_atmos_handbooks()
/datum/computer_file/program/atmosscan/ui_data(mob/user)
var/list/data = list()
var/turf/turf = get_turf(computer)
data["atmozphereMode"] = atmozphere_mode
data["clickAtmozphereCompatible"] = (computer.hardware_flag & PROGRAM_TABLET)
switch (atmozphere_mode) //Null air wont cause errors, don't worry.
if(ATMOZPHERE_SCAN_ENV)
var/datum/gas_mixture/air = turf?.return_air()
data["gasmixes"] = list(gas_mixture_parser(air, "Location Reading"))
if(ATMOZPHERE_SCAN_CLICK)
LAZYINITLIST(last_gasmix_data)
data["gasmixes"] = last_gasmix_data
return data
/datum/computer_file/program/atmosscan/ui_act(action, list/params)
. = ..()
if(.)
return
switch(action)
if("scantoggle")
if(atmozphere_mode == ATMOZPHERE_SCAN_CLICK)
atmozphere_mode = ATMOZPHERE_SCAN_ENV
UnregisterSignal(computer, COMSIG_ITEM_ATTACK_SELF_SECONDARY)
return TRUE
if(!(computer.hardware_flag & PROGRAM_TABLET))
computer.say("Device incompatible for scanning objects!")
return FALSE
atmozphere_mode = ATMOZPHERE_SCAN_CLICK
RegisterSignal(computer, COMSIG_ITEM_ATTACK_SELF_SECONDARY, PROC_REF(turf_analyze))
var/turf/turf = get_turf(computer)
last_gasmix_data = list(gas_mixture_parser(turf?.return_air(), "Location Reading"))
return TRUE