Make the admin player panel overlay button a toggle (#7153)
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
using Content.Client.Administration.Managers;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.Administration
|
||||
{
|
||||
@@ -9,8 +7,12 @@ namespace Content.Client.Administration
|
||||
{
|
||||
[Dependency] private readonly IClientAdminManager _adminManager = default!;
|
||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||
|
||||
private AdminNameOverlay _adminNameOverlay = default!;
|
||||
|
||||
public event Action? OverlayEnabled;
|
||||
public event Action? OverlayDisabled;
|
||||
|
||||
private void InitializeOverlay()
|
||||
{
|
||||
_adminNameOverlay = new AdminNameOverlay(this, _entityManager, _eyeManager, _resourceCache, _entityLookup);
|
||||
@@ -27,15 +29,17 @@ namespace Content.Client.Administration
|
||||
AdminOverlayOff();
|
||||
}
|
||||
|
||||
public void AdminOverlayOn(BaseButton.ButtonEventArgs? _ = null)
|
||||
public void AdminOverlayOn()
|
||||
{
|
||||
if (!_overlayManager.HasOverlay<AdminNameOverlay>())
|
||||
if (_overlayManager.HasOverlay<AdminNameOverlay>()) return;
|
||||
_overlayManager.AddOverlay(_adminNameOverlay);
|
||||
OverlayEnabled?.Invoke();
|
||||
}
|
||||
|
||||
public void AdminOverlayOff(BaseButton.ButtonEventArgs? _ = null)
|
||||
public void AdminOverlayOff()
|
||||
{
|
||||
_overlayManager.RemoveOverlay<AdminNameOverlay>();
|
||||
OverlayDisabled?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Name="PlayerCount" HorizontalExpand="True" SizeFlagsStretchRatio="0.50"
|
||||
Text="{Loc Player Count}" />
|
||||
<Button Name="OverlayButtonOn" HorizontalExpand="True" SizeFlagsStretchRatio="0.25"
|
||||
Text="{Loc Overlay On}"/>
|
||||
<Button Name="OverlayButtonOff" HorizontalExpand="True" SizeFlagsStretchRatio="0.25"
|
||||
Text="{Loc Overlay Off}"/>
|
||||
<Button Name="OverlayButton" HorizontalExpand="True" SizeFlagsStretchRatio="0.25"
|
||||
Text="{Loc player-tab-overlay}" ToggleMode="True"/>
|
||||
</BoxContainer>
|
||||
<Control MinSize="0 5" />
|
||||
<ScrollContainer HorizontalExpand="True" VerticalExpand="True">
|
||||
|
||||
@@ -3,9 +3,9 @@ using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using static Content.Client.Administration.UI.Tabs.PlayerTab.PlayerTabHeader;
|
||||
using static Robust.Client.UserInterface.Controls.BaseButton;
|
||||
|
||||
namespace Content.Client.Administration.UI.Tabs.PlayerTab
|
||||
{
|
||||
@@ -22,28 +22,60 @@ namespace Content.Client.Administration.UI.Tabs.PlayerTab
|
||||
private Header _headerClicked = Header.Username;
|
||||
private bool _ascending = true;
|
||||
|
||||
public event Action<BaseButton.ButtonEventArgs>? OnEntryPressed;
|
||||
public event Action<ButtonEventArgs>? OnEntryPressed;
|
||||
|
||||
public PlayerTab()
|
||||
{
|
||||
_adminSystem = EntitySystem.Get<AdminSystem>();
|
||||
RobustXamlLoader.Load(this);
|
||||
RefreshPlayerList(_adminSystem.PlayerList);
|
||||
|
||||
_adminSystem.PlayerListChanged += RefreshPlayerList;
|
||||
OverlayButtonOn.OnPressed += _adminSystem.AdminOverlayOn;
|
||||
OverlayButtonOff.OnPressed += _adminSystem.AdminOverlayOff;
|
||||
_adminSystem.OverlayEnabled += OverlayEnabled;
|
||||
_adminSystem.OverlayDisabled += OverlayDisabled;
|
||||
|
||||
OverlayButton.OnPressed += OverlayButtonPressed;
|
||||
|
||||
ListHeader.BackgroundColorPanel.PanelOverride = new StyleBoxFlat(_altColor);
|
||||
ListHeader.OnHeaderClicked += HeaderClicked;
|
||||
}
|
||||
|
||||
private void OverlayEnabled()
|
||||
{
|
||||
OverlayButton.Pressed = true;
|
||||
}
|
||||
|
||||
private void OverlayDisabled()
|
||||
{
|
||||
OverlayButton.Pressed = false;
|
||||
}
|
||||
|
||||
private void OverlayButtonPressed(ButtonEventArgs args)
|
||||
{
|
||||
if (args.Button.Pressed)
|
||||
{
|
||||
_adminSystem.AdminOverlayOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
_adminSystem.AdminOverlayOff();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
_adminSystem.PlayerListChanged -= RefreshPlayerList;
|
||||
OverlayButtonOn.OnPressed -= _adminSystem.AdminOverlayOn;
|
||||
OverlayButtonOff.OnPressed -= _adminSystem.AdminOverlayOff;
|
||||
_adminSystem.OverlayEnabled -= OverlayEnabled;
|
||||
_adminSystem.OverlayDisabled -= OverlayDisabled;
|
||||
|
||||
OverlayButton.OnPressed -= OverlayButtonPressed;
|
||||
|
||||
ListHeader.OnHeaderClicked -= HeaderClicked;
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshPlayerList(IReadOnlyList<PlayerInfo> players)
|
||||
|
||||
@@ -2,3 +2,4 @@
|
||||
player-tab-character = Character
|
||||
player-tab-job = Job
|
||||
player-tab-antagonist = Antagonist
|
||||
player-tab-overlay = Overlay
|
||||
|
||||
Reference in New Issue
Block a user