Cleaner BoundUserInterfaces (#17736)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user