From a7820b190797f3d299cfe866b68813f5f7feff08 Mon Sep 17 00:00:00 2001 From: Morrow Date: Fri, 29 Sep 2023 18:26:00 -0400 Subject: [PATCH] Alright actually does this right I think --- .../objects/items/devices/helmet_visors.dm | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/code/game/objects/items/devices/helmet_visors.dm b/code/game/objects/items/devices/helmet_visors.dm index beded8dcae33..7e631324bb08 100644 --- a/code/game/objects/items/devices/helmet_visors.dm +++ b/code/game/objects/items/devices/helmet_visors.dm @@ -87,13 +87,13 @@ /obj/item/device/helmet_visor/medical/advanced/activate_visor(obj/item/clothing/head/helmet/marine/attached_helmet, mob/living/carbon/human/user) . = ..() - var/datum/action/item_action/view_publications/publication_action = new(attached_helmet) + var/datum/action/item_action/view_publications/helmet_visor/publication_action = new(attached_helmet) publication_action.give_to(user) /obj/item/device/helmet_visor/medical/advanced/deactivate_visor(obj/item/clothing/head/helmet/marine/attached_helmet, mob/living/carbon/human/user) . = ..() - var/datum/action/item_action/view_publications/publication_action = locate() in attached_helmet.actions + var/datum/action/item_action/view_publications/helmet_visor/publication_action = locate() in attached_helmet.actions qdel(publication_action) /obj/item/device/helmet_visor/medical/advanced/can_toggle(mob/living/carbon/human/user) @@ -107,6 +107,52 @@ return TRUE +/obj/item/device/helmet_visor/medical/advanced/ui_state(mob/user) + return GLOB.not_incapacitated_and_adjacent_strict_state + +/obj/item/device/helmet_visor/medical/advanced/ui_data(mob/user) + var/list/data = list( + "published_documents" = chemical_data.research_publications, + "terminal_view" = FALSE + ) + return data + +/obj/item/device/helmet_visor/medical/advanced/tgui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if (!ui) + ui = new(user, src, "PublishedDocsHud", name) + ui.open() + +/obj/item/device/helmet_visor/medical/advanced/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) + . = ..() + if(.) + return + + if(!ishuman(ui.user)) + return + + var/mob/living/carbon/human/user = ui.user + + if(user.stat || user.is_mob_restrained() || !in_range(src, user)) + return + + switch(action) + if ("read_document") + var/print_type = params["print_type"] + var/print_title = params["print_title"] + var/obj/item/paper/research_report/report = chemical_data.get_report(print_type, print_title) + if(report) + report.read_paper(user) + return + +/datum/action/item_action/view_publications/helmet_visor/action_activate() + var/obj/item/device/helmet_visor/medical/advanced/medical_visor = locate() in holder_item + + if(!medical_visor) + return + + medical_visor.tgui_interact(owner) + /obj/item/device/helmet_visor/security name = "security optic" icon_state = "sec_sight"