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 osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface;
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>();
@ -16,6 +15,15 @@ public class ChatRecentTextBox : FocusedTextBox
private string originalMessage = string.Empty;
public MessageHistoryTextBox()
{
Current.ValueChanged += text =>
{
if (string.IsNullOrEmpty(text.NewValue))
messageIndex = -1;
};
}
protected override bool OnKeyDown(KeyDownEvent e)
{
/* Behavior:
@ -53,12 +61,7 @@ protected override bool OnKeyDown(KeyDownEvent e)
return true;
}
bool onKeyDown = base.OnKeyDown(e);
if (string.IsNullOrEmpty(Text))
messageIndex = -1;
return onKeyDown;
return base.OnKeyDown(e);
}
protected override void Commit()

View File

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

View File

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