diff --git a/Content.Client/Chat/ChatBox.cs b/Content.Client/Chat/ChatBox.cs
index 7e2a7d3d19..5561e70e41 100644
--- a/Content.Client/Chat/ChatBox.cs
+++ b/Content.Client/Chat/ChatBox.cs
@@ -7,6 +7,7 @@ using Content.Client.UserInterface;
using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility;
using Content.Shared.Chat;
+using Content.Shared.Input;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Client.State;
@@ -59,7 +60,7 @@ namespace Content.Client.Chat
///
/// Will be Unspecified if set to Console
///
- public ChatChannel SelectedChannel;
+ public ChatChannel SelectedChannel = ChatChannel.Unspecified;
///
/// Default formatting string for the ClientChatConsole.
@@ -279,7 +280,7 @@ namespace Content.Client.Chat
/// entries (which should not be presented to the user)
/// unread message counts for each disabled channel, values 10 or higher will show as 9+
public void SetChannelPermissions(List selectableChannels, IReadOnlySet filterableChannels,
- IReadOnlyDictionary channelFilters, IReadOnlyDictionary unreadMessages)
+ IReadOnlyDictionary channelFilters, IReadOnlyDictionary unreadMessages, bool switchIfConsole)
{
SelectableChannels = selectableChannels;
// update the channel selector
@@ -305,10 +306,15 @@ namespace Content.Client.Chat
_savedSelectedChannel = null;
}
- if (!selectableChannels.Contains(SelectedChannel) && SelectedChannel != ChatChannel.Unspecified)
+ if (!selectableChannels.Contains(SelectedChannel) && (switchIfConsole || SelectedChannel != ChatChannel.Unspecified))
{
- // our previously selected channel no longer exists, default back to OOC, which should always be available
- if (selectableChannels.Contains(ChatChannel.OOC))
+ // our previously selected channel no longer exists or we are still on console channel because we just joined
+ if ((SelectedChannel & ChatChannel.IC) != 0 || SelectedChannel == ChatChannel.Unspecified)
+ {
+ if (!SafelySelectChannel(ChatChannel.Local))
+ SafelySelectChannel(ChatChannel.Dead);
+ }
+ else if (selectableChannels.Contains(ChatChannel.OOC))
{
SafelySelectChannel(ChatChannel.OOC);
}
@@ -498,6 +504,24 @@ namespace Content.Client.Chat
UserInterfaceManager.KeyboardFocused?.ReleaseKeyboardFocus();
}
+ public void CycleChatChannel(bool forward)
+ {
+ Input.IgnoreNext = true;
+ var channels = SelectableChannels;
+ var idx = channels.IndexOf(SelectedChannel);
+ if (forward)
+ {
+ idx++;
+ }
+ else
+ {
+ idx--;
+ }
+ idx = MathHelper.Mod(idx, channels.Count);
+
+ SelectChannel(channels[idx]);
+ }
+
private void InputKeyBindDown(GUIBoundKeyEventArgs args)
{
if (args.Function == EngineKeyFunctions.TextReleaseFocus)
@@ -507,9 +531,22 @@ namespace Content.Client.Chat
return;
}
+ if (args.Function == ContentKeyFunctions.CycleChatChannelForward)
+ {
+ CycleChatChannel(true);
+ args.Handle();
+ return;
+ }
+
+ if (args.Function == ContentKeyFunctions.CycleChatChannelBackward)
+ {
+ CycleChatChannel(false);
+ args.Handle();
+ return;
+ }
+
// if we temporarily selected another channel via a prefx, undo that when we backspace on an empty input
- if (Input.Text.Length == 0 && _savedSelectedChannel.HasValue &&
- args.Function == EngineKeyFunctions.TextBackspace)
+ if (args.Function == EngineKeyFunctions.TextBackspace && Input.Text.Length == 0 && _savedSelectedChannel.HasValue)
{
SafelySelectChannel(_savedSelectedChannel.Value);
_savedSelectedChannel = null;
diff --git a/Content.Client/Chat/ChatManager.cs b/Content.Client/Chat/ChatManager.cs
index 4723bb12f8..a161db96e1 100644
--- a/Content.Client/Chat/ChatManager.cs
+++ b/Content.Client/Chat/ChatManager.cs
@@ -242,7 +242,7 @@ namespace Content.Client.Chat
}
// let our chatbox know all the new settings
- CurrentChatBox?.SetChannelPermissions(_selectableChannels, _filterableChannels, _channelFilters, _unreadMessages);
+ CurrentChatBox?.SetChannelPermissions(_selectableChannels, _filterableChannels, _channelFilters, _unreadMessages, true);
}
///
@@ -311,7 +311,7 @@ namespace Content.Client.Chat
CurrentChatBox.FilterToggled += OnFilterButtonToggled;
CurrentChatBox.OnResized += ChatBoxOnResized;
- CurrentChatBox.SetChannelPermissions(_selectableChannels, _filterableChannels, _channelFilters, _unreadMessages);
+ CurrentChatBox.SetChannelPermissions(_selectableChannels, _filterableChannels, _channelFilters, _unreadMessages, false);
}
RepopulateChat(_filteredHistory);
diff --git a/Content.Client/State/GameScreen.cs b/Content.Client/State/GameScreen.cs
index a601f2210d..15ce218bc0 100644
--- a/Content.Client/State/GameScreen.cs
+++ b/Content.Client/State/GameScreen.cs
@@ -79,10 +79,10 @@ namespace Content.Client.State
InputCmdHandler.FromDelegate(_ => FocusChannel(_gameChat, ChatChannel.AdminChat)));
_inputManager.SetInputCommand(ContentKeyFunctions.CycleChatChannelForward,
- InputCmdHandler.FromDelegate(_ => CycleChatChannel(_gameChat, true)));
+ InputCmdHandler.FromDelegate(_ => _gameChat.CycleChatChannel(true)));
_inputManager.SetInputCommand(ContentKeyFunctions.CycleChatChannelBackward,
- InputCmdHandler.FromDelegate(_ => CycleChatChannel(_gameChat, false)));
+ InputCmdHandler.FromDelegate(_ => _gameChat.CycleChatChannel(false)));
SetupPresenters();
@@ -136,27 +136,9 @@ namespace Content.Client.State
return;
}
- chat.Input.IgnoreNext = true;
chat.SelectChannel(channel);
- }
-
- internal static void CycleChatChannel(ChatBox chat, bool forward)
- {
chat.Input.IgnoreNext = true;
- var channels = chat.SelectableChannels;
- var idx = channels.IndexOf(chat.SelectedChannel);
- if (forward)
- {
- idx++;
- idx = MathHelper.Mod(idx, channels.Count());
- }
- else
- {
- idx--;
- idx = MathHelper.Mod(idx, channels.Count());
- }
-
- chat.SelectChannel(channels[idx]);
+ chat.Input.GrabKeyboardFocus();
}
public override void FrameUpdate(FrameEventArgs e)
diff --git a/Content.Client/State/LobbyState.cs b/Content.Client/State/LobbyState.cs
index 6c75e9ab7e..d6635e1984 100644
--- a/Content.Client/State/LobbyState.cs
+++ b/Content.Client/State/LobbyState.cs
@@ -83,10 +83,10 @@ namespace Content.Client.State
InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(_lobby.Chat, ChatChannel.AdminChat)));
_inputManager.SetInputCommand(ContentKeyFunctions.CycleChatChannelForward,
- InputCmdHandler.FromDelegate(_ => GameScreen.CycleChatChannel(_lobby.Chat, true)));
+ InputCmdHandler.FromDelegate(_ => _lobby.Chat.CycleChatChannel(true)));
_inputManager.SetInputCommand(ContentKeyFunctions.CycleChatChannelBackward,
- InputCmdHandler.FromDelegate(_ => GameScreen.CycleChatChannel(_lobby.Chat, false)));
+ InputCmdHandler.FromDelegate(_ => _lobby.Chat.CycleChatChannel(false)));
UpdateLobbyUi();
diff --git a/Content.Shared/Chat/ChatChannel.cs b/Content.Shared/Chat/ChatChannel.cs
index cb159bc8c9..9d76beb32c 100644
--- a/Content.Shared/Chat/ChatChannel.cs
+++ b/Content.Shared/Chat/ChatChannel.cs
@@ -61,5 +61,10 @@ namespace Content.Shared.Chat
/// Unspecified.
///
Unspecified = 512,
+
+ ///
+ /// Channels considered to be IC.
+ ///
+ IC = Local | Radio | Dead | Emotes | Damage | Visual,
}
}