switching branches again

This commit is contained in:
Darlantan
2022-06-04 19:38:56 -04:00
parent 97f330698a
commit 65203bbfa0
2 changed files with 90 additions and 161 deletions

View File

@@ -266,6 +266,8 @@
queue -= queue[index] queue -= queue[index]
if("clear_queue") if("clear_queue")
// Remove all entries from the queue except the currently processing recipe. // Remove all entries from the queue except the currently processing recipe.
var/confirm = alert(usr, "Are you sure you want to clear the running queue?", "Confirm", "No", "Yes")
if(confirm == "Yes")
queue = list() queue = list()
if("eject_catalyst") if("eject_catalyst")
// Removes the catalyst bottle from the machine. // Removes the catalyst bottle from the machine.
@@ -300,9 +302,15 @@
if("rem_recipe") if("rem_recipe")
// Allows the user to remove recipes while the machine is idle. // Allows the user to remove recipes while the machine is idle.
if(!busy) if(!busy)
var/confirm = alert(usr, "Are you sure you want to remove this recipe?", "Confirm", "No", "Yes")
if(confirm == "Yes")
var/index = params["rm_index"] var/index = params["rm_index"]
if(index in recipes) if(index in recipes)
recipes -= recipes[index] recipes -= recipes[index]
if("exp_recipe")
// Allows the user to export recipes to chat formatted for easy importing.
var/index = params["exp_index"]
export_recipe(usr, index)
if("add_queue") if("add_queue")
// Adds recipes to the queue. // Adds recipes to the queue.
if(queue.len >= SYNTHESIZER_MAX_QUEUE) if(queue.len >= SYNTHESIZER_MAX_QUEUE)

View File

