mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 21:18:37 +01:00
Cache design datum icons for sanic speed
This commit is contained in:
@@ -44,11 +44,48 @@ other types of metals and chemistry for reagents).
|
||||
var/dangerous_construction = FALSE //notify and log for admin investigations if this is printed.
|
||||
var/departmental_flags = NONE //bitflags for deplathes.
|
||||
var/list/datum/techweb_node/unlocked_by = list()
|
||||
var/icon_cache
|
||||
|
||||
/datum/design/Destroy()
|
||||
CRASH("DESIGN DATUMS SHOULD NOT EVER BE DESTROYED AS THEY ARE ONLY MEANT TO BE IN A GLOBAL LIST AND REFERENCED FOR US.")
|
||||
return ..()
|
||||
|
||||
/datum/design/proc/icon_html(client/user)
|
||||
if (!icon_cache)
|
||||
// construct the icon and slap it into the resource cache
|
||||
var/atom/item = build_path
|
||||
if (!ispath(item, /atom))
|
||||
// biogenerator outputs to beakers by default
|
||||
if (build_type & BIOGENERATOR)
|
||||
item = /obj/item/reagent_containers/glass/beaker/large
|
||||
else
|
||||
return // shouldn't happen, but just in case
|
||||
|
||||
// circuit boards become their resulting machines or computers
|
||||
if (ispath(item, /obj/item/circuitboard))
|
||||
var/obj/item/circuitboard/C = item
|
||||
var/machine = initial(C.build_path)
|
||||
if (machine)
|
||||
item = machine
|
||||
var/icon_file = initial(item.icon)
|
||||
var/icon/I = icon(icon_file, initial(item.icon_state), SOUTH)
|
||||
|
||||
// computers (and snowflakes) get their screen and keyboard sprites
|
||||
if (ispath(item, /obj/machinery/computer) || ispath(item, /obj/machinery/power/solar_control))
|
||||
var/obj/machinery/computer/C = item
|
||||
var/screen = initial(C.icon_screen)
|
||||
var/keyboard = initial(C.icon_keyboard)
|
||||
if (screen)
|
||||
I.Blend(icon(icon_file, screen, SOUTH), ICON_OVERLAY)
|
||||
if (keyboard)
|
||||
I.Blend(icon(icon_file, keyboard, SOUTH), ICON_OVERLAY)
|
||||
|
||||
// based on icon2html
|
||||
icon_cache = "[generate_asset_name(I)].png"
|
||||
register_asset(icon_cache, I)
|
||||
send_asset(user, icon_cache, FALSE)
|
||||
return "<img class='icon' src=\"[url_encode(icon_cache)]\">"
|
||||
|
||||
////////////////////////////////////////
|
||||
//Disks for transporting design datums//
|
||||
////////////////////////////////////////
|
||||
|
||||
@@ -570,23 +570,8 @@ doesn't have toxins access.
|
||||
l += "</tr></table>[RDSCREEN_NOBREAK]"
|
||||
return l
|
||||
|
||||
/obj/machinery/computer/rdconsole/proc/build_path_icon(atom/item, user)
|
||||
if (ispath(item, /obj/item/circuitboard))
|
||||
var/obj/item/circuitboard/C = item
|
||||
var/machine = initial(C.build_path)
|
||||
if (machine)
|
||||
item = machine
|
||||
var/icon_file = initial(item.icon)
|
||||
var/icon/item_icon = icon(icon_file, initial(item.icon_state), SOUTH)
|
||||
if (ispath(item, /obj/machinery/computer))
|
||||
var/obj/machinery/computer/C = item
|
||||
var/screen = initial(C.icon_screen)
|
||||
var/keyboard = initial(C.icon_keyboard)
|
||||
if (screen)
|
||||
item_icon.Blend(icon(icon_file, screen), ICON_OVERLAY)
|
||||
if (keyboard)
|
||||
item_icon.Blend(icon(icon_file, keyboard), ICON_OVERLAY)
|
||||
return icon2html(item_icon, user || usr)
|
||||
/obj/machinery/computer/rdconsole/proc/machine_icon(atom/item)
|
||||
return icon2html(initial(item.icon), usr, initial(item.icon_state), SOUTH)
|
||||
|
||||
/obj/machinery/computer/rdconsole/proc/ui_techweb_single_node(datum/techweb_node/node, selflink=TRUE, minimal=FALSE)
|
||||
var/list/l = list()
|
||||
@@ -612,7 +597,7 @@ doesn't have toxins access.
|
||||
l += "[node.description]"
|
||||
for(var/i in node.designs)
|
||||
var/datum/design/D = node.designs[i]
|
||||
l += "<span data-tooltip='[D.name]' onclick='location=\"?src=[REF(src)];view_design=[i];back_screen=[screen]\"'>[build_path_icon(D.build_path)]</span>[RDSCREEN_NOBREAK]"
|
||||
l += "<span data-tooltip='[D.name]' onclick='location=\"?src=[REF(src)];view_design=[i];back_screen=[screen]\"'>[D.icon_html(usr)]</span>[RDSCREEN_NOBREAK]"
|
||||
l += "</div>[RDSCREEN_NOBREAK]"
|
||||
return l
|
||||
|
||||
@@ -652,27 +637,27 @@ doesn't have toxins access.
|
||||
RDSCREEN_UI_SDESIGN_CHECK
|
||||
var/list/l = list()
|
||||
var/datum/design/D = selected_design
|
||||
l += "<div>[build_path_icon(D.build_path)] <b>[D.name]</b>"
|
||||
l += "<div>[D.icon_html(usr)] <b>[D.name]</b>"
|
||||
if(D.build_type)
|
||||
var/lathes = ""
|
||||
if(D.build_type & IMPRINTER)
|
||||
lathes += "<span data-tooltip='Circuit Imprinter'>[build_path_icon(/obj/machinery/rnd/circuit_imprinter)]</span>"
|
||||
lathes += "<span data-tooltip='Circuit Imprinter'>[machine_icon(/obj/machinery/rnd/circuit_imprinter)]</span>"
|
||||
if (linked_imprinter && D.id in stored_research.researched_designs)
|
||||
l += "<A href='?src=[REF(src)];search=1;type=imprint;to_search=[D.name]'>Imprint</A>"
|
||||
if(D.build_type & PROTOLATHE)
|
||||
lathes += "<span data-tooltip='Protolathe'>[build_path_icon(/obj/machinery/rnd/protolathe)]</span>"
|
||||
lathes += "<span data-tooltip='Protolathe'>[machine_icon(/obj/machinery/rnd/protolathe)]</span>"
|
||||
if (linked_lathe && D.id in stored_research.researched_designs)
|
||||
l += "<A href='?src=[REF(src)];search=1;type=proto;to_search=[D.name]'>Construct</A>"
|
||||
if(D.build_type & AUTOLATHE)
|
||||
lathes += "<span data-tooltip='Autolathe'>[build_path_icon(/obj/machinery/autolathe)]</span>"
|
||||
lathes += "<span data-tooltip='Autolathe'>[machine_icon(/obj/machinery/autolathe)]</span>"
|
||||
if(D.build_type & MECHFAB)
|
||||
lathes += "<span data-tooltip='Exosuit Fabricator'>[build_path_icon(/obj/machinery/mecha_part_fabricator)]</span>"
|
||||
lathes += "<span data-tooltip='Exosuit Fabricator'>[machine_icon(/obj/machinery/mecha_part_fabricator)]</span>"
|
||||
if(D.build_type & BIOGENERATOR)
|
||||
lathes += "<span data-tooltip='Biogenerator'>[build_path_icon(/obj/machinery/biogenerator)]</span>"
|
||||
lathes += "<span data-tooltip='Biogenerator'>[machine_icon(/obj/machinery/biogenerator)]</span>"
|
||||
if(D.build_type & LIMBGROWER)
|
||||
lathes += "<span data-tooltip='Limbgrower'>[build_path_icon(/obj/machinery/limbgrower)]</span>"
|
||||
lathes += "<span data-tooltip='Limbgrower'>[machine_icon(/obj/machinery/limbgrower)]</span>"
|
||||
if(D.build_type & SMELTER)
|
||||
lathes += "<span data-tooltip='Smelter'>[build_path_icon(/obj/machinery/mineral/processing_unit)]</span>"
|
||||
lathes += "<span data-tooltip='Smelter'>[machine_icon(/obj/machinery/mineral/processing_unit)]</span>"
|
||||
l += "Construction types:"
|
||||
l += lathes
|
||||
l += "Required materials:"
|
||||
|
||||
Reference in New Issue
Block a user