Skip to content

Commit

Permalink
Changes bicon() to use the builtin 515 feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Exxion committed Dec 2, 2022
1 parent 1010fae commit cb367a7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 37 deletions.
4 changes: 2 additions & 2 deletions code/game/machinery/kitchen/smartfridge.dm
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
icon_state = "bloodbank"
icon_on = "bloodbank"

accepted_types = list(/obj/item/weapon/reagent_containers/blood)
accepted_types = list(/obj/item/weapon/reagent_containers/blood)

/obj/machinery/smartfridge/bloodbank/New()
. = ..()
Expand Down Expand Up @@ -336,7 +336,7 @@
if(istype(thisPile))
thisPile.addAmount(1)
else
piles[formatted_name] = new/datum/fridge_pile(formatted_name, src, 1, costly_bicon(O))
piles[formatted_name] = new/datum/fridge_pile(formatted_name, src, 1, bicon(O))


/obj/machinery/smartfridge/proc/dump_bag(var/obj/item/weapon/storage/bag/B, var/mob/user)
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/vending.dm
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ var/global/num_vending_terminals = 1
qdel(coinbox)
coinbox = null
..()

/obj/machinery/vending/splashable()
return FALSE

Expand Down Expand Up @@ -587,7 +587,7 @@ var/global/num_vending_terminals = 1
var/datum/data/vending_product/R = new()
R.custom = TRUE
R.product_name = item.product_name()
R.mini_icon = costly_bicon(item)
R.mini_icon = bicon(item)
R.display_color = pick("red", "blue", "green")
R.amount = 1
if(item.price) // price tagger - only works on new items
Expand Down
39 changes: 6 additions & 33 deletions goon/code/datums/browserOutput.dm
Original file line number Diff line number Diff line change
Expand Up @@ -238,45 +238,18 @@ For the main html chat area
var/list/partial = splittext(iconData, "{")
return replacetext(copytext(partial[2], 3, -5), "\n", "")

/proc/bicon(var/obj)
if (!obj)
return
/proc/bicon(atom/A)
if(isatom(A))
A = A.appearance //The caching is not very smart if you use the object directly.

spawn(5){} //Do nothing. Just hold onto a ref of A for a moment. Hopefully there will be a better way to do this later.

if (isicon(obj))
//Icons get pooled constantly, references are no good here.
/*if (!bicon_cache["\ref[obj]"]) // Doesn't exist yet, make it.
bicon_cache["\ref[obj]"] = icon2base64(obj)
return "<img class='icon misc' src='data:image/png;base64,[bicon_cache["\ref[obj]"]]'>"*/
return "<img class='icon misc' src='data:image/png;base64,[icon2base64(obj)]'>"

// Either an atom or somebody fucked up and is gonna get a runtime, which I'm fine with.
var/atom/A = obj
var/key = ("[A.icon]" || "\ref[A.icon]")+":[A.icon_state]"
if (!bicon_cache[key]) // Doesn't exist, make it.
var/icon/I = icon(A.icon, A.icon_state, SOUTH, 1, 0)
if (!"[A.icon]") // Shitty workaround for a BYOND issue.
var/icon/temp = I
I = icon()
I.Insert(temp, dir = SOUTH)
bicon_cache[key] = icon2base64(I, key)

return "<img class='icon [A.icon_state]' src='data:image/png;base64,[bicon_cache[key]]'>"
return "<img class='icon' src='\ref[A]'>"

//Aliases for bicon
/proc/bi(obj)
bicon(obj)

//Costlier version of bicon() that uses getFlatIcon() to account for overlays, underlays, etc. Use with extreme moderation, ESPECIALLY on mobs.
/proc/costly_bicon(var/obj)
if (!obj)
return

if (isicon(obj))
return bicon(obj)

var/icon/I = getFlatIcon(obj)
return bicon(I)

/proc/to_chat(target, message)
//Ok so I did my best but I accept that some calls to this will be for shit like sound and images
//It stands that we PROBABLY don't want to output those to the browser output so just handle them here
Expand Down

0 comments on commit cb367a7

Please sign in to comment.