Mid-game prototype loading for game admins (#5675)

This commit is contained in:
Moony
2021-12-11 17:28:16 -06:00
committed by GitHub
parent 5abb3cdc36
commit caad34eecb
12 changed files with 186 additions and 4 deletions

View File

@@ -8,6 +8,7 @@
<GridContainer Columns="3">
<Button Name="SpawnEntitiesButton" Text="{Loc 'sandbox-window-spawn-entities-button'}" />
<Button Name="SpawnTilesButton" Text="{Loc 'sandbox-window-spawn-tiles-button'} " />
<Button Name="LoadGamePrototypeButton" Text="{Loc 'load-game-prototype'}"/>
<cc:CommandButton Command="deleteewc Singularity" Name="DeleteSingulos" Text="{Loc 'delete-singularities'}"/>
<cc:UICommandButton Command="events" Text="{Loc 'open-station-events'}" WindowType="{x:Type abt:StationEventsWindow}" />
</GridContainer>

View File

@@ -1,4 +1,6 @@
using Content.Client.Administration.Managers;
using System.IO;
using Content.Client.Administration.Managers;
using Content.Shared.Administration;
using Robust.Client.AutoGenerated;
using Robust.Client.Placement;
using Robust.Client.ResourceManagement;
@@ -24,6 +26,23 @@ namespace Content.Client.Administration.UI.Tabs.AdminbusTab
// TODO: This will probably need some command check at some point
SpawnEntitiesButton.OnPressed += SpawnEntitiesButtonOnOnPressed;
SpawnTilesButton.OnPressed += SpawnTilesButtonOnOnPressed;
LoadGamePrototypeButton.OnPressed += LoadGamePrototypeButtonOnOnPressed;
LoadGamePrototypeButton.Visible = IoCManager.Resolve<IClientAdminManager>().HasFlag(AdminFlags.Query);
}
private async void LoadGamePrototypeButtonOnOnPressed(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);
}
private void SpawnEntitiesButtonOnOnPressed(BaseButton.ButtonEventArgs obj)