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

Commit 86c68b3

Browse files
Started attempt of reducing number of functions
1 parent 7ca13ff commit 86c68b3

File tree

1 file changed

+46
-14
lines changed

1 file changed

+46
-14
lines changed

tgui/packages/tgui/interfaces/FoodCart.tsx

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,29 @@ type Data = {
1313
storage: StorageData;
1414
}
1515

16-
// Stats for food item
16+
// Data for food item
1717
type FoodData = {
1818
image: string;
1919
name: string;
2020
quantity: number;
2121
type_path: string;
2222
}
2323

24-
// Stats for reagents in cart's reagent holder
24+
// Data for reagents in cart's reagent holder
2525
type DrinkData = {
2626
name: string;
2727
quantity: number;
2828
type_path: string;
2929
}
3030

31-
// Stats for reagents in mixer's reagent holder
31+
// Data for reagents in mixer's reagent holder
3232
type MixerDrinkData = {
3333
name: string;
3434
quantity: number;
3535
type_path: string;
3636
}
3737

38-
// Stats for all storage information
38+
// Data for all storage information
3939
type StorageData = {
4040
contents_length: number;
4141
storage_capacity: number;
@@ -89,6 +89,12 @@ export const FoodCart = (props, context) => {
8989
};
9090

9191
const FoodTab = (props, context) => {
92+
// Get data from ui_data in backend code
93+
const { data } = useBackend<Data>(context);
94+
// Get needed variables from StorageData
95+
const { storage } = data
96+
const { contents_length } = storage;
97+
const { storage_capacity } = storage;
9298

9399
// For organizing the food tab's information
94100
return (
@@ -100,6 +106,15 @@ const FoodTab = (props, context) => {
100106
<CapacityRow />
101107
</Section>
102108
</Stack.Item>
109+
<Stack.Item>
110+
<Section
111+
title="Storage Capacity"
112+
textAlign="center">
113+
<StorageRow
114+
num1={1}
115+
num2={10} />
116+
</Section>
117+
</Stack.Item>
103118
<Stack.Item>
104119
<Section
105120
title="Food Selection"
@@ -111,10 +126,26 @@ const FoodTab = (props, context) => {
111126
);
112127
};
113128

129+
const StorageRow = (props, context, num1: number, num2: number) => {
130+
return(
131+
<Table>
132+
<Table.Row>
133+
<Table.Cell
134+
fontSize="14px"
135+
textAlign="center"
136+
bold>
137+
{/* Show numbers based on recieved arguments */}
138+
{num1}/{num2}
139+
</Table.Cell>
140+
</Table.Row>
141+
</Table>
142+
);
143+
}
144+
114145
const CapacityRow = (props, context) => {
115146
// Get data from ui_data in backend code
116147
const { data } = useBackend<Data>(context);
117-
// Get needed variables from StorageStats
148+
// Get needed variables from StorageData
118149
const { storage } = data
119150
const { contents_length } = storage;
120151
const { storage_capacity } = storage;
@@ -145,7 +176,7 @@ const FoodRow = (props, context) => {
145176
return (
146177
// Create Table for horizontal format
147178
<Table>
148-
{/* Use map to create dynamic rows based on the contents of food, with item being the individual item and its stats */}
179+
{/* Use map to create dynamic rows based on the contents of food, with item being the individual item and its data */}
149180
{food.map(item => (
150181
// Start row for holding ui elements and given data
151182
<Table.Row
@@ -275,7 +306,7 @@ const DrinkTab = (props, context) => {
275306
const GlassRow = (props, context) => {
276307
// Get data from ui_data in backend code
277308
const { data } = useBackend<Data>(context);
278-
// Get needed variables from StorageStats
309+
// Get needed variables from StorageData
279310
const { storage } = data
280311
const { glass_quantity } = storage;
281312
const { glass_capacity } = storage;
@@ -297,7 +328,7 @@ const GlassRow = (props, context) => {
297328
const DrinkCapacityRow = (props, context) => {
298329
// Get data from ui_data in backend code
299330
const { data } = useBackend<Data>(context);
300-
// Get needed variables from StorageStats
331+
// Get needed variables from StorageData
301332
const { storage } = data
302333
const { drink_quantity } = storage;
303334
const { drink_capacity } = storage;
@@ -358,7 +389,7 @@ const MainDrinkRow = (props, context) => {
358389
return (
359390
// Create Table for horizontal format
360391
<Table>
361-
{/* Use map to create dynamic rows based on the contents of drinks, with drink being the individual item and its stats */}
392+
{/* Use map to create dynamic rows based on the contents of drinks, with drink being the individual item and its data */}
362393
{mainDrinks.map(reagent => (
363394
// Start row for holding ui elements and given data
364395
<Table.Row
@@ -370,6 +401,7 @@ const MainDrinkRow = (props, context) => {
370401
bold>
371402
{/* Get name */}
372403
{capitalize(reagent.name)}
404+
{props.bold}
373405
</Table.Cell>
374406
<Table.Cell>
375407
<ProgressBar
@@ -378,7 +410,6 @@ const MainDrinkRow = (props, context) => {
378410
</ProgressBar>
379411
</Table.Cell>
380412
<Table.Cell
381-
// Limit width for
382413
width="75px">
383414
{/* Remove from cart storage */}
384415
<Button
@@ -443,7 +474,7 @@ const MixerDrinkRow = (props, context) => {
443474
return (
444475
// Create Table for horizontal format
445476
<Table>
446-
{/* Use map to create dynamic rows based on the contents of drinks, with drink being the individual item and its stats */}
477+
{/* Use map to create dynamic rows based on the contents of drinks, with drink being the individual item and its data */}
447478
{mixerDrinks.map(reagent => (
448479
// Start row for holding ui elements and given data
449480
<Table.Row
@@ -456,7 +487,8 @@ const MixerDrinkRow = (props, context) => {
456487
{/* Get name */}
457488
{capitalize(reagent.name)}
458489
</Table.Cell>
459-
<Table.Cell>
490+
<Table.Cell
491+
width="230px">
460492
<ProgressBar
461493
value={reagent.quantity/50}>
462494
{reagent.quantity}u
@@ -465,10 +497,10 @@ const MixerDrinkRow = (props, context) => {
465497
<Table.Cell>
466498
{/* Transfer reagents back to cart */}
467499
<Button
500+
fluid
468501
content="Transfer Back"
469502
textAlign="center"
470503
fontSize="16px"
471-
width="150px"
472504
// Disable if there is none of the reagent in storage
473505
disabled={(
474506
reagent.quantity === 0
@@ -524,7 +556,7 @@ const MixerDrinkRow1 = (props, context) => {
524556
direction="column"
525557
justify="space-around"
526558
fontSize="14px">
527-
{/* Use map to create dynamic rows based on the contents of drinks, with drink being the individual item and its stats */}
559+
{/* Use map to create dynamic rows based on the contents of drinks, with drink being the individual item and its data */}
528560
{mixerDrinks.map(reagent => (
529561
// Start row for holding ui elements and given data
530562
<Stack

0 commit comments

Comments
 (0)