Reverting changes for citadels modifications

This commit is contained in:
Artur
2020-05-07 18:56:38 +03:00
parent f3ee184672
commit 50881d42fd
2 changed files with 261 additions and 180 deletions

View File

@@ -157,7 +157,7 @@ export const ChemDispenser = (props, context) => {
<AnimatedNumber <AnimatedNumber
initial={0} initial={0}
value={data.beakerCurrentVolume} /> value={data.beakerCurrentVolume} />
/{data.beakerMaxVolume} units /{data.beakerMaxVolume} units, {data.beakerCurrentpH} pH
</Fragment> </Fragment>
) )
|| 'No beaker'} || 'No beaker'}

View File

@@ -1,26 +1,11 @@
import { Fragment } from 'inferno'; import { Component, Fragment } from 'inferno';
import { useBackend, useSharedState } from '../backend'; import { act } from '../byond';
import { AnimatedNumber, Box, Button, ColorBox, LabeledList, NumberInput, Section, Table } from '../components'; import { AnimatedNumber, Box, Button, ColorBox, LabeledList, NumberInput, Section, Table } from '../components';
import { Window } from '../layouts';
export const ChemMaster = (props, context) => { export const ChemMaster = props => {
const { data } = useBackend(context); const { state } = props;
const { screen } = data; const { config, data } = state;
return ( const { ref } = config;
<Window resizable>
<Window.Content scrollable>
{screen === 'analyze' && (
<AnalysisResults />
) || (
<ChemMasterContent />
)}
</Window.Content>
</Window>
);
};
const ChemMasterContent = (props, context) => {
const { act, data } = useBackend(context);
const { const {
screen, screen,
beakerContents = [], beakerContents = [],
@@ -32,9 +17,7 @@ const ChemMasterContent = (props, context) => {
pillBottleCurrentAmount, pillBottleCurrentAmount,
pillBottleMaxAmount, pillBottleMaxAmount,
} = data; } = data;
if (screen === 'analyze') {
return <AnalysisResults />;
}
return ( return (
<Fragment> <Fragment>
<Section <Section
@@ -50,7 +33,7 @@ const ChemMasterContent = (props, context) => {
<Button <Button
icon="eject" icon="eject"
content="Eject" content="Eject"
onClick={() => act('eject')} /> onClick={() => act(ref, 'eject')} />
</Fragment> </Fragment>
)}> )}>
{!isBeakerLoaded && ( {!isBeakerLoaded && (
@@ -67,6 +50,7 @@ const ChemMasterContent = (props, context) => {
{beakerContents.map(chemical => ( {beakerContents.map(chemical => (
<ChemicalBufferEntry <ChemicalBufferEntry
key={chemical.id} key={chemical.id}
state={state}
chemical={chemical} chemical={chemical}
transferTo="buffer" /> transferTo="buffer" />
))} ))}
@@ -83,7 +67,7 @@ const ChemMasterContent = (props, context) => {
color={data.mode ? 'good' : 'bad'} color={data.mode ? 'good' : 'bad'}
icon={data.mode ? 'exchange-alt' : 'times'} icon={data.mode ? 'exchange-alt' : 'times'}
content={data.mode ? 'Transfer' : 'Destroy'} content={data.mode ? 'Transfer' : 'Destroy'}
onClick={() => act('toggleMode')} /> onClick={() => act(ref, 'toggleMode')} />
</Fragment> </Fragment>
)}> )}>
{bufferContents.length === 0 && ( {bufferContents.length === 0 && (
@@ -95,6 +79,7 @@ const ChemMasterContent = (props, context) => {
{bufferContents.map(chemical => ( {bufferContents.map(chemical => (
<ChemicalBufferEntry <ChemicalBufferEntry
key={chemical.id} key={chemical.id}
state={state}
chemical={chemical} chemical={chemical}
transferTo="beaker" /> transferTo="beaker" />
))} ))}
@@ -102,7 +87,7 @@ const ChemMasterContent = (props, context) => {
</Section> </Section>
<Section <Section
title="Packaging"> title="Packaging">
<PackagingControls /> <PackagingControls state={state} />
</Section> </Section>
{!!isPillBottleLoaded && ( {!!isPillBottleLoaded && (
<Section <Section
@@ -115,7 +100,7 @@ const ChemMasterContent = (props, context) => {
<Button <Button
icon="eject" icon="eject"
content="Eject" content="Eject"
onClick={() => act('ejectPillBottle')} /> onClick={() => act(ref, 'ejectPillBottle')} />
</Fragment> </Fragment>
)} /> )} />
)} )}
@@ -125,9 +110,9 @@ const ChemMasterContent = (props, context) => {
const ChemicalBuffer = Table; const ChemicalBuffer = Table;
const ChemicalBufferEntry = (props, context) => { const ChemicalBufferEntry = props => {
const { act } = useBackend(context); const { state, chemical, transferTo } = props;
const { chemical, transferTo } = props; const { ref } = state.config;
return ( return (
<Table.Row key={chemical.id}> <Table.Row key={chemical.id}>
<Table.Cell color="label"> <Table.Cell color="label">
@@ -139,28 +124,28 @@ const ChemicalBufferEntry = (props, context) => {
<Table.Cell collapsing> <Table.Cell collapsing>
<Button <Button
content="1" content="1"
onClick={() => act('transfer', { onClick={() => act(ref, 'transfer', {
id: chemical.id, id: chemical.id,
amount: 1, amount: 1,
to: transferTo, to: transferTo,
})} /> })} />
<Button <Button
content="5" content="5"
onClick={() => act('transfer', { onClick={() => act(ref, 'transfer', {
id: chemical.id, id: chemical.id,
amount: 5, amount: 5,
to: transferTo, to: transferTo,
})} /> })} />
<Button <Button
content="10" content="10"
onClick={() => act('transfer', { onClick={() => act(ref, 'transfer', {
id: chemical.id, id: chemical.id,
amount: 10, amount: 10,
to: transferTo, to: transferTo,
})} /> })} />
<Button <Button
content="All" content="All"
onClick={() => act('transfer', { onClick={() => act(ref, 'transfer', {
id: chemical.id, id: chemical.id,
amount: 1000, amount: 1000,
to: transferTo, to: transferTo,
@@ -168,7 +153,7 @@ const ChemicalBufferEntry = (props, context) => {
<Button <Button
icon="ellipsis-h" icon="ellipsis-h"
title="Custom amount" title="Custom amount"
onClick={() => act('transfer', { onClick={() => act(ref, 'transfer', {
id: chemical.id, id: chemical.id,
amount: -1, amount: -1,
to: transferTo, to: transferTo,
@@ -176,7 +161,7 @@ const ChemicalBufferEntry = (props, context) => {
<Button <Button
icon="question" icon="question"
title="Analyze" title="Analyze"
onClick={() => act('analyze', { onClick={() => act(ref, 'analyze', {
id: chemical.id, id: chemical.id,
})} /> })} />
</Table.Cell> </Table.Cell>
@@ -196,7 +181,7 @@ const PackagingControlsItem = props => {
return ( return (
<LabeledList.Item label={label}> <LabeledList.Item label={label}>
<NumberInput <NumberInput
width="84px" width={14}
unit={amountUnit} unit={amountUnit}
step={1} step={1}
stepPixelSize={15} stepPixelSize={15}
@@ -204,129 +189,176 @@ const PackagingControlsItem = props => {
minValue={1} minValue={1}
maxValue={10} maxValue={10}
onChange={onChangeAmount} /> onChange={onChangeAmount} />
<Button <Button ml={1}
ml={1}
content="Create" content="Create"
onClick={onCreate} /> onClick={onCreate} />
<Box inline ml={1} color="label"> <Box inline ml={1}
{sideNote} color="label"
</Box> content={sideNote} />
</LabeledList.Item> </LabeledList.Item>
); );
}; };
const PackagingControls = (props, context) => { class PackagingControls extends Component {
const { act, data } = useBackend(context); constructor() {
const [ super();
pillAmount, this.state = {
setPillAmount, pillAmount: 1,
] = useSharedState(context, 'pillAmount', 1); patchAmount: 1,
const [ bottleAmount: 1,
patchAmount, packAmount: 1,
setPatchAmount, vialAmount: 1,
] = useSharedState(context, 'patchAmount', 1); dartAmount: 1,
const [ };
bottleAmount, }
setBottleAmount,
] = useSharedState(context, 'bottleAmount', 1);
const [
packAmount,
setPackAmount,
] = useSharedState(context, 'packAmount', 1);
const {
condi,
chosenPillStyle,
pillStyles = [],
} = data;
return (
<LabeledList>
{!condi && (
<LabeledList.Item label="Pill type">
{pillStyles.map(pill => (
<Button
key={pill.id}
width="30px"
selected={pill.id === chosenPillStyle}
textAlign="center"
color="transparent"
onClick={() => act('pillStyle', { id: pill.id })}>
<Box mx={-1} className={pill.className} />
</Button>
))}
</LabeledList.Item>
)}
{!condi && (
<PackagingControlsItem
label="Pills"
amount={pillAmount}
amountUnit="pills"
sideNote="max 50u"
onChangeAmount={(e, value) => setPillAmount(value)}
onCreate={() => act('create', {
type: 'pill',
amount: pillAmount,
volume: 'auto',
})} />
)}
{!condi && (
<PackagingControlsItem
label="Patches"
amount={patchAmount}
amountUnit="patches"
sideNote="max 40u"
onChangeAmount={(e, value) => setPatchAmount(value)}
onCreate={() => act('create', {
type: 'patch',
amount: patchAmount,
volume: 'auto',
})} />
)}
{!condi && (
<PackagingControlsItem
label="Bottles"
amount={bottleAmount}
amountUnit="bottles"
sideNote="max 30u"
onChangeAmount={(e, value) => setBottleAmount(value)}
onCreate={() => act('create', {
type: 'bottle',
amount: bottleAmount,
volume: 'auto',
})} />
)}
{!!condi && (
<PackagingControlsItem
label="Packs"
amount={packAmount}
amountUnit="packs"
sideNote="max 10u"
onChangeAmount={(e, value) => setPackAmount(value)}
onCreate={() => act('create', {
type: 'condimentPack',
amount: packAmount,
volume: 'auto',
})} />
)}
{!!condi && (
<PackagingControlsItem
label="Bottles"
amount={bottleAmount}
amountUnit="bottles"
sideNote="max 50u"
onChangeAmount={(e, value) => setBottleAmount(value)}
onCreate={() => act('create', {
type: 'condimentBottle',
amount: bottleAmount,
volume: 'auto',
})} />
)}
</LabeledList>
);
};
const AnalysisResults = (props, context) => { render() {
const { act, data } = useBackend(context); const { state, props } = this;
const { analyzeVars } = data; const { ref } = props.state.config;
const {
pillAmount,
patchAmount,
bottleAmount,
packAmount,
vialAmount,
dartAmount,
} = this.state;
const {
condi,
chosenPillStyle,
pillStyles = [],
} = props.state.data;
return (
<LabeledList>
{!condi && (
<LabeledList.Item label="Pill type">
{pillStyles.map(pill => (
<Button
key={pill.id}
width={5}
selected={pill.id === chosenPillStyle}
textAlign="center"
color="transparent"
onClick={() => act(ref, 'pillStyle', { id: pill.id })}>
<Box mx={-1} className={pill.className} />
</Button>
))}
</LabeledList.Item>
)}
{!condi && (
<PackagingControlsItem
label="Pills"
amount={pillAmount}
amountUnit="pills"
sideNote="max 50u"
onChangeAmount={(e, value) => this.setState({
pillAmount: value,
})}
onCreate={() => act(ref, 'create', {
type: 'pill',
amount: pillAmount,
volume: 'auto',
})} />
)}
{!condi && (
<PackagingControlsItem
label="Patches"
amount={patchAmount}
amountUnit="patches"
sideNote="max 40u"
onChangeAmount={(e, value) => this.setState({
patchAmount: value,
})}
onCreate={() => act(ref, 'create', {
type: 'patch',
amount: patchAmount,
volume: 'auto',
})} />
)}
{!condi && (
<PackagingControlsItem
label="Bottles"
amount={bottleAmount}
amountUnit="bottles"
sideNote="max 30u"
onChangeAmount={(e, value) => this.setState({
bottleAmount: value,
})}
onCreate={() => act(ref, 'create', {
type: 'bottle',
amount: bottleAmount,
volume: 'auto',
})} />
)}
{!condi && (
<PackagingControlsItem
label="Hypovials"
amount={vialAmount}
amountUnit="vials"
sideNote="max 60u"
onChangeAmount={(e, value) => this.setState({
vialAmount: value,
})}
onCreate={() => act(ref, 'create', {
type: 'hypoVial',
amount: vialAmount,
volume: 'auto',
})} />
)}
{!condi && (
<PackagingControlsItem
label="Smartdarts"
amount={dartAmount}
amountUnit="darts"
sideNote="max 20u"
onChangeAmount={(e, value) => this.setState({
dartAmount: value,
})}
onCreate={() => act(ref, 'create', {
type: 'smartDart',
amount: dartAmount,
volume: 'auto',
})} />
)}
{!!condi && (
<PackagingControlsItem
label="Packs"
amount={packAmount}
amountUnit="packs"
sideNote="max 10u"
onChangeAmount={(e, value) => this.setState({
packAmount: value,
})}
onCreate={() => act(ref, 'create', {
type: 'condimentPack',
amount: packAmount,
volume: 'auto',
})} />
)}
{!!condi && (
<PackagingControlsItem
label="Bottles"
amount={bottleAmount}
amountUnit="bottles"
sideNote="max 50u"
onChangeAmount={(e, value) => this.setState({
bottleAmount: value,
})}
onCreate={() => act(ref, 'create', {
type: 'condimentBottle',
amount: bottleAmount,
volume: 'auto',
})} />
)}
</LabeledList>
);
}
}
const AnalysisResults = props => {
const { state, fermianalyze } = props;
const { ref } = state.config;
const { analyzeVars } = state.data;
return ( return (
<Section <Section
title="Analysis Results" title="Analysis Results"
@@ -334,34 +366,83 @@ const AnalysisResults = (props, context) => {
<Button <Button
icon="arrow-left" icon="arrow-left"
content="Back" content="Back"
onClick={() => act('goScreen', { onClick={() => act(ref, 'goScreen', {
screen: 'home', screen: 'home',
})} /> })} />
)}> )}>
<LabeledList> {!fermianalyze && (
<LabeledList.Item label="Name"> <LabeledList>
{analyzeVars.name} <LabeledList.Item label="Name">
</LabeledList.Item> {analyzeVars.name}
<LabeledList.Item label="State"> </LabeledList.Item>
{analyzeVars.state} <LabeledList.Item label="State">
</LabeledList.Item> {analyzeVars.state}
<LabeledList.Item label="Color"> </LabeledList.Item>
<ColorBox color={analyzeVars.color} mr={1} /> <LabeledList.Item label="Color">
{analyzeVars.color} <ColorBox color={analyzeVars.color} mr={1} />
</LabeledList.Item> {analyzeVars.color}
<LabeledList.Item label="Description"> </LabeledList.Item>
{analyzeVars.description} <LabeledList.Item label="Description">
</LabeledList.Item> {analyzeVars.description}
<LabeledList.Item label="Metabolization Rate"> </LabeledList.Item>
{analyzeVars.metaRate} u/minute <LabeledList.Item label="Metabolization Rate">
</LabeledList.Item> {analyzeVars.metaRate} u/minute
<LabeledList.Item label="Overdose Threshold"> </LabeledList.Item>
{analyzeVars.overD} <LabeledList.Item label="Overdose Threshold">
</LabeledList.Item> {analyzeVars.overD}
<LabeledList.Item label="Addiction Threshold"> </LabeledList.Item>
{analyzeVars.addicD} <LabeledList.Item label="Addiction Threshold">
</LabeledList.Item> {analyzeVars.addicD}
</LabeledList> </LabeledList.Item>
</LabeledList>
)}
{!!fermianalyze && (
<LabeledList>
<LabeledList.Item label="Name">
{analyzeVars.name}
</LabeledList.Item>
<LabeledList.Item label="State">
{analyzeVars.state}
</LabeledList.Item>
<LabeledList.Item label="Color">
<ColorBox color={analyzeVars.color} mr={1} />
{analyzeVars.color}
</LabeledList.Item>
<LabeledList.Item label="Description">
{analyzeVars.description}
</LabeledList.Item>
<LabeledList.Item label="Metabolization Rate">
{analyzeVars.metaRate} u/minute
</LabeledList.Item>
<LabeledList.Item label="Overdose Threshold">
{analyzeVars.overD}
</LabeledList.Item>
<LabeledList.Item label="Addiction Threshold">
{analyzeVars.addicD}
</LabeledList.Item>
<LabeledList.Item label="Purity">
{analyzeVars.purityF}
</LabeledList.Item>
<LabeledList.Item label="Inverse Ratio">
{analyzeVars.inverseRatioF}
</LabeledList.Item>
<LabeledList.Item label="Purity E">
{analyzeVars.purityE}
</LabeledList.Item>
<LabeledList.Item label="Lower Optimal Temperature">
{analyzeVars.minTemp}
</LabeledList.Item>
<LabeledList.Item label="Upper Optimal Temperature">
{analyzeVars.maxTemp}
</LabeledList.Item>
<LabeledList.Item label="Explosive Temperature">
{analyzeVars.eTemp}
</LabeledList.Item>
<LabeledList.Item label="pH Peak">
{analyzeVars.pHpeak}
</LabeledList.Item>
</LabeledList>
)}
</Section> </Section>
); );
}; };