From 263a6937ed50451842d8a831a599f29e01bdc710 Mon Sep 17 00:00:00 2001 From: harryob Date: Sat, 9 Nov 2024 10:06:30 +0000 Subject: [PATCH] fixes missing icons in abductor console (#87759) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## About The Pull Request grabs the icon for the item correctly. also typescripts the interface because blessed type safety would've prevented it being missing in the first place. and clears some random deprecations ## Why It's Good For The Game pretty icons 👍 loading icons 👎 ![image](https://github.com/user-attachments/assets/ec524a52-fff5-4c67-b3fb-88fbfd5988af) ## Changelog :cl: fix: the abductor console now correctly loads images of equipment /:cl: closes #87565 --- .../antagonists/abductor/machinery/console.dm | 9 +++ ...bductorConsole.jsx => AbductorConsole.tsx} | 62 +++++++++++++------ 2 files changed, 53 insertions(+), 18 deletions(-) rename tgui/packages/tgui/interfaces/{AbductorConsole.jsx => AbductorConsole.tsx} (74%) diff --git a/code/modules/antagonists/abductor/machinery/console.dm b/code/modules/antagonists/abductor/machinery/console.dm index 3dcdaf5a5b07e..4c5a30c0d9e27 100644 --- a/code/modules/antagonists/abductor/machinery/console.dm +++ b/code/modules/antagonists/abductor/machinery/console.dm @@ -94,10 +94,19 @@ "items" = (category == selected_cat ? list() : null)) for(var/gear in possible_gear[category]) var/datum/abductor_gear/AG = possible_gear[category][gear] + + var/atom/gear_path + if(!length(AG.build_path)) + continue + + gear_path = AG.build_path[1] + cat["items"] += list(list( "name" = AG.name, "cost" = AG.cost, "desc" = AG.description, + "icon" = gear_path::icon, + "icon_state" = gear_path::icon_state, )) data["categories"] += list(cat) return data diff --git a/tgui/packages/tgui/interfaces/AbductorConsole.jsx b/tgui/packages/tgui/interfaces/AbductorConsole.tsx similarity index 74% rename from tgui/packages/tgui/interfaces/AbductorConsole.jsx rename to tgui/packages/tgui/interfaces/AbductorConsole.tsx index bb2f1dffccfe3..d8d3305362725 100644 --- a/tgui/packages/tgui/interfaces/AbductorConsole.jsx +++ b/tgui/packages/tgui/interfaces/AbductorConsole.tsx @@ -5,10 +5,33 @@ import { Section, Tabs, } from 'tgui-core/components'; +import { BooleanLike } from 'tgui-core/react'; import { useBackend, useSharedState } from '../backend'; import { Window } from '../layouts'; -import { GenericUplink } from './Uplink/GenericUplink'; +import { GenericUplink, Item } from './Uplink/GenericUplink'; + +type AbductorConsoleData = { + categories: { name: string; items: ConsoleItem[] }[]; + + compactMode: BooleanLike; + experiment: BooleanLike; + points?: number; + credits?: number; + pad: BooleanLike; + gizmo: BooleanLike; + vest: BooleanLike; + vest_mode?: number; + vest_lock?: BooleanLike; +}; + +type ConsoleItem = { + name: string; + cost: number; + desc: string; + icon: string; + icon_state: string; +}; export const AbductorConsole = (props) => { const [tab, setTab] = useSharedState('tab', 1); @@ -47,15 +70,15 @@ export const AbductorConsole = (props) => { }; const Abductsoft = (props) => { - const { act, data } = useBackend(); + const { act, data } = useBackend(); const { experiment, points, credits, categories } = data; if (!experiment) { return No Experiment Machine Detected; } - const categoriesList = []; - const items = []; + const categoriesList: string[] = []; + const items: Item[] = []; for (let i = 0; i < categories.length; i++) { const category = categories[i]; categoriesList.push(category.name); @@ -67,7 +90,9 @@ const Abductsoft = (props) => { category: category.name, cost: `${item.cost} Credits`, desc: item.desc, - disabled: credits < item.cost, + disabled: (credits || 0) < item.cost, + icon: item.icon, + icon_state: item.icon_state, }); } } @@ -92,7 +117,7 @@ const Abductsoft = (props) => { }; const EmergencyTeleporter = (props) => { - const { act, data } = useBackend(); + const { act, data } = useBackend(); const { pad, gizmo } = data; if (!pad) { @@ -115,10 +140,11 @@ const EmergencyTeleporter = (props) => { @@ -126,7 +152,7 @@ const EmergencyTeleporter = (props) => { }; const VestSettings = (props) => { - const { act, data } = useBackend(); + const { act, data } = useBackend(); const { vest, vest_mode, vest_lock } = data; if (!vest) { @@ -139,25 +165,25 @@ const VestSettings = (props) => { buttons={ } > -