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

@@ -10,7 +10,7 @@ namespace Content.Client.Access.UI
{
private AgentIDCardWindow? _window;
public AgentIDCardBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public AgentIDCardBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

View File

@@ -10,19 +10,21 @@ namespace Content.Client.Access.UI
public sealed class IdCardConsoleBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
private readonly SharedIdCardConsoleSystem _idCardConsoleSystem = default!;
public IdCardConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
{
}
private IdCardConsoleWindow? _window;
public IdCardConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
_idCardConsoleSystem = EntMan.System<SharedIdCardConsoleSystem>();
}
protected override void Open()
{
base.Open();
List<string> accessLevels;
if (_entityManager.TryGetComponent<IdCardConsoleComponent>(Owner.Owner, out var idCard))
if (EntMan.TryGetComponent<IdCardConsoleComponent>(Owner, out var idCard))
{
accessLevels = idCard.AccessLevels;
accessLevels.Sort();
@@ -30,10 +32,13 @@ namespace Content.Client.Access.UI
else
{
accessLevels = new List<string>();
Logger.ErrorS(SharedIdCardConsoleSystem.Sawmill, $"No IdCardConsole component found for {_entityManager.ToPrettyString(Owner.Owner)}!");
_idCardConsoleSystem.Log.Error($"No IdCardConsole component found for {EntMan.ToPrettyString(Owner)}!");
}
_window = new IdCardConsoleWindow(this, _prototypeManager, accessLevels) {Title = _entityManager.GetComponent<MetaDataComponent>(Owner.Owner).EntityName};
_window = new IdCardConsoleWindow(this, _prototypeManager, accessLevels)
{
Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName
};
_window.CrewManifestButton.OnPressed += _ => SendMessage(new CrewManifestOpenUiMessage());
_window.PrivilegedIdButton.OnPressed += _ => SendMessage(new ItemSlotButtonPressedEvent(PrivilegedIdCardSlotId));

View File

@@ -6,12 +6,13 @@ namespace Content.Client.AirlockPainter.UI
{
public sealed class AirlockPainterBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private AirlockPainterWindow? _window;
[ViewVariables]
private AirlockPainterSystem? _painter;
[Dependency] private readonly IEntitySystemManager _entitySystems = default!;
public AirlockPainterBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public AirlockPainterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -21,7 +22,7 @@ namespace Content.Client.AirlockPainter.UI
_window = new AirlockPainterWindow();
_painter = _entitySystems.GetEntitySystem<AirlockPainterSystem>();
_painter = EntMan.System<AirlockPainterSystem>();
_window.OpenCentered();
_window.OnClose += Close;

View File

@@ -9,7 +9,7 @@ namespace Content.Client.Ame.UI
{
private AmeWindow? _window;
public AmeControllerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public AmeControllerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

View File

@@ -3,14 +3,14 @@ using Content.Shared.Gravity;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
namespace Content.Client. Anomaly.Ui;
namespace Content.Client.Anomaly.Ui;
[UsedImplicitly]
public sealed class AnomalyGeneratorBoundUserInterface : BoundUserInterface
{
private AnomalyGeneratorWindow? _window;
public AnomalyGeneratorBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base (owner, uiKey)
public AnomalyGeneratorBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -18,7 +18,7 @@ public sealed class AnomalyGeneratorBoundUserInterface : BoundUserInterface
{
base.Open();
_window = new (Owner.Owner);
_window = new(Owner);
_window.OpenCentered();
_window.OnClose += Close;

View File

@@ -9,7 +9,7 @@ public sealed class AnomalyScannerBoundUserInterface : BoundUserInterface
{
private AnomalyScannerMenu? _menu;
public AnomalyScannerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public AnomalyScannerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

View File

@@ -7,7 +7,7 @@ public sealed class BlockGameBoundUserInterface : BoundUserInterface
{
private BlockGameMenu? _menu;
public BlockGameBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public BlockGameBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

View File

@@ -11,7 +11,7 @@ public sealed class SpaceVillainArcadeBoundUserInterface : BoundUserInterface
//public SharedSpaceVillainArcadeComponent SpaceVillainArcade;
public SpaceVillainArcadeBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public SpaceVillainArcadeBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
SendAction(PlayerAction.RequestData);
}

View File

@@ -12,7 +12,7 @@ public sealed class AirAlarmBoundUserInterface : BoundUserInterface
{
private AirAlarmWindow? _window;
public AirAlarmBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public AirAlarmBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -20,7 +20,7 @@ public sealed class AirAlarmBoundUserInterface : BoundUserInterface
{
base.Open();
_window = new AirAlarmWindow(Owner);
_window = new AirAlarmWindow(this);
if (State != null)
{

View File

@@ -44,7 +44,7 @@ public sealed partial class AirAlarmWindow : FancyWindow
private OptionButton _modes => CModeButton;
public AirAlarmWindow(ClientUserInterfaceComponent component)
public AirAlarmWindow(BoundUserInterface owner)
{
RobustXamlLoader.Load(this);
@@ -88,7 +88,7 @@ public sealed partial class AirAlarmWindow : FancyWindow
ResyncAllRequested!.Invoke();
};
EntityView.Sprite = IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(component.Owner);
EntityView.SetEntity(owner.Owner);
}
public void UpdateState(AirAlarmUIState state)

View File

@@ -5,12 +5,13 @@ namespace Content.Client.Atmos.UI
{
public sealed class GasAnalyzerBoundUserInterface : BoundUserInterface
{
public GasAnalyzerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
[ViewVariables]
private GasAnalyzerWindow? _window;
public GasAnalyzerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
private GasAnalyzerWindow? _window;
protected override void Open()
{
base.Open();

View File

@@ -1,7 +1,6 @@
using Content.Shared.Atmos.Piping.Binary.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.Atmos.UI
{
@@ -11,10 +10,10 @@ namespace Content.Client.Atmos.UI
[UsedImplicitly]
public sealed class GasCanisterBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private GasCanisterWindow? _window;
public GasCanisterBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public GasCanisterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -24,7 +23,7 @@ namespace Content.Client.Atmos.UI
_window = new GasCanisterWindow();
if(State != null)
if (State != null)
UpdateState(State);
_window.OpenCentered();

View File

@@ -12,10 +12,13 @@ namespace Content.Client.Atmos.UI
[UsedImplicitly]
public sealed class GasFilterBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private const float MaxTransferRate = Atmospherics.MaxTransferRate;
[ViewVariables]
private GasFilterWindow? _window;
public GasFilterBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public GasFilterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -23,11 +26,11 @@ namespace Content.Client.Atmos.UI
{
base.Open();
var atmosSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AtmosphereSystem>();
var atmosSystem = EntMan.System<AtmosphereSystem>();
_window = new GasFilterWindow(atmosSystem.Gases);
if(State != null)
if (State != null)
UpdateState(State);
_window.OpenCentered();
@@ -81,7 +84,7 @@ namespace Content.Client.Atmos.UI
_window.SetTransferRate(cast.TransferRate);
if (cast.FilteredGas is not null)
{
var atmos = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AtmosphereSystem>();
var atmos = EntMan.System<AtmosphereSystem>();
var gas = atmos.GetGas((Gas) cast.FilteredGas);
var gasName = Loc.GetString(gas.Name);
_window.SetGasFiltered(gas.ID, gasName);

View File

@@ -1,11 +1,7 @@
using System;
using Content.Client.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Piping.Binary.Components;
using Content.Shared.Atmos.Piping.Trinary.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.Atmos.UI
{
@@ -15,11 +11,13 @@ namespace Content.Client.Atmos.UI
[UsedImplicitly]
public sealed class GasMixerBoundUserInterface : BoundUserInterface
{
private GasMixerWindow? _window;
[ViewVariables]
private const float MaxPressure = Atmospherics.MaxOutputPressure;
public GasMixerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
[ViewVariables]
private GasMixerWindow? _window;
public GasMixerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -29,7 +27,7 @@ namespace Content.Client.Atmos.UI
_window = new GasMixerWindow();
if(State != null)
if (State != null)
UpdateState(State);
_window.OpenCentered();
@@ -49,8 +47,9 @@ namespace Content.Client.Atmos.UI
private void OnMixerOutputPressurePressed(string value)
{
float pressure = float.TryParse(value, out var parsed) ? parsed : 0f;
if (pressure > MaxPressure) pressure = MaxPressure;
var pressure = float.TryParse(value, out var parsed) ? parsed : 0f;
if (pressure > MaxPressure)
pressure = MaxPressure;
SendMessage(new GasMixerChangeOutputPressureMessage(pressure));
}
@@ -58,11 +57,12 @@ namespace Content.Client.Atmos.UI
private void OnMixerSetPercentagePressed(string value)
{
// We don't need to send both nodes because it's just 100.0f - node
float node = float.TryParse(value, out var parsed) ? parsed : 1.0f;
var node = float.TryParse(value, out var parsed) ? parsed : 1.0f;
node = Math.Clamp(node, 0f, 100.0f);
if (_window is not null) node = _window.NodeOneLastEdited ? node : 100.0f - node;
if (_window is not null)
node = _window.NodeOneLastEdited ? node : 100.0f - node;
SendMessage(new GasMixerChangeNodePercentageMessage(node));
}

View File

@@ -1,11 +1,7 @@
using System;
using Content.Client.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Piping.Binary.Components;
using Content.Shared.Atmos.Piping.Trinary.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.Atmos.UI
{
@@ -15,11 +11,13 @@ namespace Content.Client.Atmos.UI
[UsedImplicitly]
public sealed class GasPressurePumpBoundUserInterface : BoundUserInterface
{
private GasPressurePumpWindow? _window;
[ViewVariables]
private const float MaxPressure = Atmospherics.MaxOutputPressure;
public GasPressurePumpBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
[ViewVariables]
private GasPressurePumpWindow? _window;
public GasPressurePumpBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -29,7 +27,7 @@ namespace Content.Client.Atmos.UI
_window = new GasPressurePumpWindow();
if(State != null)
if (State != null)
UpdateState(State);
_window.OpenCentered();

View File

@@ -1,9 +1,6 @@
using Content.Shared.Atmos;
using Content.Shared.Atmos.Piping.Binary.Components;
using Content.Shared.Atmos.Piping.Unary.Components;
using Content.Shared.Atmos.Piping.Unary.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.Atmos.UI
{
@@ -13,12 +10,16 @@ namespace Content.Client.Atmos.UI
[UsedImplicitly]
public sealed class GasThermomachineBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private GasThermomachineWindow? _window;
[ViewVariables]
private float _minTemp = 0.0f;
[ViewVariables]
private float _maxTemp = 0.0f;
public GasThermomachineBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public GasThermomachineBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -28,7 +29,7 @@ namespace Content.Client.Atmos.UI
_window = new GasThermomachineWindow();
if(State != null)
if (State != null)
UpdateState(State);
_window.OpenCentered();

View File

@@ -2,7 +2,6 @@
using Content.Shared.Atmos.Piping.Binary.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.Atmos.UI
{
@@ -12,11 +11,13 @@ namespace Content.Client.Atmos.UI
[UsedImplicitly]
public sealed class GasVolumePumpBoundUserInterface : BoundUserInterface
{
private GasVolumePumpWindow? _window;
[ViewVariables]
private const float MaxTransferRate = Atmospherics.MaxTransferRate;
public GasVolumePumpBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
[ViewVariables]
private GasVolumePumpWindow? _window;
public GasVolumePumpBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -26,7 +27,7 @@ namespace Content.Client.Atmos.UI
_window = new GasVolumePumpWindow();
if(State != null)
if (State != null)
UpdateState(State);
_window.OpenCentered();
@@ -45,8 +46,9 @@ namespace Content.Client.Atmos.UI
private void OnPumpTransferRatePressed(string value)
{
float rate = float.TryParse(value, out var parsed) ? parsed : 0f;
if (rate > MaxTransferRate) rate = MaxTransferRate;
var rate = float.TryParse(value, out var parsed) ? parsed : 0f;
if (rate > MaxTransferRate)
rate = MaxTransferRate;
SendMessage(new GasVolumePumpChangeTransferRateMessage(rate));
}

View File

@@ -11,9 +11,8 @@ public sealed class CargoBountyConsoleBoundUserInterface : BoundUserInterface
[ViewVariables]
private CargoBountyMenu? _menu;
public CargoBountyConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public CargoBountyConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()

View File

@@ -38,9 +38,10 @@ namespace Content.Client.Cargo.BUI
/// <summary>
/// Currently selected product
/// </summary>
[ViewVariables]
private CargoProductPrototype? _product;
public CargoOrderConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public CargoOrderConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -48,17 +49,15 @@ namespace Content.Client.Cargo.BUI
{
base.Open();
var entityManager = IoCManager.Resolve<IEntityManager>();
var sysManager = entityManager.EntitySysManager;
var spriteSystem = sysManager.GetEntitySystem<SpriteSystem>();
var spriteSystem = EntMan.System<SpriteSystem>();
_menu = new CargoConsoleMenu(IoCManager.Resolve<IPrototypeManager>(), spriteSystem);
var localPlayer = IoCManager.Resolve<IPlayerManager>()?.LocalPlayer?.ControlledEntity;
var description = new FormattedMessage();
string orderRequester;
if (entityManager.TryGetComponent<MetaDataComponent>(localPlayer, out var metadata))
orderRequester = Identity.Name(localPlayer.Value, entityManager);
if (EntMan.TryGetComponent<MetaDataComponent>(localPlayer, out var metadata))
orderRequester = Identity.Name(localPlayer.Value, EntMan);
else
orderRequester = string.Empty;
@@ -138,7 +137,7 @@ namespace Content.Client.Cargo.BUI
private bool AddOrder()
{
int orderAmt = _orderMenu?.Amount.Value ?? 0;
var orderAmt = _orderMenu?.Amount.Value ?? 0;
if (orderAmt < 1 || orderAmt > OrderCapacity)
{
return false;

View File

@@ -7,9 +7,12 @@ namespace Content.Client.Cargo.BUI;
public sealed class CargoPalletConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private CargoPalletMenu? _menu;
public CargoPalletConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) {}
public CargoPalletConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{

View File

@@ -9,9 +9,12 @@ namespace Content.Client.Cargo.BUI;
[UsedImplicitly]
public sealed class CargoShuttleConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private CargoShuttleMenu? _menu;
public CargoShuttleConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) {}
public CargoShuttleConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{

View File

@@ -8,15 +8,17 @@ namespace Content.Client.CartridgeLoader;
public abstract class CartridgeLoaderBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IEntityManager? _entityManager = default!;
[ViewVariables]
private EntityUid? _activeProgram;
[ViewVariables]
private UIFragment? _activeCartridgeUI;
[ViewVariables]
private Control? _activeUiFragment;
protected CartridgeLoaderBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
protected CartridgeLoaderBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
}
protected override void UpdateState(BoundUserInterfaceState state)
@@ -119,7 +121,7 @@ public abstract class CartridgeLoaderBoundUserInterface : BoundUserInterface
protected CartridgeComponent? RetrieveCartridgeComponent(EntityUid? cartridgeUid)
{
return _entityManager?.GetComponentOrNull<CartridgeComponent>(cartridgeUid);
return EntMan.GetComponentOrNull<CartridgeComponent>(cartridgeUid);
}
private void SendCartridgeUiReadyEvent(EntityUid cartridgeUid)
@@ -130,7 +132,7 @@ public abstract class CartridgeLoaderBoundUserInterface : BoundUserInterface
private UIFragment? RetrieveCartridgeUI(EntityUid? cartridgeUid)
{
var component = _entityManager?.GetComponentOrNull<UIFragmentComponent>(cartridgeUid);
var component = EntMan.GetComponentOrNull<UIFragmentComponent>(cartridgeUid);
component?.Ui?.Setup(this, cartridgeUid);
return component?.Ui;
}

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);

View File

@@ -7,9 +7,10 @@ namespace Content.Client.CloningConsole.UI
[UsedImplicitly]
public sealed class CloningConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private CloningConsoleWindow? _window;
public CloningConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public CloningConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

View File

@@ -8,15 +8,14 @@ namespace Content.Client.Clothing.UI;
[UsedImplicitly]
public sealed class ChameleonBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IEntityManager _entityManager = default!;
private readonly ChameleonClothingSystem _chameleon;
[ViewVariables]
private ChameleonMenu? _menu;
public ChameleonBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public ChameleonBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
_chameleon = _entityManager.System<ChameleonClothingSystem>();
_chameleon = EntMan.System<ChameleonClothingSystem>();
}
protected override void Open()

View File

@@ -8,23 +8,31 @@ namespace Content.Client.Communications.UI
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[ViewVariables] private CommunicationsConsoleMenu? _menu;
[ViewVariables]
private CommunicationsConsoleMenu? _menu;
[ViewVariables]
public bool CanAnnounce { get; private set; }
[ViewVariables]
public bool CanCall { get; private set; }
[ViewVariables]
public bool CountdownStarted { get; private set; }
[ViewVariables]
public bool AlertLevelSelectable { get; private set; }
[ViewVariables]
public string CurrentLevel { get; private set; } = default!;
public int Countdown => _expectedCountdownTime == null ? 0 : Math.Max((int)_expectedCountdownTime.Value.Subtract(_gameTiming.CurTime).TotalSeconds, 0);
[ViewVariables]
private TimeSpan? _expectedCountdownTime;
public CommunicationsConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
{
public int Countdown => _expectedCountdownTime == null ? 0 : Math.Max((int) _expectedCountdownTime.Value.Subtract(_gameTiming.CurTime).TotalSeconds, 0);
public CommunicationsConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()

View File

@@ -1,7 +1,5 @@
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Client.Computer
{
@@ -13,6 +11,8 @@ namespace Content.Client.Computer
public class ComputerBoundUserInterface<TWindow, TState> : ComputerBoundUserInterfaceBase where TWindow : BaseWindow, IComputerWindow<TState>, new() where TState : BoundUserInterfaceState
{
[Dependency] private readonly IDynamicTypeFactory _dynamicTypeFactory = default!;
[ViewVariables]
private TWindow? _window;
protected override void Open()
@@ -26,7 +26,9 @@ namespace Content.Client.Computer
}
// Alas, this constructor has to be copied to the subclass. :(
public ComputerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) {}
public ComputerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void UpdateState(BoundUserInterfaceState state)
{
@@ -58,7 +60,9 @@ namespace Content.Client.Computer
[Virtual]
public class ComputerBoundUserInterfaceBase : BoundUserInterface
{
public ComputerBoundUserInterfaceBase(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) {}
public ComputerBoundUserInterfaceBase(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
public new void SendMessage(BoundUserInterfaceMessage msg)
{
@@ -68,8 +72,13 @@ namespace Content.Client.Computer
public interface IComputerWindow<TState>
{
void SetupComputerWindow(ComputerBoundUserInterfaceBase cb) {}
void UpdateState(TState state) {}
void SetupComputerWindow(ComputerBoundUserInterfaceBase cb)
{
}
void UpdateState(TState state)
{
}
}
}

View File

@@ -1,21 +1,21 @@
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text.RegularExpressions;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using static Content.Shared.Configurable.ConfigurationComponent;
namespace Content.Client.Configurable.UI
{
public sealed class ConfigurationBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private ConfigurationMenu? _menu;
[ViewVariables]
public Regex? Validation { get; internal set; }
public ConfigurationBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public ConfigurationBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
private ConfigurationMenu? _menu;
protected override void Open()
{
base.Open();

View File

@@ -2,20 +2,19 @@
using Content.Shared.Crayon;
using Content.Shared.Decals;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Client.Crayon.UI
{
public sealed class CrayonBoundUserInterface : BoundUserInterface
{
public CrayonBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
[ViewVariables]
private CrayonWindow? _menu;
public CrayonBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
private CrayonWindow? _menu;
protected override void Open()
{
base.Open();

View File

@@ -1,6 +1,5 @@
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using static Content.Shared.Disposal.Components.SharedDisposalRouterComponent;
namespace Content.Client.Disposal.UI
@@ -11,9 +10,10 @@ namespace Content.Client.Disposal.UI
[UsedImplicitly]
public sealed class DisposalRouterBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private DisposalRouterWindow? _window;
public DisposalRouterBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public DisposalRouterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

View File

@@ -1,6 +1,5 @@
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using static Content.Shared.Disposal.Components.SharedDisposalTaggerComponent;
namespace Content.Client.Disposal.UI
@@ -11,9 +10,10 @@ namespace Content.Client.Disposal.UI
[UsedImplicitly]
public sealed class DisposalTaggerBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private DisposalTaggerWindow? _window;
public DisposalTaggerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public DisposalTaggerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

View File

@@ -14,16 +14,15 @@ namespace Content.Client.Disposal.UI
[UsedImplicitly]
public sealed class DisposalUnitBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IEntityManager _entityManager = default!;
// What are you doing here
[ViewVariables]
public MailingUnitWindow? MailingUnitWindow;
[ViewVariables]
public DisposalUnitWindow? DisposalUnitWindow;
public DisposalUnitBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public DisposalUnitBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
}
private void ButtonPressed(UiButton button)
@@ -56,7 +55,7 @@ namespace Content.Client.Disposal.UI
MailingUnitWindow.TargetListContainer.OnItemSelected += TargetSelected;
}
else if(UiKey is DisposalUnitUiKey)
else if (UiKey is DisposalUnitUiKey)
{
DisposalUnitWindow = new DisposalUnitWindow();

View File

@@ -7,9 +7,10 @@ namespace Content.Client.Fax.UI;
[UsedImplicitly]
public sealed class FaxBoundUi : BoundUserInterface
{
[ViewVariables]
private FaxWindow? _window;
public FaxBoundUi(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public FaxBoundUi(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

View File

@@ -8,11 +8,13 @@ namespace Content.Client.Forensics
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[ViewVariables]
private ForensicScannerMenu? _window;
[ViewVariables]
private TimeSpan _printCooldown;
public ForensicScannerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public ForensicScannerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

View File

@@ -1,16 +1,16 @@
using Content.Shared.Gravity;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.Gravity.UI
{
[UsedImplicitly]
public sealed class GravityGeneratorBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private GravityGeneratorWindow? _window;
public GravityGeneratorBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base (owner, uiKey)
public GravityGeneratorBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -18,7 +18,7 @@ namespace Content.Client.Gravity.UI
{
base.Open();
_window = new GravityGeneratorWindow(this, Owner);
_window = new GravityGeneratorWindow(this);
/*
_window.Switch.OnPressed += _ =>

View File

@@ -14,12 +14,12 @@ namespace Content.Client.Gravity.UI
private readonly GravityGeneratorBoundUserInterface _owner;
public GravityGeneratorWindow(GravityGeneratorBoundUserInterface ui, ClientUserInterfaceComponent component)
public GravityGeneratorWindow(GravityGeneratorBoundUserInterface owner)
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
_owner = ui;
_owner = owner;
OnButton.Group = _buttonGroup;
OffButton.Group = _buttonGroup;
@@ -27,7 +27,7 @@ namespace Content.Client.Gravity.UI
OnButton.OnPressed += _ => _owner.SetPowerSwitch(true);
OffButton.OnPressed += _ => _owner.SetPowerSwitch(false);
EntityView.Sprite = IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(component.Owner);
EntityView.SetEntity(owner.Owner);
}
public void UpdateState(SharedGravityGeneratorComponent.GeneratorState state)

View File

@@ -7,9 +7,10 @@ namespace Content.Client.HealthAnalyzer.UI
[UsedImplicitly]
public sealed class HealthAnalyzerBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private HealthAnalyzerWindow? _window;
public HealthAnalyzerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public HealthAnalyzerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -18,7 +19,7 @@ namespace Content.Client.HealthAnalyzer.UI
base.Open();
_window = new HealthAnalyzerWindow
{
Title = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Owner).EntityName,
Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName,
};
_window.OnClose += Close;
_window.OpenCentered();

View File

@@ -11,12 +11,13 @@ namespace Content.Client.Humanoid;
public sealed class HumanoidMarkingModifierBoundUserInterface : BoundUserInterface
{
public HumanoidMarkingModifierBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
[ViewVariables]
private HumanoidMarkingModifierWindow? _window;
public HumanoidMarkingModifierBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
private HumanoidMarkingModifierWindow? _window;
protected override void Open()
{
base.Open();

View File

@@ -1,7 +1,4 @@
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.ViewVariables;
namespace Content.Client.Instruments.UI
{
@@ -10,15 +7,16 @@ namespace Content.Client.Instruments.UI
[ViewVariables]
private InstrumentMenu? _instrumentMenu;
[ViewVariables]
public InstrumentComponent? Instrument { get; set; }
public InstrumentBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public InstrumentBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<InstrumentComponent?>(Owner.Owner, out var instrument)) return;
if (!EntMan.TryGetComponent<InstrumentComponent?>(Owner, out var instrument)) return;
Instrument = instrument;
_instrumentMenu = new InstrumentMenu(this);

View File

@@ -29,31 +29,34 @@ namespace Content.Client.Inventory
[UsedImplicitly]
public sealed class StrippableBoundUserInterface : BoundUserInterface
{
private const int ButtonSeparation = 4;
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IUserInterfaceManager _ui = default!;
private ExamineSystem _examine = default!;
private InventorySystem _inv = default!;
private readonly ExamineSystem _examine = default!;
private readonly InventorySystem _inv = default!;
private readonly SharedCuffableSystem _cuffable;
[ViewVariables]
private StrippingMenu? _strippingMenu;
private const int ButtonSeparation = 4;
[ViewVariables]
public const string HiddenPocketEntityId = "StrippingHiddenEntity";
private EntityUid _virtualHiddenEntity;
public StrippableBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
[ViewVariables]
private readonly StrippingMenu? _strippingMenu;
[ViewVariables]
private readonly EntityUid _virtualHiddenEntity;
public StrippableBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
_examine = _entMan.EntitySysManager.GetEntitySystem<ExamineSystem>();
_inv = _entMan.EntitySysManager.GetEntitySystem<InventorySystem>();
_cuffable = _entMan.System<SharedCuffableSystem>();
var title = Loc.GetString("strippable-bound-user-interface-stripping-menu-title", ("ownerName", Identity.Name(Owner.Owner, _entMan)));
_examine = EntMan.System<ExamineSystem>();
_inv = EntMan.System<InventorySystem>();
_cuffable = EntMan.System<SharedCuffableSystem>();
var title = Loc.GetString("strippable-bound-user-interface-stripping-menu-title", ("ownerName", Identity.Name(Owner, EntMan)));
_strippingMenu = new StrippingMenu(title, this);
_strippingMenu.OnClose += Close;
_virtualHiddenEntity = _entMan.SpawnEntity(HiddenPocketEntityId, MapCoordinates.Nullspace);
_virtualHiddenEntity = EntMan.SpawnEntity(HiddenPocketEntityId, MapCoordinates.Nullspace);
}
protected override void Open()
@@ -66,7 +69,7 @@ namespace Content.Client.Inventory
{
base.Dispose(disposing);
_entMan.DeleteEntity(_virtualHiddenEntity);
EntMan.DeleteEntity(_virtualHiddenEntity);
if (!disposing)
return;
@@ -87,15 +90,15 @@ namespace Content.Client.Inventory
_strippingMenu.ClearButtons();
if (_entMan.TryGetComponent(Owner.Owner, out InventoryComponent? inv) && _protoMan.TryIndex<InventoryTemplatePrototype>(inv.TemplateId, out var template))
if (EntMan.TryGetComponent<InventoryComponent>(Owner, out var inv) && _protoMan.TryIndex<InventoryTemplatePrototype>(inv.TemplateId, out var template))
{
foreach (var slot in template.Slots)
{
AddInventoryButton(slot.Name, template, inv);
AddInventoryButton(Owner, slot.Name, template, inv);
}
}
if (_entMan.TryGetComponent(Owner.Owner, out HandsComponent? handsComp))
if (EntMan.TryGetComponent<HandsComponent>(Owner, out var handsComp))
{
// good ol hands shit code. there is a GuiHands comparer that does the same thing... but these are hands
// and not gui hands... which are different...
@@ -125,7 +128,7 @@ namespace Content.Client.Inventory
}
// snare-removal button. This is just the old button before the change to item slots. It is pretty out of place.
if (_entMan.TryGetComponent(Owner.Owner, out EnsnareableComponent? snare) && snare.IsEnsnared)
if (EntMan.TryGetComponent<EnsnareableComponent>(Owner, out var snare) && snare.IsEnsnared)
{
var button = new Button()
{
@@ -156,10 +159,10 @@ namespace Content.Client.Inventory
button.Pressed += SlotPressed;
if (_entMan.TryGetComponent(hand.HeldEntity, out HandVirtualItemComponent? virt))
if (EntMan.TryGetComponent<HandVirtualItemComponent>(hand.HeldEntity, out var virt))
{
button.Blocked = true;
if (_entMan.TryGetComponent(Owner.Owner, out CuffableComponent? cuff) && _cuffable.GetAllCuffs(cuff).Contains(virt.BlockingEntity))
if (EntMan.TryGetComponent<CuffableComponent>(Owner, out var cuff) && _cuffable.GetAllCuffs(cuff).Contains(virt.BlockingEntity))
button.BlockedRect.MouseFilter = MouseFilterMode.Ignore;
}
@@ -187,9 +190,9 @@ namespace Content.Client.Inventory
_ui.GetUIController<VerbMenuUIController>().OpenVerbMenu(slot.Entity.Value);
}
private void AddInventoryButton(string slotId, InventoryTemplatePrototype template, InventoryComponent inv)
private void AddInventoryButton(EntityUid invUid, string slotId, InventoryTemplatePrototype _, InventoryComponent inv)
{
if (!_inv.TryGetSlotContainer(inv.Owner, slotId, out var container, out var slotDef, inv))
if (!_inv.TryGetSlotContainer(invUid, slotId, out var container, out var slotDef, inv))
return;
var entity = container.ContainedEntity;
@@ -216,17 +219,19 @@ namespace Content.Client.Inventory
if (entity == null)
{
button.SpriteView.Sprite = null;
button.SpriteView.SetEntity(null);
return;
}
SpriteComponent? sprite;
if (_entMan.TryGetComponent(entity, out HandVirtualItemComponent? virt))
_entMan.TryGetComponent(virt.BlockingEntity, out sprite);
else if (!_entMan.TryGetComponent(entity, out sprite))
EntityUid? viewEnt;
if (EntMan.TryGetComponent<HandVirtualItemComponent>(entity, out var virt))
viewEnt = EntMan.HasComponent<SpriteComponent>(virt.BlockingEntity) ? virt.BlockingEntity : null;
else if (EntMan.HasComponent<SpriteComponent>(entity))
viewEnt = entity;
else
return;
button.SpriteView.Sprite = sprite;
button.SpriteView.SetEntity(viewEnt);
}
}
}

View File

@@ -1,29 +1,25 @@
using System.Collections.Generic;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Kitchen.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
namespace Content.Client.Kitchen.UI
{
[UsedImplicitly]
public sealed class MicrowaveBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[ViewVariables]
private MicrowaveMenu? _menu;
[ViewVariables]
private readonly Dictionary<int, EntityUid> _solids = new();
private readonly Dictionary<int, Solution.ReagentQuantity> _reagents =new();
public MicrowaveBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner,uiKey)
[ViewVariables]
private readonly Dictionary<int, Solution.ReagentQuantity> _reagents = new();
public MicrowaveBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -40,10 +36,10 @@ namespace Content.Client.Kitchen.UI
SendMessage(new MicrowaveEjectSolidIndexedMessage(_solids[args.ItemIndex]));
};
_menu.OnCookTimeSelected += (args,buttonIndex) =>
_menu.OnCookTimeSelected += (args, buttonIndex) =>
{
var actualButton = (MicrowaveMenu.MicrowaveCookTimeButton) args.Button ;
SendMessage(new MicrowaveSelectCookTimeMessage(buttonIndex,actualButton.CookTime));
var actualButton = (MicrowaveMenu.MicrowaveCookTimeButton) args.Button;
SendMessage(new MicrowaveSelectCookTimeMessage(buttonIndex, actualButton.CookTime));
};
}
@@ -93,7 +89,7 @@ namespace Content.Client.Kitchen.UI
_menu.IngredientsList.Clear();
foreach (var entity in containedSolids)
{
if (_entityManager.Deleted(entity))
if (EntMan.Deleted(entity))
{
return;
}
@@ -101,11 +97,11 @@ namespace Content.Client.Kitchen.UI
// TODO just use sprite view
Texture? texture;
if (_entityManager.TryGetComponent(entity, out IconComponent? iconComponent))
if (EntMan.TryGetComponent<IconComponent>(entity, out var iconComponent))
{
texture = _entityManager.System<SpriteSystem>().GetIcon(iconComponent);
texture = EntMan.System<SpriteSystem>().GetIcon(iconComponent);
}
else if (_entityManager.TryGetComponent(entity, out SpriteComponent? spriteComponent))
else if (EntMan.TryGetComponent<SpriteComponent>(entity, out var spriteComponent))
{
texture = spriteComponent.Icon?.Default;
}
@@ -114,7 +110,7 @@ namespace Content.Client.Kitchen.UI
continue;
}
var solidItem = _menu.IngredientsList.AddItem(_entityManager.GetComponent<MetaDataComponent>(entity).EntityName, texture);
var solidItem = _menu.IngredientsList.AddItem(EntMan.GetComponent<MetaDataComponent>(entity).EntityName, texture);
var solidIndex = _menu.IngredientsList.IndexOf(solidItem);
_solids.Add(solidIndex, entity);
}

View File

@@ -8,18 +8,20 @@ namespace Content.Client.Kitchen.UI
{
public sealed class ReagentGrinderBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[ViewVariables]
private GrinderMenu? _menu;
public ReagentGrinderBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) { }
public ReagentGrinderBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_menu = new GrinderMenu(this, _entityManager, _prototypeManager);
_menu = new GrinderMenu(this, EntMan, _prototypeManager);
_menu.OpenCentered();
_menu.OnClose += Close;
}
@@ -38,10 +40,8 @@ namespace Content.Client.Kitchen.UI
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (!(state is ReagentGrinderInterfaceState cState))
{
if (state is not ReagentGrinderInterfaceState cState)
return;
}
_menu?.UpdateState(cState);
}
@@ -52,10 +52,29 @@ namespace Content.Client.Kitchen.UI
_menu?.HandleMessage(message);
}
public void StartGrinding(BaseButton.ButtonEventArgs? args = null) => SendMessage(new ReagentGrinderStartMessage(GrinderProgram.Grind));
public void StartJuicing(BaseButton.ButtonEventArgs? args = null) => SendMessage(new ReagentGrinderStartMessage(GrinderProgram.Juice));
public void EjectAll(BaseButton.ButtonEventArgs? args = null) => SendMessage(new ReagentGrinderEjectChamberAllMessage());
public void EjectBeaker(BaseButton.ButtonEventArgs? args = null) => SendMessage(new ItemSlotButtonPressedEvent(SharedReagentGrinder.BeakerSlotId));
public void EjectChamberContent(EntityUid uid) => SendMessage(new ReagentGrinderEjectChamberContentMessage(uid));
public void StartGrinding(BaseButton.ButtonEventArgs? _ = null)
{
SendMessage(new ReagentGrinderStartMessage(GrinderProgram.Grind));
}
public void StartJuicing(BaseButton.ButtonEventArgs? _ = null)
{
SendMessage(new ReagentGrinderStartMessage(GrinderProgram.Juice));
}
public void EjectAll(BaseButton.ButtonEventArgs? _ = null)
{
SendMessage(new ReagentGrinderEjectChamberAllMessage());
}
public void EjectBeaker(BaseButton.ButtonEventArgs? _ = null)
{
SendMessage(new ItemSlotButtonPressedEvent(SharedReagentGrinder.BeakerSlotId));
}
public void EjectChamberContent(EntityUid uid)
{
SendMessage(new ReagentGrinderEjectChamberContentMessage(uid));
}
}
}

View File

@@ -1,6 +1,5 @@
using Content.Shared.Labels;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.Labels.UI
{
@@ -9,9 +8,10 @@ namespace Content.Client.Labels.UI
/// </summary>
public sealed class HandLabelerBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private HandLabelerWindow? _window;
public HandLabelerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public HandLabelerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

View File

@@ -8,14 +8,14 @@ namespace Content.Client.Lathe.UI
[UsedImplicitly]
public sealed class LatheBoundUserInterface : BoundUserInterface
{
[ViewVariables] private LatheMenu? _menu;
[ViewVariables] private LatheQueueMenu? _queueMenu;
[ViewVariables]
private LatheMenu? _menu;
public EntityUid Lathe;
[ViewVariables]
private LatheQueueMenu? _queueMenu;
public LatheBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public LatheBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
Lathe = owner.Owner;
}
protected override void Open()
@@ -55,8 +55,8 @@ namespace Content.Client.Lathe.UI
case LatheUpdateState msg:
if (_menu != null)
_menu.Recipes = msg.Recipes;
_menu?.PopulateRecipes(Lathe);
_menu?.PopulateMaterials(Lathe);
_menu?.PopulateRecipes(Owner);
_menu?.PopulateMaterials(Owner);
_queueMenu?.PopulateList(msg.Queue);
_queueMenu?.SetInfo(msg.CurrentlyProducing);
break;

View File

@@ -16,8 +16,8 @@ namespace Content.Client.Lathe.UI;
[GenerateTypedNameReferences]
public sealed partial class LatheMenu : DefaultWindow
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private readonly SpriteSystem _spriteSystem;
private readonly LatheSystem _lathe;
@@ -32,24 +32,24 @@ public sealed partial class LatheMenu : DefaultWindow
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
_spriteSystem = _entityManager.EntitySysManager.GetEntitySystem<SpriteSystem>();
_lathe = _entityManager.EntitySysManager.GetEntitySystem<LatheSystem>();
_spriteSystem = _entityManager.System<SpriteSystem>();
_lathe = _entityManager.System<LatheSystem>();
Title = _entityManager.GetComponent<MetaDataComponent>(owner.Lathe).EntityName;
Title = _entityManager.GetComponent<MetaDataComponent>(owner.Owner).EntityName;
SearchBar.OnTextChanged += _ =>
{
PopulateRecipes(owner.Lathe);
PopulateRecipes(owner.Owner);
};
AmountLineEdit.OnTextChanged += _ =>
{
PopulateRecipes(owner.Lathe);
PopulateRecipes(owner.Owner);
};
QueueButton.OnPressed += a => OnQueueButtonPressed?.Invoke(a);
ServerListButton.OnPressed += a => OnServerListButtonPressed?.Invoke(a);
if (_entityManager.TryGetComponent<LatheComponent>(owner.Lathe, out var latheComponent))
if (_entityManager.TryGetComponent<LatheComponent>(owner.Owner, out var latheComponent))
{
if (!latheComponent.DynamicRecipes.Any())
{

View File

@@ -1,18 +1,23 @@
using Content.Shared.MachineLinking;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.MachineLinking.UI
{
public sealed class SignalPortSelectorBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private SignalPortSelectorMenu? _menu;
[ViewVariables]
private string? _selectedTransmitterPort;
[ViewVariables]
private string? _selectedReceiverPort;
public SignalPortSelectorBoundUserInterface([NotNull] ClientUserInterfaceComponent owner, [NotNull] Enum uiKey) : base(owner, uiKey) { }
public SignalPortSelectorBoundUserInterface([NotNull] EntityUid owner, [NotNull] Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{

View File

@@ -8,9 +8,10 @@ public sealed class SignalTimerBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[ViewVariables]
private SignalTimerWindow? _window;
public SignalTimerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public SignalTimerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

View File

@@ -6,9 +6,10 @@ namespace Content.Client.MagicMirror;
public sealed class MagicMirrorBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private MagicMirrorWindow? _window;
public MagicMirrorBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public MagicMirrorBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -20,13 +21,13 @@ public sealed class MagicMirrorBoundUserInterface : BoundUserInterface
_window.OnHairSelected += tuple => SelectHair(MagicMirrorCategory.Hair, tuple.id, tuple.slot);
_window.OnHairColorChanged += args => ChangeColor(MagicMirrorCategory.Hair, args.marking, args.slot);
_window.OnHairSlotAdded += delegate() { AddSlot(MagicMirrorCategory.Hair); };
_window.OnHairSlotAdded += delegate () { AddSlot(MagicMirrorCategory.Hair); };
_window.OnHairSlotRemoved += args => RemoveSlot(MagicMirrorCategory.Hair, args);
_window.OnFacialHairSelected += tuple => SelectHair(MagicMirrorCategory.FacialHair, tuple.id, tuple.slot);
_window.OnFacialHairColorChanged +=
args => ChangeColor(MagicMirrorCategory.FacialHair, args.marking, args.slot);
_window.OnFacialHairSlotAdded += delegate() { AddSlot(MagicMirrorCategory.FacialHair); };
_window.OnFacialHairSlotAdded += delegate () { AddSlot(MagicMirrorCategory.FacialHair); };
_window.OnFacialHairSlotRemoved += args => RemoveSlot(MagicMirrorCategory.FacialHair, args);
_window.OpenCentered();

View File

@@ -9,23 +9,18 @@ namespace Content.Client.Mech.Ui;
[UsedImplicitly]
public sealed class MechBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IEntityManager _ent = default!;
private readonly EntityUid _mech;
[ViewVariables]
private MechMenu? _menu;
public MechBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public MechBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
_mech = owner.Owner;
}
protected override void Open()
{
base.Open();
_menu = new(_mech);
_menu = new(Owner);
_menu.OnClose += Close;
_menu.OpenCenteredLeft();
@@ -49,7 +44,7 @@ public sealed class MechBoundUserInterface : BoundUserInterface
public void UpdateEquipmentControls(MechBoundUiState state)
{
if (!_ent.TryGetComponent<MechComponent>(_mech, out var mechComp))
if (!EntMan.TryGetComponent<MechComponent>(Owner, out var mechComp))
return;
foreach (var ent in mechComp.EquipmentContainer.ContainedEntities)
@@ -77,7 +72,7 @@ public sealed class MechBoundUserInterface : BoundUserInterface
public UIFragment? GetEquipmentUi(EntityUid? uid)
{
var component = _ent.GetComponentOrNull<UIFragmentComponent>(uid);
var component = EntMan.GetComponentOrNull<UIFragmentComponent>(uid);
component?.Ui?.Setup(this, uid);
return component?.Ui;
}

View File

@@ -1,25 +1,22 @@
using Content.Shared.Medical.CrewMonitoring;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.Medical.CrewMonitoring
{
public sealed class CrewMonitoringBoundUserInterface : BoundUserInterface
{
private readonly IEntityManager _entManager;
[ViewVariables]
private CrewMonitoringWindow? _menu;
public CrewMonitoringBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public CrewMonitoringBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
_entManager = IoCManager.Resolve<IEntityManager>();
}
protected override void Open()
{
EntityUid? gridUid = null;
if (_entManager.TryGetComponent<TransformComponent>(Owner.Owner, out var xform))
if (EntMan.TryGetComponent<TransformComponent>(Owner, out var xform))
{
gridUid = xform.GridUid;
}
@@ -37,7 +34,7 @@ namespace Content.Client.Medical.CrewMonitoring
switch (state)
{
case CrewMonitoringState st:
_entManager.TryGetComponent<TransformComponent>(Owner.Owner, out var xform);
EntMan.TryGetComponent<TransformComponent>(Owner, out var xform);
_menu?.ShowSensors(st.Sensors, xform?.Coordinates, st.Snap, st.Precision);
break;

View File

@@ -7,19 +7,20 @@ namespace Content.Client.NetworkConfigurator;
public sealed class NetworkConfiguratorBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IEntityManager _entityManager = default!;
private readonly NetworkConfiguratorSystem _netConfig;
private NetworkConfiguratorListMenu? _listMenu;
[ViewVariables]
private NetworkConfiguratorConfigurationMenu? _configurationMenu;
[ViewVariables]
private NetworkConfiguratorLinkMenu? _linkMenu;
private NetworkConfiguratorSystem _netConfig;
[ViewVariables]
private NetworkConfiguratorListMenu? _listMenu;
public NetworkConfiguratorBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public NetworkConfiguratorBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
_netConfig = _entityManager.System<NetworkConfiguratorSystem>();
_netConfig = EntMan.System<NetworkConfiguratorSystem>();
}
public void OnRemoveButtonPressed(string address)
@@ -48,7 +49,7 @@ public sealed class NetworkConfiguratorBoundUserInterface : BoundUserInterface
_configurationMenu.Clear.OnPressed += _ => OnConfigButtonPressed(NetworkConfiguratorButtonKey.Clear);
_configurationMenu.Copy.OnPressed += _ => OnConfigButtonPressed(NetworkConfiguratorButtonKey.Copy);
_configurationMenu.Show.OnPressed += OnShowPressed;
_configurationMenu.Show.Pressed = _netConfig.ConfiguredListIsTracked(Owner.Owner);
_configurationMenu.Show.Pressed = _netConfig.ConfiguredListIsTracked(Owner);
_configurationMenu.OpenCentered();
break;
case NetworkConfiguratorUiKey.Link:
@@ -61,7 +62,7 @@ public sealed class NetworkConfiguratorBoundUserInterface : BoundUserInterface
private void OnShowPressed(BaseButton.ButtonEventArgs args)
{
_netConfig.ToggleVisualization(Owner.Owner, args.Button.Pressed);
_netConfig.ToggleVisualization(Owner, args.Button.Pressed);
}
protected override void UpdateState(BoundUserInterfaceState state)

View File

@@ -8,9 +8,10 @@ namespace Content.Client.Nuke
[UsedImplicitly]
public sealed class NukeBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private NukeMenu? _menu;
public NukeBoundUserInterface([NotNull] ClientUserInterfaceComponent owner, [NotNull] Enum uiKey) : base(owner, uiKey)
public NukeBoundUserInterface([NotNull] EntityUid owner, [NotNull] Enum uiKey) : base(owner, uiKey)
{
}
@@ -57,12 +58,10 @@ namespace Content.Client.Nuke
switch (state)
{
case NukeUiState msg:
{
_menu.UpdateState(msg);
break;
}
}
}
protected override void Dispose(bool disposing)
{

View File

@@ -5,7 +5,6 @@ using Content.Shared.Containers.ItemSlots;
using Content.Shared.CrewManifest;
using Content.Shared.PDA;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Robust.Shared.Configuration;
@@ -14,14 +13,13 @@ namespace Content.Client.PDA
[UsedImplicitly]
public sealed class PdaBoundUserInterface : CartridgeLoaderBoundUserInterface
{
[Dependency] private readonly IEntityManager? _entityManager = default!;
[Dependency] private readonly IConfigurationManager _configManager = default!;
[ViewVariables]
private PdaMenu? _menu;
public PdaBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public PdaBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
}
protected override void Open()
@@ -132,7 +130,7 @@ namespace Content.Client.PDA
private PdaBorderColorComponent? GetBorderColorComponent()
{
return _entityManager?.GetComponentOrNull<PdaBorderColorComponent>(Owner.Owner);
return EntMan.GetComponentOrNull<PdaBorderColorComponent>(Owner);
}
}
}

View File

@@ -2,14 +2,16 @@ using Content.Shared.PDA;
using Content.Shared.PDA.Ringer;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
namespace Content.Client.PDA.Ringer
{
[UsedImplicitly]
public sealed class RingerBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private RingtoneMenu? _menu;
public RingerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public RingerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

View File

@@ -10,16 +10,16 @@ namespace Content.Client.Paper.UI
[UsedImplicitly]
public sealed class PaperBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private PaperWindow? _window;
public PaperBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public PaperBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
var entityMgr = IoCManager.Resolve<IEntityManager>();
_window = new PaperWindow();
_window.OnClose += Close;
@@ -33,7 +33,7 @@ namespace Content.Client.Paper.UI
}
};
if (entityMgr.TryGetComponent<PaperVisualsComponent>(Owner.Owner, out var visuals))
if (EntMan.TryGetComponent<PaperVisualsComponent>(Owner, out var visuals))
{
_window.InitVisuals(visuals);
}

View File

@@ -5,9 +5,10 @@ namespace Content.Client.ParticleAccelerator.UI
{
public sealed class ParticleAcceleratorBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private ParticleAcceleratorControlMenu? _menu;
public ParticleAcceleratorBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public ParticleAcceleratorBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

View File

@@ -1,13 +1,13 @@
using Robust.Client.GameObjects;
using Robust.Client.Player;
namespace Content.Client.Pinpointer.UI;
public sealed class StationMapBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private StationMapWindow? _window;
public StationMapBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public StationMapBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -17,12 +17,12 @@ public sealed class StationMapBoundUserInterface : BoundUserInterface
_window?.Close();
EntityUid? gridUid = null;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<TransformComponent>(Owner.Owner, out var xform))
if (EntMan.TryGetComponent<TransformComponent>(Owner, out var xform))
{
gridUid = xform.GridUid;
}
_window = new StationMapWindow(gridUid, Owner.Owner);
_window = new StationMapWindow(gridUid, Owner);
_window.OpenCentered();
_window.OnClose += Close;
}

View File

@@ -2,29 +2,28 @@
using Content.Shared.APC;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.ViewVariables;
namespace Content.Client.Power.APC
{
[UsedImplicitly]
public sealed class ApcBoundUserInterface : BoundUserInterface
{
[ViewVariables] private ApcMenu? _menu;
[ViewVariables]
private ApcMenu? _menu;
public ApcBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_menu = new ApcMenu(this,Owner);
_menu = new ApcMenu(this);
_menu.OnClose += Close;
_menu.OpenCentered();
}
public ApcBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

View File

@@ -18,12 +18,12 @@ namespace Content.Client.Power.APC.UI
public sealed partial class ApcMenu : FancyWindow
{
[Dependency] private readonly IEntityManager _entityManager = default!;
public ApcMenu(ApcBoundUserInterface owner, ClientUserInterfaceComponent component)
public ApcMenu(ApcBoundUserInterface owner)
{
IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);
EntityView.Sprite = _entityManager.GetComponent<SpriteComponent>(component.Owner);
EntityView.SetEntity(owner.Owner);
BreakerButton.OnPressed += _ => owner.BreakerPressed();
}

View File

@@ -1,22 +1,14 @@
using System;
using System.Linq;
using System.Numerics;
using Content.Client.Computer;
using Content.Client.IoC;
using Content.Shared.Power;
using JetBrains.Annotations;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Timing;
using Robust.Shared.Prototypes;
namespace Content.Client.Power;
@@ -25,12 +17,14 @@ namespace Content.Client.Power;
public sealed partial class PowerMonitoringWindow : DefaultWindow, IComputerWindow<PowerMonitoringConsoleBoundInterfaceState>
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private readonly SpriteSystem _spriteSystem = default!;
public PowerMonitoringWindow()
{
RobustXamlLoader.Load(this);
SetSize = MinSize = new Vector2(300, 450);
IoCManager.InjectDependencies(this);
_spriteSystem = IoCManager.Resolve<IEntityManager>().System<SpriteSystem>();
MasterTabContainer.SetTabTitle(0, Loc.GetString("power-monitoring-window-tab-sources"));
MasterTabContainer.SetTabTitle(1, Loc.GetString("power-monitoring-window-tab-loads"));
}
@@ -45,7 +39,7 @@ public sealed partial class PowerMonitoringWindow : DefaultWindow, IComputerWind
// This means filtering out loads that are not either:
// + Batteries (always important)
// + Meaningful (size above 0)
loads = loads.Where(a => a.IsBattery || (a.Size > 0.0f)).ToArray();
loads = loads.Where(a => a.IsBattery || a.Size > 0.0f).ToArray();
}
UpdateList(TotalLoadsNum, scc.TotalLoads, LoadsList, loads);
}
@@ -69,7 +63,7 @@ public sealed partial class PowerMonitoringWindow : DefaultWindow, IComputerWind
_prototypeManager.TryIndex(ent.IconEntityPrototypeId, out EntityPrototype? entityPrototype);
IRsiStateLike? iconState = null;
if (entityPrototype != null)
iconState = SpriteComponent.GetPrototypeIcon(entityPrototype, StaticIoC.ResC);
iconState = _spriteSystem.GetPrototypeIcon(entityPrototype);
var icon = iconState?.GetFrame(RSI.State.Direction.South, 0);
var item = list[i];
item.Text = $"{ent.NameLocalized} {Loc.GetString("power-monitoring-window-value", ("value", ent.Size))}";
@@ -81,6 +75,8 @@ public sealed partial class PowerMonitoringWindow : DefaultWindow, IComputerWind
[UsedImplicitly]
public sealed class PowerMonitoringConsoleBoundUserInterface : ComputerBoundUserInterface<PowerMonitoringWindow, PowerMonitoringConsoleBoundInterfaceState>
{
public PowerMonitoringConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) {}
public PowerMonitoringConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
}

View File

@@ -4,14 +4,11 @@ using Content.Client.Computer;
using Content.Shared.Solar;
using JetBrains.Annotations;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Timing;
namespace Content.Client.Power
@@ -19,6 +16,7 @@ namespace Content.Client.Power
[GenerateTypedNameReferences]
public sealed partial class SolarControlWindow : DefaultWindow, IComputerWindow<SolarControlConsoleBoundInterfaceState>
{
[ViewVariables]
private SolarControlConsoleBoundInterfaceState _lastState = new(0, 0, 0, 0);
public SolarControlWindow()
@@ -28,9 +26,10 @@ namespace Content.Client.Power
public void SetupComputerWindow(ComputerBoundUserInterfaceBase cb)
{
PanelRotation.OnTextEntered += text => {
double value;
if (!double.TryParse((string?) text.Text, out value)) return;
PanelRotation.OnTextEntered += text =>
{
if (!double.TryParse((string?) text.Text, out var value))
return;
SolarControlConsoleAdjustMessage msg = new()
{
@@ -43,9 +42,11 @@ namespace Content.Client.Power
_lastState.Rotation = msg.Rotation;
NotARadar.UpdateState(_lastState);
};
PanelVelocity.OnTextEntered += text => {
double value;
if (!double.TryParse((string?) text.Text, out value)) return;
PanelVelocity.OnTextEntered += text =>
{
if (!double.TryParse((string?) text.Text, out var value))
return;
SolarControlConsoleAdjustMessage msg = new()
{
@@ -61,14 +62,14 @@ namespace Content.Client.Power
};
}
private string FormatAngle(Angle d)
private static string FormatAngle(Angle d)
{
return d.Degrees.ToString("F1");
}
// The idea behind this is to prevent every update from the server
// breaking the textfield.
private void UpdateField(LineEdit field, string newValue)
private static void UpdateField(LineEdit field, string newValue)
{
if (!field.HasKeyboardFocus())
{
@@ -92,7 +93,7 @@ namespace Content.Client.Power
{
// This is used for client-side prediction of the panel rotation.
// This makes the display feel a lot smoother.
private IGameTiming _gameTiming = IoCManager.Resolve<IGameTiming>();
[Dependency] private readonly IGameTiming _gameTiming = default!;
private SolarControlConsoleBoundInterfaceState _lastState = new(0, 0, 0, 0);
@@ -105,6 +106,7 @@ namespace Content.Client.Power
public SolarControlNotARadar()
{
IoCManager.InjectDependencies(this);
MinSize = new Vector2(SizeFull, SizeFull);
}
@@ -114,7 +116,7 @@ namespace Content.Client.Power
_lastStateTime = _gameTiming.CurTime;
}
public Angle PredictedPanelRotation => _lastState.Rotation + (_lastState.AngularVelocity * ((_gameTiming.CurTime - _lastStateTime).TotalSeconds));
public Angle PredictedPanelRotation => _lastState.Rotation + _lastState.AngularVelocity * (_gameTiming.CurTime - _lastStateTime).TotalSeconds;
protected override void Draw(DrawingHandleScreen handle)
{
@@ -137,7 +139,7 @@ namespace Content.Client.Power
for (var i = 0; i < gridLinesRadial; i++)
{
Angle angle = (Math.PI / gridLinesRadial) * i;
Angle angle = Math.PI / gridLinesRadial * i;
var aExtent = angle.ToVec() * RadiusCircle;
handle.DrawLine(new Vector2(point, point) - aExtent, new Vector2(point, point) + aExtent, gridLines);
}
@@ -162,6 +164,8 @@ namespace Content.Client.Power
[UsedImplicitly]
public sealed class SolarControlConsoleBoundUserInterface : ComputerBoundUserInterface<SolarControlWindow, SolarControlConsoleBoundInterfaceState>
{
public SolarControlConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) {}
public SolarControlConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
}
}

View File

@@ -6,11 +6,11 @@ namespace Content.Client.Research.UI
{
public sealed class DiskConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private DiskConsoleMenu? _menu;
public DiskConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public DiskConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()

View File

@@ -5,9 +5,10 @@ namespace Content.Client.Research.UI
{
public sealed class ResearchClientBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private ResearchClientServerSelectionMenu? _menu;
public ResearchClientBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public ResearchClientBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
SendMessage(new ResearchClientSyncMessage());
}

View File

@@ -7,20 +7,18 @@ namespace Content.Client.Research.UI;
[UsedImplicitly]
public sealed class ResearchConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private ResearchConsoleMenu? _consoleMenu;
public ResearchConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public ResearchConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
var owner = Owner.Owner;
var owner = Owner;
_consoleMenu = new ResearchConsoleMenu(owner);

View File

@@ -1,4 +1,3 @@
using Content.Shared.Salvage;
using Content.Shared.Salvage.Expeditions;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
@@ -8,9 +7,10 @@ namespace Content.Client.Salvage.UI;
[UsedImplicitly]
public sealed class SalvageExpeditionConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private SalvageExpeditionWindow? _window;
public SalvageExpeditionConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public SalvageExpeditionConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

View File

@@ -2,12 +2,13 @@ using Content.Client.Computer;
using Content.Client.Shuttles.UI;
using Content.Shared.Shuttles.BUIStates;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
namespace Content.Client.Shuttles.BUI;
[UsedImplicitly]
public sealed class EmergencyConsoleBoundUserInterface : ComputerBoundUserInterface<EmergencyConsoleWindow, EmergencyConsoleBoundUserInterfaceState>
{
public EmergencyConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) {}
public EmergencyConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
}

View File

@@ -9,16 +9,17 @@ namespace Content.Client.Shuttles.BUI;
[UsedImplicitly]
public sealed class IFFConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private IFFConsoleWindow? _window;
public IFFConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public IFFConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = new IFFConsoleWindow();
_window.OnClose += Close;
_window.ShowIFF += SendIFFMessage;

View File

@@ -8,13 +8,17 @@ namespace Content.Client.Shuttles.BUI;
[UsedImplicitly]
public sealed class RadarConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private RadarConsoleWindow? _window;
public RadarConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) {}
public RadarConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = new RadarConsoleWindow();
_window.OnClose += Close;
_window.OpenCentered();

View File

@@ -1,6 +1,5 @@
using Content.Client.Shuttles.UI;
using Content.Shared.Shuttles.BUIStates;
using Content.Shared.Shuttles.Components;
using Content.Shared.Shuttles.Events;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
@@ -10,9 +9,12 @@ namespace Content.Client.Shuttles.BUI;
[UsedImplicitly]
public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private ShuttleConsoleWindow? _window;
public ShuttleConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) {}
public ShuttleConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
@@ -51,17 +53,17 @@ public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface
private void OnStopAutodockPressed(EntityUid obj)
{
SendMessage(new StopAutodockRequestMessage() {DockEntity = obj});
SendMessage(new StopAutodockRequestMessage() { DockEntity = obj });
}
private void OnAutodockPressed(EntityUid obj)
{
SendMessage(new AutodockRequestMessage() {DockEntity = obj});
SendMessage(new AutodockRequestMessage() { DockEntity = obj });
}
private void OnUndockPressed(EntityUid obj)
{
SendMessage(new UndockRequestMessage() {DockEntity = obj});
SendMessage(new UndockRequestMessage() { DockEntity = obj });
}
protected override void UpdateState(BoundUserInterfaceState state)

View File

@@ -52,13 +52,13 @@ namespace Content.Client.Shuttles.Systems
return;
}
if (!TryComp<ShuttleConsoleComponent>(console, out var shuttleConsoleComponent))
if (!HasComp<ShuttleConsoleComponent>(console))
{
Logger.Warning($"Unable to set Helmsman console to {console}");
Log.Warning($"Unable to set Helmsman console to {console}");
return;
}
component.Console = shuttleConsoleComponent;
component.Console = console;
ActionBlockerSystem.UpdateCanMove(uid);
_input.Contexts.SetActiveContext("shuttle");
}

View File

@@ -5,10 +5,12 @@ namespace Content.Client.StationRecords;
public sealed class GeneralStationRecordConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private GeneralStationRecordConsoleWindow? _window = default!;
public GeneralStationRecordConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
{}
public GeneralStationRecordConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{

View File

@@ -1,7 +1,6 @@
using Content.Client.Examine;
using Content.Client.Storage.UI;
using Content.Client.UserInterface.Controls;
using Content.Client.Verbs;
using Content.Client.Verbs.UI;
using Content.Shared.Input;
using Content.Shared.Interaction;
@@ -17,9 +16,10 @@ namespace Content.Client.Storage
[UsedImplicitly]
public sealed class StorageBoundUserInterface : BoundUserInterface
{
[ViewVariables] private StorageWindow? _window;
[ViewVariables]
private StorageWindow? _window;
public StorageBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public StorageBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -29,9 +29,10 @@ namespace Content.Client.Storage
if (_window == null)
{
var entMan = IoCManager.Resolve<IEntityManager>();
_window = new StorageWindow(entMan)
{Title = entMan.GetComponent<MetaDataComponent>(Owner.Owner).EntityName};
_window = new StorageWindow(EntMan)
{
Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName
};
_window.EntityList.GenerateItem += _window.GenerateButton;
_window.EntityList.ItemPressed += InteractWithItem;
@@ -48,14 +49,14 @@ namespace Content.Client.Storage
public void InteractWithItem(BaseButton.ButtonEventArgs args, ListData cData)
{
if (cData is not EntityListData {Uid: var entity})
if (cData is not EntityListData { Uid: var entity })
return;
if (args.Event.Function == EngineKeyFunctions.UIClick)
{
SendMessage(new StorageInteractWithItemEvent(entity));
}
else if (IoCManager.Resolve<IEntityManager>().EntityExists(entity))
else if (EntMan.EntityExists(entity))
{
OnButtonPressed(args.Event, entity);
}
@@ -63,12 +64,9 @@ namespace Content.Client.Storage
private void OnButtonPressed(GUIBoundKeyEventArgs args, EntityUid entity)
{
var entitySys = IoCManager.Resolve<IEntitySystemManager>();
var entities = IoCManager.Resolve<IEntityManager>();
if (args.Function == ContentKeyFunctions.ExamineEntity)
{
entitySys.GetEntitySystem<ExamineSystem>()
EntMan.System<ExamineSystem>()
.DoExamine(entity);
}
else if (args.Function == EngineKeyFunctions.UseSecondary)
@@ -77,12 +75,12 @@ namespace Content.Client.Storage
}
else if (args.Function == ContentKeyFunctions.ActivateItemInWorld)
{
entities.EntityNetManager?.SendSystemNetworkMessage(
EntMan.EntityNetManager?.SendSystemNetworkMessage(
new InteractInventorySlotEvent(entity, altInteract: false));
}
else if (args.Function == ContentKeyFunctions.AltActivateItemInWorld)
{
entities.RaisePredictiveEvent(new InteractInventorySlotEvent(entity, altInteract: true));
EntMan.RaisePredictiveEvent(new InteractInventorySlotEvent(entity, altInteract: true));
}
else
{

View File

@@ -8,13 +8,14 @@ namespace Content.Client.Store.Ui;
[UsedImplicitly]
public sealed class StoreBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private StoreMenu? _menu;
[ViewVariables]
private string _windowName = Loc.GetString("store-ui-default-title");
public StoreBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public StoreBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()

View File

@@ -36,7 +36,7 @@ public sealed class StrippableSystem : SharedStrippableSystem
if (!TryComp(uid, out ClientUserInterfaceComponent? uiComp))
return;
foreach (var ui in uiComp.Interfaces)
foreach (var ui in uiComp.OpenInterfaces.Values)
{
if (ui is StrippableBoundUserInterface stripUi)
stripUi.DirtyMenu();

View File

@@ -6,18 +6,19 @@ namespace Content.Client.SurveillanceCamera.UI;
public sealed class SurveillanceCameraMonitorBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IEntityManager _entityManager = default!;
private readonly EyeLerpingSystem _eyeLerpingSystem;
private readonly SurveillanceCameraMonitorSystem _surveillanceCameraMonitorSystem;
[ViewVariables]
private SurveillanceCameraMonitorWindow? _window;
[ViewVariables]
private EntityUid? _currentCamera;
public SurveillanceCameraMonitorBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public SurveillanceCameraMonitorBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
_eyeLerpingSystem = _entityManager.EntitySysManager.GetEntitySystem<EyeLerpingSystem>();
_surveillanceCameraMonitorSystem = _entityManager.EntitySysManager.GetEntitySystem<SurveillanceCameraMonitorSystem>();
_eyeLerpingSystem = EntMan.System<EyeLerpingSystem>();
_surveillanceCameraMonitorSystem = EntMan.System<SurveillanceCameraMonitorSystem>();
}
protected override void Open()
@@ -54,7 +55,7 @@ public sealed class SurveillanceCameraMonitorBoundUserInterface : BoundUserInter
private void OnCameraSwitchTimer()
{
_surveillanceCameraMonitorSystem.AddTimer(Owner.Owner, _window!.OnSwitchTimerComplete);
_surveillanceCameraMonitorSystem.AddTimer(Owner, _window!.OnSwitchTimerComplete);
}
private void OnCameraRefresh()
@@ -85,7 +86,7 @@ public sealed class SurveillanceCameraMonitorBoundUserInterface : BoundUserInter
if (_currentCamera != null)
{
_surveillanceCameraMonitorSystem.RemoveTimer(Owner.Owner);
_surveillanceCameraMonitorSystem.RemoveTimer(Owner);
_eyeLerpingSystem.RemoveEye(_currentCamera.Value);
_currentCamera = null;
}
@@ -104,7 +105,7 @@ public sealed class SurveillanceCameraMonitorBoundUserInterface : BoundUserInter
_currentCamera = cast.ActiveCamera;
}
if (_entityManager.TryGetComponent(cast.ActiveCamera, out EyeComponent? eye))
if (EntMan.TryGetComponent<EyeComponent>(cast.ActiveCamera, out var eye))
{
_window.UpdateState(eye.Eye, cast.Subnets, cast.ActiveAddress, cast.ActiveSubnet, cast.Cameras);
}

View File

@@ -5,15 +5,16 @@ namespace Content.Client.SurveillanceCamera.UI;
public sealed class SurveillanceCameraSetupBoundUi : BoundUserInterface
{
private SurveillanceCameraSetupWindow? _window;
private SurveillanceCameraSetupUiKey _type;
[ViewVariables]
private readonly SurveillanceCameraSetupUiKey _type;
public SurveillanceCameraSetupBoundUi(ClientUserInterfaceComponent component, Enum uiKey) : base(component, uiKey)
[ViewVariables]
private SurveillanceCameraSetupWindow? _window;
public SurveillanceCameraSetupBoundUi(EntityUid component, Enum uiKey) : base(component, uiKey)
{
if (uiKey is not SurveillanceCameraSetupUiKey key)
{
return;
}
_type = key;
}

View File

@@ -5,19 +5,21 @@ using Robust.Client.GameObjects;
namespace Content.Client.UserInterface.Systems.Atmos.GasTank
{
[UsedImplicitly]
public sealed class GasTankBoundUserInterface
: BoundUserInterface
public sealed class GasTankBoundUserInterface : BoundUserInterface
{
public GasTankBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) :
base(owner, uiKey)
[ViewVariables]
private GasTankWindow? _window;
public GasTankBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
private GasTankWindow? _window;
public void SetOutputPressure(in float value)
{
SendMessage(new GasTankSetPressureMessage {Pressure = value});
SendMessage(new GasTankSetPressureMessage
{
Pressure = value
});
}
public void ToggleInternals()

View File

@@ -11,9 +11,10 @@ namespace Content.Client.VendingMachines
[ViewVariables]
private VendingMachineMenu? _menu;
[ViewVariables]
private List<VendingMachineInventoryEntry> _cachedInventory = new();
public VendingMachineBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public VendingMachineBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -21,12 +22,11 @@ namespace Content.Client.VendingMachines
{
base.Open();
var entMan = IoCManager.Resolve<IEntityManager>();
var vendingMachineSys = entMan.System<VendingMachineSystem>();
var vendingMachineSys = EntMan.System<VendingMachineSystem>();
_cachedInventory = vendingMachineSys.GetAllInventory(Owner.Owner);
_cachedInventory = vendingMachineSys.GetAllInventory(Owner);
_menu = new VendingMachineMenu {Title = entMan.GetComponent<MetaDataComponent>(Owner.Owner).EntityName};
_menu = new VendingMachineMenu { Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName };
_menu.OnClose += Close;
_menu.OnItemSelected += OnItemSelected;

View File

@@ -5,12 +5,13 @@ namespace Content.Client.VoiceMask;
public sealed class VoiceMaskBoundUserInterface : BoundUserInterface
{
public VoiceMaskBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
[ViewVariables]
private VoiceMaskNameChangeWindow? _window;
public VoiceMaskBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
private VoiceMaskNameChangeWindow? _window;
protected override void Open()
{
base.Open();

View File

@@ -8,9 +8,10 @@ namespace Content.Client.Weapons.Melee.UI;
/// </summary>
public sealed class MeleeSpeechBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private MeleeSpeechWindow? _window;
public MeleeSpeechBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public MeleeSpeechBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -50,7 +51,9 @@ public sealed class MeleeSpeechBoundUserInterface : BoundUserInterface
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing) return;
if (!disposing)
return;
_window?.Dispose();
}
}

View File

@@ -1,14 +1,14 @@
using Content.Shared.Wires;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.Wires.UI
{
public sealed class WiresBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private WiresMenu? _menu;
public WiresBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public WiresBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

View File

@@ -7,11 +7,11 @@ namespace Content.Client.Xenoarchaeology.Ui;
[UsedImplicitly]
public sealed class AnalysisConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private AnalysisConsoleMenu? _consoleMenu;
public AnalysisConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public AnalysisConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()

View File

@@ -753,22 +753,26 @@ public abstract partial class InteractionTest
return false;
}
if (!CEntMan.TryGetComponent(target, out ClientUserInterfaceComponent? ui))
if (!CEntMan.TryGetComponent<ClientUserInterfaceComponent>(target, out var ui))
{
if (shouldSucceed)
Assert.Fail($"Entity {SEntMan.ToPrettyString(target.Value)} does not have a bui component");
return false;
}
bui = ui.Interfaces.FirstOrDefault(x => x.UiKey.Equals(key));
if (bui == null)
if (!ui.OpenInterfaces.TryGetValue(key, out bui))
{
if (shouldSucceed)
Assert.Fail($"Entity {SEntMan.ToPrettyString(target.Value)} does not have an open bui with key {key.GetType()}.{key}.");
return false;
}
var bui2 = bui;
Assert.Multiple(() =>
{
Assert.That(bui2.UiKey, Is.EqualTo(key), $"Bound user interface {bui2} is indexed by a key other than the one assigned to it somehow. {bui2.UiKey} != {key}");
Assert.That(shouldSucceed, Is.True);
});
return true;
}

View File

@@ -21,7 +21,7 @@ namespace Content.Server.Access.Systems
// BUI
SubscribeLocalEvent<AgentIDCardComponent, AfterActivatableUIOpenEvent>(AfterUIOpen);
SubscribeLocalEvent<AgentIDCardComponent, AgentIDCardNameChangedMessage>(OnNameChanged);
SubscribeLocalEvent<AgentIDCardComponent, AgentIDCardJobChangedMessage> (OnJobChanged);
SubscribeLocalEvent<AgentIDCardComponent, AgentIDCardJobChangedMessage>(OnJobChanged);
}
private void OnAfterInteract(EntityUid uid, AgentIDCardComponent component, AfterInteractEvent args)
@@ -55,14 +55,14 @@ namespace Content.Server.Access.Systems
private void AfterUIOpen(EntityUid uid, AgentIDCardComponent component, AfterActivatableUIOpenEvent args)
{
if (!_uiSystem.TryGetUi(component.Owner, AgentIDCardUiKey.Key, out var ui))
if (!_uiSystem.TryGetUi(uid, AgentIDCardUiKey.Key, out var ui))
return;
if (!TryComp<IdCardComponent>(uid, out var idCard))
return;
var state = new AgentIDCardBoundUserInterfaceState(idCard.FullName ?? "", idCard.JobTitle ?? "");
ui.SetState(state, args.Session);
UserInterfaceSystem.SetUiState(ui, state, args.Session);
}
private void OnJobChanged(EntityUid uid, AgentIDCardComponent comp, AgentIDCardJobChangedMessage args)

View File

@@ -57,7 +57,9 @@ namespace Content.Server.AirlockPainter
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;
DirtyUI(uid, component);
component.Owner.GetUIOrNull(AirlockPainterUiKey.Key)?.Open(actor.PlayerSession);
if (_userInterfaceSystem.TryGetUi(uid, AirlockPainterUiKey.Key, out var bui))
_userInterfaceSystem.OpenUi(bui, actor.PlayerSession);
args.Handled = true;
}

View File

@@ -16,8 +16,8 @@ namespace Content.Server.Alert.Click
{
var entManager = IoCManager.Resolve<IEntityManager>();
if (entManager.TryGetComponent(player, out PilotComponent? pilotComponent) &&
pilotComponent.Console != null)
if (entManager.TryGetComponent(player, out PilotComponent? pilotComponent)
&& pilotComponent.Console != null)
{
entManager.System<ShuttleConsoleSystem>().RemovePilot(player, pilotComponent);
}

View File

@@ -94,7 +94,7 @@ public sealed class AmeControllerSystem : EntitySystem
return;
var state = GetUiState(uid, controller);
_userInterfaceSystem.SetUiState(bui, state);
UserInterfaceSystem.SetUiState(bui, state);
}
private AmeControllerBoundUserInterfaceState GetUiState(EntityUid uid, AmeControllerComponent controller)

View File

@@ -1,12 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using Content.Server.Access.Systems;
using Content.Server.Cargo.Components;
using Content.Server.Labels.Components;
using Content.Server.DeviceLinking.Systems;
using Content.Server.Popups;
using Content.Server.Station.Systems;
using Content.Shared.Access.Systems;
using Content.Shared.Administration.Logs;
using Content.Shared.Cargo;
using Content.Shared.Cargo.BUI;
using Content.Shared.Cargo.Events;
@@ -14,7 +8,6 @@ using Content.Shared.Cargo.Prototypes;
using Content.Shared.Database;
using Content.Shared.GameTicking;
using Content.Server.Paper;
using Content.Shared.Access.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Players;
@@ -49,7 +42,7 @@ namespace Content.Server.Cargo.Systems
private void OnInit(EntityUid uid, CargoOrderConsoleComponent orderConsole, ComponentInit args)
{
var station = _station.GetOwningStation(uid);
UpdateOrderState(orderConsole, station);
UpdateOrderState(uid, station);
}
private void Reset(RoundRestartCleanupEvent ev)
@@ -77,12 +70,13 @@ namespace Content.Server.Cargo.Systems
account.Balance += account.IncreasePerSecond * Delay;
}
foreach (var comp in EntityQuery<CargoOrderConsoleComponent>())
var query = EntityQueryEnumerator<CargoOrderConsoleComponent>();
while (query.MoveNext(out var uid, out var _))
{
if (!_uiSystem.IsUiOpen(comp.Owner, CargoConsoleUiKey.Orders)) continue;
if (!_uiSystem.IsUiOpen(uid, CargoConsoleUiKey.Orders)) continue;
var station = _station.GetOwningStation(comp.Owner);
UpdateOrderState(comp, station);
var station = _station.GetOwningStation(uid);
UpdateOrderState(uid, station);
}
}
}
@@ -91,7 +85,7 @@ namespace Content.Server.Cargo.Systems
private void OnApproveOrderMessage(EntityUid uid, CargoOrderConsoleComponent component, CargoConsoleApproveOrderMessage args)
{
if (args.Session.AttachedEntity is not {Valid: true} player)
if (args.Session.AttachedEntity is not { Valid: true } player)
return;
if (!_accessReaderSystem.IsAllowed(player, uid))
@@ -101,11 +95,10 @@ namespace Content.Server.Cargo.Systems
return;
}
var orderDatabase = GetOrderDatabase(component);
var bankAccount = GetBankAccount(component);
var bankAccount = GetBankAccount(uid, component);
// No station to deduct from.
if (orderDatabase == null || bankAccount == null)
if (!TryGetOrderDatabase(uid, out var dbUid, out var orderDatabase, component) || bankAccount == null)
{
ConsolePopup(args.Session, Loc.GetString("cargo-console-station-not-found"));
PlayDenySound(uid, component);
@@ -113,8 +106,8 @@ namespace Content.Server.Cargo.Systems
}
// Find our order again. It might have been dispatched or approved already
var order = orderDatabase.Orders.Find(order => (args.OrderId == order.OrderId) && !order.Approved);
if(order == null)
var order = orderDatabase.Orders.Find(order => args.OrderId == order.OrderId && !order.Approved);
if (order == null)
{
return;
}
@@ -167,30 +160,30 @@ namespace Content.Server.Cargo.Systems
$"{ToPrettyString(player):user} approved order [orderId:{order.OrderId}, quantity:{order.OrderQuantity}, product:{order.ProductId}, requester:{order.Requester}, reason:{order.Reason}] with balance at {bankAccount.Balance}");
DeductFunds(bankAccount, cost);
UpdateOrders(orderDatabase);
UpdateOrders(dbUid!.Value, orderDatabase);
}
private void OnRemoveOrderMessage(EntityUid uid, CargoOrderConsoleComponent component, CargoConsoleRemoveOrderMessage args)
{
var orderDatabase = GetOrderDatabase(component);
if (orderDatabase == null) return;
RemoveOrder(orderDatabase, args.OrderId);
if (!TryGetOrderDatabase(uid, out var dbUid, out var orderDatabase, component))
return;
RemoveOrder(dbUid!.Value, args.OrderId, orderDatabase);
}
private void OnAddOrderMessage(EntityUid uid, CargoOrderConsoleComponent component, CargoConsoleAddOrderMessage args)
{
if (args.Session.AttachedEntity is not {Valid: true} player)
if (args.Session.AttachedEntity is not { Valid: true } player)
return;
if (args.Amount <= 0)
return;
var bank = GetBankAccount(component);
var bank = GetBankAccount(uid, component);
if (bank == null)
return;
var orderDatabase = GetOrderDatabase(component);
if (orderDatabase == null)
if (!TryGetOrderDatabase(uid, out var dbUid, out var orderDatabase, component))
return;
if (!_protoMan.TryIndex<CargoProductPrototype>(args.CargoProductId, out var product))
@@ -201,7 +194,7 @@ namespace Content.Server.Cargo.Systems
var data = GetOrderData(args, product, GenerateOrderId(orderDatabase));
if (!TryAddOrder(orderDatabase, data))
if (!TryAddOrder(dbUid!.Value, data, orderDatabase))
{
PlayDenySound(uid, component);
return;
@@ -216,46 +209,50 @@ namespace Content.Server.Cargo.Systems
private void OnOrderUIOpened(EntityUid uid, CargoOrderConsoleComponent component, BoundUIOpenedEvent args)
{
var station = _station.GetOwningStation(uid);
UpdateOrderState(component, station);
UpdateOrderState(uid, station);
}
#endregion
private void UpdateOrderState(CargoOrderConsoleComponent component, EntityUid? station)
private void UpdateOrderState(EntityUid consoleUid, EntityUid? station)
{
if (station == null ||
!TryComp<StationCargoOrderDatabaseComponent>(station, out var orderDatabase) ||
!TryComp<StationBankAccountComponent>(station, out var bankAccount)) return;
var state = new CargoConsoleInterfaceState(
if (_uiSystem.TryGetUi(consoleUid, CargoConsoleUiKey.Orders, out var bui))
UserInterfaceSystem.SetUiState(bui, new CargoConsoleInterfaceState(
MetaData(station.Value).EntityName,
GetOutstandingOrderCount(orderDatabase),
orderDatabase.Capacity,
bankAccount.Balance,
orderDatabase.Orders);
_uiSystem.GetUiOrNull(component.Owner, CargoConsoleUiKey.Orders)?.SetState(state);
orderDatabase.Orders
));
}
private void ConsolePopup(ICommonSession session, string text) => _popup.PopupCursor(text, session);
private void ConsolePopup(ICommonSession session, string text)
{
_popup.PopupCursor(text, session);
}
private void PlayDenySound(EntityUid uid, CargoOrderConsoleComponent component)
{
_audio.PlayPvs(_audio.GetSound(component.ErrorSound), uid);
}
private CargoOrderData GetOrderData(CargoConsoleAddOrderMessage args, CargoProductPrototype cargoProduct, int id)
private static CargoOrderData GetOrderData(CargoConsoleAddOrderMessage args, CargoProductPrototype cargoProduct, int id)
{
return new CargoOrderData(id, cargoProduct.Product, cargoProduct.PointCost, args.Amount, args.Requester, args.Reason);
}
public int GetOutstandingOrderCount(StationCargoOrderDatabaseComponent component)
public static int GetOutstandingOrderCount(StationCargoOrderDatabaseComponent component)
{
var amount = 0;
foreach (var order in component.Orders)
{
if (!order.Approved) continue;
if (!order.Approved)
continue;
amount += order.OrderQuantity - order.NumDispatched;
}
@@ -266,32 +263,41 @@ namespace Content.Server.Cargo.Systems
/// Updates all of the cargo-related consoles for a particular station.
/// This should be called whenever orders change.
/// </summary>
private void UpdateOrders(StationCargoOrderDatabaseComponent component)
private void UpdateOrders(EntityUid dbUid, StationCargoOrderDatabaseComponent _)
{
// Order added so all consoles need updating.
var orderQuery = AllEntityQuery<CargoOrderConsoleComponent>();
while (orderQuery.MoveNext(out var uid, out var comp))
while (orderQuery.MoveNext(out var uid, out var _))
{
var station = _station.GetOwningStation(uid);
if (station != component.Owner)
if (station != dbUid)
continue;
UpdateOrderState(comp, station);
UpdateOrderState(uid, station);
}
var consoleQuery = AllEntityQuery<CargoShuttleConsoleComponent>();
while (consoleQuery.MoveNext(out var uid, out var comp))
while (consoleQuery.MoveNext(out var uid, out var _))
{
var station = _station.GetOwningStation(uid);
if (station != component.Owner)
if (station != dbUid)
continue;
UpdateShuttleState(uid, station);
}
}
public bool AddAndApproveOrder(StationCargoOrderDatabaseComponent component, string spawnId, int cost, int qty, string sender, string description, string dest)
public bool AddAndApproveOrder(
EntityUid dbUid,
string spawnId,
int cost,
int qty,
string sender,
string description,
string dest,
StationCargoOrderDatabaseComponent component
)
{
DebugTools.Assert(_protoMan.HasIndex<EntityPrototype>(spawnId));
// Make an order
@@ -306,31 +312,31 @@ namespace Content.Server.Cargo.Systems
$"AddAndApproveOrder {description} added order [orderId:{order.OrderId}, quantity:{order.OrderQuantity}, product:{order.ProductId}, requester:{order.Requester}, reason:{order.Reason}]");
// Add it to the list
return TryAddOrder(component, order);
return TryAddOrder(dbUid, order, component);
}
private bool TryAddOrder(StationCargoOrderDatabaseComponent component, CargoOrderData data)
private bool TryAddOrder(EntityUid dbUid, CargoOrderData data, StationCargoOrderDatabaseComponent component)
{
component.Orders.Add(data);
UpdateOrders(component);
UpdateOrders(dbUid, component);
return true;
}
private int GenerateOrderId(StationCargoOrderDatabaseComponent orderDB)
private static int GenerateOrderId(StationCargoOrderDatabaseComponent orderDB)
{
// We need an arbitrary unique ID to identify orders, since they may
// want to be cancelled later.
return ++orderDB.NumOrdersCreated;
}
public void RemoveOrder(StationCargoOrderDatabaseComponent orderDB, int index)
public void RemoveOrder(EntityUid dbUid, int index, StationCargoOrderDatabaseComponent orderDB)
{
var sequenceIdx = orderDB.Orders.FindIndex(order => order.OrderId == index);
if (sequenceIdx != -1)
{
orderDB.Orders.RemoveAt(sequenceIdx);
}
UpdateOrders(orderDB);
UpdateOrders(dbUid, orderDB);
}
public void ClearOrders(StationCargoOrderDatabaseComponent component)
@@ -341,7 +347,7 @@ namespace Content.Server.Cargo.Systems
Dirty(component);
}
private bool PopFrontOrder(StationCargoOrderDatabaseComponent orderDB, [NotNullWhen(true)] out CargoOrderData? orderOut)
private static bool PopFrontOrder(StationCargoOrderDatabaseComponent orderDB, [NotNullWhen(true)] out CargoOrderData? orderOut)
{
var orderIdx = orderDB.Orders.FindIndex(order => order.Approved);
if (orderIdx == -1)
@@ -353,7 +359,7 @@ namespace Content.Server.Cargo.Systems
orderOut = orderDB.Orders[orderIdx];
orderOut.NumDispatched++;
if(orderOut.NumDispatched >= orderOut.OrderQuantity)
if (orderOut.NumDispatched >= orderOut.OrderQuantity)
{
// Order is complete. Remove from the queue.
orderDB.Orders.RemoveAt(orderIdx);
@@ -375,7 +381,7 @@ namespace Content.Server.Cargo.Systems
{
// fill in the order data
var val = Loc.GetString("cargo-console-paper-print-name", ("orderNumber", order.OrderId));
MetaData(printed).EntityName = val;
_metaSystem.SetEntityName(printed, val);
_paperSystem.SetContent(printed, Loc.GetString(
"cargo-console-paper-print-text",
@@ -407,20 +413,18 @@ namespace Content.Server.Cargo.Systems
#region Station
private StationBankAccountComponent? GetBankAccount(CargoOrderConsoleComponent component)
private StationBankAccountComponent? GetBankAccount(EntityUid uid, CargoOrderConsoleComponent _)
{
var station = _station.GetOwningStation(component.Owner);
var station = _station.GetOwningStation(uid);
TryComp<StationBankAccountComponent>(station, out var bankComponent);
return bankComponent;
}
private StationCargoOrderDatabaseComponent? GetOrderDatabase(CargoOrderConsoleComponent component)
private bool TryGetOrderDatabase(EntityUid uid, [MaybeNullWhen(false)] out EntityUid? dbUid, [MaybeNullWhen(false)] out StationCargoOrderDatabaseComponent dbComp, CargoOrderConsoleComponent _)
{
var station = _station.GetOwningStation(component.Owner);
TryComp<StationCargoOrderDatabaseComponent>(station, out var orderComponent);
return orderComponent;
dbUid = _station.GetOwningStation(uid);
return TryComp(dbUid, out dbComp);
}
#endregion

View File

@@ -2,8 +2,6 @@ using System.Linq;
using Content.Server.Cargo.Components;
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Events;
using Content.Server.Shuttles.Systems;
using Content.Server.Stack;
using Content.Shared.Stacks;
using Content.Shared.Cargo;
using Content.Shared.Cargo.BUI;
@@ -12,15 +10,13 @@ using Content.Shared.Cargo.Events;
using Content.Shared.CCVar;
using Content.Shared.GameTicking;
using Content.Shared.Whitelist;
using Robust.Shared.Configuration;
using Robust.Server.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using Robust.Shared.Prototypes;
using Content.Shared.Coordinates;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Robust.Shared.Containers;
namespace Content.Server.Cargo.Systems;
@@ -73,7 +69,7 @@ public sealed partial class CargoSystem
#region Console
private void UpdateCargoShuttleConsoles(EntityUid shuttleUid, CargoShuttleComponent component)
private void UpdateCargoShuttleConsoles(EntityUid shuttleUid, CargoShuttleComponent _)
{
// Update pilot consoles that are already open.
_console.RefreshDroneConsoles();
@@ -81,7 +77,7 @@ public sealed partial class CargoSystem
// Update order consoles.
var shuttleConsoleQuery = AllEntityQuery<CargoShuttleConsoleComponent>();
while (shuttleConsoleQuery.MoveNext(out var uid, out _))
while (shuttleConsoleQuery.MoveNext(out var uid, out var _))
{
var stationUid = _station.GetOwningStation(uid);
if (stationUid != shuttleUid)
@@ -96,12 +92,12 @@ public sealed partial class CargoSystem
var bui = _uiSystem.GetUi(uid, CargoPalletConsoleUiKey.Sale);
if (Transform(uid).GridUid is not EntityUid gridUid)
{
_uiSystem.SetUiState(bui,
UserInterfaceSystem.SetUiState(bui,
new CargoPalletConsoleInterfaceState(0, 0, false));
return;
}
GetPalletGoods(gridUid, out var toSell, out var amount);
_uiSystem.SetUiState(bui,
UserInterfaceSystem.SetUiState(bui,
new CargoPalletConsoleInterfaceState((int) amount, toSell.Count, true));
}
@@ -147,11 +143,12 @@ public sealed partial class CargoSystem
var orders = GetProjectedOrders(station ?? EntityUid.Invalid, orderDatabase, shuttle);
var shuttleName = orderDatabase?.Shuttle != null ? MetaData(orderDatabase.Shuttle.Value).EntityName : string.Empty;
_uiSystem.GetUiOrNull(uid, CargoConsoleUiKey.Shuttle)?.SetState(
new CargoShuttleConsoleBoundUserInterfaceState(
if (_uiSystem.TryGetUi(uid, CargoConsoleUiKey.Shuttle, out var bui))
UserInterfaceSystem.SetUiState(bui, new CargoShuttleConsoleBoundUserInterfaceState(
station != null ? MetaData(station.Value).EntityName : Loc.GetString("cargo-shuttle-console-station-unknown"),
string.IsNullOrEmpty(shuttleName) ? Loc.GetString("cargo-shuttle-console-shuttle-not-found") : shuttleName,
orders));
orders
));
}
#endregion
@@ -172,10 +169,10 @@ public sealed partial class CargoSystem
return orders;
var spaceRemaining = GetCargoSpace(shuttleUid);
for( var i = 0; i < component.Orders.Count && spaceRemaining > 0; i++)
for (var i = 0; i < component.Orders.Count && spaceRemaining > 0; i++)
{
var order = component.Orders[i];
if(order.Approved)
if (order.Approved)
{
var numToShip = order.OrderQuantity - order.NumDispatched;
if (numToShip > spaceRemaining)
@@ -311,7 +308,7 @@ public sealed partial class CargoSystem
while (pads.Count > 0)
{
var coordinates = new EntityCoordinates(shuttleUid, xformQuery.GetComponent(_random.PickAndTake(pads).Entity).LocalPosition);
if(!FulfillOrder(orderDatabase, coordinates, shuttle.PrinterOutput))
if (!FulfillOrder(orderDatabase, coordinates, shuttle.PrinterOutput))
{
break;
}
@@ -328,14 +325,14 @@ public sealed partial class CargoSystem
var bui = _uiSystem.GetUi(uid, CargoPalletConsoleUiKey.Sale);
if (Transform(uid).GridUid is not EntityUid gridUid)
{
_uiSystem.SetUiState(bui,
UserInterfaceSystem.SetUiState(bui,
new CargoPalletConsoleInterfaceState(0, 0, false));
return;
}
SellPallets(gridUid, null, out var price);
var stackPrototype = _protoMan.Index<StackPrototype>(component.CashType);
_stack.Spawn((int)price, stackPrototype, uid.ToCoordinates());
_stack.Spawn((int) price, stackPrototype, uid.ToCoordinates());
UpdatePalletConsoleInterface(uid);
}
@@ -352,7 +349,7 @@ public sealed partial class CargoSystem
}
AddCargoContents(uid, component, orderDatabase);
UpdateOrders(orderDatabase);
UpdateOrders(stationUid!.Value, orderDatabase);
UpdateCargoShuttleConsoles(uid, component);
}
@@ -397,7 +394,7 @@ public sealed partial class CargoSystem
// Shuttle may not have been in the cargo dimension (e.g. on the station map) so need to delete.
var query = AllEntityQuery<CargoShuttleComponent>();
while (query.MoveNext(out var uid, out var comp))
while (query.MoveNext(out var uid, out var _))
{
if (TryComp<StationCargoOrderDatabaseComponent>(uid, out var station))
{
@@ -427,7 +424,7 @@ public sealed partial class CargoSystem
}
};
MetaData(mapUid).EntityName = $"Trading post {_random.Next(1000):000}";
_metaSystem.SetEntityName(mapUid, $"Trading post {_random.Next(1000):000}");
_console.RefreshShuttleConsoles();
}

View File

@@ -65,10 +65,10 @@ public sealed partial class CargoSystem
}
var xform = Transform(uid);
if (FulfillOrder(orderDatabase, xform.Coordinates,comp.PrinterOutput))
if (FulfillOrder(orderDatabase, xform.Coordinates, comp.PrinterOutput))
{
_audio.PlayPvs(_audio.GetSound(comp.TeleportSound), uid, AudioParams.Default.WithVolume(-8f));
UpdateOrders(orderDatabase);
UpdateOrders(station!.Value, orderDatabase);
comp.CurrentState = CargoTelepadState.Teleporting;
_appearance.SetData(uid, CargoTelepadVisuals.State, CargoTelepadState.Teleporting, appearance);

View File

@@ -43,6 +43,7 @@ public sealed partial class CargoSystem : SharedCargoSystem
[Dependency] private readonly StackSystem _stack = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
private ISawmill _sawmill = default!;
@@ -76,7 +77,7 @@ public sealed partial class CargoSystem : SharedCargoSystem
component.Balance += balanceAdded;
var query = EntityQueryEnumerator<CargoOrderConsoleComponent>();
while (query.MoveNext(out var oUid, out var oComp))
while (query.MoveNext(out var oUid, out var _))
{
if (!_uiSystem.IsUiOpen(oUid, CargoConsoleUiKey.Orders))
continue;
@@ -85,7 +86,7 @@ public sealed partial class CargoSystem : SharedCargoSystem
if (station != uid)
continue;
UpdateOrderState(oComp, station);
UpdateOrderState(oUid, station);
}
}
}

View File

@@ -44,9 +44,8 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
state.ActiveUI = loader.ActiveProgram;
state.Programs = GetAvailablePrograms(loaderUid, loader);
var ui = _userInterfaceSystem.GetUiOrNull(loader.Owner, loader.UiKey);
if (ui != null)
_userInterfaceSystem.SetUiState(ui, state, session);
if (_userInterfaceSystem.TryGetUi(loaderUid, loader.UiKey, out var ui))
UserInterfaceSystem.SetUiState(ui, state, session);
}
/// <summary>
@@ -65,9 +64,8 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
if (!Resolve(loaderUid, ref loader))
return;
var ui = _userInterfaceSystem.GetUiOrNull(loader.Owner, loader.UiKey);
if (ui != null)
_userInterfaceSystem.SetUiState(ui, state, session);
if (_userInterfaceSystem.TryGetUi(loaderUid, loader.UiKey, out var ui))
UserInterfaceSystem.SetUiState(ui, state, session);
}
/// <summary>
@@ -306,7 +304,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
RaiseLocalEvent(component.ActiveProgram.Value, new CartridgeUiReadyEvent(loaderUid));
break;
default:
throw new ArgumentOutOfRangeException();
throw new ArgumentOutOfRangeException($"Unrecognized UI action passed from cartridge loader ui {message.Action}.");
}
}
@@ -379,7 +377,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
}
}
private bool ContainsCartridge(EntityUid cartridgeUid, CartridgeLoaderComponent loader , bool onlyInstalled = false)
private static bool ContainsCartridge(EntityUid cartridgeUid, CartridgeLoaderComponent loader, bool onlyInstalled = false)
{
return !onlyInstalled && loader.CartridgeSlot.Item?.Equals(cartridgeUid) == true || loader.InstalledPrograms.Contains(cartridgeUid);
}

View File

@@ -1,10 +1,8 @@
using System.Linq;
using JetBrains.Annotations;
using Robust.Shared.Timing;
using Content.Server.Administration.Logs;
using Content.Server.Medical.Components;
using Content.Server.Cloning.Components;
using Content.Server.DeviceLinking.Events;
using Content.Server.DeviceLinking.Systems;
using Content.Server.Power.Components;
using Content.Server.Mind.Components;
@@ -62,12 +60,12 @@ namespace Content.Server.Cloning
TryClone(uid, consoleComponent.CloningPod.Value, consoleComponent.GeneticScanner.Value, consoleComponent: consoleComponent);
break;
}
UpdateUserInterface(consoleComponent);
UpdateUserInterface(uid, consoleComponent);
}
private void OnPowerChanged(EntityUid uid, CloningConsoleComponent component, ref PowerChangedEvent args)
{
UpdateUserInterface(component);
UpdateUserInterface(uid, component);
}
private void OnMapInit(EntityUid uid, CloningConsoleComponent component, MapInitEvent args)
@@ -115,12 +113,12 @@ namespace Content.Server.Cloning
if (args.Port == CloningConsoleComponent.PodPort)
component.CloningPod = null;
UpdateUserInterface(component);
UpdateUserInterface(uid, component);
}
private void OnUIOpen(EntityUid uid, CloningConsoleComponent component, AfterActivatableUIOpenEvent args)
{
UpdateUserInterface(component);
UpdateUserInterface(uid, component);
}
private void OnAnchorChanged(EntityUid uid, CloningConsoleComponent component, ref AnchorStateChangedEvent args)
@@ -130,22 +128,22 @@ namespace Content.Server.Cloning
RecheckConnections(uid, component.CloningPod, component.GeneticScanner, component);
return;
}
UpdateUserInterface(component);
UpdateUserInterface(uid, component);
}
public void UpdateUserInterface(CloningConsoleComponent consoleComponent)
public void UpdateUserInterface(EntityUid consoleUid, CloningConsoleComponent consoleComponent)
{
var ui = _uiSystem.GetUiOrNull(consoleComponent.Owner, CloningConsoleUiKey.Key);
if (ui == null)
if (!_uiSystem.TryGetUi(consoleUid, CloningConsoleUiKey.Key, out var ui))
return;
if (!_powerReceiverSystem.IsPowered(consoleComponent.Owner))
if (!_powerReceiverSystem.IsPowered(consoleUid))
{
_uiSystem.CloseAll(ui);
return;
}
var newState = GetUserInterfaceState(consoleComponent);
_uiSystem.SetUiState(ui, newState);
UserInterfaceSystem.SetUiState(ui, newState);
}
public void TryClone(EntityUid uid, EntityUid cloningPodUid, EntityUid scannerUid, CloningPodComponent? cloningPod = null, MedicalScannerComponent? scannerComp = null, CloningConsoleComponent? consoleComponent = null)
@@ -192,7 +190,7 @@ namespace Content.Server.Cloning
consoleComp.CloningPodInRange = podDistance <= consoleComp.MaxDistance;
}
UpdateUserInterface(consoleComp);
UpdateUserInterface(console, consoleComp);
}
private CloningConsoleBoundUserInterfaceState GetUserInterfaceState(CloningConsoleComponent consoleComponent)
{

View File

@@ -33,7 +33,6 @@ using Robust.Shared.Random;
using Robust.Shared.Configuration;
using Robust.Shared.Containers;
using Robust.Shared.Physics.Components;
using Content.Shared.Humanoid;
using Content.Shared.Doors.Components;
using Content.Shared.Emag.Systems;
using Robust.Shared.Audio;
@@ -66,6 +65,7 @@ namespace Content.Server.Cloning
[Dependency] private readonly MaterialStorageSystem _material = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly MindSystem _mindSystem = default!;
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
public readonly Dictionary<Mind.Mind, EntityUid> ClonesWaitingForMind = new();
public const float EasyModeCloningCost = 0.7f;
@@ -87,7 +87,7 @@ namespace Content.Server.Cloning
private void OnComponentInit(EntityUid uid, CloningPodComponent clonePod, ComponentInit args)
{
clonePod.BodyContainer = _containerSystem.EnsureContainer<ContainerSlot>(clonePod.Owner, "clonepod-bodyContainer");
clonePod.BodyContainer = _containerSystem.EnsureContainer<ContainerSlot>(uid, "clonepod-bodyContainer");
_signalSystem.EnsureSinkPorts(uid, CloningPodComponent.PodPort);
}
@@ -124,12 +124,12 @@ namespace Content.Server.Cloning
if (clonedComponent.Parent == EntityUid.Invalid ||
!EntityManager.EntityExists(clonedComponent.Parent) ||
!TryComp<CloningPodComponent>(clonedComponent.Parent, out var cloningPodComponent) ||
clonedComponent.Owner != cloningPodComponent.BodyContainer.ContainedEntity)
uid != cloningPodComponent.BodyContainer.ContainedEntity)
{
EntityManager.RemoveComponent<BeingClonedComponent>(clonedComponent.Owner);
EntityManager.RemoveComponent<BeingClonedComponent>(uid);
return;
}
UpdateStatus(CloningPodStatus.Cloning, cloningPodComponent);
UpdateStatus(clonedComponent.Parent, CloningPodStatus.Cloning, cloningPodComponent);
}
private void OnPortDisconnected(EntityUid uid, CloningPodComponent pod, PortDisconnectedEvent args)
@@ -147,7 +147,7 @@ namespace Content.Server.Cloning
_cloningConsoleSystem.RecheckConnections(component.ConnectedConsole.Value, uid, console.GeneticScanner, console);
return;
}
_cloningConsoleSystem.UpdateUserInterface(console);
_cloningConsoleSystem.UpdateUserInterface(component.ConnectedConsole.Value, console);
}
private void OnExamined(EntityUid uid, CloningPodComponent component, ExaminedEvent args)
@@ -230,11 +230,11 @@ namespace Content.Server.Cloning
chance *= failChanceModifier;
if (cellularDmg > 0 && clonePod.ConnectedConsole != null)
_chatSystem.TrySendInGameICMessage(clonePod.ConnectedConsole.Value, Loc.GetString("cloning-console-cellular-warning", ("percent", Math.Round(100 - (chance * 100)))), InGameICChatType.Speak, false);
_chatSystem.TrySendInGameICMessage(clonePod.ConnectedConsole.Value, Loc.GetString("cloning-console-cellular-warning", ("percent", Math.Round(100 - chance * 100))), InGameICChatType.Speak, false);
if (_robustRandom.Prob(chance))
{
UpdateStatus(CloningPodStatus.Gore, clonePod);
UpdateStatus(uid, CloningPodStatus.Gore, clonePod);
clonePod.FailedClone = true;
AddComp<ActiveCloningPodComponent>(uid);
return true;
@@ -242,21 +242,21 @@ namespace Content.Server.Cloning
}
// end of genetic damage checks
var mob = Spawn(speciesPrototype.Prototype, Transform(clonePod.Owner).MapPosition);
var mob = Spawn(speciesPrototype.Prototype, Transform(uid).MapPosition);
_humanoidSystem.CloneAppearance(bodyToClone, mob);
var ev = new CloningEvent(bodyToClone, mob);
RaiseLocalEvent(bodyToClone, ref ev);
if (!ev.NameHandled)
MetaData(mob).EntityName = MetaData(bodyToClone).EntityName;
_metaSystem.SetEntityName(mob, MetaData(bodyToClone).EntityName);
var cloneMindReturn = EntityManager.AddComponent<BeingClonedComponent>(mob);
cloneMindReturn.Mind = mind;
cloneMindReturn.Parent = clonePod.Owner;
cloneMindReturn.Parent = uid;
clonePod.BodyContainer.Insert(mob);
ClonesWaitingForMind.Add(mind, mob);
UpdateStatus(CloningPodStatus.NoMind, clonePod);
UpdateStatus(uid, CloningPodStatus.NoMind, clonePod);
_euiManager.OpenEui(new AcceptCloningEui(mind, this), client);
AddComp<ActiveCloningPodComponent>(uid);
@@ -276,17 +276,18 @@ namespace Content.Server.Cloning
return true;
}
public void UpdateStatus(CloningPodStatus status, CloningPodComponent cloningPod)
public void UpdateStatus(EntityUid podUid, CloningPodStatus status, CloningPodComponent cloningPod)
{
cloningPod.Status = status;
_appearance.SetData(cloningPod.Owner, CloningPodVisuals.Status, cloningPod.Status);
_appearance.SetData(podUid, CloningPodVisuals.Status, cloningPod.Status);
}
public override void Update(float frameTime)
{
foreach (var (_, cloning) in EntityManager.EntityQuery<ActiveCloningPodComponent, CloningPodComponent>())
var query = EntityQueryEnumerator<ActiveCloningPodComponent, CloningPodComponent>();
while (query.MoveNext(out var uid, out var _, out var cloning))
{
if (!_powerReceiverSystem.IsPowered(cloning.Owner))
if (!_powerReceiverSystem.IsPowered(uid))
continue;
if (cloning.BodyContainer.ContainedEntity == null && !cloning.FailedClone)
@@ -297,9 +298,9 @@ namespace Content.Server.Cloning
continue;
if (cloning.FailedClone)
EndFailedCloning(cloning.Owner, cloning);
EndFailedCloning(uid, cloning);
else
Eject(cloning.Owner, cloning);
Eject(uid, cloning);
}
}
@@ -321,14 +322,14 @@ namespace Content.Server.Cloning
if (!Resolve(uid, ref clonePod))
return;
if (clonePod.BodyContainer.ContainedEntity is not {Valid: true} entity || clonePod.CloningProgress < clonePod.CloningTime)
if (clonePod.BodyContainer.ContainedEntity is not { Valid: true } entity || clonePod.CloningProgress < clonePod.CloningTime)
return;
EntityManager.RemoveComponent<BeingClonedComponent>(entity);
clonePod.BodyContainer.Remove(entity);
clonePod.CloningProgress = 0f;
clonePod.UsedBiomass = 0;
UpdateStatus(CloningPodStatus.Idle, clonePod);
UpdateStatus(uid, CloningPodStatus.Idle, clonePod);
RemCompDeferred<ActiveCloningPodComponent>(uid);
}
@@ -336,7 +337,7 @@ namespace Content.Server.Cloning
{
clonePod.FailedClone = false;
clonePod.CloningProgress = 0f;
UpdateStatus(CloningPodStatus.Idle, clonePod);
UpdateStatus(uid, CloningPodStatus.Idle, clonePod);
var transform = Transform(uid);
var indices = _transformSystem.GetGridOrMapTilePosition(uid);
@@ -350,7 +351,7 @@ namespace Content.Server.Cloning
Solution bloodSolution = new();
int i = 0;
var i = 0;
while (i < 1)
{
tileMix?.AdjustMoles(Gas.Miasma, 6f);
@@ -386,7 +387,8 @@ namespace Content.Server.Cloning
public readonly EntityUid Source;
public readonly EntityUid Target;
public CloningEvent(EntityUid source, EntityUid target) {
public CloningEvent(EntityUid source, EntityUid target)
{
Source = source;
Target = target;
}

View File

@@ -37,6 +37,7 @@ namespace Content.Server.Communications
[Dependency] private readonly StationSystem _stationSystem = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
private const int MaxMessageLength = 256;
private const int MaxMessageNewlines = 2;
@@ -46,7 +47,7 @@ namespace Content.Server.Communications
{
// All events that refresh the BUI
SubscribeLocalEvent<AlertLevelChangedEvent>(OnAlertLevelChanged);
SubscribeLocalEvent<CommunicationsConsoleComponent, ComponentInit>((_, comp, _) => UpdateCommsConsoleInterface(comp));
SubscribeLocalEvent<CommunicationsConsoleComponent, ComponentInit>((uid, comp, _) => UpdateCommsConsoleInterface(uid, comp));
SubscribeLocalEvent<RoundEndSystemChangedEvent>(_ => OnGenericBroadcastEvent());
SubscribeLocalEvent<AlertLevelDelayFinishedEvent>(_ => OnGenericBroadcastEvent());
@@ -59,7 +60,8 @@ namespace Content.Server.Communications
public override void Update(float frameTime)
{
foreach (var comp in EntityQuery<CommunicationsConsoleComponent>())
var query = EntityQueryEnumerator<CommunicationsConsoleComponent>();
while (query.MoveNext(out var uid, out var comp))
{
// TODO refresh the UI in a less horrible way
if (comp.AnnouncementCooldownRemaining >= 0f)
@@ -74,8 +76,8 @@ namespace Content.Server.Communications
comp.UIUpdateAccumulator -= UIUpdateInterval;
if (comp.UserInterface is {} ui && ui.SubscribedSessions.Count > 0)
UpdateCommsConsoleInterface(comp);
if (comp.UserInterface is { } ui && ui.SubscribedSessions.Count > 0)
UpdateCommsConsoleInterface(uid, comp);
}
base.Update(frameTime);
@@ -86,9 +88,10 @@ namespace Content.Server.Communications
/// </summary>
private void OnGenericBroadcastEvent()
{
foreach (var comp in EntityQuery<CommunicationsConsoleComponent>())
var query = EntityQueryEnumerator<CommunicationsConsoleComponent>();
while (query.MoveNext(out var uid, out var comp))
{
UpdateCommsConsoleInterface(comp);
UpdateCommsConsoleInterface(uid, comp);
}
}
@@ -98,13 +101,12 @@ namespace Content.Server.Communications
/// <param name="args">Alert level changed event arguments</param>
private void OnAlertLevelChanged(AlertLevelChangedEvent args)
{
foreach (var comp in EntityQuery<CommunicationsConsoleComponent>(true))
var query = EntityQueryEnumerator<CommunicationsConsoleComponent>();
while (query.MoveNext(out var uid, out var comp))
{
var entStation = _stationSystem.GetOwningStation(comp.Owner);
var entStation = _stationSystem.GetOwningStation(uid);
if (args.Station == entStation)
{
UpdateCommsConsoleInterface(comp);
}
UpdateCommsConsoleInterface(uid, comp);
}
}
@@ -113,9 +115,10 @@ namespace Content.Server.Communications
/// </summary>
public void UpdateCommsConsoleInterface()
{
foreach (var comp in EntityQuery<CommunicationsConsoleComponent>())
var query = EntityQueryEnumerator<CommunicationsConsoleComponent>();
while (query.MoveNext(out var uid, out var comp))
{
UpdateCommsConsoleInterface(comp);
UpdateCommsConsoleInterface(uid, comp);
}
}
@@ -123,10 +126,8 @@ namespace Content.Server.Communications
/// Updates the UI for a particular comms console.
/// </summary>
/// <param name="comp"></param>
public void UpdateCommsConsoleInterface(CommunicationsConsoleComponent comp)
public void UpdateCommsConsoleInterface(EntityUid uid, CommunicationsConsoleComponent comp)
{
var uid = comp.Owner;
var stationUid = _stationSystem.GetOwningStation(uid);
List<string>? levels = null;
string currentLevel = default!;
@@ -154,19 +155,18 @@ namespace Content.Server.Communications
}
}
comp.UserInterface?.SetState(
new CommunicationsConsoleInterfaceState(
if (comp.UserInterface is not null)
UserInterfaceSystem.SetUiState(comp.UserInterface, new CommunicationsConsoleInterfaceState(
CanAnnounce(comp),
CanCallOrRecall(comp),
levels,
currentLevel,
currentDelay,
_roundEndSystem.ExpectedCountdownEnd
)
);
));
}
private bool CanAnnounce(CommunicationsConsoleComponent comp)
private static bool CanAnnounce(CommunicationsConsoleComponent comp)
{
return comp.AnnouncementCooldownRemaining <= 0f;
}
@@ -207,7 +207,7 @@ namespace Content.Server.Communications
private void OnSelectAlertLevelMessage(EntityUid uid, CommunicationsConsoleComponent comp, CommunicationsConsoleSelectAlertLevelMessage message)
{
if (message.Session.AttachedEntity is not {Valid: true} mob) return;
if (message.Session.AttachedEntity is not { Valid: true } mob) return;
if (!CanUse(mob, uid))
{
_popupSystem.PopupCursor(Loc.GetString("comms-console-permission-denied"), message.Session, PopupType.Medium);
@@ -224,7 +224,8 @@ namespace Content.Server.Communications
private void OnAnnounceMessage(EntityUid uid, CommunicationsConsoleComponent comp,
CommunicationsConsoleAnnounceMessage message)
{
var msgChars = (message.Message.Length <= MaxMessageLength ? message.Message.Trim() : $"{message.Message.Trim().Substring(0, MaxMessageLength)}...").ToCharArray();
var msgWords = message.Message.Trim();
var msgChars = (msgWords.Length <= MaxMessageLength ? msgWords : $"{msgWords[0..MaxMessageLength]}...").ToCharArray();
var newlines = 0;
for (var i = 0; i < msgChars.Length; i++)
@@ -240,7 +241,7 @@ namespace Content.Server.Communications
var msg = new string(msgChars);
var author = Loc.GetString("comms-console-announcement-unknown-sender");
if (message.Session.AttachedEntity is {Valid: true} mob)
if (message.Session.AttachedEntity is { Valid: true } mob)
{
if (!CanAnnounce(comp))
{
@@ -260,7 +261,7 @@ namespace Content.Server.Communications
}
comp.AnnouncementCooldownRemaining = comp.DelayBetweenAnnouncements;
UpdateCommsConsoleInterface(comp);
UpdateCommsConsoleInterface(uid, comp);
// allow admemes with vv
Loc.TryGetString(comp.AnnouncementDisplayName, out var title);
@@ -285,7 +286,7 @@ namespace Content.Server.Communications
private void OnCallShuttleMessage(EntityUid uid, CommunicationsConsoleComponent comp, CommunicationsConsoleCallEmergencyShuttleMessage message)
{
if (!CanCallOrRecall(comp)) return;
if (message.Session.AttachedEntity is not {Valid: true} mob) return;
if (message.Session.AttachedEntity is not { Valid: true } mob) return;
if (!CanUse(mob, uid))
{
_popupSystem.PopupEntity(Loc.GetString("comms-console-permission-denied"), uid, message.Session);
@@ -298,7 +299,7 @@ namespace Content.Server.Communications
private void OnRecallShuttleMessage(EntityUid uid, CommunicationsConsoleComponent comp, CommunicationsConsoleRecallEmergencyShuttleMessage message)
{
if (!CanCallOrRecall(comp)) return;
if (message.Session.AttachedEntity is not {Valid: true} mob) return;
if (message.Session.AttachedEntity is not { Valid: true } mob) return;
if (!CanUse(mob, uid))
{
_popupSystem.PopupEntity(Loc.GetString("comms-console-permission-denied"), uid, message.Session);

View File

@@ -43,7 +43,7 @@ public sealed class ConfigurationSystem : EntitySystem
private void UpdateUi(EntityUid uid, ConfigurationComponent component)
{
if (_uiSystem.TryGetUi(uid, ConfigurationUiKey.Key, out var ui))
ui.SetState(new ConfigurationBoundUserInterfaceState(component.Config));
UserInterfaceSystem.SetUiState(ui, new ConfigurationBoundUserInterfaceState(component.Config));
}
private void OnUpdate(EntityUid uid, ConfigurationComponent component, ConfigurationUpdatedMessage args)

View File

@@ -4,7 +4,6 @@ using Content.Server.Administration.Logs;
using Content.Server.Decals;
using Content.Server.Nutrition.EntitySystems;
using Content.Server.Popups;
using Content.Shared.Audio;
using Content.Shared.Crayon;
using Content.Shared.Database;
using Content.Shared.Decals;
@@ -13,15 +12,15 @@ using Content.Shared.Interaction.Events;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Server.Crayon;
public sealed class CrayonSystem : SharedCrayonSystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly DecalSystem _decals = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
@@ -33,8 +32,8 @@ public sealed class CrayonSystem : SharedCrayonSystem
SubscribeLocalEvent<CrayonComponent, ComponentInit>(OnCrayonInit);
SubscribeLocalEvent<CrayonComponent, CrayonSelectMessage>(OnCrayonBoundUI);
SubscribeLocalEvent<CrayonComponent, CrayonColorMessage>(OnCrayonBoundUIColor);
SubscribeLocalEvent<CrayonComponent, UseInHandEvent>(OnCrayonUse, before: new []{ typeof(FoodSystem) });
SubscribeLocalEvent<CrayonComponent, AfterInteractEvent>(OnCrayonAfterInteract, after: new []{ typeof(FoodSystem) });
SubscribeLocalEvent<CrayonComponent, UseInHandEvent>(OnCrayonUse, before: new[] { typeof(FoodSystem) });
SubscribeLocalEvent<CrayonComponent, AfterInteractEvent>(OnCrayonAfterInteract, after: new[] { typeof(FoodSystem) });
SubscribeLocalEvent<CrayonComponent, DroppedEvent>(OnCrayonDropped);
SubscribeLocalEvent<CrayonComponent, ComponentGetState>(OnCrayonGetState);
}
@@ -67,11 +66,11 @@ public sealed class CrayonSystem : SharedCrayonSystem
return;
}
if(!_decals.TryAddDecal(component.SelectedState, args.ClickLocation.Offset(new Vector2(-0.5f,-0.5f)), out _, component.Color, cleanable: true))
if (!_decals.TryAddDecal(component.SelectedState, args.ClickLocation.Offset(new Vector2(-0.5f, -0.5f)), out _, component.Color, cleanable: true))
return;
if (component.UseSound != null)
_audio.PlayPvs(component.UseSound, uid, AudioHelpers.WithVariation(0.125f));
_audio.PlayPvs(component.UseSound, uid, AudioParams.Default.WithVariation(0.125f));
// Decrease "Ammo"
component.Charges--;
@@ -100,7 +99,7 @@ public sealed class CrayonSystem : SharedCrayonSystem
if (component.UserInterface?.SubscribedSessions.Contains(actor.PlayerSession) == true)
{
// Tell the user interface the selected stuff
_uiSystem.SetUiState(component.UserInterface, new CrayonBoundUserInterfaceState(component.SelectedState, component.SelectableColor, component.Color));
UserInterfaceSystem.SetUiState(component.UserInterface, new CrayonBoundUserInterfaceState(component.SelectedState, component.SelectableColor, component.Color));
}
args.Handled = true;

View File

@@ -1,5 +1,4 @@
using Content.Server.DeviceLinking.Components;
using Content.Server.Interaction;
using Content.Server.UserInterface;
using Content.Shared.Access.Systems;
using Content.Shared.MachineLinking;
@@ -17,7 +16,6 @@ public sealed class SignalTimerSystem : EntitySystem
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[Dependency] private readonly AccessReaderSystem _accessReader = default!;
[Dependency] private readonly InteractionSystem _interaction = default!;
public override void Initialize()
{
@@ -42,7 +40,7 @@ public sealed class SignalTimerSystem : EntitySystem
if (_ui.TryGetUi(uid, SignalTimerUiKey.Key, out var bui))
{
_ui.SetUiState(bui, new SignalTimerBoundUserInterfaceState(component.Label,
UserInterfaceSystem.SetUiState(bui, new SignalTimerBoundUserInterfaceState(component.Label,
TimeSpan.FromSeconds(component.Delay).Minutes.ToString("D2"),
TimeSpan.FromSeconds(component.Delay).Seconds.ToString("D2"),
component.CanEditLabel,
@@ -62,7 +60,7 @@ public sealed class SignalTimerSystem : EntitySystem
if (_ui.TryGetUi(uid, SignalTimerUiKey.Key, out var bui))
{
_ui.SetUiState(bui, new SignalTimerBoundUserInterfaceState(signalTimer.Label,
UserInterfaceSystem.SetUiState(bui, new SignalTimerBoundUserInterfaceState(signalTimer.Label,
TimeSpan.FromSeconds(signalTimer.Delay).Minutes.ToString("D2"),
TimeSpan.FromSeconds(signalTimer.Delay).Seconds.ToString("D2"),
signalTimer.CanEditLabel,
@@ -115,7 +113,7 @@ public sealed class SignalTimerSystem : EntitySystem
if (!IsMessageValid(uid, args))
return;
component.Label = args.Text[..Math.Min(5,args.Text.Length)];
component.Label = args.Text[..Math.Min(5, args.Text.Length)];
_appearanceSystem.SetData(uid, TextScreenVisuals.ScreenText, component.Label);
}

Some files were not shown because too many files have changed in this diff Show More