mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-23 03:57:13 +01:00
Better Supermatter Monitor (#15364)
* Better Supermatter Monitor * even better * tweak * Update tgui.bundle.js * Update tgui.bundle.js
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
/obj/machinery/computer/sm_monitor/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
|
||||
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "SupermatterMonitor", name, 600, 325, master_ui, state)
|
||||
ui = new(user, src, ui_key, "SupermatterMonitor", name, 600, 350, master_ui, state)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/computer/sm_monitor/ui_data(mob/user)
|
||||
@@ -52,23 +52,23 @@
|
||||
data["SM_ambienttemp"] = air.temperature
|
||||
data["SM_ambientpressure"] = air.return_pressure()
|
||||
//data["SM_EPR"] = round((air.total_moles / air.group_multiplier) / 23.1, 0.01)
|
||||
var/other_moles = air.total_trace_moles()
|
||||
var/list/gasdata = list()
|
||||
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)
|
||||
if(other_moles)
|
||||
data["SM_gas_OTHER"] = round(100 * other_moles / TM, 0.01)
|
||||
else
|
||||
data["SM_gas_OTHER"] = 0
|
||||
gasdata.Add(list(list("name"= "Oxygen", "amount" = round(100 * air.oxygen / TM, 0.01))))
|
||||
gasdata.Add(list(list("name"= "Carbon Dioxide", "amount" = round(100 * air.carbon_dioxide / TM, 0.01))))
|
||||
gasdata.Add(list(list("name"= "Nitrogen", "amount" = round(100 * air.nitrogen / TM, 0.01))))
|
||||
gasdata.Add(list(list("name"= "Plasma", "amount" = round(100 * air.toxins / TM, 0.01))))
|
||||
gasdata.Add(list(list("name"= "Nitrous Oxide", "amount" = round(100 * air.sleeping_agent / TM, 0.01))))
|
||||
gasdata.Add(list(list("name"= "Agent B", "amount" = round(100 * air.agent_b / TM, 0.01))))
|
||||
else
|
||||
data["SM_gas_O2"] = 0
|
||||
data["SM_gas_CO2"] = 0
|
||||
data["SM_gas_N2"] = 0
|
||||
data["SM_gas_PH"] = 0
|
||||
data["SM_gas_OTHER"] = 0
|
||||
gasdata.Add(list(list("name"= "Oxygen", "amount" = 0)))
|
||||
gasdata.Add(list(list("name"= "Carbon Dioxide", "amount" = 0)))
|
||||
gasdata.Add(list(list("name"= "Nitrogen", "amount" = 0)))
|
||||
gasdata.Add(list(list("name"= "Plasma", "amount" = 0)))
|
||||
gasdata.Add(list(list("name"= "Nitrous Oxide", "amount" = 0)))
|
||||
gasdata.Add(list(list("name"= "Agent B", "amount" = 0)))
|
||||
data["gases"] = gasdata
|
||||
else
|
||||
var/list/SMS = list()
|
||||
for(var/I in supermatters)
|
||||
@@ -80,7 +80,7 @@
|
||||
SMS.Add(list(list(
|
||||
"area_name" = A.name,
|
||||
"integrity" = S.get_integrity(),
|
||||
"uid" = S.UID()
|
||||
"supermatter_id" = S.supermatter_id
|
||||
)))
|
||||
|
||||
data["active"] = FALSE
|
||||
@@ -136,9 +136,9 @@
|
||||
refresh()
|
||||
|
||||
if("view")
|
||||
var/newuid = params["view"]
|
||||
var/newuid = text2num(params["view"])
|
||||
for(var/obj/machinery/power/supermatter_crystal/S in supermatters)
|
||||
if(S.UID() == newuid)
|
||||
if(S.supermatter_id == newuid)
|
||||
active = S
|
||||
break
|
||||
|
||||
|
||||
@@ -81,6 +81,10 @@
|
||||
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF | FREEZE_PROOF
|
||||
var/base_icon_state = "darkmatter"
|
||||
|
||||
///The id of our supermatter
|
||||
var/supermatter_id = 1
|
||||
///The amount of supermatters that have been created this round
|
||||
var/static/global_supermatter_id = 1
|
||||
///Tracks the bolt color we are using
|
||||
var/zap_icon = DEFAULT_ZAP_ICON_STATE
|
||||
///The portion of the gasmix we're on that we should remove
|
||||
@@ -179,6 +183,7 @@
|
||||
|
||||
/obj/machinery/power/supermatter_crystal/Initialize(mapload)
|
||||
. = ..()
|
||||
supermatter_id = global_supermatter_id++
|
||||
SSair.atmos_machinery += src
|
||||
countdown = new(src)
|
||||
countdown.start()
|
||||
|
||||
@@ -227,6 +227,12 @@ const GASES = [
|
||||
'label': 'H₂',
|
||||
'color': 'white',
|
||||
},
|
||||
{
|
||||
'id': 'ab',
|
||||
'name': 'Agent B',
|
||||
'label': 'Agent B',
|
||||
'color': 'purple',
|
||||
},
|
||||
];
|
||||
|
||||
export const getGasLabel = (gasId, fallbackValue) => {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { sortBy } from 'common/collections';
|
||||
import { flow } from 'common/fp';
|
||||
import { toFixed } from 'common/math';
|
||||
import { Fragment } from 'inferno';
|
||||
import { useBackend } from '../backend';
|
||||
import { Section, Box, Button, Table, LabeledList, ProgressBar } from '../components';
|
||||
import { Section, Box, Button, Flex, Table, LabeledList, ProgressBar } from '../components';
|
||||
import { getGasColor, getGasLabel } from '../constants';
|
||||
import { Window } from '../layouts';
|
||||
import { TableRow, TableCell } from '../components/Table';
|
||||
|
||||
@@ -13,76 +17,50 @@ export const SupermatterMonitor = (props, context) => {
|
||||
}
|
||||
};
|
||||
|
||||
const powerToColor = power => {
|
||||
if (power > 300) {
|
||||
return 'bad';
|
||||
} else if (power > 150) {
|
||||
return 'average';
|
||||
} else {
|
||||
return 'good';
|
||||
}
|
||||
};
|
||||
|
||||
const temperatureToColor = temp => {
|
||||
if (temp > 5000) {
|
||||
return 'bad';
|
||||
} else if (temp > 4000) {
|
||||
return 'average';
|
||||
} else {
|
||||
return 'good';
|
||||
}
|
||||
};
|
||||
|
||||
const pressureToColor = pressure => {
|
||||
if (pressure > 10000) {
|
||||
return 'bad';
|
||||
} else if (pressure > 5000) {
|
||||
return 'average';
|
||||
} else {
|
||||
return 'good';
|
||||
}
|
||||
};
|
||||
const logScale = value => Math.log2(16 + Math.max(0, value)) - 4;
|
||||
|
||||
const SupermatterMonitorListView = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const { supermatters = [] } = data;
|
||||
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
|
||||
title="Detected Supermatters"
|
||||
buttons={(
|
||||
<Button
|
||||
icon="sync"
|
||||
content="Refresh"
|
||||
onClick={() => act("refresh")} />
|
||||
)}>
|
||||
<Table>
|
||||
{supermatters.map(sm => (
|
||||
<Table.Row key={sm.supermatter_id}>
|
||||
<Table.Cell>
|
||||
{sm.supermatter_id + '. ' + sm.area_name}
|
||||
</Table.Cell>
|
||||
<Table.Cell collapsing color="label">
|
||||
Integrity:
|
||||
</Table.Cell>
|
||||
<Table.Cell collapsing width="120px">
|
||||
<ProgressBar
|
||||
value={sm.integrity / 100}
|
||||
ranges={{
|
||||
good: [0.90, Infinity],
|
||||
average: [0.5, 0.90],
|
||||
bad: [-Infinity, 0.5],
|
||||
}} />
|
||||
</Table.Cell>
|
||||
<Table.Cell collapsing>
|
||||
<Button
|
||||
content="Details"
|
||||
onClick={() => act('view', {
|
||||
view: sm.supermatter_id,
|
||||
})} />
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</Section>
|
||||
</Window.Content>
|
||||
</Window>
|
||||
@@ -91,66 +69,104 @@ const SupermatterMonitorListView = (props, context) => {
|
||||
|
||||
const SupermatterMonitorDataView = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const {
|
||||
active,
|
||||
SM_integrity,
|
||||
SM_power,
|
||||
SM_ambienttemp,
|
||||
SM_ambientpressure,
|
||||
} = data;
|
||||
const gases = flow([
|
||||
gases => gases.filter(gas => gas.amount >= 0.01),
|
||||
sortBy(gas => -gas.amount),
|
||||
])(data.gases || []);
|
||||
const gasMaxAmount = Math.max(1, ...gases.map(gas => gas.amount));
|
||||
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>
|
||||
<Flex spacing={1}>
|
||||
<Flex.Item width="270px">
|
||||
<Section title="Metrics">
|
||||
<LabeledList>
|
||||
<LabeledList.Item label="Integrity">
|
||||
<ProgressBar
|
||||
value={SM_integrity / 100}
|
||||
ranges={{
|
||||
good: [0.90, Infinity],
|
||||
average: [0.5, 0.90],
|
||||
bad: [-Infinity, 0.5],
|
||||
}} />
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Relative EER">
|
||||
<ProgressBar
|
||||
value={SM_power}
|
||||
minValue={0}
|
||||
maxValue={5000}
|
||||
ranges={{
|
||||
good: [-Infinity, 5000],
|
||||
average: [5000, 7000],
|
||||
bad: [7000, Infinity],
|
||||
}}>
|
||||
{toFixed(SM_power) + ' MeV/cm3'}
|
||||
</ProgressBar>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Temperature">
|
||||
<ProgressBar
|
||||
value={logScale(SM_ambienttemp)}
|
||||
minValue={0}
|
||||
maxValue={logScale(10000)}
|
||||
ranges={{
|
||||
teal: [-Infinity, logScale(80)],
|
||||
good: [logScale(80), logScale(373)],
|
||||
average: [logScale(373), logScale(1000)],
|
||||
bad: [logScale(1000), Infinity],
|
||||
}}>
|
||||
{toFixed(SM_ambienttemp) + ' K'}
|
||||
</ProgressBar>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Pressure">
|
||||
<ProgressBar
|
||||
value={logScale(SM_ambientpressure)}
|
||||
minValue={0}
|
||||
maxValue={logScale(50000)}
|
||||
ranges={{
|
||||
good: [logScale(1), logScale(300)],
|
||||
average: [-Infinity, logScale(1000)],
|
||||
bad: [logScale(1000), Infinity],
|
||||
}}>
|
||||
{toFixed(SM_ambientpressure) + ' kPa'}
|
||||
</ProgressBar>
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
</Section>
|
||||
</Flex.Item>
|
||||
<Flex.Item grow={1} basis={0}>
|
||||
<Section
|
||||
title="Gases"
|
||||
buttons={(
|
||||
<Button
|
||||
icon="arrow-left"
|
||||
content="Back"
|
||||
onClick={() => act("back")} />
|
||||
)}>
|
||||
<LabeledList>
|
||||
{gases.map(gas => (
|
||||
<LabeledList.Item
|
||||
key={gas.name}
|
||||
label={getGasLabel(gas.name)}>
|
||||
<ProgressBar
|
||||
color={getGasColor(gas.name)}
|
||||
value={gas.amount}
|
||||
minValue={0}
|
||||
maxValue={gasMaxAmount}>
|
||||
{toFixed(gas.amount, 2) + '%'}
|
||||
</ProgressBar>
|
||||
</LabeledList.Item>
|
||||
))}
|
||||
</LabeledList>
|
||||
</Section>
|
||||
</Flex.Item>
|
||||
</Flex>
|
||||
</Window.Content>
|
||||
</Window>
|
||||
);
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user