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:
@@ -1,14 +1,13 @@
|
||||
using System;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using FancyWindow = Content.Client.UserInterface.Controls.FancyWindow;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Client.Kitchen.UI
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class MicrowaveMenu : DefaultWindow
|
||||
public sealed partial class MicrowaveMenu : FancyWindow
|
||||
{
|
||||
public sealed class MicrowaveCookTimeButton : Button
|
||||
{
|
||||
@@ -17,28 +16,43 @@ namespace Content.Client.Kitchen.UI
|
||||
|
||||
public event Action<BaseButton.ButtonEventArgs, int>? OnCookTimeSelected;
|
||||
|
||||
private ButtonGroup CookTimeButtonGroup { get; }
|
||||
public ButtonGroup CookTimeButtonGroup { get; }
|
||||
private readonly MicrowaveBoundUserInterface _owner;
|
||||
|
||||
public MicrowaveMenu(MicrowaveBoundUserInterface owner)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
CookTimeButtonGroup = new ButtonGroup();
|
||||
InstantCookButton.Group = CookTimeButtonGroup;
|
||||
_owner = owner;
|
||||
InstantCookButton.OnPressed += args =>
|
||||
{
|
||||
OnCookTimeSelected?.Invoke(args, 0);
|
||||
};
|
||||
|
||||
for (var i = 0; i <= 30; i += 5)
|
||||
for (var i = 1; i <= 6; i++)
|
||||
{
|
||||
var newButton = new MicrowaveCookTimeButton
|
||||
{
|
||||
Text = i == 0 ? Loc.GetString("microwave-menu-instant-button") : i.ToString(),
|
||||
CookTime = (uint) i,
|
||||
Text = (i * 5).ToString(),
|
||||
TextAlign = Label.AlignMode.Center,
|
||||
ToggleMode = true,
|
||||
CookTime = (uint) (i * 5),
|
||||
Group = CookTimeButtonGroup,
|
||||
HorizontalExpand = true,
|
||||
};
|
||||
CookTimeButtonVbox.AddChild(newButton);
|
||||
newButton.OnToggled += args =>
|
||||
if (i == 4)
|
||||
{
|
||||
OnCookTimeSelected?.Invoke(args, newButton.GetPositionInParent());
|
||||
newButton.StyleClasses.Add("OpenRight");
|
||||
}
|
||||
else
|
||||
{
|
||||
newButton.StyleClasses.Add("OpenBoth");
|
||||
}
|
||||
CookTimeButtonVbox.AddChild(newButton);
|
||||
newButton.OnPressed += args =>
|
||||
{
|
||||
OnCookTimeSelected?.Invoke(args, i);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -47,5 +61,18 @@ namespace Content.Client.Kitchen.UI
|
||||
{
|
||||
DisableCookingPanelOverlay.Visible = shouldDisable;
|
||||
}
|
||||
|
||||
protected override void FrameUpdate(FrameEventArgs args)
|
||||
{
|
||||
base.FrameUpdate(args);
|
||||
if(!_owner.currentState.IsMicrowaveBusy)
|
||||
return;
|
||||
|
||||
if(_owner.currentState.CurrentCookTimeEnd > _owner.GetCurrentTime())
|
||||
{
|
||||
CookTimeInfoLabel.Text = Loc.GetString("microwave-bound-user-interface-cook-time-label",
|
||||
("time",_owner.currentState.CurrentCookTimeEnd.Subtract(_owner.GetCurrentTime()).Seconds));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user