Admin shuttle call button (#4859)
* shuttle call ui * shuttle call ui * Localize shuttle commands better. * localization fix
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
<SS14Window xmlns="https://spacestation14.io"
|
||||||
|
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
|
||||||
|
Title="{Loc 'admin-shuttle-title'}"
|
||||||
|
MinWidth="300">
|
||||||
|
<BoxContainer Orientation="Vertical">
|
||||||
|
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
|
||||||
|
<LineEdit Name="_callShuttleTime" Text="4:00" PlaceHolder="m:ss" HorizontalExpand="True" SizeFlagsStretchRatio="2"/>
|
||||||
|
<Control HorizontalExpand="True" SizeFlagsStretchRatio="1"/>
|
||||||
|
<cc:CommandButton Command="callshuttle 4:00" Name="_callShuttleButton" Text="{Loc 'communicationsconsole-menu-call-shuttle'}" HorizontalExpand="True" SizeFlagsStretchRatio="2" />
|
||||||
|
</BoxContainer>
|
||||||
|
<cc:CommandButton Command="recallshuttle" Name="_recallShuttleButton" Text="{Loc 'communicationsconsole-menu-recall-shuttle'}" HorizontalAlignment="Center"/>
|
||||||
|
</BoxContainer>
|
||||||
|
|
||||||
|
</SS14Window>
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using Content.Shared.Localizations;
|
||||||
|
using Robust.Client.AutoGenerated;
|
||||||
|
using Robust.Client.UserInterface.Controls;
|
||||||
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
|
using Robust.Client.UserInterface.XAML;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
|
|
||||||
|
namespace Content.Client.Administration.UI.Tabs.AdminTab
|
||||||
|
{
|
||||||
|
[GenerateTypedNameReferences]
|
||||||
|
public partial class AdminShuttleWindow : SS14Window
|
||||||
|
{
|
||||||
|
public AdminShuttleWindow()
|
||||||
|
{
|
||||||
|
RobustXamlLoader.Load(this);
|
||||||
|
IoCManager.InjectDependencies(this);
|
||||||
|
|
||||||
|
_callShuttleTime.OnTextChanged += CallShuttleTimeOnOnTextChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CallShuttleTimeOnOnTextChanged(LineEdit.LineEditEventArgs obj)
|
||||||
|
{
|
||||||
|
var loc = IoCManager.Resolve<ILocalizationManager>();
|
||||||
|
_callShuttleButton.Disabled = !TimeSpan.TryParseExact(obj.Text, Localization.TimeSpanMinutesFormats, loc.DefaultCulture, out _);
|
||||||
|
_callShuttleButton.Command = $"callshuttle {obj.Text}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,13 +6,14 @@
|
|||||||
Margin="4"
|
Margin="4"
|
||||||
MinSize="50 50">
|
MinSize="50 50">
|
||||||
<BoxContainer Orientation="Vertical">
|
<BoxContainer Orientation="Vertical">
|
||||||
<GridContainer Columns="4">
|
<GridContainer Columns="3">
|
||||||
<cc:UICommandButton Command="kick" Text="{Loc admin-player-actions-window-title}" WindowType="{x:Type at:PlayerActionsWindow}" />
|
<cc:UICommandButton Command="kick" Text="{Loc admin-player-actions-window-title}" WindowType="{x:Type at:PlayerActionsWindow}" />
|
||||||
<cc:UICommandButton Command="ban" Text="{Loc Ban}" WindowType="{x:Type at:BanWindow}" />
|
<cc:UICommandButton Command="ban" Text="{Loc Ban}" WindowType="{x:Type at:BanWindow}" />
|
||||||
<cc:CommandButton Command="aghost" Text="{Loc Admin Ghost}" />
|
<cc:CommandButton Command="aghost" Text="{Loc Admin Ghost}" />
|
||||||
<cc:UICommandButton Command="tpto" Text="{Loc Teleport}" WindowType="{x:Type at:TeleportWindow}" />
|
<cc:UICommandButton Command="tpto" Text="{Loc Teleport}" WindowType="{x:Type at:TeleportWindow}" />
|
||||||
<cc:CommandButton Command="permissions" Text="{Loc Permissions Panel}" />
|
<cc:CommandButton Command="permissions" Text="{Loc Permissions Panel}" />
|
||||||
<cc:CommandButton Command="announceui" Text="{Loc Announce}"/>
|
<cc:CommandButton Command="announceui" Text="{Loc Announce}"/>
|
||||||
|
<cc:UICommandButton Command="callshuttle" Text="{Loc (Re)call Shuttle}" WindowType="{x:Type at:AdminShuttleWindow}"/>
|
||||||
</GridContainer>
|
</GridContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</Control>
|
</Control>
|
||||||
|
|||||||
51
Content.Server/Administration/Commands/ShuttleCommands.cs
Normal file
51
Content.Server/Administration/Commands/ShuttleCommands.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
using System;
|
||||||
|
using Content.Server.RoundEnd;
|
||||||
|
using Content.Shared.Administration;
|
||||||
|
using Content.Shared.Localizations;
|
||||||
|
using Robust.Shared.Console;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
|
|
||||||
|
namespace Content.Server.Administration.Commands
|
||||||
|
{
|
||||||
|
[AdminCommand(AdminFlags.Server)]
|
||||||
|
public class CallShuttleCommand : IConsoleCommand
|
||||||
|
{
|
||||||
|
public string Command => "callshuttle";
|
||||||
|
public string Description => Loc.GetString("call-shuttle-command-description");
|
||||||
|
public string Help => Loc.GetString("call-shuttle-command-help-text", ("command",Command));
|
||||||
|
|
||||||
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
|
{
|
||||||
|
var loc = IoCManager.Resolve<ILocalizationManager>();
|
||||||
|
|
||||||
|
// ReSharper disable once ConvertIfStatementToSwitchStatement
|
||||||
|
if (args.Length == 1 && TimeSpan.TryParseExact(args[0], Localization.TimeSpanMinutesFormats, loc.DefaultCulture, out var timeSpan))
|
||||||
|
{
|
||||||
|
EntitySystem.Get<RoundEndSystem>().RequestRoundEnd(timeSpan, false);
|
||||||
|
}
|
||||||
|
else if (args.Length == 1)
|
||||||
|
{
|
||||||
|
shell.WriteLine(Loc.GetString("shell-timespan-minutes-must-be-correct"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EntitySystem.Get<RoundEndSystem>().RequestRoundEnd(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[AdminCommand(AdminFlags.Server)]
|
||||||
|
public class RecallShuttleCommand : IConsoleCommand
|
||||||
|
{
|
||||||
|
public string Command => "recallshuttle";
|
||||||
|
public string Description => Loc.GetString("recall-shuttle-command-description");
|
||||||
|
public string Help => Loc.GetString("recall-shuttle-command-help-text", ("command",Command));
|
||||||
|
|
||||||
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
|
{
|
||||||
|
EntitySystem.Get<RoundEndSystem>().CancelRoundEndCountdown(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -74,36 +74,41 @@ namespace Content.Server.RoundEnd
|
|||||||
Timer.Spawn(CallCooldown, () => OnCallCooldownEnded?.Invoke(), _callCooldownEndedTokenSource.Token);
|
Timer.Spawn(CallCooldown, () => OnCallCooldownEnded?.Invoke(), _callCooldownEndedTokenSource.Token);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RequestRoundEnd()
|
public void RequestRoundEnd(bool checkCooldown = true)
|
||||||
|
{
|
||||||
|
RequestRoundEnd(RoundEndCountdownTime, checkCooldown);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RequestRoundEnd(TimeSpan countdownTime, bool checkCooldown = true)
|
||||||
{
|
{
|
||||||
if (IsRoundEndCountdownStarted)
|
if (IsRoundEndCountdownStarted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!CanCall())
|
if (checkCooldown && !CanCall())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IsRoundEndCountdownStarted = true;
|
IsRoundEndCountdownStarted = true;
|
||||||
|
|
||||||
_chatManager.DispatchStationAnnouncement(Loc.GetString("round-end-system-shuttle-called-announcement",("minutes", RoundEndCountdownTime.Minutes)), Loc.GetString("Station"));
|
_chatManager.DispatchStationAnnouncement(Loc.GetString("round-end-system-shuttle-called-announcement",("minutes", countdownTime.Minutes)), Loc.GetString("Station"));
|
||||||
|
|
||||||
SoundSystem.Play(Filter.Broadcast(), "/Audio/Announcements/shuttlecalled.ogg");
|
SoundSystem.Play(Filter.Broadcast(), "/Audio/Announcements/shuttlecalled.ogg");
|
||||||
|
|
||||||
ExpectedCountdownEnd = _gameTiming.CurTime + RoundEndCountdownTime;
|
ExpectedCountdownEnd = _gameTiming.CurTime + countdownTime;
|
||||||
Timer.Spawn(RoundEndCountdownTime, EndRound, _roundEndCancellationTokenSource.Token);
|
Timer.Spawn(countdownTime, EndRound, _roundEndCancellationTokenSource.Token);
|
||||||
|
|
||||||
ActivateCooldown();
|
ActivateCooldown();
|
||||||
|
|
||||||
OnRoundEndCountdownStarted?.Invoke();
|
OnRoundEndCountdownStarted?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CancelRoundEndCountdown()
|
public void CancelRoundEndCountdown( bool checkCooldown = true)
|
||||||
{
|
{
|
||||||
if (!IsRoundEndCountdownStarted)
|
if (!IsRoundEndCountdownStarted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!CanCall())
|
if (checkCooldown && !CanCall())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,17 @@ namespace Content.Shared.Localizations
|
|||||||
// If you want to change your codebase's language, do it here.
|
// If you want to change your codebase's language, do it here.
|
||||||
private const string Culture = "en-US";
|
private const string Culture = "en-US";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Custom format strings used for parsing and displaying minutes:seconds timespans.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string[] TimeSpanMinutesFormats = new[]
|
||||||
|
{
|
||||||
|
@"m\:ss",
|
||||||
|
@"mm\:ss",
|
||||||
|
@"%m",
|
||||||
|
@"mm"
|
||||||
|
};
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
var loc = IoCManager.Resolve<ILocalizationManager>();
|
var loc = IoCManager.Resolve<ILocalizationManager>();
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
call-shuttle-command-description = Calls the emergency shuttle with an optionally provided arrival time.
|
||||||
|
call-shuttle-command-help-text = Usage: {$command} [m:ss]
|
||||||
|
recall-shuttle-command-description = Recalls the emergency shuttle.
|
||||||
|
recall-shuttle-command-help-text = Usage: {$command}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
admin-shuttle-title = (Re)call shuttle
|
||||||
@@ -6,7 +6,7 @@ shell-server-cannot = Server cannot do this.
|
|||||||
shell-command-success = Command successful
|
shell-command-success = Command successful
|
||||||
shell-invalid-command = Invalid command.
|
shell-invalid-command = Invalid command.
|
||||||
shell-invalid-command-specific = Invalid {$commandName} command.
|
shell-invalid-command-specific = Invalid {$commandName} command.
|
||||||
shell-cannot-run-command-from-server = You cannot run this command from the server.
|
shell-cannot-run-command-from-server = You cannot run this command from the server.
|
||||||
shell-only-players-can-run-this-command = Only players can run this command.
|
shell-only-players-can-run-this-command = Only players can run this command.
|
||||||
|
|
||||||
## Arguments
|
## Arguments
|
||||||
@@ -29,5 +29,4 @@ shell-entity-with-uid-lacks-component = Entity with uid {$uid} doesn't have a {$
|
|||||||
shell-invalid-color-hex = Invalid color hex!
|
shell-invalid-color-hex = Invalid color hex!
|
||||||
shell-target-player-does-not-exist = Target player does not exist!
|
shell-target-player-does-not-exist = Target player does not exist!
|
||||||
shell-target-entity-does-not-have-message = Target entity does not have a(n) {$missing}!
|
shell-target-entity-does-not-have-message = Target entity does not have a(n) {$missing}!
|
||||||
|
shell-timespan-minutes-must-be-correct = {$span} is not a valid minutes timespan.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user