Skip to content

Commit

Permalink
Improved cloning UI (#26753)
Browse files Browse the repository at this point in the history
Co-authored-by: Adrer <adrermail@gmail.com>
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
  • Loading branch information
3 people committed Sep 17, 2024
1 parent 8883a72 commit 9adbe39
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 33 deletions.
8 changes: 6 additions & 2 deletions code/game/machinery/computer/cloning.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
var/feedback
/// The desired outcome of the cloning process.
var/datum/cloning_data/desired_data

/// Is the scanner currently scanning someone?
var/currently_scanning = FALSE
COOLDOWN_DECLARE(scancooldown)

/obj/machinery/computer/cloning/Initialize(mapload)
Expand Down Expand Up @@ -157,6 +158,7 @@

if(scanner)
data["has_scanned"] = scanner.has_scanned
data["currently_scanning"] = currently_scanning
else
data["has_scanned"] = FALSE

Expand Down Expand Up @@ -231,7 +233,6 @@
switch(text2num(params["tab"]))
if(TAB_MAIN)
tab = TAB_MAIN
scanner?.update_scan_status()
return TRUE
if(TAB_DAMAGES_BREAKDOWN)
tab = TAB_DAMAGES_BREAKDOWN
Expand All @@ -256,6 +257,7 @@
if(!scanner.occupant)
return FALSE

currently_scanning = TRUE
scanner.occupant.notify_ghost_cloning()
feedback = list("text" = "Scanning occupant! Please wait...", "color" = "good", "scan_succeeded" = FALSE)
COOLDOWN_START(src, scancooldown, 10 SECONDS)
Expand Down Expand Up @@ -318,6 +320,7 @@
if("eject")
if(scanner?.occupant)
scanner.remove_mob(scanner.occupant)
currently_scanning = FALSE
return TRUE


Expand Down Expand Up @@ -352,5 +355,6 @@
feedback = list("text" = "Successfully scanned the patient.", "color" = "good", "scan_succeeded" = TRUE)
desired_data = generate_healthy_data(scan)

currently_scanning = FALSE
#undef TAB_MAIN
#undef TAB_DAMAGES_BREAKDOWN
24 changes: 18 additions & 6 deletions tgui/packages/tgui/interfaces/CloningConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,16 @@ const CloningConsoleMain = (props, context) => {

const CloningConsoleDamage = (props, context) => {
const { act, data } = useBackend(context);
const { selected_pod_data, has_scanned, scanner_has_patient, feedback, scan_successful, cloning_cost, has_scanner } =
data;
const {
selected_pod_data,
has_scanned,
scanner_has_patient,
feedback,
scan_successful,
cloning_cost,
has_scanner,
currently_scanning,
} = data;
return (
<Box>
{!has_scanner && <Box color="average">Notice: No scanner connected.</Box>}
Expand All @@ -123,21 +131,25 @@ const CloningConsoleDamage = (props, context) => {
title="Scanner Info"
buttons={
<Box>
<Button icon="hourglass-half" onClick={() => act('scan')}>
<Button
icon="hourglass-half"
onClick={() => act('scan')}
disabled={!scanner_has_patient || currently_scanning}
>
Scan
</Button>
<Button icon="eject" onClick={() => act('eject')}>
<Button icon="eject" onClick={() => act('eject')} disabled={!scanner_has_patient || currently_scanning}>
Eject Patient
</Button>
</Box>
}
>
{!has_scanned && (
{!has_scanned && !currently_scanning && (
<Box color="average">
{scanner_has_patient ? 'No scan detected for current patient.' : 'No patient is in the scanner.'}
</Box>
)}
{!!has_scanned && <Box color={feedback['color']}>{feedback['text']}</Box>}
{(!!has_scanned || !!currently_scanning) && <Box color={feedback['color']}>{feedback['text']}</Box>}
</Section>
<Section layer={2} title="Damages Breakdown">
<Box>
Expand Down
50 changes: 25 additions & 25 deletions tgui/public/tgui.bundle.js

Large diffs are not rendered by default.

0 comments on commit 9adbe39

Please sign in to comment.