diff --git a/Content.Client/Chat/ChatBox.cs b/Content.Client/Chat/ChatBox.cs index 554d1fd918..3ad087d1ae 100644 --- a/Content.Client/Chat/ChatBox.cs +++ b/Content.Client/Chat/ChatBox.cs @@ -17,13 +17,9 @@ namespace Content.Client.Chat public delegate void FilterToggledHandler(ChatBox chatBox, BaseButton.ButtonToggledEventArgs e); - private const int MaxLinePixelLength = 500; + private readonly ILocalizationManager _localize = IoCManager.Resolve(); - private readonly IList _inputHistory = new List(); - - private readonly ILocalizationManager localize = IoCManager.Resolve(); - - public LineEdit Input { get; private set; } + public HistoryLineEdit Input { get; private set; } public OutputPanel Contents { get; } // Buttons for filtering @@ -31,16 +27,6 @@ namespace Content.Client.Chat public Button LocalButton { get; } public Button OOCButton { get; } - /// - /// Index while cycling through the input history. -1 means not going through history. - /// - private int _inputIndex = -1; - - /// - /// Message that WAS being input before going through history began. - /// - private string _inputTemp; - /// /// Default formatting string for the ClientChatConsole. /// @@ -81,14 +67,14 @@ namespace Content.Client.Chat contentMargin.AddChild(Contents); vBox.AddChild(contentMargin); - Input = new LineEdit(); + Input = new HistoryLineEdit(); Input.OnKeyBindDown += InputKeyBindDown; Input.OnTextEntered += Input_OnTextEntered; vBox.AddChild(Input); AllButton = new Button { - Text = localize.GetString("All"), + Text = _localize.GetString("All"), Name = "ALL", SizeFlagsHorizontal = SizeFlags.ShrinkEnd | SizeFlags.Expand, ToggleMode = true, @@ -96,14 +82,14 @@ namespace Content.Client.Chat LocalButton = new Button { - Text = localize.GetString("Local"), + Text = _localize.GetString("Local"), Name = "Local", ToggleMode = true, }; OOCButton = new Button { - Text = localize.GetString("OOC"), + Text = _localize.GetString("OOC"), Name = "OOC", ToggleMode = true, }; @@ -139,44 +125,6 @@ namespace Content.Client.Chat args.Handle(); return; } - else if (args.Function == EngineKeyFunctions.TextHistoryPrev) - { - if (_inputIndex == -1 && _inputHistory.Count != 0) - { - _inputTemp = Input.Text; - _inputIndex++; - } - else if (_inputIndex + 1 < _inputHistory.Count) - { - _inputIndex++; - } - - if (_inputIndex != -1) - { - Input.Text = _inputHistory[_inputIndex]; - } - Input.CursorPos = Input.Text.Length; - - args.Handle(); - return; - } - else if (args.Function == EngineKeyFunctions.TextHistoryNext) - { - if (_inputIndex == 0) - { - Input.Text = _inputTemp; - _inputTemp = ""; - _inputIndex--; - } - else if (_inputIndex != -1) - { - _inputIndex--; - Input.Text = _inputHistory[_inputIndex]; - } - Input.CursorPos = Input.Text.Length; - - args.Handle(); - } } public event TextSubmitHandler TextSubmitted; @@ -202,11 +150,8 @@ namespace Content.Client.Chat if (!string.IsNullOrWhiteSpace(args.Text)) { TextSubmitted?.Invoke(this, args.Text); - _inputHistory.Insert(0, args.Text); } - _inputIndex = -1; - Input.Clear(); if (ReleaseFocusOnEnter)