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

Commit 83e69f8

Browse files
Started on drink tab
1 parent 6c4beb2 commit 83e69f8

File tree

2 files changed

+312
-21
lines changed

2 files changed

+312
-21
lines changed

code/modules/food_and_drinks/kitchen_machinery/food_cart_TGUI.dm

Lines changed: 74 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,24 @@
66
density = TRUE
77
anchored = FALSE
88
use_power = NO_POWER_USE
9-
//Max amount of items that can be in cart's storage
10-
var/storage_capacity = 80
9+
//Max amount of items that can be in the cart's contents list
10+
var/contents_capacity = 80
11+
//How many drinking glasses the cart has
12+
var/glass_quantity = 0
13+
//Max amount of drink glasses the cart can have
14+
var/glass_capacity = 30
15+
//Max amount of reagents that can be in cart's mixer
16+
var/reagent_capacity = 200
1117
//Sound made when an item is dispensed
1218
var/dispense_sound = 'sound/machines/click.ogg'
13-
//List used to show items in UI
14-
var/list/ui_list = list()
19+
//List used to show food items in UI
20+
var/list/food_ui_list = list()
21+
//List used to show reagents in cart's reagent storage
22+
var/list/drink_ui_list = list()
23+
//List used to show reagents in mixer's reagent storage
24+
var/list/mixer_ui_list = list()
25+
//Mixer for dispencing drinks
26+
var/obj/item/reagent_containers/mixer
1527

1628
/obj/machinery/food_cart_TGUI/ui_interact(mob/user, datum/tgui/ui)
1729
ui = SStgui.try_update_ui(user, src, ui)
@@ -26,9 +38,8 @@
2638
data["food"] = list()
2739
data["storage"] = list()
2840

29-
//Loop through starting list for data to send to main tab
30-
for(var/item_detail in ui_list)
31-
41+
//Loop through food list for data to send to food tab
42+
for(var/item_detail in food_ui_list)
3243
//Create needed list and variable for geting data for UI
3344
var/list/details = list()
3445
var/obj/item/reagent_containers/food/item = new item_detail
@@ -49,9 +60,36 @@
4960
//Add to food list
5061
data["food"] += list(details)
5162

63+
//Loop through drink list for data to send to cart's reagent storage tab
64+
for(var/datum/reagent/drink in reagents.reagent_list)
65+
var/list/details = list()
66+
67+
//Get information for UI
68+
details["drink_name"] = drink.name
69+
details["drink_quantity"] = drink.volume
70+
details["drink_type_path"] = drink.type
71+
72+
//Add to drink list
73+
data["mainDrinks"] += list(details)
74+
75+
//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)
77+
var/list/details = list()
78+
79+
//Get information for UI
80+
details["drink_name"] = drink.name
81+
details["drink_quantity"] = drink.volume
82+
details["drink_type_path"] = drink.type
83+
84+
//Add to drink list
85+
data["mixerDrinks"] += list(details)
86+
5287
//Get content and capacity data
53-
data["contents_length"] = contents.len
54-
data["storage_capacity"] = storage_capacity
88+
//Have to subtract contents.len by 1 due to reagents container being in contents
89+
data["contents_length"] = contents.len - 1
90+
data["storage_capacity"] = contents_capacity
91+
data["glass_quantity"] = glass_quantity
92+
data["glass_capacity"] = glass_capacity
5593

5694
//Send stored information to UI
5795
return data
@@ -67,11 +105,30 @@
67105
var/itemPath = text2path(params["itemPath"])
68106
dispense_item(itemPath)
69107

70-
//For adding items to storage
108+
/obj/machinery/food_cart_TGUI/Initialize(mapload)
109+
. = ..()
110+
//Create reagents holder for drinks
111+
create_reagents(reagent_capacity, OPENCONTAINER | NO_REACT)
112+
mixer = new /obj/item/reagent_containers(src, 100)
113+
114+
/obj/machinery/food_cart_TGUI/Destroy()
115+
QDEL_NULL(mixer)
116+
return ..()
117+
118+
//For adding items and reagents to storage
71119
/obj/machinery/food_cart_TGUI/attackby(obj/item/A, mob/user, params)
72-
//Check to make sure it is a food item
73-
if(istype(A, /obj/item/reagent_containers/food))
120+
//Depending on the item, either attempt to store it or ignore it
121+
if(istype(A, /obj/item/reagent_containers/food/snacks))
74122
storage_single(A)
123+
else if(istype(A, /obj/item/reagent_containers/food/drinks/drinkingglass))
124+
//Check if glass is empty
125+
if(!A.reagents.total_volume)
126+
qdel(A)
127+
glass_quantity++
128+
user.visible_message(span_notice("[user] inserts [A] into [src]."), span_notice("You insert [A] into [src]."))
129+
playsound(src, 'sound/effects/rustle2.ogg', 50, TRUE, extrarange = -3)
130+
else if(A.is_drainable())
131+
return
75132

76133
..()
77134

@@ -90,17 +147,17 @@
90147
playsound(src, dispense_sound, 25, TRUE, extrarange = -3)
91148
//If the last one was dispenced, remove from UI
92149
if(find_amount(ui_item) == 0)
93-
LAZYREMOVE(ui_list, received_item)
150+
LAZYREMOVE(food_ui_list, received_item)
94151
else
95152
//For Alt click and because UI buttons are slow to disable themselves
96153
user.balloon_alert(user, "All out!")
97154

98155
/obj/machinery/food_cart_TGUI/proc/storage_single(obj/item/target_item, mob/user = usr)
99156
//Check if there is room
100-
if(contents.len < storage_capacity)
101-
//If item's typepath is not already in ui_list, add it
102-
if(!LAZYFIND(ui_list, target_item.type))
103-
LAZYADD(ui_list, target_item.type)
157+
if(contents.len - 1 < contents_capacity)
158+
//If item's typepath is not already in food_ui_list, add it
159+
if(!LAZYFIND(food_ui_list, target_item.type))
160+
LAZYADD(food_ui_list, target_item.type)
104161
//Move item to content
105162
target_item.forceMove(src)
106163
user.visible_message(span_notice("[user] inserts [target_item] into [src]."), span_notice("You insert [target_item] into [src]."))

0 commit comments

Comments
 (0)