From a557dd26ecc9cc16d70b32699aba0551425abc10 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Wed, 25 May 2022 00:26:57 +0200 Subject: [PATCH] Add completions for ForceMap and ForcePreset --- .../GameTicking/Commands/ForceMapCommand.cs | 23 ++++++++++++++++--- .../Commands/ForcePresetCommand.cs | 20 +++++++++++++++- .../en-US/game-ticking/forcemap-command.ftl | 3 ++- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/Content.Server/GameTicking/Commands/ForceMapCommand.cs b/Content.Server/GameTicking/Commands/ForceMapCommand.cs index 1b3cbfaecb..c0007de76c 100644 --- a/Content.Server/GameTicking/Commands/ForceMapCommand.cs +++ b/Content.Server/GameTicking/Commands/ForceMapCommand.cs @@ -1,7 +1,9 @@ -using Content.Server.Administration; +using System.Linq; +using Content.Server.Administration; using Content.Server.Maps; using Content.Shared.Administration; using Robust.Shared.Console; +using Robust.Shared.Prototypes; namespace Content.Server.GameTicking.Commands { @@ -9,8 +11,8 @@ namespace Content.Server.GameTicking.Commands sealed class ForceMapCommand : IConsoleCommand { public string Command => "forcemap"; - public string Description => "forcemap-command-description"; - public string Help => $"forcemap-command-help"; + public string Description => Loc.GetString("forcemap-command-description"); + public string Help => Loc.GetString("forcemap-command-help"); public void Execute(IConsoleShell shell, string argStr, string[] args) { @@ -26,5 +28,20 @@ namespace Content.Server.GameTicking.Commands gameMap.ForceSelectMap(name); shell.WriteLine(Loc.GetString("forcemap-command-success", ("map", name))); } + + public CompletionResult GetCompletion(IConsoleShell shell, string[] args) + { + if (args.Length == 1) + { + var options = IoCManager.Resolve() + .EnumeratePrototypes() + .Select(p => new CompletionOption(p.ID, p.MapName)) + .OrderBy(p => p.Value); + + return CompletionResult.FromHintOptions(options, Loc.GetString("forcemap-command-arg-map")); + } + + return CompletionResult.Empty; + } } } diff --git a/Content.Server/GameTicking/Commands/ForcePresetCommand.cs b/Content.Server/GameTicking/Commands/ForcePresetCommand.cs index 42003d2a46..1041fed6ec 100644 --- a/Content.Server/GameTicking/Commands/ForcePresetCommand.cs +++ b/Content.Server/GameTicking/Commands/ForcePresetCommand.cs @@ -1,6 +1,9 @@ -using Content.Server.Administration; +using System.Linq; +using Content.Server.Administration; +using Content.Server.GameTicking.Presets; using Content.Shared.Administration; using Robust.Shared.Console; +using Robust.Shared.Prototypes; namespace Content.Server.GameTicking.Commands { @@ -37,5 +40,20 @@ namespace Content.Server.GameTicking.Commands shell.WriteLine($"Forced the game to start with preset {name}."); ticker.UpdateInfoText(); } + + public CompletionResult GetCompletion(IConsoleShell shell, string[] args) + { + if (args.Length == 1) + { + var options = IoCManager.Resolve() + .EnumeratePrototypes() + .OrderBy(p => p.ID) + .Select(p => p.ID); + + return CompletionResult.FromHintOptions(options, ""); + } + + return CompletionResult.Empty; + } } } diff --git a/Resources/Locale/en-US/game-ticking/forcemap-command.ftl b/Resources/Locale/en-US/game-ticking/forcemap-command.ftl index 316eb21e8e..df2ca68786 100644 --- a/Resources/Locale/en-US/game-ticking/forcemap-command.ftl +++ b/Resources/Locale/en-US/game-ticking/forcemap-command.ftl @@ -1,6 +1,7 @@ ## Forcemap command loc. forcemap-command-description = Forces the game to start with a given map next round. -forcemap-command-help = forcemap +forcemap-command-help = forcemap forcemap-command-need-one-argument = forcemap takes one argument, the path to the map file. forcemap-command-success = Forced the game to start with map { $map } next round. +forcemap-command-arg-map =