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

Commit 4056ed7

Browse files
Finished purge and transfer functions
1 parent 7d5f654 commit 4056ed7

File tree

2 files changed

+74
-51
lines changed

2 files changed

+74
-51
lines changed

code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
//List of transfer amounts for reagents
2222
var/list/transfer_list = list(5, 10, 15, 20, 30, 50)
2323
//What transfer amount is currently selected
24-
var/selected_transfer = null
24+
var/selected_transfer = 0
2525
//Mixer for dispencing drinks
2626
var/obj/item/reagent_containers/mixer
2727

@@ -105,15 +105,25 @@
105105
return
106106

107107
switch(action)
108+
//Dispense food item
108109
if("dispense")
109110
var/itemPath = text2path(params["itemPath"])
110111
dispense_item(itemPath)
111-
if("amount")
112+
//Change selected_transfer
113+
if("transferNum")
112114
selected_transfer = params["dispenceAmount"]
115+
//Remove reagent from cart
113116
if("purge")
114-
return
117+
reagents.remove_reagent(text2path(params["itemPath"]), selected_transfer)
118+
//Add reagent to mixer
115119
if("addMixer")
116-
src.reagents.trans_id_to(mixer, text2path(params["itemPath"]),selected_transfer)
120+
src.reagents.trans_id_to(mixer, text2path(params["itemPath"]), selected_transfer)
121+
//Return reagent to storage
122+
if("transferBack")
123+
mixer.reagents.trans_id_to(src, text2path(params["itemPath"]), selected_transfer)
124+
//Pour glass
125+
if("pour")
126+
pour_glass()
117127

118128

119129
/obj/machinery/food_cart_TGUI/Initialize(mapload)
@@ -178,7 +188,20 @@
178188
else
179189
//Warn about full capacity
180190
user.balloon_alert(user, "No space!")
181-
191+
192+
/obj/machinery/food_cart_TGUI/proc/pour_glass(mob/user = usr)
193+
//Check if there are any glasses in storage
194+
if(glass_quantity > 0)
195+
glass_quantity -= 0
196+
//Create new glass
197+
var/obj/item/reagent_containers/food/drinks/drinkingglass/drink = new(loc)
198+
//Move all reagents in mixer to glass
199+
mixer.reagents.trans_to(drink, mixer.reagents.total_volume)
200+
//Attempt to put glass into user's hand
201+
user.put_in_hands(drink)
202+
else
203+
user.balloon_alert(user, "No Drinking Glasses!")
204+
182205
/obj/machinery/food_cart_TGUI/proc/find_amount(obj/item/counting_item, target_name = null, list/target_list = null)
183206
var/amount = 0
184207

tgui/packages/tgui/interfaces/FoodCart.tsx

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { storage } from 'common/storage';
22
import { capitalize } from 'common/string';
3+
import { Fragment } from 'inferno';
34
import { useBackend, useLocalState } from '../backend';
45
import { Button, Section, Table, Tabs, Box, TextArea, Stack, Tooltip, Flex } from '../components';
56
import { Window } from '../layouts';
67
import { resolveAsset } from './../assets';
78

8-
// Store data for cones and scoops within Data
9+
// Store data for UI elements within Data
910
type Data = {
1011
tabs: Tab[];
1112
}
@@ -39,6 +40,7 @@ type MixerDrinkStats = {
3940
drink_type_path: string;
4041
}
4142

43+
// Stats for all storage information
4244
type StorageStats = {
4345
contents_length: number;
4446
storage_capacity: number;
@@ -328,7 +330,7 @@ const DrinkTransferRow = (props, context) => {
328330
content={amount}
329331
textAlign="center"
330332
selected={amount === dispence_selected}
331-
onClick={() => act("amount", {
333+
onClick={() => act("transferNum", {
332334
dispenceAmount: amount,
333335
})}/>
334336
</Flex.Item>
@@ -375,7 +377,7 @@ const MainDrinkRow = (props, context) => {
375377
content="Purge"
376378
textAlign="center"
377379
fontSize="16px"
378-
// Dissable if there is none of the reagent in storage
380+
// Disable if there is none of the reagent in storage
379381
disabled={(
380382
reagent.drink_quantity === 0
381383
)}
@@ -430,56 +432,54 @@ const MixerDrinkRow = (props, context) => {
430432
if(mixerDrinks.length > 0) {
431433
return (
432434
// Create Table for horizontal format
433-
<Table>
435+
<Table
436+
direction="column">
434437
{/* Use map to create dynamic rows based on the contents of drinks, with drink being the individual item and its stats */}
435438
{mixerDrinks.map(reagent => (
436439
// Start row for holding ui elements and given data
437440
<Table.Row
441+
direction="row"
438442
key={reagent.drink_name}
439443
fontSize="14px">
440-
<Table.Cell
441-
bold>
442-
{/* Get name */}
443-
{capitalize(reagent.drink_name)}
444-
</Table.Cell>
445-
<Table.Cell
446-
textAlign="right">
447-
{/* Get amount of reagent in storage */}
448-
{reagent.drink_quantity}u
449-
</Table.Cell>
450-
<Table.Cell>
451-
{/* Make dispense button */}
452-
<Button
453-
fluid
454-
content="Transfer Back"
455-
textAlign="center"
456-
fontSize="16px"
457-
// Dissable if there is none of the reagent in storage
458-
disabled={(
459-
reagent.drink_quantity === 0
460-
)}
461-
onClick={() => act("transferBack", {
462-
itemPath: reagent.drink_type_path,
463-
})}
464-
/>
465-
</Table.Cell>
466-
<Table.Cell>
467-
<Button
468-
fluid
469-
content="Pour in glass"
470-
textAlign="center"
471-
fontSize="16px"
472-
// Dissable if there is none of the reagent in storage
473-
disabled={(
474-
reagent.drink_quantity === 0
475-
)}
476-
onClick={() => act("pour", {
477-
itemPath: reagent.drink_type_path,
478-
})}
479-
/>
480-
</Table.Cell>
444+
<Table.Cell
445+
bold>
446+
{/* Get name */}
447+
{capitalize(reagent.drink_name)}
448+
</Table.Cell>
449+
<Table.Cell
450+
textAlign="left">
451+
{/* Get amount of reagent in storage */}
452+
{reagent.drink_quantity}u
453+
</Table.Cell>
454+
<Table.Cell>
455+
{/* Make dispense button */}
456+
<Button
457+
fluid
458+
content="Transfer Back"
459+
textAlign="center"
460+
fontSize="16px"
461+
width="175px"
462+
// Disable if there is none of the reagent in storage
463+
disabled={(
464+
reagent.drink_quantity === 0
465+
)}
466+
onClick={() => act("transferBack", {
467+
itemPath: reagent.drink_type_path,
468+
})}
469+
/>
470+
</Table.Cell>
481471
</Table.Row>
482-
))}
472+
))}
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+
/>
482+
</Table.Row>
483483
</Table>
484484
);
485485
} else {

0 commit comments

Comments
 (0)