mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-12 07:33:34 +01:00
Port DmIcon & Image components from TG (#26623)
* Port DmIcon & Image components from TG * Documentation * Uh oh * I hate it * I will bang you
This commit is contained in:
@@ -271,12 +271,18 @@
|
||||
|
||||
/obj/item/stack/proc/build_recipe_data(datum/stack_recipe/recipe)
|
||||
var/list/data = list()
|
||||
var/obj/result = recipe.result_type
|
||||
|
||||
data["uid"] = recipe.UID()
|
||||
data["required_amount"] = recipe.req_amount
|
||||
data["result_amount"] = recipe.res_amount
|
||||
data["max_result_amount"] = recipe.max_res_amount
|
||||
data["image"] = recipe.image
|
||||
data["icon"] = result.icon
|
||||
data["icon_state"] = result.icon_state
|
||||
|
||||
// DmIcon cannot paint images. So, if we have grayscale sprite, we need ready base64 image.
|
||||
if(recipe.result_image)
|
||||
data["image"] = recipe.result_image
|
||||
|
||||
return data
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
/datum/stack_recipe
|
||||
/// Visible title of recipe
|
||||
var/title = "ERROR"
|
||||
/// Cached recipe result base64 image
|
||||
var/image
|
||||
/// Resulting typepath of crafted atom
|
||||
var/result_type
|
||||
/// Generated base64 image. Used only if result has color
|
||||
var/result_image
|
||||
/// Required stack amount to make
|
||||
var/req_amount = 1
|
||||
/// Amount of atoms made
|
||||
@@ -52,15 +52,14 @@
|
||||
src.window_checks = window_checks
|
||||
src.cult_structure = cult_structure
|
||||
|
||||
// We create base64 image only if item have color. Otherwise use icon_ref for TGUI
|
||||
var/obj/item/result = result_type
|
||||
var/icon/result_icon = icon(result::icon, result::icon_state, SOUTH, 1)
|
||||
var/paint = result::color
|
||||
|
||||
result_icon.Scale(32, 32)
|
||||
if(!isnull(paint) && paint != COLOR_WHITE)
|
||||
var/icon/result_icon = icon(result::icon, result::icon_state, SOUTH, 1)
|
||||
result_icon.Scale(32, 32)
|
||||
result_icon.Blend(paint, ICON_MULTIPLY)
|
||||
|
||||
src.image = "[icon2base64(result_icon)]"
|
||||
src.result_image = "[icon2base64(result_icon)]"
|
||||
|
||||
/// Returns TRUE if the recipe can be built, otherwise returns FALSE. This proc is only meant as a series of tests to check if construction is possible; the actual creation of the resulting atom should be handled in do_build()
|
||||
/datum/stack_recipe/proc/try_build(mob/user, obj/item/stack/material, multiplier)
|
||||
|
||||
Reference in New Issue
Block a user