]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make the lobby AHelp button red for admins when one is received (#20390)
authorDrSmugleaf <DrSmugleaf@users.noreply.github.com>
Thu, 21 Sep 2023 07:40:57 +0000 (00:40 -0700)
committerGitHub <noreply@github.com>
Thu, 21 Sep 2023 07:40:57 +0000 (17:40 +1000)
Content.Client/Lobby/UI/LobbyGui.xaml
Content.Client/UserInterface/Systems/Bwoink/AHelpUIController.cs

index 68e974dbd547c3e747280588ba11a63bb43ca5f3..c3bd0da642a6342ae40b4a8eeafc85da40340019 100644 (file)
@@ -1,47 +1,57 @@
-<lobbyUi:LobbyGui xmlns="https://spacestation14.io"
-         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-         xmlns:maths="clr-namespace:Robust.Shared.Maths;assembly=Robust.Shared.Maths"
-         xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
-         xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
-         xmlns:vote="clr-namespace:Content.Client.Voting.UI"
-         xmlns:style="clr-namespace:Content.Client.Stylesheets"
-         xmlns:lobbyUi="clr-namespace:Content.Client.Lobby.UI"
-         xmlns:info="clr-namespace:Content.Client.Info"
-         xmlns:widgets="clr-namespace:Content.Client.UserInterface.Systems.Chat.Widgets">
+<lobbyUi:LobbyGui
+    xmlns="https://spacestation14.io"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:maths="clr-namespace:Robust.Shared.Maths;assembly=Robust.Shared.Maths"
+    xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
+    xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
+    xmlns:vote="clr-namespace:Content.Client.Voting.UI"
+    xmlns:style="clr-namespace:Content.Client.Stylesheets"
+    xmlns:lobbyUi="clr-namespace:Content.Client.Lobby.UI"
+    xmlns:info="clr-namespace:Content.Client.Info"
+    xmlns:widgets="clr-namespace:Content.Client.UserInterface.Systems.Chat.Widgets">
     <!-- Background -->
-    <TextureRect Access="Public" VerticalExpand="True" HorizontalExpand="True" Name = "Background" Stretch="KeepAspectCovered"/>
-    <BoxContainer Name="MainContainer" VerticalExpand="True" HorizontalExpand="True" Orientation="Horizontal" Margin="10 10 10 10" SeparationOverride="2">
+    <TextureRect Access="Public" VerticalExpand="True" HorizontalExpand="True" Name="Background"
+                 Stretch="KeepAspectCovered" />
+    <BoxContainer Name="MainContainer" VerticalExpand="True" HorizontalExpand="True" Orientation="Horizontal"
+                  Margin="10 10 10 10" SeparationOverride="2">
         <SplitContainer State="Auto" HorizontalExpand="True">
             <!-- LHS Controls -->
             <BoxContainer Name="LeftSide" Orientation="Vertical" SeparationOverride="4" HorizontalExpand="True">
                 <Control Name="DefaultState" VerticalExpand="True">
                     <BoxContainer Name="TopLeft" Orientation="Vertical">
                         <!-- 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">
-                                <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>
                                     <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"
                                                Access="Public"
                                                Align="Left"
                                                FontColorOverride="{x:Static maths:Color.DarkGray}"
                                                StyleClasses="LabelBig" HorizontalExpand="True" />
-                                        <Button Name="ReadyButton" Access="Public" ToggleMode="True" Text="{Loc 'ui-lobby-ready-up-button'}"
-                                                StyleClasses="ButtonBig" MinWidth="137"/>
+                                        <Button Name="ReadyButton" Access="Public" ToggleMode="True"
+                                                Text="{Loc 'ui-lobby-ready-up-button'}"
+                                                StyleClasses="ButtonBig" MinWidth="137" />
                                     </BoxContainer>
                                 </controls:StripeBack>
                             </BoxContainer>
                         </PanelContainer>
                         <!-- 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>
                     <!-- Vertical Padding-->
-                    <Control VerticalExpand="True"/>
+                    <Control VerticalExpand="True" />
                     <!-- Left Bot Panel -->
                     <BoxContainer Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Bottom">
-                        <info:DevInfoBanner Name="DevInfoBanner" VerticalExpand="false" Margin="3 3 3 3"/>
+                        <info:DevInfoBanner Name="DevInfoBanner" VerticalExpand="false" Margin="3 3 3 3" />
                         <PanelContainer StyleClasses="AngleRect">
                             <RichTextLabel Name="LobbySong" Access="Public" HorizontalAlignment="Center" />
                         </PanelContainer>
                 <Control Access="Public" Visible="False" Name="CharacterSetupState" VerticalExpand="True" />
             </BoxContainer>
             <!-- Right Panel -->
-            <PanelContainer Name="RightSide" StyleClasses="AngleRect" HorizontalAlignment= "Right" VerticalExpand="True" VerticalAlignment="Stretch">
-                <BoxContainer Orientation="Vertical"  HorizontalExpand="True">
-                <!-- Top row -->
-                <BoxContainer Orientation="Horizontal" MinSize="0 40" Name="HeaderContainer" Access="Public"  SeparationOverride="4">
-                    <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>
-                <!-- Gold line -->
-                <controls:HLine Color="{x:Static style:StyleNano.NanoGold}" Thickness="2"/>
-                <controls:HSpacer Spacing="10"/>
-                <!-- Voting & misc button bar -->
-                <BoxContainer Orientation="Horizontal" MinSize="0 40" HorizontalAlignment="Right">
-                    <cc:CommandButton Name = "AHelpButton" Command="openahelp" Access="Public" Text = "{Loc 'ui-lobby-ahelp-button'}" StyleClasses="ButtonBig"/>
-                    <vote:VoteCallMenuButton Name="CallVoteButton" StyleClasses="ButtonBig" />
-                    <Button Name="OptionsButton" Access="Public" StyleClasses="ButtonBig" Text="{Loc 'ui-lobby-options-button'}" />
-                    <Button Name="LeaveButton" Access="Public" StyleClasses="ButtonBig" Text="{Loc 'ui-lobby-leave-button'}" />
-                </BoxContainer>
-                <controls:HSpacer Spacing="10"/>
-                <!-- Server info -->
-                <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"/>
-                <Label Name="StationTime" Access="Public" FontColorOverride="{x:Static maths:Color.LightGray}" Margin="3 3 3 3" HorizontalAlignment="Left"/>
-                <controls:HSpacer Spacing="5"/>
-                <lobbyUi:LobbyCharacterPreviewPanel Name="CharacterPreview" Access="Public" />
-                <controls:HSpacer Spacing="5"/>
-                <BoxContainer MinHeight="10"/>
-                <!-- Gold line -->
-                <controls:HLine Color="{x:Static style:StyleNano.NanoGold}" Thickness="2" Access="Public"/>
-                <controls:HSpacer Spacing="10"/>
-                <widgets:ChatBox Name="Chat" Access="Public" VerticalExpand="True" Margin="3 3 3 3" MinHeight="50" />
+            <PanelContainer Name="RightSide" StyleClasses="AngleRect" HorizontalAlignment="Right" VerticalExpand="True"
+                            VerticalAlignment="Stretch">
+                <BoxContainer Orientation="Vertical" HorizontalExpand="True">
+                    <!-- Top row -->
+                    <BoxContainer Orientation="Horizontal" MinSize="0 40" Name="HeaderContainer" Access="Public"
+                                  SeparationOverride="4">
+                        <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>
+                    <!-- Gold line -->
+                    <controls:HLine Color="{x:Static style:StyleNano.NanoGold}" Thickness="2" />
+                    <controls:HSpacer Spacing="10" />
+                    <!-- Voting & misc button bar -->
+                    <BoxContainer Orientation="Horizontal" MinSize="0 40" HorizontalAlignment="Right">
+                        <Button Name="AHelpButton" Access="Public" Text="{Loc 'ui-lobby-ahelp-button'}"
+                                StyleClasses="ButtonBig" />
+                        <vote:VoteCallMenuButton Name="CallVoteButton" StyleClasses="ButtonBig" />
+                        <Button Name="OptionsButton" Access="Public" StyleClasses="ButtonBig"
+                                Text="{Loc 'ui-lobby-options-button'}" />
+                        <Button Name="LeaveButton" Access="Public" StyleClasses="ButtonBig"
+                                Text="{Loc 'ui-lobby-leave-button'}" />
+                    </BoxContainer>
+                    <controls:HSpacer Spacing="10" />
+                    <!-- Server info -->
+                    <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" />
+                    <Label Name="StationTime" Access="Public" FontColorOverride="{x:Static maths:Color.LightGray}"
+                           Margin="3 3 3 3" HorizontalAlignment="Left" />
+                    <controls:HSpacer Spacing="5" />
+                    <lobbyUi:LobbyCharacterPreviewPanel Name="CharacterPreview" Access="Public" />
+                    <controls:HSpacer Spacing="5" />
+                    <BoxContainer MinHeight="10" />
+                    <!-- Gold line -->
+                    <controls:HLine Color="{x:Static style:StyleNano.NanoGold}" Thickness="2" Access="Public" />
+                    <controls:HSpacer Spacing="10" />
+                    <widgets:ChatBox Name="Chat" Access="Public" VerticalExpand="True" Margin="3 3 3 3" MinHeight="50" />
                 </BoxContainer>
             </PanelContainer>
         </SplitContainer>
index 0c6a48791ff049d1b6bcc3f9ae2dd8523666ff85..f26d33f5f87051a5ca78c7e0b397aed99c55723b 100644 (file)
@@ -4,7 +4,12 @@ using System.Numerics;
 using Content.Client.Administration.Managers;
 using Content.Client.Administration.Systems;
 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.Systems.MenuBar.Widgets;
 using Content.Shared.Administration;
 using Content.Shared.Input;
 using JetBrains.Annotations;
@@ -23,7 +28,7 @@ using Robust.Shared.Utility;
 namespace Content.Client.UserInterface.Systems.Bwoink;
 
 [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 IPlayerManager _playerManager = default!;
@@ -31,9 +36,11 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
     [Dependency] private readonly IUserInterfaceManager _uiManager = default!;
 
     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;
     private bool _discordRelayActive;
+    private bool _hasUnreadAHelp;
 
     public override void Initialize()
     {
@@ -47,22 +54,20 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
 
     public void UnloadButton()
     {
-        if (AhelpButton == null)
-        {
-            return;
-        }
+        if (GameAHelpButton != null)
+            GameAHelpButton.OnPressed -= AHelpButtonPressed;
 
-        AhelpButton.OnPressed -= AHelpButtonPressed;
+        if (LobbyAHelpButton != null)
+            LobbyAHelpButton.OnPressed -= AHelpButtonPressed;
     }
 
     public void LoadButton()
     {
-        if (AhelpButton == null)
-        {
-            return;
-        }
+        if (GameAHelpButton != null)
+            GameAHelpButton.OnPressed += AHelpButtonPressed;
 
-        AhelpButton.OnPressed += AHelpButtonPressed;
+        if (LobbyAHelpButton != null)
+            LobbyAHelpButton.OnPressed += AHelpButtonPressed;
     }
 
     private void OnAdminStatusUpdated()
@@ -81,7 +86,7 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
     public void OnSystemLoaded(BwoinkSystem system)
     {
         _bwoinkSystem = system;
-        _bwoinkSystem.OnBwoinkTextMessageRecieved += RecievedBwoink;
+        _bwoinkSystem.OnBwoinkTextMessageRecieved += ReceivedBwoink;
 
         CommandBinds.Builder
             .Bind(ContentKeyFunctions.OpenAHelp,
@@ -94,19 +99,26 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
         CommandBinds.Unregister<AHelpUIController>();
 
         DebugTools.Assert(_bwoinkSystem != null);
-        _bwoinkSystem!.OnBwoinkTextMessageRecieved -= RecievedBwoink;
+        _bwoinkSystem!.OnBwoinkTextMessageRecieved -= ReceivedBwoink;
         _bwoinkSystem = null;
     }
 
     private void SetAHelpPressed(bool pressed)
     {
-        if (AhelpButton == null || AhelpButton.Pressed == pressed)
-            return;
-        AhelpButton.StyleClasses.Remove(MenuButton.StyleClassRedTopButton);
-        AhelpButton.Pressed = pressed;
+        if (GameAHelpButton != null)
+        {
+            GameAHelpButton.Pressed = pressed;
+        }
+
+        if (LobbyAHelpButton != null)
+        {
+            LobbyAHelpButton.Pressed = pressed;
+        }
+
+        UnreadAHelpRead();
     }
 
-    private void RecievedBwoink(object? sender, SharedBwoinkSystem.BwoinkTextMessage message)
+    private void ReceivedBwoink(object? sender, SharedBwoinkSystem.BwoinkTextMessage message)
     {
         Logger.InfoS("c.s.go.es.bwoink", $"@{message.UserId}: {message.Text}");
         var localPlayer = _playerManager.LocalPlayer;
@@ -121,10 +133,12 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
         }
 
         EnsureUIHelper();
+
         if (!UIHelper!.IsOpen)
         {
-            AhelpButton?.StyleClasses.Add(MenuButton.StyleClassRedTopButton);
+            UnreadAHelpReceived();
         }
+
         UIHelper!.Receive(message);
     }
 
@@ -158,11 +172,6 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
         SetAHelpPressed(UIHelper.IsOpen);
     }
 
-    public void Close()
-    {
-        UIHelper?.Close();
-    }
-
     public void Open()
     {
         var localPlayer = _playerManager.LocalPlayer;
@@ -226,6 +235,70 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
         helper.Control.PopOut.Disabled = true;
         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