From e6a5685456bb081f09f084e11650907cdf75ff2e Mon Sep 17 00:00:00 2001
From: Luc <89928798+lewcc@users.noreply.github.com>
Date: Fri, 29 Mar 2024 11:00:06 -0400
Subject: [PATCH] get locked idiot (#24852)
Co-authored-by: S34N <12197162+S34NW@users.noreply.github.com>
Co-authored-by: paradisess13[bot] <165046124+paradisess13[bot]@users.noreply.github.com>
---
code/_onclick/hud/action_button.dm | 31 +++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/code/_onclick/hud/action_button.dm b/code/_onclick/hud/action_button.dm
index b78612c0fbdc4..1eacfda422936 100644
--- a/code/_onclick/hud/action_button.dm
+++ b/code/_onclick/hud/action_button.dm
@@ -16,6 +16,8 @@
var/id
/// UID of the last thing we hovered over. Used for managing action button dragging.
var/last_hovered_ref
+ /// Whether or not this button is locked, preventing it from being dragged.
+ var/locked = FALSE
/atom/movable/screen/movable/action_button/Destroy()
. = ..()
@@ -38,7 +40,7 @@
// Very much byond logic, but I want nice behavior, so we fake it with drag
/atom/movable/screen/movable/action_button/MouseDrag(atom/over_object, src_location, over_location, src_control, over_control, params)
. = ..()
- if(!can_use(usr))
+ if(!can_use(usr) || locked)
return
@@ -64,6 +66,10 @@
last_hovered_ref = null
if(!can_use(usr))
return
+ if(locked)
+ fire_action()
+ return
+
var/datum/hud/our_hud = usr.hud_used
if(over_object == src)
our_hud.hide_landings()
@@ -100,6 +106,12 @@
var/position_info = SCRN_OBJ_DEFAULT
user.hud_used.position_action(src, position_info)
+/atom/movable/screen/movable/action_button/proc/fire_action(left_click = TRUE)
+ linked_action.Trigger(TRUE)
+ transform = transform.Scale(0.8, 0.8)
+ alpha = 200
+ animate(src, transform = matrix(), time = 0.4 SECONDS, alpha = 255)
+
/atom/movable/screen/movable/action_button/Click(location, control, params)
var/list/modifiers = params2list(params)
if(modifiers["ctrl"] && modifiers["shift"])
@@ -116,18 +128,23 @@
AltClick(usr)
return TRUE
if(modifiers["middle"])
- linked_action.Trigger(left_click = FALSE)
+ fire_action(TRUE)
return TRUE
if(modifiers["ctrl"])
CtrlClick(usr)
return TRUE
- linked_action.Trigger(TRUE)
- transform = transform.Scale(0.8, 0.8)
- alpha = 200
- animate(src, transform = matrix(), time = 0.4 SECONDS, alpha = 255)
+
+ fire_action(TRUE)
return TRUE
+/atom/movable/screen/movable/action_button/CtrlClick(mob/user)
+ if(!can_use(user))
+ return
+ locked = !locked
+ to_chat(user, "[src]'s button has been [locked ? "":"un"]locked.")
+
+
/**
* This is a silly proc used in hud code code to determine what icon and icon state we should be using
* for hud elements (such as action buttons) that don't have their own icon and icon state set.
@@ -215,7 +232,7 @@
/atom/movable/screen/button_palette
- desc = "Drag buttons to move them.
Shift-click any button to reset it.
Alt-click this to reset all buttons.
Ctrl-click this to get a detailed explanation of how to use this."
+ desc = "Drag buttons to move them.
Shift-click any button to reset it.
Alt-click this to reset all buttons.
Ctrl-click action buttons to lock or unlock them.
Ctrl-click this to get a detailed explanation of how to use this."
icon = 'icons/hud/64x16_actions.dmi'
icon_state = "screen_gen_palette"
screen_loc = ui_action_palette