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,7 +266,9 @@
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.
queue = list() var/confirm = alert(usr, "Are you sure you want to clear the running queue?", "Confirm", "No", "Yes")
if(confirm == "Yes")
queue = list()
if("eject_catalyst") if("eject_catalyst")
// Removes the catalyst bottle from the machine. // Removes the catalyst bottle from the machine.
if(!busy && catalyst) if(!busy && catalyst)
@@ -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/index = params["rm_index"] var/confirm = alert(usr, "Are you sure you want to remove this recipe?", "Confirm", "No", "Yes")
if(index in recipes) if(confirm == "Yes")
recipes -= recipes[index] var/index = params["rm_index"]
if(index in recipes)
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 (
<Section <Flex
title="Beaker" height="100%"
buttons={headerButton}> width="100%"
{beaker direction="column">
? ( <Flex.Item
<BeakerContents height={0}
beakerLoaded grow={1}>
beakerContents={beakerReagents} <Section
buttons={(chemical, i) => ( height="100%"
<Box mb={(i < beakerReagents.length - 1) && "2px"}> title="Queue"
overflowY="auto"
buttons={
<Fragment>
<Button
disabled={!!busy}
color="bad"
icon="wrench"
content={use_catalyst ? "Catalyst Active" : "Catalyst Disabled"}
onClick={() => act("toggle_catalyst")} />
<Button.Confirm
disabled={!queue.length}
color="bad"
icon="minus-circle"
content="Clear Queue"
onClick={() => act("clear_queue")} />
{(!busy && (
<Button <Button
content="Analyze" disabled={!queue.length}
mb="0" content="Start Queue"
onClick={() => modalOpen(context, 'analyze', { icon="play"
idx: i + 1, onClick={() => act("start_queue")} />
beaker: 1, ))
})} }
/> </Fragment>
{transferAmounts.map((am, j) => }>
(<Button <Flex
key={j} direction="column"
content={am} height="100%">
mb="0" <Flex.Item>
onClick={() => act('add', { <ChemSynthesizerQueueList />
id: chemical.id, </Flex.Item>
amount: am, </Flex>
})} </Section>
/>) <Section
)} height="100%"
<Button title="Recipes"
content="All" overflowY="auto">
mb="0" <Flex
onClick={() => act('add', { direction="column"
id: chemical.id, height="100%">
amount: chemical.volume, <Flex.Item>
})} <ChemSynthesizerRecipeList />
/> </Flex.Item>
<Button </Flex>
content="Custom.." </Section>
mb="0" </Flex.Item>
onClick={() => modalOpen(context, 'addcustom', { </Flex>
id: chemical.id,
})}
/>
</Box>
)}
/>
)
: (
<Box color="label">
No beaker loaded.
</Box>
)}
</Section>
); );
}; };
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 {