Files
tbd-station-14/Content.Client/GameObjects/Components/Wires/WiresMenu.cs
DamianX 264a63b7f6 Wires! (#315)
* Wires!

* Use state instead of messages

* cleanup

* Update submodule

* actually fix conflict

* Maybe fix conflicts?

* Localized strings, removed hardcoded sprite path

* cleanup

* More localization and sounds
2019-09-01 22:15:34 +02:00

61 lines
2.2 KiB
C#

using System.Collections.Generic;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using static Content.Shared.GameObjects.Components.SharedWiresComponent;
namespace Content.Client.GameObjects.Components.Wires
{
public class WiresMenu : SS14Window
{
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
protected override Vector2? CustomSize => (300, 450);
public WiresBoundUserInterface Owner { get; set; }
private readonly VBoxContainer _rows;
public WiresMenu()
{
IoCManager.InjectDependencies(this); // TODO: Remove this and use DynamicTypeFactory?
Title = _localizationManager.GetString("Wires");
_rows = new VBoxContainer();
Contents.AddChild(_rows);
}
public void Populate(List<ClientWire> wiresList)
{
_rows.RemoveAllChildren();
foreach (var entry in wiresList)
{
var container = new HBoxContainer();
var newLabel = new Label()
{
Text = $"{_localizationManager.GetString(entry.Color.Name())}: ",
FontColorOverride = entry.Color,
};
container.AddChild(newLabel);
var newButton = new Button()
{
Text = _localizationManager.GetString("Pulse"),
};
newButton.OnPressed += _ => Owner.PerformAction(entry.Guid, WiresAction.Pulse);
container.AddChild(newButton);
newButton = new Button()
{
Text = entry.IsCut ? _localizationManager.GetString("Mend") : _localizationManager.GetString("Cut"),
};
newButton.OnPressed += _ => Owner.PerformAction(entry.Guid, entry.IsCut ? WiresAction.Mend : WiresAction.Cut);
container.AddChild(newButton);
_rows.AddChild(container);
}
}
}
}