2020-10-06 10:16:42 +02:00
|
|
|
|
using System.Threading;
|
2020-04-09 00:28:56 +02:00
|
|
|
|
using Content.Client.GameObjects.Components.Command;
|
|
|
|
|
|
using Robust.Client.UserInterface;
|
|
|
|
|
|
using Robust.Client.UserInterface.Controls;
|
|
|
|
|
|
using Robust.Client.UserInterface.CustomControls;
|
|
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
|
using Robust.Shared.Localization;
|
|
|
|
|
|
using Robust.Shared.Maths;
|
2021-02-18 20:45:45 -08:00
|
|
|
|
using Timer = Robust.Shared.Timing.Timer;
|
2020-04-09 00:28:56 +02:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Client.Command
|
|
|
|
|
|
{
|
|
|
|
|
|
public class CommunicationsConsoleMenu : SS14Window
|
|
|
|
|
|
{
|
|
|
|
|
|
protected override Vector2? CustomSize => new Vector2(600, 400);
|
|
|
|
|
|
|
|
|
|
|
|
private CommunicationsConsoleBoundUserInterface Owner { get; set; }
|
2020-11-27 11:00:49 +01:00
|
|
|
|
private readonly CancellationTokenSource _timerCancelTokenSource = new();
|
2021-02-16 09:31:57 +01:00
|
|
|
|
public readonly Button EmergencyShuttleButton;
|
2020-04-09 00:28:56 +02:00
|
|
|
|
private readonly RichTextLabel _countdownLabel;
|
|
|
|
|
|
|
|
|
|
|
|
public CommunicationsConsoleMenu(CommunicationsConsoleBoundUserInterface owner)
|
|
|
|
|
|
{
|
|
|
|
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
|
|
|
2020-09-17 09:55:50 +12:00
|
|
|
|
Title = Loc.GetString("Communications Console");
|
2020-04-09 00:28:56 +02:00
|
|
|
|
Owner = owner;
|
|
|
|
|
|
|
|
|
|
|
|
_countdownLabel = new RichTextLabel(){CustomMinimumSize = new Vector2(0, 200)};
|
2021-02-16 09:31:57 +01:00
|
|
|
|
EmergencyShuttleButton = new Button();
|
|
|
|
|
|
EmergencyShuttleButton.OnPressed += (_) => Owner.EmergencyShuttleButtonPressed();
|
|
|
|
|
|
EmergencyShuttleButton.Disabled = !owner.CanCall;
|
2020-04-09 00:28:56 +02:00
|
|
|
|
|
|
|
|
|
|
var vbox = new VBoxContainer() {SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand};
|
|
|
|
|
|
|
|
|
|
|
|
vbox.AddChild(_countdownLabel);
|
2021-02-16 09:31:57 +01:00
|
|
|
|
vbox.AddChild(EmergencyShuttleButton);
|
2020-04-09 00:28:56 +02:00
|
|
|
|
|
|
|
|
|
|
var hbox = new HBoxContainer() {SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand};
|
|
|
|
|
|
hbox.AddChild(new Control(){CustomMinimumSize = new Vector2(100,0), SizeFlagsHorizontal = SizeFlags.FillExpand});
|
|
|
|
|
|
hbox.AddChild(vbox);
|
|
|
|
|
|
hbox.AddChild(new Control(){CustomMinimumSize = new Vector2(100,0), SizeFlagsHorizontal = SizeFlags.FillExpand});
|
|
|
|
|
|
|
|
|
|
|
|
Contents.AddChild(hbox);
|
|
|
|
|
|
|
|
|
|
|
|
UpdateCountdown();
|
|
|
|
|
|
Timer.SpawnRepeating(1000, UpdateCountdown, _timerCancelTokenSource.Token);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-10 13:36:30 +02:00
|
|
|
|
public void UpdateCountdown()
|
2020-04-09 00:28:56 +02:00
|
|
|
|
{
|
|
|
|
|
|
if (!Owner.CountdownStarted)
|
|
|
|
|
|
{
|
|
|
|
|
|
_countdownLabel.SetMessage("");
|
2021-02-16 09:31:57 +01:00
|
|
|
|
EmergencyShuttleButton.Text = Loc.GetString("Call emergency shuttle");
|
2020-04-09 00:28:56 +02:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-02-16 09:31:57 +01:00
|
|
|
|
EmergencyShuttleButton.Text = Loc.GetString("Recall emergency shuttle");
|
2020-04-09 00:28:56 +02:00
|
|
|
|
_countdownLabel.SetMessage($"Time remaining\n{Owner.Countdown.ToString()}s");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Close()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Close();
|
|
|
|
|
|
|
|
|
|
|
|
_timerCancelTokenSource.Cancel();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
|
|
{
|
2020-10-06 10:16:42 +02:00
|
|
|
|
base.Dispose(disposing);
|
|
|
|
|
|
|
|
|
|
|
|
if (disposing)
|
2020-04-09 00:28:56 +02:00
|
|
|
|
_timerCancelTokenSource.Cancel();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|