* Reapply "Remove some BUI boilerplate" (#30214)
This reverts commit cb0ba66be3.
* Fix gas tank
* Fix PA
* Fix microwave
* Comms console underwrap
* Fix rcd
* log wehs
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Content.Shared.Pinpointer;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.UserInterface;
|
||||
|
||||
namespace Content.Client.Pinpointer.UI;
|
||||
|
||||
@@ -16,19 +17,16 @@ public sealed class NavMapBeaconBoundUserInterface : BoundUserInterface
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
_window = new NavMapBeaconWindow(Owner);
|
||||
_window.OpenCentered();
|
||||
_window.OnClose += Close;
|
||||
_window = this.CreateWindow<NavMapBeaconWindow>();
|
||||
|
||||
if (EntMan.TryGetComponent(Owner, out NavMapBeaconComponent? beacon))
|
||||
{
|
||||
_window.SetEntity(Owner, beacon);
|
||||
}
|
||||
|
||||
_window.OnApplyButtonPressed += (label, enabled, color) =>
|
||||
{
|
||||
SendMessage(new NavMapBeaconConfigureBuiMessage(label, enabled, color));
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
_window?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,36 +10,35 @@ namespace Content.Client.Pinpointer.UI;
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class NavMapBeaconWindow : FancyWindow
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
private string? _defaultLabel;
|
||||
private bool _defaultEnabled;
|
||||
private Color _defaultColor;
|
||||
|
||||
public event Action<string?, bool, Color>? OnApplyButtonPressed;
|
||||
|
||||
public NavMapBeaconWindow(EntityUid beaconEntity)
|
||||
public NavMapBeaconWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
if (!_entityManager.TryGetComponent<NavMapBeaconComponent>(beaconEntity, out var navMap))
|
||||
return;
|
||||
|
||||
VisibleButton.OnPressed += args => UpdateVisibleButton(args.Button.Pressed);
|
||||
LabelLineEdit.OnTextChanged += OnTextChanged;
|
||||
ColorSelector.OnColorChanged += _ => TryEnableApplyButton();
|
||||
|
||||
TryEnableApplyButton();
|
||||
ApplyButton.OnPressed += OnApplyPressed;
|
||||
}
|
||||
|
||||
public void SetEntity(EntityUid uid, NavMapBeaconComponent navMap)
|
||||
{
|
||||
_defaultLabel = navMap.Text;
|
||||
_defaultEnabled = navMap.Enabled;
|
||||
_defaultColor = navMap.Color;
|
||||
|
||||
UpdateVisibleButton(navMap.Enabled);
|
||||
VisibleButton.OnPressed += args => UpdateVisibleButton(args.Button.Pressed);
|
||||
|
||||
LabelLineEdit.Text = navMap.Text ?? string.Empty;
|
||||
LabelLineEdit.OnTextChanged += OnTextChanged;
|
||||
|
||||
ColorSelector.Color = navMap.Color;
|
||||
ColorSelector.OnColorChanged += _ => TryEnableApplyButton();
|
||||
|
||||
TryEnableApplyButton();
|
||||
ApplyButton.OnPressed += OnApplyPressed;
|
||||
}
|
||||
|
||||
private void UpdateVisibleButton(bool value)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface;
|
||||
|
||||
namespace Content.Client.Pinpointer.UI;
|
||||
|
||||
@@ -14,7 +14,6 @@ public sealed class StationMapBoundUserInterface : BoundUserInterface
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
_window?.Close();
|
||||
EntityUid? gridUid = null;
|
||||
|
||||
if (EntMan.TryGetComponent<TransformComponent>(Owner, out var xform))
|
||||
@@ -22,14 +21,8 @@ public sealed class StationMapBoundUserInterface : BoundUserInterface
|
||||
gridUid = xform.GridUid;
|
||||
}
|
||||
|
||||
_window = new StationMapWindow(gridUid, Owner);
|
||||
_window.OpenCentered();
|
||||
_window.OnClose += Close;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
_window?.Dispose();
|
||||
_window = this.CreateWindow<StationMapWindow>();
|
||||
_window.Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName;
|
||||
_window.Set(gridUid, Owner);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,19 +9,18 @@ namespace Content.Client.Pinpointer.UI;
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class StationMapWindow : FancyWindow
|
||||
{
|
||||
public StationMapWindow(EntityUid? mapUid, EntityUid? trackedEntity)
|
||||
public StationMapWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public void Set(EntityUid? mapUid, EntityUid? trackedEntity)
|
||||
{
|
||||
NavMapScreen.MapUid = mapUid;
|
||||
|
||||
if (trackedEntity != null)
|
||||
NavMapScreen.TrackedCoordinates.Add(new EntityCoordinates(trackedEntity.Value, Vector2.Zero), (true, Color.Cyan));
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<MetaDataComponent>(mapUid, out var metadata))
|
||||
{
|
||||
Title = metadata.EntityName;
|
||||
}
|
||||
|
||||
NavMapScreen.ForceNavMapUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface;
|
||||
|
||||
namespace Content.Client.Pinpointer.UI;
|
||||
|
||||
@@ -14,22 +14,15 @@ public sealed class UntrackedStationMapBoundUserInterface : BoundUserInterface
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
_window?.Close();
|
||||
EntityUid? gridUid = null;
|
||||
|
||||
// TODO: What this just looks like it's been copy-pasted wholesale from StationMapBoundUserInterface?
|
||||
if (EntMan.TryGetComponent<TransformComponent>(Owner, out var xform))
|
||||
{
|
||||
gridUid = xform.GridUid;
|
||||
}
|
||||
|
||||
_window = new StationMapWindow(gridUid, null);
|
||||
_window.OpenCentered();
|
||||
_window.OnClose += Close;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
_window?.Dispose();
|
||||
_window = this.CreateWindow<StationMapWindow>();
|
||||
_window.Set(gridUid, Owner);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user