Microwave UI + solids implemented.

This commit is contained in:
FL-OZ
2020-05-03 01:34:00 -05:00
parent dba0949c5b
commit 0f61c2fadf
8 changed files with 186 additions and 129 deletions

View File

@@ -1,8 +1,4 @@
using Robust.Client.GameObjects.Components.UserInterface;
using System;
using System.Collections.Generic;
using System.Text;
using Content.Client.GameObjects.Components.Mobs;
using Content.Shared.Kitchen;
using Robust.Shared.GameObjects.Components.UserInterface;
@@ -28,9 +24,9 @@ namespace Content.Client.GameObjects.Components.Kitchen
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (!(state is MicrowaveUserInterfaceState cstate))
if (!(state is MicrowaveUpdateUserInterfaceState cstate))
return;
_menu.RefreshContents(cstate.ReagentsReagents, cstate.ContainedSolids);
_menu.RefreshContentsDisplay(cstate.ReagentsReagents, cstate.ContainedSolids);
}
@@ -43,5 +39,10 @@ namespace Content.Client.GameObjects.Components.Kitchen
{
SendMessage(new SharedMicrowaveComponent.MicrowaveEjectMessage());
}
public void EjectSolidWithIndex(int index)
{
SendMessage(new SharedMicrowaveComponent.MicrowaveEjectSolidIndexedMessage(index));
}
}
}

View File

@@ -1,11 +1,9 @@
using System.Collections.Generic;
using Content.Shared.Chemistry;
using Content.Shared.GameObjects;
using Content.Shared.Kitchen;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
@@ -17,7 +15,7 @@ namespace Content.Client.GameObjects.Components.Kitchen
{
protected override Vector2? CustomSize => (512, 256);
public MicrowaveBoundUserInterface Owner { get; set; }
private MicrowaveBoundUserInterface Owner { get; set; }
private List<Solution.ReagentQuantity> _heldReagents;
@@ -35,11 +33,11 @@ namespace Content.Client.GameObjects.Components.Kitchen
var startButton = new Button()
{
Label = { Text = Loc.GetString("START")}
Label = { Text = Loc.GetString("START"), FontColorOverride = Color.Green}
};
var ejectButton = new Button()
{
Label = { Text = Loc.GetString("EJECT REAGENTS")}
Label = { Text = Loc.GetString("EJECT REAGENTS"),FontColorOverride = Color.Red}
};
var scrollContainer = new ScrollContainer()
{
@@ -56,24 +54,12 @@ namespace Content.Client.GameObjects.Components.Kitchen
vbox.AddChild(ejectButton);
vbox.AddChild(scrollContainer);
Contents.AddChild(vbox);
startButton.OnPressed += OnCookButtonPressed;
ejectButton.OnPressed += OnEjectButtonPressed;
startButton.OnPressed += args => Owner.Cook();
ejectButton.OnPressed += args => Owner.Eject();
}
private void OnEjectButtonPressed(BaseButton.ButtonEventArgs obj)
{
Owner.Eject();
}
private void OnCookButtonPressed(BaseButton.ButtonEventArgs args)
{
Owner.Cook();
}
public void RefreshContents(List<Solution.ReagentQuantity> reagents, Dictionary<string,int> solids)
public void RefreshContentsDisplay(List<Solution.ReagentQuantity> reagents, List<EntityUid> solids)
{
InnerScrollContainer.RemoveAllChildren();
foreach (var item in reagents)
@@ -82,20 +68,20 @@ namespace Content.Client.GameObjects.Components.Kitchen
InnerScrollContainer.AddChild(new Label()
{
Text = $"{item.Quantity} {proto.Name}"
});
}
foreach (var item in solids)
{
IoCManager.Resolve<IPrototypeManager>().TryIndex(item.Key, out EntityPrototype proto);
var solidLabel = new Button()
var name = IoCManager.Resolve<IEntityManager>().GetEntity(item).Prototype.Name;
var solidButton = new Button()
{
Text = $"{item.Value} {proto.Name}"
Text = $"{name}"
};
InnerScrollContainer.AddChild(solidLabel);
solidButton.OnPressed += args => Owner.EjectSolidWithIndex(solids.IndexOf(item));
InnerScrollContainer.AddChild(solidButton);
}
}

View File

@@ -20,8 +20,6 @@ namespace Content.Client.GameObjects.Components.Kitchen
public override void LoadData(YamlMappingNode node)
{
base.LoadData(node);
//_audioSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>();
}
public override void OnChangeData(AppearanceComponent component)