From 0ceeee4d0c795b84886a51511805de87a6caabc7 Mon Sep 17 00:00:00 2001 From: KomradeSpectre Date: Tue, 5 Feb 2019 23:20:38 -0500 Subject: [PATCH] Port vendor icon display instead of color from Yogs (#42653) Port of yogstation13/Yogstation-TG#2549 which is a port of Citadel-Station-13/Citadel-Station-13#7442 which is a port of OracleStation/OracleStation#50 This port visualizes items in all machines handled by _vending.dm, allowing a person to see what they're buying before buying it. This is very useful for clothing vendors for example, and much better than the previous system that had vending machines choose from three colors randomly. Credits to: * AndrewMontagne (Oracle, original implementation) * FlattestGuitar (Citadel) * nichlas0010 (Yogstation) --- code/_globalvars/lists/objects.dm | 1 + code/modules/vending/_vending.dm | 26 ++++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/code/_globalvars/lists/objects.dm b/code/_globalvars/lists/objects.dm index 14c752613bf..b5ba352bab1 100644 --- a/code/_globalvars/lists/objects.dm +++ b/code/_globalvars/lists/objects.dm @@ -13,6 +13,7 @@ GLOBAL_LIST_EMPTY(deliverybeacontags) //list of all tags associated with d GLOBAL_LIST_EMPTY(nuke_list) GLOBAL_LIST_EMPTY(alarmdisplay) //list of all machines or programs that can display station alerts GLOBAL_LIST_EMPTY(singularities) //list of all singularities on the station (actually technically all engines) +GLOBAL_LIST_EMPTY(vending_cache) GLOBAL_LIST(chemical_reactions_list) //list of all /datum/chemical_reaction datums. Used during chemical reactions GLOBAL_LIST(chemical_reagents_list) //list of all /datum/reagent datums indexed by reagent id. Used by chemistry stuff diff --git a/code/modules/vending/_vending.dm b/code/modules/vending/_vending.dm index dfc4d25fb94..3c2c6f59d10 100644 --- a/code/modules/vending/_vending.dm +++ b/code/modules/vending/_vending.dm @@ -21,7 +21,6 @@ IF YOU MODIFY THE PRODUCTS LIST OF A MACHINE, MAKE SURE TO UPDATE ITS RESUPPLY C var/product_path = null var/amount = 0 var/max_amount = 0 - var/display_color = "blue" var/custom_price var/custom_premium_price @@ -166,6 +165,15 @@ IF YOU MODIFY THE PRODUCTS LIST OF A MACHINE, MAKE SURE TO UPDATE ITS RESUPPLY C if (dump_amount >= 16) return +/obj/machinery/vending/proc/GetIconForProduct(datum/data/vending_product/P) + if(GLOB.vending_cache[P.product_path]) + return GLOB.vending_cache[P.product_path] + + var/product = new P.product_path() + GLOB.vending_cache[P.product_path] = icon2base64(getFlatIcon(product, no_anim = TRUE)) + qdel(product) + return GLOB.vending_cache[P.product_path] + /obj/machinery/vending/proc/build_inventory(list/productlist, list/recordlist, start_empty = FALSE) for(var/typepath in productlist) var/amount = productlist[typepath] @@ -179,7 +187,6 @@ IF YOU MODIFY THE PRODUCTS LIST OF A MACHINE, MAKE SURE TO UPDATE ITS RESUPPLY C if(!start_empty) R.amount = amount R.max_amount = amount - R.display_color = pick("#ff8080","#80ff80","#8080ff") R.custom_price = initial(temp.custom_price) R.custom_premium_price = initial(temp.custom_premium_price) recordlist += R @@ -335,7 +342,7 @@ IF YOU MODIFY THE PRODUCTS LIST OF A MACHINE, MAKE SURE TO UPDATE ITS RESUPPLY C var/list/display_records = product_records + coin_records if(extended_inventory) display_records = product_records + coin_records + hidden_records - dat += "