Make the lobby AHelp button red for admins when one is received (#20390)

This commit is contained in:
DrSmugleaf
2023-09-21 00:40:57 -07:00
committed by GitHub
parent 31b2c9f830
commit 4c5e7a01f1
2 changed files with 167 additions and 75 deletions

View File

@@ -1,4 +1,5 @@
<lobbyUi:LobbyGui xmlns="https://spacestation14.io" <lobbyUi:LobbyGui
xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:maths="clr-namespace:Robust.Shared.Maths;assembly=Robust.Shared.Maths" xmlns:maths="clr-namespace:Robust.Shared.Maths;assembly=Robust.Shared.Maths"
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls" xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
@@ -9,33 +10,42 @@
xmlns:info="clr-namespace:Content.Client.Info" xmlns:info="clr-namespace:Content.Client.Info"
xmlns:widgets="clr-namespace:Content.Client.UserInterface.Systems.Chat.Widgets"> xmlns:widgets="clr-namespace:Content.Client.UserInterface.Systems.Chat.Widgets">
<!-- Background --> <!-- Background -->
<TextureRect Access="Public" VerticalExpand="True" HorizontalExpand="True" Name = "Background" Stretch="KeepAspectCovered"/> <TextureRect Access="Public" VerticalExpand="True" HorizontalExpand="True" Name="Background"
<BoxContainer Name="MainContainer" VerticalExpand="True" HorizontalExpand="True" Orientation="Horizontal" Margin="10 10 10 10" SeparationOverride="2"> Stretch="KeepAspectCovered" />
<BoxContainer Name="MainContainer" VerticalExpand="True" HorizontalExpand="True" Orientation="Horizontal"
Margin="10 10 10 10" SeparationOverride="2">
<SplitContainer State="Auto" HorizontalExpand="True"> <SplitContainer State="Auto" HorizontalExpand="True">
<!-- LHS Controls --> <!-- LHS Controls -->
<BoxContainer Name="LeftSide" Orientation="Vertical" SeparationOverride="4" HorizontalExpand="True"> <BoxContainer Name="LeftSide" Orientation="Vertical" SeparationOverride="4" HorizontalExpand="True">
<Control Name="DefaultState" VerticalExpand="True"> <Control Name="DefaultState" VerticalExpand="True">
<BoxContainer Name="TopLeft" Orientation="Vertical"> <BoxContainer Name="TopLeft" Orientation="Vertical">
<!-- Left Top Panel --> <!-- Left Top Panel -->
<PanelContainer StyleClasses="AngleRect" HorizontalAlignment="Left" Name = "LeftSideTop" VerticalAlignment="Top" > <PanelContainer StyleClasses="AngleRect" HorizontalAlignment="Left" Name="LeftSideTop"
VerticalAlignment="Top">
<BoxContainer Orientation="Vertical" HorizontalAlignment="Center" MaxWidth="800"> <BoxContainer Orientation="Vertical" HorizontalAlignment="Center" MaxWidth="800">
<info:LinkBanner Name="LinkBanner" VerticalExpand="false" HorizontalAlignment="Center" Margin="3 3 3 3"/> <info:LinkBanner Name="LinkBanner" VerticalExpand="false" HorizontalAlignment="Center"
Margin="3 3 3 3" />
<controls:StripeBack> <controls:StripeBack>
<BoxContainer Orientation="Horizontal" SeparationOverride="6" Margin="3 3 3 3"> <BoxContainer Orientation="Horizontal" SeparationOverride="6" Margin="3 3 3 3">
<cc:UICommandButton Command="observe" Name="ObserveButton" Access="Public" Text="{Loc 'ui-lobby-observe-button'}" StyleClasses="ButtonBig" WindowType="{x:Type lobbyUi:ObserveWarningWindow}"/> <cc:UICommandButton Command="observe" Name="ObserveButton" Access="Public"
Text="{Loc 'ui-lobby-observe-button'}"
StyleClasses="ButtonBig"
WindowType="{x:Type lobbyUi:ObserveWarningWindow}" />
<Label Name="StartTime" <Label Name="StartTime"
Access="Public" Access="Public"
Align="Left" Align="Left"
FontColorOverride="{x:Static maths:Color.DarkGray}" FontColorOverride="{x:Static maths:Color.DarkGray}"
StyleClasses="LabelBig" HorizontalExpand="True" /> StyleClasses="LabelBig" HorizontalExpand="True" />
<Button Name="ReadyButton" Access="Public" ToggleMode="True" Text="{Loc 'ui-lobby-ready-up-button'}" <Button Name="ReadyButton" Access="Public" ToggleMode="True"
Text="{Loc 'ui-lobby-ready-up-button'}"
StyleClasses="ButtonBig" MinWidth="137" /> StyleClasses="ButtonBig" MinWidth="137" />
</BoxContainer> </BoxContainer>
</controls:StripeBack> </controls:StripeBack>
</BoxContainer> </BoxContainer>
</PanelContainer> </PanelContainer>
<!-- Voting Popups --> <!-- Voting Popups -->
<BoxContainer Orientation="Vertical" SeparationOverride="4" Name="VoteContainer" Access="Public" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0 8"/> <BoxContainer Orientation="Vertical" SeparationOverride="4" Name="VoteContainer"
Access="Public" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0 8" />
</BoxContainer> </BoxContainer>
<!-- Vertical Padding--> <!-- Vertical Padding-->
<Control VerticalExpand="True" /> <Control VerticalExpand="True" />
@@ -52,28 +62,37 @@
<Control Access="Public" Visible="False" Name="CharacterSetupState" VerticalExpand="True" /> <Control Access="Public" Visible="False" Name="CharacterSetupState" VerticalExpand="True" />
</BoxContainer> </BoxContainer>
<!-- Right Panel --> <!-- Right Panel -->
<PanelContainer Name="RightSide" StyleClasses="AngleRect" HorizontalAlignment= "Right" VerticalExpand="True" VerticalAlignment="Stretch"> <PanelContainer Name="RightSide" StyleClasses="AngleRect" HorizontalAlignment="Right" VerticalExpand="True"
VerticalAlignment="Stretch">
<BoxContainer Orientation="Vertical" HorizontalExpand="True"> <BoxContainer Orientation="Vertical" HorizontalExpand="True">
<!-- Top row --> <!-- Top row -->
<BoxContainer Orientation="Horizontal" MinSize="0 40" Name="HeaderContainer" Access="Public" SeparationOverride="4"> <BoxContainer Orientation="Horizontal" MinSize="0 40" Name="HeaderContainer" Access="Public"
<Label Margin="8 0 0 0" StyleClasses="LabelHeadingBigger" VAlign="Center" Text="{Loc 'ui-lobby-title'}" /> SeparationOverride="4">
<Label Name="ServerName" Access="Public" StyleClasses="LabelHeadingBigger" VAlign="Center" HorizontalExpand="True" HorizontalAlignment="Center" /> <Label Margin="8 0 0 0" StyleClasses="LabelHeadingBigger" VAlign="Center"
Text="{Loc 'ui-lobby-title'}" />
<Label Name="ServerName" Access="Public" StyleClasses="LabelHeadingBigger" VAlign="Center"
HorizontalExpand="True" HorizontalAlignment="Center" />
</BoxContainer> </BoxContainer>
<!-- Gold line --> <!-- Gold line -->
<controls:HLine Color="{x:Static style:StyleNano.NanoGold}" Thickness="2" /> <controls:HLine Color="{x:Static style:StyleNano.NanoGold}" Thickness="2" />
<controls:HSpacer Spacing="10" /> <controls:HSpacer Spacing="10" />
<!-- Voting & misc button bar --> <!-- Voting & misc button bar -->
<BoxContainer Orientation="Horizontal" MinSize="0 40" HorizontalAlignment="Right"> <BoxContainer Orientation="Horizontal" MinSize="0 40" HorizontalAlignment="Right">
<cc:CommandButton Name = "AHelpButton" Command="openahelp" Access="Public" Text = "{Loc 'ui-lobby-ahelp-button'}" StyleClasses="ButtonBig"/> <Button Name="AHelpButton" Access="Public" Text="{Loc 'ui-lobby-ahelp-button'}"
StyleClasses="ButtonBig" />
<vote:VoteCallMenuButton Name="CallVoteButton" StyleClasses="ButtonBig" /> <vote:VoteCallMenuButton Name="CallVoteButton" StyleClasses="ButtonBig" />
<Button Name="OptionsButton" Access="Public" StyleClasses="ButtonBig" Text="{Loc 'ui-lobby-options-button'}" /> <Button Name="OptionsButton" Access="Public" StyleClasses="ButtonBig"
<Button Name="LeaveButton" Access="Public" StyleClasses="ButtonBig" Text="{Loc 'ui-lobby-leave-button'}" /> Text="{Loc 'ui-lobby-options-button'}" />
<Button Name="LeaveButton" Access="Public" StyleClasses="ButtonBig"
Text="{Loc 'ui-lobby-leave-button'}" />
</BoxContainer> </BoxContainer>
<controls:HSpacer Spacing="10" /> <controls:HSpacer Spacing="10" />
<!-- Server info --> <!-- Server info -->
<controls:NanoHeading Text="{Loc 'ui-lobby-server-info-block'}" /> <controls:NanoHeading Text="{Loc 'ui-lobby-server-info-block'}" />
<info:ServerInfo Name="ServerInfo" Access="Public" MinSize="0 30" VerticalExpand="false" Margin="3 3 3 3" MaxWidth="400" HorizontalAlignment="Left"/> <info:ServerInfo Name="ServerInfo" Access="Public" MinSize="0 30" VerticalExpand="false"
<Label Name="StationTime" Access="Public" FontColorOverride="{x:Static maths:Color.LightGray}" Margin="3 3 3 3" HorizontalAlignment="Left"/> Margin="3 3 3 3" MaxWidth="400" HorizontalAlignment="Left" />
<Label Name="StationTime" Access="Public" FontColorOverride="{x:Static maths:Color.LightGray}"
Margin="3 3 3 3" HorizontalAlignment="Left" />
<controls:HSpacer Spacing="5" /> <controls:HSpacer Spacing="5" />
<lobbyUi:LobbyCharacterPreviewPanel Name="CharacterPreview" Access="Public" /> <lobbyUi:LobbyCharacterPreviewPanel Name="CharacterPreview" Access="Public" />
<controls:HSpacer Spacing="5" /> <controls:HSpacer Spacing="5" />

View File

@@ -4,7 +4,12 @@ using System.Numerics;
using Content.Client.Administration.Managers; using Content.Client.Administration.Managers;
using Content.Client.Administration.Systems; using Content.Client.Administration.Systems;
using Content.Client.Administration.UI.Bwoink; using Content.Client.Administration.UI.Bwoink;
using Content.Client.Gameplay;
using Content.Client.Lobby;
using Content.Client.Lobby.UI;
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Controls; using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Systems.MenuBar.Widgets;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Input; using Content.Shared.Input;
using JetBrains.Annotations; using JetBrains.Annotations;
@@ -23,7 +28,7 @@ using Robust.Shared.Utility;
namespace Content.Client.UserInterface.Systems.Bwoink; namespace Content.Client.UserInterface.Systems.Bwoink;
[UsedImplicitly] [UsedImplicitly]
public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSystem> public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSystem>, IOnStateChanged<GameplayState>, IOnStateChanged<LobbyState>
{ {
[Dependency] private readonly IClientAdminManager _adminManager = default!; [Dependency] private readonly IClientAdminManager _adminManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!;
@@ -31,9 +36,11 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
[Dependency] private readonly IUserInterfaceManager _uiManager = default!; [Dependency] private readonly IUserInterfaceManager _uiManager = default!;
private BwoinkSystem? _bwoinkSystem; private BwoinkSystem? _bwoinkSystem;
private MenuButton? AhelpButton => UIManager.GetActiveUIWidgetOrNull<MenuBar.Widgets.GameTopMenuBar>()?.AHelpButton; private MenuButton? GameAHelpButton => UIManager.GetActiveUIWidgetOrNull<GameTopMenuBar>()?.AHelpButton;
private Button? LobbyAHelpButton => (UIManager.ActiveScreen as LobbyGui)?.AHelpButton;
public IAHelpUIHandler? UIHelper; public IAHelpUIHandler? UIHelper;
private bool _discordRelayActive; private bool _discordRelayActive;
private bool _hasUnreadAHelp;
public override void Initialize() public override void Initialize()
{ {
@@ -47,22 +54,20 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
public void UnloadButton() public void UnloadButton()
{ {
if (AhelpButton == null) if (GameAHelpButton != null)
{ GameAHelpButton.OnPressed -= AHelpButtonPressed;
return;
}
AhelpButton.OnPressed -= AHelpButtonPressed; if (LobbyAHelpButton != null)
LobbyAHelpButton.OnPressed -= AHelpButtonPressed;
} }
public void LoadButton() public void LoadButton()
{ {
if (AhelpButton == null) if (GameAHelpButton != null)
{ GameAHelpButton.OnPressed += AHelpButtonPressed;
return;
}
AhelpButton.OnPressed += AHelpButtonPressed; if (LobbyAHelpButton != null)
LobbyAHelpButton.OnPressed += AHelpButtonPressed;
} }
private void OnAdminStatusUpdated() private void OnAdminStatusUpdated()
@@ -81,7 +86,7 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
public void OnSystemLoaded(BwoinkSystem system) public void OnSystemLoaded(BwoinkSystem system)
{ {
_bwoinkSystem = system; _bwoinkSystem = system;
_bwoinkSystem.OnBwoinkTextMessageRecieved += RecievedBwoink; _bwoinkSystem.OnBwoinkTextMessageRecieved += ReceivedBwoink;
CommandBinds.Builder CommandBinds.Builder
.Bind(ContentKeyFunctions.OpenAHelp, .Bind(ContentKeyFunctions.OpenAHelp,
@@ -94,19 +99,26 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
CommandBinds.Unregister<AHelpUIController>(); CommandBinds.Unregister<AHelpUIController>();
DebugTools.Assert(_bwoinkSystem != null); DebugTools.Assert(_bwoinkSystem != null);
_bwoinkSystem!.OnBwoinkTextMessageRecieved -= RecievedBwoink; _bwoinkSystem!.OnBwoinkTextMessageRecieved -= ReceivedBwoink;
_bwoinkSystem = null; _bwoinkSystem = null;
} }
private void SetAHelpPressed(bool pressed) private void SetAHelpPressed(bool pressed)
{ {
if (AhelpButton == null || AhelpButton.Pressed == pressed) if (GameAHelpButton != null)
return; {
AhelpButton.StyleClasses.Remove(MenuButton.StyleClassRedTopButton); GameAHelpButton.Pressed = pressed;
AhelpButton.Pressed = pressed;
} }
private void RecievedBwoink(object? sender, SharedBwoinkSystem.BwoinkTextMessage message) if (LobbyAHelpButton != null)
{
LobbyAHelpButton.Pressed = pressed;
}
UnreadAHelpRead();
}
private void ReceivedBwoink(object? sender, SharedBwoinkSystem.BwoinkTextMessage message)
{ {
Logger.InfoS("c.s.go.es.bwoink", $"@{message.UserId}: {message.Text}"); Logger.InfoS("c.s.go.es.bwoink", $"@{message.UserId}: {message.Text}");
var localPlayer = _playerManager.LocalPlayer; var localPlayer = _playerManager.LocalPlayer;
@@ -121,10 +133,12 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
} }
EnsureUIHelper(); EnsureUIHelper();
if (!UIHelper!.IsOpen) if (!UIHelper!.IsOpen)
{ {
AhelpButton?.StyleClasses.Add(MenuButton.StyleClassRedTopButton); UnreadAHelpReceived();
} }
UIHelper!.Receive(message); UIHelper!.Receive(message);
} }
@@ -158,11 +172,6 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
SetAHelpPressed(UIHelper.IsOpen); SetAHelpPressed(UIHelper.IsOpen);
} }
public void Close()
{
UIHelper?.Close();
}
public void Open() public void Open()
{ {
var localPlayer = _playerManager.LocalPlayer; var localPlayer = _playerManager.LocalPlayer;
@@ -226,6 +235,70 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
helper.Control.PopOut.Disabled = true; helper.Control.PopOut.Disabled = true;
helper.Control.PopOut.Visible = false; helper.Control.PopOut.Visible = false;
} }
private void UnreadAHelpReceived()
{
GameAHelpButton?.StyleClasses.Add(MenuButton.StyleClassRedTopButton);
LobbyAHelpButton?.StyleClasses.Add(StyleNano.StyleClassButtonColorRed);
_hasUnreadAHelp = true;
}
private void UnreadAHelpRead()
{
GameAHelpButton?.StyleClasses.Remove(MenuButton.StyleClassRedTopButton);
LobbyAHelpButton?.StyleClasses.Remove(StyleNano.StyleClassButtonColorRed);
_hasUnreadAHelp = false;
}
public void OnStateEntered(GameplayState state)
{
if (GameAHelpButton != null)
{
GameAHelpButton.OnPressed -= AHelpButtonPressed;
GameAHelpButton.OnPressed += AHelpButtonPressed;
GameAHelpButton.Pressed = UIHelper?.IsOpen ?? false;
if (_hasUnreadAHelp)
{
UnreadAHelpReceived();
}
else
{
UnreadAHelpRead();
}
}
}
public void OnStateExited(GameplayState state)
{
if (GameAHelpButton != null)
GameAHelpButton.OnPressed -= AHelpButtonPressed;
}
public void OnStateEntered(LobbyState state)
{
if (LobbyAHelpButton != null)
{
LobbyAHelpButton.OnPressed -= AHelpButtonPressed;
LobbyAHelpButton.OnPressed += AHelpButtonPressed;
LobbyAHelpButton.Pressed = UIHelper?.IsOpen ?? false;
if (_hasUnreadAHelp)
{
UnreadAHelpReceived();
}
else
{
UnreadAHelpRead();
}
}
}
public void OnStateExited(LobbyState state)
{
if (LobbyAHelpButton != null)
LobbyAHelpButton.OnPressed -= AHelpButtonPressed;
}
} }
// please kill all this indirection // please kill all this indirection