MicrowaveMenu to XAML UI (#4988)
* Rename and create files * MicrowaveMenu to XAML UI * Improve code 😪 * Restart tests * Restart tests * Remove unused imports * Remove duplicate localization string, set MinWidth so string fits * Improve code and localization * Update Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
This commit is contained in:
51
Content.Client/Kitchen/UI/MicrowaveMenu.xaml.cs
Normal file
51
Content.Client/Kitchen/UI/MicrowaveMenu.xaml.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
namespace Content.Client.Kitchen.UI
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class MicrowaveMenu : SS14Window
|
||||
{
|
||||
public class MicrowaveCookTimeButton : Button
|
||||
{
|
||||
public uint CookTime;
|
||||
}
|
||||
|
||||
public event Action<BaseButton.ButtonEventArgs, int>? OnCookTimeSelected;
|
||||
|
||||
private ButtonGroup CookTimeButtonGroup { get; }
|
||||
|
||||
public MicrowaveMenu(MicrowaveBoundUserInterface owner)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
CookTimeButtonGroup = new ButtonGroup();
|
||||
|
||||
for (var i = 0; i <= 30; i += 5)
|
||||
{
|
||||
var newButton = new MicrowaveCookTimeButton
|
||||
{
|
||||
Text = i == 0 ? Loc.GetString("microwave-menu-instant-button") : i.ToString(),
|
||||
CookTime = (uint) i,
|
||||
TextAlign = Label.AlignMode.Center,
|
||||
ToggleMode = true,
|
||||
Group = CookTimeButtonGroup,
|
||||
};
|
||||
CookTimeButtonVbox.AddChild(newButton);
|
||||
newButton.OnToggled += args =>
|
||||
{
|
||||
OnCookTimeSelected?.Invoke(args, newButton.GetPositionInParent());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleBusyDisableOverlayPanel(bool shouldDisable)
|
||||
{
|
||||
DisableCookingPanelOverlay.Visible = shouldDisable;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user