let MatchIPCInfo .Beatmap be nullable

This commit is contained in:
cdwcgt 2023-08-09 19:11:51 +09:00
parent 5898a9986b
commit 5ad80879b7
No known key found for this signature in database
GPG Key ID: 144396D01095C3A2
5 changed files with 7 additions and 6 deletions

View File

@ -29,7 +29,7 @@ namespace osu.Game.Tournament.Components
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
public TournamentBeatmap Beatmap
public TournamentBeatmap? Beatmap
{
set
{

View File

@ -87,12 +87,13 @@ namespace osu.Game.Tournament.IPC
var existing = ladder.CurrentMatch.Value?.Round.Value?.Beatmaps.FirstOrDefault(b => b.ID == beatmapId);
if (existing?.Beatmap != null)
if (existing != null)
Beatmap.Value = existing.Beatmap;
else
{
beatmapLookupRequest = new GetBeatmapRequest(new APIBeatmap { OnlineID = beatmapId });
beatmapLookupRequest.Success += b => Beatmap.Value = new TournamentBeatmap(b);
beatmapLookupRequest.Failure += _ => Beatmap.Value = null;
API.Queue(beatmapLookupRequest);
}
}

View File

@ -10,7 +10,7 @@ namespace osu.Game.Tournament.IPC
{
public partial class MatchIPCInfo : Component
{
public Bindable<TournamentBeatmap> Beatmap { get; } = new Bindable<TournamentBeatmap>();
public Bindable<TournamentBeatmap?> Beatmap { get; } = new Bindable<TournamentBeatmap?>();
public Bindable<LegacyMods> Mods { get; } = new Bindable<LegacyMods>();
public Bindable<TourneyState> State { get; } = new Bindable<TourneyState>();
public Bindable<string> ChatChannel { get; } = new Bindable<string>();

View File

@ -37,7 +37,7 @@ namespace osu.Game.Tournament.Screens
SongBar.Mods = mods.NewValue;
}
private void beatmapChanged(ValueChangedEvent<TournamentBeatmap> beatmap)
private void beatmapChanged(ValueChangedEvent<TournamentBeatmap?> beatmap)
{
SongBar.FadeInFromZero(300, Easing.OutQuint);
SongBar.Beatmap = beatmap.NewValue;

View File

@ -121,13 +121,13 @@ namespace osu.Game.Tournament.Screens.MapPool
splitMapPoolByMods.BindValueChanged(_ => updateDisplay());
}
private void beatmapChanged(ValueChangedEvent<TournamentBeatmap> beatmap)
private void beatmapChanged(ValueChangedEvent<TournamentBeatmap?> beatmap)
{
if (CurrentMatch.Value == null || CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) < 2)
return;
// if bans have already been placed, beatmap changes result in a selection being made autoamtically
if (beatmap.NewValue.OnlineID > 0)
if (beatmap.NewValue?.OnlineID > 0)
addForBeatmap(beatmap.NewValue.OnlineID);
}