Files
Bubberstation/code/modules/wiremod/components/action/equpiment_action.dm
T
san7890andGitHub c403a6eccc Wraps lowertext() to ensure proper stringification. (#82442)
## About The Pull Request

Fixes #82440

This PR just creates a new macro, `LOWER_TEXT()` (yes the irony is not
lost on me) to wrap around all calls of `lowertext()` and ensure that
whatever we input into that proc will be stringified using the `"[]"`
(or `tostring()` for the nerds) operator. very simple.

I also added a linter to enforce this (and prevent all forms of
regression) because I think that machines should do the menial work and
we shouldn't expect maintainers to remember this, let me know if you
disagree. if there is a time when it should be opted out for some
reason, the linter does respect it if you wrap your input with the
`UNLINT()` function.
2024-04-10 12:19:43 -07:00

93 lines
2.3 KiB
Plaintext

/obj/item/circuit_component/equipment_action
display_name = "Equipment Action"
desc = "Represents an action the user can take when using supported shells."
required_shells = list(/obj/item/organ/internal/cyberimp/bci, /obj/item/mod/module/circuit)
/// The icon of the button
var/datum/port/input/option/icon_options
/// The name to use for the button
var/datum/port/input/button_name
/// The mob who activated their granted action
var/datum/port/output/user
/// Called when the user presses the button
var/datum/port/output/signal
/// An assoc list of datum REF()s, linked to the actions granted.
var/list/granted_to = list()
/obj/item/circuit_component/equipment_action/Initialize(mapload, default_icon)
. = ..()
if (!isnull(default_icon))
icon_options.set_input(default_icon)
button_name = add_input_port("Name", PORT_TYPE_STRING)
user = add_output_port("User", PORT_TYPE_USER)
signal = add_output_port("Signal", PORT_TYPE_SIGNAL)
/obj/item/circuit_component/equipment_action/Destroy()
QDEL_LIST_ASSOC_VAL(granted_to)
return ..()
/obj/item/circuit_component/equipment_action/populate_options()
var/static/action_options = list(
"Blank",
"One",
"Two",
"Three",
"Four",
"Five",
"Blood",
"Bomb",
"Brain",
"Brain Damage",
"Cross",
"Electricity",
"Exclamation",
"Heart",
"Id",
"Info",
"Injection",
"Magnetism",
"Minus",
"Network",
"Plus",
"Power",
"Question",
"Radioactive",
"Reaction",
"Repair",
"Say",
"Scan",
"Shield",
"Skull",
"Sleep",
"Wireless",
)
icon_options = add_option_port("Icon", action_options)
/obj/item/circuit_component/equipment_action/register_shell(atom/movable/shell)
. = ..()
SEND_SIGNAL(shell, COMSIG_CIRCUIT_ACTION_COMPONENT_REGISTERED, src)
/obj/item/circuit_component/equipment_action/unregister_shell(atom/movable/shell)
. = ..()
SEND_SIGNAL(shell, COMSIG_CIRCUIT_ACTION_COMPONENT_UNREGISTERED, src)
/obj/item/circuit_component/equipment_action/input_received(datum/port/input/port)
if (length(granted_to))
update_actions()
/obj/item/circuit_component/equipment_action/proc/update_actions()
for(var/ref in granted_to)
var/datum/action/granted_action = granted_to[ref]
granted_action.name = button_name.value || "Action"
granted_action.button_icon_state = "bci_[replacetextEx(LOWER_TEXT(icon_options.value), " ", "_")]"