Escape markup for in-game chat, and labeler (#26359)

* Escape markup for in-game chat, and labeler

* different way

* remove a using

---------

Co-authored-by: wrexbe <wrexbe@protonmail.com>
(cherry picked from commit c93052c7553e5a495f70cffe435febc6157ab8b3)
This commit is contained in:
Wrexbe (Josh) 2024-04-21 17:37:50 -07:00 committed by null
parent f10014496e
commit 21f7b18b14
No known key found for this signature in database
GPG Key ID: 212F05528FD678BE
1 changed files with 12 additions and 17 deletions

View 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));
}
}
}