mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 05:22:54 +08:00
null guard for Current Match in MatchMessage
This commit is contained in:
parent
0dced46100
commit
a3cd0d14a3
@ -63,18 +63,6 @@ namespace osu.Game.Tournament.Tests.Components
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
});
|
});
|
||||||
|
|
||||||
ladderInfo.CurrentMatch.Value = new TournamentMatch
|
|
||||||
{
|
|
||||||
Team1 =
|
|
||||||
{
|
|
||||||
Value = new TournamentTeam { Players = new BindableList<TournamentUser> { redUser } }
|
|
||||||
},
|
|
||||||
Team2 =
|
|
||||||
{
|
|
||||||
Value = new TournamentTeam { Players = new BindableList<TournamentUser> { blueUser, blueUserWithCustomColour } }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
chatDisplay.Channel.Value = testChannel;
|
chatDisplay.Channel.Value = testChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +76,18 @@ namespace osu.Game.Tournament.Tests.Components
|
|||||||
Content = "I am a wang!"
|
Content = "I am a wang!"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
AddStep("set Current match", () => ladderInfo.CurrentMatch.Value = new TournamentMatch
|
||||||
|
{
|
||||||
|
Team1 =
|
||||||
|
{
|
||||||
|
Value = new TournamentTeam { Players = new BindableList<TournamentUser> { redUser } }
|
||||||
|
},
|
||||||
|
Team2 =
|
||||||
|
{
|
||||||
|
Value = new TournamentTeam { Players = new BindableList<TournamentUser> { blueUser, blueUserWithCustomColour } }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId())
|
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId())
|
||||||
{
|
{
|
||||||
Sender = redUser.ToAPIUser(),
|
Sender = redUser.ToAPIUser(),
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// 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.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -19,10 +17,10 @@ namespace osu.Game.Tournament.Components
|
|||||||
{
|
{
|
||||||
private readonly Bindable<string> chatChannel = new Bindable<string>();
|
private readonly Bindable<string> chatChannel = new Bindable<string>();
|
||||||
|
|
||||||
private ChannelManager manager;
|
private ChannelManager? manager;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private LadderInfo ladderInfo { get; set; }
|
private LadderInfo ladderInfo { get; set; } = null!;
|
||||||
|
|
||||||
public TournamentMatchChatDisplay()
|
public TournamentMatchChatDisplay()
|
||||||
{
|
{
|
||||||
@ -35,7 +33,7 @@ namespace osu.Game.Tournament.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(MatchIPCInfo ipc, IAPIProvider api)
|
private void load(MatchIPCInfo? ipc, IAPIProvider api)
|
||||||
{
|
{
|
||||||
if (ipc != null)
|
if (ipc != null)
|
||||||
{
|
{
|
||||||
@ -92,6 +90,8 @@ namespace osu.Game.Tournament.Components
|
|||||||
public MatchMessage(Message message, LadderInfo info)
|
public MatchMessage(Message message, LadderInfo info)
|
||||||
: base(message)
|
: base(message)
|
||||||
{
|
{
|
||||||
|
if (info.CurrentMatch.Value == null) return;
|
||||||
|
|
||||||
if (info.CurrentMatch.Value.Team1.Value.Players.Any(u => u.OnlineID == Message.Sender.OnlineID))
|
if (info.CurrentMatch.Value.Team1.Value.Players.Any(u => u.OnlineID == Message.Sender.OnlineID))
|
||||||
UsernameColour = TournamentGame.COLOUR_RED;
|
UsernameColour = TournamentGame.COLOUR_RED;
|
||||||
else if (info.CurrentMatch.Value.Team2.Value.Players.Any(u => u.OnlineID == Message.Sender.OnlineID))
|
else if (info.CurrentMatch.Value.Team2.Value.Players.Any(u => u.OnlineID == Message.Sender.OnlineID))
|
||||||
|
Loading…
Reference in New Issue
Block a user