Let PopupOnTrigger display names of user and item (#41157)
* waved away * waves at you with my [Prime Cut Corgi Meat] * pls dont litter the repository with unnecessary components * forgot to remove a variable from testing * guh * the more things change, the more things stay the same * and then she ternaried everywhere * owie
This commit is contained in:
@@ -5,6 +5,9 @@ namespace Content.Shared.Trigger.Components.Effects;
|
||||
|
||||
/// <summary>
|
||||
/// Displays a popup on the target when triggered.
|
||||
/// Supports following fluent variables:
|
||||
/// $entity - displays the target entity's name
|
||||
/// $user - displays the user's name
|
||||
/// Will display the popup on the user when <see cref="BaseXOnTriggerComponent.TargetUser"/> is true.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Trigger.Components.Effects;
|
||||
|
||||
@@ -12,12 +13,14 @@ public sealed class PopupOnTriggerSystem : XOnTriggerSystem<PopupOnTriggerCompon
|
||||
|
||||
protected override void OnTrigger(Entity<PopupOnTriggerComponent> ent, EntityUid target, ref TriggerEvent args)
|
||||
{
|
||||
var user = args.User != null ? Identity.Name(args.User.Value, EntityManager) : Loc.GetString("generic-unknown");
|
||||
|
||||
// Popups only play for one entity
|
||||
if (ent.Comp.Quiet)
|
||||
{
|
||||
if (ent.Comp.Predicted)
|
||||
{
|
||||
_popup.PopupClient(Loc.GetString(ent.Comp.Text),
|
||||
_popup.PopupClient(Loc.GetString(ent.Comp.Text, ("entity", ent), ("user", user)),
|
||||
target,
|
||||
ent.Comp.UserIsRecipient ? args.User : ent.Owner,
|
||||
ent.Comp.PopupType);
|
||||
@@ -25,7 +28,7 @@ public sealed class PopupOnTriggerSystem : XOnTriggerSystem<PopupOnTriggerCompon
|
||||
|
||||
else if (args.User != null)
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString(ent.Comp.OtherText ?? ent.Comp.Text),
|
||||
_popup.PopupEntity(Loc.GetString(ent.Comp.OtherText ?? ent.Comp.Text, ("entity", ent), ("user", user)),
|
||||
target,
|
||||
args.User.Value,
|
||||
ent.Comp.PopupType);
|
||||
@@ -37,8 +40,8 @@ public sealed class PopupOnTriggerSystem : XOnTriggerSystem<PopupOnTriggerCompon
|
||||
// Popups play for all entities
|
||||
if (ent.Comp.Predicted)
|
||||
{
|
||||
_popup.PopupPredicted(Loc.GetString(ent.Comp.Text),
|
||||
Loc.GetString(ent.Comp.OtherText ?? ent.Comp.Text),
|
||||
_popup.PopupPredicted(Loc.GetString(ent.Comp.Text, ("entity", ent), ("user", user)),
|
||||
Loc.GetString(ent.Comp.OtherText ?? ent.Comp.Text, ("entity", ent), ("user", user)),
|
||||
target,
|
||||
ent.Comp.UserIsRecipient ? args.User : ent.Owner,
|
||||
ent.Comp.PopupType);
|
||||
@@ -46,7 +49,7 @@ public sealed class PopupOnTriggerSystem : XOnTriggerSystem<PopupOnTriggerCompon
|
||||
|
||||
else
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString(ent.Comp.OtherText ?? ent.Comp.Text),
|
||||
_popup.PopupEntity(Loc.GetString(ent.Comp.OtherText ?? ent.Comp.Text, ("entity", ent), ("user", user)),
|
||||
target,
|
||||
ent.Comp.PopupType);
|
||||
}
|
||||
|
||||
7
Resources/Locale/en-US/triggers/popup-on-trigger.ftl
Normal file
7
Resources/Locale/en-US/triggers/popup-on-trigger.ftl
Normal file
@@ -0,0 +1,7 @@
|
||||
### Locales for PopupOnTrigger
|
||||
|
||||
popup-on-trigger-use = You use { THE($entity) }.
|
||||
popup-on-trigger-use-other = { CAPITALIZE(THE($user)) } uses { THE($entity) }.
|
||||
|
||||
popup-on-trigger-activate = You activate { THE($entity) }.
|
||||
popup-on-trigger-activate-other = { CAPITALIZE(THE($user)) } activates { THE($entity) }.
|
||||
Reference in New Issue
Block a user