Improves kick, teleport and ban menus (#3312)
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<VBoxContainer
|
||||
xmlns="https://spacestation14.io">
|
||||
<Control CustomMinimumSize="0 5" />
|
||||
<HBoxContainer>
|
||||
<!-- <Label Text="{Loc Search}" CustomMinimumSize="100 0" /> -->
|
||||
<!-- <Control CustomMinimumSize="50 0" /> -->
|
||||
<LineEdit Name="FilterLineEdit" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" PlaceHolder="{Loc Filter}"/>
|
||||
</HBoxContainer>
|
||||
<!-- <Control CustomMinimumSize="0 5" /> -->
|
||||
<ItemList
|
||||
Name="PlayerItemList" SelectMode="Single" SizeFlagsVertical="FillExpand" SizeFlagsHorizontal="FillExpand"
|
||||
CustomMinimumSize="100 100" />
|
||||
</VBoxContainer>
|
||||
@@ -0,0 +1,78 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.UserInterface.AdminMenu.CustomControls
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class PlayerListControl : VBoxContainer
|
||||
{
|
||||
private List<IPlayerSession>? _data;
|
||||
|
||||
public event Action<IPlayerSession?>? OnSelectionChanged;
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
// Fill the Option data
|
||||
_data = IoCManager.Resolve<IPlayerManager>().Sessions.ToList();
|
||||
PopulateList();
|
||||
PlayerItemList.OnItemSelected += PlayerItemListOnOnItemSelected;
|
||||
PlayerItemList.OnItemDeselected += PlayerItemListOnOnItemDeselected;
|
||||
FilterLineEdit.OnTextChanged += FilterLineEditOnOnTextEntered;
|
||||
}
|
||||
|
||||
private void FilterLineEditOnOnTextEntered(LineEdit.LineEditEventArgs obj)
|
||||
{
|
||||
PopulateList(FilterLineEdit.Text);
|
||||
}
|
||||
|
||||
private static string GetDisplayName(IPlayerSession session)
|
||||
{
|
||||
return $"{session.Name} ({session.AttachedEntity?.Name})";
|
||||
}
|
||||
|
||||
private void PlayerItemListOnOnItemSelected(ItemList.ItemListSelectedEventArgs obj)
|
||||
{
|
||||
var selectedPlayer = (IPlayerSession) obj.ItemList[obj.ItemIndex].Metadata!;
|
||||
OnSelectionChanged?.Invoke(selectedPlayer);
|
||||
}
|
||||
|
||||
private void PlayerItemListOnOnItemDeselected(ItemList.ItemListDeselectedEventArgs obj)
|
||||
{
|
||||
OnSelectionChanged?.Invoke(null);
|
||||
}
|
||||
|
||||
private void PopulateList(string? filter = null)
|
||||
{
|
||||
// _data should never be null here
|
||||
if (_data == null)
|
||||
return;
|
||||
PlayerItemList.Clear();
|
||||
foreach (var session in _data)
|
||||
{
|
||||
var displayName = GetDisplayName(session);
|
||||
if (!string.IsNullOrEmpty(filter) &&
|
||||
!displayName.ToLowerInvariant().Contains(filter.Trim().ToLowerInvariant()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayerItemList.Add(new ItemList.Item(PlayerItemList)
|
||||
{
|
||||
Metadata = session,
|
||||
Text = displayName
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearSelection()
|
||||
{
|
||||
PlayerItemList.ClearSelected();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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)}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user