Improves kick, teleport and ban menus (#3312)

This commit is contained in:
Leo
2021-02-19 15:26:34 -03:00
committed by GitHub
parent d1b5a31397
commit 19ca611f5f
8 changed files with 126 additions and 67 deletions

View File

@@ -1,10 +1,12 @@
<SS14Window
xmlns="https://spacestation14.io" Title="{Loc Ban}">
xmlns="https://spacestation14.io"
xmlns:cc="clr-namespace:Content.Client.UserInterface.AdminMenu.CustomControls"
Title="{Loc Ban}" CustomMinimumSize="425 162">
<VBoxContainer>
<HBoxContainer>
<Label Text="{Loc Player}" CustomMinimumSize="100 0" />
<Control CustomMinimumSize="50 0" />
<OptionButton Name="PlayerOptions" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
<LineEdit Name="PlayerNameLine" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
</HBoxContainer>
<HBoxContainer>
<Label Text="{Loc Reason}" CustomMinimumSize="100 0" />
@@ -14,8 +16,9 @@
<HBoxContainer>
<Label Text="{Loc Minutes}" CustomMinimumSize="100 0" />
<Control CustomMinimumSize="50 0" />
<LineEdit Name="MinutesLine" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
<LineEdit Name="MinutesLine" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" PlaceHolder="{Loc 0 minutes for a permanent ban}" />
</HBoxContainer>
<Control CustomMinimumSize="50 0" />
<Button Name="SubmitButton" Text="{Loc Ban}" />
</VBoxContainer>
</SS14Window>

View File

@@ -1,10 +1,7 @@
#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;
@@ -16,33 +13,23 @@ namespace Content.Client.UserInterface.AdminMenu.Tabs.AdminTab
[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);
PlayerNameLine.OnTextChanged += PlayerNameLineOnOnTextChanged;
SubmitButton.OnPressed += SubmitButtonOnOnPressed;
}
private static string GetDisplayName(IPlayerSession session)
private void PlayerNameLineOnOnTextChanged(LineEdit.LineEditEventArgs obj)
{
return $"{session.Name} ({session.AttachedEntity?.Name})";
SubmitButton.Disabled = string.IsNullOrEmpty(PlayerNameLine.Text);
}
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
{
if (_data == null)
return;
var dataList = _data.ToList();
var session = dataList[PlayerOptions.SelectedId];
// Small verification if Player Name exists
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
$"ban \"{session.Name}\" \"{CommandParsing.Escape(ReasonLine.Text)}\" {MinutesLine.Text}");
$"ban \"{PlayerNameLine.Text}\" \"{CommandParsing.Escape(ReasonLine.Text)}\" {MinutesLine.Text}");
}
}
}

View File

@@ -1,16 +1,14 @@
<SS14Window
xmlns="https://spacestation14.io" Title="{Loc Kick}">
xmlns="https://spacestation14.io"
xmlns:cc="clr-namespace:Content.Client.UserInterface.AdminMenu.CustomControls"
Title="{Loc Kick}" CustomMinimumSize="425 272">
<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>
<cc:PlayerListControl Name="PlayerList" />
<Button Name="SubmitButton" Text="{Loc Kick}" />
</VBoxContainer>
</SS14Window>

View File

@@ -1,6 +1,4 @@
#nullable enable
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Robust.Client.AutoGenerated;
using Robust.Client.Console;
@@ -16,33 +14,26 @@ namespace Content.Client.UserInterface.AdminMenu.Tabs.AdminTab
[UsedImplicitly]
public partial class KickWindow : SS14Window
{
private IEnumerable<IPlayerSession>? _data;
private IPlayerSession? _selectedSession;
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;
PlayerList.OnSelectionChanged += OnListOnOnSelectionChanged;
}
private static string GetDisplayName(IPlayerSession session)
private void OnListOnOnSelectionChanged(IPlayerSession? obj)
{
return $"{session.Name} ({session.AttachedEntity?.Name})";
_selectedSession = obj;
SubmitButton.Disabled = _selectedSession == null;
}
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
{
if (_data == null)
if (_selectedSession == null)
return;
var dataList = _data.ToList();
var session = dataList[PlayerOptions.SelectedId];
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
$"kick \"{session.Name}\" \"{CommandParsing.Escape(ReasonLine.Text)}\"");
$"kick \"{_selectedSession.Name}\" \"{CommandParsing.Escape(ReasonLine.Text)}\"");
}
}
}

View File

@@ -1,11 +1,9 @@
<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>
xmlns="https://spacestation14.io"
xmlns:cc="clr-namespace:Content.Client.UserInterface.AdminMenu.CustomControls"
Title="{Loc Teleport}" CustomMinimumSize="425 230">
<VBoxContainer SizeFlagsVertical="FillExpand">
<cc:PlayerListControl Name="PlayerList" />
<Button Name="SubmitButton" Text="{Loc Teleport}" />
</VBoxContainer>
</SS14Window>

View File

@@ -1,7 +1,6 @@
#nullable enable
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using NFluidsynth;
using Robust.Client.AutoGenerated;
using Robust.Client.Console;
using Robust.Client.Player;
@@ -15,35 +14,27 @@ namespace Content.Client.UserInterface.AdminMenu.Tabs.AdminTab
[UsedImplicitly]
public partial class TeleportWindow : SS14Window
{
private IEnumerable<IPlayerSession>? _data;
private IPlayerSession? _selectedSession;
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;
PlayerList.OnSelectionChanged += OnListOnOnSelectionChanged;
}
private static string GetDisplayName(IPlayerSession session)
private void OnListOnOnSelectionChanged(IPlayerSession? obj)
{
return $"{session.Name} ({session.AttachedEntity?.Name})";
_selectedSession = obj;
SubmitButton.Disabled = _selectedSession == null;
}
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
{
// Find the value
if (_data == null)
if (_selectedSession == null)
return;
var dataList = _data.ToList();
var session = dataList[PlayerOptions.SelectedId];
// Execute command
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
$"tpto \"{session.Name}\"");
$"tpto \"{_selectedSession.Name}\"");
}
}
}