Merge branch 'master' into activity-on-multiplayer-screens

This commit is contained in:
smoogipoo
2021-08-24 12:33:34 +09:00
273 changed files with 5663 additions and 3348 deletions

View File

@ -553,7 +553,7 @@ namespace osu.Game.Online.Chat
if (channel.LastMessageId == channel.LastReadId)
return;
var message = channel.Messages.LastOrDefault();
var message = channel.Messages.FindLast(msg => !(msg is LocalMessage));
if (message == null)
return;

View File

@ -43,7 +43,8 @@ namespace osu.Game.Online.Chat
RegexOptions.IgnoreCase);
// 00:00:000 (1,2,3) - test
private static readonly Regex time_regex = new Regex(@"\d\d:\d\d:\d\d\d? [^-]*");
// regex from https://github.com/ppy/osu-web/blob/651a9bac2b60d031edd7e33b8073a469bf11edaa/resources/assets/coffee/_classes/beatmap-discussion-helper.coffee#L10
private static readonly Regex time_regex = new Regex(@"\b(((\d{2,}):([0-5]\d)[:.](\d{3}))(\s\((?:\d+[,|])*\d+\))?)");
// #osu
private static readonly Regex channel_regex = new Regex(@"(#[a-zA-Z]+[a-zA-Z0-9]+)");

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Chat;
@ -22,7 +23,7 @@ namespace osu.Game.Online.Chat
{
public readonly Bindable<Channel> Channel = new Bindable<Channel>();
private readonly FocusedTextBox textbox;
protected readonly ChatTextBox Textbox;
protected ChannelManager ChannelManager;
@ -30,6 +31,8 @@ namespace osu.Game.Online.Chat
private readonly bool postingTextbox;
protected readonly Box Background;
private const float textbox_height = 30;
/// <summary>
@ -44,7 +47,7 @@ namespace osu.Game.Online.Chat
InternalChildren = new Drawable[]
{
new Box
Background = new Box
{
Colour = Color4.Black,
Alpha = 0.8f,
@ -54,7 +57,7 @@ namespace osu.Game.Online.Chat
if (postingTextbox)
{
AddInternal(textbox = new FocusedTextBox
AddInternal(Textbox = new ChatTextBox
{
RelativeSizeAxes = Axes.X,
Height = textbox_height,
@ -65,7 +68,7 @@ namespace osu.Game.Online.Chat
Origin = Anchor.BottomLeft,
});
textbox.OnCommit += postMessage;
Textbox.OnCommit += postMessage;
}
Channel.BindValueChanged(channelChanged);
@ -82,7 +85,7 @@ namespace osu.Game.Online.Chat
private void postMessage(TextBox sender, bool newtext)
{
var text = textbox.Text.Trim();
var text = Textbox.Text.Trim();
if (string.IsNullOrWhiteSpace(text))
return;
@ -92,7 +95,7 @@ namespace osu.Game.Online.Chat
else
ChannelManager?.PostMessage(text, target: Channel.Value);
textbox.Text = string.Empty;
Textbox.Text = string.Empty;
}
protected virtual ChatLine CreateMessage(Message message) => new StandAloneMessage(message);
@ -110,6 +113,25 @@ namespace osu.Game.Online.Chat
AddInternal(drawableChannel);
}
public class ChatTextBox : FocusedTextBox
{
protected override void LoadComplete()
{
base.LoadComplete();
BackgroundUnfocused = new Color4(10, 10, 10, 10);
BackgroundFocused = new Color4(10, 10, 10, 255);
}
protected override void OnFocusLost(FocusLostEvent e)
{
base.OnFocusLost(e);
FocusLost?.Invoke();
}
public Action FocusLost;
}
public class StandAloneDrawableChannel : DrawableChannel
{
public Func<Message, ChatLine> CreateChatLineAction;