refactor: rename action button appearance related variables and procs to be clearer (#25658)

* refactor: make action appearance creation more straightforward

* some adjustments

* fix: adjust action icons to refactor
This commit is contained in:
Gaxeer
2024-07-01 02:29:31 +00:00
committed by GitHub
parent 49599aa2f6
commit 32e46c02aa
88 changed files with 357 additions and 350 deletions
+37 -33
View File
@@ -4,12 +4,15 @@
var/desc = null
var/obj/target = null
var/check_flags = 0
var/button_icon = 'icons/mob/actions/actions.dmi'
var/background_icon = 'icons/mob/actions/actions.dmi'
var/background_icon_state = ACTION_BUTTON_DEFAULT_BACKGROUND
/// Icon that our button screen object overlay and background
var/button_overlay_icon = 'icons/mob/actions/actions.dmi'
/// Icon state of screen object overlay
var/button_overlay_icon_state = ACTION_BUTTON_DEFAULT_OVERLAY
/// Icon that our button screen object background will have
var/button_background_icon = 'icons/mob/actions/actions.dmi'
/// Icon state of screen object background
var/button_background_icon_state = ACTION_BUTTON_DEFAULT_BACKGROUND
var/buttontooltipstyle = ""
var/icon_icon = 'icons/mob/actions/actions.dmi'
var/button_icon_state = "default"
var/transparent_when_unavailable = TRUE
var/mob/owner
/// Where any buttons we create should be by default. Accepts screen_loc and location defines
@@ -131,19 +134,19 @@
button.name = name
if(desc)
button.desc = "[desc] [initial(button.desc)]"
if(owner?.hud_used && background_icon_state == ACTION_BUTTON_DEFAULT_BACKGROUND)
if(owner?.hud_used && button_background_icon_state == ACTION_BUTTON_DEFAULT_BACKGROUND)
var/list/settings = owner.hud_used.get_action_buttons_icons()
if(button.icon != settings["bg_icon"])
button.icon = settings["bg_icon"]
if(button.icon_state != settings["bg_state"])
button.icon_state = settings["bg_state"]
else
if(button.icon != button_icon)
button.icon = button_icon
if(button.icon_state != background_icon_state)
button.icon_state = background_icon_state
if(button.icon != button_background_icon)
button.icon = button_background_icon
if(button.icon_state != button_background_icon_state)
button.icon_state = button_background_icon_state
ApplyIcon(button, force)
apply_button_overlay(button, force)
if(should_draw_cooldown())
apply_unavailable_effect(button)
@@ -225,10 +228,10 @@
B.add_overlay(img)
/datum/action/proc/ApplyIcon(atom/movable/screen/movable/action_button/current_button)
/datum/action/proc/apply_button_overlay(atom/movable/screen/movable/action_button/current_button)
current_button.cut_overlays()
if(icon_icon && button_icon_state)
var/image/img = image(icon_icon, current_button, button_icon_state)
if(button_overlay_icon && button_overlay_icon_state)
var/image/img = image(button_overlay_icon, current_button, button_overlay_icon_state)
img.appearance_flags = RESET_COLOR | RESET_ALPHA
img.pixel_x = 0
img.pixel_y = 0
@@ -245,8 +248,8 @@
I.actions += src
if(custom_icon && custom_icon_state)
use_itemicon = FALSE
icon_icon = custom_icon
button_icon_state = custom_icon_state
button_overlay_icon = custom_icon
button_overlay_icon_state = custom_icon_state
UpdateButtons()
/datum/action/item_action/Destroy()
@@ -263,7 +266,7 @@
I.ui_action_click(owner, type, left_click)
return TRUE
/datum/action/item_action/ApplyIcon(atom/movable/screen/movable/action_button/current_button)
/datum/action/item_action/apply_button_overlay(atom/movable/screen/movable/action_button/current_button)
if(use_itemicon)
if(target)
var/obj/item/I = target
@@ -299,7 +302,7 @@
/datum/action/item_action/print_forensic_report
name = "Print Report"
button_icon_state = "scanner_print"
button_overlay_icon_state = "scanner_print"
use_itemicon = FALSE
/datum/action/item_action/clear_records
@@ -358,7 +361,7 @@
/datum/action/item_action/toggle_unfriendly_fire
name = "Toggle Friendly Fire \[ON\]"
desc = "Toggles if the club's blasts cause friendly fire."
button_icon_state = "vortex_ff_on"
button_overlay_icon_state = "vortex_ff_on"
/datum/action/item_action/toggle_unfriendly_fire/Trigger(left_click)
if(..())
@@ -368,17 +371,17 @@
if(istype(target, /obj/item/hierophant_club))
var/obj/item/hierophant_club/H = target
if(H.friendly_fire_check)
button_icon_state = "vortex_ff_off"
button_overlay_icon_state = "vortex_ff_off"
name = "Toggle Friendly Fire \[OFF\]"
else
button_icon_state = "vortex_ff_on"
button_overlay_icon_state = "vortex_ff_on"
name = "Toggle Friendly Fire \[ON\]"
..()
/datum/action/item_action/vortex_recall
name = "Vortex Recall"
desc = "Recall yourself, and anyone nearby, to an attuned hierophant beacon at any time.<br>If the beacon is still attached, will detach it."
button_icon_state = "vortex_recall"
button_overlay_icon_state = "vortex_recall"
/datum/action/item_action/vortex_recall/IsAvailable()
if(istype(target, /obj/item/hierophant_club))
@@ -515,7 +518,7 @@
/datum/action/item_action/toggle_research_scanner
name = "Toggle Research Scanner"
button_icon_state = "scan_mode"
button_overlay_icon_state = "scan_mode"
/datum/action/item_action/toggle_research_scanner/Trigger(left_click)
if(IsAvailable())
@@ -528,10 +531,10 @@
owner.research_scanner = FALSE
..()
/datum/action/item_action/toggle_research_scanner/ApplyIcon(atom/movable/screen/movable/action_button/current_button)
/datum/action/item_action/toggle_research_scanner/apply_button_overlay(atom/movable/screen/movable/action_button/current_button)
current_button.cut_overlays()
if(button_icon && button_icon_state)
var/image/img = image(button_icon, current_button, "scan_mode")
if(button_overlay_icon && button_overlay_icon_state)
var/image/img = image(button_overlay_icon, current_button, "scan_mode")
img.appearance_flags = RESET_COLOR | RESET_ALPHA
current_button.overlays += img
@@ -557,14 +560,14 @@
/datum/action/item_action/slipping
name = "Tactical Slip"
desc = "Activates the clown shoes' ankle-stimulating module, allowing the user to do a short slip forward going under anyone."
button_icon_state = "clown"
button_overlay_icon_state = "clown"
// Jump boots
/datum/action/item_action/bhop
name = "Activate Jump Boots"
desc = "Activates the jump boot's internal propulsion system, allowing the user to dash over 4-wide gaps."
icon_icon = 'icons/mob/actions/actions.dmi'
button_icon_state = "jetboot"
button_overlay_icon = 'icons/mob/actions/actions.dmi'
button_overlay_icon_state = "jetboot"
use_itemicon = FALSE
@@ -644,7 +647,7 @@
//Preset for spells
/datum/action/spell_action
check_flags = 0
background_icon_state = "bg_spell"
button_background_icon_state = "bg_spell"
var/recharge_text_color = "#FFFFFF"
/datum/action/spell_action/New(Target)
@@ -653,9 +656,10 @@
S.action = src
name = S.name
desc = S.desc
button_icon = S.action_icon
button_icon_state = S.action_icon_state
background_icon_state = S.action_background_icon_state
button_overlay_icon = S.action_icon
button_background_icon = S.action_background_icon
button_overlay_icon_state = S.action_icon_state
button_background_icon_state = S.action_background_icon_state
UpdateButtons()
+1 -1
View File
@@ -273,4 +273,4 @@
/datum/action/zoom
name = "Toggle Scope"
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_RESTRAINED|AB_CHECK_STUNNED|AB_CHECK_LYING
button_icon_state = "sniper_zoom"
button_overlay_icon_state = "sniper_zoom"
+1 -1
View File
@@ -176,7 +176,7 @@
/datum/action/innate/end_holocall
name = "End Holocall"
button_icon_state = "camera_off"
button_overlay_icon_state = "camera_off"
var/datum/holocall/hcall
/datum/action/innate/end_holocall/New(Target, datum/holocall/HC)
+1
View File
@@ -110,6 +110,7 @@ GLOBAL_LIST_INIT(spells, typesof(/datum/spell))
var/datum/action/spell_action/action = null
var/action_icon = 'icons/mob/actions/actions.dmi'
var/action_icon_state = "spell_default"
var/action_background_icon = 'icons/mob/actions/actions.dmi'
var/action_background_icon_state = "bg_spell"
var/sound = null //The sound the spell makes when it is cast
@@ -15,7 +15,7 @@
/datum/spell/alien_spell/neurotoxin/update_spell_icon()
if(!action)
return
action.button_icon_state = "alien_neurotoxin_[active]"
action.button_overlay_icon_state = "alien_neurotoxin_[active]"
action.UpdateButtons()
/datum/spell/alien_spell/neurotoxin/cast(list/targets, mob/living/carbon/user)
+1 -1
View File
@@ -362,7 +362,7 @@
/datum/spell/fireball/update_spell_icon()
if(!action)
return
action.button_icon_state = "fireball[active]"
action.button_overlay_icon_state = "fireball[active]"
action.UpdateButtons()
/datum/spell/fireball/cast(list/targets, mob/living/user = usr)