Skip to content

Commit

Permalink
[MIRROR] Ody sleeper new UI (#2818)
Browse files Browse the repository at this point in the history
* Ody sleeper new UI (#82513)

## About The Pull Request

Removes the old reagent manager menu, and replaces it with a modern tsx
one.
Old:
![Screenshot 2024-04-06
130418](https://github.com/tgstation/tgstation/assets/163439532/71cb46a8-ad3d-4c74-a1de-19c41b07a461)

New:
![Screenshot 2024-04-06
130427](https://github.com/tgstation/tgstation/assets/163439532/008722b5-0473-4cdb-99ec-2eeba3886eeb)

+Candy Stripes:

![image](https://github.com/tgstation/tgstation/assets/163439532/c0f0681d-a298-44a6-a57d-bdb212040524)


## Why It's Good For The Game

Old menu doesn't look good. Fixes some issues old menu had.

## Changelog

:cl:
fix: fixes ody sleeper UI not updating to new chems to inject.
fix: fixes ody sleeper not telling user why they can't pick up a person.
code: gives a common method for giving reagent list data to .tsx
/:cl:

---------



* Ody sleeper new UI

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: Bilbo367 <[email protected]>
Co-authored-by: san7890 <[email protected]>
  • Loading branch information
4 people authored Apr 10, 2024
1 parent 4b40944 commit ee0f85d
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 142 deletions.
150 changes: 48 additions & 102 deletions code/modules/vehicles/mecha/equipment/tools/medical_tools.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

/obj/item/mecha_parts/mecha_equipment/medical/sleeper
name = "mounted sleeper"
desc = "Equipment for medical exosuits. A mounted sleeper that stabilizes patients and can inject reagents in the exosuit's reserves."
desc = "Equipment for medical exosuits. A mounted sleeper that stabilizes patients and can inject reagents from a equipped exosuit syringe gun."
icon_state = "mecha_sleeper"
energy_drain = 20
range = MECHA_MELEE
equip_cooldown = 20
///ref to the patient loaded in the sleeper
/// ref to the patient loaded in the sleeper
var/mob/living/carbon/patient
/// amount of chems to inject into patient from other hands syringe gun
var/inject_amount = 10
Expand All @@ -32,34 +32,69 @@
content.forceMove(get_turf(src))
return ..()

/obj/item/mecha_parts/mecha_equipment/medical/proc/get_reagent_data(list/datum/reagent/reagent_list)
var/list/contained_reagents = list()
if(length(reagent_list))
for(var/datum/reagent/reagent as anything in reagent_list)
contained_reagents += list(list("name" = reagent.name, "volume" = round(reagent.volume, 0.01))) // list in a list because Byond merges the first list...
return contained_reagents

/obj/item/mecha_parts/mecha_equipment/medical/sleeper/get_snowflake_data()
var/list/data = list("snowflake_id" = MECHA_SNOWFLAKE_ID_SLEEPER)
if(!patient)
if(isnull(patient))
return data
var/patient_state
switch(patient.stat)
if(0)
patient_state = "Conscious"
if(1)
patient_state = "Unconscious"
if(2)
patient_state = "*dead*"
else
patient_state = "Unknown"
var/core_temp = ""
if(ishuman(patient))
var/mob/living/carbon/human/humi = patient
core_temp = humi.bodytemperature-T0C
data["patient"] = list(
"patientname" = patient.name,
"is_dead" = patient.stat == DEAD,
"patient_name" = patient.name,
"patient_health" = patient.health/patient.maxHealth,
"patient_state" = patient_state,
"core_temp" = core_temp,
"brute_loss" = patient.getBruteLoss(),
"burn_loss" = patient.getFireLoss(),
"toxin_loss" = patient.getToxLoss(),
"oxygen_loss" = patient.getOxyLoss(),
)
data["has_brain_damage"] = patient.get_organ_loss(ORGAN_SLOT_BRAIN) != 0
data["has_traumas"] = length(patient.get_traumas()) != 0
data["contained_reagents"] = get_reagent_data(patient.reagents.reagent_list)

var/obj/item/mecha_parts/mecha_equipment/medical/syringe_gun/shooter = locate(/obj/item/mecha_parts/mecha_equipment/medical/syringe_gun) in chassis
data["injectible_reagents"] = get_reagent_data(shooter.reagents.reagent_list)
return data

/obj/item/mecha_parts/mecha_equipment/medical/sleeper/handle_ui_act(action, list/params)
switch(action)
if("eject")
go_out()
return TRUE
if("view_stats")
usr << browse(get_patient_stats(),"window=msleeper")
onclose(usr, "msleeper")
return FALSE
var/obj/item/mecha_parts/mecha_equipment/medical/syringe_gun/shooter = locate() in chassis
for(var/datum/reagent/medication in shooter.reagents.reagent_list)
if(action == ("inject_reagent_" + medication.name))
inject_reagent(medication, shooter)
break // or maybe return TRUE? i'm not certain

return FALSE

/obj/item/mecha_parts/mecha_equipment/medical/sleeper/action(mob/source, atom/atomtarget, list/modifiers)
if(!action_checks(atomtarget))
return
if(!iscarbon(atomtarget))
return
var/mob/living/carbon/target = atomtarget
if(!patient_insertion_check(target))
if(!patient_insertion_check(target, source))
return
to_chat(source, "[icon2html(src, source)][span_notice("You start putting [target] into [src]...")]")
chassis.visible_message(span_warning("[chassis] starts putting [target] into \the [src]."))
Expand All @@ -76,7 +111,7 @@
return ..()

/obj/item/mecha_parts/mecha_equipment/medical/sleeper/proc/patient_insertion_check(mob/living/carbon/target, mob/user)
if(target.buckled)
if(!isnull(target.buckled))
to_chat(user, "[icon2html(src, user)][span_warning("[target] will not fit into the sleeper because [target.p_theyre()] buckled to [target.buckled]!")]")
return FALSE
if(target.has_buckled_mobs())
Expand All @@ -103,92 +138,7 @@
STOP_PROCESSING(SSobj, src)
return ..()

/obj/item/mecha_parts/mecha_equipment/medical/sleeper/Topic(href,href_list)
. = ..()
if(.)
return
if(!(usr in chassis.occupants))
return
if(href_list["inject"])
var/obj/item/mecha_parts/mecha_equipment/medical/syringe_gun/SG = locate() in chassis
var/datum/reagent/R = locate(href_list["inject"]) in SG.reagents.reagent_list
if(istype(R))
inject_reagent(R, SG)

/obj/item/mecha_parts/mecha_equipment/medical/sleeper/proc/get_patient_stats()
if(!patient)
return
return {"<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
<title>[patient] statistics</title>
<script language='javascript' type='text/javascript'>
[js_byjax]
</script>
<style>
h3 {margin-bottom:2px;font-size:14px;}
#lossinfo, #reagents, #injectwith {padding-left:15px;}
</style>
</head>
<body>
<h3>Health statistics</h3>
<div id="lossinfo">
[get_patient_dam()]
</div>
<h3>Reagents in bloodstream</h3>
<div id="reagents">
[get_patient_reagents()]
</div>
<div id="injectwith">
[get_available_reagents()]
</div>
</body>
</html>"}

/obj/item/mecha_parts/mecha_equipment/medical/sleeper/proc/get_patient_dam()
var/t1
switch(patient.stat)
if(0)
t1 = "Conscious"
if(1)
t1 = "Unconscious"
if(2)
t1 = "*dead*"
else
t1 = "Unknown"
var/core_temp = ""
if(ishuman(patient))
var/mob/living/carbon/human/humi = patient
core_temp = {"<font color="[humi.coretemperature > 300 ? "#3d5bc3" : "#c51e1e"]"><b>Body Temperature:</b> [humi.bodytemperature-T0C]&deg;C ([humi.bodytemperature*1.8-459.67]&deg;F)</font><br />"}
return {"<font color="[patient.health > 50 ? "#3d5bc3" : "#c51e1e"]"><b>Health:</b> [patient.stat > 1 ? "[t1]" : "[patient.health]% ([t1])"]</font><br />
[core_temp]
<font color="[patient.bodytemperature > 300 ? "#3d5bc3" : "#c51e1e"]"><b>Body Temperature:</b> [patient.bodytemperature-T0C]&deg;C ([patient.bodytemperature*1.8-459.67]&deg;F)</font><br />
<font color="[patient.getBruteLoss() < 60 ? "#3d5bc3" : "#c51e1e"]"><b>Brute Damage:</b> [patient.getBruteLoss()]%</font><br />
<font color="[patient.getOxyLoss() < 60 ? "#3d5bc3" : "#c51e1e"]"><b>Respiratory Damage:</b> [patient.getOxyLoss()]%</font><br />
<font color="[patient.getToxLoss() < 60 ? "#3d5bc3" : "#c51e1e"]"><b>Toxin Content:</b> [patient.getToxLoss()]%</font><br />
<font color="[patient.getFireLoss() < 60 ? "#3d5bc3" : "#c51e1e"]"><b>Burn Severity:</b> [patient.getFireLoss()]%</font><br />
[span_danger("[patient.get_organ_loss(ORGAN_SLOT_BRAIN) ? "Significant brain damage detected." : ""]")]<br />
[span_danger("[length(patient.get_traumas()) ? "Brain Traumas detected." : ""]")]<br />
"}

/obj/item/mecha_parts/mecha_equipment/medical/sleeper/proc/get_patient_reagents()
if(patient.reagents)
for(var/datum/reagent/R in patient.reagents.reagent_list)
if(R.volume > 0)
. += "[R]: [round(R.volume,0.01)]<br />"
return . || "None"

/obj/item/mecha_parts/mecha_equipment/medical/sleeper/proc/get_available_reagents()
var/output
var/obj/item/mecha_parts/mecha_equipment/medical/syringe_gun/SG = locate(/obj/item/mecha_parts/mecha_equipment/medical/syringe_gun) in chassis
if(SG && SG.reagents && islist(SG.reagents.reagent_list))
for(var/datum/reagent/R in SG.reagents.reagent_list)
if(R.volume > 0)
output += "<a href=\"?src=[REF(src)];inject=[REF(R)]\">Inject [R.name]</a><br />"
return output


/obj/item/mecha_parts/mecha_equipment/medical/sleeper/proc/inject_reagent(datum/reagent/R,obj/item/mecha_parts/mecha_equipment/medical/syringe_gun/SG)
/obj/item/mecha_parts/mecha_equipment/medical/sleeper/proc/inject_reagent(datum/reagent/R, obj/item/mecha_parts/mecha_equipment/medical/syringe_gun/SG)
if(!R || !patient || !SG || !(SG in chassis.flat_equipment))
return
var/to_inject = min(R.volume, inject_amount)
Expand Down Expand Up @@ -294,11 +244,7 @@
"total_reagents" = reagents.maximum_volume,
"analyzed_reagents" = analyzed_reagents,
)
var/list/contained_reagents = list()
if(length(reagents.reagent_list))
for(var/datum/reagent/reagent as anything in reagents.reagent_list)
contained_reagents += list(list("name" = reagent.name, "volume" = round(reagent.volume, 0.01))) // list in a list because Byond merges the first list...
data["contained_reagents"] = contained_reagents
data["contained_reagents"] = get_reagent_data(reagents.reagent_list)
return data

/obj/item/mecha_parts/mecha_equipment/medical/syringe_gun/handle_ui_act(action, list/params)
Expand Down
Loading

0 comments on commit ee0f85d

Please sign in to comment.