diff --git a/code/_onclick/hud/action_button.dm b/code/_onclick/hud/action_button.dm index d73e39784363c..d8313a8e922c1 100644 --- a/code/_onclick/hud/action_button.dm +++ b/code/_onclick/hud/action_button.dm @@ -43,7 +43,7 @@ /atom/movable/screen/movable/action_button/Click(location,control,params) if (!can_use(usr)) - return + return FALSE var/list/modifiers = params2list(params) if(LAZYACCESS(modifiers, SHIFT_CLICK)) @@ -75,10 +75,26 @@ desc = "Shift-click any button to reset its position, and Control-click it to lock it in place. Alt-click this button to reset all buttons to their default positions." icon = 'icons/mob/actions.dmi' icon_state = "bg_default" - var/hidden = 0 + var/hidden = FALSE var/hide_icon = 'icons/mob/actions.dmi' var/hide_state = "hide" var/show_state = "show" + var/mutable_appearance/hide_appearance + var/mutable_appearance/show_appearance + +/atom/movable/screen/movable/action_button/hide_toggle/Initialize(mapload) + . = ..() + var/static/list/icon_cache = list() + + var/cache_key = "[hide_icon][hide_state]" + hide_appearance = icon_cache[cache_key] + if(!hide_appearance) + hide_appearance = icon_cache[cache_key] = mutable_appearance(hide_icon, hide_state) + + cache_key = "[hide_icon][show_state]" + show_appearance = icon_cache[cache_key] + if(!show_appearance) + show_appearance = icon_cache[cache_key] = mutable_appearance(hide_icon, show_state) /atom/movable/screen/movable/action_button/hide_toggle/Click(location,control,params) if (!can_use(usr)) @@ -121,7 +137,7 @@ name = "Show Buttons" else name = "Hide Buttons" - update_icon() + update_appearance() usr.update_action_buttons() /atom/movable/screen/movable/action_button/hide_toggle/AltClick(mob/user) @@ -142,12 +158,11 @@ hide_icon = settings["toggle_icon"] hide_state = settings["toggle_hide"] show_state = settings["toggle_show"] - update_icon() - -/atom/movable/screen/movable/action_button/hide_toggle/update_icon() - cut_overlays() - add_overlay(mutable_appearance(hide_icon, hidden ? show_state : hide_state)) + update_appearance() +/atom/movable/screen/movable/action_button/hide_toggle/update_overlays() + . = ..() + . += hidden ? show_appearance : hide_appearance /atom/movable/screen/movable/action_button/MouseEntered(location,control,params) if(!QDELETED(src))