From f4c38d74e1560f8f8ab8ff54321406648d4591e4 Mon Sep 17 00:00:00 2001 From: Flipp Syder <76629141+vulppine@users.noreply.github.com> Date: Wed, 14 Sep 2022 18:43:50 -0700 Subject: [PATCH] Load prototype command (#11275) --- .../Commands/LoadPrototypeCommand.cs | 33 +++++++++++++++++++ .../UI/Tabs/AdminbusTab/AdminbusTab.xaml.cs | 15 ++------- Resources/clientCommandPerms.yml | 1 + 3 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 Content.Client/Administration/Commands/LoadPrototypeCommand.cs diff --git a/Content.Client/Administration/Commands/LoadPrototypeCommand.cs b/Content.Client/Administration/Commands/LoadPrototypeCommand.cs new file mode 100644 index 0000000000..9a962f9b76 --- /dev/null +++ b/Content.Client/Administration/Commands/LoadPrototypeCommand.cs @@ -0,0 +1,33 @@ +using System.IO; +using Content.Shared.Administration; +using Robust.Client.UserInterface; +using Robust.Shared.Console; + +namespace Content.Client.Administration.Commands; + +public sealed class LoadPrototypeCommand : IConsoleCommand +{ + public string Command { get; } = "loadprototype"; + public string Description { get; } = "Load a prototype file into the server."; + public string Help => Command; + + public void Execute(IConsoleShell shell, string argStr, string[] args) + { + LoadPrototype(); + } + + public static async void LoadPrototype() + { + var dialogManager = IoCManager.Resolve(); + var loadManager = IoCManager.Resolve(); + + var stream = await dialogManager.OpenFile(); + if (stream is null) + return; + + // ew oop + var reader = new StreamReader(stream); + var proto = await reader.ReadToEndAsync(); + loadManager.SendGamePrototype(proto); + } +} diff --git a/Content.Client/Administration/UI/Tabs/AdminbusTab/AdminbusTab.xaml.cs b/Content.Client/Administration/UI/Tabs/AdminbusTab/AdminbusTab.xaml.cs index 4383300cee..01d2fa97d5 100644 --- a/Content.Client/Administration/UI/Tabs/AdminbusTab/AdminbusTab.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AdminbusTab/AdminbusTab.xaml.cs @@ -1,4 +1,5 @@ using System.IO; +using Content.Client.Administration.Commands; using Content.Client.Administration.Managers; using Content.Client.Sandbox; using Content.Client.UserInterface.Systems.DecalPlacer; @@ -31,19 +32,9 @@ namespace Content.Client.Administration.UI.Tabs.AdminbusTab LoadBlueprintsButton.Disabled = !adminManager.HasFlag(AdminFlags.Mapping); } - private async void LoadGamePrototypeButtonOnPressed(BaseButton.ButtonEventArgs obj) + private void LoadGamePrototypeButtonOnPressed(BaseButton.ButtonEventArgs obj) { - var dialogManager = IoCManager.Resolve(); - var loadManager = IoCManager.Resolve(); - - var stream = await dialogManager.OpenFile(); - if (stream is null) - return; - - // ew oop - var reader = new StreamReader(stream); - var proto = await reader.ReadToEndAsync(); - loadManager.SendGamePrototype(proto); + LoadPrototypeCommand.LoadPrototype(); } private void SpawnEntitiesButtonOnPressed(BaseButton.ButtonEventArgs obj) diff --git a/Resources/clientCommandPerms.yml b/Resources/clientCommandPerms.yml index bd83884f01..d442ae9576 100644 --- a/Resources/clientCommandPerms.yml +++ b/Resources/clientCommandPerms.yml @@ -61,3 +61,4 @@ - Flags: QUERY Commands: - uploadfile + - loadprototype