From 2c46ef8a4d32dc8d046d68349ed6325fe0db1391 Mon Sep 17 00:00:00 2001 From: Geeves Date: Tue, 26 Sep 2023 21:12:00 +0200 Subject: [PATCH] Examinable Armor (#17364) * Examinable Armor * horse react this linter * me coder * changes * Update tgui/packages/tgui/interfaces/ArmorValues.tsx Co-authored-by: Matt Atlas * capitalize * cl newline --------- Co-authored-by: Matt Atlas --- aurorastation.dme | 1 + code/game/objects/items.dm | 12 ++++- code/modules/clothing/clothing_accessories.dm | 2 +- code/modules/clothing/spacesuits/rig/rig.dm | 18 +++++--- code/modules/tgui/modules/armor_values.dm | 20 +++++++++ html/changelogs/geeves-armor_tgui.yml | 6 +++ tgui/packages/tgui/interfaces/ArmorValues.tsx | 45 +++++++++++++++++++ 7 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 code/modules/tgui/modules/armor_values.dm create mode 100644 html/changelogs/geeves-armor_tgui.yml create mode 100644 tgui/packages/tgui/interfaces/ArmorValues.tsx diff --git a/aurorastation.dme b/aurorastation.dme index 378950e5298..5ffbf1d8905 100644 --- a/aurorastation.dme +++ b/aurorastation.dme @@ -3352,6 +3352,7 @@ #include "code\modules\tgui\status_composers.dm" #include "code\modules\tgui\tgui.dm" #include "code\modules\tgui\tgui_window.dm" +#include "code\modules\tgui\modules\armor_values.dm" #include "code\modules\tgui\modules\flavor_text.dm" #include "code\modules\tgui\states\admin.dm" #include "code\modules\tgui\states\always.dm" diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index b44a9af030e..cbca46adbde 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -333,8 +333,18 @@ //Changed this switch to ranges instead of tiered values, to cope with granularity and also //things outside its range ~Nanako + . = ..(user, distance, "", "It is a [size] item.") + if(length(armor)) + to_chat(user, FONT_SMALL(SPAN_NOTICE("\[?\] This item has armor values. \[Show Armor Values\]"))) - return ..(user, distance, "", "It is a [size] item.") +/obj/item/Topic(href, href_list) + if(href_list["examine_armor"]) + var/list/armor_details = list() + for(var/armor_type in armor) + armor_details[armor_type] = armor[armor_type] + var/datum/tgui_module/armor_values/AV = new /datum/tgui_module/armor_values(usr, capitalize_first_letters(name), armor_details) + AV.ui_interact(usr) + return ..() /obj/item/attack_hand(mob/user) if(!user) diff --git a/code/modules/clothing/clothing_accessories.dm b/code/modules/clothing/clothing_accessories.dm index b4d68007df8..2849908115e 100644 --- a/code/modules/clothing/clothing_accessories.dm +++ b/code/modules/clothing/clothing_accessories.dm @@ -95,7 +95,7 @@ . = ..() if(LAZYLEN(accessories)) for(var/obj/item/clothing/accessory/A in accessories) - to_chat(user, "\A [A] [A.gender == PLURAL ? "are" : "is"] attached to it.") + to_chat(user, SPAN_NOTICE("\A [A] [A.gender == PLURAL ? "are" : "is"] attached to it.")) /obj/item/clothing/proc/update_accessory_slowdown() slowdown_accessory = 0 diff --git a/code/modules/clothing/spacesuits/rig/rig.dm b/code/modules/clothing/spacesuits/rig/rig.dm index c6f8aff617d..38294253a3a 100644 --- a/code/modules/clothing/spacesuits/rig/rig.dm +++ b/code/modules/clothing/spacesuits/rig/rig.dm @@ -610,12 +610,18 @@ //TODO: Fix Topic vulnerabilities for malfunction and AI override. /obj/item/rig/Topic(href,href_list) - if(href_list["examine_fluff"]) - examine_fluff(usr) - if(ismob(href)) - do_rig_thing(href, href_list) - return - do_rig_thing(usr, href_list) + if(href_list["examine_armor"]) + var/list/armor_details = list() + for(var/armor_type in armor) + armor_details[armor_type] = armor[armor_type] + var/datum/tgui_module/armor_values/AV = new /datum/tgui_module/armor_values(usr, capitalize_first_letters(name), armor_details) + AV.ui_interact(usr) + if(href_list["examine_fluff"]) + examine_fluff(usr) + if(ismob(href)) + do_rig_thing(href, href_list) + return + do_rig_thing(usr, href_list) /obj/item/rig/proc/do_rig_thing(mob/user, var/list/href_list) if(!check_suit_access(user)) diff --git a/code/modules/tgui/modules/armor_values.dm b/code/modules/tgui/modules/armor_values.dm new file mode 100644 index 00000000000..a5fff678f41 --- /dev/null +++ b/code/modules/tgui/modules/armor_values.dm @@ -0,0 +1,20 @@ +/datum/tgui_module/armor_values + var/armor_name = "" + var/list/armor_values = list() + +/datum/tgui_module/armor_values/New(mob/user, var/set_armor_name, var/list/set_armor_values) + ..() + armor_name = set_armor_name + armor_values = set_armor_values + +/datum/tgui_module/armor_values/ui_interact(var/mob/user, var/datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "ArmorValues", armor_name, 500, 400) + ui.autoupdate = FALSE + ui.open() + +/datum/tgui_module/armor_values/ui_data(mob/user) + var/list/data = list() + data["armor_values"] = armor_values + return data diff --git a/html/changelogs/geeves-armor_tgui.yml b/html/changelogs/geeves-armor_tgui.yml new file mode 100644 index 00000000000..feecc70f0c5 --- /dev/null +++ b/html/changelogs/geeves-armor_tgui.yml @@ -0,0 +1,6 @@ +author: Geeves + +delete-after: True + +changes: + - rscadd: "Added the ability to examine items and see their armor values." diff --git a/tgui/packages/tgui/interfaces/ArmorValues.tsx b/tgui/packages/tgui/interfaces/ArmorValues.tsx new file mode 100644 index 00000000000..596fa381fc8 --- /dev/null +++ b/tgui/packages/tgui/interfaces/ArmorValues.tsx @@ -0,0 +1,45 @@ +import { useBackend } from '../backend'; +import { Box, Divider, NoticeBox, ProgressBar, Section } from '../components'; +import { capitalize } from '../../common/string'; +import { Window } from '../layouts'; + +export type ArmorValuesData = { + armor_values: string[]; +}; + +export const ArmorValues = (props, context) => { + const { act, data } = useBackend(context); + + return ( + + +
+ + The statistics below are out of character info, you can use this to + reference armor values, but do not state the percentages in + character. + + + {Object.keys(data.armor_values).map((line) => + line ? ( + + {capitalize(line)} + + + + ) : null + )} +
+
+
+ ); +};