[feat]enableShuttleCall command and button to admin menu

This commit is contained in:
rhailrake
2023-04-27 22:45:07 +06:00
committed by Remuchi
parent 2fc83dce19
commit 6202617b8c
6 changed files with 78 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
Title="{Loc 'admin-player-actions-window-shuttle-call'}"
MinWidth="300">
<BoxContainer Orientation="Vertical">
<cc:CommandButton Command="enableShuttleCall True" Name="_enableCallShuttleButton" Text="{Loc 'emergency_shuttle-call-enable'}" HorizontalAlignment="Center"/>
<cc:CommandButton Command="enableShuttleCall False" Name="_disableCallShuttleButton" Text="{Loc 'emergency_shuttle-call-disable'}" HorizontalAlignment="Center"/>
</BoxContainer>
</DefaultWindow>

View File

@@ -0,0 +1,16 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.Administration.UI.Tabs.AdminTab
{
[GenerateTypedNameReferences]
public sealed partial class AdminShuttleCallEnableWindow : DefaultWindow
{
public AdminShuttleCallEnableWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
}
}
}

View File

@@ -17,6 +17,7 @@
<cc:UICommandButton Command="callshuttle" Text="{Loc admin-player-actions-window-shuttle}" WindowType="{x:Type at:AdminShuttleWindow}"/>
<cc:CommandButton Command="adminlogs" Text="{Loc admin-player-actions-window-admin-logs}"/>
<cc:CommandButton Command="faxui" Text="{Loc admin-player-actions-window-admin-fax}"/>
<cc:UICommandButton Command="enableShuttleCall" Text="{Loc admin-player-actions-window-shuttle-call}" WindowType="{x:Type at:AdminShuttleCallEnableWindow}"/>
</GridContainer>
</BoxContainer>
</Control>

View File

@@ -16,6 +16,7 @@ using Content.Shared.Communications;
using Content.Shared.Database;
using Content.Shared.Emag.Components;
using Content.Shared.Popups;
using Content.Shared.White;
using Robust.Server.GameObjects;
using Robust.Shared.Configuration;
@@ -188,6 +189,10 @@ namespace Content.Server.Communications
if (_emergency.EmergencyShuttleArrived || !_roundEndSystem.CanCallOrRecall())
return false;
var shuttleCallEnabled = _cfg.GetCVar(WhiteCVars.EmergencyShuttleCallEnabled);
if (!shuttleCallEnabled)
return false;
// Calling shuttle checks
if (_roundEndSystem.ExpectedCountdownEnd is null)
return comp.CanShuttle;

View File

@@ -0,0 +1,40 @@
using Content.Server.Administration;
using Content.Server.Chat.Managers;
using Content.Shared.Administration;
using Content.Shared.White;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
namespace Content.Server.Shuttles.Commands;
[AdminCommand(AdminFlags.Fun)]
public sealed class EnableShuttleCallCommand : IConsoleCommand
{
public string Command => "enableShuttleCall";
public string Description => Loc.GetString("Toggles the shuttle call.");
public string Help => $"{Command} <bool>";
[Dependency] private readonly IConfigurationManager _cfg = default!;
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1 || !bool.TryParse(args[0], out bool value))
{
shell.WriteError($"{args[0]} is not a valid boolean.");
return;
}
var shuttleEnabled = _cfg.GetCVar(WhiteCVars.EmergencyShuttleCallEnabled);
if (value == shuttleEnabled)
{
shell.WriteError($"enableShuttleCall is already {args[0]}");
return;
}
_cfg.SetCVar(WhiteCVars.EmergencyShuttleCallEnabled, value);
var announce = Loc.GetString("emergency_shuttle-announce-toggle",
("admin", $"{shell.Player?.Name}"),
("value", $"{value}"));
IoCManager.Resolve<IChatManager>().SendAdminAnnouncement(announce);
}
}

View File

@@ -115,4 +115,11 @@ public sealed class WhiteCVars
public static readonly CVarDef<bool> NonPeacefulRoundEndEnabled =
CVarDef.Create("white.non_peaceful_round_end_enabled", true, CVar.SERVERONLY | CVar.ARCHIVE);
/*
* Disabling calling shuttle by admin button
*/
public static readonly CVarDef<bool> EmergencyShuttleCallEnabled =
CVarDef.Create("shuttle.emergency_shuttle_call", true, CVar.SERVER | CVar.REPLICATED | CVar.ARCHIVE);
}