Load prototype command (#11275)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -61,3 +61,4 @@
|
||||
- Flags: QUERY
|
||||
Commands:
|
||||
- uploadfile
|
||||
- loadprototype
|
||||
|
||||
Reference in New Issue
Block a user