You can now cancel the timer (recall)

This commit is contained in:
zumorica
2020-04-09 01:43:28 +02:00
parent 64eafde0c3
commit 83e9688133
5 changed files with 36 additions and 5 deletions

View File

@@ -20,7 +20,7 @@ namespace Content.Client.Command
private CommunicationsConsoleBoundUserInterface Owner { get; set; }
private readonly CancellationTokenSource _timerCancelTokenSource = new CancellationTokenSource();
private readonly Button _emergencyShuttleButton;
private readonly RichTextLabel _countdownLabel;
public CommunicationsConsoleMenu(CommunicationsConsoleBoundUserInterface owner)
@@ -31,14 +31,13 @@ namespace Content.Client.Command
Owner = owner;
_countdownLabel = new RichTextLabel(){CustomMinimumSize = new Vector2(0, 200)};
var emergencyShuttleButton = new Button() {Text = _localizationManager.GetString("Call emergency shuttle")};
emergencyShuttleButton.OnPressed += (e) => Owner.CallShuttle();
_emergencyShuttleButton = new Button();
_emergencyShuttleButton.OnPressed += (e) => Owner.EmergencyShuttleButtonPressed();
var vbox = new VBoxContainer() {SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand};
vbox.AddChild(_countdownLabel);
vbox.AddChild(emergencyShuttleButton);
vbox.AddChild(_emergencyShuttleButton);
var hbox = new HBoxContainer() {SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand};
hbox.AddChild(new Control(){CustomMinimumSize = new Vector2(100,0), SizeFlagsHorizontal = SizeFlags.FillExpand});
@@ -56,9 +55,11 @@ namespace Content.Client.Command
if (!Owner.CountdownStarted)
{
_countdownLabel.SetMessage("");
_emergencyShuttleButton.Text = _localizationManager.GetString("Call emergency shuttle");
return;
}
_emergencyShuttleButton.Text = _localizationManager.GetString("Recall emergency shuttle");
_countdownLabel.SetMessage($"Time remaining\n{Owner.Countdown.ToString()}s");
}

View File

@@ -33,11 +33,24 @@ namespace Content.Client.GameObjects.Components.Command
_menu.OpenCentered();
}
public void EmergencyShuttleButtonPressed()
{
if(CountdownStarted)
RecallShuttle();
else
CallShuttle();
}
public void CallShuttle()
{
SendMessage(new CommunicationsConsoleCallEmergencyShuttleMessage());
}
public void RecallShuttle()
{
SendMessage(new CommunicationsConsoleRecallEmergencyShuttleMessage());
}
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
{
switch (message)

View File

@@ -49,6 +49,10 @@ namespace Content.Server.GameObjects.Components.Command
case CommunicationsConsoleCallEmergencyShuttleMessage _:
RoundEndSystem.RequestRoundEnd();
break;
case CommunicationsConsoleRecallEmergencyShuttleMessage _:
RoundEndSystem.CancelRoundEndCountdown();
break;
}
}

View File

@@ -41,6 +41,11 @@ namespace Content.Server.GameObjects.EntitySystems
public void CancelRoundEndCountdown()
{
if (!IsRoundEndCountdownStarted)
return;
IsRoundEndCountdownStarted = false;
_roundEndCancellationTokenSource.Cancel();
_roundEndCancellationTokenSource = new CancellationTokenSource();

View File

@@ -33,6 +33,14 @@ namespace Content.Shared.GameObjects.Components.Command
}
}
[Serializable, NetSerializable]
public class CommunicationsConsoleRecallEmergencyShuttleMessage : BoundUserInterfaceMessage
{
public CommunicationsConsoleRecallEmergencyShuttleMessage()
{
}
}
[Serializable, NetSerializable]
public enum CommunicationsConsoleUiKey
{