mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 06:12:56 +08:00
Merge pull request #24033 from cdwcgt/chatdisplay-fix
Fix tournament chat potentially crashing due to null current match
This commit is contained in:
commit
66f1ed052b
@ -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(),
|
||||
|
@ -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()
|
||||
{
|
||||
@ -34,8 +32,8 @@ namespace osu.Game.Tournament.Components
|
||||
CornerRadius = 0;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(MatchIPCInfo ipc, IAPIProvider api)
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(MatchIPCInfo? ipc, IAPIProvider api)
|
||||
{
|
||||
if (ipc != null)
|
||||
{
|
||||
@ -92,10 +90,13 @@ namespace osu.Game.Tournament.Components
|
||||
public MatchMessage(Message message, LadderInfo info)
|
||||
: base(message)
|
||||
{
|
||||
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))
|
||||
UsernameColour = TournamentGame.COLOUR_BLUE;
|
||||
if (info.CurrentMatch.Value is TournamentMatch match)
|
||||
{
|
||||
if (match.Team1.Value.Players.Any(u => u.OnlineID == Message.Sender.OnlineID))
|
||||
UsernameColour = TournamentGame.COLOUR_RED;
|
||||
else if (match.Team2.Value.Players.Any(u => u.OnlineID == Message.Sender.OnlineID))
|
||||
UsernameColour = TournamentGame.COLOUR_BLUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user