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:
Aylong
2024-09-24 00:04:37 +03:00
committed by GitHub
parent f830f8c70c
commit 9d968e6ba9
27 changed files with 526 additions and 244 deletions
@@ -0,0 +1,28 @@
/// Maps icon names to ref values
/datum/asset/json/icon_ref_map
name = "icon_ref_map"
early = TRUE
/datum/asset/json/icon_ref_map/generate()
var/list/data = list() //"icons/obj/drinks.dmi" => "[0xc000020]"
//var/start = "0xc000000"
var/value = 0
while(TRUE)
value += 1
var/ref = "\[0xc[num2text(value,6,16)]\]"
var/mystery_meat = locate(ref)
if(isicon(mystery_meat))
if(!isfile(mystery_meat)) // Ignore the runtime icons for now
continue
var/path = get_icon_dmi_path(mystery_meat) //Try to get the icon path
if(path)
data[path] = ref
else if(mystery_meat)
continue; //Some other non-icon resource, ogg/json/whatever
else //Out of resources end this, could also try to end this earlier as soon as runtime generated icons appear but eh
break;
return data
@@ -1,13 +0,0 @@
/datum/asset/spritesheet/prize_counter
name = "prize_counter"
/datum/asset/spritesheet/prize_counter/create_spritesheets()
for(var/datum/prize_item/prize in GLOB.global_prizes.prizes)
var/obj/item/prize_item = prize.typepath
var/prize_icon = icon(icon = initial(prize_item.icon), icon_state = initial(prize_item.icon_state))
var/imgid = replacetext(replacetext("[prize_item]", "/obj/item/", ""), "/", "-")
Insert(imgid, prize_icon)
/datum/asset/spritesheet/prize_counter/ModifyInserted(icon/pre_asset)
pre_asset.Scale(64, 64)
return pre_asset