mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-20 20:45:28 +01:00
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. /🆑
This commit is contained in:
@@ -420,13 +420,6 @@ GLOBAL_LIST_EMPTY(TabletMessengers) // a list of all active messengers, similar
|
||||
update_appearance(UPDATE_ICON)
|
||||
return ..()
|
||||
|
||||
// On-click handling. Turns on the computer if it's off and opens the GUI.
|
||||
/obj/item/modular_computer/interact(mob/user)
|
||||
if(enabled)
|
||||
ui_interact(user)
|
||||
else
|
||||
turn_on(user)
|
||||
|
||||
/obj/item/modular_computer/CtrlShiftClick(mob/user)
|
||||
. = ..()
|
||||
if(.)
|
||||
@@ -605,7 +598,6 @@ GLOBAL_LIST_EMPTY(TabletMessengers) // a list of all active messengers, similar
|
||||
program.alert_pending = FALSE
|
||||
idle_threads.Remove(program)
|
||||
update_appearance()
|
||||
updateUsrDialog()
|
||||
return TRUE
|
||||
|
||||
if(!program.is_supported_by_hardware(hardware_flag, 1, user))
|
||||
@@ -625,7 +617,7 @@ GLOBAL_LIST_EMPTY(TabletMessengers) // a list of all active messengers, similar
|
||||
active_program = program
|
||||
program.alert_pending = FALSE
|
||||
update_appearance()
|
||||
updateUsrDialog()
|
||||
ui_interact(user)
|
||||
return TRUE
|
||||
|
||||
// Returns 0 for No Signal, 1 for Low Signal and 2 for Good Signal. 3 is for wired connection (always-on)
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
/obj/item/modular_computer/attack_self(mob/user)
|
||||
. = ..()
|
||||
ui_interact(user)
|
||||
/obj/item/modular_computer/interact(mob/user)
|
||||
if(enabled)
|
||||
ui_interact(user)
|
||||
else
|
||||
turn_on(user)
|
||||
|
||||
// Operates TGUI
|
||||
/obj/item/modular_computer/ui_interact(mob/user, datum/tgui/ui)
|
||||
if(!enabled)
|
||||
if(!enabled || !user.can_read(src, READING_CHECK_LITERACY) || !use_power())
|
||||
if(ui)
|
||||
ui.close()
|
||||
return
|
||||
if(!use_power())
|
||||
if(ui)
|
||||
ui.close()
|
||||
return
|
||||
|
||||
if(!user.can_read(src, READING_CHECK_LITERACY))
|
||||
return
|
||||
|
||||
// Robots don't really need to see the screen, their wireless connection works as long as computer is on.
|
||||
if(!screen_on && !issilicon(user))
|
||||
@@ -22,27 +17,43 @@
|
||||
ui.close()
|
||||
return
|
||||
|
||||
// If we have an active program switch to it now.
|
||||
if(active_program)
|
||||
if(ui) // This is the main laptop screen. Since we are switching to program's UI close it for now.
|
||||
ui.close()
|
||||
active_program.ui_interact(user)
|
||||
return
|
||||
|
||||
if(honkvirus_amount > 0) // EXTRA annoying, huh!
|
||||
honkvirus_amount--
|
||||
playsound(src, 'sound/items/bikehorn.ogg', 30, TRUE)
|
||||
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if (!ui)
|
||||
ui = new(user, src, "NtosMain")
|
||||
ui.set_autoupdate(TRUE)
|
||||
if(ui.open())
|
||||
ui.send_asset(get_asset_datum(/datum/asset/simple/headers))
|
||||
if(!ui)
|
||||
if(active_program)
|
||||
ui = new(user, src, active_program.tgui_id, active_program.filedesc)
|
||||
else
|
||||
ui = new(user, src, "NtosMain")
|
||||
ui.open()
|
||||
return
|
||||
|
||||
var/old_open_ui = ui.interface
|
||||
if(active_program)
|
||||
ui.interface = active_program.tgui_id
|
||||
ui.title = active_program.filedesc
|
||||
else
|
||||
ui.interface = "NtosMain"
|
||||
//opened a new UI
|
||||
if(old_open_ui != ui.interface)
|
||||
update_static_data(user, ui)
|
||||
ui.send_assets()
|
||||
|
||||
/obj/item/modular_computer/ui_assets(mob/user)
|
||||
var/list/data = list()
|
||||
data += get_asset_datum(/datum/asset/simple/headers)
|
||||
if(active_program)
|
||||
data += active_program.ui_assets(user)
|
||||
return data
|
||||
|
||||
/obj/item/modular_computer/ui_static_data(mob/user)
|
||||
. = ..()
|
||||
var/list/data = list()
|
||||
if(active_program)
|
||||
data += active_program.ui_static_data(user)
|
||||
return data
|
||||
|
||||
data["show_imprint"] = istype(src, /obj/item/modular_computer/pda)
|
||||
|
||||
@@ -50,6 +61,9 @@
|
||||
|
||||
/obj/item/modular_computer/ui_data(mob/user)
|
||||
var/list/data = get_header_data()
|
||||
if(active_program)
|
||||
data += active_program.ui_data(user)
|
||||
return data
|
||||
|
||||
data["login"] = list(
|
||||
IDName = saved_identification || "Unknown",
|
||||
@@ -61,7 +75,6 @@
|
||||
IDJob = computer_id_slot?.assignment,
|
||||
)
|
||||
|
||||
|
||||
data["removable_media"] = list()
|
||||
if(inserted_disk)
|
||||
data["removable_media"] += "Eject Disk"
|
||||
@@ -86,9 +99,8 @@
|
||||
data["pai"] = inserted_pai
|
||||
return data
|
||||
|
||||
|
||||
// Handles user's GUI input
|
||||
/obj/item/modular_computer/ui_act(action, params)
|
||||
/obj/item/modular_computer/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
@@ -99,6 +111,9 @@
|
||||
balloon_alert(human_user, "fingers are too big!")
|
||||
return TRUE
|
||||
|
||||
if(active_program)
|
||||
active_program.ui_act(action, params, ui, state)
|
||||
|
||||
switch(action)
|
||||
if("PC_exit")
|
||||
kill_program()
|
||||
@@ -107,29 +122,28 @@
|
||||
shutdown_computer()
|
||||
return TRUE
|
||||
if("PC_minimize")
|
||||
var/mob/user = usr
|
||||
if(!active_program)
|
||||
return
|
||||
//header programs can't be minimized.
|
||||
if(active_program.header_program)
|
||||
kill_program()
|
||||
return TRUE
|
||||
|
||||
idle_threads.Add(active_program)
|
||||
active_program.program_state = PROGRAM_STATE_BACKGROUND // Should close any existing UIs
|
||||
|
||||
active_program = null
|
||||
update_appearance()
|
||||
if(user && istype(user))
|
||||
ui_interact(user) // Re-open the UI on this computer. It should show the main screen now.
|
||||
|
||||
if("PC_killprogram")
|
||||
var/prog = params["name"]
|
||||
var/datum/computer_file/program/P = null
|
||||
var/mob/user = usr
|
||||
P = find_file_by_name(prog)
|
||||
var/datum/computer_file/program/killed_program = find_file_by_name(prog)
|
||||
|
||||
if(!istype(P) || P.program_state == PROGRAM_STATE_KILLED)
|
||||
if(!istype(killed_program) || killed_program.program_state == PROGRAM_STATE_KILLED)
|
||||
return
|
||||
|
||||
P.kill_program(forced = TRUE)
|
||||
to_chat(user, span_notice("Program [P.filename].[P.filetype] with PID [rand(100,999)] has been killed."))
|
||||
killed_program.kill_program(forced = TRUE)
|
||||
to_chat(usr, span_notice("Program [killed_program.filename].[killed_program.filetype] with PID [rand(100,999)] has been killed."))
|
||||
|
||||
if("PC_runprogram")
|
||||
open_program(usr, find_file_by_name(params["name"]))
|
||||
@@ -172,7 +186,7 @@
|
||||
return TRUE
|
||||
|
||||
if("ID")
|
||||
if(RemoveID())
|
||||
if(RemoveID(user))
|
||||
playsound(src, 'sound/machines/card_slide.ogg', 50)
|
||||
return TRUE
|
||||
|
||||
@@ -192,8 +206,6 @@
|
||||
if("interact")
|
||||
inserted_pai.attack_self(usr)
|
||||
return UI_UPDATE
|
||||
else
|
||||
return
|
||||
|
||||
/obj/item/modular_computer/ui_host()
|
||||
if(physical)
|
||||
|
||||
Reference in New Issue
Block a user