Files
tbd-station-14/Content.Client/GameObjects/Components/Wires/WiresMenu.cs
DamianX 36078382e4 Airlock hacking (#329)
* Airlock hacking

* Added status text

* Whoops don't need this

* Update Content.Server/GameObjects/Components/Doors/AirlockComponent.cs

Co-Authored-By: Pieter-Jan Briers <pieterjan.briers@gmail.com>

* ComponentReference ServerDoorComponent

* Suggested name
2019-09-06 10:05:02 +02:00

71 lines
2.5 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 _wiresContainer;
public WiresMenu()
{
IoCManager.InjectDependencies(this); // TODO: Remove this and use DynamicTypeFactory?
Title = _localizationManager.GetString("Wires");
_wiresContainer = new VBoxContainer();
Contents.AddChild(_wiresContainer);
}
public void Populate(WiresBoundUserInterfaceState state)
{
_wiresContainer.RemoveAllChildren();
foreach (var wire in state.WiresList)
{
var container = new HBoxContainer();
var newLabel = new Label()
{
Text = $"{_localizationManager.GetString(wire.Color.Name())}: ",
FontColorOverride = wire.Color,
};
container.AddChild(newLabel);
var newButton = new Button()
{
Text = _localizationManager.GetString("Pulse"),
};
newButton.OnPressed += _ => Owner.PerformAction(wire.Guid, WiresAction.Pulse);
container.AddChild(newButton);
newButton = new Button()
{
Text = wire.IsCut ? _localizationManager.GetString("Mend") : _localizationManager.GetString("Cut"),
};
newButton.OnPressed += _ => Owner.PerformAction(wire.Guid, wire.IsCut ? WiresAction.Mend : WiresAction.Cut);
container.AddChild(newButton);
_wiresContainer.AddChild(container);
}
foreach (var status in state.Statuses)
{
var container = new HBoxContainer();
container.AddChild(new Label
{
Text = status
});
_wiresContainer.AddChild(container);
}
}
}
}