Fix Medical Records Virology

This commit is contained in:
ShadowLarkens
2020-08-07 04:53:44 -07:00
parent dc6c47841d
commit f8881b2ca7
7 changed files with 71 additions and 36 deletions

View File

@@ -255,13 +255,13 @@ SUBSYSTEM_DEF(tgui)
* *
* return int The number of UIs closed. * return int The number of UIs closed.
**/ **/
/datum/controller/subsystem/tgui/proc/close_user_uis(mob/user, datum/src_object) /datum/controller/subsystem/tgui/proc/close_user_uis(mob/user, datum/src_object, logout = FALSE)
var/count = 0 var/count = 0
if(length(user?.tgui_open_uis) == 0) if(length(user?.tgui_open_uis) == 0)
return count return count
for(var/datum/tgui/ui in user.tgui_open_uis) for(var/datum/tgui/ui in user.tgui_open_uis)
if(isnull(src_object) || ui.src_object == src_object) if(isnull(src_object) || ui.src_object == src_object)
ui.close() ui.close(logout = logout)
count++ count++
return count return count
@@ -315,7 +315,7 @@ SUBSYSTEM_DEF(tgui)
* return int The number of UIs closed. * return int The number of UIs closed.
**/ **/
/datum/controller/subsystem/tgui/proc/on_logout(mob/user) /datum/controller/subsystem/tgui/proc/on_logout(mob/user)
return close_user_uis(user) return close_user_uis(user, logout = TRUE)
/** /**
* private * private

View File

@@ -170,7 +170,7 @@
data["virus"] = list() data["virus"] = list()
for(var/ID in virusDB) for(var/ID in virusDB)
var/datum/data/record/v = virusDB[ID] var/datum/data/record/v = virusDB[ID]
data["virus"] += list(list("name" = v.fields["name"], "D" = v)) data["virus"] += list(list("name" = v.fields["name"], "D" = "\ref[v]"))
if(MED_DATA_MEDBOT) if(MED_DATA_MEDBOT)
data["medbots"] = list() data["medbots"] = list()
for(var/mob/living/bot/medbot/M in mob_list) for(var/mob/living/bot/medbot/M in mob_list)
@@ -266,16 +266,9 @@
active2 = null active2 = null
if("vir") if("vir")
var/datum/data/record/v = locate(params["vir"]) var/datum/data/record/v = locate(params["vir"])
var/list/payload = list( if(!istype(v))
id = v.fields["id"], return FALSE
name = v.fields["name"], tgui_modal_message(src, "virus", "", null, v.fields["tgui_description"])
max_stages = "Unknown",
spread_text = v.fields["spread type"],
cure = v.fields["antigen"],
desc = v.fields["description"],
severity = "Unknown"
);
tgui_modal_message(src, "virus", "", null, payload)
if("del_all") if("del_all")
for(var/datum/data/record/R in data_core.medical) for(var/datum/data/record/R in data_core.medical)
qdel(R) qdel(R)

View File

@@ -108,7 +108,7 @@
* *
* Close the UI, and all its children. * Close the UI, and all its children.
*/ */
/datum/tgui/proc/close(can_be_suspended = TRUE) /datum/tgui/proc/close(can_be_suspended = TRUE, logout = FALSE)
if(closing) if(closing)
return return
closing = TRUE closing = TRUE
@@ -122,7 +122,7 @@
// and we want to keep them around, to allow user to read // and we want to keep them around, to allow user to read
// the error message properly. // the error message properly.
window.release_lock() window.release_lock()
window.close(can_be_suspended) window.close(can_be_suspended, logout)
src_object.tgui_close(user) src_object.tgui_close(user)
SStgui.on_close(src) SStgui.on_close(src)
state = null state = null

View File

