1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 16:07:24 +08:00

null guard for Current Match in MatchMessage

This commit is contained in:
cdwcgt 2023-06-25 20:46:58 +09:00
parent 0dced46100
commit a3cd0d14a3
No known key found for this signature in database
GPG Key ID: 144396D01095C3A2
2 changed files with 17 additions and 17 deletions

View File

@ -63,18 +63,6 @@ namespace osu.Game.Tournament.Tests.Components
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;
}
@ -88,6 +76,18 @@ namespace osu.Game.Tournament.Tests.Components
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())
{
Sender = redUser.ToAPIUser(),

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -19,10 +17,10 @@ namespace osu.Game.Tournament.Components
{
private readonly Bindable<string> chatChannel = new Bindable<string>();
private ChannelManager manager;
private ChannelManager? manager;
[Resolved]
private LadderInfo ladderInfo { get; set; }
private LadderInfo ladderInfo { get; set; } = null!;
public TournamentMatchChatDisplay()
{
@ -35,7 +33,7 @@ namespace osu.Game.Tournament.Components
}
[BackgroundDependencyLoader(true)]
private void load(MatchIPCInfo ipc, IAPIProvider api)
private void load(MatchIPCInfo? ipc, IAPIProvider api)
{
if (ipc != null)
{
@ -92,6 +90,8 @@ namespace osu.Game.Tournament.Components
public MatchMessage(Message message, LadderInfo info)
: base(message)
{
if (info.CurrentMatch.Value == null) return;
if (info.CurrentMatch.Value.Team1.Value.Players.Any(u => u.OnlineID == Message.Sender.OnlineID))
UsernameColour = TournamentGame.COLOUR_RED;
else if (info.CurrentMatch.Value.Team2.Value.Players.Any(u => u.OnlineID == Message.Sender.OnlineID))