From fb8313308e5c92c079ed730191ea5611771bea21 Mon Sep 17 00:00:00 2001 From: Arkatos1 Date: Tue, 21 May 2019 22:44:54 +0200 Subject: [PATCH 1/2] added action button ability to lock or unlock them in place --- code/_onclick/hud/action_button.dm | 29 ++++++++++++++------- code/_onclick/hud/movable_screen_objects.dm | 9 ++++--- code/datums/action.dm | 2 ++ 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/code/_onclick/hud/action_button.dm b/code/_onclick/hud/action_button.dm index 5780e86a298..d57a4d74bd6 100644 --- a/code/_onclick/hud/action_button.dm +++ b/code/_onclick/hud/action_button.dm @@ -1,4 +1,3 @@ - /obj/screen/movable/action_button var/datum/action/linked_action screen_loc = null @@ -6,18 +5,26 @@ /obj/screen/movable/action_button/Click(location,control,params) var/list/modifiers = params2list(params) if(modifiers["shift"]) - moved = 0 + if(locked) + to_chat(usr, "Action button \"[name]\" is locked, unlock it first.") + return TRUE + moved = FALSE usr.update_action_buttons() //redraw buttons that are no longer considered "moved" - return 1 - if(usr.next_move >= world.time) // Is this needed ? + return TRUE + if(modifiers["ctrl"]) + locked = !locked + to_chat(usr, "Action button \"[name]\" [locked ? "" : "un"]locked.") + return TRUE + if(usr.next_click > world.time) return + usr.next_click = world.time + 1 linked_action.Trigger() - return 1 + return TRUE //Hide/Show Action Buttons ... Button /obj/screen/movable/action_button/hide_toggle name = "Hide Buttons" - desc = "Shift-click any button to reset its position. Alt-click to reset all buttons to their default positions." + desc = "Shift-click any button to reset its position, and Control-click it to unlock/lock its position in place. Alt-click this button to reset all buttons to their default positions." icon = 'icons/mob/actions/actions.dmi' icon_state = "bg_default" var/hidden = 0 @@ -25,9 +32,16 @@ /obj/screen/movable/action_button/hide_toggle/Click(location,control,params) var/list/modifiers = params2list(params) if(modifiers["shift"]) + if(locked) + to_chat(usr, "Action button \"[name]\" is locked, unlock it first.") + return TRUE moved = FALSE usr.update_action_buttons(TRUE) return TRUE + if(modifiers["ctrl"]) + locked = !locked + to_chat(usr, "Action button \"[name]\" [locked ? "" : "un"]locked.") + return TRUE if(modifiers["alt"]) for(var/V in usr.actions) var/datum/action/A = V @@ -69,7 +83,6 @@ var/image/img = image(icon, src, hidden ? "show" : "hide") overlays += img - /obj/screen/movable/action_button/MouseEntered(location,control,params) openToolTip(usr,src,params,title = name,content = desc) @@ -77,7 +90,6 @@ /obj/screen/movable/action_button/MouseExited() closeToolTip(usr) - /mob/proc/update_action_buttons_icon() for(var/X in actions) var/datum/action/A = X @@ -122,7 +134,6 @@ client.screen += hud_used.hide_actions_toggle - #define AB_MAX_COLUMNS 10 /datum/hud/proc/ButtonNumberToScreenCoords(number) // TODO : Make this zero-indexed for readabilty diff --git a/code/_onclick/hud/movable_screen_objects.dm b/code/_onclick/hud/movable_screen_objects.dm index 668e0e67fc7..366931cea33 100644 --- a/code/_onclick/hud/movable_screen_objects.dm +++ b/code/_onclick/hud/movable_screen_objects.dm @@ -11,6 +11,7 @@ /obj/screen/movable var/snap2grid = FALSE var/moved = FALSE + var/locked = TRUE var/x_off = -16 var/y_off = -16 @@ -20,8 +21,10 @@ /obj/screen/movable/snap snap2grid = TRUE - /obj/screen/movable/MouseDrop(over_object, src_location, over_location, src_control, over_control, params) + if(locked) //no! I am locked! begone! + return + var/list/PM = params2list(params) //No screen-loc information? abort. @@ -47,7 +50,6 @@ moved = screen_loc - //Debug procs /client/proc/test_movable_UI() set category = "Debug" @@ -67,7 +69,6 @@ screen += M - /client/proc/test_snap_UI() set category = "Debug" set name = "Spawn Snap UI Object" @@ -84,4 +85,4 @@ S.screen_loc = screen_l - screen += S \ No newline at end of file + screen += S diff --git a/code/datums/action.dm b/code/datums/action.dm index 3b98a0fef1a..4815b3f8cac 100644 --- a/code/datums/action.dm +++ b/code/datums/action.dm @@ -43,6 +43,7 @@ M.actions += src if(M.client) M.client.screen += button + button.locked = TRUE M.update_action_buttons() /datum/action/proc/Remove(mob/M) @@ -52,6 +53,7 @@ if(M.client) M.client.screen -= button button.moved = FALSE //so the button appears in its normal position when given to another owner. + button.locked = FALSE M.actions -= src M.update_action_buttons() From 3b9c5eb3b94c9225c748504f960c636cd566b41b Mon Sep 17 00:00:00 2001 From: Arkatos1 Date: Tue, 21 May 2019 23:09:40 +0200 Subject: [PATCH 2/2] better description --- code/_onclick/hud/action_button.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/_onclick/hud/action_button.dm b/code/_onclick/hud/action_button.dm index d57a4d74bd6..15ed4429965 100644 --- a/code/_onclick/hud/action_button.dm +++ b/code/_onclick/hud/action_button.dm @@ -24,7 +24,7 @@ //Hide/Show Action Buttons ... Button /obj/screen/movable/action_button/hide_toggle name = "Hide Buttons" - desc = "Shift-click any button to reset its position, and Control-click it to unlock/lock its position in place. Alt-click this button to reset all buttons to their default positions." + desc = "Shift-click any button to reset its position, and Control-click it to lock/unlock its position. Alt-click this button to reset all buttons to their default positions." icon = 'icons/mob/actions/actions.dmi' icon_state = "bg_default" var/hidden = 0