Cleaner BoundUserInterfaces (#17736)

This commit is contained in:
TemporalOroboros
2023-07-08 09:02:17 -07:00
committed by GitHub
parent 55b4fb1649
commit 3ac4cf85db
137 changed files with 1069 additions and 972 deletions

View File

@@ -1,5 +1,4 @@
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Dispenser;
using Content.Shared.Containers.ItemSlots;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
@@ -12,12 +11,11 @@ namespace Content.Client.Chemistry.UI
[UsedImplicitly]
public sealed class ChemMasterBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[ViewVariables]
private ChemMasterWindow? _window;
public ChemMasterBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public ChemMasterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
/// <summary>
@@ -31,7 +29,7 @@ namespace Content.Client.Chemistry.UI
// Setup window layout/elements
_window = new ChemMasterWindow
{
Title = _entityManager.GetComponent<MetaDataComponent>(Owner.Owner).EntityName,
Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName,
};
_window.OpenCentered();
@@ -48,9 +46,10 @@ namespace Content.Client.Chemistry.UI
new ChemMasterSetModeMessage(ChemMasterMode.Discard));
_window.CreatePillButton.OnPressed += _ => SendMessage(
new ChemMasterCreatePillsMessage(
(uint)_window.PillDosage.Value, (uint)_window.PillNumber.Value, _window.LabelLine));
(uint) _window.PillDosage.Value, (uint) _window.PillNumber.Value, _window.LabelLine));
_window.CreateBottleButton.OnPressed += _ => SendMessage(
new ChemMasterOutputToBottleMessage((uint)_window.BottleDosage.Value, _window.LabelLine));
new ChemMasterOutputToBottleMessage(
(uint) _window.BottleDosage.Value, _window.LabelLine));
for (uint i = 0; i < _window.PillTypeButtons.Length; i++)
{

View File

@@ -11,11 +11,13 @@ namespace Content.Client.Chemistry.UI
[UsedImplicitly]
public sealed class ReagentDispenserBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[ViewVariables]
private ReagentDispenserWindow? _window;
[ViewVariables]
private ReagentDispenserBoundUserInterfaceState? _lastState;
public ReagentDispenserBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public ReagentDispenserBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -31,7 +33,7 @@ namespace Content.Client.Chemistry.UI
// Setup window layout/elements
_window = new()
{
Title = _entityManager.GetComponent<MetaDataComponent>(Owner.Owner).EntityName,
Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName,
};
_window.OpenCentered();
@@ -52,11 +54,13 @@ namespace Content.Client.Chemistry.UI
// Setup reagent button actions.
_window.OnDispenseReagentButtonPressed += (args, button) => SendMessage(new ReagentDispenserDispenseReagentMessage(button.ReagentId));
_window.OnDispenseReagentButtonMouseEntered += (args, button) => {
_window.OnDispenseReagentButtonMouseEntered += (args, button) =>
{
if (_lastState is not null)
_window.UpdateContainerInfo(_lastState, button.ReagentId);
};
_window.OnDispenseReagentButtonMouseExited += (args, button) => {
_window.OnDispenseReagentButtonMouseExited += (args, button) =>
{
if (_lastState is not null)
_window.UpdateContainerInfo(_lastState);
};
@@ -73,7 +77,7 @@ namespace Content.Client.Chemistry.UI
{
base.UpdateState(state);
var castState = (ReagentDispenserBoundUserInterfaceState)state;
var castState = (ReagentDispenserBoundUserInterfaceState) state;
_lastState = castState;
_window?.UpdateState(castState); //Update window state

View File

@@ -8,8 +8,13 @@ namespace Content.Client.Chemistry.UI
[UsedImplicitly]
public sealed class TransferAmountBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private TransferAmountWindow? _window;
public TransferAmountBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
@@ -27,10 +32,6 @@ namespace Content.Client.Chemistry.UI
_window.OpenCentered();
}
public TransferAmountBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);