Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsar-Salat authored Oct 6, 2023
1 parent 6984e0c commit bc38bdf
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions code/_onclick/hud/action_button.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand All @@ -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))
Expand Down

0 comments on commit bc38bdf

Please sign in to comment.