Microwave interface.
This commit is contained in:
@@ -2,15 +2,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Content.Shared.Kitchen;
|
||||
using Robust.Shared.GameObjects.Components.UserInterface;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Kitchen
|
||||
{
|
||||
public class MicrowaveBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
private MicrowaveMenu _menu;
|
||||
|
||||
public MicrowaveBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner,uiKey)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
_menu = new MicrowaveMenu(this);
|
||||
_menu.OpenCentered();
|
||||
_menu.OnClose += Close;
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
if (!(state is MicrowaveUserInterfaceState cstate))
|
||||
return;
|
||||
_menu.RefreshReagents(cstate.ContainedReagents);
|
||||
|
||||
}
|
||||
|
||||
public void Cook()
|
||||
{
|
||||
SendMessage(new SharedMicrowaveComponent.MicrowaveStartCookMessage());
|
||||
}
|
||||
|
||||
public void Eject()
|
||||
{
|
||||
SendMessage(new SharedMicrowaveComponent.MicrowaveEjectMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.GameObjects;
|
||||
using Content.Shared.Kitchen;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Kitchen
|
||||
{
|
||||
public class MicrowaveMenu : SS14Window
|
||||
{
|
||||
protected override Vector2? CustomSize => (512, 256);
|
||||
|
||||
public MicrowaveBoundUserInterface Owner { get; set; }
|
||||
|
||||
private List<Solution.ReagentQuantity> _heldReagents;
|
||||
|
||||
private VBoxContainer InnerScrollContainer { get; set; }
|
||||
|
||||
public MicrowaveMenu(MicrowaveBoundUserInterface owner = null)
|
||||
{
|
||||
Owner = owner;
|
||||
_heldReagents = new List<Solution.ReagentQuantity>();
|
||||
Title = Loc.GetString("Microwave");
|
||||
var vbox = new VBoxContainer()
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.Fill
|
||||
};
|
||||
|
||||
var startButton = new Button()
|
||||
{
|
||||
Label = { Text = Loc.GetString("START")}
|
||||
};
|
||||
var ejectButton = new Button()
|
||||
{
|
||||
Label = { Text = Loc.GetString("EJECT CONTENTS")}
|
||||
};
|
||||
var scrollContainer = new ScrollContainer()
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand
|
||||
};
|
||||
|
||||
InnerScrollContainer = new VBoxContainer()
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand
|
||||
};
|
||||
|
||||
scrollContainer.AddChild(InnerScrollContainer);
|
||||
vbox.AddChild(startButton);
|
||||
vbox.AddChild(ejectButton);
|
||||
vbox.AddChild(scrollContainer);
|
||||
Contents.AddChild(vbox);
|
||||
startButton.OnPressed += OnCookButtonPressed;
|
||||
ejectButton.OnPressed += OnEjectButtonPressed;
|
||||
|
||||
}
|
||||
|
||||
private void OnEjectButtonPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
Owner.Eject();
|
||||
}
|
||||
|
||||
private void OnCookButtonPressed(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
Owner.Cook();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void RefreshReagents(List<Solution.ReagentQuantity> reagents)
|
||||
{
|
||||
InnerScrollContainer.RemoveAllChildren();
|
||||
foreach (var item in reagents)
|
||||
{
|
||||
IoCManager.Resolve<IPrototypeManager>().TryIndex(item.ReagentId, out ReagentPrototype proto);
|
||||
|
||||
InnerScrollContainer.AddChild(new Label()
|
||||
{
|
||||
|
||||
Text = $"{item.Quantity} {proto.Name}"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
InnerScrollContainer.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using Content.Client.GameObjects.Components.Sound;
|
||||
using Content.Shared.GameObjects.Components.Power;
|
||||
using Content.Shared.GameObjects.Components.Sound;
|
||||
using Content.Shared.Kitchen;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.GameObjects.EntitySystems;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.GameObjects.Components.UserInterface;
|
||||
using Robust.Shared.Serialization;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Kitchen
|
||||
@@ -60,6 +60,7 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
||||
|
||||
}
|
||||
|
||||
|
||||
public enum MicrowaveVisualizerLayers
|
||||
{
|
||||
Base,
|
||||
|
||||
Reference in New Issue
Block a user