mirror of
https://github.com/ppy/osu
synced 2024-12-22 14:54:35 +00:00
Hide !mp
commands from tournament streaming chat
This commit is contained in:
parent
d72a0b04b8
commit
09fc30e377
@ -152,6 +152,12 @@ namespace osu.Game.Tournament.Tests.Components
|
|||||||
AddStep("change channel to 2", () => chatDisplay.Channel.Value = testChannel2);
|
AddStep("change channel to 2", () => chatDisplay.Channel.Value = testChannel2);
|
||||||
|
|
||||||
AddStep("change channel to 1", () => chatDisplay.Channel.Value = testChannel);
|
AddStep("change channel to 1", () => chatDisplay.Channel.Value = testChannel);
|
||||||
|
|
||||||
|
AddStep("!mp message (shouldn't display)", () => testChannel.AddNewMessages(new Message(nextMessageId())
|
||||||
|
{
|
||||||
|
Sender = redUser.ToAPIUser(),
|
||||||
|
Content = "!mp wangs"
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int messageId;
|
private int messageId;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// 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 System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -72,7 +73,13 @@ namespace osu.Game.Tournament.Components
|
|||||||
|
|
||||||
public void Contract() => this.FadeOut(200);
|
public void Contract() => this.FadeOut(200);
|
||||||
|
|
||||||
protected override ChatLine CreateMessage(Message message) => new MatchMessage(message, ladderInfo);
|
protected override ChatLine? CreateMessage(Message message)
|
||||||
|
{
|
||||||
|
if (message.Content.StartsWith("!mp", StringComparison.Ordinal))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new MatchMessage(message, ladderInfo);
|
||||||
|
}
|
||||||
|
|
||||||
protected override StandAloneDrawableChannel CreateDrawableChannel(Channel channel) => new MatchChannel(channel);
|
protected override StandAloneDrawableChannel CreateDrawableChannel(Channel channel) => new MatchChannel(channel);
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -21,18 +20,18 @@ using osuTK.Input;
|
|||||||
namespace osu.Game.Online.Chat
|
namespace osu.Game.Online.Chat
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Display a chat channel in an insolated region.
|
/// Display a chat channel in an isolated region.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class StandAloneChatDisplay : CompositeDrawable
|
public partial class StandAloneChatDisplay : CompositeDrawable
|
||||||
{
|
{
|
||||||
[Cached]
|
[Cached]
|
||||||
public readonly Bindable<Channel> Channel = new Bindable<Channel>();
|
public readonly Bindable<Channel?> Channel = new Bindable<Channel?>();
|
||||||
|
|
||||||
protected readonly ChatTextBox TextBox;
|
protected readonly ChatTextBox? TextBox;
|
||||||
|
|
||||||
private ChannelManager channelManager;
|
private ChannelManager? channelManager;
|
||||||
|
|
||||||
private StandAloneDrawableChannel drawableChannel;
|
private StandAloneDrawableChannel? drawableChannel;
|
||||||
|
|
||||||
private readonly bool postingTextBox;
|
private readonly bool postingTextBox;
|
||||||
|
|
||||||
@ -93,6 +92,8 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
private void postMessage(TextBox sender, bool newText)
|
private void postMessage(TextBox sender, bool newText)
|
||||||
{
|
{
|
||||||
|
Debug.Assert(TextBox != null);
|
||||||
|
|
||||||
string text = TextBox.Text.Trim();
|
string text = TextBox.Text.Trim();
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(text))
|
if (string.IsNullOrWhiteSpace(text))
|
||||||
@ -106,9 +107,9 @@ namespace osu.Game.Online.Chat
|
|||||||
TextBox.Text = string.Empty;
|
TextBox.Text = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual ChatLine CreateMessage(Message message) => new StandAloneMessage(message);
|
protected virtual ChatLine? CreateMessage(Message message) => new StandAloneMessage(message);
|
||||||
|
|
||||||
private void channelChanged(ValueChangedEvent<Channel> e)
|
private void channelChanged(ValueChangedEvent<Channel?> e)
|
||||||
{
|
{
|
||||||
drawableChannel?.Expire();
|
drawableChannel?.Expire();
|
||||||
|
|
||||||
@ -128,8 +129,8 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
public partial class ChatTextBox : HistoryTextBox
|
public partial class ChatTextBox : HistoryTextBox
|
||||||
{
|
{
|
||||||
public Action Focus;
|
public Action? Focus;
|
||||||
public Action FocusLost;
|
public Action? FocusLost;
|
||||||
|
|
||||||
protected override bool OnKeyDown(KeyDownEvent e)
|
protected override bool OnKeyDown(KeyDownEvent e)
|
||||||
{
|
{
|
||||||
@ -171,14 +172,14 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
public partial class StandAloneDrawableChannel : DrawableChannel
|
public partial class StandAloneDrawableChannel : DrawableChannel
|
||||||
{
|
{
|
||||||
public Func<Message, ChatLine> CreateChatLineAction;
|
public Func<Message, ChatLine?>? CreateChatLineAction;
|
||||||
|
|
||||||
public StandAloneDrawableChannel(Channel channel)
|
public StandAloneDrawableChannel(Channel channel)
|
||||||
: base(channel)
|
: base(channel)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ChatLine CreateChatLine(Message m) => CreateChatLineAction(m);
|
protected override ChatLine? CreateChatLine(Message m) => CreateChatLineAction?.Invoke(m) ?? null;
|
||||||
|
|
||||||
protected override DaySeparator CreateDaySeparator(DateTimeOffset time) => new StandAloneDaySeparator(time);
|
protected override DaySeparator CreateDaySeparator(DateTimeOffset time) => new StandAloneDaySeparator(time);
|
||||||
}
|
}
|
||||||
|
@ -155,9 +155,14 @@ namespace osu.Game.Overlays.Chat
|
|||||||
{
|
{
|
||||||
addDaySeparatorIfRequired(lastMessage, message);
|
addDaySeparatorIfRequired(lastMessage, message);
|
||||||
|
|
||||||
ChatLineFlow.Add(CreateChatLine(message));
|
var chatLine = CreateChatLine(message);
|
||||||
|
|
||||||
|
if (chatLine != null)
|
||||||
|
{
|
||||||
|
ChatLineFlow.Add(chatLine);
|
||||||
lastMessage = message;
|
lastMessage = message;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var staleMessages = chatLines.Where(c => c.LifetimeEnd == double.MaxValue).ToArray();
|
var staleMessages = chatLines.Where(c => c.LifetimeEnd == double.MaxValue).ToArray();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user