Moved and renamed MessageHistoryTextBox.cs for better fit.

This commit is contained in:
Terochi 2022-11-15 13:06:02 +01:00 committed by Terochi
parent b9590320b7
commit 6d83af01e2
3 changed files with 16 additions and 11 deletions

View File

@ -3,12 +3,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface;
using osuTK.Input; using osuTK.Input;
namespace osu.Game.Overlays.Chat namespace osu.Game.Graphics.UserInterface
{ {
public class ChatRecentTextBox : FocusedTextBox public class MessageHistoryTextBox : FocusedTextBox
{ {
private readonly List<string> messageHistory = new List<string>(); private readonly List<string> messageHistory = new List<string>();
@ -16,6 +15,15 @@ namespace osu.Game.Overlays.Chat
private string originalMessage = string.Empty; private string originalMessage = string.Empty;
public MessageHistoryTextBox()
{
Current.ValueChanged += text =>
{
if (string.IsNullOrEmpty(text.NewValue))
messageIndex = -1;
};
}
protected override bool OnKeyDown(KeyDownEvent e) protected override bool OnKeyDown(KeyDownEvent e)
{ {
/* Behavior: /* Behavior:
@ -53,12 +61,7 @@ namespace osu.Game.Overlays.Chat
return true; return true;
} }
bool onKeyDown = base.OnKeyDown(e); return base.OnKeyDown(e);
if (string.IsNullOrEmpty(Text))
messageIndex = -1;
return onKeyDown;
} }
protected override void Commit() protected override void Commit()

View File

@ -12,6 +12,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Chat; using osu.Game.Overlays.Chat;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;
using osuTK.Graphics; using osuTK.Graphics;
@ -119,7 +120,7 @@ namespace osu.Game.Online.Chat
AddInternal(drawableChannel); AddInternal(drawableChannel);
} }
public class ChatTextBox : ChatRecentTextBox public class ChatTextBox : MessageHistoryTextBox
{ {
protected override bool OnKeyDown(KeyDownEvent e) protected override bool OnKeyDown(KeyDownEvent e)
{ {

View File

@ -2,11 +2,12 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Graphics.UserInterface;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Overlays.Chat namespace osu.Game.Overlays.Chat
{ {
public class ChatTextBox : ChatRecentTextBox public class ChatTextBox : MessageHistoryTextBox
{ {
public readonly BindableBool ShowSearch = new BindableBool(); public readonly BindableBool ShowSearch = new BindableBool();