mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
Chem Master/Chem Dispenser 30/60u, + multibottle
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
#define MAX_MULTI_AMOUNT 20 // Max number of pills/patches that can be made at once
|
#define MAX_MULTI_AMOUNT 20 // Max number of pills/patches that can be made at once
|
||||||
#define MAX_UNITS_PER_PILL 60 // Max amount of units in a pill
|
#define MAX_UNITS_PER_PILL 60 // Max amount of units in a pill
|
||||||
#define MAX_UNITS_PER_PATCH 60 // Max amount of units in a patch
|
#define MAX_UNITS_PER_PATCH 60 // Max amount of units in a patch
|
||||||
|
#define MAX_UNITS_PER_BOTTLE 60 // Max amount of units in a bottle (it's volume)
|
||||||
#define MAX_CUSTOM_NAME_LEN 64 // Max length of a custom pill/condiment/whatever
|
#define MAX_CUSTOM_NAME_LEN 64 // Max length of a custom pill/condiment/whatever
|
||||||
|
|
||||||
|
|
||||||
@@ -245,7 +246,18 @@
|
|||||||
if("create_bottle")
|
if("create_bottle")
|
||||||
if(condi || !reagents.total_volume)
|
if(condi || !reagents.total_volume)
|
||||||
return
|
return
|
||||||
tgui_modal_input(src, id, "Please name your bottle:", null, arguments, reagents.get_master_reagent_name(), MAX_CUSTOM_NAME_LEN)
|
var/num = round(text2num(arguments["num"] || 1))
|
||||||
|
if(!num)
|
||||||
|
return
|
||||||
|
arguments["num"] = num
|
||||||
|
var/amount_per_bottle = CLAMP(reagents.total_volume / num, 0, MAX_UNITS_PER_BOTTLE)
|
||||||
|
var/default_name = "[reagents.get_master_reagent_name()] ([amount_per_bottle]u)"
|
||||||
|
var/bottles_text = num == 1 ? "new bottle" : "[num] new bottles"
|
||||||
|
tgui_modal_input(src, id, "Please name your [bottles_text]:", null, arguments, default_name, MAX_CUSTOM_NAME_LEN)
|
||||||
|
if("create_bottle_multiple")
|
||||||
|
if(condi || !reagents.total_volume)
|
||||||
|
return
|
||||||
|
tgui_modal_input(src, id, "Please enter the amount of bottles to make (max [MAX_MULTI_AMOUNT] at a time):", null, arguments, pillamount, 5)
|
||||||
if("change_bottle_style")
|
if("change_bottle_style")
|
||||||
var/list/choices = list()
|
var/list/choices = list()
|
||||||
for(var/i = 1 to MAX_BOTTLE_SPRITE)
|
for(var/i = 1 to MAX_BOTTLE_SPRITE)
|
||||||
@@ -357,16 +369,28 @@
|
|||||||
if("create_bottle")
|
if("create_bottle")
|
||||||
if(condi || !reagents.total_volume)
|
if(condi || !reagents.total_volume)
|
||||||
return
|
return
|
||||||
|
var/count = CLAMP(round(text2num(arguments["num"]) || 0), 0, MAX_MULTI_AMOUNT)
|
||||||
|
if(!count)
|
||||||
|
return
|
||||||
|
|
||||||
if(!length(answer))
|
if(!length(answer))
|
||||||
answer = reagents.get_master_reagent_name()
|
answer = reagents.get_master_reagent_name()
|
||||||
var/obj/item/weapon/reagent_containers/glass/bottle/P = new(loc)
|
var/amount_per_bottle = CLAMP(reagents.total_volume / count, 0, MAX_UNITS_PER_BOTTLE)
|
||||||
P.name = "[answer] bottle"
|
while(count--)
|
||||||
P.pixel_x = rand(-7, 7) // random position
|
if(reagents.total_volume <= 0)
|
||||||
P.pixel_y = rand(-7, 7)
|
to_chat(usr, "<span class='notice'>Not enough reagents to create these bottles!</span>")
|
||||||
P.icon_state = "bottle-[bottlesprite]" || "bottle-1"
|
return
|
||||||
reagents.trans_to_obj(P, 60)
|
var/obj/item/weapon/reagent_containers/glass/bottle/P = new(loc)
|
||||||
P.update_icon()
|
P.name = "[answer] bottle"
|
||||||
|
P.pixel_x = rand(-7, 7) // random position
|
||||||
|
P.pixel_y = rand(-7, 7)
|
||||||
|
P.icon_state = "bottle-[bottlesprite]" || "bottle-1"
|
||||||
|
reagents.trans_to_obj(P, amount_per_bottle)
|
||||||
|
P.update_icon()
|
||||||
|
if("create_bottle_multiple")
|
||||||
|
if(condi || !reagents.total_volume)
|
||||||
|
return
|
||||||
|
tgui_act("modal_open", list("id" = "create_bottle", "arguments" = list("num" = answer)), ui, state)
|
||||||
if("change_bottle_style")
|
if("change_bottle_style")
|
||||||
var/new_style = CLAMP(text2num(answer) || 0, 0, MAX_BOTTLE_SPRITE)
|
var/new_style = CLAMP(text2num(answer) || 0, 0, MAX_BOTTLE_SPRITE)
|
||||||
if(!new_style)
|
if(!new_style)
|
||||||
@@ -393,7 +417,9 @@
|
|||||||
mode = !mode
|
mode = !mode
|
||||||
if("ejectp")
|
if("ejectp")
|
||||||
if(loaded_pill_bottle)
|
if(loaded_pill_bottle)
|
||||||
loaded_pill_bottle.forceMove(loc)
|
loaded_pill_bottle.forceMove(get_turf(src))
|
||||||
|
if(Adjacent(usr) && !issilicon(usr))
|
||||||
|
usr.put_in_hands(loaded_pill_bottle)
|
||||||
loaded_pill_bottle = null
|
loaded_pill_bottle = null
|
||||||
if("print")
|
if("print")
|
||||||
if(printing || condi)
|
if(printing || condi)
|
||||||
@@ -842,4 +868,5 @@
|
|||||||
#undef MAX_MULTI_AMOUNT
|
#undef MAX_MULTI_AMOUNT
|
||||||
#undef MAX_UNITS_PER_PILL
|
#undef MAX_UNITS_PER_PILL
|
||||||
#undef MAX_UNITS_PER_PATCH
|
#undef MAX_UNITS_PER_PATCH
|
||||||
|
#undef MAX_UNITS_PER_BOTTLE
|
||||||
#undef MAX_CUSTOM_NAME_LEN
|
#undef MAX_CUSTOM_NAME_LEN
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Box, Button, Flex, LabeledList, ProgressBar, Slider, Section } from "..
|
|||||||
import { BeakerContents } from "../interfaces/common/BeakerContents";
|
import { BeakerContents } from "../interfaces/common/BeakerContents";
|
||||||
import { Window } from "../layouts";
|
import { Window } from "../layouts";
|
||||||
|
|
||||||
const dispenseAmounts = [5, 10, 20, 30, 40];
|
const dispenseAmounts = [5, 10, 20, 30, 40, 60];
|
||||||
const removeAmounts = [1, 5, 10];
|
const removeAmounts = [1, 5, 10];
|
||||||
|
|
||||||
export const ChemDispenser = (props, context) => {
|
export const ChemDispenser = (props, context) => {
|
||||||
@@ -35,11 +35,11 @@ const ChemDispenserSettings = (properties, context) => {
|
|||||||
{dispenseAmounts.map((a, i) => (
|
{dispenseAmounts.map((a, i) => (
|
||||||
<Flex.Item key={i} grow="1">
|
<Flex.Item key={i} grow="1">
|
||||||
<Button
|
<Button
|
||||||
icon="cog"
|
textAlign="center"
|
||||||
selected={amount === a}
|
selected={amount === a}
|
||||||
content={a}
|
content={a + "u"}
|
||||||
m="0"
|
m="0"
|
||||||
width="100%"
|
fluid
|
||||||
onClick={() => act('amount', {
|
onClick={() => act('amount', {
|
||||||
amount: a,
|
amount: a,
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Window } from "../layouts";
|
|||||||
import { BeakerContents } from './common/BeakerContents';
|
import { BeakerContents } from './common/BeakerContents';
|
||||||
import { ComplexModal, modalOpen, modalRegisterBodyOverride } from './common/ComplexModal';
|
import { ComplexModal, modalOpen, modalRegisterBodyOverride } from './common/ComplexModal';
|
||||||
|
|
||||||
const transferAmounts = [1, 5, 10];
|
const transferAmounts = [1, 5, 10, 30, 60];
|
||||||
const bottleStyles = [
|
const bottleStyles = [
|
||||||
"bottle.png",
|
"bottle.png",
|
||||||
"small_bottle.png",
|
"small_bottle.png",
|
||||||
@@ -91,14 +91,14 @@ export const ChemMaster = (props, context) => {
|
|||||||
isCondiment={condi}
|
isCondiment={condi}
|
||||||
bufferNonEmpty={buffer_reagents.length > 0}
|
bufferNonEmpty={buffer_reagents.length > 0}
|
||||||
/>
|
/>
|
||||||
<ChemMasterCustomization />
|
{/* <ChemMasterCustomization /> */}
|
||||||
</Window.Content>
|
</Window.Content>
|
||||||
</Window>
|
</Window>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const ChemMasterBeaker = (props, context) => {
|
const ChemMasterBeaker = (props, context) => {
|
||||||
const { act } = useBackend(context);
|
const { act, data } = useBackend(context);
|
||||||
const {
|
const {
|
||||||
beaker,
|
beaker,
|
||||||
beakerReagents,
|
beakerReagents,
|
||||||
@@ -245,12 +245,30 @@ const ChemMasterBuffer = (props, context) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ChemMasterProduction = (props, context) => {
|
const ChemMasterProduction = (props, context) => {
|
||||||
const { act } = useBackend(context);
|
const { act, data } = useBackend(context);
|
||||||
if (!props.bufferNonEmpty) {
|
if (!props.bufferNonEmpty) {
|
||||||
return (
|
return (
|
||||||
<Section
|
<Section
|
||||||
title="Production"
|
title="Production"
|
||||||
flexGrow="1">
|
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 height="100%">
|
||||||
<Flex.Item
|
<Flex.Item
|
||||||
grow="1"
|
grow="1"
|
||||||
@@ -271,7 +289,27 @@ const ChemMasterProduction = (props, context) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Section title="Production" flexGrow="1">
|
<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 ? (
|
{!props.isCondiment ? (
|
||||||
<ChemMasterProductionChemical />
|
<ChemMasterProductionChemical />
|
||||||
) : (
|
) : (
|
||||||
@@ -332,6 +370,11 @@ const ChemMasterProductionChemical = (props, context) => {
|
|||||||
mr="0.5rem"
|
mr="0.5rem"
|
||||||
mb="0.5rem"
|
mb="0.5rem"
|
||||||
onClick={() => modalOpen(context, 'create_bottle')}
|
onClick={() => modalOpen(context, 'create_bottle')}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
icon="plus-square"
|
||||||
|
content="Multiple"
|
||||||
|
onClick={() => modalOpen(context, 'create_bottle_multiple')}
|
||||||
/><br />
|
/><br />
|
||||||
<Button
|
<Button
|
||||||
mb="0.5rem"
|
mb="0.5rem"
|
||||||
@@ -372,38 +415,38 @@ const ChemMasterProductionCondiment = (props, context) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const ChemMasterCustomization = (props, context) => {
|
// const ChemMasterCustomization = (props, context) => {
|
||||||
const { act, data } = useBackend(context);
|
// const { act, data } = useBackend(context);
|
||||||
if (!data.loaded_pill_bottle) {
|
// if (!data.loaded_pill_bottle) {
|
||||||
return (
|
// return (
|
||||||
<Section title="Pill Bottle Customization">
|
// <Section title="Pill Bottle Customization">
|
||||||
<Box color="label">
|
// <Box color="label">
|
||||||
None loaded.
|
// None loaded.
|
||||||
</Box>
|
// </Box>
|
||||||
</Section>
|
// </Section>
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
return (
|
// return (
|
||||||
<Section title="Pill Bottle Customization">
|
// <Section title="Pill Bottle Customization">
|
||||||
<Button
|
// <Button
|
||||||
disabled={!data.loaded_pill_bottle}
|
// disabled={!data.loaded_pill_bottle}
|
||||||
icon="eject"
|
// icon="eject"
|
||||||
content={data.loaded_pill_bottle
|
// content={data.loaded_pill_bottle
|
||||||
? (
|
// ? (
|
||||||
data.loaded_pill_bottle_name
|
// data.loaded_pill_bottle_name
|
||||||
+ " ("
|
// + " ("
|
||||||
+ data.loaded_pill_bottle_contents_len
|
// + data.loaded_pill_bottle_contents_len
|
||||||
+ "/"
|
// + "/"
|
||||||
+ data.loaded_pill_bottle_storage_slots
|
// + data.loaded_pill_bottle_storage_slots
|
||||||
+ ")"
|
// + ")"
|
||||||
)
|
// )
|
||||||
: "None loaded"}
|
// : "None loaded"}
|
||||||
mb="0.5rem"
|
// mb="0.5rem"
|
||||||
onClick={() => act('ejectp')}
|
// onClick={() => act('ejectp')}
|
||||||
/>
|
// />
|
||||||
</Section>
|
// </Section>
|
||||||
);
|
// );
|
||||||
};
|
// };
|
||||||
|
|
||||||
modalRegisterBodyOverride('analyze', analyzeModalBodyOverride);
|
modalRegisterBodyOverride('analyze', analyzeModalBodyOverride);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user