Converts AdminMenu to partially use XAML (#3231)
This commit is contained in:
@@ -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}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user