@@ -3,182 +3,103 @@ import { useBackend } from "../backend";
import { Box, Button, Flex, Icon, LabeledList, Section } from "../components"; import { Box, Button, Flex, Icon, LabeledList, Section } from "../components";
import { Window } from "../layouts"; import { Window } from "../layouts";
import { BeakerContents } from './common/BeakerContents'; import { BeakerContents } from './common/BeakerContents';
import { ComplexModal, modalOpen, modalRegisterBodyOverride } from './common/ComplexModal';
const transferAmounts = [1, 5, 10, 30, 60]; export const ChemSynthesizer = (props, context) => {
const bottleStyles = [
"bottle.png",
"small_bottle.png",
"wide_bottle.png",
"round_bottle.png",
"reagent_bottle.png",
];
const analyzeModalBodyOverride = (modal, context) => {
const { act, data } = useBackend(context);
const result = modal.args.analysis;
return (
<Section
level={2}
m="-1rem"
pb="1rem"
title={data.condi ? "Condiment Analysis" : "Reagent Analysis"}>
<Box mx="0.5rem">
<LabeledList>
<LabeledList.Item label="Name">
{result.name}
</LabeledList.Item>
<LabeledList.Item label="Description">
{(result.desc || "").length > 0 ? result.desc : "N/A"}
</LabeledList.Item>
{result.blood_type && (
<Fragment>
<LabeledList.Item label="Blood type">
{result.blood_type}
</LabeledList.Item>
<LabeledList.Item
label="Blood DNA"
className="LabeledList__breakContents">
{result.blood_dna}
</LabeledList.Item>
</Fragment>
)}
{!data.condi && (
<Button
icon={data.printing ? 'spinner' : 'print'}
disabled={data.printing}
iconSpin={!!data.printing}
ml="0.5rem"
content="Print"
onClick={() => act('print', {
idx: result.idx,
beaker: modal.args.beaker,
})}
/>
)}
</LabeledList>
</Box>
</Section>
);
};
export const ChemMaster = (props, context) => {
const { data } = useBackend(context);
const {
condi,
beaker,
beaker_reagents = [],
buffer_reagents = [],
mode,
} = data;
return ( return (
<Window <Window
width={575} width={575}
height={500} height={500}
resizable> resizable>
<ComplexModal /> <Window.Content className="Layout__content--flexColumn">
<Window.Content scrollable className="Layout__content--flexColumn"> <ChemSynthesizerQueueRecipes />
<ChemMasterBeaker <ChemSynthesizerQueueList />
beaker={beaker} <ChemSynthesizerRecipeList />
beakerReagents={beaker_reagents} <ChemSynthesizerChemicals />
bufferNonEmpty={buffer_reagents.length > 0} <ChemSynthesizerSettings />
/>
<ChemMasterBuffer
mode={mode}
bufferReagents={buffer_reagents}
/>
<ChemMasterProduction
isCondiment={condi}
bufferNonEmpty={buffer_reagents.length > 0}
/>
{/* <ChemMasterCustomization /> */}
</Window.Content> </Window.Content>
</Window> </Window>
); );
}; };
const ChemMasterBeaker = (props, context) => { const ChemSynthesizerQueueRecipes = (props, context) => {
const { act, data } = useBackend(context); const { act, data } = useBackend(context);
const { const {
beaker, busy,
beakerReagents, use_catalyst,
bufferNonEmpty, queue = [],
} = props; } = data;
let headerButton = bufferNonEmpty ? (
<Button.Confirm
icon="eject"
disabled={!beaker}
content="Eject and Clear Buffer"
onClick={() => act('eject')}
/>
) : (
<Button
icon="eject"
disabled={!beaker}
content="Eject and Clear Buffer"
onClick={() => act('eject')}
/>
);
return ( return (
<Flex
height="100%"
width="100%"
direction="column">
<Flex.Item
height={0}
grow={1}>
<Section <Section
title="Beaker" height="100%"
buttons={headerButton}> title="Queue"
{beaker overflowY="auto"
? ( buttons={
<BeakerContents <Fragment>
beakerLoaded
beakerContents={beakerReagents}
buttons={(chemical, i) => (
<Box mb={(i < beakerReagents.length - 1) && "2px"}>
<Button <Button
content="Analyze" disabled={!!busy}
mb="0" color="bad"
onClick={() => modalOpen(context, 'analyze', { icon="wrench"
idx: i + 1, content={use_catalyst ? "Catalyst Active" : "Catalyst Disabled"}
beaker: 1, onClick={() => act("toggle_catalyst")} />
})} <Button.Confirm
/> disabled={!queue.length}
{transferAmounts.map((am, j) => color="bad"
(<Button icon="minus-circle"
key={j} content="Clear Queue"
content={am} onClick={() => act("clear_queue")} />
mb="0" {(!busy && (
onClick={() => act('add', {
id: chemical.id,
amount: am,
})}
/>)
)}
<Button <Button
content="All" disabled={!queue.length}
mb="0" content="Start Queue"
onClick={() => act('add', { icon="play"
id: chemical.id, onClick={() => act("start_queue")} />
amount: chemical.volume, ))
})} }
/> </Fragment>
<Button }>
content="Custom.." <Flex
mb="0" direction="column"
onClick={() => modalOpen(context, 'addcustom', { height="100%">
id: chemical.id, <Flex.Item>
})} <ChemSynthesizerQueueList />
/> </Flex.Item>
</Box> </Flex>
)}
/>
)
: (
<Box color="label">
No beaker loaded.
</Box>
)}
</Section> </Section>
<Section
height="100%"
title="Recipes"
overflowY="auto">
<Flex
direction="column"
height="100%">
<Flex.Item>
<ChemSynthesizerRecipeList />
</Flex.Item>
</Flex>
</Section>
</Flex.Item>
</Flex>
); );
}; };
const ChemSynthesizerQueueList = (props, context) => {
const { act, data } = useBackend(context);
const {
queue = [],
use_catalyst,
queue = [],
} = data;
};
const ChemMasterBuffer = (props, context) => { const ChemMasterBuffer = (props, context) => {
const { act } = useBackend(context); const { act } = useBackend(context);
const { const {