Don't force bwoink window open for admins (#8066)

This commit is contained in:
metalgearsloth
2022-05-13 09:45:08 +10:00
committed by GitHub
parent d82f9155eb
commit 91bb48eec9
3 changed files with 26 additions and 12 deletions

View File

@@ -5,6 +5,7 @@ using System.Linq;
using Content.Client.Administration.Managers;
using Content.Client.Administration.UI;
using Content.Client.Administration.UI.CustomControls;
using Content.Client.HUD;
using Content.Shared.Administration;
using JetBrains.Annotations;
using Robust.Client.Graphics;
@@ -25,6 +26,7 @@ namespace Content.Client.Administration
[Dependency] private readonly IClientAdminManager _adminManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IClyde _clyde = default!;
[Dependency] private readonly IGameHud _hud = default!;
private BwoinkWindow? _adminWindow;
private DefaultWindow? _plainWindow;
@@ -47,7 +49,17 @@ namespace Content.Client.Administration
_clyde.RequestWindowAttention();
}
// If they're not an admin force it open so they read
// If it's admin-admin messaging then eh.
if (!_adminManager.HasFlag(AdminFlags.Adminhelp))
_plainWindow?.Open();
else
{
_adminWindow?.OnBwoink(message.ChannelId);
if (_adminWindow?.IsOpen != true)
_hud.SetInfoRed(true);
}
}
public bool TryGetChannel(NetUserId ch, [NotNullWhen(true)] out BwoinkPanel? bp) => _activePanelMap.TryGetValue(ch, out bp);
@@ -64,8 +76,6 @@ namespace Content.Client.Administration
_adminWindow.BwoinkArea.AddChild(existingPanel);
}
if(!_adminWindow.IsOpen) _adminWindow.Open();
return existingPanel;
}
@@ -90,7 +100,6 @@ namespace Content.Client.Administration
bp = (BwoinkPanel) _plainWindow.Contents.GetChild(0);
}
_plainWindow.Open();
return bp;
}
@@ -112,13 +121,17 @@ namespace Content.Client.Administration
return;
}
_hud.SetInfoRed(false);
if (_adminManager.HasFlag(AdminFlags.Adminhelp))
{
SelectChannel(channelId.Value);
_adminWindow?.Open();
return;
}
EnsurePlain(channelId.Value);
_plainWindow?.Open();
}
public void Close()

View File

@@ -120,16 +120,8 @@ namespace Content.Client.Administration.UI
public void OnBwoink(NetUserId channel)
{
var open = IsOpen;
Open();
ChannelSelector.RefreshDecorators();
ChannelSelector.Sort();
if (!open)
{
SelectChannel(channel);
}
}
public void SelectChannel(NetUserId channel)

View File

@@ -50,6 +50,7 @@ public interface IButtonBarView
// Info top button
event Action InfoButtonPressed;
void SetInfoRed(bool value);
}
internal sealed partial class GameHud
@@ -321,4 +322,12 @@ internal sealed partial class GameHud
/// <inheritdoc />
public event Action? InfoButtonPressed;
public void SetInfoRed(bool value)
{
if (value)
_buttonInfo.StyleClasses.Add(TopButton.StyleClassRedTopButton);
else
_buttonInfo.StyleClasses.Remove(TopButton.StyleClassRedTopButton);
}
}