switching branches AGAIN

This commit is contained in:
Darlantan
2022-06-06 17:53:39 -04:00
parent 65203bbfa0
commit 9199f5a281
2 changed files with 93 additions and 288 deletions

View File

@@ -222,7 +222,12 @@
// Queue and recipe lists might not be formatted correctly here. Delete this once you've confirmed. // Queue and recipe lists might not be formatted correctly here. Delete this once you've confirmed.
data["queue"] = queue data["queue"] = queue
data["recipes"] = recipes
// Convert the recipes list into an array of strings. The UI does not need the associative list attached to each string.
var/list/tmp_recipes = list()
data["recipes"] = tmp_recipes
for(var/i = 1, i <= recipes.len, i++)
tmp_recipes[i] = recipes[i]
@@ -259,16 +264,21 @@
if(!busy) if(!busy)
start_queue() start_queue()
if("rem_queue") if("rem_queue")
// Remove a single entry from the queue. // Remove a single entry from the queue. Sanity checks also prevent removing the first entry if the machine is busy though UI should already prevent that.
var/index = text2num(params["q_index"]) var/index = text2num(params["q_index"])
if(!isnum(index) || !ISINTEGER(index) || !istype(queue) || (index<1 || index>length(queue))) if(!isnum(index) || !ISINTEGER(index) || !istype(queue) || (index<1 || index>length(queue) || (busy && index == 1)))
return return
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") var/confirm = alert(usr, "Are you sure you want to clear the running queue?", "Confirm", "No", "Yes")
if(confirm == "Yes") if(confirm == "Yes")
queue = list() if(busy)
// Oh no, I've broken code convention to remove all entries but the first.
for(var/i = queue.len, i >= 2, i--)
queue -= queue[i]
else
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)
@@ -281,7 +291,9 @@
if("emergency_stop") if("emergency_stop")
// Stops everything if that's desirable for some reason. // Stops everything if that's desirable for some reason.
if(busy) if(busy)
stall() var/confirm = alert(usr, "Are you sure you want to stall the machine?", "Confirm", "Yes", "No")
if(confirm == "Yes")
stall()
if("bottle_product") if("bottle_product")
// Bottles the reaction mixture if stalled. // Bottles the reaction mixture if stalled.
if(!busy) if(!busy)
@@ -307,6 +319,8 @@
var/index = params["rm_index"] var/index = params["rm_index"]
if(index in recipes) if(index in recipes)
recipes -= recipes[index] recipes -= recipes[index]
else
to_chat(usr, "<span class='warning'>You cannot remove recipes while the machine is running!</span>")
if("exp_recipe") if("exp_recipe")
// Allows the user to export recipes to chat formatted for easy importing. // Allows the user to export recipes to chat formatted for easy importing.
var/index = params["exp_index"] var/index = params["exp_index"]

View File

