mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Adds a component (added to MobSoliconBase) which allows you to rename an entity in-game via a verb. --- # TODO <!-- A list of everything you have to do before this PR is "complete" You probably won't have to complete everything before merging but it's good to leave future references --> - [x] Make the Verb appear - [x] Successfully open the UI - [x] Apply input as entity name --- <!-- This is default collapsed, readers click to expand it and see all your media The PR media section can get very large at times, so this is a good way to keep it clean The title is written using HTML tags The title must be within the <summary> tags or you won't see it --> <details><summary><h1>Media</h1></summary> <p>  </p> </details> --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 - tweak: Allow renaming robots and pAI --------- Signed-off-by: Timfa <timfalken@hotmail.com> Co-authored-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> (cherry picked from commit 3014a0db4560e9949e690caaa49f46866bc20079)
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using System.IO;
|
|
using Content.Shared.NameModifier.EntitySystems;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Renamable.EntitySystems;
|
|
using Robust.Client.UserInterface;
|
|
|
|
namespace Content.Client.Renamable;
|
|
|
|
public sealed class RenamableBoundUserInterface : BoundUserInterface
|
|
{
|
|
[Dependency] private readonly IEntityManager _entManager = default!;
|
|
private EntityQuery<MetaDataComponent> _metaQuery;
|
|
|
|
[ViewVariables]
|
|
private RenamableWindow? _window;
|
|
|
|
public RenamableBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
|
{
|
|
_metaQuery = _entManager.GetEntityQuery<MetaDataComponent>();
|
|
}
|
|
|
|
protected override void Open()
|
|
{
|
|
base.Open();
|
|
|
|
_window = this.CreateWindow<RenamableWindow>();
|
|
_window.OnNameChanged += OnNameChanged;
|
|
Reload();
|
|
}
|
|
|
|
private void OnNameChanged(string newName) => SendPredictedMessage(new RenamableBuiMessage(newName));
|
|
|
|
private void Reload(MetaDataComponent? metaData = null)
|
|
{
|
|
if (!_metaQuery.Resolve(Owner, ref metaData))
|
|
return;
|
|
|
|
_window!.SetCurrentName(metaData.EntityName);
|
|
}
|
|
}
|