* 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,6 +1,7 @@
|
||||
using Content.Shared.Silicons.Borgs;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface;
|
||||
|
||||
namespace Content.Client.Silicons.Borgs;
|
||||
|
||||
@@ -18,9 +19,8 @@ public sealed class BorgBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
base.Open();
|
||||
|
||||
var owner = Owner;
|
||||
|
||||
_menu = new BorgMenu(owner);
|
||||
_menu = this.CreateWindow<BorgMenu>();
|
||||
_menu.SetEntity(Owner);
|
||||
|
||||
_menu.BrainButtonPressed += () =>
|
||||
{
|
||||
@@ -41,10 +41,6 @@ public sealed class BorgBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
SendMessage(new BorgRemoveModuleBuiMessage(EntMan.GetNetEntity(module)));
|
||||
};
|
||||
|
||||
_menu.OnClose += Close;
|
||||
|
||||
_menu.OpenCentered();
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
@@ -55,12 +51,4 @@ public sealed class BorgBoundUserInterface : BoundUserInterface
|
||||
return;
|
||||
_menu?.UpdateState(msg);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing)
|
||||
return;
|
||||
_menu?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
VerticalExpand="True">
|
||||
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True" Margin="15 10 15 15">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<ProgressBar Name="ChargeBar" Access="Public" HorizontalExpand="True" MinValue="0" MaxValue="1">
|
||||
<ProgressBar Name="ChargeBar" Access="Public" HorizontalExpand="True" MinValue="0" Value="1" MaxValue="1">
|
||||
<Label Name="ChargeLabel" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5 0 0 0"/>
|
||||
</ProgressBar>
|
||||
<Control MinWidth="5"/>
|
||||
|
||||
@@ -21,25 +21,33 @@ public sealed partial class BorgMenu : FancyWindow
|
||||
public Action<string>? NameChanged;
|
||||
public Action<EntityUid>? RemoveModuleButtonPressed;
|
||||
|
||||
private readonly BorgChassisComponent? _chassis;
|
||||
public readonly EntityUid Entity;
|
||||
public float AccumulatedTime;
|
||||
private string _lastValidName;
|
||||
private List<EntityUid> _modules = new();
|
||||
|
||||
public BorgMenu(EntityUid entity)
|
||||
public EntityUid Entity;
|
||||
|
||||
public BorgMenu()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
_lastValidName = NameLineEdit.Text;
|
||||
|
||||
EjectBatteryButton.OnPressed += _ => EjectBatteryButtonPressed?.Invoke();
|
||||
BrainButton.OnPressed += _ => BrainButtonPressed?.Invoke();
|
||||
|
||||
NameLineEdit.OnTextChanged += OnNameChanged;
|
||||
NameLineEdit.OnTextEntered += OnNameEntered;
|
||||
NameLineEdit.OnFocusExit += OnNameFocusExit;
|
||||
|
||||
UpdateBrainButton();
|
||||
}
|
||||
|
||||
public void SetEntity(EntityUid entity)
|
||||
{
|
||||
Entity = entity;
|
||||
|
||||
if (_entity.TryGetComponent<BorgChassisComponent>(Entity, out var chassis))
|
||||
_chassis = chassis;
|
||||
|
||||
BorgSprite.SetEntity(entity);
|
||||
ChargeBar.MaxValue = 1f;
|
||||
ChargeBar.Value = 1f;
|
||||
|
||||
if (_entity.TryGetComponent<NameIdentifierComponent>(Entity, out var nameIdentifierComponent))
|
||||
{
|
||||
@@ -55,17 +63,6 @@ public sealed partial class BorgMenu : FancyWindow
|
||||
NameIdentifierLabel.Visible = false;
|
||||
NameLineEdit.Text = _entity.GetComponent<MetaDataComponent>(Entity).EntityName;
|
||||
}
|
||||
|
||||
_lastValidName = NameLineEdit.Text;
|
||||
|
||||
EjectBatteryButton.OnPressed += _ => EjectBatteryButtonPressed?.Invoke();
|
||||
BrainButton.OnPressed += _ => BrainButtonPressed?.Invoke();
|
||||
|
||||
NameLineEdit.OnTextChanged += OnNameChanged;
|
||||
NameLineEdit.OnTextEntered += OnNameEntered;
|
||||
NameLineEdit.OnFocusExit += OnNameFocusExit;
|
||||
|
||||
UpdateBrainButton();
|
||||
}
|
||||
|
||||
protected override void FrameUpdate(FrameEventArgs args)
|
||||
@@ -89,7 +86,7 @@ public sealed partial class BorgMenu : FancyWindow
|
||||
|
||||
private void UpdateBrainButton()
|
||||
{
|
||||
if (_chassis?.BrainEntity is { } brain)
|
||||
if (_entity.TryGetComponent(Entity, out BorgChassisComponent? chassis) && chassis.BrainEntity is { } brain)
|
||||
{
|
||||
BrainButton.Text = _entity.GetComponent<MetaDataComponent>(brain).EntityName;
|
||||
BrainView.Visible = true;
|
||||
@@ -108,17 +105,17 @@ public sealed partial class BorgMenu : FancyWindow
|
||||
|
||||
private void UpdateModulePanel()
|
||||
{
|
||||
if (_chassis == null)
|
||||
if (!_entity.TryGetComponent(Entity, out BorgChassisComponent? chassis))
|
||||
return;
|
||||
|
||||
ModuleCounter.Text = Loc.GetString("borg-ui-module-counter",
|
||||
("actual", _chassis.ModuleCount),
|
||||
("max", _chassis.MaxModules));
|
||||
("actual", chassis.ModuleCount),
|
||||
("max", chassis.MaxModules));
|
||||
|
||||
if (_chassis.ModuleContainer.Count == _modules.Count)
|
||||
if (chassis.ModuleContainer.Count == _modules.Count)
|
||||
{
|
||||
var isSame = true;
|
||||
foreach (var module in _chassis.ModuleContainer.ContainedEntities)
|
||||
foreach (var module in chassis.ModuleContainer.ContainedEntities)
|
||||
{
|
||||
if (_modules.Contains(module))
|
||||
continue;
|
||||
@@ -132,7 +129,7 @@ public sealed partial class BorgMenu : FancyWindow
|
||||
|
||||
ModuleContainer.Children.Clear();
|
||||
_modules.Clear();
|
||||
foreach (var module in _chassis.ModuleContainer.ContainedEntities)
|
||||
foreach (var module in chassis.ModuleContainer.ContainedEntities)
|
||||
{
|
||||
var control = new BorgModuleControl(module, _entity);
|
||||
control.RemoveButtonPressed += () =>
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Linq;
|
||||
using Content.Shared.Silicons.Laws;
|
||||
using Content.Shared.Silicons.Laws.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.UserInterface;
|
||||
|
||||
namespace Content.Client.Silicons.Laws.Ui;
|
||||
|
||||
@@ -22,18 +23,7 @@ public sealed class SiliconLawBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
base.Open();
|
||||
|
||||
_menu = new();
|
||||
|
||||
_menu.OnClose += Close;
|
||||
_menu.OpenCentered();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing)
|
||||
return;
|
||||
_menu?.Close();
|
||||
_menu = this.CreateWindow<SiliconLawMenu>();
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
|
||||
Reference in New Issue
Block a user