Converts AdminMenu to partially use XAML (#3231)
This commit is contained in:
@@ -1,927 +0,0 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Client.GameObjects.EntitySystems;
|
||||
using Content.Client.StationEvents;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Placement;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
using static Robust.Client.UserInterface.Controls.BaseButton;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu
|
||||
{
|
||||
public class AdminMenuWindow : SS14Window
|
||||
{
|
||||
public readonly TabContainer MasterTabContainer;
|
||||
public readonly VBoxContainer PlayerList;
|
||||
public readonly Label PlayerCount;
|
||||
private readonly IGameHud _gameHud;
|
||||
|
||||
protected override Vector2? CustomSize => (500, 250);
|
||||
|
||||
public delegate void PlayerListRefresh();
|
||||
|
||||
public event PlayerListRefresh? OnPlayerListRefresh;
|
||||
|
||||
private readonly List<CommandButton> _adminButtons = new()
|
||||
{
|
||||
new KickCommandButton(),
|
||||
new BanCommandButton(),
|
||||
new DirectCommandButton("Admin Ghost", "aghost"),
|
||||
new TeleportCommandButton(),
|
||||
new DirectCommandButton("Permissions Panel", "permissions"),
|
||||
};
|
||||
private readonly List<CommandButton> _adminbusButtons = new()
|
||||
{
|
||||
new SpawnEntitiesCommandButton(),
|
||||
new SpawnTilesCommandButton(),
|
||||
new StationEventsCommandButton()
|
||||
};
|
||||
private readonly List<CommandButton> _atmosButtons = new()
|
||||
{
|
||||
new AddAtmosCommandButton(),
|
||||
new AddGasCommandButton(),
|
||||
new FillGasCommandButton(),
|
||||
new SetTempCommandButton(),
|
||||
};
|
||||
private readonly List<CommandButton> _roundButtons = new()
|
||||
{
|
||||
new DirectCommandButton("Start Round", "startround"),
|
||||
new DirectCommandButton("End Round", "endround"),
|
||||
new DirectCommandButton("Restart Round", "restartround"),
|
||||
};
|
||||
private readonly List<CommandButton> _serverButtons = new()
|
||||
{
|
||||
new DirectCommandButton("Reboot", "restart"),
|
||||
new DirectCommandButton("Shutdown", "shutdown"),
|
||||
};
|
||||
|
||||
private static readonly Color SeparatorColor = Color.FromHex("#3D4059");
|
||||
private class HSeparator : Control
|
||||
{
|
||||
public HSeparator()
|
||||
{
|
||||
AddChild(new PanelContainer {
|
||||
PanelOverride = new StyleBoxFlat
|
||||
{
|
||||
BackgroundColor = SeparatorColor,
|
||||
ContentMarginBottomOverride = 2, ContentMarginLeftOverride = 2
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private class VSeperator : PanelContainer
|
||||
{
|
||||
public VSeperator()
|
||||
{
|
||||
CustomMinimumSize = (2, 5);
|
||||
AddChild(new PanelContainer {
|
||||
PanelOverride = new StyleBoxFlat {
|
||||
BackgroundColor = SeparatorColor
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshPlayerList(Dictionary<string, string> namesToPlayers)
|
||||
{
|
||||
PlayerList.RemoveAllChildren();
|
||||
var playerManager = IoCManager.Resolve<IPlayerManager>();
|
||||
PlayerCount.Text = $"Players: {playerManager.PlayerCount}";
|
||||
|
||||
var altColor = Color.FromHex("#292B38");
|
||||
var defaultColor = Color.FromHex("#2F2F3B");
|
||||
|
||||
var header = new HBoxContainer
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SeparationOverride = 4,
|
||||
Children =
|
||||
{
|
||||
new Label { Text = "Name",
|
||||
SizeFlagsStretchRatio = 2f,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand },
|
||||
new VSeperator(),
|
||||
new Label { Text = "Player",
|
||||
SizeFlagsStretchRatio = 2f,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand },
|
||||
}
|
||||
};
|
||||
PlayerList.AddChild(new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat
|
||||
{
|
||||
BackgroundColor = altColor,
|
||||
},
|
||||
Children =
|
||||
{
|
||||
header
|
||||
}
|
||||
});
|
||||
PlayerList.AddChild(new HSeparator());
|
||||
|
||||
var useAltColor = false;
|
||||
foreach (var (name, player) in namesToPlayers)
|
||||
{
|
||||
var hBox = new HBoxContainer
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SeparationOverride = 4,
|
||||
Children =
|
||||
{
|
||||
new Label {
|
||||
Text = name,
|
||||
SizeFlagsStretchRatio = 2f,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
ClipText = true },
|
||||
new VSeperator(),
|
||||
new Label {
|
||||
Text = player,
|
||||
SizeFlagsStretchRatio = 2f,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
ClipText = true },
|
||||
}
|
||||
};
|
||||
PlayerList.AddChild(new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat
|
||||
{
|
||||
BackgroundColor = useAltColor ? altColor : defaultColor,
|
||||
},
|
||||
Children =
|
||||
{
|
||||
hBox
|
||||
}
|
||||
});
|
||||
useAltColor ^= true;
|
||||
}
|
||||
}
|
||||
|
||||
private void AddCommandButton(List<CommandButton> buttons, Control parent)
|
||||
{
|
||||
foreach (var cmd in buttons)
|
||||
{
|
||||
// Check if the player can do the command
|
||||
if (!cmd.CanPress())
|
||||
continue;
|
||||
|
||||
//TODO: make toggle?
|
||||
var button = new Button
|
||||
{
|
||||
Text = cmd.Name
|
||||
};
|
||||
button.OnPressed += cmd.ButtonPressed;
|
||||
parent.AddChild(button);
|
||||
}
|
||||
}
|
||||
|
||||
public AdminMenuWindow() //TODO: search for buttons?
|
||||
{
|
||||
_gameHud = IoCManager.Resolve<IGameHud>();
|
||||
Title = Loc.GetString("Admin Menu");
|
||||
|
||||
#region PlayerList
|
||||
// Players // List of all the players, their entities and status
|
||||
var playerTabContainer = new MarginContainer
|
||||
{
|
||||
MarginLeftOverride = 4,
|
||||
MarginTopOverride = 4,
|
||||
MarginRightOverride = 4,
|
||||
MarginBottomOverride = 4,
|
||||
CustomMinimumSize = (50, 50),
|
||||
};
|
||||
|
||||
PlayerCount = new Label
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 0.7f,
|
||||
};
|
||||
var refreshButton = new Button
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 0.3f,
|
||||
Text = "Refresh",
|
||||
};
|
||||
refreshButton.OnPressed += (_) => OnPlayerListRefresh?.Invoke();
|
||||
|
||||
PlayerList = new VBoxContainer();
|
||||
|
||||
var playerVBox = new VBoxContainer
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
Children =
|
||||
{
|
||||
new HBoxContainer
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
Children =
|
||||
{
|
||||
PlayerCount,
|
||||
refreshButton,
|
||||
}
|
||||
},
|
||||
new Control { CustomMinimumSize = (0, 5) },
|
||||
new ScrollContainer
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
Children =
|
||||
{
|
||||
PlayerList
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
playerTabContainer.AddChild(playerVBox);
|
||||
OnPlayerListRefresh?.Invoke();
|
||||
#endregion PlayerList
|
||||
|
||||
#region Admin Tab
|
||||
// Admin Tab // Actual admin stuff
|
||||
var adminTabContainer = new MarginContainer
|
||||
{
|
||||
MarginLeftOverride = 4,
|
||||
MarginTopOverride = 4,
|
||||
MarginRightOverride = 4,
|
||||
MarginBottomOverride = 4,
|
||||
CustomMinimumSize = (50, 50),
|
||||
};
|
||||
var adminButtonGrid = new GridContainer
|
||||
{
|
||||
Columns = 4,
|
||||
};
|
||||
AddCommandButton(_adminButtons, adminButtonGrid);
|
||||
adminTabContainer.AddChild(adminButtonGrid);
|
||||
#endregion
|
||||
|
||||
#region Adminbus
|
||||
// Adminbus // Fun Commands
|
||||
var adminbusTabContainer = new MarginContainer
|
||||
{
|
||||
MarginLeftOverride = 4,
|
||||
MarginTopOverride = 4,
|
||||
MarginRightOverride = 4,
|
||||
MarginBottomOverride = 4,
|
||||
CustomMinimumSize = (50, 50),
|
||||
};
|
||||
var adminbusButtonGrid = new GridContainer
|
||||
{
|
||||
Columns = 4,
|
||||
};
|
||||
AddCommandButton(_adminbusButtons, adminbusButtonGrid);
|
||||
adminbusTabContainer.AddChild(adminbusButtonGrid);
|
||||
#endregion
|
||||
|
||||
#region Atmos
|
||||
// Atmos // Commands to add, modify, or remove gases.
|
||||
var atmosTabContainer = new MarginContainer
|
||||
{
|
||||
MarginLeftOverride = 4,
|
||||
MarginTopOverride = 4,
|
||||
MarginRightOverride = 4,
|
||||
MarginBottomOverride = 4,
|
||||
CustomMinimumSize = (50, 50),
|
||||
};
|
||||
var atmosButtonGrid = new GridContainer
|
||||
{
|
||||
Columns = 4,
|
||||
};
|
||||
AddCommandButton(_atmosButtons, atmosButtonGrid);
|
||||
atmosTabContainer.AddChild(atmosButtonGrid);
|
||||
#endregion
|
||||
|
||||
#region Round
|
||||
// Round // Commands like Check Antags, End Round, RestartRound
|
||||
var roundTabContainer = new MarginContainer
|
||||
{
|
||||
MarginLeftOverride = 4,
|
||||
MarginTopOverride = 4,
|
||||
MarginRightOverride = 4,
|
||||
MarginBottomOverride = 4,
|
||||
CustomMinimumSize = (50, 50),
|
||||
};
|
||||
var roundButtonGrid = new GridContainer
|
||||
{
|
||||
Columns = 4,
|
||||
};
|
||||
AddCommandButton(_roundButtons, roundButtonGrid);
|
||||
roundTabContainer.AddChild(roundButtonGrid);
|
||||
#endregion
|
||||
|
||||
#region Server
|
||||
// Server // Commands like Restart, Shutdown
|
||||
var serverTabContainer = new MarginContainer
|
||||
{
|
||||
MarginLeftOverride = 4,
|
||||
MarginTopOverride = 4,
|
||||
MarginRightOverride = 4,
|
||||
MarginBottomOverride = 4,
|
||||
CustomMinimumSize = (50, 50),
|
||||
};
|
||||
var serverButtonGrid = new GridContainer
|
||||
{
|
||||
Columns = 4,
|
||||
};
|
||||
AddCommandButton(_serverButtons, serverButtonGrid);
|
||||
serverTabContainer.AddChild(serverButtonGrid);
|
||||
#endregion
|
||||
|
||||
|
||||
//The master menu that contains all of the tabs.
|
||||
MasterTabContainer = new TabContainer();
|
||||
|
||||
//Add all the tabs to the Master container.
|
||||
MasterTabContainer.AddChild(adminTabContainer);
|
||||
MasterTabContainer.SetTabTitle(0, Loc.GetString("Admin"));
|
||||
MasterTabContainer.AddChild(adminbusTabContainer);
|
||||
MasterTabContainer.SetTabTitle(1, Loc.GetString("Adminbus"));
|
||||
MasterTabContainer.AddChild(atmosTabContainer);
|
||||
MasterTabContainer.SetTabTitle(2, Loc.GetString("Atmos"));
|
||||
MasterTabContainer.AddChild(roundTabContainer);
|
||||
MasterTabContainer.SetTabTitle(3, Loc.GetString("Round"));
|
||||
MasterTabContainer.AddChild(serverTabContainer);
|
||||
MasterTabContainer.SetTabTitle(4, Loc.GetString("Server"));
|
||||
MasterTabContainer.AddChild(playerTabContainer);
|
||||
MasterTabContainer.SetTabTitle(5, Loc.GetString("Players"));
|
||||
Contents.AddChild(MasterTabContainer);
|
||||
//Request station events, so we can use them later
|
||||
IoCManager.Resolve<IStationEventManager>().RequestEvents();
|
||||
}
|
||||
|
||||
protected override void ExitedTree()
|
||||
{
|
||||
base.ExitedTree();
|
||||
_gameHud.AdminButtonDown = false;
|
||||
|
||||
}
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
base.EnteredTree();
|
||||
_gameHud.AdminButtonDown = true;
|
||||
}
|
||||
|
||||
#region CommandButtonBaseClass
|
||||
private abstract class CommandButton
|
||||
{
|
||||
public virtual string Name { get; }
|
||||
public virtual string RequiredCommand { get; }
|
||||
public abstract void ButtonPressed(ButtonEventArgs args);
|
||||
public virtual bool CanPress()
|
||||
{
|
||||
return RequiredCommand == string.Empty ||
|
||||
IoCManager.Resolve<IClientConGroupController>().CanCommand(RequiredCommand);
|
||||
}
|
||||
|
||||
public CommandButton() : this(string.Empty, string.Empty) {}
|
||||
public CommandButton(string name, string command)
|
||||
{
|
||||
Name = name;
|
||||
RequiredCommand = command;
|
||||
}
|
||||
}
|
||||
|
||||
// Button that opens a UI
|
||||
private abstract class UICommandButton : CommandButton
|
||||
{
|
||||
// The text on the submit button
|
||||
public virtual string? SubmitText { get; }
|
||||
/// <summary>
|
||||
/// Called when the Submit button is pressed
|
||||
/// </summary>
|
||||
/// <param name="val">Dictionary of the parameter names and values</param>
|
||||
public abstract void Submit();
|
||||
public override void ButtonPressed(ButtonEventArgs args)
|
||||
{
|
||||
var manager = IoCManager.Resolve<IAdminMenuManager>();
|
||||
var window = new CommandWindow(this);
|
||||
window.Submit += Submit;
|
||||
manager.OpenCommand(window);
|
||||
}
|
||||
// List of all the UI Elements
|
||||
public abstract List<CommandUIControl> UI { get; }
|
||||
}
|
||||
|
||||
// Button that directly calls a Command
|
||||
private class DirectCommandButton : CommandButton
|
||||
{
|
||||
public DirectCommandButton(string name, string command) : base(name, command) { }
|
||||
|
||||
public override void ButtonPressed(ButtonEventArgs args)
|
||||
{
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(RequiredCommand);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CommandButtons
|
||||
private class SpawnEntitiesCommandButton : CommandButton
|
||||
{
|
||||
public override string Name => "Spawn Entities";
|
||||
//TODO: override CanPress
|
||||
public override void ButtonPressed(ButtonEventArgs args)
|
||||
{
|
||||
var manager = IoCManager.Resolve<IAdminMenuManager>();
|
||||
var window = new EntitySpawnWindow(IoCManager.Resolve<IPlacementManager>(),
|
||||
IoCManager.Resolve<IPrototypeManager>(),
|
||||
IoCManager.Resolve<IResourceCache>());
|
||||
manager.OpenCommand(window);
|
||||
}
|
||||
}
|
||||
|
||||
private class SpawnTilesCommandButton : CommandButton
|
||||
{
|
||||
public override string Name => "Spawn Tiles";
|
||||
//TODO: override CanPress
|
||||
public override void ButtonPressed(ButtonEventArgs args)
|
||||
{
|
||||
var manager = IoCManager.Resolve<IAdminMenuManager>();
|
||||
var window = new TileSpawnWindow(IoCManager.Resolve<ITileDefinitionManager>(),
|
||||
IoCManager.Resolve<IPlacementManager>(),
|
||||
IoCManager.Resolve<IResourceCache>());
|
||||
manager.OpenCommand(window);
|
||||
}
|
||||
}
|
||||
|
||||
private class StationEventsCommandButton : UICommandButton
|
||||
{
|
||||
public override string Name => "Station Events";
|
||||
public override string RequiredCommand => "events";
|
||||
public override string? SubmitText => "Run";
|
||||
|
||||
private readonly CommandUIDropDown _eventsDropDown = new()
|
||||
{
|
||||
Name = "Event",
|
||||
GetData = () =>
|
||||
{
|
||||
var events = IoCManager.Resolve<IStationEventManager>().StationEvents.ToList();
|
||||
if (events.Count == 0)
|
||||
events.Add(Loc.GetString("Not loaded"));
|
||||
else
|
||||
events.Add(Loc.GetString("Random"));
|
||||
return events.ToList<object>();
|
||||
},
|
||||
GetDisplayName = (obj) => (string) obj,
|
||||
GetValueFromData = (obj) => ((string) obj).ToLower(),
|
||||
};
|
||||
|
||||
public override List<CommandUIControl> UI => new()
|
||||
{
|
||||
_eventsDropDown,
|
||||
new CommandUIButton
|
||||
{
|
||||
Name = "Pause",
|
||||
Handler = () =>
|
||||
{
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand("events pause");
|
||||
},
|
||||
},
|
||||
new CommandUIButton
|
||||
{
|
||||
Name = "Resume",
|
||||
Handler = () =>
|
||||
{
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand("events resume");
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
public override void Submit()
|
||||
{
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"events run \"{_eventsDropDown.GetValue()}\"");
|
||||
}
|
||||
}
|
||||
|
||||
private class KickCommandButton : UICommandButton
|
||||
{
|
||||
public override string Name => "Kick";
|
||||
public override string RequiredCommand => "kick";
|
||||
|
||||
private readonly CommandUIDropDown _playerDropDown = new()
|
||||
{
|
||||
Name = "Player",
|
||||
GetData = () => IoCManager.Resolve<IPlayerManager>().Sessions.ToList<object>(),
|
||||
GetDisplayName = (obj) => $"{((IPlayerSession) obj).Name} ({((IPlayerSession) obj).AttachedEntity?.Name})",
|
||||
GetValueFromData = (obj) => ((IPlayerSession) obj).Name,
|
||||
};
|
||||
private readonly CommandUILineEdit _reason = new()
|
||||
{
|
||||
Name = "Reason"
|
||||
};
|
||||
|
||||
public override List<CommandUIControl> UI => new()
|
||||
{
|
||||
_playerDropDown,
|
||||
_reason
|
||||
};
|
||||
|
||||
public override void Submit()
|
||||
{
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"kick \"{_playerDropDown.GetValue()}\" \"{CommandParsing.Escape(_reason.GetValue())}\"");
|
||||
}
|
||||
}
|
||||
|
||||
private class BanCommandButton : UICommandButton
|
||||
{
|
||||
public override string Name => "Ban";
|
||||
public override string RequiredCommand => "ban";
|
||||
|
||||
private readonly CommandUIDropDown _playerDropDown = new()
|
||||
{
|
||||
Name = "Player",
|
||||
GetData = () => IoCManager.Resolve<IPlayerManager>().Sessions.ToList<object>(),
|
||||
GetDisplayName = (obj) => $"{((IPlayerSession) obj).Name} ({((IPlayerSession) obj).AttachedEntity?.Name})",
|
||||
GetValueFromData = (obj) => ((IPlayerSession) obj).Name,
|
||||
};
|
||||
|
||||
private readonly CommandUILineEdit _reason = new()
|
||||
{
|
||||
Name = "Reason"
|
||||
};
|
||||
|
||||
private readonly CommandUILineEdit _minutes = new()
|
||||
{
|
||||
Name = "Minutes"
|
||||
};
|
||||
|
||||
public override List<CommandUIControl> UI => new()
|
||||
{
|
||||
_playerDropDown,
|
||||
_reason,
|
||||
_minutes
|
||||
};
|
||||
|
||||
public override void Submit()
|
||||
{
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"ban \"{_playerDropDown.GetValue()}\" \"{CommandParsing.Escape(_reason.GetValue())}\" \"{_minutes.GetValue()}");
|
||||
}
|
||||
}
|
||||
|
||||
private class TeleportCommandButton : UICommandButton
|
||||
{
|
||||
public override string Name => "Teleport";
|
||||
public override string RequiredCommand => "tpto";
|
||||
|
||||
private readonly CommandUIDropDown _playerDropDown = new()
|
||||
{
|
||||
Name = "Player",
|
||||
GetData = () => IoCManager.Resolve<IPlayerManager>().Sessions.ToList<object>(),
|
||||
GetDisplayName = (obj) => $"{((IPlayerSession) obj).Name} ({((IPlayerSession) obj).AttachedEntity?.Name})",
|
||||
GetValueFromData = (obj) => ((IPlayerSession) obj).Name,
|
||||
};
|
||||
|
||||
public override List<CommandUIControl> UI => new()
|
||||
{
|
||||
_playerDropDown
|
||||
};
|
||||
|
||||
public override void Submit()
|
||||
{
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"tpto \"{_playerDropDown.GetValue()}\"");
|
||||
}
|
||||
}
|
||||
|
||||
private class AddAtmosCommandButton : UICommandButton
|
||||
{
|
||||
public override string Name => "Add Atmos";
|
||||
public override string RequiredCommand => "addatmos";
|
||||
|
||||
private readonly CommandUIDropDown _grid = new()
|
||||
{
|
||||
Name = "Grid",
|
||||
GetData = () => IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0).ToList<object>(),
|
||||
GetDisplayName = (obj) => $"{((IMapGrid) obj).Index}{(IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity?.Transform.GridID == ((IMapGrid) obj).Index ? " (Current)" : "")}",
|
||||
GetValueFromData = (obj) => ((IMapGrid) obj).Index.ToString(),
|
||||
};
|
||||
|
||||
public override List<CommandUIControl> UI => new()
|
||||
{
|
||||
_grid,
|
||||
};
|
||||
|
||||
public override void Submit()
|
||||
{
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"addatmos {_grid.GetValue()}");
|
||||
}
|
||||
}
|
||||
|
||||
private class AddGasCommandButton : UICommandButton
|
||||
{
|
||||
public override string Name => "Add Gas";
|
||||
public override string RequiredCommand => "addgas";
|
||||
|
||||
private readonly CommandUIDropDown _grid = new()
|
||||
{
|
||||
Name = "Grid",
|
||||
GetData = () => IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0).ToList<object>(),
|
||||
GetDisplayName = (obj) => $"{((IMapGrid) obj).Index}{(IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity?.Transform.GridID == ((IMapGrid) obj).Index ? " (Current)" : "")}",
|
||||
GetValueFromData = (obj) => ((IMapGrid) obj).Index.ToString(),
|
||||
};
|
||||
|
||||
private readonly CommandUISpinBox _tileX = new()
|
||||
{
|
||||
Name = "TileX",
|
||||
};
|
||||
|
||||
private readonly CommandUISpinBox _tileY = new()
|
||||
{
|
||||
Name = "TileY",
|
||||
};
|
||||
|
||||
private readonly CommandUIDropDown _gas = new()
|
||||
{
|
||||
Name = "Gas",
|
||||
GetData = () =>
|
||||
{
|
||||
var atmosSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
return atmosSystem.Gases.ToList<object>();
|
||||
},
|
||||
GetDisplayName = (obj) => $"{((GasPrototype) obj).Name} ({((GasPrototype) obj).ID})",
|
||||
GetValueFromData = (obj) => ((GasPrototype) obj).ID.ToString(),
|
||||
};
|
||||
|
||||
private readonly CommandUISpinBox _amount = new()
|
||||
{
|
||||
Name = "Amount"
|
||||
};
|
||||
|
||||
public override List<CommandUIControl> UI => new()
|
||||
{
|
||||
_grid,
|
||||
_gas,
|
||||
_tileX,
|
||||
_tileY,
|
||||
_amount,
|
||||
};
|
||||
|
||||
public override void Submit()
|
||||
{
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"addgas {_tileX.GetValue()} {_tileY.GetValue()} {_grid.GetValue()} {_gas.GetValue()} {_amount.GetValue()}");
|
||||
}
|
||||
}
|
||||
|
||||
private class FillGasCommandButton : UICommandButton
|
||||
{
|
||||
public override string Name => "Fill Gas";
|
||||
public override string RequiredCommand => "fillgas";
|
||||
|
||||
private readonly CommandUIDropDown _grid = new()
|
||||
{
|
||||
Name = "Grid",
|
||||
GetData = () => IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0).ToList<object>(),
|
||||
GetDisplayName = (obj) => $"{((IMapGrid) obj).Index}{(IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity?.Transform.GridID == ((IMapGrid) obj).Index ? " (Current)" : "")}",
|
||||
GetValueFromData = (obj) => ((IMapGrid) obj).Index.ToString(),
|
||||
};
|
||||
|
||||
private readonly CommandUIDropDown _gas = new()
|
||||
{
|
||||
Name = "Gas",
|
||||
GetData = () =>
|
||||
{
|
||||
var atmosSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
return atmosSystem.Gases.ToList<object>();
|
||||
},
|
||||
GetDisplayName = (obj) => $"{((GasPrototype) obj).Name} ({((GasPrototype) obj).ID})",
|
||||
GetValueFromData = (obj) => ((GasPrototype) obj).ID.ToString(),
|
||||
};
|
||||
|
||||
private readonly CommandUISpinBox _amount = new()
|
||||
{
|
||||
Name = "Amount"
|
||||
};
|
||||
|
||||
public override List<CommandUIControl> UI => new()
|
||||
{
|
||||
_grid,
|
||||
_gas,
|
||||
_amount,
|
||||
};
|
||||
|
||||
public override void Submit()
|
||||
{
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"fillgas {_grid.GetValue()} {_gas.GetValue()} {_amount.GetValue()}");
|
||||
}
|
||||
}
|
||||
|
||||
private class SetTempCommandButton : UICommandButton
|
||||
{
|
||||
public override string Name => "Set temperature";
|
||||
public override string RequiredCommand => "settemp";
|
||||
|
||||
private readonly CommandUIDropDown _grid = new()
|
||||
{
|
||||
Name = "Grid",
|
||||
GetData = () => IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0).ToList<object>(),
|
||||
GetDisplayName = (obj) => $"{((IMapGrid) obj).Index}{(IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity?.Transform.GridID == ((IMapGrid) obj).Index ? " (Current)" : "")}",
|
||||
GetValueFromData = (obj) => ((IMapGrid) obj).Index.ToString(),
|
||||
};
|
||||
|
||||
private readonly CommandUISpinBox _tileX = new()
|
||||
{
|
||||
Name = "TileX",
|
||||
};
|
||||
|
||||
private readonly CommandUISpinBox _tileY = new()
|
||||
{
|
||||
Name = "TileY",
|
||||
};
|
||||
|
||||
private readonly CommandUISpinBox _temperature = new()
|
||||
{
|
||||
Name = "Temperature"
|
||||
};
|
||||
|
||||
public override List<CommandUIControl> UI => new()
|
||||
{
|
||||
_grid,
|
||||
_tileX,
|
||||
_tileY,
|
||||
_temperature,
|
||||
};
|
||||
|
||||
public override void Submit()
|
||||
{
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"settemp {_tileX.GetValue()} {_tileY.GetValue()} {_grid.GetValue()} {_temperature.GetValue()}");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CommandUIControls
|
||||
private abstract class CommandUIControl
|
||||
{
|
||||
public string? Name;
|
||||
public Control? Control;
|
||||
public abstract Control GetControl();
|
||||
public abstract string GetValue();
|
||||
}
|
||||
private class CommandUIDropDown : CommandUIControl
|
||||
{
|
||||
public Func<List<object>>? GetData;
|
||||
// The string that the player sees in the list
|
||||
public Func<object, string>? GetDisplayName;
|
||||
// The value that is given to Submit
|
||||
public Func<object, string>? GetValueFromData;
|
||||
// Cache
|
||||
protected List<object>? Data; //TODO: make this like IEnumerable or smth, so you don't have to do this ToList<object> shittery
|
||||
|
||||
public override Control GetControl() //TODO: fix optionbutton being shitty after moving the window
|
||||
{
|
||||
var opt = new OptionButton { CustomMinimumSize = (100, 0), SizeFlagsHorizontal = SizeFlags.FillExpand };
|
||||
Data = GetData!();
|
||||
foreach (var item in Data)
|
||||
opt.AddItem(GetDisplayName!(item));
|
||||
|
||||
opt.OnItemSelected += eventArgs => opt.SelectId(eventArgs.Id);
|
||||
Control = opt;
|
||||
return Control;
|
||||
}
|
||||
|
||||
public override string GetValue()
|
||||
{
|
||||
return GetValueFromData!(Data![((OptionButton)Control!).SelectedId]);
|
||||
}
|
||||
}
|
||||
private class CommandUICheckBox : CommandUIControl
|
||||
{
|
||||
public override Control GetControl()
|
||||
{
|
||||
Control = new CheckBox { SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.ShrinkCenter };
|
||||
return Control;
|
||||
}
|
||||
|
||||
public override string GetValue()
|
||||
{
|
||||
return ((CheckBox)Control!).Pressed ? "1" : "0";
|
||||
}
|
||||
}
|
||||
private class CommandUILineEdit : CommandUIControl
|
||||
{
|
||||
public override Control GetControl()
|
||||
{
|
||||
Control = new LineEdit { CustomMinimumSize = (100, 0), SizeFlagsHorizontal = SizeFlags.FillExpand };
|
||||
return Control;
|
||||
}
|
||||
|
||||
public override string GetValue()
|
||||
{
|
||||
return ((LineEdit)Control!).Text;
|
||||
}
|
||||
}
|
||||
|
||||
private class CommandUISpinBox : CommandUIControl
|
||||
{
|
||||
public override Control GetControl()
|
||||
{
|
||||
Control = new SpinBox { CustomMinimumSize = (100, 0), SizeFlagsHorizontal = SizeFlags.FillExpand };
|
||||
return Control;
|
||||
}
|
||||
|
||||
public override string GetValue()
|
||||
{
|
||||
return ((SpinBox)Control!).Value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private class CommandUIButton : CommandUIControl
|
||||
{
|
||||
public Action? Handler { get; set; }
|
||||
|
||||
public override Control GetControl()
|
||||
{
|
||||
Control = new Button {
|
||||
CustomMinimumSize = (100, 0),
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
Text = Name };
|
||||
return Control;
|
||||
}
|
||||
|
||||
public override string GetValue()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CommandWindow
|
||||
private class CommandWindow : SS14Window
|
||||
{
|
||||
List<CommandUIControl> _controls;
|
||||
public Action? Submit { get; set; }
|
||||
public CommandWindow(UICommandButton button)
|
||||
{
|
||||
Title = button.Name;
|
||||
_controls = button.UI;
|
||||
var container = new VBoxContainer //TODO: add margin between different controls
|
||||
{
|
||||
};
|
||||
// Init Controls in a hbox + a label
|
||||
foreach (var control in _controls)
|
||||
{
|
||||
var c = control.GetControl();
|
||||
if (c is Button)
|
||||
{
|
||||
((Button) c).OnPressed += (args) =>
|
||||
{
|
||||
((CommandUIButton) control).Handler?.Invoke();
|
||||
};
|
||||
container.AddChild(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
var label = new Label
|
||||
{
|
||||
Text = control.Name,
|
||||
CustomMinimumSize = (100, 0)
|
||||
};
|
||||
var divider = new Control
|
||||
{
|
||||
CustomMinimumSize = (50, 0)
|
||||
};
|
||||
var hbox = new HBoxContainer
|
||||
{
|
||||
Children =
|
||||
{
|
||||
label,
|
||||
divider,
|
||||
c
|
||||
},
|
||||
};
|
||||
container.AddChild(hbox);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// Init Submit Button
|
||||
var submitButton = new Button
|
||||
{
|
||||
Text = button.SubmitText ?? button.Name
|
||||
};
|
||||
submitButton.OnPressed += SubmitPressed;
|
||||
container.AddChild(submitButton);
|
||||
|
||||
Contents.AddChild(container);
|
||||
}
|
||||
|
||||
public void SubmitPressed(ButtonEventArgs args)
|
||||
{
|
||||
Submit?.Invoke();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
15
Content.Client/UserInterface/AdminMenu/AdminMenuWindow.xaml
Normal file
15
Content.Client/UserInterface/AdminMenu/AdminMenuWindow.xaml
Normal file
@@ -0,0 +1,15 @@
|
||||
<SS14Window
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:adminMenu="clr-namespace:Content.Client.UserInterface.AdminMenu.Tabs;assembly=Content.Client"
|
||||
xmlns:adminTab="clr-namespace:Content.Client.UserInterface.AdminMenu.Tabs.AdminTab"
|
||||
xmlns:adminbusTab="clr-namespace:Content.Client.UserInterface.AdminMenu.Tabs.AdminbusTab"
|
||||
xmlns:atmosTab="clr-namespace:Content.Client.UserInterface.AdminMenu.Tabs.AtmosTab">
|
||||
<TabContainer Name="MasterTabContainer">
|
||||
<adminTab:AdminTab />
|
||||
<adminbusTab:AdminbusTab />
|
||||
<atmosTab:AtmosTab />
|
||||
<adminMenu:RoundTab />
|
||||
<adminMenu:ServerTab />
|
||||
<adminMenu:PlayerTab Name="PlayerTabControl" />
|
||||
</TabContainer>
|
||||
</SS14Window>
|
||||
@@ -0,0 +1,58 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.UserInterface.AdminMenu.Tabs;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class AdminMenuWindow : SS14Window
|
||||
{
|
||||
[Dependency] private readonly IGameHud? _gameHud = default!;
|
||||
|
||||
public event PlayerTab.PlayerListRefresh? OnPlayerListRefresh
|
||||
{
|
||||
add => PlayerTabControl.OnPlayerListRefresh += value;
|
||||
remove => PlayerTabControl.OnPlayerListRefresh -= value;
|
||||
}
|
||||
|
||||
protected override Vector2? CustomSize => (500, 250);
|
||||
|
||||
public AdminMenuWindow()
|
||||
{
|
||||
Title = Loc.GetString("Admin Menu");
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
MasterTabContainer.SetTabTitle(0, Loc.GetString("Admin"));
|
||||
MasterTabContainer.SetTabTitle(1, Loc.GetString("Adminbus"));
|
||||
MasterTabContainer.SetTabTitle(2, Loc.GetString("Atmos"));
|
||||
MasterTabContainer.SetTabTitle(3, Loc.GetString("Round"));
|
||||
MasterTabContainer.SetTabTitle(4, Loc.GetString("Server"));
|
||||
MasterTabContainer.SetTabTitle(5, Loc.GetString("Players"));
|
||||
}
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
base.EnteredTree();
|
||||
if (_gameHud != null)
|
||||
_gameHud.AdminButtonDown = true;
|
||||
}
|
||||
|
||||
protected override void ExitedTree()
|
||||
{
|
||||
base.ExitedTree();
|
||||
if (_gameHud != null)
|
||||
_gameHud.AdminButtonDown = false;
|
||||
}
|
||||
|
||||
public void RefreshPlayerList(Dictionary<string, string> namesToPlayers)
|
||||
{
|
||||
PlayerTabControl.RefreshPlayerList(namesToPlayers);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#nullable enable
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu.CustomControls
|
||||
{
|
||||
public class CommandButton : Button
|
||||
{
|
||||
public string? Command { get; set; }
|
||||
|
||||
public CommandButton() : base()
|
||||
{
|
||||
OnPressed += Execute;
|
||||
}
|
||||
|
||||
protected virtual bool CanPress()
|
||||
{
|
||||
return string.IsNullOrEmpty(Command) ||
|
||||
IoCManager.Resolve<IClientConGroupController>().CanCommand(Command);
|
||||
}
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
if (!CanPress())
|
||||
{
|
||||
Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Execute(ButtonEventArgs obj)
|
||||
{
|
||||
// Default is to execute command
|
||||
if (!string.IsNullOrEmpty(Command))
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(Command);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu.CustomControls
|
||||
{
|
||||
public class UICommandButton : CommandButton
|
||||
{
|
||||
public Type? WindowType { get; set; }
|
||||
private SS14Window? _window;
|
||||
|
||||
protected override void Execute(ButtonEventArgs obj)
|
||||
{
|
||||
if (WindowType == null)
|
||||
return;
|
||||
_window = (SS14Window) IoCManager.Resolve<IDynamicTypeFactory>().CreateInstance(WindowType);
|
||||
_window?.OpenCentered();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<MarginContainer
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:amc="clr-namespace:Content.Client.UserInterface.AdminMenu.CustomControls"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:at="clr-namespace:Content.Client.UserInterface.AdminMenu.Tabs.AdminTab"
|
||||
MarginLeftOverride="4"
|
||||
MarginTopOverride="4" MarginRightOverride="4"
|
||||
MarginBottomOverride="4"
|
||||
CustomMinimumSize="50 50">
|
||||
<VBoxContainer>
|
||||
<GridContainer Columns="4">
|
||||
<amc:UICommandButton Command="kick" Text="{Loc Kick}" WindowType="{x:Type at:KickWindow}" />
|
||||
<amc:UICommandButton Command="ban" Text="{Loc Ban}" WindowType="{x:Type at:BanWindow}" />
|
||||
<amc:CommandButton Command="aghost" Text="{Loc Admin Ghost}" />
|
||||
<amc:UICommandButton Command="tpto" Text="{Loc Teleport}" WindowType="{x:Type at:TeleportWindow}" />
|
||||
<amc:CommandButton Command="permissions" Text="{Loc Permissions Panel}" />
|
||||
</GridContainer>
|
||||
</VBoxContainer>
|
||||
</MarginContainer>
|
||||
@@ -0,0 +1,11 @@
|
||||
#nullable enable
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu.Tabs.AdminTab
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class AdminTab : MarginContainer
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<SS14Window
|
||||
xmlns="https://spacestation14.io" Title="{Loc Ban}">
|
||||
<VBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc Player}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<OptionButton Name="PlayerOptions" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc Reason}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<LineEdit Name="ReasonLine" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc Minutes}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<LineEdit Name="MinutesLine" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<Button Name="SubmitButton" Text="{Loc Ban}" />
|
||||
</VBoxContainer>
|
||||
</SS14Window>
|
||||
@@ -0,0 +1,48 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu.Tabs.AdminTab
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
[UsedImplicitly]
|
||||
public partial class BanWindow : SS14Window
|
||||
{
|
||||
private IEnumerable<IPlayerSession>? _data;
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
// Fill the Option data
|
||||
_data = IoCManager.Resolve<IPlayerManager>().Sessions;
|
||||
foreach (var session in _data)
|
||||
{
|
||||
PlayerOptions.AddItem(GetDisplayName(session));
|
||||
}
|
||||
PlayerOptions.OnItemSelected += eventArgs => PlayerOptions.SelectId(eventArgs.Id);
|
||||
SubmitButton.OnPressed += SubmitButtonOnOnPressed;
|
||||
}
|
||||
|
||||
private static string GetDisplayName(IPlayerSession session)
|
||||
{
|
||||
return $"{session.Name} ({session.AttachedEntity?.Name})";
|
||||
}
|
||||
|
||||
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
if (_data == null)
|
||||
return;
|
||||
var dataList = _data.ToList();
|
||||
var session = dataList[PlayerOptions.SelectedId];
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
||||
$"ban \"{session.Name}\" \"{CommandParsing.Escape(ReasonLine.Text)}\" {MinutesLine.Text}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<SS14Window
|
||||
xmlns="https://spacestation14.io" Title="{Loc Kick}">
|
||||
<VBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc Player}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<OptionButton Name="PlayerOptions" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc Reason}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<LineEdit Name="ReasonLine" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<Button Name="SubmitButton" Text="{Loc Kick}" />
|
||||
</VBoxContainer>
|
||||
</SS14Window>
|
||||
@@ -0,0 +1,48 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu.Tabs.AdminTab
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
[UsedImplicitly]
|
||||
public partial class KickWindow : SS14Window
|
||||
{
|
||||
private IEnumerable<IPlayerSession>? _data;
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
// Fill the Option data
|
||||
_data = IoCManager.Resolve<IPlayerManager>().Sessions;
|
||||
foreach (var session in _data)
|
||||
{
|
||||
PlayerOptions.AddItem(GetDisplayName(session));
|
||||
}
|
||||
PlayerOptions.OnItemSelected += eventArgs => PlayerOptions.SelectId(eventArgs.Id);
|
||||
SubmitButton.OnPressed += SubmitButtonOnOnPressed;
|
||||
}
|
||||
|
||||
private static string GetDisplayName(IPlayerSession session)
|
||||
{
|
||||
return $"{session.Name} ({session.AttachedEntity?.Name})";
|
||||
}
|
||||
|
||||
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
if (_data == null)
|
||||
return;
|
||||
var dataList = _data.ToList();
|
||||
var session = dataList[PlayerOptions.SelectedId];
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
||||
$"kick \"{session.Name}\" \"{CommandParsing.Escape(ReasonLine.Text)}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<SS14Window
|
||||
xmlns="https://spacestation14.io" Title="{Loc Teleport}">
|
||||
<VBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc Player}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<OptionButton Name="PlayerOptions" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<Button Name="SubmitButton" Text="{Loc Teleport}" />
|
||||
</VBoxContainer>
|
||||
</SS14Window>
|
||||
@@ -0,0 +1,49 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu.Tabs.AdminTab
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
[UsedImplicitly]
|
||||
public partial class TeleportWindow : SS14Window
|
||||
{
|
||||
private IEnumerable<IPlayerSession>? _data;
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
// Fill the Option data
|
||||
_data = IoCManager.Resolve<IPlayerManager>().Sessions;
|
||||
foreach (var session in _data)
|
||||
{
|
||||
PlayerOptions.AddItem(GetDisplayName(session));
|
||||
}
|
||||
PlayerOptions.OnItemSelected += eventArgs => PlayerOptions.SelectId(eventArgs.Id);
|
||||
SubmitButton.OnPressed += SubmitButtonOnOnPressed;
|
||||
}
|
||||
|
||||
private static string GetDisplayName(IPlayerSession session)
|
||||
{
|
||||
return $"{session.Name} ({session.AttachedEntity?.Name})";
|
||||
}
|
||||
|
||||
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
// Find the value
|
||||
if (_data == null)
|
||||
return;
|
||||
var dataList = _data.ToList();
|
||||
var session = dataList[PlayerOptions.SelectedId];
|
||||
// Execute command
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
||||
$"tpto \"{session.Name}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<MarginContainer
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:amc="clr-namespace:Content.Client.UserInterface.AdminMenu.CustomControls"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:abt="clr-namespace:Content.Client.UserInterface.AdminMenu.Tabs.AdminbusTab"
|
||||
MarginLeftOverride="4"
|
||||
MarginTopOverride="4" MarginRightOverride="4"
|
||||
MarginBottomOverride="4"
|
||||
CustomMinimumSize="50 50">
|
||||
<GridContainer
|
||||
Columns="4">
|
||||
<amc:CommandButton Name="SpawnEntitiesButton" Text="{Loc Spawn Entities}" />
|
||||
<amc:CommandButton Name="SpawnTilesButton" Text="{Loc Spawn Tiles} " />
|
||||
<amc:UICommandButton Command="events" Text="{Loc Station Events}" WindowType="{x:Type abt:StationEventsWindow}" />
|
||||
</GridContainer>
|
||||
</MarginContainer>
|
||||
@@ -0,0 +1,42 @@
|
||||
#nullable enable
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Placement;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu.Tabs.AdminbusTab
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class AdminbusTab : MarginContainer
|
||||
{
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
private static void SpawnEntitiesButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
var manager = IoCManager.Resolve<IAdminMenuManager>();
|
||||
var window = new EntitySpawnWindow(IoCManager.Resolve<IPlacementManager>(),
|
||||
IoCManager.Resolve<IPrototypeManager>(),
|
||||
IoCManager.Resolve<IResourceCache>());
|
||||
manager.OpenCommand(window);
|
||||
}
|
||||
|
||||
private static void SpawnTilesButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
var manager = IoCManager.Resolve<IAdminMenuManager>();
|
||||
var window = new TileSpawnWindow(IoCManager.Resolve<ITileDefinitionManager>(),
|
||||
IoCManager.Resolve<IPlacementManager>(),
|
||||
IoCManager.Resolve<IResourceCache>());
|
||||
manager.OpenCommand(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<SS14Window
|
||||
xmlns="https://spacestation14.io" Title="Kick">
|
||||
<VBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc Event}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<OptionButton Name="EventsOptions" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<Button Name="PauseButton" Text="{Loc Pause}" />
|
||||
<Button Name="ResumeButton" Text="{Loc Resume}" />
|
||||
<Button Name="SubmitButton" Text="{Loc Run}" />
|
||||
</VBoxContainer>
|
||||
</SS14Window>
|
||||
@@ -0,0 +1,54 @@
|
||||
#nullable enable
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.StationEvents;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu.Tabs.AdminbusTab
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
[UsedImplicitly]
|
||||
public partial class StationEventsWindow : SS14Window
|
||||
{
|
||||
private List<string>? _data;
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
_data = IoCManager.Resolve<IStationEventManager>().StationEvents.ToList();
|
||||
_data.Add(_data.Any() ? Loc.GetString("Not loaded") : Loc.GetString("Random"));
|
||||
foreach (var stationEvent in _data)
|
||||
{
|
||||
EventsOptions.AddItem(stationEvent);
|
||||
}
|
||||
|
||||
EventsOptions.OnItemSelected += eventArgs => EventsOptions.SelectId(eventArgs.Id);
|
||||
PauseButton.OnPressed += PauseButtonOnOnPressed;
|
||||
ResumeButton.OnPressed += ResumeButtonOnOnPressed;
|
||||
SubmitButton.OnPressed += SubmitButtonOnOnPressed;
|
||||
}
|
||||
|
||||
private static void PauseButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand("events pause");
|
||||
}
|
||||
|
||||
private static void ResumeButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand("events resume");
|
||||
}
|
||||
|
||||
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
if (_data == null)
|
||||
return;
|
||||
var selectedEvent = _data[EventsOptions.SelectedId];
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"events run \"{selectedEvent}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<SS14Window
|
||||
xmlns="https://spacestation14.io" Title="{Loc Add Atmos}">
|
||||
<VBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc Grid}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<OptionButton Name="GridOptions" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<Button Name="SubmitButton" Text="{Loc Add Atmos}" />
|
||||
</VBoxContainer>
|
||||
</SS14Window>
|
||||
@@ -0,0 +1,43 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu.Tabs.AtmosTab
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
[UsedImplicitly]
|
||||
public partial class AddAtmosWindow : SS14Window
|
||||
{
|
||||
private IEnumerable<IMapGrid>? _data;
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
_data = IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0);
|
||||
foreach (var grid in _data)
|
||||
{
|
||||
var playerGrid = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity?.Transform.GridID;
|
||||
GridOptions.AddItem($"{grid.Index} {(playerGrid == grid.Index ? " (Current)" : "")}");
|
||||
}
|
||||
|
||||
GridOptions.OnItemSelected += eventArgs => GridOptions.SelectId(eventArgs.Id);
|
||||
SubmitButton.OnPressed += SubmitButtonOnOnPressed;
|
||||
}
|
||||
|
||||
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
if (_data == null)
|
||||
return;
|
||||
var dataList = _data.ToList();
|
||||
var selectedGrid = dataList[GridOptions.SelectedId].Index;
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"addatmos {selectedGrid}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<SS14Window
|
||||
xmlns="https://spacestation14.io" Title="{Loc Add Gas}">
|
||||
<VBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc Grid}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<OptionButton Name="GridOptions" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc TileX}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<SpinBox Name="TileXSpin" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc TileY}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<SpinBox Name="TileYSpin" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc Gas}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<OptionButton Name="GasOptions" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc Amount}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<SpinBox Name="AmountSpin" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<Button Name="SubmitButton" Text="{Loc Add Gas}" />
|
||||
</VBoxContainer>
|
||||
</SS14Window>
|
||||
@@ -0,0 +1,64 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Client.GameObjects.EntitySystems;
|
||||
using Content.Shared.Atmos;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu.Tabs.AtmosTab
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
[UsedImplicitly]
|
||||
public partial class AddGasWindow : SS14Window
|
||||
{
|
||||
private IEnumerable<IMapGrid>? _gridData;
|
||||
private IEnumerable<GasPrototype>? _gasData;
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
// Fill out grids
|
||||
_gridData = IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0);
|
||||
foreach (var grid in _gridData)
|
||||
{
|
||||
var playerGrid = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity?.Transform.GridID;
|
||||
GridOptions.AddItem($"{grid.Index} {(playerGrid == grid.Index ? " (Current)" : "")}");
|
||||
}
|
||||
|
||||
GridOptions.OnItemSelected += eventArgs => GridOptions.SelectId(eventArgs.Id);
|
||||
|
||||
// Fill out gases
|
||||
_gasData = EntitySystem.Get<AtmosphereSystem>().Gases;
|
||||
foreach (var gas in _gasData)
|
||||
{
|
||||
GasOptions.AddItem($"{gas.Name} ({gas.ID})");
|
||||
}
|
||||
|
||||
GasOptions.OnItemSelected += eventArgs => GasOptions.SelectId(eventArgs.Id);
|
||||
|
||||
SubmitButton.OnPressed += SubmitButtonOnOnPressed;
|
||||
}
|
||||
|
||||
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
if (_gridData == null || _gasData == null)
|
||||
return;
|
||||
|
||||
var gridList = _gridData.ToList();
|
||||
var gridIndex = gridList[GridOptions.SelectedId].Index;
|
||||
|
||||
var gasList = _gasData.ToList();
|
||||
var gasId = gasList[GasOptions.SelectedId].ID;
|
||||
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
||||
$"addgas {TileXSpin.Value} {TileYSpin.Value} {gridIndex} {gasId} {AmountSpin.Value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<MarginContainer
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:amc="clr-namespace:Content.Client.UserInterface.AdminMenu.CustomControls"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:at="clr-namespace:Content.Client.UserInterface.AdminMenu.Tabs.AtmosTab"
|
||||
MarginLeftOverride="4"
|
||||
MarginTopOverride="4" MarginRightOverride="4"
|
||||
MarginBottomOverride="4"
|
||||
CustomMinimumSize="50 50">
|
||||
<GridContainer Columns="4">
|
||||
<amc:UICommandButton Text="{Loc Add Atmos}" Command="addatmos" WindowType="{x:Type at:AddAtmosWindow}" />
|
||||
<amc:UICommandButton Text="{Loc Add Gas}" Command="addgas" WindowType="{x:Type at:AddGasWindow}" />
|
||||
<amc:UICommandButton Text="{Loc Fill Gas}" Command="fillgas" WindowType="{x:Type at:FillGasWindow}" />
|
||||
<amc:UICommandButton Text="{Loc Set Temperature}" Command="settemp"
|
||||
WindowType="{x:Type at:SetTemperatureWindow}" />
|
||||
</GridContainer>
|
||||
</MarginContainer>
|
||||
@@ -0,0 +1,11 @@
|
||||
#nullable enable
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu.Tabs.AtmosTab
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class AtmosTab : MarginContainer
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<SS14Window
|
||||
xmlns="https://spacestation14.io" Title="{Loc Fill Gas}">
|
||||
<VBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc Grid}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<OptionButton Name="GridOptions" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc Gas}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<OptionButton Name="GasOptions" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc Amount}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<SpinBox Name="AmountSpin" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<Button Name="SubmitButton" Text="{Loc Fill Gas}" />
|
||||
</VBoxContainer>
|
||||
</SS14Window>
|
||||
@@ -0,0 +1,64 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Client.GameObjects.EntitySystems;
|
||||
using Content.Shared.Atmos;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu.Tabs.AtmosTab
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
[UsedImplicitly]
|
||||
public partial class FillGasWindow : SS14Window
|
||||
{
|
||||
private IEnumerable<IMapGrid>? _gridData;
|
||||
private IEnumerable<GasPrototype>? _gasData;
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
// Fill out grids
|
||||
_gridData = IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0);
|
||||
foreach (var grid in _gridData)
|
||||
{
|
||||
var playerGrid = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity?.Transform.GridID;
|
||||
GridOptions.AddItem($"{grid.Index} {(playerGrid == grid.Index ? " (Current)" : "")}");
|
||||
}
|
||||
|
||||
GridOptions.OnItemSelected += eventArgs => GridOptions.SelectId(eventArgs.Id);
|
||||
|
||||
// Fill out gases
|
||||
_gasData = EntitySystem.Get<AtmosphereSystem>().Gases;
|
||||
foreach (var gas in _gasData)
|
||||
{
|
||||
GasOptions.AddItem($"{gas.Name} ({gas.ID})");
|
||||
}
|
||||
|
||||
GasOptions.OnItemSelected += eventArgs => GasOptions.SelectId(eventArgs.Id);
|
||||
|
||||
SubmitButton.OnPressed += SubmitButtonOnOnPressed;
|
||||
}
|
||||
|
||||
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
if (_gridData == null || _gasData == null)
|
||||
return;
|
||||
|
||||
var gridList = _gridData.ToList();
|
||||
var gridIndex = gridList[GridOptions.SelectedId].Index;
|
||||
|
||||
var gasList = _gasData.ToList();
|
||||
var gasId = gasList[GasOptions.SelectedId].ID;
|
||||
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
||||
$"fillgas {gridIndex} {gasId} {AmountSpin.Value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<SS14Window
|
||||
xmlns="https://spacestation14.io" Title="{Loc Set Temperature}">
|
||||
<VBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc Grid}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<OptionButton Name="GridOptions" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc TileX}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<SpinBox Name="TileXSpin" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc TileY}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<SpinBox Name="TileYSpin" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<HBoxContainer>
|
||||
<Label Text="{Loc Temperature}" CustomMinimumSize="100 0" />
|
||||
<Control CustomMinimumSize="50 0" />
|
||||
<SpinBox Name="TemperatureSpin" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||
</HBoxContainer>
|
||||
<Button Name="SubmitButton" Text="{Loc Set Temperature}" />
|
||||
</VBoxContainer>
|
||||
</SS14Window>
|
||||
@@ -0,0 +1,44 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu.Tabs.AtmosTab
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
[UsedImplicitly]
|
||||
public partial class SetTemperatureWindow : SS14Window
|
||||
{
|
||||
private IEnumerable<IMapGrid>? _data;
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
_data = IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0);
|
||||
foreach (var grid in _data)
|
||||
{
|
||||
var playerGrid = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity?.Transform.GridID;
|
||||
GridOptions.AddItem($"{grid.Index} {(playerGrid == grid.Index ? " (Current)" : "")}");
|
||||
}
|
||||
|
||||
GridOptions.OnItemSelected += eventArgs => GridOptions.SelectId(eventArgs.Id);
|
||||
SubmitButton.OnPressed += SubmitButtonOnOnPressed;
|
||||
}
|
||||
|
||||
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
if (_data == null)
|
||||
return;
|
||||
var dataList = _data.ToList();
|
||||
var selectedGrid = dataList[GridOptions.SelectedId].Index;
|
||||
IoCManager.Resolve<IClientConsoleHost>()
|
||||
.ExecuteCommand($"settemp {TileXSpin.Value} {TileYSpin.Value} {selectedGrid} {TemperatureSpin.Value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Content.Client/UserInterface/AdminMenu/Tabs/PlayerTab.xaml
Normal file
15
Content.Client/UserInterface/AdminMenu/Tabs/PlayerTab.xaml
Normal file
@@ -0,0 +1,15 @@
|
||||
<MarginContainer
|
||||
xmlns="https://spacestation14.io">
|
||||
<VBoxContainer SizeFlagsVertical="Fill">
|
||||
<HBoxContainer SizeFlagsVertical="Fill">
|
||||
<Label Name="PlayerCount" SizeFlagsHorizontal="FillExpand" SizeFlagsStretchRatio="0.7"
|
||||
Text="{Loc Player Count}" />
|
||||
<Button Name="RefreshButton" SizeFlagsHorizontal="FillExpand" SizeFlagsStretchRatio="0.3"
|
||||
Text="{Loc Refresh}" />
|
||||
</HBoxContainer>
|
||||
<Control CustomMinimumSize="0 5" />
|
||||
<ScrollContainer SizeFlagsHorizontal="FillExpand" SizeFlagsVertical="FillExpand">
|
||||
<VBoxContainer Name="PlayerList" />
|
||||
</ScrollContainer>
|
||||
</VBoxContainer>
|
||||
</MarginContainer>
|
||||
150
Content.Client/UserInterface/AdminMenu/Tabs/PlayerTab.xaml.cs
Normal file
150
Content.Client/UserInterface/AdminMenu/Tabs/PlayerTab.xaml.cs
Normal file
@@ -0,0 +1,150 @@
|
||||
#nullable enable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu.Tabs
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class PlayerTab : MarginContainer
|
||||
{
|
||||
public delegate void PlayerListRefresh();
|
||||
|
||||
public event PlayerListRefresh? OnPlayerListRefresh;
|
||||
|
||||
public PlayerTab()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
RobustXamlLoader.Load(this);
|
||||
RefreshButton.OnPressed += (_) => OnPlayerListRefresh?.Invoke();
|
||||
}
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
OnPlayerListRefresh?.Invoke();
|
||||
}
|
||||
|
||||
public void RefreshPlayerList(Dictionary<string, string> namesToPlayers)
|
||||
{
|
||||
PlayerList.RemoveAllChildren();
|
||||
var playerManager = IoCManager.Resolve<IPlayerManager>();
|
||||
PlayerCount.Text = $"Players: {playerManager.PlayerCount}";
|
||||
|
||||
var altColor = Color.FromHex("#292B38");
|
||||
var defaultColor = Color.FromHex("#2F2F3B");
|
||||
|
||||
var header = new HBoxContainer
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SeparationOverride = 4,
|
||||
Children =
|
||||
{
|
||||
new Label
|
||||
{
|
||||
Text = "Name",
|
||||
SizeFlagsStretchRatio = 2f,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand
|
||||
},
|
||||
new VSeparator(),
|
||||
new Label
|
||||
{
|
||||
Text = "Player",
|
||||
SizeFlagsStretchRatio = 2f,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand
|
||||
}
|
||||
}
|
||||
};
|
||||
PlayerList.AddChild(new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat
|
||||
{
|
||||
BackgroundColor = altColor,
|
||||
},
|
||||
Children =
|
||||
{
|
||||
header
|
||||
}
|
||||
});
|
||||
PlayerList.AddChild(new HSeparator());
|
||||
|
||||
var useAltColor = false;
|
||||
foreach (var (name, player) in namesToPlayers)
|
||||
{
|
||||
var hBox = new HBoxContainer
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SeparationOverride = 4,
|
||||
Children =
|
||||
{
|
||||
new Label
|
||||
{
|
||||
Text = player,
|
||||
SizeFlagsStretchRatio = 2f,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
ClipText = true
|
||||
},
|
||||
new VSeparator(),
|
||||
new Label
|
||||
{
|
||||
Text = player,
|
||||
SizeFlagsStretchRatio = 2f,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
ClipText = true
|
||||
}
|
||||
}
|
||||
};
|
||||
PlayerList.AddChild(new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat
|
||||
{
|
||||
BackgroundColor = useAltColor ? altColor : defaultColor,
|
||||
},
|
||||
Children =
|
||||
{
|
||||
hBox
|
||||
}
|
||||
});
|
||||
useAltColor ^= true;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Color SeparatorColor = Color.FromHex("#3D4059");
|
||||
|
||||
private class VSeparator : PanelContainer
|
||||
{
|
||||
public VSeparator()
|
||||
{
|
||||
CustomMinimumSize = (2, 5);
|
||||
AddChild(new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat
|
||||
{
|
||||
BackgroundColor = SeparatorColor
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private class HSeparator : Control
|
||||
{
|
||||
public HSeparator()
|
||||
{
|
||||
AddChild(new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat
|
||||
{
|
||||
BackgroundColor = SeparatorColor,
|
||||
ContentMarginBottomOverride = 2, ContentMarginLeftOverride = 2
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Content.Client/UserInterface/AdminMenu/Tabs/RoundTab.xaml
Normal file
14
Content.Client/UserInterface/AdminMenu/Tabs/RoundTab.xaml
Normal file
@@ -0,0 +1,14 @@
|
||||
<MarginContainer
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:amc="clr-namespace:Content.Client.UserInterface.AdminMenu.CustomControls"
|
||||
MarginLeftOverride="4"
|
||||
MarginTopOverride="4" MarginRightOverride="4"
|
||||
MarginBottomOverride="4"
|
||||
CustomMinimumSize="50 50">
|
||||
<GridContainer
|
||||
Columns="4">
|
||||
<amc:CommandButton Command="startround" Text="{Loc Start Round}" />
|
||||
<amc:CommandButton Command="endround" Text="{Loc End Round}" />
|
||||
<amc:CommandButton Command="restartround" Text="{Loc Restart Round}" />
|
||||
</GridContainer>
|
||||
</MarginContainer>
|
||||
11
Content.Client/UserInterface/AdminMenu/Tabs/RoundTab.xaml.cs
Normal file
11
Content.Client/UserInterface/AdminMenu/Tabs/RoundTab.xaml.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
#nullable enable
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu.Tabs
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class RoundTab : MarginContainer
|
||||
{
|
||||
}
|
||||
}
|
||||
13
Content.Client/UserInterface/AdminMenu/Tabs/ServerTab.xaml
Normal file
13
Content.Client/UserInterface/AdminMenu/Tabs/ServerTab.xaml
Normal file
@@ -0,0 +1,13 @@
|
||||
<MarginContainer
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:amc="clr-namespace:Content.Client.UserInterface.AdminMenu.CustomControls"
|
||||
MarginLeftOverride="4"
|
||||
MarginTopOverride="4" MarginRightOverride="4"
|
||||
MarginBottomOverride="4"
|
||||
CustomMinimumSize="50 50">
|
||||
<GridContainer
|
||||
Columns="4" >
|
||||
<amc:CommandButton Command="restart" Text="{Loc Reboot}"></amc:CommandButton>
|
||||
<amc:CommandButton Command="shutdown" Text="{Loc Shutdown}"></amc:CommandButton>
|
||||
</GridContainer>
|
||||
</MarginContainer>
|
||||
@@ -0,0 +1,14 @@
|
||||
#nullable enable
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu.Tabs
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class ServerTab : MarginContainer
|
||||
{
|
||||
public ServerTab()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user