mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-17 05:32:27 +00:00
- SmartFridge has been tweaked to look better - ChemMaster no longer puts the units in bottle names by default - Trinary filter reads last_flow_rate again - Operating computer now works based off percentage of health, rather than real health (note, a tesh at -50 won't die until -100, but it'll trigger the -100% alarm) - Clicking on the knob in the canister UI no longer brings up a number input too small to enter values in the valid range. For right now, the knob stays, but this may be reconsidered in favor of a NumberInput if more people would prefer accessibility over skeuomorphism UI design. - Pipe dispenser has a bent pipe option again
145 lines
4.5 KiB
JavaScript
145 lines
4.5 KiB
JavaScript
import { toFixed } from 'common/math';
|
|
import { Fragment } from 'inferno';
|
|
import { useBackend } from '../backend';
|
|
import { AnimatedNumber, Box, Button, Icon, Knob, LabeledControls, LabeledList, Section, Tooltip } from '../components';
|
|
import { formatSiUnit } from '../format';
|
|
import { Window } from '../layouts';
|
|
|
|
export const Canister = (props, context) => {
|
|
const { act, data } = useBackend(context);
|
|
const {
|
|
connected,
|
|
can_relabel,
|
|
pressure,
|
|
releasePressure,
|
|
defaultReleasePressure,
|
|
minReleasePressure,
|
|
maxReleasePressure,
|
|
valveOpen,
|
|
holding,
|
|
} = data;
|
|
return (
|
|
<Window
|
|
width={360}
|
|
height={242}
|
|
resizable>
|
|
<Window.Content>
|
|
<Section
|
|
title="Canister"
|
|
buttons={(
|
|
<Button
|
|
icon="pencil-alt"
|
|
disabled={!can_relabel}
|
|
content="Relabel"
|
|
onClick={() => act('relabel')} />
|
|
)}>
|
|
<LabeledControls>
|
|
<LabeledControls.Item
|
|
minWidth="66px"
|
|
label="Tank Pressure">
|
|
<AnimatedNumber
|
|
value={pressure}
|
|
format={value => {
|
|
if (value < 10000) {
|
|
return toFixed(value) + ' kPa';
|
|
}
|
|
return formatSiUnit(value * 1000, 1, 'Pa');
|
|
}} />
|
|
</LabeledControls.Item>
|
|
<LabeledControls.Item label="Regulator">
|
|
<Box
|
|
position="relative"
|
|
left="-8px">
|
|
<Knob
|
|
forcedInputWidth="60px"
|
|
size={1.25}
|
|
color={!!valveOpen && 'yellow'}
|
|
value={releasePressure}
|
|
unit="kPa"
|
|
minValue={minReleasePressure}
|
|
maxValue={maxReleasePressure}
|
|
stepPixelSize={1}
|
|
onDrag={(e, value) => act('pressure', {
|
|
pressure: value,
|
|
})} />
|
|
<Button
|
|
fluid
|
|
position="absolute"
|
|
top="-2px"
|
|
right="-20px"
|
|
color="transparent"
|
|
icon="fast-forward"
|
|
onClick={() => act('pressure', {
|
|
pressure: maxReleasePressure,
|
|
})} />
|
|
<Button
|
|
fluid
|
|
position="absolute"
|
|
top="16px"
|
|
right="-20px"
|
|
color="transparent"
|
|
icon="undo"
|
|
onClick={() => act('pressure', {
|
|
pressure: defaultReleasePressure,
|
|
})} />
|
|
</Box>
|
|
</LabeledControls.Item>
|
|
<LabeledControls.Item label="Valve">
|
|
<Button
|
|
my={0.5}
|
|
width="50px"
|
|
lineHeight={2}
|
|
fontSize="11px"
|
|
color={valveOpen
|
|
? (holding ? 'caution' : 'danger')
|
|
: null}
|
|
content={valveOpen ? 'Open' : 'Closed'}
|
|
onClick={() => act('valve')} />
|
|
</LabeledControls.Item>
|
|
<LabeledControls.Item
|
|
mr={1}
|
|
label="Port">
|
|
<Box position="relative">
|
|
<Icon
|
|
size={1.25}
|
|
name={connected? 'plug' : 'times'}
|
|
color={connected? 'good' : 'bad'} />
|
|
<Tooltip
|
|
content={connected
|
|
? 'Connected'
|
|
: 'Disconnected'}
|
|
position="top" />
|
|
</Box>
|
|
</LabeledControls.Item>
|
|
</LabeledControls>
|
|
</Section>
|
|
<Section
|
|
title="Holding Tank"
|
|
buttons={!!holding && (
|
|
<Button
|
|
icon="eject"
|
|
color={valveOpen && 'danger'}
|
|
content="Eject"
|
|
onClick={() => act('eject')} />
|
|
)}>
|
|
{!!holding && (
|
|
<LabeledList>
|
|
<LabeledList.Item label="Label">
|
|
{holding.name}
|
|
</LabeledList.Item>
|
|
<LabeledList.Item label="Pressure">
|
|
<AnimatedNumber value={holding.pressure} /> kPa
|
|
</LabeledList.Item>
|
|
</LabeledList>
|
|
)}
|
|
{!holding && (
|
|
<Box color="average">
|
|
No Holding Tank
|
|
</Box>
|
|
)}
|
|
</Section>
|
|
</Window.Content>
|
|
</Window>
|
|
);
|
|
};
|