mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 14:08:31 +01:00
Replaces /image with /mutable_appearance, where appropriate (#26518)
In cases where you're creating an image to use as an overlay, it makes more sense to use a mutable_appearance if you can. The image will create a static appearance for not just the image but also each intermediate step if you change vars along the way. The mutable appearance avoids this unnecessary and expensive process. The only situation that requires an image instead of a mutable_appearance is if the overlay is supposed to be directional. MA's ignore direction while images don't. I dunno why, probably another BYOND-ism. I added a convenience function, mutable_appearance(), designed to emulate image(). Also went ahead and set the default plane of /mutable_appearance to FLOAT_PLANE because it's fucking 0 by default. Several overlays that were image() calls were changed to just text strings when I could. overlays += "string" has the same result as overlays += image(icon, "string") and saves a proc call.
This commit is contained in:
@@ -93,12 +93,6 @@
|
||||
var/force_update = 0
|
||||
var/update_state = -1
|
||||
var/update_overlay = -1
|
||||
var/global/status_overlays = 0
|
||||
var/global/list/status_overlays_lock
|
||||
var/global/list/status_overlays_charging
|
||||
var/global/list/status_overlays_equipment
|
||||
var/global/list/status_overlays_lighting
|
||||
var/global/list/status_overlays_environ
|
||||
|
||||
|
||||
/obj/machinery/power/apc/connect_to_network()
|
||||
@@ -218,35 +212,6 @@
|
||||
// update the APC icon to show the three base states
|
||||
// also add overlays for indicator lights
|
||||
/obj/machinery/power/apc/update_icon()
|
||||
if (!status_overlays)
|
||||
status_overlays = 1
|
||||
status_overlays_lock = new(2)
|
||||
status_overlays_charging = new(3)
|
||||
status_overlays_equipment = new(4)
|
||||
status_overlays_lighting = new(4)
|
||||
status_overlays_environ = new(4)
|
||||
|
||||
status_overlays_lock[1] = image(icon, "apcox-0") // 0=blue 1=red
|
||||
status_overlays_lock[2] = image(icon, "apcox-1")
|
||||
|
||||
status_overlays_charging[1] = image(icon, "apco3-0")
|
||||
status_overlays_charging[2] = image(icon, "apco3-1")
|
||||
status_overlays_charging[3] = image(icon, "apco3-2")
|
||||
|
||||
status_overlays_equipment[1] = image(icon, "apco0-0")
|
||||
status_overlays_equipment[2] = image(icon, "apco0-1")
|
||||
status_overlays_equipment[3] = image(icon, "apco0-2")
|
||||
status_overlays_equipment[4] = image(icon, "apco0-3")
|
||||
|
||||
status_overlays_lighting[1] = image(icon, "apco1-0")
|
||||
status_overlays_lighting[2] = image(icon, "apco1-1")
|
||||
status_overlays_lighting[3] = image(icon, "apco1-2")
|
||||
status_overlays_lighting[4] = image(icon, "apco1-3")
|
||||
|
||||
status_overlays_environ[1] = image(icon, "apco2-0")
|
||||
status_overlays_environ[2] = image(icon, "apco2-1")
|
||||
status_overlays_environ[3] = image(icon, "apco2-2")
|
||||
status_overlays_environ[4] = image(icon, "apco2-3")
|
||||
|
||||
var/update = check_updates() //returns 0 if no need to update icons.
|
||||
// 1 if we need to update the icon_state
|
||||
@@ -283,12 +248,12 @@
|
||||
cut_overlays()
|
||||
if(!(stat & (BROKEN|MAINT)) && update_state & UPSTATE_ALLGOOD)
|
||||
var/list/O = list(
|
||||
status_overlays_lock[locked+1],
|
||||
status_overlays_charging[charging+1])
|
||||
"apcox-[locked]",
|
||||
"apco3-[charging]")
|
||||
if(operating)
|
||||
O += status_overlays_equipment[equipment+1]
|
||||
O += status_overlays_lighting[lighting+1]
|
||||
O += status_overlays_environ[environ+1]
|
||||
O += "apco0-[equipment]"
|
||||
O += "apco1-[lighting]"
|
||||
O += "apco2-[environ]"
|
||||
add_overlay(O)
|
||||
|
||||
// And now, seperately for cleanness, the lighting changing
|
||||
|
||||
@@ -49,13 +49,13 @@
|
||||
/obj/item/weapon/stock_parts/cell/proc/updateicon()
|
||||
cut_overlays()
|
||||
if(grown_battery)
|
||||
add_overlay(image('icons/obj/power.dmi', "grown_wires"))
|
||||
add_overlay("grown_wires")
|
||||
if(charge < 0.01)
|
||||
return
|
||||
else if(charge/maxcharge >=0.995)
|
||||
add_overlay(image('icons/obj/power.dmi', "cell-o2"))
|
||||
add_overlay("cell-o2")
|
||||
else
|
||||
add_overlay(image('icons/obj/power.dmi', "cell-o1"))
|
||||
add_overlay("cell-o1")
|
||||
|
||||
/obj/item/weapon/stock_parts/cell/proc/percent() // return % charge of cell
|
||||
return 100*charge/maxcharge
|
||||
|
||||
@@ -64,9 +64,9 @@
|
||||
cut_overlays()
|
||||
|
||||
if(lastgenlev != 0)
|
||||
add_overlay(image('icons/obj/power.dmi', "teg-op[lastgenlev]"))
|
||||
add_overlay("teg-op[lastgenlev]")
|
||||
|
||||
add_overlay(image('icons/obj/power.dmi', "teg-oc[lastcirc]"))
|
||||
add_overlay("teg-oc[lastcirc]")
|
||||
|
||||
|
||||
#define GENRATE 800 // generator output coefficient from Q
|
||||
|
||||
@@ -141,11 +141,11 @@ GLOBAL_LIST_EMPTY(rad_collectors)
|
||||
/obj/machinery/power/rad_collector/proc/update_icons()
|
||||
cut_overlays()
|
||||
if(loaded_tank)
|
||||
add_overlay(image('icons/obj/singularity.dmi', "ptank"))
|
||||
add_overlay("ptank")
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return
|
||||
if(active)
|
||||
add_overlay(image('icons/obj/singularity.dmi', "on"))
|
||||
add_overlay("on")
|
||||
|
||||
|
||||
/obj/machinery/power/rad_collector/proc/toggle_power()
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
var/area/A = get_area(src)
|
||||
if(A)
|
||||
var/image/alert_overlay = image('icons/effects/effects.dmi', "ghostalertsie")
|
||||
var/mutable_appearance/alert_overlay = mutable_appearance('icons/effects/effects.dmi', "ghostalertsie")
|
||||
notify_ghosts("Nar-Sie has risen in \the [A.name]. Reach out to the Geometer to be given a new shell for your soul.", source = src, alert_overlay = alert_overlay, action=NOTIFY_ATTACK)
|
||||
|
||||
narsie_spawn_animation()
|
||||
|
||||
@@ -38,9 +38,6 @@
|
||||
|
||||
var/obj/machinery/power/terminal/terminal = null
|
||||
|
||||
var/static/list/smesImageCache
|
||||
|
||||
|
||||
/obj/machinery/power/smes/examine(user)
|
||||
..()
|
||||
if(!terminal)
|
||||
@@ -226,36 +223,20 @@
|
||||
if(panel_open)
|
||||
return
|
||||
|
||||
if(!smesImageCache || !smesImageCache.len)
|
||||
smesImageCache = list()
|
||||
smesImageCache.len = 9
|
||||
|
||||
smesImageCache[SMES_CLEVEL_1] = image('icons/obj/power.dmi',"smes-og1")
|
||||
smesImageCache[SMES_CLEVEL_2] = image('icons/obj/power.dmi',"smes-og2")
|
||||
smesImageCache[SMES_CLEVEL_3] = image('icons/obj/power.dmi',"smes-og3")
|
||||
smesImageCache[SMES_CLEVEL_4] = image('icons/obj/power.dmi',"smes-og4")
|
||||
smesImageCache[SMES_CLEVEL_5] = image('icons/obj/power.dmi',"smes-og5")
|
||||
|
||||
smesImageCache[SMES_OUTPUTTING] = image('icons/obj/power.dmi', "smes-op1")
|
||||
smesImageCache[SMES_NOT_OUTPUTTING] = image('icons/obj/power.dmi',"smes-op0")
|
||||
smesImageCache[SMES_INPUTTING] = image('icons/obj/power.dmi', "smes-oc1")
|
||||
smesImageCache[SMES_INPUT_ATTEMPT] = image('icons/obj/power.dmi', "smes-oc0")
|
||||
|
||||
if(outputting)
|
||||
add_overlay(smesImageCache[SMES_OUTPUTTING])
|
||||
add_overlay("smes-op1")
|
||||
else
|
||||
add_overlay(smesImageCache[SMES_NOT_OUTPUTTING])
|
||||
add_overlay("smes-op0")
|
||||
|
||||
if(inputting)
|
||||
add_overlay(smesImageCache[SMES_INPUTTING])
|
||||
add_overlay("smes-oc1")
|
||||
else
|
||||
if(input_attempt)
|
||||
add_overlay(smesImageCache[SMES_INPUT_ATTEMPT])
|
||||
add_overlay("smes-oc0")
|
||||
|
||||
var/clevel = chargedisplay()
|
||||
if(clevel>0)
|
||||
add_overlay(smesImageCache[clevel])
|
||||
return
|
||||
add_overlay("smes-og[clevel]")
|
||||
|
||||
|
||||
/obj/machinery/power/smes/proc/chargedisplay()
|
||||
|
||||
@@ -103,9 +103,9 @@
|
||||
..()
|
||||
cut_overlays()
|
||||
if(stat & BROKEN)
|
||||
add_overlay(image('icons/obj/power.dmi', icon_state = "solar_panel-b", layer = FLY_LAYER))
|
||||
add_overlay(mutable_appearance(icon, "solar_panel-b", FLY_LAYER))
|
||||
else
|
||||
add_overlay(image('icons/obj/power.dmi', icon_state = "solar_panel", layer = FLY_LAYER))
|
||||
add_overlay(mutable_appearance(icon, "solar_panel", FLY_LAYER))
|
||||
src.setDir(angle2dir(adir))
|
||||
|
||||
//calculates the fraction of the sunlight that the panel recieves
|
||||
@@ -345,7 +345,8 @@
|
||||
else
|
||||
add_overlay(icon_screen)
|
||||
if(currentdir > -1)
|
||||
add_overlay(image('icons/obj/computer.dmi', "solcon-o", FLY_LAYER, angle2dir(currentdir)))
|
||||
setDir(angle2dir(currentdir))
|
||||
add_overlay(mutable_appearance(icon, "solcon-o", FLY_LAYER))
|
||||
|
||||
/obj/machinery/power/solar_control/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, \
|
||||
datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
|
||||
|
||||
@@ -170,13 +170,13 @@
|
||||
|
||||
|
||||
if(rpm>50000)
|
||||
add_overlay(image('icons/obj/atmospherics/pipes/simple.dmi', "comp-o4", FLY_LAYER))
|
||||
add_overlay(mutable_appearance(icon, "comp-o4", FLY_LAYER))
|
||||
else if(rpm>10000)
|
||||
add_overlay(image('icons/obj/atmospherics/pipes/simple.dmi', "comp-o3", FLY_LAYER))
|
||||
add_overlay(mutable_appearance(icon, "comp-o3", FLY_LAYER))
|
||||
else if(rpm>2000)
|
||||
add_overlay(image('icons/obj/atmospherics/pipes/simple.dmi', "comp-o2", FLY_LAYER))
|
||||
add_overlay(mutable_appearance(icon, "comp-o2", FLY_LAYER))
|
||||
else if(rpm>500)
|
||||
add_overlay(image('icons/obj/atmospherics/pipes/simple.dmi', "comp-o1", FLY_LAYER))
|
||||
add_overlay(mutable_appearance(icon, "comp-o1", FLY_LAYER))
|
||||
//TODO: DEFERRED
|
||||
|
||||
// These are crucial to working of a turbine - the stats modify the power output. TurbGenQ modifies how much raw energy can you get from
|
||||
@@ -255,7 +255,7 @@
|
||||
// If it works, put an overlay that it works!
|
||||
|
||||
if(lastgen > 100)
|
||||
add_overlay(image('icons/obj/atmospherics/pipes/simple.dmi', "turb-o", FLY_LAYER))
|
||||
add_overlay(mutable_appearance(icon, "turb-o", FLY_LAYER))
|
||||
|
||||
updateDialog()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user