Ice Cream Rework Part 2: I can't think of a funny name (#22490)

* Started groundwork for new vat

* forgot a space

* Started on TGUI code

* Continued work on TGUI code and ui_data

* I do not like TGUI

* Borrowed code from food cart

* Getting there

* More tweaking

* Fixed amount problem

* UI is dead

* Fixed TGUI list stuff

* Image fixed

* Messed with UI layout

* Finished base UI and gave thanks

* Added comments and general code improvements

* Fixed typos and changed actions in UI

* ui_act for selecting and dispencing items

* Improved dispensing and selecting code

* Added alt click interaction and extra examines

* Deselecting and attackby for adding to vat

* Now stores items rather than type paths

* Added carton interaction with vat

* Selected item's select ui button now becomes green

* lets you scoop cones with right click

* Start with new cones

* Finish cone crafting and started with tabs

* Attempt #2 at getting tabs to work

* Vat tab now works as intended

* Messed with info tab layout

* Finished work on tabs

* Replaced original vat code and improved code

* Removed ice cream from borg dispencers

* Removed creamatorium ;[

* Removed duplicate item from black list

* Finishing touches

* Fixes for Lint tests

* More fixes for Lints test

* Shortens info tab text
This commit is contained in:
Scrambledeggs
2024-08-13 20:19:05 -04:00
committed by GitHub
parent d0d2b07166
commit e12cf574f3
11 changed files with 737 additions and 317 deletions

View File

@@ -1116,7 +1116,9 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)
/obj/item/reagent_containers/food/snacks/donkpocket/warm/gondola, //same thing
/obj/item/reagent_containers/food/snacks/fish, // debug fish
/obj/item/reagent_containers/food/snacks/powercrepe, //obscenely strong for a food item and shouldn't just be randomly spawned
/obj/item/reagent_containers/food/snacks/grown/banana/bombanana //They were made in a factory. A bomb factory. They're bombs.
/obj/item/reagent_containers/food/snacks/grown/banana/bombanana, //They were made in a factory. A bomb factory. They're bombs.
/obj/item/reagent_containers/food/snacks/ice_cream_cone, //base cone
/obj/item/reagent_containers/food/snacks/raw_cone //base raw cone
)
blocked |= typesof(/obj/item/reagent_containers/food/snacks/customizable)

28
code/datums/info_tab.dm Normal file
View File

@@ -0,0 +1,28 @@
//Meant to store information for dynamicly adding stuff to TGUI
//How to do: Make a child of info_tab. Every child of that child is a section of the TGUI info tab
//Then use subtypesof() on the original child to get all the information of its children
/datum/info_tab
var/section = null
var/section_text = null
/datum/info_tab/icecream_vat
/datum/info_tab/icecream_vat/vat_instructions
section = "Vat Instructions"
section_text = "The ice cream vat allows you to select and dispense both ice cream scoops and cones, along with scooping ice cream scoops onto cones. The selected scoop will be scooped into cones, while the selected cone is what is dispensed by alt-clicking the vat. To scoop a cone, select a scoop type and then right-click the vat with an empty cone. Cones can only have one scoop of ice cream."
/datum/info_tab/icecream_vat/restocking
section = "Restocking"
section_text = "The ice cream vat can be restocked with new ice cream scoops and cones by left-clicking on the vat with said item. The vat can also be restocked by left-clicking on the vat with an ice cream carton with scoops. Doing so will transfer the scoops into the vat."
/datum/info_tab/icecream_vat/storage_capacity
section = "Storage Capacity"
section_text = "The ice cream vat has a storage capacity of 120 scoops and cones combined."
/datum/info_tab/icecream_vat/new_scoops
section = "Creating New Scoops"
section_text = "Scoops are made by mixing 10u of any ice cream reagent with 2u of ice. To make ice cream reagents, you will need to start with plain ice cream, which is made by mixing 5u of cream, 3u of sugar, 2u of salt, and then cooling the mixture to 272 Kelvin. To make the reagents of flavored ice cream, just mix 10u of plain ice cream with 2u of a valid flavor reagent such as vanilla."
/datum/info_tab/icecream_vat/new_cones
section = "Creating New Cones"
section_text = "Cones are made in the crafting menu in the misc. food tab. They require a raw pastry base and 2u of their flavor reagent. Once you have made the raw cone, process it with a food processor to turn it into a finished cone."

View File

@@ -373,8 +373,7 @@
/obj/item/reagent_containers/food/snacks/cookie/bacon,
/obj/item/reagent_containers/food/snacks/cookie/cloth,
/obj/item/reagent_containers/food/snacks/lollipop,
/obj/item/reagent_containers/food/snacks/gumball,
/obj/item/reagent_containers/food/snacks/icecream // Becomes vanilla icecream down the line.
/obj/item/reagent_containers/food/snacks/gumball
)
// A list of surfaces that we are allowed to place things on.
var/list/allowed_surfaces = list(/obj/structure/table, /turf/open/floor)
@@ -398,10 +397,7 @@
/obj/item/borg_snack_dispenser/attack_self(mob/user, modifiers)
var/list/choices = list()
for(var/atom/snack as anything in valid_snacks)
if(snack == /obj/item/reagent_containers/food/snacks/icecream)
choices["vanilla icecream"] = snack // Would be "ice cream cone" in the menu otherwise.
else
choices[initial(snack.name)] = snack
choices[initial(snack.name)] = snack
if(!length(choices))
to_chat(user, span_warning("No valid snacks in database."))
if(length(choices) == 1)
@@ -441,13 +437,6 @@
patron.put_in_hand(snack, empty_hand)
user.do_item_attack_animation(patron, null, snack)
playsound(loc, 'sound/machines/click.ogg', 10, TRUE)
// Vanilla Icecream & Setting 'snack.name' Early
if(istype(snack, /obj/item/reagent_containers/food/snacks/icecream))
var/obj/item/reagent_containers/food/snacks/icecream/icecream = snack
icecream.add_ice_cream("vanilla")
icecream.desc = "Eat the ice cream."
to_chat(patron, span_notice("[user] dispenses a [snack.name] into your empty hand and you reflexively grasp it."))
to_chat(user, span_notice("You dispense a [snack.name] into the hand of [patron]."))
@@ -479,20 +468,12 @@
RegisterSignal(snack, COMSIG_MOVABLE_THROW_LANDED, PROC_REF(post_throw))
snack.throw_at(target, 7, 2, user, TRUE, FALSE)
playsound(loc, 'sound/machines/click.ogg', 10, TRUE)
if(istype(snack, /obj/item/reagent_containers/food/snacks/icecream))
var/obj/item/reagent_containers/food/snacks/icecream/icecream = snack
icecream.add_ice_cream("vanilla")
icecream.desc = "Eat the ice cream."
user.visible_message(span_notice("[src] launches a [snack.name] at [target]!"))
user.newtonian_move(get_dir(target, user)) // For no gravity.
else if(user.Adjacent(target) && is_allowed(target, user))
COOLDOWN_START(src, last_snack_disp, cooldown)
snack = new selected_snack(get_turf(target))
playsound(loc, 'sound/machines/click.ogg', 10, TRUE)
if(istype(snack, /obj/item/reagent_containers/food/snacks/icecream))
var/obj/item/reagent_containers/food/snacks/icecream/icecream = snack
icecream.add_ice_cream("vanilla")
icecream.desc = "Eat the ice cream."
user.visible_message(span_notice("[user] dispenses a [snack.name]."))
if(snack && user.emagged && istype(snack, /obj/item/reagent_containers/food/snacks/cookie))
@@ -517,7 +498,7 @@
/obj/item/borg_snack_dispenser/medical
name = "\improper Treat Borg Snack Dispenser" // Not calling this "Medical Borg Snack Dispenser" since Service & Clown Cyborgs use this too.
desc = "A dispenser that dispenses treats such as lollipops and gumballs!"
valid_snacks = list(/obj/item/reagent_containers/food/snacks/lollipop, /obj/item/reagent_containers/food/snacks/gumball, /obj/item/reagent_containers/food/snacks/icecream)
valid_snacks = list(/obj/item/reagent_containers/food/snacks/lollipop, /obj/item/reagent_containers/food/snacks/gumball)
#define PKBORG_DAMPEN_CYCLE_DELAY 20

