Chat channel switching improvements (#4000)

* IC is default when joining;
switch to IC channel if IC channel becomes unavailable before trying OOC

* Allow channel cycling while the textbox is focused

* Fix focus channel keybinds not actually focusing

* Whitespess

* Fix duplicate radio

* Smol CycleChatChannel cleanup

* Revert style change
This commit is contained in:
Clyybber
2021-05-15 12:28:04 +02:00
committed by GitHub
parent 8bfd9f9090
commit 914e49f867
5 changed files with 56 additions and 32 deletions

View File

@@ -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)