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
|
<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>
|
<VBoxContainer>
|
||||||
<HBoxContainer>
|
<HBoxContainer>
|
||||||
<Label Text="{Loc Player}" CustomMinimumSize="100 0" />
|
<Label Text="{Loc Player}" CustomMinimumSize="100 0" />
|
||||||
<Control CustomMinimumSize="50 0" />
|
<Control CustomMinimumSize="50 0" />
|
||||||
<OptionButton Name="PlayerOptions" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
<LineEdit Name="PlayerNameLine" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||||
</HBoxContainer>
|
</HBoxContainer>
|
||||||
<HBoxContainer>
|
<HBoxContainer>
|
||||||
<Label Text="{Loc Reason}" CustomMinimumSize="100 0" />
|
<Label Text="{Loc Reason}" CustomMinimumSize="100 0" />
|
||||||
@@ -14,8 +16,9 @@
|
|||||||
<HBoxContainer>
|
<HBoxContainer>
|
||||||
<Label Text="{Loc Minutes}" CustomMinimumSize="100 0" />
|
<Label Text="{Loc Minutes}" CustomMinimumSize="100 0" />
|
||||||
<Control CustomMinimumSize="50 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>
|
</HBoxContainer>
|
||||||
|
<Control CustomMinimumSize="50 0" />
|
||||||
<Button Name="SubmitButton" Text="{Loc Ban}" />
|
<Button Name="SubmitButton" Text="{Loc Ban}" />
|
||||||
</VBoxContainer>
|
</VBoxContainer>
|
||||||
</SS14Window>
|
</SS14Window>
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Client.AutoGenerated;
|
using Robust.Client.AutoGenerated;
|
||||||
using Robust.Client.Console;
|
using Robust.Client.Console;
|
||||||
using Robust.Client.Player;
|
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
@@ -16,33 +13,23 @@ namespace Content.Client.UserInterface.AdminMenu.Tabs.AdminTab
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public partial class BanWindow : SS14Window
|
public partial class BanWindow : SS14Window
|
||||||
{
|
{
|
||||||
private IEnumerable<IPlayerSession>? _data;
|
|
||||||
|
|
||||||
protected override void EnteredTree()
|
protected override void EnteredTree()
|
||||||
{
|
{
|
||||||
// Fill the Option data
|
PlayerNameLine.OnTextChanged += PlayerNameLineOnOnTextChanged;
|
||||||
_data = IoCManager.Resolve<IPlayerManager>().Sessions;
|
|
||||||
foreach (var session in _data)
|
|
||||||
{
|
|
||||||
PlayerOptions.AddItem(GetDisplayName(session));
|
|
||||||
}
|
|
||||||
PlayerOptions.OnItemSelected += eventArgs => PlayerOptions.SelectId(eventArgs.Id);
|
|
||||||
SubmitButton.OnPressed += SubmitButtonOnOnPressed;
|
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)
|
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||||
{
|
{
|
||||||
if (_data == null)
|
// Small verification if Player Name exists
|
||||||
return;
|
|
||||||
var dataList = _data.ToList();
|
|
||||||
var session = dataList[PlayerOptions.SelectedId];
|
|
||||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
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
|
<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>
|
<VBoxContainer>
|
||||||
<HBoxContainer>
|
|
||||||
<Label Text="{Loc Player}" CustomMinimumSize="100 0" />
|
|
||||||
<Control CustomMinimumSize="50 0" />
|
|
||||||
<OptionButton Name="PlayerOptions" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
|
||||||
</HBoxContainer>
|
|
||||||
<HBoxContainer>
|
<HBoxContainer>
|
||||||
<Label Text="{Loc Reason}" CustomMinimumSize="100 0" />
|
<Label Text="{Loc Reason}" CustomMinimumSize="100 0" />
|
||||||
<Control CustomMinimumSize="50 0" />
|
<Control CustomMinimumSize="50 0" />
|
||||||
<LineEdit Name="ReasonLine" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
<LineEdit Name="ReasonLine" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
||||||
</HBoxContainer>
|
</HBoxContainer>
|
||||||
|
<cc:PlayerListControl Name="PlayerList" />
|
||||||
<Button Name="SubmitButton" Text="{Loc Kick}" />
|
<Button Name="SubmitButton" Text="{Loc Kick}" />
|
||||||
</VBoxContainer>
|
</VBoxContainer>
|
||||||
</SS14Window>
|
</SS14Window>
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Client.AutoGenerated;
|
using Robust.Client.AutoGenerated;
|
||||||
using Robust.Client.Console;
|
using Robust.Client.Console;
|
||||||
@@ -16,33 +14,26 @@ namespace Content.Client.UserInterface.AdminMenu.Tabs.AdminTab
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public partial class KickWindow : SS14Window
|
public partial class KickWindow : SS14Window
|
||||||
{
|
{
|
||||||
private IEnumerable<IPlayerSession>? _data;
|
private IPlayerSession? _selectedSession;
|
||||||
|
|
||||||
protected override void EnteredTree()
|
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;
|
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)
|
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||||
{
|
{
|
||||||
if (_data == null)
|
if (_selectedSession == null)
|
||||||
return;
|
return;
|
||||||
var dataList = _data.ToList();
|
|
||||||
var session = dataList[PlayerOptions.SelectedId];
|
|
||||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
||||||
$"kick \"{session.Name}\" \"{CommandParsing.Escape(ReasonLine.Text)}\"");
|
$"kick \"{_selectedSession.Name}\" \"{CommandParsing.Escape(ReasonLine.Text)}\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
<SS14Window
|
<SS14Window
|
||||||
xmlns="https://spacestation14.io" Title="{Loc Teleport}">
|
xmlns="https://spacestation14.io"
|
||||||
<VBoxContainer>
|
xmlns:cc="clr-namespace:Content.Client.UserInterface.AdminMenu.CustomControls"
|
||||||
<HBoxContainer>
|
Title="{Loc Teleport}" CustomMinimumSize="425 230">
|
||||||
<Label Text="{Loc Player}" CustomMinimumSize="100 0" />
|
<VBoxContainer SizeFlagsVertical="FillExpand">
|
||||||
<Control CustomMinimumSize="50 0" />
|
<cc:PlayerListControl Name="PlayerList" />
|
||||||
<OptionButton Name="PlayerOptions" CustomMinimumSize="100 0" SizeFlagsHorizontal="FillExpand" />
|
|
||||||
</HBoxContainer>
|
|
||||||
<Button Name="SubmitButton" Text="{Loc Teleport}" />
|
<Button Name="SubmitButton" Text="{Loc Teleport}" />
|
||||||
</VBoxContainer>
|
</VBoxContainer>
|
||||||
</SS14Window>
|
</SS14Window>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using NFluidsynth;
|
||||||
using Robust.Client.AutoGenerated;
|
using Robust.Client.AutoGenerated;
|
||||||
using Robust.Client.Console;
|
using Robust.Client.Console;
|
||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
@@ -15,35 +14,27 @@ namespace Content.Client.UserInterface.AdminMenu.Tabs.AdminTab
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public partial class TeleportWindow : SS14Window
|
public partial class TeleportWindow : SS14Window
|
||||||
{
|
{
|
||||||
private IEnumerable<IPlayerSession>? _data;
|
private IPlayerSession? _selectedSession;
|
||||||
|
|
||||||
protected override void EnteredTree()
|
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;
|
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)
|
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||||
{
|
{
|
||||||
// Find the value
|
if (_selectedSession == null)
|
||||||
if (_data == null)
|
|
||||||
return;
|
return;
|
||||||
var dataList = _data.ToList();
|
|
||||||
var session = dataList[PlayerOptions.SelectedId];
|
|
||||||
// Execute command
|
// Execute command
|
||||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
||||||
$"tpto \"{session.Name}\"");
|
$"tpto \"{_selectedSession.Name}\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user