Fixes Round 1

This commit is contained in:
AffectedArc07
2020-07-30 08:45:15 +01:00
parent 9401b38450
commit cd032d511f
3 changed files with 135 additions and 120 deletions
+15 -10
View File
@@ -6,7 +6,7 @@
circuit = /obj/item/circuitboard/sm_monitor
light_color = LIGHT_COLOR_YELLOW
/// Cache-list of all supermatter shards
var/list/supermatters = list()
var/list/supermatters
/// Last status of the active supermatter for caching purposes
var/last_status
/// Reference to the active shard
@@ -55,10 +55,10 @@
var/other_moles = air.total_trace_moles()
var/TM = air.total_moles()
if(TM)
data["SM_gas_O2"] = round(100*air.oxygen/TM,0.01)
data["SM_gas_CO2"] = round(100*air.carbon_dioxide/TM,0.01)
data["SM_gas_N2"] = round(100*air.nitrogen/TM,0.01)
data["SM_gas_PL"] = round(100*air.toxins/TM,0.01)
data["SM_gas_O2"] = round(100*air.oxygen/TM, 0.01)
data["SM_gas_CO2"] = round(100*air.carbon_dioxide/TM, 0.01)
data["SM_gas_N2"] = round(100*air.nitrogen/TM, 0.01)
data["SM_gas_PL"] = round(100*air.toxins/TM, 0.01)
if(other_moles)
data["SM_gas_OTHER"] = round(100 * other_moles / TM, 0.01)
else
@@ -71,15 +71,16 @@
data["SM_gas_OTHER"] = 0
else
var/list/SMS = list()
for(var/obj/machinery/power/supermatter_shard/S in supermatters)
for(var/I in supermatters)
var/obj/machinery/power/supermatter_shard/S = I
var/area/A = get_area(S)
if(!A)
continue
SMS.Add(list(list(
"area_name" = A.name,
"integrity" = S.get_integrity(),
"uid" = S.UID()
"area_name" = A.name,
"integrity" = S.get_integrity(),
"uid" = S.UID()
)))
data["active"] = FALSE
@@ -99,7 +100,7 @@
return
for(var/obj/machinery/power/supermatter_shard/S in SSair.atmos_machinery)
// Delaminating, not within coverage, not on a tile.
if(!(is_station_level(S.z) || is_mining_level(S.z) || atoms_share_level(S, T) || !istype(S.loc, /turf/simulated/)))
if(!(is_station_level(S.z) || is_mining_level(S.z) || atoms_share_level(S, T) || !istype(S.loc, /turf/simulated/)))
continue
supermatters.Add(S)
@@ -125,6 +126,9 @@
if(..())
return
if(stat & (BROKEN|NOPOWER))
return
. = TRUE
switch(action)
@@ -136,6 +140,7 @@
for(var/obj/machinery/power/supermatter_shard/S in supermatters)
if(S.UID() == newuid)
active = S
break
if("back")
active = null
@@ -4,6 +4,15 @@ import { Section, Box, Button, Table, LabeledList, ProgressBar } from '../compon
import { Window } from '../layouts';
import { TableRow, TableCell } from '../components/Table';
export const SupermatterMonitor = (props, context) => {
const { act, data } = useBackend(context);
if (data.active === 0) {
return <SupermatterMonitorListView />;
} else {
return <SupermatterMonitorDataView />;
}
};
const powerToColor = power => {
if (power > 300) {
return 'bad';
@@ -34,114 +43,115 @@ const pressureToColor = pressure => {
}
};
export const SupermatterMonitor = (props, context) => {
const SupermatterMonitorListView = (props, context) => {
const { act, data } = useBackend(context);
if (data.active === 0) {
return (
<Window>
<Window.Content scrollable>
<Section title="Detected Supermatter Shards" buttons={
<Button
icon="sync"
content="Refresh"
onClick={() => act("refresh")}
/>
}>
<Box m={1}>
{data.supermatters.length === 0 ? (
<h3>No shards detected</h3>
) : (
<Table>
<Table.Row header>
<TableCell>Area</TableCell>
<TableCell>Integrity</TableCell>
<TableCell>Details</TableCell>
</Table.Row>
{data.supermatters.map(sm => (
<TableRow key={sm}>
<TableCell>{sm.area_name}</TableCell>
<TableCell>{sm.integrity}%</TableCell>
<TableCell>
<Button
icon="sign-in-alt"
content="View"
onClick={() => act('view', {
view: sm.uid,
})}
/>
</TableCell>
</TableRow>
))}
</Table>
)}
</Box>
</Section>
</Window.Content>
</Window>
);
} else {
return (
<Window>
<Window.Content>
<Section title="Crystal Status" buttons={
<Button
icon="caret-square-left"
content="Back"
onClick={() => act("back")}
/>
}>
<LabeledList>
<LabeledList.Item label="Core Integrity">
<ProgressBar
ranges={{
good: [95, Infinity],
average: [80, 94],
bad: [-Infinity, 79],
}}
minValue={0}
maxValue={100}
value={data.SM_integrity}>
{data.SM_integrity}%
</ProgressBar>
</LabeledList.Item>
<LabeledList.Item label="Relative EER">
<Box color={powerToColor(data.SM_power)}>
{data.SM_power} MeV/cm3
</Box>
</LabeledList.Item>
<LabeledList.Item label="Temperature">
<Box color={temperatureToColor(data.SM_ambienttemp)}>
{data.SM_ambienttemp} K
</Box>
</LabeledList.Item>
<LabeledList.Item label="Pressure">
<Box color={pressureToColor(data.SM_ambientpressure)}>
{data.SM_ambientpressure} kPa
</Box>
</LabeledList.Item>
</LabeledList>
</Section>
<Section title="Gas Composition">
<LabeledList>
<LabeledList.Item label="Oxygen">
{data.SM_gas_O2}%
</LabeledList.Item>
<LabeledList.Item label="Carbon Dioxide">
{data.SM_gas_CO2}%
</LabeledList.Item>
<LabeledList.Item label="Nitrogen">
{data.SM_gas_N2}%
</LabeledList.Item>
<LabeledList.Item label="Plasma">
{data.SM_gas_PL}%
</LabeledList.Item>
<LabeledList.Item label="Other">
{data.SM_gas_OTHER}%
</LabeledList.Item>
</LabeledList>
</Section>
</Window.Content>
</Window>
);
}
return (
<Window>
<Window.Content scrollable>
<Section title="Detected Supermatter Shards" buttons={
<Button
icon="sync"
content="Refresh"
onClick={() => act("refresh")}
/>
}>
<Box m={1}>
{data.supermatters.length === 0 ? (
<h3>No shards detected</h3>
) : (
<Table>
<Table.Row header>
<TableCell>Area</TableCell>
<TableCell>Integrity</TableCell>
<TableCell>Details</TableCell>
</Table.Row>
{data.supermatters.map(sm => (
<TableRow key={sm}>
<TableCell>{sm.area_name}</TableCell>
<TableCell>{sm.integrity}%</TableCell>
<TableCell>
<Button
icon="sign-in-alt"
content="View"
onClick={() => act('view', {
view: sm.uid,
})}
/>
</TableCell>
</TableRow>
))}
</Table>
)}
</Box>
</Section>
</Window.Content>
</Window>
);
};
const SupermatterMonitorDataView = (props, context) => {
const { act, data } = useBackend(context);
return (
<Window>
<Window.Content>
<Section title="Crystal Status" buttons={
<Button
icon="caret-square-left"
content="Back"
onClick={() => act("back")}
/>
}>
<LabeledList>
<LabeledList.Item label="Core Integrity">
<ProgressBar
ranges={{
good: [95, Infinity],
average: [80, 94],
bad: [-Infinity, 79],
}}
minValue="0"
maxValue="100"
value={data.SM_integrity}>
{data.SM_integrity}%
</ProgressBar>
</LabeledList.Item>
<LabeledList.Item label="Relative EER">
<Box color={powerToColor(data.SM_power)}>
{data.SM_power} MeV/cm3
</Box>
</LabeledList.Item>
<LabeledList.Item label="Temperature">
<Box color={temperatureToColor(data.SM_ambienttemp)}>
{data.SM_ambienttemp} K
</Box>
</LabeledList.Item>
<LabeledList.Item label="Pressure">
<Box color={pressureToColor(data.SM_ambientpressure)}>
{data.SM_ambientpressure} kPa
</Box>
</LabeledList.Item>
</LabeledList>
</Section>
<Section title="Gas Composition">
<LabeledList>
<LabeledList.Item label="Oxygen">
{data.SM_gas_O2}%
</LabeledList.Item>
<LabeledList.Item label="Carbon Dioxide">
{data.SM_gas_CO2}%
</LabeledList.Item>
<LabeledList.Item label="Nitrogen">
{data.SM_gas_N2}%
</LabeledList.Item>
<LabeledList.Item label="Plasma">
{data.SM_gas_PL}%
</LabeledList.Item>
<LabeledList.Item label="Other">
{data.SM_gas_OTHER}%
</LabeledList.Item>
</LabeledList>
</Section>
</Window.Content>
</Window>
);
};
File diff suppressed because one or more lines are too long