Skip to content

Commit

Permalink
Chat improvements. (#4283)
Browse files Browse the repository at this point in the history
* UI is an abbreviation, in XAML.

* Chat improvements.

Changing the "selected" channel on the chat box is now only done via the tab cycle or clicking the button.

Prefix chars like [ will temporarily replace the active chat channel. This is based 100% on message box contents so there's no input eating garbage or anything.

Pressing specific channel focusing keys inserts the correct prefix character, potentially replacing an existing one. Existing chat contents are left in place just fine and selected so you can easily delete them (but are not forced to).

Channel focusing keys now match the QWERTY key codes.

Deadchat works now.

Console can no longer be selected as a chat channel, but you can still use it with the / prefix.

Refactored the connection between chat manager and chat box so that it's event based, reducing tons of spaghetti everywhere.

Main chat box control uses XAML now.

General cleanup.

Added focus hotkeys for deadchat/console. Also added prefix for deadchat.

Local chat is mapped to deadchat when a ghost.

Probably more stuff I can't think of right now.

* Add preferred channel system to chat box to automatically select local.

I can't actually test this works because the non-lobby chat box code is complete disastrous spaghetti and i need to refactor it.

* Move chatbox resizing and all that to a subclass.

Refine preferred channel & deadchat mapping code further.

* Don't do prefixes for channels you don't have access to.

* Change format on channel select popup.

* Clean up code with console handling somewhat.
  • Loading branch information
PJB3005 authored Jul 20, 2021
1 parent 4f08bc5 commit b96d760
Show file tree
Hide file tree
Showing 22 changed files with 1,296 additions and 1,274 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Alerts/UI/AlertsUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected override void EnteredTree()
base.EnteredTree();
var _chatManager = IoCManager.Resolve<IChatManager>();
_chatManager.OnChatBoxResized += OnChatResized;
OnChatResized(new ChatResizedEventArgs(ChatBox.InitialChatBottom));
OnChatResized(new ChatResizedEventArgs(HudChatBox.InitialChatBottom));
}

protected override void ExitedTree()
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Chat/ChatHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static Color ChatColor(ChatChannel channel) =>
ChatChannel.Radio => Color.Green,
ChatChannel.OOC => Color.LightSkyBlue,
ChatChannel.Dead => Color.MediumPurple,
ChatChannel.AdminChat => Color.Red,
ChatChannel.Admin => Color.Red,
_ => Color.DarkGray
};
}
Expand Down
42 changes: 42 additions & 0 deletions Content.Client/Chat/ChatInput.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Content.Client.Chat.UI;
using Content.Client.Viewport;
using Content.Shared.Chat;
using Content.Shared.Input;
using Robust.Client.Input;
using Robust.Shared.Input.Binding;

namespace Content.Client.Chat
{
public static class ChatInput
{
public static void SetupChatInputHandlers(IInputManager inputManager, ChatBox chatBox)
{
inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
InputCmdHandler.FromDelegate(_ => GameScreen.FocusChat(chatBox)));

inputManager.SetInputCommand(ContentKeyFunctions.FocusLocalChat,
InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.Local)));

inputManager.SetInputCommand(ContentKeyFunctions.FocusOOC,
InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.OOC)));

inputManager.SetInputCommand(ContentKeyFunctions.FocusAdminChat,
InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.Admin)));

inputManager.SetInputCommand(ContentKeyFunctions.FocusRadio,
InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.Radio)));

inputManager.SetInputCommand(ContentKeyFunctions.FocusDeadChat,
InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.Dead)));

inputManager.SetInputCommand(ContentKeyFunctions.FocusConsoleChat,
InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.Console)));

inputManager.SetInputCommand(ContentKeyFunctions.CycleChatChannelForward,
InputCmdHandler.FromDelegate(_ => chatBox.CycleChatChannel(true)));

inputManager.SetInputCommand(ContentKeyFunctions.CycleChatChannelBackward,
InputCmdHandler.FromDelegate(_ => chatBox.CycleChatChannel(false)));
}
}
}
Loading

0 comments on commit b96d760

Please sign in to comment.