diff --git a/code/_helpers/text.dm b/code/_helpers/text.dm index 520b98d39a..3357116d30 100644 --- a/code/_helpers/text.dm +++ b/code/_helpers/text.dm @@ -620,3 +620,8 @@ return json_decode(data) catch return null + +/// Removes all non-alphanumerics from the text, keep in mind this can lead to id conflicts +/proc/sanitize_css_class_name(name) + var/static/regex/regex = new(@"[^a-zA-Z0-9]","g") + return replacetext(name, regex, "") diff --git a/code/modules/asset_cache/asset_list_items.dm b/code/modules/asset_cache/asset_list_items.dm index 911dd62fb0..b0dc6223e6 100644 --- a/code/modules/asset_cache/asset_list_items.dm +++ b/code/modules/asset_cache/asset_list_items.dm @@ -443,7 +443,7 @@ /datum/asset/spritesheet/robot_icons/create_spritesheets() for(var/datum/robot_sprite/S as anything in typesof(/datum/robot_sprite)) - if(!S.name || !S.module_type) + if(!S.name) continue var/icon/I_S = icon(S.sprite_icon, S.sprite_icon_state, SOUTH) var/icon/I_N = icon(S.sprite_icon, S.sprite_icon_state, NORTH) @@ -461,10 +461,11 @@ var/icon/I_EE = icon(S.sprite_icon, "[S.sprite_icon_state]-eyes", EAST) if(I_EE) I_E.Blend(I_EE, ICON_OVERLAY) - Insert(S.module_type + S.name + "_S", I_S) - Insert(S.module_type + S.name + "_N", I_N) - Insert(S.module_type + S.name + "_W", I_W) - Insert(S.module_type + S.name + "_E", I_E) + var/imgid = sanitize_css_class_name("[S.type]") + Insert(imgid + "_S", I_S) + Insert(imgid + "_N", I_N) + Insert(imgid + "_W", I_W) + Insert(imgid + "_E", I_E) //Cloning pod sprites for UIs diff --git a/code/modules/mob/living/silicon/robot/robot_ui_module.dm b/code/modules/mob/living/silicon/robot/robot_ui_module.dm index 435c524146..1c3973d5dc 100644 --- a/code/modules/mob/living/silicon/robot/robot_ui_module.dm +++ b/code/modules/mob/living/silicon/robot/robot_ui_module.dm @@ -71,8 +71,10 @@ available_sprites += list(list("sprite" = S.name, "belly" = S.has_vore_belly_sprites, "type" = model_type)) data["possible_sprites"] = available_sprites + data["sprite_datum"] = sprite_datum + data["asset"] = null if(sprite_datum) - data["sprite_datum"] = sprite_datum + data["asset"] = sanitize_css_class_name("[sprite_datum.type]") return data diff --git a/tgui/packages/tgui/interfaces/RobotChoose/IconSection.tsx b/tgui/packages/tgui/interfaces/RobotChoose/IconSection.tsx index f066f1b507..8f18137ea1 100644 --- a/tgui/packages/tgui/interfaces/RobotChoose/IconSection.tsx +++ b/tgui/packages/tgui/interfaces/RobotChoose/IconSection.tsx @@ -2,9 +2,9 @@ import { resolveAsset } from 'tgui/assets'; import { useBackend } from 'tgui/backend'; import { Button, Image, Section, Stack } from 'tgui-core/components'; -export const IconSection = (props: { module?: string; sprite?: string }) => { +export const IconSection = (props: { sprite?: string | null }) => { const { act } = useBackend(); - const { module, sprite } = props; + const { sprite } = props; return (
{ } > - {!!sprite && !!module && ( + {!!sprite && ( <> { { { { const { act } = useBackend(); diff --git a/tgui/packages/tgui/interfaces/RobotChoose/SpriteSection.tsx b/tgui/packages/tgui/interfaces/RobotChoose/SpriteSection.tsx index 13cba8fc05..b9906e252e 100644 --- a/tgui/packages/tgui/interfaces/RobotChoose/SpriteSection.tsx +++ b/tgui/packages/tgui/interfaces/RobotChoose/SpriteSection.tsx @@ -7,8 +7,8 @@ import { spriteOption } from './types'; export const SpriteSection = (props: { title: string; + selected?: string | null; sortable?: spriteOption[]; - selected?: string; }) => { const { title, sortable, selected } = props; diff --git a/tgui/packages/tgui/interfaces/RobotChoose/index.tsx b/tgui/packages/tgui/interfaces/RobotChoose/index.tsx index 999b0c687f..3f04b68e77 100644 --- a/tgui/packages/tgui/interfaces/RobotChoose/index.tsx +++ b/tgui/packages/tgui/interfaces/RobotChoose/index.tsx @@ -16,6 +16,7 @@ export const RobotChoose = (props) => { selected_module, sprite_datum, theme, + asset, } = data; return ( @@ -32,7 +33,7 @@ export const RobotChoose = (props) => { sortable={possible_sprites} selected={sprite_datum} /> - + diff --git a/tgui/packages/tgui/interfaces/RobotChoose/types.ts b/tgui/packages/tgui/interfaces/RobotChoose/types.ts index 1fa9774eb9..60bab5ac9d 100644 --- a/tgui/packages/tgui/interfaces/RobotChoose/types.ts +++ b/tgui/packages/tgui/interfaces/RobotChoose/types.ts @@ -3,7 +3,8 @@ export type Data = { possible_sprites?: spriteOption[]; theme?: string; selected_module?: string; - sprite_datum?: string; + sprite_datum?: string | null; + asset?: string | null; }; export type spriteOption = { sprite: string; belly: boolean; type: string };