78 lines
3.0 KiB
C#
78 lines
3.0 KiB
C#
using System.IO;
|
|
using Content.Client.Administration.Managers;
|
|
using Content.Shared.Administration;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.Placement;
|
|
using Robust.Client.ResourceManagement;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.CustomControls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client.Administration.UI.Tabs.AdminbusTab
|
|
{
|
|
[GenerateTypedNameReferences]
|
|
public partial class AdminbusTab : Control
|
|
{
|
|
private EntitySpawnWindow? _entitySpawnWindow;
|
|
private TileSpawnWindow? _tileSpawnWindow;
|
|
|
|
public AdminbusTab()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
// For the SpawnEntitiesButton and SpawnTilesButton we need to do the press manually
|
|
// 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)
|
|
{
|
|
//FIXME: WE SHOULDN'T NEED TO CHECK FOR DISPOSED
|
|
if (_entitySpawnWindow == null || _entitySpawnWindow.Disposed)
|
|
{
|
|
_entitySpawnWindow = new EntitySpawnWindow(IoCManager.Resolve<IPlacementManager>(),
|
|
IoCManager.Resolve<IPrototypeManager>(),
|
|
IoCManager.Resolve<IResourceCache>());
|
|
}
|
|
|
|
EntitySystem.Get<AdminSystem>().OpenCommand(_entitySpawnWindow);
|
|
}
|
|
|
|
private void SpawnTilesButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
|
{
|
|
//FIXME: WE SHOULDN'T NEED TO CHECK FOR DISPOSED
|
|
if (_tileSpawnWindow == null || _tileSpawnWindow.Disposed)
|
|
{
|
|
_tileSpawnWindow = new TileSpawnWindow(IoCManager.Resolve<ITileDefinitionManager>(),
|
|
IoCManager.Resolve<IPlacementManager>(),
|
|
IoCManager.Resolve<IResourceCache>());
|
|
}
|
|
|
|
EntitySystem.Get<AdminSystem>().OpenCommand(_tileSpawnWindow);
|
|
}
|
|
}
|
|
}
|