From bc78411eacd79afd3176a26eb9c594743ca4e590 Mon Sep 17 00:00:00 2001 From: Shroopy Date: Fri, 17 Nov 2023 18:49:47 -0800 Subject: [PATCH] Adds a toggle action to implant HUDs (#79777) ## About The Pull Request Adds an action for all implanted HUDs to toggle them on and off. The default state is on, and the state is toggled appropriately when the implant is added or removed. This is done by using hud.hide_from and hud.show_to. ## Why It's Good For The Game Quality of life change for roleplay situations where the HUD is usless clutter. ## Changelog :cl: qol: Implanted HUDs can now be toggled on and off with an action. /:cl: --------- Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> --- code/datums/actions/items/toggles.dm | 11 +++++++++++ .../organs/internal/cyberimp/augments_eyes.dm | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/code/datums/actions/items/toggles.dm b/code/datums/actions/items/toggles.dm index bbdd2e9f7b9..53c9e4f53cc 100644 --- a/code/datums/actions/items/toggles.dm +++ b/code/datums/actions/items/toggles.dm @@ -80,6 +80,17 @@ return FALSE return ..() +/datum/action/item_action/toggle_hud + name = "Toggle Implant HUD" + desc = "Disables your HUD implant's visuals. You can still access examine information." + +/datum/action/item_action/toggle_hud/Trigger(trigger_flags) + . = ..() + if(!.) + return + var/obj/item/organ/internal/cyberimp/eyes/hud/hud_implant = target + hud_implant.toggle_hud(owner) + /datum/action/item_action/wheelys name = "Toggle Wheels" desc = "Pops out or in your shoes' wheels." diff --git a/code/modules/surgery/organs/internal/cyberimp/augments_eyes.dm b/code/modules/surgery/organs/internal/cyberimp/augments_eyes.dm index 352d4237cc0..869d4cc1c9e 100644 --- a/code/modules/surgery/organs/internal/cyberimp/augments_eyes.dm +++ b/code/modules/surgery/organs/internal/cyberimp/augments_eyes.dm @@ -12,8 +12,24 @@ name = "HUD implant" desc = "These cybernetic eyes will display a HUD over everything you see. Maybe." slot = ORGAN_SLOT_HUD + actions_types = list(/datum/action/item_action/toggle_hud) var/HUD_type = 0 var/HUD_trait = null + /// Whether the HUD implant is on or off + var/toggled_on = TRUE + + +/obj/item/organ/internal/cyberimp/eyes/hud/proc/toggle_hud(mob/living/carbon/eye_owner) + if(toggled_on) + if(HUD_type) + var/datum/atom_hud/hud = GLOB.huds[HUD_type] + hud.hide_from(eye_owner) + toggled_on = FALSE + else + if(HUD_type) + var/datum/atom_hud/hud = GLOB.huds[HUD_type] + hud.show_to(eye_owner) + toggled_on = TRUE /obj/item/organ/internal/cyberimp/eyes/hud/Insert(mob/living/carbon/eye_owner, special = FALSE, drop_if_replaced = TRUE) . = ..() @@ -24,6 +40,7 @@ hud.show_to(eye_owner) if(HUD_trait) ADD_TRAIT(eye_owner, HUD_trait, ORGAN_TRAIT) + toggled_on = TRUE /obj/item/organ/internal/cyberimp/eyes/hud/Remove(mob/living/carbon/eye_owner, special = FALSE) . = ..() @@ -32,6 +49,7 @@ hud.hide_from(eye_owner) if(HUD_trait) REMOVE_TRAIT(eye_owner, HUD_trait, ORGAN_TRAIT) + toggled_on = FALSE /obj/item/organ/internal/cyberimp/eyes/hud/medical name = "Medical HUD implant"