forked from Skyrat-SS13/Skyrat-tg
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from GalacticStation/upstream-merge-80379
[MIRROR] Circuit action button refactor
- Loading branch information
Showing
13 changed files
with
268 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 0 additions & 65 deletions
65
code/modules/wiremod/components/abstract/equpiment_action.dm
This file was deleted.
Oops, something went wrong.
92 changes: 92 additions & 0 deletions
92
code/modules/wiremod/components/action/equpiment_action.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/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(lowertext(icon_options.value), " ", "_")]" |
Oops, something went wrong.