Door Remote now shows Mode in UI (#26162)

* Prep for DoorRemote Status

* Door Remote Mode Messages

* plural opens and closes

* never trust webedits

---------

Co-authored-by: Plykiya <plykiya@protonmail.com>
This commit is contained in:
Plykiya
2024-03-21 17:19:52 -07:00
committed by GitHub
parent de6fc4033a
commit e627a0d24b
7 changed files with 151 additions and 67 deletions

View File

@@ -0,0 +1,46 @@
using Content.Client.Message;
using Content.Client.Stylesheets;
using Content.Shared.Remotes.Components;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;
namespace Content.Client.Remote.UI;
public sealed class DoorRemoteStatusControl : Control
{
private readonly Entity<DoorRemoteComponent> _entity;
private readonly RichTextLabel _label;
// set to toggle bolts initially just so that it updates on first pickup of remote
private OperatingMode PrevOperatingMode = OperatingMode.placeholderForUiUpdates;
public DoorRemoteStatusControl(Entity<DoorRemoteComponent> entity)
{
_entity = entity;
_label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } };
AddChild(_label);
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
// only updates the UI if any of the details are different than they previously were
if (PrevOperatingMode == _entity.Comp.Mode)
return;
PrevOperatingMode = _entity.Comp.Mode;
// Update current volume and injector state
var modeStringLocalized = Loc.GetString(_entity.Comp.Mode switch
{
OperatingMode.OpenClose => "door-remote-open-close-text",
OperatingMode.ToggleBolts => "door-remote-toggle-bolt-text",
OperatingMode.ToggleEmergencyAccess => "door-remote-emergency-access-text",
_ => "door-remote-invalid-text"
});
_label.SetMarkup(Loc.GetString("door-remote-mode-label", ("modeString", modeStringLocalized)));
}
}