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

Commit c8211e8

Browse files
Tooltips and transfer amount
1 parent 5cdd029 commit c8211e8

File tree

2 files changed

+109
-47
lines changed

2 files changed

+109
-47
lines changed

code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
var/dispense_sound = 'sound/machines/click.ogg'
1919
//List used to show food items in UI
2020
var/list/food_ui_list = list()
21+
//List of transfer amounts for reagents
22+
var/list/transfer_list = list(5, 10, 15, 20, 30, 50)
23+
//What transfer amount is currently selected
24+
var/selected_transfer
2125
//List used to show reagents in cart's reagent storage
2226
var/list/drink_ui_list = list()
2327
//List used to show reagents in mixer's reagent storage
@@ -90,6 +94,8 @@
9094
data["storage_capacity"] = contents_capacity
9195
data["glass_quantity"] = glass_quantity
9296
data["glass_capacity"] = glass_capacity
97+
data["dispence_options"] = transfer_list
98+
data["dispence_selected"] = selected_transfer
9399
//Add the total_volumne of both cart and mixer storage for quantity
94100
data["drink_quantity"] = mixer.reagents.total_volume + reagents.total_volume
95101
data["drink_capacity"] = reagent_capacity
@@ -107,6 +113,8 @@
107113
if("dispense")
108114
var/itemPath = text2path(params["itemPath"])
109115
dispense_item(itemPath)
116+
if("amount")
117+
selected_transfer = text2num(params["dispenceAmount"])
110118

111119
/obj/machinery/food_cart_TGUI/Initialize(mapload)
112120
. = ..()

tgui/packages/tgui/interfaces/FoodCart.tsx

Lines changed: 101 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { storage } from 'common/storage';
22
import { capitalize } from 'common/string';
33
import { useBackend, useLocalState } from '../backend';
4-
import { Button, Section, Table, Tabs, Box, TextArea, Stack, Tooltip } from '../components';
4+
import { Button, Section, Table, Tabs, Box, TextArea, Stack, Tooltip, Flex } from '../components';
55
import { Window } from '../layouts';
66
import { resolveAsset } from './../assets';
77

@@ -46,6 +46,8 @@ type StorageStats = {
4646
glass_capacity: number;
4747
drink_quantity: number;
4848
drink_capacity: number;
49+
dispence_options: number[];
50+
dispence_selected: number;
4951
}
5052

5153
export const FoodCart = (props, context) => {
@@ -183,7 +185,7 @@ const FoodRow = (props, context) => {
183185
item.item_quantity === 0
184186
)}
185187
onClick={() => act("dispense", {
186-
itemPath: item.item_type_path,
188+
itemPath: item.item_type_path,
187189
})}
188190
/>
189191
</Table.Cell>
@@ -210,36 +212,56 @@ const FoodRow = (props, context) => {
210212
const DrinkTab = (props, context) => {
211213
// For organizing the food tab's information
212214
return (
213-
<Stack vertical>
214-
<Stack.Item>
215-
<Section
216-
title="Glass Storage"
217-
textAlign="center">
218-
<GlassRow />
219-
</Section>
220-
</Stack.Item>
221-
<Stack.Item>
222-
<Section
223-
title="Drink Capacity"
224-
textAlign="center">
225-
<DrinkCapacityRow />
226-
</Section>
227-
</Stack.Item>
228-
<Stack.Item>
229-
<Section
230-
title="Cart Drink Storage"
231-
textAlign="center">
232-
<MainDrinkRow />
233-
</Section>
234-
</Stack.Item>
235-
<Stack.Item>
236-
<Section
237-
title="Cart Mixer Storage"
238-
textAlign="center">
239-
<MixerDrinkRow />
240-
</Section>
241-
</Stack.Item>
242-
</Stack>
215+
<Stack vertical>
216+
<Stack.Item>
217+
<Section
218+
title="Glass Storage"
219+
textAlign="center">
220+
<GlassRow />
221+
</Section>
222+
</Stack.Item>
223+
<Stack.Item>
224+
<Section
225+
title="Drink Capacity"
226+
textAlign="center">
227+
<DrinkCapacityRow />
228+
</Section>
229+
</Stack.Item>
230+
<Stack.Item>
231+
<Section
232+
title="Transfer Amount"
233+
textAlign="center"
234+
buttons={<Button
235+
circular
236+
tooltip="Amount of reagents to be transfered or purged"
237+
icon="info"/>}
238+
>
239+
<DrinkTransferRow />
240+
</Section>
241+
</Stack.Item>
242+
<Stack.Item>
243+
<Section
244+
title="Cart Drink Storage"
245+
textAlign="center"
246+
buttons={<Button
247+
circular
248+
tooltip="Main reagent storage for the cart"
249+
icon="info"/>}>
250+
<MainDrinkRow />
251+
</Section>
252+
</Stack.Item>
253+
<Stack.Item>
254+
<Section
255+
title="Cart Mixer Storage"
256+
textAlign="center"
257+
buttons={<Button
258+
circular
259+
tooltip="Reagents to be poured into drinking glasses"
260+
icon="info"/>}>
261+
<MixerDrinkRow />
262+
</Section>
263+
</Stack.Item>
264+
</Stack>
243265
);
244266
};
245267

@@ -252,15 +274,15 @@ const GlassRow = (props, context) => {
252274

253275
return (
254276
<Table>
255-
<Table.Row>
256-
<Table.Cell
257-
fontSize="14px"
258-
textAlign="center"
259-
bold>
260-
{glass_quantity}/{glass_capacity}
261-
</Table.Cell>
262-
</Table.Row>
263-
</Table>
277+
<Table.Row>
278+
<Table.Cell
279+
fontSize="14px"
280+
textAlign="center"
281+
bold>
282+
{glass_quantity}/{glass_capacity}
283+
</Table.Cell>
284+
</Table.Row>
285+
</Table>
264286
);
265287
};
266288

@@ -285,6 +307,36 @@ const DrinkCapacityRow = (props, context) => {
285307
);
286308
}
287309

