mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 12:41:09 +01:00
PDA update (Messenger works while dead, Microwave works, etc). (#80069)
## About The Pull Request This is an update that touches many more things all at once (compared to my other PRs) meant to make PDAs in general feel more consistent and not take away from one of the experiences we want to encourage: interaction between players. 1. Replaced all checks of a 'pda' with a 'modular pc'. This means technically (though not done in-game currently) other modpcs can hold an uplink, and microwaves can charge laptops. 2. Speaking of microwave, they now don't break and require deconstruction if the cell is removed mid-charge. 3. When a Mod PC is out of power, it will now allow the Messenger to work (which now also doesn't consume any additional power), if the app exists on the PC. Here's a video demonstration https://github.com/tgstation/tgstation/assets/53777086/7ae12f81-a271-49b8-95fa-2ba54d2e2d1f 4. Flashlights can't be turned on while the cell is dead 5. I replaced a bunch of program vars with ``program_flags`` and renamed ``usage_flags`` to ``can_run_on_flags``. 6. Added a debug modPC that has every app installed by default. Mafia had some issues in the past that were unknown because Mafia wasn't preinstalled with any tablet so was never in create & destroy nor in any other unit test. This was just an easy solution I had, but PDAs should get more in-depth unit tests in the future for running apps n stuff- I just wanted to make sure no other apps were broken/harddeling. ## Why It's Good For The Game Currently when a PDA dies, its only use is to reply to PDA messages sent to you, since you can still reply to them. Instead of just fixing it and telling players to cope, I thought it would be nice to allow PDA Messenger to still work, as it is a vital app. You can call it some emergency power mode or whatever, I don't really mind the reason behind why it is this way. When I made cells used more on PDAs, my main goal was to encourage upgrading your PDA and/or limiting how many apps you use at once, I did not want this to hit on players who use it as a form of interaction. This is the best of both worlds, I think. The rest of the changes is just for modularity, if some downstream wants to add tablets, phone computers, or whatever the hell else, they can still get just as far as PDAs should be able to get to, hopefully. ## Changelog 🆑 add: PDAs with a dead power cell are now limited to using their Messenger app. fix: Microwaves now stop charging PDAs if the cell was removed mid-charge. fix: Microwaves can now charge laptops. fix: PDA Flashlights can't be turned on while the PDA is dead. fix: You can now hold a laptop up to a camera (if it has a notekeeper app installed) like PDAs already could. /🆑 --------- Co-authored-by: lessthanthree <83487515+lessthnthree@users.noreply.github.com>
This commit is contained in:
co-authored by
lessthanthree
parent
b2a1c7e2ca
commit
edbc7c5622
@@ -47,7 +47,7 @@
|
||||
var/max_idle_programs = 2
|
||||
|
||||
///Flag of the type of device the modular computer is, deciding what types of apps it can run.
|
||||
var/hardware_flag = NONE
|
||||
var/hardware_flag = PROGRAM_ALL
|
||||
// Options: PROGRAM_ALL | PROGRAM_CONSOLE | PROGRAM_LAPTOP | PROGRAM_PDA
|
||||
|
||||
///The theme, used for the main menu and file browser apps.
|
||||
@@ -472,13 +472,13 @@
|
||||
shutdown_computer()
|
||||
return
|
||||
|
||||
if(active_program && active_program.requires_ntnet && !get_ntnet_status())
|
||||
if(active_program && (active_program.program_flags & PROGRAM_REQUIRES_NTNET) && !get_ntnet_status())
|
||||
active_program.event_networkfailure(FALSE) // Active program requires NTNet to run but we've just lost connection. Crash.
|
||||
|
||||
for(var/datum/computer_file/program/idle_programs as anything in idle_threads)
|
||||
idle_programs.process_tick(seconds_per_tick)
|
||||
idle_programs.ntnet_status = get_ntnet_status()
|
||||
if(idle_programs.requires_ntnet && !idle_programs.ntnet_status)
|
||||
if((idle_programs.program_flags & PROGRAM_REQUIRES_NTNET) && !idle_programs.ntnet_status)
|
||||
idle_programs.event_networkfailure(TRUE)
|
||||
|
||||
if(active_program)
|
||||
@@ -506,6 +506,8 @@
|
||||
physical.loc.visible_message(span_notice("[icon2html(physical, viewers(physical.loc))] \The [src] displays a [caller.filedesc] notification: [alerttext]"))
|
||||
|
||||
/obj/item/modular_computer/proc/ring(ringtone) // bring bring
|
||||
if(!use_power())
|
||||
return
|
||||
if(HAS_TRAIT(SSstation, STATION_TRAIT_PDA_GLITCHED))
|
||||
playsound(src, pick('sound/machines/twobeep_voice1.ogg', 'sound/machines/twobeep_voice2.ogg'), 50, TRUE)
|
||||
else
|
||||
@@ -522,8 +524,9 @@
|
||||
data["PC_device_theme"] = device_theme
|
||||
|
||||
if(internal_cell)
|
||||
data["PC_lowpower_mode"] = !internal_cell.charge
|
||||
switch(internal_cell.percent())
|
||||
if(80 to 200) // 100 should be maximal but just in case..
|
||||
if(80 to INFINITY)
|
||||
data["PC_batteryicon"] = "batt_100.gif"
|
||||
if(60 to 80)
|
||||
data["PC_batteryicon"] = "batt_80.gif"
|
||||
@@ -537,6 +540,7 @@
|
||||
data["PC_batteryicon"] = "batt_5.gif"
|
||||
data["PC_batterypercent"] = "[round(internal_cell.percent())]%"
|
||||
else
|
||||
data["PC_lowpower_mode"] = FALSE
|
||||
data["PC_batteryicon"] = null
|
||||
data["PC_batterypercent"] = null
|
||||
|
||||
@@ -569,7 +573,8 @@
|
||||
CRASH("tried to open program that does not belong to this computer")
|
||||
|
||||
if(!program || !istype(program)) // Program not found or it's not executable program.
|
||||
to_chat(user, span_danger("\The [src]'s screen shows \"I/O ERROR - Unable to run program\" warning."))
|
||||
if(user)
|
||||
to_chat(user, span_danger("\The [src]'s screen shows \"I/O ERROR - Unable to run program\" warning."))
|
||||
return FALSE
|
||||
|
||||
// The program is already running. Resume it.
|
||||
@@ -582,15 +587,17 @@
|
||||
update_appearance(UPDATE_ICON)
|
||||
return TRUE
|
||||
|
||||
if(!program.is_supported_by_hardware(hardware_flag, 1, user))
|
||||
if(!program.is_supported_by_hardware(hardware_flag, loud = TRUE, user = user))
|
||||
return FALSE
|
||||
|
||||
if(idle_threads.len > max_idle_programs)
|
||||
to_chat(user, span_danger("\The [src] displays a \"Maximal CPU load reached. Unable to run another program.\" error."))
|
||||
if(user)
|
||||
to_chat(user, span_danger("\The [src] displays a \"Maximal CPU load reached. Unable to run another program.\" error."))
|
||||
return FALSE
|
||||
|
||||
if(program.requires_ntnet && !get_ntnet_status()) // The program requires NTNet connection, but we are not connected to NTNet.
|
||||
to_chat(user, span_danger("\The [src]'s screen shows \"Unable to connect to NTNet. Please retry. If problem persists contact your system administrator.\" warning."))
|
||||
if(program.program_flags & PROGRAM_REQUIRES_NTNET && !get_ntnet_status()) // The program requires NTNet connection, but we are not connected to NTNet.
|
||||
if(user)
|
||||
to_chat(user, span_danger("\The [src]'s screen shows \"Unable to connect to NTNet. Please retry. If problem persists contact your system administrator.\" warning."))
|
||||
return FALSE
|
||||
|
||||
if(!program.on_start(user))
|
||||
@@ -675,7 +682,7 @@
|
||||
* It is separated from ui_act() to be overwritten as needed.
|
||||
*/
|
||||
/obj/item/modular_computer/proc/toggle_flashlight(mob/user)
|
||||
if(!has_light)
|
||||
if(!has_light || !internal_cell || !internal_cell.charge)
|
||||
return FALSE
|
||||
if(!COOLDOWN_FINISHED(src, disabled_time))
|
||||
balloon_alert(user, "disrupted!")
|
||||
@@ -898,3 +905,14 @@
|
||||
inserted_pai = null
|
||||
update_appearance(UPDATE_ICON)
|
||||
return TRUE
|
||||
|
||||
/**
|
||||
* Debug ModPC
|
||||
* Used to spawn all programs for Create and Destroy unit test.
|
||||
*/
|
||||
/obj/item/modular_computer/debug
|
||||
max_capacity = INFINITY
|
||||
|
||||
/obj/item/modular_computer/debug/Initialize(mapload)
|
||||
starting_programs += subtypesof(/datum/computer_file/program)
|
||||
return ..()
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
///The multiplier given to the base overtime charge drain value if its flashlight is on.
|
||||
#define FLASHLIGHT_DRAIN_MULTIPLIER 1.1
|
||||
|
||||
// Tries to draw power from charger or, if no operational charger is present, from power cell.
|
||||
///Draws power from its rightful source (area if its a computer, the cell otherwise)
|
||||
///Takes into account special cases, like silicon PDAs through override, and nopower apps.
|
||||
/obj/item/modular_computer/proc/use_power(amount = 0)
|
||||
if(check_power_override())
|
||||
return TRUE
|
||||
|
||||
if(ismachinery(physical))
|
||||
var/obj/machinery/machine_holder = physical
|
||||
if(machine_holder.powered())
|
||||
machine_holder.use_power(amount)
|
||||
return TRUE
|
||||
|
||||
if(!internal_cell || !internal_cell.charge)
|
||||
if(!internal_cell)
|
||||
return FALSE
|
||||
if(!internal_cell.charge && (isnull(active_program) || !(active_program.program_flags & PROGRAM_RUNS_WITHOUT_POWER)))
|
||||
close_all_programs()
|
||||
for(var/datum/computer_file/program/programs as anything in stored_files)
|
||||
if((programs.program_flags & PROGRAM_RUNS_WITHOUT_POWER) && open_program(program = programs))
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
if(!internal_cell.use(amount JOULES))
|
||||
@@ -25,9 +26,9 @@
|
||||
return internal_cell.give(amount)
|
||||
return 0
|
||||
|
||||
// Used in following function to reduce copypaste
|
||||
///Shuts down the computer from powerloss.
|
||||
/obj/item/modular_computer/proc/power_failure()
|
||||
if(!enabled) // Shut down the computer
|
||||
if(!enabled)
|
||||
return
|
||||
if(active_program)
|
||||
active_program.event_powerfailure()
|
||||
@@ -56,9 +57,10 @@
|
||||
power_failure()
|
||||
return FALSE
|
||||
|
||||
///Used by subtypes for special cases for power usage, returns TRUE if it should stop the use_power chain.
|
||||
///Returns TRUE if the PC should not be using any power, FALSE otherwise.
|
||||
///Checks to see if the current app allows to be ran without power, if so we'll run with it.
|
||||
/obj/item/modular_computer/proc/check_power_override()
|
||||
return FALSE
|
||||
return (!internal_cell?.charge && (active_program?.program_flags & PROGRAM_RUNS_WITHOUT_POWER))
|
||||
|
||||
//Integrated (Silicon) tablets don't drain power, because the tablet is required to state laws, so it being disabled WILL cause problems.
|
||||
/obj/item/modular_computer/pda/silicon/check_power_override()
|
||||
|
||||
@@ -8,23 +8,24 @@
|
||||
* This is best called when you're actually changing the app, as we don't check
|
||||
* if we're swapping to the current UI repeatedly.
|
||||
* Args:
|
||||
* user - The person whose UI we're updating.
|
||||
* user - The person whose UI we're updating. Only necessary if we're opening the UI for the first time.
|
||||
*/
|
||||
/obj/item/modular_computer/proc/update_tablet_open_uis(mob/user)
|
||||
var/datum/tgui/active_ui = SStgui.get_open_ui(user, src)
|
||||
if(!active_ui)
|
||||
if(active_program)
|
||||
active_ui = new(user, src, active_program.tgui_id, active_program.filedesc)
|
||||
active_program.ui_interact(user, active_ui)
|
||||
else
|
||||
active_ui = new(user, src, "NtosMain")
|
||||
return active_ui.open()
|
||||
if(user)
|
||||
var/datum/tgui/active_ui = SStgui.get_open_ui(user, src)
|
||||
if(!active_ui)
|
||||
if(active_program)
|
||||
active_ui = new(user, src, active_program.tgui_id, active_program.filedesc)
|
||||
active_program.ui_interact(user, active_ui)
|
||||
else
|
||||
active_ui = new(user, src, "NtosMain")
|
||||
return active_ui.open()
|
||||
|
||||
for (var/datum/tgui/window as anything in open_uis)
|
||||
if(active_program)
|
||||
window.interface = active_program.tgui_id
|
||||
window.title = active_program.filedesc
|
||||
active_program.ui_interact(user, window)
|
||||
active_program.ui_interact(window.user, window)
|
||||
else
|
||||
window.interface = "NtosMain"
|
||||
window.send_assets()
|
||||
@@ -113,7 +114,7 @@
|
||||
data["programs"] += list(list(
|
||||
"name" = program.filename,
|
||||
"desc" = program.filedesc,
|
||||
"header_program" = program.header_program,
|
||||
"header_program" = !!(program.program_flags & PROGRAM_HEADER),
|
||||
"running" = !!(program in idle_threads),
|
||||
"icon" = program.program_icon,
|
||||
"alert" = program.alert_pending,
|
||||
@@ -135,13 +136,15 @@
|
||||
|
||||
switch(action)
|
||||
if("PC_exit")
|
||||
active_program.kill_program(usr)
|
||||
//you can't close apps in emergency mode.
|
||||
if(internal_cell.charge)
|
||||
active_program.kill_program(usr)
|
||||
return TRUE
|
||||
if("PC_shutdown")
|
||||
shutdown_computer()
|
||||
return TRUE
|
||||
if("PC_minimize")
|
||||
if(!active_program)
|
||||
if(!active_program || !internal_cell.charge)
|
||||
return
|
||||
active_program.background_program()
|
||||
return TRUE
|
||||
|
||||
@@ -44,6 +44,13 @@
|
||||
machinery_computer = null
|
||||
return ..()
|
||||
|
||||
/obj/item/modular_computer/processor/use_power(amount = 0)
|
||||
var/obj/machinery/machine_holder = physical
|
||||
if(machine_holder.powered())
|
||||
machine_holder.use_power(amount)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/obj/item/modular_computer/processor/relay_qdel()
|
||||
qdel(machinery_computer)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user