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:
MrPerson
2017-04-25 12:15:16 +02:00
committed by AnturK
parent 572696292a
commit ff3f84ab81
151 changed files with 763 additions and 921 deletions
+14 -12
View File
@@ -51,7 +51,7 @@ GLOBAL_LIST_EMPTY(PDAs)
var/obj/item/device/paicard/pai = null // A slot for a personal AI device
var/image/photo = null //Scanned photo
var/icon/photo //Scanned photo
var/list/contained_item = list(/obj/item/weapon/pen, /obj/item/toy/crayon, /obj/item/weapon/lipstick, /obj/item/device/flashlight/pen, /obj/item/clothing/mask/cigarette)
var/obj/item/inserted_item //Used for pen, crayon, and lipstick insertion or removal. Same as above.
@@ -82,22 +82,24 @@ GLOBAL_LIST_EMPTY(PDAs)
/obj/item/device/pda/update_icon()
cut_overlays()
var/mutable_appearance/overlay = new()
overlay.pixel_x = overlays_x_offset
if(id)
var/image/I = image(icon_state = "id_overlay", pixel_x = overlays_x_offset)
add_overlay(I)
overlay.icon_state = "id_overlay"
add_overlay(new /mutable_appearance(overlay))
if(inserted_item)
var/image/I = image(icon_state = "insert_overlay", pixel_x = overlays_x_offset)
add_overlay(I)
overlay.icon_state = "insert_overlay"
add_overlay(new /mutable_appearance(overlay))
if(fon)
var/image/I = image(icon_state = "light_overlay", pixel_x = overlays_x_offset)
add_overlay(I)
overlay.icon_state = "light_overlay"
add_overlay(new /mutable_appearance(overlay))
if(pai)
if(pai.pai)
var/image/I = image(icon_state = "pai_overlay", pixel_x = overlays_x_offset)
add_overlay(I)
overlay.icon_state = "pai_overlay"
add_overlay(new /mutable_appearance(overlay))
else
var/image/I = image(icon_state = "pai_off_overlay", pixel_x = overlays_x_offset)
add_overlay(I)
overlay.icon_state = "pai_off_overlay"
add_overlay(new /mutable_appearance(overlay))
/obj/item/device/pda/MouseDrop(obj/over_object, src_location, over_location)
var/mob/M = usr
@@ -633,7 +635,7 @@ GLOBAL_LIST_EMPTY(PDAs)
to_chat(L, "\icon[src] <b>Message from [source.owner] ([source.ownjob]), </b>\"[msg.message]\"[msg.get_photo_ref()] (<a href='byond://?src=\ref[src];choice=Message;skiprefresh=1;target=\ref[source]'>Reply</a>)")
update_icon()
add_overlay(image(icon, icon_alert))
add_overlay(icon_alert)
/obj/item/device/pda/proc/show_to_ghosts(mob/living/user, datum/data_pda_msg/msg,multiple = 0)
for(var/mob/M in GLOB.player_list)
+2 -2
View File
@@ -23,6 +23,7 @@
update_icon() //Whatever happened, update the card's state (icon, name) to match.
/obj/item/device/aicard/update_icon()
cut_overlays()
if(AI)
name = "[initial(name)]- [AI.name]"
if(AI.stat == DEAD)
@@ -30,12 +31,11 @@
else
icon_state = "aicard-full"
if(!AI.control_disabled)
add_overlay(image('icons/obj/aicards.dmi', "aicard-on"))
add_overlay("aicard-on")
AI.cancel_camera()
else
name = initial(name)
icon_state = initial(icon_state)
cut_overlays()
/obj/item/device/aicard/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, \
datum/tgui/master_ui = null, datum/ui_state/state = GLOB.hands_state)
@@ -344,8 +344,9 @@
cut_overlays()
set_light(0)
else if(on)
var/image/I = image(icon,"glowstick-glow",color)
add_overlay(I)
var/mutable_appearance/glowstick_overlay = mutable_appearance(icon, "glowstick-glow")
glowstick_overlay.color = color
add_overlay(glowstick_overlay)
item_state = "glowstick-on"
set_light(brightness_on)
else