Chairbender Chat (#3794)
* #272 restructure and restyle chat line edit section * #272 no arrow, actually change id on channel changer * #272 nice round chat channel picker * #272 add chat channel selection logic, and auto-select when a prefix is entered * #272 consistent width of chat channel btn * #272 only show admin channel filter if asay perms * #272 add tutorial info on chat prefixes * #272 added chat filter button * #272 added chat filter button * #272 WIP on filter popup * #272 fix filter popup pressed / unpressed logic * #272 fix filter popup positioning and layout * #272 WIP channel filter logic * #272 WIP channel filter logic * #272 WIP refactoring how chatbox / manager manages available filters and channels to send on * #272 WIP implementing filtering UI / logic and refactoring how chat UI is managed * #272 fix various bugs with new chat filter / selector logic * #272 remove outdated todos * #272 WIP working chat window resize * #272 bounded chatbox resizing * #272 alertUI moves with resized chat * #272 WIP making alertUI not be too large when changing size / UIScale * #272 WIP fixing window / uiscale adjustment * #272 WIP hacky approach for resizing, will try another approach * #272 implement hacky approach for bounded chat resize * #272 no resizing of lobby chat * #272 WIP adding unread marker to chat filters * #272 basic working unread chat message indicators * #272 WIP adding horizontal channel selector items * #272 horizontal channel selector popup * #272 workaround for chat selector staying highlighted when right clicking it while toggled * #272 workaround for chat selector staying highlighted when right clicking it while toggled * #272 wip trying to add tests for chatbox * #272 remove test, not really possible with current system * #272 merge latest * #272 merge latest * #272 fix csproj changes * It works if you disable the lobby * Fixes lobby chat * Adds more channel focusses * Channel cycler * Address review * Address nitpicks * Address more of the review * Fix chat post-viewport * Finalize review stuff Co-authored-by: chairbender <kwhipke1@gmail.com> Co-authored-by: ike709 <sparebytes@protonmail.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Linq;
|
||||
using Content.Client.Administration;
|
||||
using Content.Client.Chat;
|
||||
using Content.Client.Construction;
|
||||
@@ -5,6 +6,7 @@ using Content.Client.Interfaces.Chat;
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Client.Voting;
|
||||
using Content.Shared;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Input;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Input;
|
||||
@@ -37,9 +39,6 @@ namespace Content.Client.State
|
||||
[ViewVariables] private ChatBox? _gameChat;
|
||||
private ConstructionMenuPresenter? _constructionMenu;
|
||||
|
||||
private bool _oocEnabled;
|
||||
private bool _adminOocEnabled;
|
||||
|
||||
public MainViewport Viewport { get; private set; } = default!;
|
||||
|
||||
public override void Startup()
|
||||
@@ -59,29 +58,31 @@ namespace Content.Client.State
|
||||
LayoutContainer.SetAnchorPreset(Viewport, LayoutContainer.LayoutPreset.Wide);
|
||||
Viewport.SetPositionFirst();
|
||||
|
||||
_userInterfaceManager.StateRoot.AddChild(_gameChat);
|
||||
LayoutContainer.SetAnchorAndMarginPreset(_gameChat, LayoutContainer.LayoutPreset.TopRight, margin: 10);
|
||||
LayoutContainer.SetMarginLeft(_gameChat, -475);
|
||||
LayoutContainer.SetMarginBottom(_gameChat, 235);
|
||||
|
||||
_userInterfaceManager.StateRoot.AddChild(_gameHud.RootControl);
|
||||
_chatManager.SetChatBox(_gameChat);
|
||||
_voteManager.SetPopupContainer(_gameHud.VoteContainer);
|
||||
_gameChat.DefaultChatFormat = "say \"{0}\"";
|
||||
_gameChat.Input.PlaceHolder = Loc.GetString("Say something! [ for OOC");
|
||||
|
||||
_inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
|
||||
InputCmdHandler.FromDelegate(_ => FocusChat(_gameChat)));
|
||||
|
||||
_inputManager.SetInputCommand(ContentKeyFunctions.FocusOOC,
|
||||
InputCmdHandler.FromDelegate(_ => FocusOOC(_gameChat)));
|
||||
InputCmdHandler.FromDelegate(_ => FocusChannel(_gameChat, ChatChannel.OOC)));
|
||||
|
||||
_inputManager.SetInputCommand(ContentKeyFunctions.FocusLocalChat,
|
||||
InputCmdHandler.FromDelegate(_ => FocusChannel(_gameChat, ChatChannel.Local)));
|
||||
|
||||
_inputManager.SetInputCommand(ContentKeyFunctions.FocusRadio,
|
||||
InputCmdHandler.FromDelegate(_ => FocusChannel(_gameChat, ChatChannel.Radio)));
|
||||
|
||||
_inputManager.SetInputCommand(ContentKeyFunctions.FocusAdminChat,
|
||||
InputCmdHandler.FromDelegate(_ => FocusAdminChat(_gameChat)));
|
||||
InputCmdHandler.FromDelegate(_ => FocusChannel(_gameChat, ChatChannel.AdminChat)));
|
||||
|
||||
_configurationManager.OnValueChanged(CCVars.OocEnabled, OnOocEnabledChanged, true);
|
||||
_configurationManager.OnValueChanged(CCVars.AdminOocEnabled, OnAdminOocEnabledChanged, true);
|
||||
_adminManager.AdminStatusUpdated += OnAdminStatusUpdated;
|
||||
_inputManager.SetInputCommand(ContentKeyFunctions.CycleChatChannelForward,
|
||||
InputCmdHandler.FromDelegate(_ => CycleChatChannel(_gameChat, true)));
|
||||
|
||||
_inputManager.SetInputCommand(ContentKeyFunctions.CycleChatChannelBackward,
|
||||
InputCmdHandler.FromDelegate(_ => CycleChatChannel(_gameChat, false)));
|
||||
|
||||
SetupPresenters();
|
||||
|
||||
@@ -118,50 +119,9 @@ namespace Content.Client.State
|
||||
_constructionMenu?.Dispose();
|
||||
}
|
||||
|
||||
|
||||
private void OnOocEnabledChanged(bool val)
|
||||
{
|
||||
_oocEnabled = val;
|
||||
|
||||
if (_adminManager.IsActive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(_gameChat is null)
|
||||
return;
|
||||
|
||||
_gameChat.Input.PlaceHolder = Loc.GetString(_oocEnabled ? "Say something! [ for OOC" : "Say something!");
|
||||
}
|
||||
|
||||
private void OnAdminOocEnabledChanged(bool val)
|
||||
{
|
||||
_adminOocEnabled = val;
|
||||
|
||||
if (!_adminManager.IsActive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_gameChat is null)
|
||||
return;
|
||||
|
||||
_gameChat.Input.PlaceHolder = Loc.GetString(_adminOocEnabled ? "Say something! [ for OOC" : "Say something!");
|
||||
}
|
||||
|
||||
private void OnAdminStatusUpdated()
|
||||
{
|
||||
if (_gameChat is null)
|
||||
return;
|
||||
|
||||
_gameChat.Input.PlaceHolder = _adminManager.IsActive()
|
||||
? Loc.GetString(_adminOocEnabled ? "Say something! [ for OOC" : "Say something!")
|
||||
: Loc.GetString(_oocEnabled ? "Say something! [ for OOC" : "Say something!");
|
||||
}
|
||||
|
||||
internal static void FocusChat(ChatBox chat)
|
||||
{
|
||||
if (chat == null || chat.UserInterfaceManager.KeyboardFocused != null)
|
||||
if (chat.UserInterfaceManager.KeyboardFocused != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -169,28 +129,34 @@ namespace Content.Client.State
|
||||
chat.Input.IgnoreNext = true;
|
||||
chat.Input.GrabKeyboardFocus();
|
||||
}
|
||||
internal static void FocusOOC(ChatBox chat)
|
||||
internal static void FocusChannel(ChatBox chat, ChatChannel channel)
|
||||
{
|
||||
if (chat == null || chat.UserInterfaceManager.KeyboardFocused != null)
|
||||
if (chat.UserInterfaceManager.KeyboardFocused != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
chat.Input.IgnoreNext = true;
|
||||
chat.Input.GrabKeyboardFocus();
|
||||
chat.Input.InsertAtCursor("[");
|
||||
chat.SelectChannel(channel);
|
||||
}
|
||||
|
||||
internal static void FocusAdminChat(ChatBox chat)
|
||||
internal static void CycleChatChannel(ChatBox chat, bool forward)
|
||||
{
|
||||
if (chat == null || chat.UserInterfaceManager.KeyboardFocused != null)
|
||||
chat.Input.IgnoreNext = true;
|
||||
var channels = chat.SelectableChannels;
|
||||
var idx = channels.IndexOf(chat.SelectedChannel);
|
||||
if (forward)
|
||||
{
|
||||
return;
|
||||
idx++;
|
||||
idx = MathHelper.Mod(idx, channels.Count());
|
||||
}
|
||||
else
|
||||
{
|
||||
idx--;
|
||||
idx = MathHelper.Mod(idx, channels.Count());
|
||||
}
|
||||
|
||||
chat.Input.IgnoreNext = true;
|
||||
chat.Input.GrabKeyboardFocus();
|
||||
chat.Input.InsertAtCursor("]");
|
||||
chat.SelectChannel(channels[idx]);
|
||||
}
|
||||
|
||||
public override void FrameUpdate(FrameEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user