Load prototype command (#11275)

This commit is contained in:
Flipp Syder
2022-09-14 18:43:50 -07:00
committed by GitHub
parent 4cca9a7add
commit f4c38d74e1
3 changed files with 37 additions and 12 deletions

View File

@@ -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<IFileDialogManager>();
var loadManager = IoCManager.Resolve<IGamePrototypeLoadManager>();
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);
}
}

View File

@@ -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<IFileDialogManager>();
var loadManager = IoCManager.Resolve<IGamePrototypeLoadManager>();
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)

View File

@@ -61,3 +61,4 @@
- Flags: QUERY
Commands:
- uploadfile
- loadprototype