Files
tbd-station-14/Content.Client/Gravity/UI/GravityGeneratorBoundUserInterface.cs
Visne 5063689d81 GravityGeneratorWindow to XAML UI (#4638)
* Move color handling to localization strings, small improvements

* Create/move files to UI namespace

* Actually change namespace

* Move to XAML

* Improve localization
2021-09-19 09:59:55 -07:00

55 lines
1.5 KiB
C#

using Content.Shared.Gravity;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.Gravity.UI
{
[UsedImplicitly]
public class GravityGeneratorBoundUserInterface : BoundUserInterface
{
private GravityGeneratorWindow? _window;
public bool IsOn;
public GravityGeneratorBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base (owner, uiKey)
{
SendMessage(new SharedGravityGeneratorComponent.GeneratorStatusRequestMessage());
}
protected override void Open()
{
base.Open();
IsOn = false;
_window = new GravityGeneratorWindow(this);
_window.Switch.OnPressed += _ =>
{
SendMessage(new SharedGravityGeneratorComponent.SwitchGeneratorMessage(!IsOn));
SendMessage(new SharedGravityGeneratorComponent.GeneratorStatusRequestMessage());
};
_window.OpenCentered();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
var castState = (SharedGravityGeneratorComponent.GeneratorState) state;
IsOn = castState.On;
_window?.UpdateButton();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing) return;
_window?.Dispose();
}
}
}