Microwave UX enhancements (#24547)
* Facelift Microwave UI Includes new background light in UI, Uses predictive input, UI now properly disables buttons when microwave is active * Microwave now shows Elapsed time * Fixed bad formatting * Added new term for "BottomMargin" * Change yellow color * Update StyleNano.cs just spacing fixed * Cook time countdown now detached from server Instead of the server constantly sending out messages for the cook countdown, it is now predicted client side using TimeSpan * Update MicrowaveMenu.xaml forgot to re-add item space
This commit is contained in:
@@ -4,6 +4,7 @@ using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Client.Kitchen.UI
|
||||
{
|
||||
@@ -18,6 +19,9 @@ namespace Content.Client.Kitchen.UI
|
||||
|
||||
[ViewVariables]
|
||||
private readonly Dictionary<int, ReagentQuantity> _reagents = new();
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
public MicrowaveUpdateUserInterfaceState currentState = default!;
|
||||
|
||||
private IEntityManager _entManager;
|
||||
|
||||
@@ -26,23 +30,47 @@ namespace Content.Client.Kitchen.UI
|
||||
_entManager = IoCManager.Resolve<IEntityManager>();
|
||||
}
|
||||
|
||||
public TimeSpan GetCurrentTime()
|
||||
{
|
||||
return _gameTiming.CurTime;
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
_menu = new MicrowaveMenu(this);
|
||||
_menu.OpenCentered();
|
||||
_menu.OnClose += Close;
|
||||
_menu.StartButton.OnPressed += _ => SendMessage(new MicrowaveStartCookMessage());
|
||||
_menu.EjectButton.OnPressed += _ => SendMessage(new MicrowaveEjectMessage());
|
||||
_menu.StartButton.OnPressed += _ => SendPredictedMessage(new MicrowaveStartCookMessage());
|
||||
_menu.EjectButton.OnPressed += _ => SendPredictedMessage(new MicrowaveEjectMessage());
|
||||
_menu.IngredientsList.OnItemSelected += args =>
|
||||
{
|
||||
SendMessage(new MicrowaveEjectSolidIndexedMessage(EntMan.GetNetEntity(_solids[args.ItemIndex])));
|
||||
SendPredictedMessage(new MicrowaveEjectSolidIndexedMessage(EntMan.GetNetEntity(_solids[args.ItemIndex])));
|
||||
};
|
||||
|
||||
_menu.OnCookTimeSelected += (args, buttonIndex) =>
|
||||
{
|
||||
var actualButton = (MicrowaveMenu.MicrowaveCookTimeButton) args.Button;
|
||||
SendMessage(new MicrowaveSelectCookTimeMessage(buttonIndex, actualButton.CookTime));
|
||||
var selectedCookTime = (uint) 0;
|
||||
|
||||
if (args.Button is MicrowaveMenu.MicrowaveCookTimeButton microwaveCookTimeButton)
|
||||
{
|
||||
// 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));
|
||||
SendPredictedMessage(new MicrowaveSelectCookTimeMessage((int) selectedCookTime / 5, actualButton.CookTime));
|
||||
|
||||
_menu.CookTimeInfoLabel.Text = Loc.GetString("microwave-bound-user-interface-cook-time-label",
|
||||
("time", selectedCookTime));
|
||||
}
|
||||
else
|
||||
{
|
||||
// args.Button is a normal button aka instant cook button
|
||||
SendPredictedMessage(new MicrowaveSelectCookTimeMessage((int) selectedCookTime, 0));
|
||||
|
||||
_menu.CookTimeInfoLabel.Text = Loc.GetString("microwave-bound-user-interface-cook-time-label",
|
||||
("time", Loc.GetString("microwave-menu-instant-button")));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -67,20 +95,47 @@ namespace Content.Client.Kitchen.UI
|
||||
return;
|
||||
}
|
||||
|
||||
_menu?.ToggleBusyDisableOverlayPanel(cState.IsMicrowaveBusy);
|
||||
|
||||
_menu?.ToggleBusyDisableOverlayPanel(cState.IsMicrowaveBusy || cState.ContainedSolids.Length == 0);
|
||||
currentState = cState;
|
||||
|
||||
// TODO move this to a component state and ensure the net ids.
|
||||
RefreshContentsDisplay(_entManager.GetEntityArray(cState.ContainedSolids));
|
||||
|
||||
if (_menu == null) return;
|
||||
|
||||
var currentlySelectedTimeButton = (Button) _menu.CookTimeButtonVbox.GetChild(cState.ActiveButtonIndex);
|
||||
currentlySelectedTimeButton.Pressed = true;
|
||||
var cookTime = cState.ActiveButtonIndex == 0
|
||||
//Set the cook time info label
|
||||
var cookTime = cState.ActiveButtonIndex == 0
|
||||
? Loc.GetString("microwave-menu-instant-button")
|
||||
: cState.CurrentCookTime.ToString();
|
||||
|
||||
|
||||
_menu.CookTimeInfoLabel.Text = Loc.GetString("microwave-bound-user-interface-cook-time-label",
|
||||
("time", cookTime));
|
||||
_menu.StartButton.Disabled = cState.IsMicrowaveBusy || cState.ContainedSolids.Length == 0;
|
||||
_menu.EjectButton.Disabled = cState.IsMicrowaveBusy || cState.ContainedSolids.Length == 0;
|
||||
|
||||
|
||||
//Set the correct button active button
|
||||
if (cState.ActiveButtonIndex == 0)
|
||||
{
|
||||
_menu.InstantCookButton.Pressed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var currentlySelectedTimeButton = (Button) _menu.CookTimeButtonVbox.GetChild(cState.ActiveButtonIndex - 1);
|
||||
currentlySelectedTimeButton.Pressed = true;
|
||||
}
|
||||
|
||||
//Set the "micowave light" ui color to indicate if the microwave is busy or not
|
||||
if (cState.IsMicrowaveBusy && cState.ContainedSolids.Length > 0)
|
||||
{
|
||||
_menu.IngredientsPanel.PanelOverride = new StyleBoxFlat { BackgroundColor = Color.FromHex("#947300") };
|
||||
}
|
||||
else
|
||||
{
|
||||
_menu.IngredientsPanel.PanelOverride = new StyleBoxFlat { BackgroundColor = Color.FromHex("#1B1B1E") };
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshContentsDisplay(EntityUid[] containedSolids)
|
||||
|
||||
Reference in New Issue
Block a user