Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Apr 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Robust.Shared.Input.Binding;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Utility;

namespace Content.Shared.Hands.EntitySystems;

Expand Down Expand Up @@ -181,27 +182,21 @@ public bool TryMoveHeldEntityToActiveHand(EntityUid uid, string handName, bool c
}

//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));
}
}
}
Loading