Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 240ef00

Browse files
Attempt #1 at fixing drink update bug
1 parent 5e469d8 commit 240ef00

File tree

2 files changed

+118
-26
lines changed

2 files changed

+118
-26
lines changed

code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,24 @@
2525
//Mixer for dispencing drinks
2626
var/obj/item/reagent_containers/mixer
2727

28+
var/list/drink_list
29+
var/list/mixer_list
30+
2831
/obj/machinery/food_cart_TGUI/ui_interact(mob/user, datum/tgui/ui)
2932
ui = SStgui.try_update_ui(user, src, ui)
3033
if(!ui)
3134
ui = new(user, src, "FoodCart", name)
3235
ui.open()
33-
ui.set_autoupdate(TRUE)
3436

3537
/obj/machinery/food_cart_TGUI/ui_data(mob/user)
3638
//Define variables from UI
3739
var/list/data = list()
3840
data["food"] = list()
3941
data["storage"] = list()
4042

43+
drink_list = reagents.reagent_list
44+
mixer_list = mixer.reagents.reagent_list
45+
4146
//Loop through food list for data to send to food tab
4247
for(var/item_detail in food_ui_list)
4348
//Create needed list and variable for geting data for UI
@@ -61,7 +66,7 @@
6166
data["food"] += list(details)
6267

6368
//Loop through drink list for data to send to cart's reagent storage tab
64-
for(var/datum/reagent/drink in reagents.reagent_list)
69+
for(var/datum/reagent/drink in drink_list)
6570
var/list/details = list()
6671

6772
//Get information for UI
@@ -73,7 +78,7 @@
7378
data["mainDrinks"] += list(details)
7479

7580
//Loop through drink list for data to send to cart's reagent mixer tab
76-
for(var/datum/reagent/drink in mixer.reagents.reagent_list)
81+
for(var/datum/reagent/drink in mixer_list)
7782
var/list/details = list()
7883

7984
//Get information for UI

tgui/packages/tgui/interfaces/FoodCart.tsx

Lines changed: 110 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -216,18 +216,27 @@ const DrinkTab = (props, context) => {
216216
return (
217217
<Stack vertical>
218218
<Stack.Item>
219-
<Section
220-
title="Glass Storage"
221-
textAlign="center">
222-
<GlassRow />
223-
</Section>
224-
</Stack.Item>
225-
<Stack.Item>
226-
<Section
227-
title="Drink Capacity"
228-
textAlign="center">
229-
<DrinkCapacityRow />
230-
</Section>
219+
<Flex
220+
justify="center">
221+
<Flex.Item
222+
grow={1}
223+
mr={1}>
224+
<Section
225+
title="Glass Storage"
226+
textAlign="center">
227+
<GlassRow />
228+
</Section>
229+
</Flex.Item>
230+
<Flex.Item
231+
grow={1}
232+
mr={1}>
233+
<Section
234+
title="Drink Capacity"
235+
textAlign="center">
236+
<DrinkCapacityRow />
237+
</Section>
238+
</Flex.Item>
239+
</Flex>
231240
</Stack.Item>
232241
<Stack.Item>
233242
<Section
@@ -260,7 +269,7 @@ const DrinkTab = (props, context) => {
260269
circular
261270
tooltip="Reagents to be poured into drinking glasses"
262271
icon="info"/>}>
263-
<MixerDrinkRow />
272+
<MixerDrinkRow1 />
264273
</Section>
265274
</Stack.Item>
266275
</Stack>
@@ -318,7 +327,6 @@ const DrinkTransferRow = (props, context) => {
318327

319328
return(
320329
<Flex
321-
align="center"
322330
justify="center">
323331
{dispence_options.map(amount => (
324332
<Flex.Item
@@ -470,15 +478,17 @@ const MixerDrinkRow = (props, context) => {
470478
</Table.Cell>
471479
</Table.Row>
472480
))}
473-
<Table.Row
474-
align="center">
475-
<Button
476-
fluid
477-
content="Pour glass"
478-
textAlign="center"
479-
fontSize="16px"
480-
onClick={() => act("pour")}
481-
/>
481+
<Table.Row
482+
justify="center">
483+
<Table.Cell>
484+
<Button
485+
fluid
486+
content="Pour glass"
487+
textAlign="center"
488+
fontSize="16px"
489+
onClick={() => act("pour")}
490+
/>
491+
</Table.Cell>
482492
</Table.Row>
483493
</Table>
484494
);
@@ -497,3 +507,80 @@ const MixerDrinkRow = (props, context) => {
497507
);
498508
}
499509
};
510+
511+
const MixerDrinkRow1 = (props, context) => {
512+
// Get data from ui_data in backend code
513+
const { act, data } = useBackend<Tab>(context);
514+
// Get drink information for cart's container from data
515+
const { mixerDrinks = [] } = data;
516+
517+
if(mixerDrinks.length > 0) {
518+
return (
519+
// Create Table for horizontal format
520+
<Flex
521+
direction="column">
522+
{/* Use map to create dynamic rows based on the contents of drinks, with drink being the individual item and its stats */}
523+
{mixerDrinks.map(reagent => (
524+
// Start row for holding ui elements and given data
525+
<Stack
526+
key={reagent.drink_name}
527+
justify="space-around"
528+
fontSize="14px">
529+
<Stack.Item
530+
textAlign="left"
531+
bold>
532+
{/* Get name */}
533+
{capitalize(reagent.drink_name)}
534+
</Stack.Item>
535+
<Stack.Item>
536+
{/* Get amount of reagent in storage */}
537+
{reagent.drink_quantity}u
538+
</Stack.Item>
539+
<Stack.Item>
540+
{/* Make dispense button */}
541+
<Button
542+
fluid
543+
content="Transfer Back"
544+
textAlign="center"
545+
fontSize="16px"
546+
width="175px"
547+
// Disable if there is none of the reagent in storage
548+
disabled={(
549+
reagent.drink_quantity === 0
550+
)}
551+
onClick={() => act("transferBack", {
552+
itemPath: reagent.drink_type_path,
553+
})}
554+
/>
555+
</Stack.Item>
556+
</Stack>
557+
))}
558+
<Table.Row
559+
justify="center">
560+
<Table.Cell>
561+
<Button
562+
fluid
563+
content="Pour glass"
564+
textAlign="center"
565+
fontSize="16px"
566+
onClick={() => act("pour")}
567+
/>
568+
</Table.Cell>
569+
</Table.Row>
570+
</Flex>
571+
);
572+
} else {
573+
return (
574+
<Table>
575+
<Table.Row>
576+
<Table.Cell
577+
fontSize="14px"
578+
textAlign="center"
579+
bold>
580+
Mixer Storage Empty
581+
</Table.Cell>
582+
</Table.Row>
583+
</Table>
584+
);
585+
}
586+
}

0 commit comments

Comments
 (0)