From b7d020570fcf317c95b3a798fb8464d54311081b Mon Sep 17 00:00:00 2001 From: pathetic meowmeow Date: Sat, 26 Apr 2025 17:45:53 -0400 Subject: [PATCH] Truncate lathe announcement lists (#36945) --- .../Lathe/Components/LatheAnnouncingComponent.cs | 6 ++++++ Content.Server/Lathe/LatheSystem.cs | 15 +++++++++++---- Resources/Locale/en-US/lathe/lathesystem.ftl | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Content.Server/Lathe/Components/LatheAnnouncingComponent.cs b/Content.Server/Lathe/Components/LatheAnnouncingComponent.cs index 16c30d98eb..e5a6fbf352 100644 --- a/Content.Server/Lathe/Components/LatheAnnouncingComponent.cs +++ b/Content.Server/Lathe/Components/LatheAnnouncingComponent.cs @@ -14,4 +14,10 @@ public sealed partial class LatheAnnouncingComponent : Component /// [DataField(required: true)] public List> Channels = new(); + + /// + /// How many items should be announced in a message before it truncates + /// + [DataField] + public int MaximumItems = 5; } diff --git a/Content.Server/Lathe/LatheSystem.cs b/Content.Server/Lathe/LatheSystem.cs index 0212bb6eeb..3c5ecde1c6 100644 --- a/Content.Server/Lathe/LatheSystem.cs +++ b/Content.Server/Lathe/LatheSystem.cs @@ -385,10 +385,17 @@ namespace Content.Server.Lathe if (recipeNames.Count == 0) return; - var message = Loc.GetString( - "lathe-unlock-recipe-radio-broadcast", - ("items", ContentLocalizationManager.FormatList(recipeNames)) - ); + var message = + recipeNames.Count > ent.Comp.MaximumItems ? + Loc.GetString( + "lathe-unlock-recipe-radio-broadcast-overflow", + ("items", ContentLocalizationManager.FormatList(recipeNames.GetRange(0, ent.Comp.MaximumItems))), + ("count", recipeNames.Count) + ) : + Loc.GetString( + "lathe-unlock-recipe-radio-broadcast", + ("items", ContentLocalizationManager.FormatList(recipeNames)) + ); foreach (var channel in ent.Comp.Channels) { diff --git a/Resources/Locale/en-US/lathe/lathesystem.ftl b/Resources/Locale/en-US/lathe/lathesystem.ftl index 93e0107f68..ecf01b3317 100644 --- a/Resources/Locale/en-US/lathe/lathesystem.ftl +++ b/Resources/Locale/en-US/lathe/lathesystem.ftl @@ -1,3 +1,4 @@ lathe-popup-material-not-used = This material is not used in this machine. lathe-unlock-recipe-radio-broadcast = This lathe is now capable of producing the following recipes: {$items} +lathe-unlock-recipe-radio-broadcast-overflow = This lathe is now capable of producing {$count} new recipes, including: {$items} lathe-unlock-recipe-radio-broadcast-item = [bold]{$item}[/bold] -- 2.51.2