@@ -27,6 +27,7 @@ const ChemSynthesizerQueueRecipes = (props, context) => {
busy, busy,
use_catalyst, use_catalyst,
queue = [], queue = [],
production_mode,
} = data; } = data;
return ( return (
@@ -45,7 +46,8 @@ const ChemSynthesizerQueueRecipes = (props, context) => {
<Fragment> <Fragment>
<Button <Button
disabled={!!busy} disabled={!!busy}
color="bad" color={use_catalyst ? "green" : "bad"}
tooltip="Enable/Disable the catalyst BEFORE starting the queue."
icon="wrench" icon="wrench"
content={use_catalyst ? "Catalyst Active" : "Catalyst Disabled"} content={use_catalyst ? "Catalyst Active" : "Catalyst Disabled"}
onClick={() => act("toggle_catalyst")} /> onClick={() => act("toggle_catalyst")} />
@@ -53,12 +55,12 @@ const ChemSynthesizerQueueRecipes = (props, context) => {
disabled={!queue.length} disabled={!queue.length}
color="bad" color="bad"
icon="minus-circle" icon="minus-circle"
content="Clear Queue" tooltip="Clear Queue"
onClick={() => act("clear_queue")} /> onClick={() => act("clear_queue")} />
{(!busy && ( {(!busy && (
<Button <Button
disabled={!queue.length} disabled={!queue.length}
content="Start Queue" tooltip="Start Queue"
icon="play" icon="play"
onClick={() => act("start_queue")} /> onClick={() => act("start_queue")} />
)) ))
@@ -76,7 +78,15 @@ const ChemSynthesizerQueueRecipes = (props, context) => {
<Section <Section
height="100%" height="100%"
title="Recipes" title="Recipes"
overflowY="auto"> overflowY="auto"
buttons = {
<Fragment>
<Button
icon="plus"
tooltip={production_mode ? "Import Recipe" : "Generate Recipe"}
onClick={() => act("add_recipe")} />
</Fragment>
}>
<Flex <Flex
direction="column" direction="column"
height="100%"> height="100%">
@@ -94,289 +104,70 @@ const ChemSynthesizerQueueList = (props, context) => {
const { act, data } = useBackend(context); const { act, data } = useBackend(context);
const { const {
queue = [], queue = [],
use_catalyst, busy,
queue = [],
} = data; } = data;
}; return = (
const ChemMasterBuffer = (props, context) => {
const { act } = useBackend(context);
const {
mode,
bufferReagents = [],
} = props;
return (
<Section
title="Buffer"
buttons={
<Box color="label">
Transferring to&nbsp;
<Button
icon={mode ? "flask" : "trash"}
color={!mode && "bad"}
content={mode ? "Beaker" : "Disposal"}
onClick={() => act('toggle')}
/>
</Box>
}>
{(bufferReagents.length > 0)
? (
<BeakerContents
beakerLoaded
beakerContents={bufferReagents}
buttons={(chemical, i) => (
<Box mb={(i < bufferReagents.length - 1) && "2px"}>
<Button
content="Analyze"
mb="0"
onClick={() => modalOpen(context, 'analyze', {
idx: i + 1,
beaker: 0,
})}
/>
{transferAmounts.map((am, i) =>
(<Button
key={i}
content={am}
mb="0"
onClick={() => act('remove', {
id: chemical.id,
amount: am,
})}
/>)
)}
<Button
content="All"
mb="0"
onClick={() => act('remove', {
id: chemical.id,
amount: chemical.volume,
})}
/>
<Button
content="Custom.."
mb="0"
onClick={() => modalOpen(context, 'removecustom', {
id: chemical.id,
})}
/>
</Box>
)}
/>
)
: (
<Box color="label">
Buffer is empty.
</Box>
)}
</Section>
);
};
const ChemMasterProduction = (props, context) => {
const { act, data } = useBackend(context);
if (!props.bufferNonEmpty) {
return (
<Section
title="Production"
flexGrow="1"
buttons={
<Button
disabled={!data.loaded_pill_bottle}
icon="eject"
content={data.loaded_pill_bottle
? (
data.loaded_pill_bottle_name
+ " ("
+ data.loaded_pill_bottle_contents_len
+ "/"
+ data.loaded_pill_bottle_storage_slots
+ ")"
)
: "No pill bottle loaded"}
mb="0.5rem"
onClick={() => act('ejectp')}
/>
}>
<Flex height="100%">
<Flex.Item
grow="1"
align="center"
textAlign="center"
color="label">
<Icon
name="tint-slash"
mt="0.5rem"
mb="0.5rem"
size="5"
/><br />
Buffer is empty.
</Flex.Item>
</Flex>
</Section>
);
}
return (
<Section
title="Production"
flexGrow="1"
buttons={
<Button
disabled={!data.loaded_pill_bottle}
icon="eject"
content={data.loaded_pill_bottle
? (
data.loaded_pill_bottle_name
+ " ("
+ data.loaded_pill_bottle_contents_len
+ "/"
+ data.loaded_pill_bottle_storage_slots
+ ")"
)
: "No pill bottle loaded"}
mb="0.5rem"
onClick={() => act('ejectp')}
/>
}>
{!props.isCondiment ? (
<ChemMasterProductionChemical />
) : (
<ChemMasterProductionCondiment />
)}
</Section>
);
};
const ChemMasterProductionChemical = (props, context) => {
const { act, data } = useBackend(context);
return (
<LabeledList> <LabeledList>
<LabeledList.Item label="Pills"> {queue.length && queue.map(item => {
<Button if ((item.index === 1) && !!busy) {
icon="circle" return (
content="One (60u max)" <LabeledList.Item label={item.name} labelColor="bad">
mr="0.5rem" {
onClick={() => modalOpen(context, 'create_pill')} <Box>
/> <Button
<Button disabled icon="trash">
icon="plus-circle" Delete
content="Multiple" </Button>
mb="0.5rem" </Box>
onClick={() => modalOpen(context, 'create_pill_multiple')} }
/><br /> </LabeledList.Item>
<Button );
onClick={() => modalOpen(context, 'change_pill_style')}> }
<div style={ return (
"display: inline-block;" <LabeledList.Item label={item.name}>
+ "width: 16px;" <Button
+ "height: 16px;" icon="trash"
+ "vertical-align: middle;" onClick={() => act("rem_queue", {
+ "background: url(pill" + data.pillsprite + ".png);" q_index: item.index
+ "background-size: 200%;" })}>
+ "background-position: left -10px bottom -6px;" Delete
} /> </Button>
Style </LabeledList.Item>
</Button> );
</LabeledList.Item> }) || (
<LabeledList.Item label="Patches"> <Box m={1}>
<Button Queue Empty.
icon="square" </Box>
content="One (60u max)" )}
mr="0.5rem" </LabeledList>
onClick={() => modalOpen(context, 'create_patch')}
/>
<Button
icon="plus-square"
content="Multiple"
onClick={() => modalOpen(context, 'create_patch_multiple')}
/>
</LabeledList.Item>
<LabeledList.Item label="Bottle">
<Button
icon="wine-bottle"
content="Create bottle (60u max)"
mr="0.5rem"
mb="0.5rem"
onClick={() => modalOpen(context, 'create_bottle')}
/>
<Button
icon="plus-square"
content="Multiple"
onClick={() => modalOpen(context, 'create_bottle_multiple')}
/><br />
<Button
mb="0.5rem"
onClick={() => modalOpen(context, 'change_bottle_style')}>
<div style={
"display: inline-block;"
+ "width: 16px;"
+ "height: 16px;"
+ "vertical-align: middle;"
+ "background: url(bottle-" + data.bottlesprite + ".png);"
+ "background-size: 200%;"
+ "background-position: left -10px bottom -6px;"
} />
Style
</Button>
</LabeledList.Item>
</LabeledList>
); );
}; };
const ChemMasterProductionCondiment = (props, context) => { const ChemSynthesizerRecipeList = (props, context) => {
const { act } = useBackend(context); const { act, data } = useBackend(context);
return ( const {
<Fragment> recipes = [],
<Button busy,
icon="box" } = data;
content="Create condiment pack (10u max)"
mb="0.5rem" return = (
onClick={() => modalOpen(context, 'create_condi_pack')} <LabeledList>
/><br /> {recipes.length && recipes.map(item => {
<Button <LabeledList.Item label={item.name}>
icon="wine-bottle" <Button
content="Create bottle (60u max)" icon="trash"
mb="0" onClick={() => act("rem_queue", {
onClick={() => act('create_condi_bottle')} q_index: item.index
/> })}>
</Fragment> Delete
</Button>
</LabeledList.Item>
}) || (
<Box m={1}>
No Recipes.
</Box>
)}
</LabeledList>
); );
}; };
// const ChemMasterCustomization = (props, context) => {
// const { act, data } = useBackend(context);
// if (!data.loaded_pill_bottle) {
// return (
// <Section title="Pill Bottle Customization">
// <Box color="label">
// None loaded.
// </Box>
// </Section>
// );
// }
// return (
// <Section title="Pill Bottle Customization">
// <Button
// disabled={!data.loaded_pill_bottle}
// icon="eject"
// content={data.loaded_pill_bottle
// ? (
// data.loaded_pill_bottle_name
// + " ("
// + data.loaded_pill_bottle_contents_len
// + "/"
// + data.loaded_pill_bottle_storage_slots
// + ")"
// )
// : "None loaded"}
// mb="0.5rem"
// onClick={() => act('ejectp')}
// />
// </Section>
// );
// };
modalRegisterBodyOverride('analyze', analyzeModalBodyOverride);