310+
const DrinkTransferRow = (props, context) => {
311+
// Get data from ui_data in backend code
312+
const { act, data } = useBackend<StorageStats>(context);
313+
// Get data for buttons
314+
const { dispence_options = [] } = data;
315+
const { dispence_selected } = data;
316+
317+
return(
318+
<Flex
319+
align="center"
320+
justify="center">
321+
{dispence_options.map(amount => (
322+
<Flex.Item
323+
grow={1}
324+
mr={0.5}>
325+
<Button
326+
fluid
327+
content={amount}
328+
textAlign="center"
329+
selected={amount === dispence_selected}
330+
onClick={() => act("amount", {
331+
dispenceAmount: amount,
332+
})}/>
333+
</Flex.Item>
334+
))}
335+
</Flex>
336+
);
337+
338+
}
339+
288340
const MainDrinkRow = (props, context) => {
289341
// Get data from ui_data in backend code
290342
const { act, data } = useBackend<Tab>(context);
@@ -302,11 +354,13 @@ const MainDrinkRow = (props, context) => {
302354
key={reagent.drink_name}
303355
fontSize="14px">
304356
<Table.Cell
305-
bold>
357+
width="75px"
358+
bold>
306359
{/* Get name */}
307360
{capitalize(reagent.drink_name)}
308361
</Table.Cell>
309-
<Table.Cell>
362+
<Table.Cell
363+
textAlign="left">
310364
{/* Get amount of reagent in storage */}
311365
{reagent.drink_quantity}u
312366
</Table.Cell>
@@ -325,7 +379,7 @@ const MainDrinkRow = (props, context) => {
325379
reagent.drink_quantity === 0
326380
)}
327381
onClick={() => act("purge", {
328-
itemPath: reagent.drink_type_path,
382+
itemPath: reagent.drink_type_path,
329383
})}
330384
/>
331385
</Table.Cell>
@@ -342,7 +396,7 @@ const MainDrinkRow = (props, context) => {
342396
reagent.drink_quantity === 0
343397
)}
344398
onClick={() => act("addMixer", {
345-
itemPath: reagent.drink_type_path,
399+
itemPath: reagent.drink_type_path,
346400
})}
347401
/>
348402
</Table.Cell>
@@ -404,7 +458,7 @@ const MixerDrinkRow = (props, context) => {
404458
reagent.drink_quantity === 0
405459
)}
406460
onClick={() => act("transferBack", {
407-
itemPath: reagent.drink_type_path,
461+
itemPath: reagent.drink_type_path,
408462
})}
409463
/>
410464
</Table.Cell>
@@ -419,7 +473,7 @@ const MixerDrinkRow = (props, context) => {
419473
reagent.drink_quantity === 0
420474
)}
421475
onClick={() => act("pour", {
422-
itemPath: reagent.drink_type_path,
476+
itemPath: reagent.drink_type_path,
423477
})}
424478
/>
425479
</Table.Cell>

0 commit comments

Comments
 (0)