]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Escape markup for in-game chat, and labeler (#26359)
authorWrexbe (Josh) <81056464+wrexbe@users.noreply.github.com>
Mon, 22 Apr 2024 00:37:50 +0000 (17:37 -0700)
committerGitHub <noreply@github.com>
Mon, 22 Apr 2024 00:37:50 +0000 (20:37 -0400)
* Escape markup for in-game chat, and labeler

* different way

* remove a using

---------

Co-authored-by: wrexbe <wrexbe@protonmail.com>
Content.Shared/Hands/EntitySystems/SharedHandsSystem.Interactions.cs

index 32339eb03ac5bf42ae9f1c3537000d13c3746964..6d4d332479fdac3332f0ad0ab639027365e4bf6a 100644 (file)
@@ -8,6 +8,7 @@ using Content.Shared.Localizations;
 using Robust.Shared.Input.Binding;
 using Robust.Shared.Map;
 using Robust.Shared.Player;
+using Robust.Shared.Utility;
 
 namespace Content.Shared.Hands.EntitySystems;
 
@@ -181,27 +182,21 @@ public abstract partial class SharedHandsSystem : EntitySystem
     }
 
     //TODO: Actually shows all items/clothing/etc.
-    private void HandleExamined(EntityUid uid, HandsComponent handsComp, ExaminedEvent args)
+    private void HandleExamined(EntityUid examinedUid, HandsComponent handsComp, ExaminedEvent args)
     {
-        var held = EnumerateHeld(uid, handsComp)
-            .Where(x => !HasComp<VirtualItemComponent>(x)).ToList();
+        var heldItemNames = EnumerateHeld(examinedUid, handsComp)
+            .Where(entity => !HasComp<VirtualItemComponent>(entity))
+            .Select(item => FormattedMessage.EscapeText(Identity.Name(item, EntityManager)))
+            .Select(itemName => Loc.GetString("comp-hands-examine-wrapper", ("item", itemName)))
+            .ToList();
+
+        var locKey = heldItemNames.Count != 0 ? "comp-hands-examine" : "comp-hands-examine-empty";
+        var locUser = ("user", Identity.Entity(examinedUid, EntityManager));
+        var locItems = ("items", ContentLocalizationManager.FormatList(heldItemNames));
 
         using (args.PushGroup(nameof(HandsComponent)))
         {
-            if (!held.Any())
-            {
-                args.PushText(Loc.GetString("comp-hands-examine-empty",
-                    ("user", Identity.Entity(uid, EntityManager))));
-                return;
-            }
-
-            var heldList = ContentLocalizationManager.FormatList(held
-                .Select(x => Loc.GetString("comp-hands-examine-wrapper",
-                    ("item", Identity.Entity(x, EntityManager)))).ToList());
-
-            args.PushMarkup(Loc.GetString("comp-hands-examine",
-                ("user", Identity.Entity(uid, EntityManager)),
-                ("items", heldList)));
+            args.PushMarkup(Loc.GetString(locKey, locUser, locItems));
         }
     }
 }