Only show local/radio/emote channels when in-game (#5566)

This commit is contained in:
Clyybber
2021-11-27 07:43:58 +01:00
committed by GitHub
parent a354741b4b
commit d6d73573cb

View File

@@ -4,12 +4,14 @@ using System.Linq;
using Content.Client.Administration.Managers; using Content.Client.Administration.Managers;
using Content.Client.Chat.UI; using Content.Client.Chat.UI;
using Content.Client.Ghost; using Content.Client.Ghost;
using Content.Client.Viewport;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Content.Shared.Chat; using Content.Shared.Chat;
using Robust.Client.Console; using Robust.Client.Console;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Client.State;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
@@ -94,6 +96,7 @@ namespace Content.Client.Chat.Managers
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!; [Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IClientAdminManager _adminMgr = default!; [Dependency] private readonly IClientAdminManager _adminMgr = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!; [Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IStateManager _stateManager = default!;
/// <summary> /// <summary>
/// Current chat box control. This can be modified, so do not depend on saving a reference to this. /// Current chat box control. This can be modified, so do not depend on saving a reference to this.
@@ -133,6 +136,7 @@ namespace Content.Client.Chat.Managers
LayoutContainer.SetAnchorPreset(_speechBubbleRoot, LayoutContainer.LayoutPreset.Wide); LayoutContainer.SetAnchorPreset(_speechBubbleRoot, LayoutContainer.LayoutPreset.Wide);
_userInterfaceManager.StateRoot.AddChild(_speechBubbleRoot); _userInterfaceManager.StateRoot.AddChild(_speechBubbleRoot);
_speechBubbleRoot.SetPositionFirst(); _speechBubbleRoot.SetPositionFirst();
_stateManager.OnStateChanged += _ => UpdateChannelPermissions();
} }
public void PostInject() public void PostInject()
@@ -188,8 +192,9 @@ namespace Content.Client.Chat.Managers
// can always hear server (nobody can actually send server messages). // can always hear server (nobody can actually send server messages).
FilterableChannels |= ChatChannel.Server; FilterableChannels |= ChatChannel.Server;
// can always hear local / radio / emote if (_stateManager.CurrentState is GameScreenBase)
// todo: this makes no sense the lobby exists fix this. {
// can always hear local / radio / emote when in the game
FilterableChannels |= ChatChannel.Local; FilterableChannels |= ChatChannel.Local;
FilterableChannels |= ChatChannel.Radio; FilterableChannels |= ChatChannel.Radio;
FilterableChannels |= ChatChannel.Emotes; FilterableChannels |= ChatChannel.Emotes;
@@ -202,6 +207,7 @@ namespace Content.Client.Chat.Managers
SelectableChannels |= ChatSelectChannel.Radio; SelectableChannels |= ChatSelectChannel.Radio;
SelectableChannels |= ChatSelectChannel.Emotes; SelectableChannels |= ChatSelectChannel.Emotes;
} }
}
// Only ghosts and admins can send / see deadchat. // Only ghosts and admins can send / see deadchat.
if (_adminMgr.HasFlag(AdminFlags.Admin) || IsGhost) if (_adminMgr.HasFlag(AdminFlags.Admin) || IsGhost)