diff --git a/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs b/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs index 136e54b4ed..9e74dfa08f 100644 --- a/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs +++ b/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs @@ -1,11 +1,9 @@ -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; using Robust.Client.UserInterface.Controls; -using Robust.Shared.Timing; namespace Content.Client.Kitchen.UI { @@ -18,9 +16,6 @@ namespace Content.Client.Kitchen.UI [ViewVariables] private readonly Dictionary _solids = new(); - [ViewVariables] - private readonly Dictionary _reagents = new(); - //Sunrise-Start private readonly string _menuTitle; private readonly string _leftFlavorText; @@ -52,16 +47,13 @@ namespace Content.Client.Kitchen.UI SendPredictedMessage(new MicrowaveEjectSolidIndexedMessage(EntMan.GetNetEntity(_solids[args.ItemIndex]))); }; - _menu.OnCookTimeSelected += (args, buttonIndex) => + _menu.OnCookTimeSelected += (args, _) => { var selectedCookTime = (uint) 0; - if (args.Button is MicrowaveMenu.MicrowaveCookTimeButton microwaveCookTimeButton) + if (args.Button is MicrowaveMenu.MicrowaveCookTimeButton actualButton) { - // args.Button is a MicrowaveCookTimeButton - var actualButton = (MicrowaveMenu.MicrowaveCookTimeButton) args.Button; - selectedCookTime = actualButton.CookTime == 0 ? 0 : actualButton.CookTime; - // SendMessage(new MicrowaveSelectCookTimeMessage((int) selectedCookTime / 5, actualButton.CookTime)); + selectedCookTime = actualButton.CookTime; SendPredictedMessage(new MicrowaveSelectCookTimeMessage((int) selectedCookTime / 5, actualButton.CookTime)); _menu.CookTimeInfoLabel.Text = Loc.GetString("microwave-bound-user-interface-cook-time-label", @@ -133,8 +125,6 @@ namespace Content.Client.Kitchen.UI private void RefreshContentsDisplay(EntityUid[] containedSolids) { - _reagents.Clear(); - if (_menu == null) return; _solids.Clear(); @@ -142,30 +132,36 @@ namespace Content.Client.Kitchen.UI foreach (var entity in containedSolids) { if (EntMan.Deleted(entity)) - { - return; - } - - // TODO just use sprite view - - Texture? texture; - if (EntMan.TryGetComponent(entity, out var iconComponent)) - { - texture = EntMan.System().GetIcon(iconComponent); - } - else if (EntMan.TryGetComponent(entity, out var spriteComponent)) - { - texture = spriteComponent.Icon?.Default; - } - else { continue; } + if (!TryGetEntityTexture(entity, out var texture)) + continue; + var solidItem = _menu.IngredientsList.AddItem(EntMan.GetComponent(entity).EntityName, texture); var solidIndex = _menu.IngredientsList.IndexOf(solidItem); _solids.Add(solidIndex, entity); } } + + private bool TryGetEntityTexture(EntityUid entity, out Texture? texture) + { + // TODO just use sprite view + if (EntMan.TryGetComponent(entity, out var iconComponent)) + { + texture = EntMan.System().GetIcon(iconComponent); + return true; + } + + if (EntMan.TryGetComponent(entity, out var spriteComponent)) + { + texture = spriteComponent.Icon?.Default; + return true; + } + + texture = null; + return false; + } } } diff --git a/Content.Client/_Sunrise/Kitchen/UI/AssemblerBoundUserInterface.cs b/Content.Client/_Sunrise/Kitchen/UI/AssemblerBoundUserInterface.cs index 6657be9147..871e96b778 100644 --- a/Content.Client/_Sunrise/Kitchen/UI/AssemblerBoundUserInterface.cs +++ b/Content.Client/_Sunrise/Kitchen/UI/AssemblerBoundUserInterface.cs @@ -1,5 +1,4 @@ using Content.Shared._Sunrise.Kitchen.Components; -using Content.Shared.Chemistry.Reagent; using Content.Shared.Kitchen.Components; using JetBrains.Annotations; using Robust.Client.GameObjects; @@ -17,9 +16,6 @@ namespace Content.Client._Sunrise.Kitchen.UI [ViewVariables] private readonly Dictionary _solids = new(); - [ViewVariables] - private readonly Dictionary _reagents = new(); - private readonly string _menuTitle; private readonly string _leftFlavorText; @@ -67,9 +63,6 @@ namespace Content.Client._Sunrise.Kitchen.UI // TODO move this to a component state and ensure the net ids. RefreshContentsDisplay(EntMan.GetEntityArray(cState.ContainedSolids)); - //Set the cook time info label - var cookTime = cState.CurrentCookTime.ToString(); - _menu.CookTimeInfoLabel.Text = Loc.GetString("assembler-bound-user-interface-insert-ingredients"); _menu.StartButton.Disabled = cState.IsMicrowaveBusy || cState.ContainedSolids.Length == 0; _menu.EjectButton.Disabled = cState.IsMicrowaveBusy || cState.ContainedSolids.Length == 0; @@ -87,8 +80,6 @@ namespace Content.Client._Sunrise.Kitchen.UI private void RefreshContentsDisplay(EntityUid[] containedSolids) { - _reagents.Clear(); - if (_menu == null) return; _solids.Clear(); @@ -96,30 +87,36 @@ namespace Content.Client._Sunrise.Kitchen.UI foreach (var entity in containedSolids) { if (EntMan.Deleted(entity)) - { - return; - } - - // TODO just use sprite view - - Texture? texture; - if (EntMan.TryGetComponent(entity, out var iconComponent)) - { - texture = EntMan.System().GetIcon(iconComponent); - } - else if (EntMan.TryGetComponent(entity, out var spriteComponent)) - { - texture = spriteComponent.Icon?.Default; - } - else { continue; } + if (!TryGetEntityTexture(entity, out var texture)) + continue; + var solidItem = _menu.IngredientsList.AddItem(EntMan.GetComponent(entity).EntityName, texture); var solidIndex = _menu.IngredientsList.IndexOf(solidItem); _solids.Add(solidIndex, entity); } } + + private bool TryGetEntityTexture(EntityUid entity, out Texture? texture) + { + // TODO just use sprite view + if (EntMan.TryGetComponent(entity, out var iconComponent)) + { + texture = EntMan.System().GetIcon(iconComponent); + return true; + } + + if (EntMan.TryGetComponent(entity, out var spriteComponent)) + { + texture = spriteComponent.Icon?.Default; + return true; + } + + texture = null; + return false; + } } }