@@ -133,14 +133,19 @@
* *
* optional can_be_suspended bool * optional can_be_suspended bool
*/ */
/datum/tgui_window/proc/close(can_be_suspended = TRUE) /datum/tgui_window/proc/close(can_be_suspended = TRUE, logout = FALSE)
if(!client) if(!client)
return return
if(can_be_suspended && can_be_suspended()) if(can_be_suspended && can_be_suspended())
log_tgui(client, "[id]/close: suspending") log_tgui(client, "[id]/close: suspending")
status = TGUI_WINDOW_READY status = TGUI_WINDOW_READY
send_message("suspend") send_message("suspend")
winset(client, null, "mapwindow.map.focus=true") // You would think that BYOND would null out client or make it stop passing istypes or, y'know, ANYTHING during
// logout, but nope! It appears to be perfectly valid to call winset by every means we can measure in Logout,
// and yet it causes a bad client runtime. To avoid that happening, we just have to know if we're in Logout or
// not.
if(!logout && client)
winset(client, null, "mapwindow.map.focus=true")
return return
log_tgui(client, "[id]/close") log_tgui(client, "[id]/close")
release_lock() release_lock()
@@ -150,7 +155,8 @@
// to read the error message. // to read the error message.
if(!fatally_errored) if(!fatally_errored)
client << browse(null, "window=[id]") client << browse(null, "window=[id]")
winset(client, null, "mapwindow.map.focus=true") if(!logout && client)
winset(client, null, "mapwindow.map.focus=true")
/** /**
* public * public
* *

View File

@@ -245,6 +245,25 @@ var/global/list/virusDB = list()
return r return r
/datum/disease2/disease/proc/get_tgui_info()
. = list(
"name" = name(),
"spreadtype" = spreadtype,
"antigen" = antigens2string(antigen),
"rate" = stageprob * 10,
"resistance" = resistance,
"species" = jointext(affected_species, ", "),
"symptoms" = list(),
)
for(var/datum/disease2/effectholder/E in effects)
.["symptoms"].Add(list(list(
"stage" = E.stage,
"name" = E.effect.name,
"strength" = "[E.multiplier >= 3 ? "Severe" : E.multiplier > 1 ? "Above Average" : "Average"]",
"aggressiveness" = E.chance * 15,
)))
/datum/disease2/disease/proc/addToDB() /datum/disease2/disease/proc/addToDB()
if ("[uniqueID]" in virusDB) if ("[uniqueID]" in virusDB)
return 0 return 0
@@ -252,6 +271,7 @@ var/global/list/virusDB = list()
v.fields["id"] = uniqueID v.fields["id"] = uniqueID
v.fields["name"] = name() v.fields["name"] = name()
v.fields["description"] = get_info() v.fields["description"] = get_info()
v.fields["tgui_description"] = get_tgui_info()
v.fields["antigen"] = antigens2string(antigen) v.fields["antigen"] = antigens2string(antigen)
v.fields["spread type"] = spreadtype v.fields["spread type"] = spreadtype
virusDB["[uniqueID]"] = v virusDB["[uniqueID]"] = v

View File

@@ -6,6 +6,7 @@ import { Window } from "../layouts";
import { LoginInfo } from './common/LoginInfo'; import { LoginInfo } from './common/LoginInfo';
import { LoginScreen } from './common/LoginScreen'; import { LoginScreen } from './common/LoginScreen';
import { TemporaryNotice } from './common/TemporaryNotice'; import { TemporaryNotice } from './common/TemporaryNotice';
import { decodeHtmlEntities } from 'common/string';
const severities = { const severities = {
"Minor": "good", "Minor": "good",
@@ -23,30 +24,45 @@ const doEdit = (context, field) => {
}; };
const virusModalBodyOverride = (modal, context) => { const virusModalBodyOverride = (modal, context) => {
const { act } = useBackend(context);
const virus = modal.args; const virus = modal.args;
return ( return (
<Section <Section
level={2} level={2}
m="-1rem" m="-1rem"
pb="1rem" title={virus.name || "Virus"}
title={virus.name || "Virus"}> buttons={
<Button
icon="times"
color="red"
onClick={() => act('modal_close')} />
}>
<Box mx="0.5rem"> <Box mx="0.5rem">
<LabeledList> <LabeledList>
<LabeledList.Item label="Number of stages">
{virus.max_stages}
</LabeledList.Item>
<LabeledList.Item label="Spread"> <LabeledList.Item label="Spread">
{virus.spread_text} Transmission {virus.spread_text} Transmission
</LabeledList.Item> </LabeledList.Item>
<LabeledList.Item label="Possible cure"> <LabeledList.Item label="Possible cure">
{virus.cure} {virus.antigen}
</LabeledList.Item> </LabeledList.Item>
<LabeledList.Item label="Notes"> <LabeledList.Item label="Rate of Progression">
{virus.desc} {virus.rate}
</LabeledList.Item> </LabeledList.Item>
<LabeledList.Item label="Severity" <LabeledList.Item label="Antibiotic Resistance">
color={severities[virus.severity]}> {virus.resistance}%
{virus.severity} </LabeledList.Item>
<LabeledList.Item label="Species Affected">
{virus.species}
</LabeledList.Item>
<LabeledList.Item label="Symptoms">
<LabeledList>
{virus.symptoms.map(s => (
<LabeledList.Item key={s.stage} label={s.stage + ". " + s.name}>
<Box inline color="label">Strength:</Box> {s.strength}&nbsp;
<Box inline color="label">Aggressiveness:</Box> {s.aggressiveness}
</LabeledList.Item>
))}
</LabeledList>
</LabeledList.Item> </LabeledList.Item>
</LabeledList> </LabeledList>
</Box> </Box>
@@ -91,7 +107,7 @@ export const MedicalRecords = (_properties, context) => {
width={800} width={800}
height={380} height={380}
resizable> resizable>
<ComplexModal /> <ComplexModal maxHeight="100%" maxWidth="80%" />
<Window.Content className="Layout__content--flexColumn"> <Window.Content className="Layout__content--flexColumn">
<LoginInfo /> <LoginInfo />
<TemporaryNotice /> <TemporaryNotice />

File diff suppressed because one or more lines are too long