Skip to content

Commit

Permalink
Adds a verb to hide action buttons (#5304)
Browse files Browse the repository at this point in the history
Adds a verb on /client to show/hide action buttons
Makes it a new variable, as var/hidden also prevents the action from
being used

![image](https://github.com/cmss13-devs/cmss13/assets/56142455/1d78441c-5085-4165-a2b7-f7c3e9f7e2c3)

:cl:
qol: Adds the ability to hide your action buttons
/:cl:
  • Loading branch information
BeagleGaming1 authored and Doubleumc committed Aug 6, 2024
1 parent 31bc2b4 commit 4dcc684
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
8 changes: 4 additions & 4 deletions code/datums/action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
var/cost = 0 // By default an action has no cost -> will be utilized by skill actions/xeno actions
var/action_flags = 0 // Check out __game.dm for flags
/// Whether the action is hidden from its owner
/// Useful for when you want to preserve action state while preventing
/// a mob from using said action
var/hidden = FALSE
var/hidden = FALSE //Preserve action state while preventing mob from using action
///Hide the action from the owner without preventing them from using it (incase of keybind listen_signal)
var/player_hidden = FALSE
var/unique = TRUE
/// A signal on the mob that will cause the action to activate
var/listen_signal
Expand Down Expand Up @@ -227,7 +227,7 @@
var/atom/movable/screen/action_button/B = A.button
if(reload_screen)
client.add_to_screen(B)
if(A.hidden)
if(A.hidden || A.player_hidden)
B.screen_loc = null
continue
button_number++
Expand Down
29 changes: 29 additions & 0 deletions code/modules/client/client_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -820,3 +820,32 @@ GLOBAL_LIST_INIT(whitelisted_client_procs, list(
xeno_prefix = "XX"
if(!xeno_postfix || xeno_name_ban)
xeno_postfix = ""

/client/verb/action_hide_menu()
set name = "Show/Hide Actions"
set category = "IC"

var/mob/user = usr

var/list/actions_list = list()
for(var/datum/action/action as anything in user.actions)
var/action_name = action.name
if(action.player_hidden)
action_name += " (Hidden)"
actions_list[action_name] += action

if(!LAZYLEN(actions_list))
to_chat(user, SPAN_WARNING("You have no actions available."))
return

var/selected_action_name = tgui_input_list(user, "Show or hide selected action", "Show/Hide Actions", actions_list, 30 SECONDS)
if(!selected_action_name)
to_chat(user, SPAN_WARNING("You did not select an action."))
return

var/datum/action/selected_action = actions_list[selected_action_name]
selected_action.player_hidden = !selected_action.player_hidden
user.update_action_buttons()

if(!selected_action.player_hidden && selected_action.hidden) //Inform the player that even if they are unhiding it, itll still not be visible
to_chat(user, SPAN_NOTICE("[selected_action] is forcefully hidden, bypassing player unhiding."))

0 comments on commit 4dcc684

Please sign in to comment.