@@ -1,59 +0,0 @@
|
|||||||
using System.Threading;
|
|
||||||
using Content.Client.Stylesheets;
|
|
||||||
using Robust.Client.UserInterface.Controls;
|
|
||||||
using Timer = Robust.Shared.Timing.Timer;
|
|
||||||
|
|
||||||
namespace Content.Client.Administration.UI;
|
|
||||||
|
|
||||||
public static class AdminUIHelpers
|
|
||||||
{
|
|
||||||
private static void ResetButton(Button button, ConfirmationData data)
|
|
||||||
{
|
|
||||||
data.Cancellation.Cancel();
|
|
||||||
button.ModulateSelfOverride = null;
|
|
||||||
button.Text = data.OriginalText;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool RemoveConfirm(Button button, Dictionary<Button, ConfirmationData> confirmations)
|
|
||||||
{
|
|
||||||
if (confirmations.Remove(button, out var data))
|
|
||||||
{
|
|
||||||
ResetButton(button, data);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void RemoveAllConfirms(Dictionary<Button, ConfirmationData> confirmations)
|
|
||||||
{
|
|
||||||
foreach (var (button, confirmation) in confirmations)
|
|
||||||
{
|
|
||||||
ResetButton(button, confirmation);
|
|
||||||
}
|
|
||||||
|
|
||||||
confirmations.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool TryConfirm(Button button, Dictionary<Button, ConfirmationData> confirmations)
|
|
||||||
{
|
|
||||||
if (RemoveConfirm(button, confirmations))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
var data = new ConfirmationData(new CancellationTokenSource(), button.Text);
|
|
||||||
confirmations[button] = data;
|
|
||||||
|
|
||||||
Timer.Spawn(TimeSpan.FromSeconds(5), () =>
|
|
||||||
{
|
|
||||||
confirmations.Remove(button);
|
|
||||||
button.ModulateSelfOverride = null;
|
|
||||||
button.Text = data.OriginalText;
|
|
||||||
}, data.Cancellation.Token);
|
|
||||||
|
|
||||||
button.ModulateSelfOverride = StyleNano.ButtonColorCautionDefault;
|
|
||||||
button.Text = Loc.GetString("admin-player-actions-confirm");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public readonly record struct ConfirmationData(CancellationTokenSource Cancellation, string? OriginalText);
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
<Control
|
<Control
|
||||||
xmlns="https://spacestation14.io"
|
xmlns="https://spacestation14.io"
|
||||||
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls">
|
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
|
||||||
|
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls">
|
||||||
<PanelContainer StyleClasses="BackgroundDark">
|
<PanelContainer StyleClasses="BackgroundDark">
|
||||||
<SplitContainer Orientation="Vertical" ResizeMode="NotResizable">
|
<SplitContainer Orientation="Vertical" ResizeMode="NotResizable">
|
||||||
<SplitContainer Orientation="Horizontal" VerticalExpand="True">
|
<SplitContainer Orientation="Horizontal" VerticalExpand="True">
|
||||||
@@ -18,9 +19,9 @@
|
|||||||
<Control HorizontalExpand="True" />
|
<Control HorizontalExpand="True" />
|
||||||
<Button Visible="False" Name="Bans" Text="{Loc 'admin-player-actions-bans'}" StyleClasses="OpenRight" />
|
<Button Visible="False" Name="Bans" Text="{Loc 'admin-player-actions-bans'}" StyleClasses="OpenRight" />
|
||||||
<Button Visible="False" Name="Notes" Text="{Loc 'admin-player-actions-notes'}" StyleClasses="OpenBoth" />
|
<Button Visible="False" Name="Notes" Text="{Loc 'admin-player-actions-notes'}" StyleClasses="OpenBoth" />
|
||||||
<Button Visible="False" Name="Kick" Text="{Loc 'admin-player-actions-kick'}" StyleClasses="OpenBoth" />
|
<controls:ConfirmButton Visible="False" Name="Kick" Text="{Loc 'admin-player-actions-kick'}" ConfirmationText="{Loc 'admin-player-actions-confirm'}" StyleClasses="OpenBoth" />
|
||||||
<Button Visible="False" Name="Ban" Text="{Loc 'admin-player-actions-ban'}" StyleClasses="OpenBoth" />
|
<Button Visible="False" Name="Ban" Text="{Loc 'admin-player-actions-ban'}" StyleClasses="OpenBoth" />
|
||||||
<Button Visible="False" Name="Respawn" Text="{Loc 'admin-player-actions-respawn'}" StyleClasses="OpenBoth" />
|
<controls:ConfirmButton Visible="False" Name="Respawn" Text="{Loc 'admin-player-actions-respawn'}" ConfirmationText="{Loc 'admin-player-actions-confirm'}" StyleClasses="OpenBoth" />
|
||||||
<Button Visible="False" Name="Follow" Text="{Loc 'admin-player-actions-follow'}" StyleClasses="OpenLeft" />
|
<Button Visible="False" Name="Follow" Text="{Loc 'admin-player-actions-follow'}" StyleClasses="OpenLeft" />
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</SplitContainer>
|
</SplitContainer>
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ namespace Content.Client.Administration.UI.Bwoink
|
|||||||
public AdminAHelpUIHandler AHelpHelper = default!;
|
public AdminAHelpUIHandler AHelpHelper = default!;
|
||||||
|
|
||||||
private PlayerInfo? _currentPlayer;
|
private PlayerInfo? _currentPlayer;
|
||||||
private readonly Dictionary<Button, ConfirmationData> _confirmations = new();
|
|
||||||
|
|
||||||
public BwoinkControl()
|
public BwoinkControl()
|
||||||
{
|
{
|
||||||
@@ -178,11 +177,6 @@ namespace Content.Client.Administration.UI.Bwoink
|
|||||||
|
|
||||||
Kick.OnPressed += _ =>
|
Kick.OnPressed += _ =>
|
||||||
{
|
{
|
||||||
if (!AdminUIHelpers.TryConfirm(Kick, _confirmations))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Reason field
|
// TODO: Reason field
|
||||||
if (_currentPlayer is not null)
|
if (_currentPlayer is not null)
|
||||||
_console.ExecuteCommand($"kick \"{_currentPlayer.Username}\"");
|
_console.ExecuteCommand($"kick \"{_currentPlayer.Username}\"");
|
||||||
@@ -196,11 +190,6 @@ namespace Content.Client.Administration.UI.Bwoink
|
|||||||
|
|
||||||
Respawn.OnPressed += _ =>
|
Respawn.OnPressed += _ =>
|
||||||
{
|
{
|
||||||
if (!AdminUIHelpers.TryConfirm(Respawn, _confirmations))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_currentPlayer is not null)
|
if (_currentPlayer is not null)
|
||||||
_console.ExecuteCommand($"respawn \"{_currentPlayer.Username}\"");
|
_console.ExecuteCommand($"respawn \"{_currentPlayer.Username}\"");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<Popup xmlns="https://spacestation14.io"
|
<Popup xmlns="https://spacestation14.io"
|
||||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client">
|
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||||
|
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls">
|
||||||
<PanelContainer>
|
<PanelContainer>
|
||||||
<PanelContainer.PanelOverride>
|
<PanelContainer.PanelOverride>
|
||||||
<gfx:StyleBoxFlat BorderThickness="2" BorderColor="#18181B" BackgroundColor="#25252a"/>
|
<gfx:StyleBoxFlat BorderThickness="2" BorderColor="#18181B" BackgroundColor="#25252a"/>
|
||||||
@@ -19,7 +20,7 @@
|
|||||||
<BoxContainer Orientation="Horizontal">
|
<BoxContainer Orientation="Horizontal">
|
||||||
<Button Name="EditButton" Text="{Loc admin-notes-edit}"/>
|
<Button Name="EditButton" Text="{Loc admin-notes-edit}"/>
|
||||||
<Control HorizontalExpand="True"/>
|
<Control HorizontalExpand="True"/>
|
||||||
<Button Name="DeleteButton" Text="{Loc admin-notes-delete}" HorizontalAlignment="Right"/>
|
<controls:ConfirmButton Name="DeleteButton" Text="{Loc admin-notes-delete}" ConfirmationText="{Loc 'admin-player-actions-confirm'}" HorizontalAlignment="Right"/>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</PanelContainer>
|
</PanelContainer>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<DefaultWindow
|
<DefaultWindow
|
||||||
xmlns="https://spacestation14.io"
|
xmlns="https://spacestation14.io"
|
||||||
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
|
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
|
||||||
|
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
||||||
Title="{Loc admin-player-actions-window-title}" MinSize="425 272">
|
Title="{Loc admin-player-actions-window-title}" MinSize="425 272">
|
||||||
<BoxContainer Orientation="Vertical">
|
<BoxContainer Orientation="Vertical">
|
||||||
<BoxContainer Orientation="Horizontal">
|
<BoxContainer Orientation="Horizontal">
|
||||||
@@ -10,9 +11,9 @@
|
|||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
<cc:PlayerListControl Name="PlayerList" VerticalExpand="True" />
|
<cc:PlayerListControl Name="PlayerList" VerticalExpand="True" />
|
||||||
<BoxContainer Orientation="Horizontal">
|
<BoxContainer Orientation="Horizontal">
|
||||||
<Button Name="SubmitKickButton" Text="{Loc admin-player-actions-kick}" Disabled="True"/>
|
<controls:ConfirmButton Name="SubmitKickButton" Text="{Loc admin-player-actions-kick}" ConfirmationText="{Loc 'admin-player-actions-confirm'}" Disabled="True"/>
|
||||||
<Button Name="SubmitAHelpButton" Text="{Loc admin-player-actions-ahelp}" Disabled="True"/>
|
<Button Name="SubmitAHelpButton" Text="{Loc admin-player-actions-ahelp}" Disabled="True"/>
|
||||||
<Button Name="SubmitRespawnButton" Text="{Loc admin-player-actions-respawn}" Disabled="True"/>
|
<controls:ConfirmButton Name="SubmitRespawnButton" Text="{Loc admin-player-actions-respawn}" ConfirmationText="{Loc 'admin-player-actions-confirm'}" Disabled="True"/>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</DefaultWindow>
|
</DefaultWindow>
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ namespace Content.Client.Administration.UI.Tabs.AdminTab
|
|||||||
public sealed partial class PlayerActionsWindow : DefaultWindow
|
public sealed partial class PlayerActionsWindow : DefaultWindow
|
||||||
{
|
{
|
||||||
private PlayerInfo? _selectedPlayer;
|
private PlayerInfo? _selectedPlayer;
|
||||||
private readonly Dictionary<Button, ConfirmationData> _confirmations = new();
|
|
||||||
|
|
||||||
public PlayerActionsWindow()
|
public PlayerActionsWindow()
|
||||||
{
|
{
|
||||||
@@ -28,9 +27,6 @@ namespace Content.Client.Administration.UI.Tabs.AdminTab
|
|||||||
|
|
||||||
private void OnListOnOnSelectionChanged(PlayerInfo? obj)
|
private void OnListOnOnSelectionChanged(PlayerInfo? obj)
|
||||||
{
|
{
|
||||||
if (_selectedPlayer != obj)
|
|
||||||
AdminUIHelpers.RemoveAllConfirms(_confirmations);
|
|
||||||
|
|
||||||
_selectedPlayer = obj;
|
_selectedPlayer = obj;
|
||||||
var disableButtons = _selectedPlayer == null;
|
var disableButtons = _selectedPlayer == null;
|
||||||
SubmitKickButton.Disabled = disableButtons;
|
SubmitKickButton.Disabled = disableButtons;
|
||||||
@@ -43,9 +39,6 @@ namespace Content.Client.Administration.UI.Tabs.AdminTab
|
|||||||
if (_selectedPlayer == null)
|
if (_selectedPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!AdminUIHelpers.TryConfirm(SubmitKickButton, _confirmations))
|
|
||||||
return;
|
|
||||||
|
|
||||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
||||||
$"kick \"{_selectedPlayer.Username}\" \"{CommandParsing.Escape(ReasonLine.Text)}\"");
|
$"kick \"{_selectedPlayer.Username}\" \"{CommandParsing.Escape(ReasonLine.Text)}\"");
|
||||||
}
|
}
|
||||||
@@ -64,9 +57,6 @@ namespace Content.Client.Administration.UI.Tabs.AdminTab
|
|||||||
if (_selectedPlayer == null)
|
if (_selectedPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!AdminUIHelpers.TryConfirm(SubmitRespawnButton, _confirmations))
|
|
||||||
return;
|
|
||||||
|
|
||||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
||||||
$"respawn \"{_selectedPlayer.Username}\"");
|
$"respawn \"{_selectedPlayer.Username}\"");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ public sealed partial class ObjectsTabEntry : PanelContainer
|
|||||||
|
|
||||||
public Action<NetEntity>? OnTeleport;
|
public Action<NetEntity>? OnTeleport;
|
||||||
public Action<NetEntity>? OnDelete;
|
public Action<NetEntity>? OnDelete;
|
||||||
private readonly Dictionary<Button, ConfirmationData> _confirmations = new();
|
|
||||||
|
|
||||||
public ObjectsTabEntry(IClientAdminManager manager, string name, NetEntity nent, StyleBox styleBox)
|
public ObjectsTabEntry(IClientAdminManager manager, string name, NetEntity nent, StyleBox styleBox)
|
||||||
{
|
{
|
||||||
@@ -28,13 +27,6 @@ public sealed partial class ObjectsTabEntry : PanelContainer
|
|||||||
DeleteButton.Disabled = !manager.CanCommand("delete");
|
DeleteButton.Disabled = !manager.CanCommand("delete");
|
||||||
|
|
||||||
TeleportButton.OnPressed += _ => OnTeleport?.Invoke(nent);
|
TeleportButton.OnPressed += _ => OnTeleport?.Invoke(nent);
|
||||||
DeleteButton.OnPressed += _ =>
|
DeleteButton.OnPressed += _ => OnDelete?.Invoke(nent);
|
||||||
{
|
|
||||||
if (!AdminUIHelpers.TryConfirm(DeleteButton, _confirmations))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
OnDelete?.Invoke(nent);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user