From 59725c554629934d9a88029f1df1e2e3839daeaa Mon Sep 17 00:00:00 2001 From: Scrambledeggs <113869252+Scrambledeggs00@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:44:09 -0500 Subject: [PATCH 01/38] Added food tab to cart UI --- .../kitchen_machinery/food_cart_TGUI.dm | 140 ++++++++++++++ tgui/packages/tgui/interfaces/FoodCart.tsx | 180 ++++++++++++++++++ 2 files changed, 320 insertions(+) create mode 100644 code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm create mode 100644 tgui/packages/tgui/interfaces/FoodCart.tsx diff --git a/code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm b/code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm new file mode 100644 index 000000000000..c12cd92c2b15 --- /dev/null +++ b/code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm @@ -0,0 +1,140 @@ +/obj/machinery/food_cart_TGUI + name = "food cart" + desc = "New generation hot dog stand." + icon = 'icons/obj/kitchen.dmi' + icon_state = "foodcart" + density = TRUE + anchored = FALSE + use_power = NO_POWER_USE + //Max amount of items that can be in cart's storage + var/storage_capacity = 80 + //Sound made when an item is dispensed + var/dispense_sound = 'sound/machines/click.ogg' + //List for items to be shown in UI + var/list/ui_list = list() + +/obj/machinery/food_cart_TGUI/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "FoodCart", name) + ui.open() + ui.set_autoupdate(TRUE) + +/obj/machinery/food_cart_TGUI/ui_data(mob/user) + //Define variables from UI + var/list/data = list() + data["food"] = list() + data["storage"] = list() + + //Loop through starting list for data to send to main tab + for(var/item_detail in ui_list) + + //Create needed list and variable for geting data for UI + var/list/details = list() + var/obj/item/reagent_containers/food/item = new item_detail + + //Get information for UI + details["item_name"] = item.name + details["item_quantity"] = find_amount(item) + details["item_type_path"] = item.type + + //Get an image for the UI + var/icon/item_pic = getFlatIcon(item) + var/md5 = md5(fcopy_rsc(item_pic)) + if(!SSassets.cache["photo_[md5]_[item.name]_icon.png"]) + SSassets.transport.register_asset("photo_[md5]_[item.name]_icon.png", item_pic) + SSassets.transport.send_assets(user, list("photo_[md5]_[item.name]_icon.png" = item_pic)) + details["item_image"] = SSassets.transport.get_asset_url("photo_[md5]_[item.name]_icon.png") + + //Add to food list + data["food"] += list(details) + + //Get content and capacity data + data["contents_length"] = contents.len + data["storage_capacity"] = storage_capacity + + //Send stored information to UI + return data + +/obj/machinery/food_cart_TGUI/ui_act(action, list/params) + . = ..() + if(.) + + return + + switch(action) + if("dispense") + var/itemPath = text2path(params["itemPath"]) + dispense_item(itemPath) + +//For adding items to storage +/obj/machinery/food_cart_TGUI/attackby(obj/item/A, mob/user, params) + //Check to make sure it is a food item + if(istype(A, /obj/item/reagent_containers/food)) + storage_single(A) + +/obj/machinery/food_cart_TGUI/proc/dispense_item(received_item, mob/user = usr) + + //Make a variable for checking the type of the selected item + var/obj/item/reagent_containers/food/ui_item = new received_item + + //If the vat has some of the desired item, dispense it + if(find_amount(ui_item) > 0) + //Select the last(most recent) of desired item + var/obj/item/reagent_containers/food/snacks/dispensed_item = LAZYACCESS(contents, last_index(ui_item)) + //Drop it on the floor and then move it into the user's hands + dispensed_item.forceMove(loc) + user.put_in_hands(dispensed_item) + user.visible_message(span_notice("[user] dispenses [ui_item.name] from [src]."), span_notice("You dispense [ui_item.name] from [src].")) + playsound(src, dispense_sound, 25, TRUE, extrarange = -3) + //If the last one was dispenced, remove from UI + if(find_amount(ui_item) == 0) + LAZYREMOVE(ui_list, received_item) + else + //For Alt click and because UI buttons are slow to disable themselves + user.balloon_alert(user, "All out!") + +/obj/machinery/food_cart_TGUI/proc/storage_single(obj/item/target_item, mob/user = usr) + //Check if there is room + if(contents.len < storage_capacity) + //If item's typepath is not already in ui_list, add it + if(!LAZYFIND(ui_list, target_item.type)) + LAZYADD(ui_list, target_item.type) + //Move item to content + target_item.forceMove(src) + user.visible_message(span_notice("[user] inserts [target_item] into [src]."), span_notice("You insert [target_item] into [src].")) + playsound(src, 'sound/effects/rustle2.ogg', 50, TRUE, extrarange = -3) + + return + else + //Warn about full capacity + user.balloon_alert(user, "No space!") + +/obj/machinery/food_cart_TGUI/proc/find_amount(obj/item/counting_item, target_name = null, list/target_list = null) + var/amount = 0 + + //If target_list is null, search contents for type paths + if(!target_list) + //Loop through contents, counting every instance of the given target + for(var/obj/item/list_item in contents) + if(list_item.type == counting_item.type) + amount += 1 + //Else, search target_list + else + for(var/list_item in target_list) + if(list_item == target_name) + amount += 1 + + return amount + +/obj/machinery/food_cart_TGUI/proc/last_index(obj/item/search_item) + + var/obj/item/reagent_containers/food/snacks/item_index = null + + //Search for the same item path in storage + for(var/i in 1 to LAZYLEN(contents)) + //Loop through entire list to get last/most recent item + if(contents[i].type == search_item.type) + item_index = i + + return item_index diff --git a/tgui/packages/tgui/interfaces/FoodCart.tsx b/tgui/packages/tgui/interfaces/FoodCart.tsx new file mode 100644 index 000000000000..27443930c7b4 --- /dev/null +++ b/tgui/packages/tgui/interfaces/FoodCart.tsx @@ -0,0 +1,180 @@ +import { storage } from 'common/storage'; +import { capitalize } from 'common/string'; +import { useBackend, useLocalState } from '../backend'; +import { Button, Section, Table, Tabs, Box, TextArea, Stack, Tooltip } from '../components'; +import { Window } from '../layouts'; +import { resolveAsset } from './../assets'; + +// Store data for cones and scoops within Data +type Data = { + tabs: Tab[]; +} + +type Tab = { + food: FoodStats[]; + storage: StorageStats[]; +} + +// Stats for food item +type FoodStats = { + item_image: string; + item_name: string; + item_quantity: number; + item_type_path: string; + selected_item: string; +} + +type StorageStats = { + contents_length: number; + storage_capacity: number; +} + +export const FoodCart = (props, context) => { + // Get information from backend code + const { data } = useBackend(context); + // Make a variable for storing a number that represents the current selected tab + const [selectedMainTab, setMainTab] = useLocalState(context, 'selectedMainTab', 0); + + return( + // Create window for ui + + {/* Add constants to window and make it scrollable */} + + {/* Create tabs for better organization */} + + setMainTab(0)}> + {/* Put 'Food' in the tab to differentiate it from other tabs */} + Food + + + {/* If selectedMainTab is 0, show the UI elements in FoodTab */} + {selectedMainTab === 0 && } + + + ); +}; + +const FoodTab = (props, context) => { + + // For organizing the food tab's information + return ( + + +
+ +
+
+ +
+ +
+
+
+ ); +}; + +const CapacityRow = (props, context) => { + // Get data from ui_data in backend code + const { data } = useBackend(context); + // Get needed variables from StorageStats + const { contents_length } = data; + const { storage_capacity } = data; + + // Return a section with the tab's section_text + return( + + + + {/* Show the vat's current contents and its max contents */} + {contents_length}/{storage_capacity} + + +
+ ); +}; + +const FoodRow = (props, context) => { + // Get data from ui_data in backend code + const { act, data } = useBackend(context); + // Get cones information from data + const { food = [] } = data; + + if(food.length > 0) { + return ( + // Create Table for horizontal format + + {/* Use map to create dynamic rows based on the contents of food, with item being the individual item and its stats */} + {food.map(item => ( + // Start row for holding ui elements and given data + + + {/* Get image and then add it to the ui */} + + + + {/* Get name */} + {capitalize(item.item_name)} + + + {/* Get amount of item in storage */} + {item.item_quantity} in storage + + + {/* Make dispense button */} +
+ ); + } else { + return ( + + + + Put something in you daft fool! + + +
+ ); + } +}; From 4adc9ed07407200ec92f61b364d4e4d846e6f263 Mon Sep 17 00:00:00 2001 From: Scrambledeggs <113869252+Scrambledeggs00@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:44:50 -0500 Subject: [PATCH 02/38] Oops --- yogstation.dme | 1 + 1 file changed, 1 insertion(+) diff --git a/yogstation.dme b/yogstation.dme index 58551705d9d9..7ad5b9d00ef4 100644 --- a/yogstation.dme +++ b/yogstation.dme @@ -2549,6 +2549,7 @@ #include "code\modules\food_and_drinks\food\snacks\meat.dm" #include "code\modules\food_and_drinks\kitchen_machinery\deep_fryer.dm" #include "code\modules\food_and_drinks\kitchen_machinery\food_cart.dm" +#include "code\modules\food_and_drinks\kitchen_machinery\food_cart_TGUI.dm" #include "code\modules\food_and_drinks\kitchen_machinery\gibber.dm" #include "code\modules\food_and_drinks\kitchen_machinery\griddle.dm" #include "code\modules\food_and_drinks\kitchen_machinery\grill.dm" From 6c4beb2087b62874f7ac9b548b51c51d150bd6cf Mon Sep 17 00:00:00 2001 From: Scrambledeggs <113869252+Scrambledeggs00@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:51:22 -0500 Subject: [PATCH 03/38] Fixed interaction bug --- .../food_and_drinks/kitchen_machinery/food_cart_TGUI.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm b/code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm index c12cd92c2b15..80175a239bcd 100644 --- a/code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm +++ b/code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm @@ -10,7 +10,7 @@ var/storage_capacity = 80 //Sound made when an item is dispensed var/dispense_sound = 'sound/machines/click.ogg' - //List for items to be shown in UI + //List used to show items in UI var/list/ui_list = list() /obj/machinery/food_cart_TGUI/ui_interact(mob/user, datum/tgui/ui) @@ -73,8 +73,9 @@ if(istype(A, /obj/item/reagent_containers/food)) storage_single(A) -/obj/machinery/food_cart_TGUI/proc/dispense_item(received_item, mob/user = usr) + ..() +/obj/machinery/food_cart_TGUI/proc/dispense_item(received_item, mob/user = usr) //Make a variable for checking the type of the selected item var/obj/item/reagent_containers/food/ui_item = new received_item @@ -128,7 +129,6 @@ return amount /obj/machinery/food_cart_TGUI/proc/last_index(obj/item/search_item) - var/obj/item/reagent_containers/food/snacks/item_index = null //Search for the same item path in storage From 83e69f8ac5b78825f887b6c483dee46806c5d793 Mon Sep 17 00:00:00 2001 From: Scrambledeggs <113869252+Scrambledeggs00@users.noreply.github.com> Date: Wed, 11 Dec 2024 20:53:28 -0500 Subject: [PATCH 04/38] Started on drink tab --- .../kitchen_machinery/food_cart_TGUI.dm | 91 +++++-- tgui/packages/tgui/interfaces/FoodCart.tsx | 242 +++++++++++++++++- 2 files changed, 312 insertions(+), 21 deletions(-) diff --git a/code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm b/code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm index 80175a239bcd..5b3836ad0b57 100644 --- a/code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm +++ b/code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm @@ -6,12 +6,24 @@ density = TRUE anchored = FALSE use_power = NO_POWER_USE - //Max amount of items that can be in cart's storage - var/storage_capacity = 80 + //Max amount of items that can be in the cart's contents list + var/contents_capacity = 80 + //How many drinking glasses the cart has + var/glass_quantity = 0 + //Max amount of drink glasses the cart can have + var/glass_capacity = 30 + //Max amount of reagents that can be in cart's mixer + var/reagent_capacity = 200 //Sound made when an item is dispensed var/dispense_sound = 'sound/machines/click.ogg' - //List used to show items in UI - var/list/ui_list = list() + //List used to show food items in UI + var/list/food_ui_list = list() + //List used to show reagents in cart's reagent storage + var/list/drink_ui_list = list() + //List used to show reagents in mixer's reagent storage + var/list/mixer_ui_list = list() + //Mixer for dispencing drinks + var/obj/item/reagent_containers/mixer /obj/machinery/food_cart_TGUI/ui_interact(mob/user, datum/tgui/ui) ui = SStgui.try_update_ui(user, src, ui) @@ -26,9 +38,8 @@ data["food"] = list() data["storage"] = list() - //Loop through starting list for data to send to main tab - for(var/item_detail in ui_list) - + //Loop through food list for data to send to food tab + for(var/item_detail in food_ui_list) //Create needed list and variable for geting data for UI var/list/details = list() var/obj/item/reagent_containers/food/item = new item_detail @@ -49,9 +60,36 @@ //Add to food list data["food"] += list(details) + //Loop through drink list for data to send to cart's reagent storage tab + for(var/datum/reagent/drink in reagents.reagent_list) + var/list/details = list() + + //Get information for UI + details["drink_name"] = drink.name + details["drink_quantity"] = drink.volume + details["drink_type_path"] = drink.type + + //Add to drink list + data["mainDrinks"] += list(details) + + //Loop through drink list for data to send to cart's reagent mixer tab + for(var/datum/reagent/drink in mixer.reagents.reagent_list) + var/list/details = list() + + //Get information for UI + details["drink_name"] = drink.name + details["drink_quantity"] = drink.volume + details["drink_type_path"] = drink.type + + //Add to drink list + data["mixerDrinks"] += list(details) + //Get content and capacity data - data["contents_length"] = contents.len - data["storage_capacity"] = storage_capacity + //Have to subtract contents.len by 1 due to reagents container being in contents + data["contents_length"] = contents.len - 1 + data["storage_capacity"] = contents_capacity + data["glass_quantity"] = glass_quantity + data["glass_capacity"] = glass_capacity //Send stored information to UI return data @@ -67,11 +105,30 @@ var/itemPath = text2path(params["itemPath"]) dispense_item(itemPath) -//For adding items to storage +/obj/machinery/food_cart_TGUI/Initialize(mapload) + . = ..() + //Create reagents holder for drinks + create_reagents(reagent_capacity, OPENCONTAINER | NO_REACT) + mixer = new /obj/item/reagent_containers(src, 100) + +/obj/machinery/food_cart_TGUI/Destroy() + QDEL_NULL(mixer) + return ..() + +//For adding items and reagents to storage /obj/machinery/food_cart_TGUI/attackby(obj/item/A, mob/user, params) - //Check to make sure it is a food item - if(istype(A, /obj/item/reagent_containers/food)) + //Depending on the item, either attempt to store it or ignore it + if(istype(A, /obj/item/reagent_containers/food/snacks)) storage_single(A) + else if(istype(A, /obj/item/reagent_containers/food/drinks/drinkingglass)) + //Check if glass is empty + if(!A.reagents.total_volume) + qdel(A) + glass_quantity++ + user.visible_message(span_notice("[user] inserts [A] into [src]."), span_notice("You insert [A] into [src].")) + playsound(src, 'sound/effects/rustle2.ogg', 50, TRUE, extrarange = -3) + else if(A.is_drainable()) + return ..() @@ -90,17 +147,17 @@ playsound(src, dispense_sound, 25, TRUE, extrarange = -3) //If the last one was dispenced, remove from UI if(find_amount(ui_item) == 0) - LAZYREMOVE(ui_list, received_item) + LAZYREMOVE(food_ui_list, received_item) else //For Alt click and because UI buttons are slow to disable themselves user.balloon_alert(user, "All out!") /obj/machinery/food_cart_TGUI/proc/storage_single(obj/item/target_item, mob/user = usr) //Check if there is room - if(contents.len < storage_capacity) - //If item's typepath is not already in ui_list, add it - if(!LAZYFIND(ui_list, target_item.type)) - LAZYADD(ui_list, target_item.type) + if(contents.len - 1 < contents_capacity) + //If item's typepath is not already in food_ui_list, add it + if(!LAZYFIND(food_ui_list, target_item.type)) + LAZYADD(food_ui_list, target_item.type) //Move item to content target_item.forceMove(src) user.visible_message(span_notice("[user] inserts [target_item] into [src]."), span_notice("You insert [target_item] into [src].")) diff --git a/tgui/packages/tgui/interfaces/FoodCart.tsx b/tgui/packages/tgui/interfaces/FoodCart.tsx index 27443930c7b4..fac949494c20 100644 --- a/tgui/packages/tgui/interfaces/FoodCart.tsx +++ b/tgui/packages/tgui/interfaces/FoodCart.tsx @@ -12,6 +12,8 @@ type Data = { type Tab = { food: FoodStats[]; + mainDrinks: MainDrinkStats[]; + mixerDrinks: MixerDrinkStats[]; storage: StorageStats[]; } @@ -21,12 +23,27 @@ type FoodStats = { item_name: string; item_quantity: number; item_type_path: string; - selected_item: string; +} + +// Stats for reagents in cart's reagent holder +type MainDrinkStats = { + drink_name: string; + drink_quantity: number; + drink_type_path: string; +} + +// Stats for reagents in mixer's reagent holder +type MixerDrinkStats = { + drink_name: string; + drink_quantity: number; + drink_type_path: string; } type StorageStats = { contents_length: number; storage_capacity: number; + glass_quantity: number; + glass_capacity: number; } export const FoodCart = (props, context) => { @@ -50,12 +67,21 @@ export const FoodCart = (props, context) => { selected={selectedMainTab === 0} // Set selectedMainTab to 0 when the food tab is clicked onClick={() => setMainTab(0)}> - {/* Put 'Food' in the tab to differentiate it from other tabs */} Food + setMainTab(1)}> + Drinks + {/* If selectedMainTab is 0, show the UI elements in FoodTab */} {selectedMainTab === 0 && } + {selectedMainTab === 1 && } ); @@ -110,7 +136,7 @@ const CapacityRow = (props, context) => { const FoodRow = (props, context) => { // Get data from ui_data in backend code const { act, data } = useBackend(context); - // Get cones information from data + // Get food information from data const { food = [] } = data; if(food.length > 0) { @@ -171,7 +197,215 @@ const FoodRow = (props, context) => { fontSize="14px" textAlign="center" bold> - Put something in you daft fool! + Food Storage Empty + + + + ); + } +}; + +const DrinkTab = (props, context) => { + // For organizing the food tab's information + return ( + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+ ); +}; + +const GlassRow = (props, context) => { + // Get data from ui_data in backend code + const { data } = useBackend(context); + // Get needed variables from StorageStats + const { glass_quantity } = data; + const { glass_capacity } = data; + + return ( + + + + {/* Show the vat's current contents and its max contents */} + {glass_quantity}/{glass_capacity} + + +
+ ); +}; + +const MainDrinkRow = (props, context) => { + // Get data from ui_data in backend code + const { act, data } = useBackend(context); + // Get drink information for cart's container from data + const { mainDrinks = [] } = data; + + if(mainDrinks.length > 0) { + return ( + // Create Table for horizontal format + + {/* Use map to create dynamic rows based on the contents of drinks, with drink being the individual item and its stats */} + {mainDrinks.map(reagent => ( + // Start row for holding ui elements and given data + + + {/* Get name */} + {capitalize(reagent.drink_name)} + + + {/* Get amount of reagent in storage */} + {reagent.drink_quantity}u + + + {/* Remove from cart storage */} +
+ ); + } else { + return ( + + + + Drink Storage Empty + + +
+ ); + } +}; + +const MixerDrinkRow = (props, context) => { + // Get data from ui_data in backend code + const { act, data } = useBackend(context); + // Get drink information for cart's container from data + const { mixerDrinks = [] } = data; + + if(mixerDrinks.length > 0) { + return ( + // Create Table for horizontal format + + {/* Use map to create dynamic rows based on the contents of drinks, with drink being the individual item and its stats */} + {mixerDrinks.map(reagent => ( + // Start row for holding ui elements and given data + + + {/* Get name */} + {capitalize(reagent.drink_name)} + + + {/* Get amount of reagent in storage */} + {reagent.drink_quantity}u + + + {/* Make dispense button */} +
+ ); + } else { + return ( + + + + Mixer Storage Empty
From 5cdd0297db047d6012a1c991ce45886ec851b1bf Mon Sep 17 00:00:00 2001 From: Scrambledeggs <113869252+Scrambledeggs00@users.noreply.github.com> Date: Wed, 11 Dec 2024 21:13:20 -0500 Subject: [PATCH 05/38] Added drink capacity element to UI --- .../kitchen_machinery/food_cart_TGUI.dm | 5 ++- tgui/packages/tgui/interfaces/FoodCart.tsx | 36 +++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm b/code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm index 5b3836ad0b57..d02070bd5598 100644 --- a/code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm +++ b/code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm @@ -9,7 +9,7 @@ //Max amount of items that can be in the cart's contents list var/contents_capacity = 80 //How many drinking glasses the cart has - var/glass_quantity = 0 + var/glass_quantity = 10 //Max amount of drink glasses the cart can have var/glass_capacity = 30 //Max amount of reagents that can be in cart's mixer @@ -90,6 +90,9 @@ data["storage_capacity"] = contents_capacity data["glass_quantity"] = glass_quantity data["glass_capacity"] = glass_capacity + //Add the total_volumne of both cart and mixer storage for quantity + data["drink_quantity"] = mixer.reagents.total_volume + reagents.total_volume + data["drink_capacity"] = reagent_capacity //Send stored information to UI return data diff --git a/tgui/packages/tgui/interfaces/FoodCart.tsx b/tgui/packages/tgui/interfaces/FoodCart.tsx index fac949494c20..142420aa330c 100644 --- a/tgui/packages/tgui/interfaces/FoodCart.tsx +++ b/tgui/packages/tgui/interfaces/FoodCart.tsx @@ -44,6 +44,8 @@ type StorageStats = { storage_capacity: number; glass_quantity: number; glass_capacity: number; + drink_quantity: number; + drink_capacity: number; } export const FoodCart = (props, context) => { @@ -216,6 +218,13 @@ const DrinkTab = (props, context) => { + +
+ +
+
{ fontSize="14px" textAlign="center" bold> - {/* Show the vat's current contents and its max contents */} {glass_quantity}/{glass_capacity} @@ -256,9 +264,30 @@ const GlassRow = (props, context) => { ); }; +const DrinkCapacityRow = (props, context) => { + // Get data from ui_data in backend code + const { data } = useBackend(context); + // Get needed variables from StorageStats + const { drink_quantity } = data; + const { drink_capacity } = data; + + return ( + + + + {drink_quantity}/{drink_capacity} + + +
+ ); +} + const MainDrinkRow = (props, context) => { // Get data from ui_data in backend code - const { act, data } = useBackend(context); + const { act, data } = useBackend(context); // Get drink information for cart's container from data const { mainDrinks = [] } = data; @@ -287,6 +316,7 @@ const MainDrinkRow = (props, context) => { {/* Remove from cart storage */}
@@ -353,6 +353,7 @@ const MainDrinkRow = (props, context) => { const { act, data } = useBackend(context); // Get drink information for cart's container from data const { mainDrinks = [] } = data; + const { drink_capacity } = data.storage; if(mainDrinks.length > 0) { return ( @@ -363,9 +364,10 @@ const MainDrinkRow = (props, context) => { // Start row for holding ui elements and given data + fontSize="14px" + height="30px"> {/* Get name */} {capitalize(reagent.drink_name)} @@ -449,9 +451,11 @@ const MixerDrinkRow = (props, context) => { + fontSize="14px" + height="30px"> + bold + width="150px"> {/* Get name */} {capitalize(reagent.drink_name)} From 190dc066a18226be073f7117f89f0495e259487f Mon Sep 17 00:00:00 2001 From: Scrambledeggs <113869252+Scrambledeggs00@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:18:29 -0500 Subject: [PATCH 14/38] Attempts on progress bar --- tgui/packages/tgui/interfaces/FoodCart.tsx | 45 ++++++++++------------ 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/tgui/packages/tgui/interfaces/FoodCart.tsx b/tgui/packages/tgui/interfaces/FoodCart.tsx index 852a2fe8ffe0..68fbe3263962 100644 --- a/tgui/packages/tgui/interfaces/FoodCart.tsx +++ b/tgui/packages/tgui/interfaces/FoodCart.tsx @@ -8,10 +8,6 @@ import { resolveAsset } from './../assets'; // Store data for UI elements within Data type Data = { - tabs: Tab[]; -} - -type Tab = { food: FoodStats[]; mainDrinks: MainDrinkStats[]; mixerDrinks: MixerDrinkStats[]; @@ -141,7 +137,7 @@ const CapacityRow = (props, context) => { const FoodRow = (props, context) => { // Get data from ui_data in backend code - const { act, data } = useBackend(context); + const { act, data } = useBackend(context); // Get food information from data const { food = [] } = data; @@ -350,10 +346,10 @@ const DrinkTransferRow = (props, context) => { const MainDrinkRow = (props, context) => { // Get data from ui_data in backend code - const { act, data } = useBackend(context); + const { act, data } = useBackend(context); // Get drink information for cart's container from data const { mainDrinks = [] } = data; - const { drink_capacity } = data.storage; + const { storage } = data; if(mainDrinks.length > 0) { return ( @@ -374,7 +370,7 @@ const MainDrinkRow = (props, context) => { + value={reagent.drink_quantity/storage.drink_capacity}> {reagent.drink_quantity}u @@ -436,20 +432,18 @@ const MainDrinkRow = (props, context) => { const MixerDrinkRow = (props, context) => { // Get data from ui_data in backend code - const { act, data } = useBackend(context); + const { act, data } = useBackend(context); // Get drink information for cart's container from data const { mixerDrinks = [] } = data; if(mixerDrinks.length > 0) { return ( // Create Table for horizontal format - +
{/* Use map to create dynamic rows based on the contents of drinks, with drink being the individual item and its stats */} {mixerDrinks.map(reagent => ( // Start row for holding ui elements and given data @@ -459,19 +453,19 @@ const MixerDrinkRow = (props, context) => { {/* Get name */} {capitalize(reagent.drink_name)} - - {/* Get amount of reagent in storage */} - {reagent.drink_quantity}u - - {/* Make dispense button */} + + {reagent.drink_quantity}u + + + + {/* Transfer reagents back to cart */}
@@ -316,7 +315,7 @@ const DrinkCapacityRow = (props, context) => { const DrinkTransferRow = (props, context) => { // Get data from ui_data in backend code - const { act, data } = useBackend(context); + const { act, data } = useBackend(context); // Get data for buttons const { dispence_options = [] } = data; const { dispence_selected } = data; @@ -358,19 +357,19 @@ const MainDrinkRow = (props, context) => { {mainDrinks.map(reagent => ( // Start row for holding ui elements and given data {/* Get name */} - {capitalize(reagent.drink_name)} + {capitalize(reagent.name)} - {reagent.drink_quantity}u + value={reagent.quantity/200}> + {reagent.quantity}u { fontSize="16px" // Disable if there is none of the reagent in storage disabled={( - reagent.drink_quantity === 0 + reagent.quantity === 0 )} onClick={() => act("purge", { - itemPath: reagent.drink_type_path, + itemPath: reagent.type_path, })} /> @@ -402,10 +401,10 @@ const MainDrinkRow = (props, context) => { fontSize="16px" // Dissable if there is none of the reagent in storage disabled={( - reagent.drink_quantity === 0 + reagent.quantity === 0 )} onClick={() => act("addMixer", { - itemPath: reagent.drink_type_path, + itemPath: reagent.type_path, })} /> @@ -443,19 +442,19 @@ const MixerDrinkRow = (props, context) => { {mixerDrinks.map(reagent => ( // Start row for holding ui elements and given data {/* Get name */} - {capitalize(reagent.drink_name)} + {capitalize(reagent.name)} - {reagent.drink_quantity}u + value={reagent.quantity/50}> + {reagent.quantity}u @@ -467,10 +466,10 @@ const MixerDrinkRow = (props, context) => { width="150px" // Disable if there is none of the reagent in storage disabled={( - reagent.drink_quantity === 0 + reagent.quantity === 0 )} onClick={() => act("transferBack", { - itemPath: reagent.drink_type_path, + itemPath: reagent.type_path, })} /> @@ -524,7 +523,7 @@ const MixerDrinkRow1 = (props, context) => { {mixerDrinks.map(reagent => ( // Start row for holding ui elements and given data @@ -532,11 +531,11 @@ const MixerDrinkRow1 = (props, context) => { bold align="right"> {/* Get name */} - {capitalize(reagent.drink_name)} + {capitalize(reagent.name)} {/* Get amount of reagent in storage */} - {reagent.drink_quantity}u + {reagent.quantity}u @@ -547,10 +546,10 @@ const MixerDrinkRow1 = (props, context) => { fontSize="16px" // Disable if there is none of the reagent in storage disabled={( - reagent.drink_quantity === 0 + reagent.quantity === 0 )} onClick={() => act("transferBack", { - itemPath: reagent.drink_type_path, + itemPath: reagent.type_path, })} /> From 7ca13ffaaf823ecf4a200a29f338e57678f1c614 Mon Sep 17 00:00:00 2001 From: Scrambledeggs <113869252+Scrambledeggs00@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:42:29 -0500 Subject: [PATCH 17/38] StorageData related stuff shows again --- tgui/packages/tgui/interfaces/FoodCart.tsx | 35 ++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/tgui/packages/tgui/interfaces/FoodCart.tsx b/tgui/packages/tgui/interfaces/FoodCart.tsx index 4132aaf759f2..aad340927322 100644 --- a/tgui/packages/tgui/interfaces/FoodCart.tsx +++ b/tgui/packages/tgui/interfaces/FoodCart.tsx @@ -41,7 +41,7 @@ type StorageData = { storage_capacity: number; glass_quantity: number; glass_capacity: number; - quantity: number; + drink_quantity: number; drink_capacity: number; dispence_options: number[]; dispence_selected: number; @@ -113,10 +113,11 @@ const FoodTab = (props, context) => { const CapacityRow = (props, context) => { // Get data from ui_data in backend code - const { data } = useBackend(context); + const { data } = useBackend(context); // Get needed variables from StorageStats - const { contents_length } = data; - const { storage_capacity } = data; + const { storage } = data + const { contents_length } = storage; + const { storage_capacity } = storage; // Return a section with the tab's section_text return( @@ -273,10 +274,11 @@ const DrinkTab = (props, context) => { const GlassRow = (props, context) => { // Get data from ui_data in backend code - const { data } = useBackend(context); + const { data } = useBackend(context); // Get needed variables from StorageStats - const { glass_quantity } = data; - const { glass_capacity } = data; + const { storage } = data + const { glass_quantity } = storage; + const { glass_capacity } = storage; return ( @@ -294,10 +296,11 @@ const GlassRow = (props, context) => { const DrinkCapacityRow = (props, context) => { // Get data from ui_data in backend code - const { data } = useBackend(context); + const { data } = useBackend(context); // Get needed variables from StorageStats - const { quantity } = data; - const { drink_capacity } = data; + const { storage } = data + const { drink_quantity } = storage; + const { drink_capacity } = storage; return (
@@ -306,7 +309,7 @@ const DrinkCapacityRow = (props, context) => { fontSize="14px" textAlign="center" bold> - {quantity}/{drink_capacity} + {drink_quantity}/{drink_capacity}
@@ -315,10 +318,11 @@ const DrinkCapacityRow = (props, context) => { const DrinkTransferRow = (props, context) => { // Get data from ui_data in backend code - const { act, data } = useBackend(context); + const { act, data } = useBackend(context); // Get data for buttons - const { dispence_options = [] } = data; - const { dispence_selected } = data; + const { storage } = data + const { dispence_options = [] } = storage; + const { dispence_selected } = storage; return( { const { act, data } = useBackend(context); // Get drink information for cart's container from data const { mainDrinks = [] } = data; + const { drink_capacity } = data.storage; if(mainDrinks.length > 0) { return ( @@ -368,7 +373,7 @@ const MainDrinkRow = (props, context) => { + value={reagent.quantity/drink_capacity}> {reagent.quantity}u From 86c68b3f3985c208c738cbd3d426351d36cb393c Mon Sep 17 00:00:00 2001 From: Scrambledeggs <113869252+Scrambledeggs00@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:26:18 -0500 Subject: [PATCH 18/38] Started attempt of reducing number of functions --- tgui/packages/tgui/interfaces/FoodCart.tsx | 60 +++++++++++++++++----- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/tgui/packages/tgui/interfaces/FoodCart.tsx b/tgui/packages/tgui/interfaces/FoodCart.tsx index aad340927322..e85fcf3fc935 100644 --- a/tgui/packages/tgui/interfaces/FoodCart.tsx +++ b/tgui/packages/tgui/interfaces/FoodCart.tsx @@ -13,7 +13,7 @@ type Data = { storage: StorageData; } -// Stats for food item +// Data for food item type FoodData = { image: string; name: string; @@ -21,21 +21,21 @@ type FoodData = { type_path: string; } -// Stats for reagents in cart's reagent holder +// Data for reagents in cart's reagent holder type DrinkData = { name: string; quantity: number; type_path: string; } -// Stats for reagents in mixer's reagent holder +// Data for reagents in mixer's reagent holder type MixerDrinkData = { name: string; quantity: number; type_path: string; } -// Stats for all storage information +// Data for all storage information type StorageData = { contents_length: number; storage_capacity: number; @@ -89,6 +89,12 @@ export const FoodCart = (props, context) => { }; const FoodTab = (props, context) => { + // Get data from ui_data in backend code + const { data } = useBackend(context); + // Get needed variables from StorageData + const { storage } = data + const { contents_length } = storage; + const { storage_capacity } = storage; // For organizing the food tab's information return ( @@ -100,6 +106,15 @@ const FoodTab = (props, context) => { + +
+ +
+
{ ); }; +const StorageRow = (props, context, num1: number, num2: number) => { + return( + + + + {/* Show numbers based on recieved arguments */} + {num1}/{num2} + + +
+ ); +} + const CapacityRow = (props, context) => { // Get data from ui_data in backend code const { data } = useBackend(context); - // Get needed variables from StorageStats + // Get needed variables from StorageData const { storage } = data const { contents_length } = storage; const { storage_capacity } = storage; @@ -145,7 +176,7 @@ const FoodRow = (props, context) => { return ( // Create Table for horizontal format - {/* Use map to create dynamic rows based on the contents of food, with item being the individual item and its stats */} + {/* Use map to create dynamic rows based on the contents of food, with item being the individual item and its data */} {food.map(item => ( // Start row for holding ui elements and given data { const GlassRow = (props, context) => { // Get data from ui_data in backend code const { data } = useBackend(context); - // Get needed variables from StorageStats + // Get needed variables from StorageData const { storage } = data const { glass_quantity } = storage; const { glass_capacity } = storage; @@ -297,7 +328,7 @@ const GlassRow = (props, context) => { const DrinkCapacityRow = (props, context) => { // Get data from ui_data in backend code const { data } = useBackend(context); - // Get needed variables from StorageStats + // Get needed variables from StorageData const { storage } = data const { drink_quantity } = storage; const { drink_capacity } = storage; @@ -358,7 +389,7 @@ const MainDrinkRow = (props, context) => { return ( // Create Table for horizontal format
- {/* Use map to create dynamic rows based on the contents of drinks, with drink being the individual item and its stats */} + {/* Use map to create dynamic rows based on the contents of drinks, with drink being the individual item and its data */} {mainDrinks.map(reagent => ( // Start row for holding ui elements and given data { bold> {/* Get name */} {capitalize(reagent.name)} + {props.bold} { {/* Remove from cart storage */}
- {/* Use map to create dynamic rows based on the contents of drinks, with drink being the individual item and its stats */} + {/* Use map to create dynamic rows based on the contents of drinks, with drink being the individual item and its data */} {mixerDrinks.map(reagent => ( // Start row for holding ui elements and given data { {/* Get name */} {capitalize(reagent.name)} - + {reagent.quantity}u @@ -465,10 +497,10 @@ const MixerDrinkRow = (props, context) => { {/* Transfer reagents back to cart */}
@@ -135,37 +131,13 @@ const StorageRow = (props, context, num1: number, num2: number) => { textAlign="center" bold> {/* Show numbers based on recieved arguments */} - {num1}/{num2} + {quantity}/{capacity}
); } -const CapacityRow = (props, context) => { - // Get data from ui_data in backend code - const { data } = useBackend(context); - // Get needed variables from StorageData - const { storage } = data - const { contents_length } = storage; - const { storage_capacity } = storage; - - // Return a section with the tab's section_text - return( - - - - {/* Show the vat's current contents and its max contents */} - {contents_length}/{storage_capacity} - - -
- ); -}; - const FoodRow = (props, context) => { // Get data from ui_data in backend code const { act, data } = useBackend(context); @@ -239,28 +211,35 @@ const FoodRow = (props, context) => { }; const DrinkTab = (props, context) => { - // For organizing the food tab's information + // Get data from ui_data in backend code + const { data } = useBackend(context); + // Get needed variable for StorageRow + const { storage } = data + + // For organizing the Drink tab's information return ( - +
- +
+ grow>
- +
@@ -303,50 +282,6 @@ const DrinkTab = (props, context) => { ); }; -const GlassRow = (props, context) => { - // Get data from ui_data in backend code - const { data } = useBackend(context); - // Get needed variables from StorageData - const { storage } = data - const { glass_quantity } = storage; - const { glass_capacity } = storage; - - return ( - - - - {glass_quantity}/{glass_capacity} - - -
- ); -}; - -const DrinkCapacityRow = (props, context) => { - // Get data from ui_data in backend code - const { data } = useBackend(context); - // Get needed variables from StorageData - const { storage } = data - const { drink_quantity } = storage; - const { drink_capacity } = storage; - - return ( - - - - {drink_quantity}/{drink_capacity} - - -
- ); -} - const DrinkTransferRow = (props, context) => { // Get data from ui_data in backend code const { act, data } = useBackend(context); @@ -360,7 +295,7 @@ const DrinkTransferRow = (props, context) => { justify="center"> {dispence_options.map(amount => (
@@ -263,7 +263,7 @@ const DrinkTab = (props, context) => { buttons={