View File

@@ -330,9 +330,6 @@ GLOBAL_LIST_EMPTY(crematoriums)
RemoveElement(/datum/element/update_icon_blocker)
connected = new /obj/structure/tray/cremator(src)
connected.connected = src
if(mapload && prob(1))
new /obj/structure/bodycontainer/crematorium/creamatorium(get_turf(src))
qdel(src)
/obj/structure/bodycontainer/crematorium/update_icon_state()
. = ..()
@@ -432,21 +429,6 @@ GLOBAL_LIST_EMPTY(crematoriums)
update_appearance(UPDATE_ICON)
playsound(src.loc, 'sound/machines/ding.ogg', 50, 1) //you horrible people
/obj/structure/bodycontainer/crematorium/creamatorium
name = "crematorium"
desc = "A human incinerator. Works well during ice cream socials."
/obj/structure/bodycontainer/crematorium/creamatorium/finish_cremate(mob/user)
var/list/icecreams = new()
for(var/i_scream in get_all_contents(/mob/living))
var/obj/item/reagent_containers/food/snacks/icecream/IC = new()
IC.set_cone_type("waffle")
IC.add_mob_flavor(i_scream)
icecreams += IC
. = ..()
for(var/obj/IC in icecreams)
IC.forceMove(src)
/*
* Generic Tray
* Parent class for morguetray and crematoriumtray

View File

@@ -1,16 +1,3 @@
#define ICECREAM_VANILLA 1
#define ICECREAM_CHOCOLATE 2
#define ICECREAM_STRAWBERRY 3
#define ICECREAM_BLUE 4
#define ICECREAM_LEMON 5
#define ICECREAM_CARAMEL 6
#define ICECREAM_BANANA 7
#define ICECREAM_ORANGE 8
#define ICECREAM_PEACH 9
#define ICECREAM_CHERRY_CHOCOLATE 10
#define CONE_WAFFLE 11
#define CONE_CHOC 12
/obj/machinery/icecream_vat
name = "ice cream vat"
desc = "Ding-aling ding dong. Get your Nanotrasen-approved ice cream!"
@@ -21,290 +8,406 @@
use_power = NO_POWER_USE
layer = BELOW_OBJ_LAYER
max_integrity = 300
var/list/product_types = list()
var/dispense_flavour = ICECREAM_VANILLA
var/flavour_name = "vanilla"
var/static/list/icecream_vat_reagents = list(
/datum/reagent/consumable/milk = 6,
/datum/reagent/consumable/flour = 6,
/datum/reagent/consumable/sugar = 6,
/datum/reagent/consumable/ice = 6,
/datum/reagent/consumable/coco = 6,
/datum/reagent/consumable/vanilla = 5,
/datum/reagent/consumable/berryjuice = 5,
/datum/reagent/consumable/ethanol/singulo = 5,
/datum/reagent/consumable/lemonjuice = 5,
/datum/reagent/consumable/caramel = 5,
/datum/reagent/consumable/banana = 5,
/datum/reagent/consumable/orangejuice = 5,
/datum/reagent/consumable/cream = 5,
/datum/reagent/consumable/peachjuice = 5,
/datum/reagent/consumable/cherryjelly = 5)
//Ice cream to be dispensed into cone on attackby
var/selected_scoop = null
//Cone to be dispensed with alt click
var/selected_cone = null
//Max amount of items that can be in vat's storage
var/storage_capacity = 120
//If it starts empty or not
var/start_empty = FALSE
//Sound made when an item is dispensed
var/dispense_sound = 'sound/machines/click.ogg'
//Sound made when selecting/deselecting an item
var/select_sound = 'sound/machines/doorclick.ogg'
//Items to be added upon creation to the vat and what is shown in the UI
var/list/ui_list = list(
/obj/item/reagent_containers/food/snacks/ice_cream_scoop,
/obj/item/reagent_containers/food/snacks/ice_cream_scoop/vanilla,
/obj/item/reagent_containers/food/snacks/ice_cream_scoop/chocolate,
/obj/item/reagent_containers/food/snacks/ice_cream_scoop/strawberry,
/obj/item/reagent_containers/food/snacks/ice_cream_scoop/blue,
/obj/item/reagent_containers/food/snacks/ice_cream_scoop/lemon_sorbet,
/obj/item/reagent_containers/food/snacks/ice_cream_scoop/caramel,
/obj/item/reagent_containers/food/snacks/ice_cream_scoop/banana,
/obj/item/reagent_containers/food/snacks/ice_cream_scoop/orange_creamsicle,
/obj/item/reagent_containers/food/snacks/ice_cream_scoop/peach,
/obj/item/reagent_containers/food/snacks/ice_cream_scoop/cherry_chocolate,
/obj/item/reagent_containers/food/snacks/ice_cream_scoop/meat,
/obj/item/reagent_containers/food/snacks/ice_cream_cone/cake,
/obj/item/reagent_containers/food/snacks/ice_cream_cone/chocolate)
//Please don't add anything other than scoops or cones to the list or it could/maybe/possibly/definitely break it
/obj/machinery/icecream_vat/proc/get_ingredient_list(type)
switch(type)
if(ICECREAM_CHOCOLATE)
return list(/datum/reagent/consumable/milk, /datum/reagent/consumable/ice, /datum/reagent/consumable/coco)
if(ICECREAM_STRAWBERRY)
return list(/datum/reagent/consumable/milk, /datum/reagent/consumable/ice, /datum/reagent/consumable/berryjuice)
if(ICECREAM_BLUE)
return list(/datum/reagent/consumable/milk, /datum/reagent/consumable/ice, /datum/reagent/consumable/ethanol/singulo)
if(ICECREAM_LEMON)
return list(/datum/reagent/consumable/ice, /datum/reagent/consumable/lemonjuice)
if(ICECREAM_CARAMEL)
return list(/datum/reagent/consumable/milk, /datum/reagent/consumable/ice, /datum/reagent/consumable/caramel)
if(ICECREAM_BANANA)
return list(/datum/reagent/consumable/milk, /datum/reagent/consumable/ice, /datum/reagent/consumable/banana)
if(ICECREAM_ORANGE)
return list(/datum/reagent/consumable/cream, /datum/reagent/consumable/ice, /datum/reagent/consumable/orangejuice)
if(ICECREAM_PEACH)
return list(/datum/reagent/consumable/milk, /datum/reagent/consumable/ice, /datum/reagent/consumable/peachjuice)
if(ICECREAM_CHERRY_CHOCOLATE)
return list(/datum/reagent/consumable/milk, /datum/reagent/consumable/ice, /datum/reagent/consumable/coco, /datum/reagent/consumable/cherryjelly)
if(CONE_WAFFLE)
return list(/datum/reagent/consumable/flour, /datum/reagent/consumable/sugar)
if(CONE_CHOC)
return list(/datum/reagent/consumable/flour, /datum/reagent/consumable/sugar, /datum/reagent/consumable/coco)
else //ICECREAM_VANILLA
return list(/datum/reagent/consumable/milk, /datum/reagent/consumable/ice, /datum/reagent/consumable/vanilla)
/obj/machinery/icecream_vat/ui_interact(mob/user, datum/tgui/ui) //Thanks bug eating lizard for helping me with the UI
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "IceCreamVat", name)
ui.open()
ui.set_autoupdate(TRUE)
/obj/machinery/icecream_vat/ui_data(mob/user)
//Define variables from UI
var/list/data = list()
data["cones"] = list()
data["ice_cream"] = list()
data["tabs"] = list()
/obj/machinery/icecream_vat/proc/get_flavour_name(flavour_type)
switch(flavour_type)
if(ICECREAM_CHOCOLATE)
return "chocolate"
if(ICECREAM_STRAWBERRY)
return "strawberry"
if(ICECREAM_BLUE)
return "blue"
if(ICECREAM_LEMON)
return "lemon sorbet"
if(ICECREAM_CARAMEL)
return "caramel"
if(ICECREAM_BANANA)
return "banana"
if(ICECREAM_ORANGE)
return "orangesicle"
if(ICECREAM_PEACH)
return "peach"
if(ICECREAM_CHERRY_CHOCOLATE)
return "cherry chocolate"
if(CONE_WAFFLE)
return "waffle"
if(CONE_CHOC)
return "chocolate"
else //ICECREAM_VANILLA
return "vanilla"
//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/snacks/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")
//Sort into different data lists depending on what the item is
if(istype(item, /obj/item/reagent_containers/food/snacks/ice_cream_scoop))
details["selected_item"] = selected_scoop
data["ice_cream"] += list(details)
else
details["selected_item"] = selected_cone
data["cones"] += list(details)
//Loop through children of /datum/info_tab/icecream_vat for data to send to info tab
for(var/info_detail in subtypesof(/datum/info_tab/icecream_vat))
//Create needed list and variable for geting data for UI
var/list/details = list()
var/datum/info_tab/icecream_vat/item = new info_detail
//Get info from children
details["section_title"] = item.section
details["section_text"] = item.section_text
//Add info to data
data["info_tab"] += list(details)
//Send stored information to UI
return data
/obj/machinery/icecream_vat/ui_act(action, list/params)
. = ..()
if(.)
return
switch(action)
if("select")
var/itemPath = text2path(params["itemPath"])
select_item(itemPath)
if("dispense")
var/itemPath = text2path(params["itemPath"])
dispense_item(itemPath)
/obj/machinery/icecream_vat/Initialize(mapload)
. = ..()
while(product_types.len < 12)
product_types.Add(5)
create_reagents(100, NO_REACT | OPENCONTAINER)
for(var/reagent in icecream_vat_reagents)
reagents.add_reagent(reagent, icecream_vat_reagents[reagent])
if(!start_empty)
/obj/machinery/icecream_vat/ui_interact(mob/user)
//Loop through and add items from ui_list into content
for(var/item in ui_list)
var/loop_cycles = 5
var/obj/item/reagent_containers/food/snacks/check_item = new item
//5 of every scoop; 10 of every cone
if(istype(check_item, /obj/item/reagent_containers/food/snacks/ice_cream_cone))
loop_cycles = 10
//Add amount of items to the list depending on type
for(var/i in 1 to loop_cycles)
new item(src)
/obj/machinery/icecream_vat/examine(mob/user)
. = ..()
var/dat
dat += "<b>ICE CREAM</b><br><div class='statusDisplay'>"
dat += "<b>Dispensing: [flavour_name] icecream </b> <br><br>"
dat += "<b>Vanilla ice cream:</b> <a href='?src=[REF(src)];select=[ICECREAM_VANILLA]'><b>Select</b></a> <a href='?src=[REF(src)];make=[ICECREAM_VANILLA];amount=1'><b>Make</b></a> <a href='?src=[REF(src)];make=[ICECREAM_VANILLA];amount=5'><b>x5</b></a> [product_types[ICECREAM_VANILLA]] scoops left. (Ingredients: milk, ice, vanilla powder)<br>"
dat += "<b>Strawberry ice cream:</b> <a href='?src=[REF(src)];select=[ICECREAM_STRAWBERRY]'><b>Select</b></a> <a href='?src=[REF(src)];make=[ICECREAM_STRAWBERRY];amount=1'><b>Make</b></a> <a href='?src=[REF(src)];make=[ICECREAM_STRAWBERRY];amount=5'><b>x5</b></a> [product_types[ICECREAM_STRAWBERRY]] dollops left. (Ingredients: milk, ice, berry juice)<br>"
dat += "<b>Chocolate ice cream:</b> <a href='?src=[REF(src)];select=[ICECREAM_CHOCOLATE]'><b>Select</b></a> <a href='?src=[REF(src)];make=[ICECREAM_CHOCOLATE];amount=1'><b>Make</b></a> <a href='?src=[REF(src)];make=[ICECREAM_CHOCOLATE];amount=5'><b>x5</b></a> [product_types[ICECREAM_CHOCOLATE]] dollops left. (Ingredients: milk, ice, coco powder)<br>"
dat += "<b>Blue ice cream:</b> <a href='?src=[REF(src)];select=[ICECREAM_BLUE]'><b>Select</b></a> <a href='?src=[REF(src)];make=[ICECREAM_BLUE];amount=1'><b>Make</b></a> <a href='?src=[REF(src)];make=[ICECREAM_BLUE];amount=5'><b>x5</b></a> [product_types[ICECREAM_BLUE]] dollops left. (Ingredients: milk, ice, singulo)<br>"
dat += "<b>Lemon sorbet ice cream:</b> <a href='?src=[REF(src)];select=[ICECREAM_LEMON]'><b>Select</b></a> <a href='?src=[REF(src)];make=[ICECREAM_LEMON];amount=1'><b>Make</b></a> <a href='?src=[REF(src)];make=[ICECREAM_LEMON];amount=5'><b>x5</b></a> [product_types[ICECREAM_LEMON]] dollops left. (Ingredients: ice, lemon juice)<br>"
dat += "<b>Caramel ice cream:</b> <a href='?src=[REF(src)];select=[ICECREAM_CARAMEL]'><b>Select</b></a> <a href='?src=[REF(src)];make=[ICECREAM_CARAMEL];amount=1'><b>Make</b></a> <a href='?src=[REF(src)];make=[ICECREAM_CARAMEL];amount=5'><b>x5</b></a> [product_types[ICECREAM_CARAMEL]] dollops left. (Ingredients: milk, ice, caramel)<br>"
dat += "<b>Banana ice cream:</b> <a href='?src=[REF(src)];select=[ICECREAM_BANANA]'><b>Select</b></a> <a href='?src=[REF(src)];make=[ICECREAM_BANANA];amount=1'><b>Make</b></a> <a href='?src=[REF(src)];make=[ICECREAM_BANANA];amount=5'><b>x5</b></a> [product_types[ICECREAM_BANANA]] dollops left. (Ingredients: milk, ice, banana juice)<br>"
dat += "<b>Orangesicle ice cream:</b> <a href='?src=[REF(src)];select=[ICECREAM_ORANGE]'><b>Select</b></a> <a href='?src=[REF(src)];make=[ICECREAM_ORANGE];amount=1'><b>Make</b></a> <a href='?src=[REF(src)];make=[ICECREAM_ORANGE];amount=5'><b>x5</b></a> [product_types[ICECREAM_ORANGE]] dollops left. (Ingredients: cream, ice, orange juice)<br>"
dat += "<b>Peach ice cream:</b> <a href='?src=[REF(src)];select=[ICECREAM_PEACH]'><b>Select</b></a> <a href='?src=[REF(src)];make=[ICECREAM_PEACH];amount=1'><b>Make</b></a> <a href='?src=[REF(src)];make=[ICECREAM_PEACH];amount=5'><b>x5</b></a> [product_types[ICECREAM_PEACH]] dollops left. (Ingredients: milk, ice, peach juice)<br>"
dat += "<b>Cherry chocolate ice cream:</b> <a href='?src=[REF(src)];select=[ICECREAM_CHERRY_CHOCOLATE]'><b>Select</b></a> <a href='?src=[REF(src)];make=[ICECREAM_CHERRY_CHOCOLATE];amount=1'><b>Make</b></a> <a href='?src=[REF(src)];make=[ICECREAM_CHERRY_CHOCOLATE];amount=5'><b>x5</b></a> [product_types[ICECREAM_CHERRY_CHOCOLATE]] dollops left. (Ingredients: milk, ice, coco powder, cherry jelly)<br></div>"
dat += "<br><b>CONES</b><br><div class='statusDisplay'>"
dat += "<b>Waffle cones:</b> <a href='?src=[REF(src)];cone=[CONE_WAFFLE]'><b>Dispense</b></a> <a href='?src=[REF(src)];make=[CONE_WAFFLE];amount=1'><b>Make</b></a> <a href='?src=[REF(src)];make=[CONE_WAFFLE];amount=5'><b>x5</b></a> [product_types[CONE_WAFFLE]] cones left. (Ingredients: flour, sugar)<br>"
dat += "<b>Chocolate cones:</b> <a href='?src=[REF(src)];cone=[CONE_CHOC]'><b>Dispense</b></a> <a href='?src=[REF(src)];make=[CONE_CHOC];amount=1'><b>Make</b></a> <a href='?src=[REF(src)];make=[CONE_CHOC];amount=5'><b>x5</b></a> [product_types[CONE_CHOC]] cones left. (Ingredients: flour, sugar, coco powder)<br></div>"
dat += "<br>"
dat += "<b>VAT CONTENT</b><br>"
for(var/datum/reagent/R in reagents.reagent_list)
dat += "[R.name]: [R.volume]"
dat += "<A href='?src=[REF(src)];disposeI=[R.type]'>Purge</A><BR>"
dat += "<a href='?src=[REF(src)];refresh=1'>Refresh</a> <a href='?src=[REF(src)];close=1'>Close</a>"
var/datum/browser/popup = new(user, "icecreamvat","Icecream Vat", 700, 500, src)
popup.set_content(dat)
popup.open()
//Selected cones
if(selected_cone == null)
. += span_notice("You can <b>Alt Click</b> to dispense a cone once one is selected.")
else
var/obj/item/reagent_containers/food/snacks/examine_cone = new selected_cone
. += span_notice("<b>Alt Click</b> to dispense [examine_cone.name].")
/obj/machinery/icecream_vat/attackby(obj/item/O, mob/user, params)
if(istype(O, /obj/item/reagent_containers/food/snacks/icecream))
var/obj/item/reagent_containers/food/snacks/icecream/I = O
if(!I.ice_creamed)
if(product_types[dispense_flavour] > 0)
visible_message("[icon2html(src, viewers(src))] [span_info("[user] scoops delicious [flavour_name] ice cream into [I].")]")
product_types[dispense_flavour] -= 1
I.add_ice_cream(flavour_name)
if(I.reagents.total_volume < 10)
I.reagents.add_reagent(/datum/reagent/consumable/sugar, 10 - I.reagents.total_volume)
//Selected scoops
if(selected_scoop == null)
. += span_notice("No ice cream scoop currently selected.")
else
var/obj/item/reagent_containers/food/snacks/examine_scoop = new selected_scoop
. += span_notice("[examine_scoop.name] is currently selected.")
//Scooping cone instruction
. += span_notice("<b>Right Click</b> to add a scoop to a cone.")
//For dispensing selected cone
/obj/machinery/icecream_vat/AltClick(mob/living/carbon/user)
if(selected_cone != null)
dispense_item(selected_cone)
else
user.balloon_alert(user, "None selected!")
/obj/machinery/icecream_vat/attackby_secondary(obj/item/A, mob/user, params)
//For scooping cones
scoop_cone(A)
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
//For adding items to storage
/obj/machinery/icecream_vat/attackby(obj/item/A, mob/user, params)
//For adding individual items
if(istype(A, /obj/item/reagent_containers/food/snacks/ice_cream_cone) || istype(A, /obj/item/reagent_containers/food/snacks/ice_cream_scoop))
storage_single(A)
//Adding carton contents to storage
else if(istype(A, /obj/item/storage/box/ice_cream_carton))
storage_container(A)
..()
/obj/machinery/icecream_vat/proc/find_amount(obj/item/counting_item)
var/amount = 0
//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
return amount
/obj/machinery/icecream_vat/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/snacks/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)
else
//For Alt click and because UI buttons are slow to disable themselves
user.balloon_alert(user, "All out!")
/obj/machinery/icecream_vat/proc/select_item(received_item, mob/user = usr)
//Make a variable for checking the type of the selected item
var/obj/item/reagent_containers/food/snacks/ui_item = new received_item
//Deselecting
if(istype(ui_item, /obj/item/reagent_containers/food/snacks/ice_cream_cone))
if(selected_cone == ui_item.type)
user.visible_message(span_notice("[user] deselects [ui_item.name] from [src]."), span_notice("You deselect [ui_item.name] from [src]."))
selected_cone = null
playsound(src, select_sound, 25, TRUE, extrarange = -3)
return
else if(selected_scoop == ui_item.type)
user.visible_message(span_notice("[user] deselects [ui_item.name] from [src]."), span_notice("You deselect [ui_item.name] from [src]."))
selected_scoop = null
playsound(src, select_sound, 25, TRUE, extrarange = -3)
return
//Selecting
if(find_amount(ui_item.type) > 0)
//Set item to selected based on its type
if(istype(ui_item, /obj/item/reagent_containers/food/snacks/ice_cream_cone))
selected_cone = ui_item.type
else
selected_scoop = ui_item.type
playsound(src, select_sound, 25, TRUE, extrarange = -3)
user.visible_message(span_notice("[user] sets [src] to dispense [ui_item.name]s."), span_notice("You set [src] to dispense [ui_item.name]s."))
//Prevent them from selecting items that the vat does not have
else
user.balloon_alert(user, "All out!")
/obj/machinery/icecream_vat/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
/obj/machinery/icecream_vat/proc/storage_single(obj/item/target_item, mob/user = usr)
//Check if there is room
if(contents.len < storage_capacity)
//If a cone, check if it has already been scooped. If it has, do not store it
if(istype(target_item, /obj/item/reagent_containers/food/snacks/ice_cream_cone))
var/obj/item/reagent_containers/food/snacks/ice_cream_cone/cone = target_item
if(cone.scooped == TRUE)
user.balloon_alert(user, "Cannot store scooped cones!")
return
//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/icecream_vat/proc/storage_container(obj/item/target_container, mob/user = usr)
var/end_message = "[user] empties the [target_container] into [src]."
var/end_self_message = "You empty the [target_container] into [src]."
//Check to see if it is empty
if(target_container.contents.len > 0 && contents.len < storage_capacity)
//Hide carton's storage UI to prevent ghost scoop bug
SEND_SIGNAL(target_container, COMSIG_TRY_STORAGE_HIDE_FROM, user)
//Loop through all contents
for(var/obj/item/reagent_containers/food/snacks/ice_cream_scoop/carton_item in target_container)
//Transfer items one at a time
carton_item.forceMove(src)
if(contents.len >= storage_capacity)
//Unique message depending on carton and vat contents
if(target_container.contents.len == 0)
end_message = "[user] empties the [target_container] into [src], filling it to its capacity."
end_self_message = "You empty the [target_container] into [src], filling it to its capacity."
else
end_message = "[user] fills [src] to its capacity, with some ice cream still in the [target_container]."
end_self_message = "You fill [src] to its capacity, with some ice cream still in the [target_container]."
break
user.visible_message(span_notice(end_message), span_notice(end_self_message))
playsound(src, 'sound/effects/rustle2.ogg', 50, TRUE, extrarange = -3)
return
else
if(target_container.contents.len == 0)
user.balloon_alert(user, "Carton empty!")
else
user.balloon_alert(user, "Vat full!")
return
/obj/machinery/icecream_vat/proc/scoop_cone(obj/item/target_cone, mob/user = usr)
//Check if item is a cone
if(istype(target_cone, /obj/item/reagent_containers/food/snacks/ice_cream_cone))
var/obj/item/reagent_containers/food/snacks/ice_cream_cone/cone = target_cone
//Check if cone is scooped
if(cone.scooped == FALSE)
//Check if a scoop has been selected
if(selected_scoop != null)
//Check if there are any of selected scoop in contents
if(find_amount(selected_scoop) > 0)
//Select last of selected scoop in contents
var/obj/item/reagent_containers/food/snacks/cone_scoop = LAZYACCESS(contents, last_index(selected_scoop))
//Remove scoop from contents and add relevant variables to cone
cone_scoop.forceMove(loc)
cone.reagents.reagent_list += cone_scoop.reagents.reagent_list
cone.foodtype = cone_scoop.foodtype
//Change description of cone
cone.desc = "[cone.base_desc] with a [cone_scoop.name]."
//Add overlay of scoop to cone
cone.add_overlay(cone_scoop.icon_state)
//Alert that the cone has been scooped
user.visible_message(span_notice("[user] scoops a [cone_scoop.name] into the [cone.name]"), span_notice("You scoop a [cone_scoop.name] into the [cone.name]"))
//Set scooped to TRUE
cone.scooped = TRUE
//Delete scoop
qdel(cone_scoop)
playsound(src, 'sound/effects/rustle2.ogg', 50, TRUE, extrarange = -3)
//Warn user that there are no selected scoops left
else
user.balloon_alert(user, "No selected scoops in storage!")
//Warn user about no selected scoop
else
to_chat(user, span_warning("There is not enough ice cream left!"))
user.balloon_alert(user, "No scoop selected!")
//Warn user about cone already being scooped
else
to_chat(user, span_notice("[O] already has ice cream in it."))
return 1
else if(O.is_drainable())
return
user.balloon_alert(user, "Already scooped!")
//Warn user about invalid item
else
return ..()
user.balloon_alert(user, "Invalid item!")
/obj/machinery/icecream_vat/proc/make(mob/user, make_type, amount)
for(var/R in get_ingredient_list(make_type))
if(reagents.has_reagent(R, amount))
continue
amount = 0
break
if(amount)
for(var/R in get_ingredient_list(make_type))
reagents.remove_reagent(R, amount)
product_types[make_type] += amount
var/flavour = get_flavour_name(make_type)
if(make_type > 4)
src.visible_message(span_info("[user] cooks up some [flavour] cones."))
else
src.visible_message(span_info("[user] whips up some [flavour] icecream."))
else
to_chat(user, span_warning("You don't have the ingredients to make this!"))
///////////////////
//ICE CREAM CONES//
///////////////////
/obj/machinery/icecream_vat/Topic(href, href_list)
if(..())
return
if(href_list["select"])
dispense_flavour = text2num(href_list["select"])
flavour_name = get_flavour_name(dispense_flavour)
src.visible_message(span_notice("[usr] sets [src] to dispense [flavour_name] flavoured ice cream."))
if(href_list["cone"])
var/dispense_cone = text2num(href_list["cone"])
var/cone_name = get_flavour_name(dispense_cone)
if(product_types[dispense_cone] >= 1)
product_types[dispense_cone] -= 1
var/obj/item/reagent_containers/food/snacks/icecream/I = new(src.loc)
I.set_cone_type(cone_name)
src.visible_message(span_info("[usr] dispenses a crunchy [cone_name] cone from [src]."))
else
to_chat(usr, span_warning("There are no [cone_name] cones left!"))
if(href_list["make"])
var/amount = (text2num(href_list["amount"]))
var/C = text2num(href_list["make"])
make(usr, C, amount)
if(href_list["disposeI"])
reagents.del_reagent(href_list["disposeI"])
updateDialog()
if(href_list["refresh"])
updateDialog()
if(href_list["close"])
usr.unset_machine()
usr << browse(null,"window=icecreamvat")
return
/obj/item/reagent_containers/food/snacks/icecream
name = "ice cream cone"
desc = "Delicious waffle cone, but no ice cream."
/obj/item/reagent_containers/food/snacks/ice_cream_cone
name = "ice cream cone base"
desc = "Please report this, as this should not be seen."
icon = 'icons/obj/kitchen.dmi'
icon_state = "icecream_cone_waffle" //default for admin-spawned cones, href_list["cone"] should overwrite this all the time
var/ice_creamed = 0
var/cone_type
bitesize = 3
foodtype = GRAIN
tastes = list("cold" = 6, "creamy" = 4)
//Used for changing the description after being scooped
var/base_desc = null
//If the cone has a scoop or not
var/scooped = FALSE
//For adding chems to specific cones
var/extra_reagent = null
//Amount of extra_reagent to add to cone
var/extra_reagent_amount = 1
/obj/item/reagent_containers/food/snacks/icecream/Initialize(mapload)
/obj/item/reagent_containers/food/snacks/ice_cream_cone/Initialize(mapload)
. = ..()
create_reagents(20)
reagents.add_reagent(/datum/reagent/consumable/nutriment, 4)
if(extra_reagent != null)
reagents.add_reagent(extra_reagent, extra_reagent_amount)
/obj/item/reagent_containers/food/snacks/icecream/proc/set_cone_type(cone_name)
cone_type = cone_name
icon_state = "icecream_cone_[cone_name]"
switch (cone_type)
if ("waffle")
reagents.add_reagent(/datum/reagent/consumable/nutriment, 1)
if ("chocolate")
reagents.add_reagent(/datum/reagent/consumable/coco, 1) // chocolate ain't as nutritious kids
/obj/item/reagent_containers/food/snacks/ice_cream_cone/cake
name = "cake ice cream cone"
desc = "A delicious cake cone, but with no ice cream."
icon_state = "icecream_cone_waffle"
tastes = list("bland" = 6)
base_desc = "A delicious cake cone"
extra_reagent = /datum/reagent/consumable/sugar
/obj/item/reagent_containers/food/snacks/ice_cream_cone/chocolate
name = "chocolate ice cream cone"
desc = "A delicious chocolate cone, but with no ice cream."
icon_state = "icecream_cone_chocolate"
tastes = list("bland" = 4, "chocolate" = 6)
base_desc = "A delicious chocolate cone"
extra_reagent = /datum/reagent/consumable/coco
desc = "Delicious [cone_name] cone, but no ice cream."
///////////////////////////
//ICE CREAM CONE CRAFTING//
///////////////////////////
/obj/item/reagent_containers/food/snacks/raw_cone
name = "base raw cone"
desc = "Please report this, as this should not be seen."
icon = 'icons/obj/food/food_ingredients.dmi'
bonus_reagents = list(/datum/reagent/consumable/nutriment = 2)
list_reagents = list(/datum/reagent/consumable/nutriment = 4)
tastes = list("bland" = 6)
foodtype = GRAIN | DAIRY
/obj/item/reagent_containers/food/snacks/icecream/proc/add_ice_cream(flavour_name)
name = "[flavour_name] icecream"
src.add_overlay("icecream_[flavour_name]")
switch (flavour_name) // adding the actual reagents advertised in the ingredient list
if ("vanilla")
desc = "A delicious [cone_type] cone filled with vanilla ice cream. All the other ice creams take content from it."
foodtype = DAIRY | SUGAR
if ("chocolate")
desc = "A delicious [cone_type] cone filled with chocolate ice cream. Surprisingly, made with real cocoa."
foodtype = DAIRY | CHOCOLATE | SUGAR
reagents.add_reagent(/datum/reagent/consumable/coco, 2)
if ("strawberry")
desc = "A delicious [cone_type] cone filled with strawberry ice cream. Definitely not made with real strawberries."
foodtype = DAIRY | FRUIT | SUGAR
reagents.add_reagent(/datum/reagent/consumable/berryjuice, 2)
if ("blue")
desc = "A delicious [cone_type] cone filled with blue ice cream. Made with real... blue?"
foodtype = DAIRY | SUGAR | ALCOHOL
reagents.add_reagent(/datum/reagent/consumable/ethanol/singulo, 2)
if ("lemon sorbet")
desc = "A delicious [cone_type] cone filled with lemon sorbet. Like frozen lemonade in a cone."
foodtype = SUGAR | FRUIT
reagents.add_reagent(/datum/reagent/consumable/lemonjuice, 2)
if ("caramel")
desc = "A delicious [cone_type] cone filled with caramel ice cream. It is deliciously sweet."
foodtype = DAIRY | SUGAR | CHOCOLATE
reagents.add_reagent(/datum/reagent/consumable/caramel, 2)
if ("banana")
desc = "A delicious [cone_type] cone filled with banana ice cream. Honk!"
foodtype = DAIRY | FRUIT | SUGAR
reagents.add_reagent(/datum/reagent/consumable/banana, 2)
if ("orangesicle")
desc = "A delicious [cone_type] cone filled with orange creamsicle. Not quite the same off the stick..."
foodtype = DAIRY | FRUIT | SUGAR
reagents.add_reagent(/datum/reagent/consumable/orangejuice, 2)
if ("peach")
desc = "A delicious [cone_type] cone filled with limited edition peach flavour. Enjoy it while it lasts!"
foodtype = DAIRY | FRUIT | SUGAR
reagents.add_reagent(/datum/reagent/consumable/peachjuice, 2)
if ("cherry chocolate")
desc = "A delicious [cone_type] cone filled with cherry chocolate ice cream. It is wonderfully tangy and sweet."
foodtype = DAIRY | FRUIT | SUGAR | CHOCOLATE
reagents.add_reagent(/datum/reagent/consumable/cherryjelly, 2)
if ("mob")
desc = "A suspicious [cone_type] cone filled with bright red ice cream. That's probably not strawberry..."
foodtype = DAIRY | MICE | SUGAR
reagents.add_reagent(/datum/reagent/liquidgibs, 2)
ice_creamed = 1
/obj/item/reagent_containers/food/snacks/raw_cone/cake
name = "raw cake cone"
desc = "A raw cake cone that needs to be processed."
icon_state = "raw_cake_cone"
/obj/item/reagent_containers/food/snacks/icecream/proc/add_mob_flavor(mob/M)
add_ice_cream("mob")
name = "[M.name] icecream"
/obj/machinery/icecream_vat/deconstruct(disassembled = TRUE)
if(!(flags_1 & NODECONSTRUCT_1))
new /obj/item/stack/sheet/metal(loc, 4)
qdel(src)
#undef ICECREAM_VANILLA
#undef ICECREAM_CHOCOLATE
#undef ICECREAM_STRAWBERRY
#undef ICECREAM_BLUE
#undef ICECREAM_LEMON
#undef ICECREAM_CARAMEL
#undef ICECREAM_BANANA
#undef ICECREAM_ORANGE
#undef ICECREAM_PEACH
#undef ICECREAM_CHERRY_CHOCOLATE
#undef CONE_WAFFLE
#undef CONE_CHOC
/obj/item/reagent_containers/food/snacks/raw_cone/chocolate
name = "raw chocolate cone"
desc = "A raw chocolate cone that needs to be processed."
icon_state = "raw_chocolate_cone"

View File

@@ -77,6 +77,14 @@
input = /obj/item/reagent_containers/food/snacks/grown/parsnip
output = /obj/item/reagent_containers/food/snacks/roastparsnip
/datum/food_processor_process/raw_cake_cone
input = /obj/item/reagent_containers/food/snacks/raw_cone/cake
output = /obj/item/reagent_containers/food/snacks/ice_cream_cone/cake
/datum/food_processor_process/raw_chocolate_cone
input = /obj/item/reagent_containers/food/snacks/raw_cone/chocolate
output = /obj/item/reagent_containers/food/snacks/ice_cream_cone/chocolate
/datum/food_processor_process/mob/slime
input = /mob/living/simple_animal/slime
output = null
@@ -116,4 +124,4 @@
/datum/food_processor_process/swissmix
input = /obj/item/reagent_containers/food/snacks/cheesemix_heated/swiss
output = /obj/item/reagent_containers/food/snacks/store/cheesewheel/swiss
output = /obj/item/reagent_containers/food/snacks/store/cheesewheel/swiss

View File

@@ -15,7 +15,7 @@
/datum/crafting_recipe/food/spacefreezy
name ="Space freezy"
reqs = list(
/obj/item/reagent_containers/food/snacks/icecream = 1,
/obj/item/reagent_containers/food/snacks/ice_cream_cone/cake = 1,
/datum/reagent/consumable/bluecherryjelly = 5,
/datum/reagent/consumable/space_cola/spacemountainwind = 15,
/obj/item/reagent_containers/food/snacks/ice_cream_scoop/vanilla = 1
@@ -26,7 +26,7 @@
/datum/crafting_recipe/food/sundae
name ="Sundae"
reqs = list(
/obj/item/reagent_containers/food/snacks/icecream = 1,
/obj/item/reagent_containers/food/snacks/ice_cream_cone/cake = 1,
/obj/item/reagent_containers/food/snacks/grown/cherries = 1,
/obj/item/reagent_containers/food/snacks/grown/banana = 1,
/obj/item/reagent_containers/food/snacks/ice_cream_scoop/vanilla = 1
@@ -37,7 +37,7 @@
/datum/crafting_recipe/food/honkdae
name ="Honkdae"
reqs = list(
/obj/item/reagent_containers/food/snacks/icecream = 1,
/obj/item/reagent_containers/food/snacks/ice_cream_cone/cake = 1,
/obj/item/clothing/mask/gas/clown_hat = 1,
/obj/item/reagent_containers/food/snacks/grown/cherries = 1,
/obj/item/reagent_containers/food/snacks/grown/banana = 2,

View File

@@ -357,3 +357,21 @@
)
result = /obj/item/reagent_containers/food/snacks/pineapple_friedrice
category = CAT_MISCFOOD
/datum/crafting_recipe/food/raw_cake_cone
name = "Raw Cake Cone"
reqs = list(
/obj/item/reagent_containers/food/snacks/rawpastrybase = 1,
/datum/reagent/consumable/sugar = 2
)
result = /obj/item/reagent_containers/food/snacks/raw_cone/cake
category = CAT_MISCFOOD
/datum/crafting_recipe/food/raw_chocolate_cone
name = "Raw Chocolate Cone"
reqs = list(
/obj/item/reagent_containers/food/snacks/rawpastrybase = 1,
/datum/reagent/consumable/coco = 2
)
result = /obj/item/reagent_containers/food/snacks/raw_cone/chocolate
category = CAT_MISCFOOD

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -0,0 +1,297 @@
import { capitalize } from 'common/string';
import { useBackend, useLocalState } from '../backend';
import { Button, Section, Table, Tabs, Box, TextArea, Stack } from '../components';
import { Window } from '../layouts';
import { resolveAsset } from './../assets';
// Store data for cones and scoops within Data
type Data = {
tabs: Tab[];
}
type Tab = {
cones: ConeStats[];
ice_cream: IceCreamStats[];
info_tab: InformationStats[];
}
// Stats specific for scoops
type IceCreamStats = {
item_image: string;
item_name: string;
item_quantity: number;
item_type_path: string;
selected_item: string;
}
// Stats specific for cones
type ConeStats = {
item_image: string;
item_name: string;
item_quantity: number;
item_type_path: string;
selected_item: string;
}
// Stats for info tab
type InformationStats = {
section_title: string;
section_text: string;
}
export const IceCreamVat = (props, context) => {
// Get information from backend code
const { data } = useBackend<Data>(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
<Window width={620} height={600} resizable>
{/* Add constants to window and make it scrollable */}
<Window.Content
scrollable>
{/* Create tabs for the vat and information tabs */}
<Tabs fluid>
<Tabs.Tab
icon="ice-cream"
bold
// Show the vat tab when the selectedMainTab is 0
selected={selectedMainTab === 0}
// Set selectedMainTab to 0 when the vat tab is clicked
onClick={() => setMainTab(0)}>
{/* Put 'Vat' in the tab to differentiate it from other tabs */}
Vat
</Tabs.Tab>
<Tabs.Tab
icon="info"
bold
// Show the information tab when the selectedMainTab is 1
selected={selectedMainTab === 1}
// Set selectedMainTab to 1 when the information tab is clicked
onClick={() => setMainTab(1)}>
{/* Put 'Information' in the tab to differentiate it from other tabs */}
Information
</Tabs.Tab>
</Tabs>
{/* If selectedMainTab is 0, show the UI elements in VatTab */}
{selectedMainTab === 0 && <VatTab />}
{/* If selectedMainTab is 1, show the UI elements in InfoTab */}
{selectedMainTab === 1 && <InfoTab />}
</Window.Content>
</Window>
);
};
const ConeRow = (props, context) => {
// Get data from ui_data in backend code
const { act, data } = useBackend<Tab>(context);
// Get cones information from data
const { cones = [] } = data;
return (
// Create Table for horizontal format
<Table>
{/* Use map to create dynamic rows based on the contents of cones, with flavor being the individual item and its stats */}
{cones.map(flavor => (
// Start row for holding ui elements and given data
<Table.Row
key={flavor.item_name}
fontSize="14px">
<Table.Cell>
{/* Get image and then add it to the ui */}
<Box
as="img"
src={resolveAsset(flavor.item_image)}
height="32px"
style={{
'-ms-interpolation-mode': 'nearest-neighbor',
'image-rendering': 'pixelated' }} />
</Table.Cell>
<Table.Cell
bold>
{/* Get name */}
{capitalize(flavor.item_name)}
</Table.Cell>
<Table.Cell
textAlign="right">
{/* Get amount of item in storage */}
{flavor.item_quantity} in storage
</Table.Cell>
<Table.Cell>
{/* Make select button */}
<Button
fluid
content="Select"
textAlign="center"
fontSize="16px"
// Make the button green if the row's item's type path matches the selected item's type path
selected={flavor.selected_item === flavor.item_type_path}
onClick={() => act("select", {
itemPath: flavor.item_type_path,
})}
/>
{/* Make dispense button */}
<Button
fluid
content="Dispense"
textAlign="center"
fontSize="16px"
// Dissable if there is none of the item in storage
disabled={(
flavor.item_quantity === 0
)}
onClick={() => act("dispense", {
itemPath: flavor.item_type_path,
})}
/>
</Table.Cell>
</Table.Row>
))}
</Table>
);
};
const IceCreamRow = (props, context) => {
// Get data from ui_data in backend code
const { act, data } = useBackend<Tab>(context);
// Get ice_cream information from data
const { ice_cream = [] } = data;
return (
// Create Table for horizontal format
<Table>
{/* Use map to create dynamic rows based on the contents of ice_cream, with flavor being the individual item and its stats */}
{ice_cream.map(flavor => (
// Start row for holding ui elements and given data
<Table.Row
key={flavor.item_name}
fontSize="14px">
<Table.Cell>
{/* Get image and then add it to the ui */}
<Box
as="img"
src={resolveAsset(flavor.item_image)}
height="32px"
style={{
'-ms-interpolation-mode': 'nearest-neighbor',
'image-rendering': 'pixelated' }} />
</Table.Cell>
<Table.Cell
bold>
{/* Get name */}
{capitalize(flavor.item_name)}
</Table.Cell>
<Table.Cell
textAlign="right">
{/* Get amount of item in storage */}
{flavor.item_quantity} in storage
</Table.Cell>
{/* Make select button */}
<Table.Cell>
<Button
fluid
content="Select"
textAlign="center"
fontSize="16px"
// Make the button green if the row's item's type path matches the selected item's type path
selected={flavor.selected_item === flavor.item_type_path}
onClick={() => act("select", {
itemPath: flavor.item_type_path,
})}
/>
{/* Make dispense button */}
<Button
fluid
content="Dispense"
textAlign="center"
fontSize="16px"
// Dissable if there is none of the item in storage
disabled={(
flavor.item_quantity === 0
)}
onClick={() => act("dispense", {
itemPath: flavor.item_type_path,
})}
/>
</Table.Cell>
</Table.Row>
))}
</Table>
);
};
const InfoContentRow = (props, context) => {
// Get data from ui_data in backend code
const { data } = useBackend<Tab>(context);
// Get info_tab information from data
const { info_tab = [] } = data;
// Make constant that starts with the section_text of the first element of info_tab and which will recieve new data from InfoTab
const[infoContent] = useLocalState(context, 'selectedInfoTab', info_tab[0].section_text);
// Return a section with the tab's section_text
return (
<Section
fontSize="16px">
{infoContent}
</Section>
);
};
const VatTab = (props, context) => {
// For organizing the vat tab's information
return (
<Stack vertical>
<Stack.Item>
<Section title="Cones">
<ConeRow />
</Section>
</Stack.Item>
<Stack.Item>
<Section title="Scoops">
<IceCreamRow />
</Section>
</Stack.Item>
</Stack>
);
};
const InfoTab = (props, context) => {
// Get data from ui_data in backend code
const { data } = useBackend<Tab>(context);
// Get info_tab information from data
const { info_tab = [] } = data;
// Make constant that starts with the section_text of the first element of info_tab and which can send new data to InfoContentRow
const [selectedInfoTab, setInfoTab] = useLocalState(context, 'selectedInfoTab', info_tab[0].section_text);
// Return organized elements for the main UI
return (
// Stack them for appealing layout
<Stack>
<Stack.Item>
{/* Start tabs and make them vertical */}
<Tabs vertical>
{/* Use map to allow for dynamic tabs */}
{info_tab.map(information => (
// Create new tab based on current info_tab element
<Tabs.Tab
bold
key={information.section_title}
// A tab is selected when the current element's section_text equals the value of selectedInfoTab
selected={information.section_text === selectedInfoTab}
// When clicked, selectedInfoTab will be set to the clicked tab's section_text
onClick={() => setInfoTab(information.section_text)}>
{/* Put the section_title in the tab to differentiate it from other tabs */}
{information.section_title}
</Tabs.Tab>
))}
</Tabs>
</Stack.Item>
{/* Show the section_text stored in selectedInfotab */}
<Stack.Item>
<InfoContentRow />
</Stack.Item>
</Stack>
);
};

View File

@@ -519,6 +519,7 @@
#include "code\datums\holocall.dm"
#include "code\datums\http.dm"
#include "code\datums\hud.dm"
#include "code\datums\info_tab.dm"
#include "code\datums\lazy_template.dm"
#include "code\datums\map_config.dm"
#include "code\datums\martial.dm"