mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-20 20:45:28 +01:00
Makes vending use DMIcon where possible, halving the time it takes to make the vending spritesheet (#85085)
This commit is contained in:
@@ -6,22 +6,28 @@
|
||||
var/target_items = list()
|
||||
for(var/obj/machinery/vending/vendor as anything in typesof(/obj/machinery/vending))
|
||||
vendor = new vendor() // It seems `initial(list var)` has nothing. need to make a type.
|
||||
for(var/each in list(vendor.products, vendor.premium, vendor.contraband))
|
||||
target_items |= each
|
||||
target_items |= vendor.products
|
||||
target_items |= vendor.premium
|
||||
target_items |= vendor.contraband
|
||||
qdel(vendor)
|
||||
|
||||
// building icons for each item
|
||||
for (var/k in target_items)
|
||||
var/atom/item = k
|
||||
for (var/atom/item as anything in target_items)
|
||||
if (!ispath(item, /atom))
|
||||
continue
|
||||
|
||||
var/icon_file
|
||||
if (initial(item.greyscale_colors) && initial(item.greyscale_config))
|
||||
icon_file = SSgreyscale.GetColoredIconByType(initial(item.greyscale_config), initial(item.greyscale_colors))
|
||||
else
|
||||
icon_file = initial(item.icon)
|
||||
var/icon_state = initial(item.icon_state)
|
||||
var/icon_color = initial(item.color)
|
||||
// GAGS icons must be pregenerated
|
||||
if(initial(item.greyscale_config) && initial(item.greyscale_colors))
|
||||
icon_file = SSgreyscale.GetColoredIconByType(initial(item.greyscale_config), initial(item.greyscale_colors))
|
||||
// Colored atoms must be pregenerated
|
||||
else if(icon_color && icon_state)
|
||||
icon_file = initial(item.icon)
|
||||
// Otherwise we can rely on DMIcon, so skip it to save init time
|
||||
else
|
||||
continue
|
||||
|
||||
if (PERFORM_ALL_TESTS(focus_only/invalid_vending_machine_icon_states))
|
||||
var/icon_states_list = icon_states(icon_file)
|
||||
@@ -36,11 +42,10 @@
|
||||
stack_trace("[item] does not have a valid icon state, icon=[icon_file], icon_state=[json_encode(icon_state)]([text_ref(icon_state)]), icon_states=[icon_states_string]")
|
||||
continue
|
||||
|
||||
var/icon/I = icon(icon_file, icon_state, SOUTH)
|
||||
var/c = initial(item.color)
|
||||
if (!isnull(c) && c != COLOR_WHITE)
|
||||
I.Blend(c, ICON_MULTIPLY)
|
||||
var/icon/produced = icon(icon_file, icon_state, SOUTH)
|
||||
if (!isnull(icon_color) && icon_color != COLOR_WHITE)
|
||||
produced.Blend(icon_color, ICON_MULTIPLY)
|
||||
|
||||
var/imgid = replacetext(replacetext("[item]", "/obj/item/", ""), "/", "-")
|
||||
|
||||
Insert(imgid, I)
|
||||
Insert(imgid, produced)
|
||||
|
||||
Reference in New Issue
Block a user