Cleaner BoundUserInterfaces (#17736)

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

View File

@@ -1,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);
}