mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
switching branches AGAIN
This commit is contained in:
@@ -222,7 +222,12 @@
|
||||
|
||||
// Queue and recipe lists might not be formatted correctly here. Delete this once you've confirmed.
|
||||
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)
|
||||
start_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"])
|
||||
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
|
||||
queue -= queue[index]
|
||||
if("clear_queue")
|
||||
// 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()
|
||||
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")
|
||||
// Removes the catalyst bottle from the machine.
|
||||
if(!busy && catalyst)
|
||||
@@ -281,7 +291,9 @@
|
||||
if("emergency_stop")
|
||||
// Stops everything if that's desirable for some reason.
|
||||
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")
|
||||
// Bottles the reaction mixture if stalled.
|
||||
if(!busy)
|
||||
@@ -307,6 +319,8 @@
|
||||
var/index = params["rm_index"]
|
||||
if(index in recipes)
|
||||
recipes -= recipes[index]
|
||||
else
|
||||
to_chat(usr, "<span class='warning'>You cannot remove recipes while the machine is running!</span>")
|
||||
if("exp_recipe")
|
||||
// Allows the user to export recipes to chat formatted for easy importing.
|
||||
var/index = params["exp_index"]
|
||||
|
||||
@@ -27,6 +27,7 @@ const ChemSynthesizerQueueRecipes = (props, context) => {
|
||||
busy,
|
||||
use_catalyst,
|
||||
queue = [],
|
||||
production_mode,
|
||||
} = data;
|
||||
|
||||
return (
|
||||
@@ -45,7 +46,8 @@ const ChemSynthesizerQueueRecipes = (props, context) => {
|
||||
<Fragment>
|
||||
<Button
|
||||
disabled={!!busy}
|
||||
color="bad"
|
||||
color={use_catalyst ? "green" : "bad"}
|
||||
tooltip="Enable/Disable the catalyst BEFORE starting the queue."
|
||||
icon="wrench"
|
||||
content={use_catalyst ? "Catalyst Active" : "Catalyst Disabled"}
|
||||
onClick={() => act("toggle_catalyst")} />
|
||||
@@ -53,12 +55,12 @@ const ChemSynthesizerQueueRecipes = (props, context) => {
|
||||
disabled={!queue.length}
|
||||
color="bad"
|
||||
icon="minus-circle"
|
||||
content="Clear Queue"
|
||||
tooltip="Clear Queue"
|
||||
onClick={() => act("clear_queue")} />
|
||||
{(!busy && (
|
||||
<Button
|
||||
disabled={!queue.length}
|
||||
content="Start Queue"
|
||||
tooltip="Start Queue"
|
||||
icon="play"
|
||||
onClick={() => act("start_queue")} />
|
||||
))
|
||||
@@ -76,7 +78,15 @@ const ChemSynthesizerQueueRecipes = (props, context) => {
|
||||
<Section
|
||||
height="100%"
|
||||
title="Recipes"
|
||||
overflowY="auto">
|
||||
overflowY="auto"
|
||||
buttons = {
|
||||
<Fragment>
|
||||
<Button
|
||||
icon="plus"
|
||||
tooltip={production_mode ? "Import Recipe" : "Generate Recipe"}
|
||||
onClick={() => act("add_recipe")} />
|
||||
</Fragment>
|
||||
}>
|
||||
<Flex
|
||||
direction="column"
|
||||
height="100%">
|
||||
@@ -94,289 +104,70 @@ const ChemSynthesizerQueueList = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const {
|
||||
queue = [],
|
||||
use_catalyst,
|
||||
queue = [],
|
||||
busy,
|
||||
} = data;
|
||||
|
||||
};
|
||||
|
||||
const ChemMasterBuffer = (props, context) => {
|
||||
const { act } = useBackend(context);
|
||||
const {
|
||||
mode,
|
||||
bufferReagents = [],
|
||||
} = props;
|
||||
return (
|
||||
<Section
|
||||
title="Buffer"
|
||||
buttons={
|
||||
<Box color="label">
|
||||
Transferring to
|
||||
<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 (
|
||||
return = (
|
||||
<LabeledList>
|
||||
<LabeledList.Item label="Pills">
|
||||
<Button
|
||||
icon="circle"
|
||||
content="One (60u max)"
|
||||
mr="0.5rem"
|
||||
onClick={() => modalOpen(context, 'create_pill')}
|
||||
/>
|
||||
<Button
|
||||
icon="plus-circle"
|
||||
content="Multiple"
|
||||
mb="0.5rem"
|
||||
onClick={() => modalOpen(context, 'create_pill_multiple')}
|
||||
/><br />
|
||||
<Button
|
||||
onClick={() => modalOpen(context, 'change_pill_style')}>
|
||||
<div style={
|
||||
"display: inline-block;"
|
||||
+ "width: 16px;"
|
||||
+ "height: 16px;"
|
||||
+ "vertical-align: middle;"
|
||||
+ "background: url(pill" + data.pillsprite + ".png);"
|
||||
+ "background-size: 200%;"
|
||||
+ "background-position: left -10px bottom -6px;"
|
||||
} />
|
||||
Style
|
||||
</Button>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Patches">
|
||||
<Button
|
||||
icon="square"
|
||||
content="One (60u max)"
|
||||
mr="0.5rem"
|
||||
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>
|
||||
{queue.length && queue.map(item => {
|
||||
if ((item.index === 1) && !!busy) {
|
||||
return (
|
||||
<LabeledList.Item label={item.name} labelColor="bad">
|
||||
{
|
||||
<Box>
|
||||
<Button
|
||||
disabled icon="trash">
|
||||
Delete
|
||||
</Button>
|
||||
</Box>
|
||||
}
|
||||
</LabeledList.Item>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<LabeledList.Item label={item.name}>
|
||||
<Button
|
||||
icon="trash"
|
||||
onClick={() => act("rem_queue", {
|
||||
q_index: item.index
|
||||
})}>
|
||||
Delete
|
||||
</Button>
|
||||
</LabeledList.Item>
|
||||
);
|
||||
}) || (
|
||||
<Box m={1}>
|
||||
Queue Empty.
|
||||
</Box>
|
||||
)}
|
||||
</LabeledList>
|
||||
);
|
||||
};
|
||||
|
||||
const ChemMasterProductionCondiment = (props, context) => {
|
||||
const { act } = useBackend(context);
|
||||
return (
|
||||
<Fragment>
|
||||
<Button
|
||||
icon="box"
|
||||
content="Create condiment pack (10u max)"
|
||||
mb="0.5rem"
|
||||
onClick={() => modalOpen(context, 'create_condi_pack')}
|
||||
/><br />
|
||||
<Button
|
||||
icon="wine-bottle"
|
||||
content="Create bottle (60u max)"
|
||||
mb="0"
|
||||
onClick={() => act('create_condi_bottle')}
|
||||
/>
|
||||
</Fragment>
|
||||
const ChemSynthesizerRecipeList = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const {
|
||||
recipes = [],
|
||||
busy,
|
||||
} = data;
|
||||
|
||||
return = (
|
||||
<LabeledList>
|
||||
{recipes.length && recipes.map(item => {
|
||||
<LabeledList.Item label={item.name}>
|
||||
<Button
|
||||
icon="trash"
|
||||
onClick={() => act("rem_queue", {
|
||||
q_index: item.index
|
||||
})}>
|
||||
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);
|
||||
};
|
||||
Reference in New Issue
Block a user