remove #nullable disable in tournament

This commit is contained in:
cdwcgt 2023-07-25 20:50:55 +09:00
parent a7ff084be2
commit 8a06914438
No known key found for this signature in database
GPG Key ID: 144396D01095C3A2
51 changed files with 333 additions and 382 deletions

View File

@ -3,6 +3,7 @@
using Newtonsoft.Json;
using NUnit.Framework;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Game.Tournament.Models;
namespace osu.Game.Tournament.Tests.NonVisual
@ -35,8 +36,8 @@ private static LadderInfo createSampleLadder()
PlayersPerTeam = { Value = 4 },
Teams =
{
match.Team1.Value,
match.Team2.Value,
match.Team1.Value.AsNonNull(),
match.Team2.Value.AsNonNull(),
},
Rounds =
{

View File

@ -94,7 +94,7 @@ public void TestResetBracketTeams()
AddStep("release mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
AddAssert("assert ladder teams reset", () => Ladder.CurrentMatch.Value.Team1.Value == null && Ladder.CurrentMatch.Value.Team2.Value == null);
AddAssert("assert ladder teams reset", () => Ladder.CurrentMatch.Value?.Team1.Value == null && Ladder.CurrentMatch.Value?.Team2.Value == null);
}
}
}

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Game.Tournament.Models;
using osu.Game.Tournament.Screens.Editors;
@ -17,7 +18,7 @@ private void load()
{
var match = CreateSampleMatch();
Add(new SeedingEditorScreen(match.Team1.Value, new TeamEditorScreen())
Add(new SeedingEditorScreen(match.Team1.Value.AsNonNull(), new TeamEditorScreen())
{
Width = 0.85f // create room for control panel
});

View File

@ -21,7 +21,7 @@ private void load()
{
Team1 = { Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "USA") },
Team2 = { Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "JPN") },
Round = { Value = Ladder.Rounds.FirstOrDefault(g => g.Name.Value == "Finals") }
Round = { Value = Ladder.Rounds.First(g => g.Name.Value == "Quarterfinals") }
};
Add(new TeamIntroScreen

View File

@ -17,7 +17,7 @@ public void TestBasic()
{
var match = Ladder.CurrentMatch.Value!;
match.Round.Value = Ladder.Rounds.FirstOrDefault(g => g.Name.Value == "Finals");
match.Round.Value = Ladder.Rounds.First(g => g.Name.Value == "Quarterfinals");
match.Completed.Value = true;
});

View File

@ -4,6 +4,7 @@
using System.Linq;
using System.Threading;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Platform;
using osu.Framework.Testing;
using osu.Framework.Utils;
@ -40,10 +41,10 @@ private void load(TournamentStorage storage)
match = CreateSampleMatch();
Ladder.Rounds.Add(match.Round.Value);
Ladder.Rounds.Add(match.Round.Value.AsNonNull());
Ladder.Matches.Add(match);
Ladder.Teams.Add(match.Team1.Value);
Ladder.Teams.Add(match.Team2.Value);
Ladder.Teams.Add(match.Team1.Value.AsNonNull());
Ladder.Teams.Add(match.Team2.Value.AsNonNull());
Ruleset.BindTo(Ladder.Ruleset);
Dependencies.CacheAs(new StableInfo(storage));
@ -152,7 +153,7 @@ public virtual void SetUpSteps()
},
Round =
{
Value = new TournamentRound { Name = { Value = "Quarterfinals" } }
Value = new TournamentRound { Name = { Value = "Quarterfinals" } },
}
};

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 JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -17,14 +15,14 @@ namespace osu.Game.Tournament.Components
{
public partial class DrawableTeamFlag : Container
{
private readonly TournamentTeam team;
private readonly TournamentTeam? team;
[UsedImplicitly]
private Bindable<string> flag;
private Bindable<string>? flag;
private Sprite flagSprite;
private Sprite? flagSprite;
public DrawableTeamFlag(TournamentTeam team)
public DrawableTeamFlag(TournamentTeam? team)
{
this.team = team;
}

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 JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -12,12 +10,12 @@ namespace osu.Game.Tournament.Components
{
public partial class DrawableTeamTitle : TournamentSpriteTextWithBackground
{
private readonly TournamentTeam team;
private readonly TournamentTeam? team;
[UsedImplicitly]
private Bindable<string> acronym;
private Bindable<string>? acronym;
public DrawableTeamTitle(TournamentTeam team)
public DrawableTeamTitle(TournamentTeam? team)
{
this.team = team;
}

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 JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -14,15 +12,15 @@ namespace osu.Game.Tournament.Components
{
public abstract partial class DrawableTournamentTeam : CompositeDrawable
{
public readonly TournamentTeam Team;
public readonly TournamentTeam? Team;
protected readonly Container Flag;
protected readonly TournamentSpriteText AcronymText;
[UsedImplicitly]
private Bindable<string> acronym;
private Bindable<string>? acronym;
protected DrawableTournamentTeam(TournamentTeam team)
protected DrawableTournamentTeam(TournamentTeam? team)
{
Team = team;
@ -36,7 +34,8 @@ protected DrawableTournamentTeam(TournamentTeam team)
[BackgroundDependencyLoader]
private void load()
{
if (Team == null) return;
if (Team == null)
return;
(acronym = Team.Acronym.GetBoundCopy()).BindValueChanged(_ => AcronymText.Text = Team?.Acronym.Value?.ToUpperInvariant() ?? string.Empty, true);
}

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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -24,12 +22,12 @@ namespace osu.Game.Tournament.Components
{
public partial class SongBar : CompositeDrawable
{
private TournamentBeatmap beatmap;
private TournamentBeatmap? beatmap;
public const float HEIGHT = 145 / 2f;
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; }
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
public TournamentBeatmap Beatmap
{
@ -55,7 +53,7 @@ public LegacyMods Mods
}
}
private FillFlowContainer flow;
private FillFlowContainer flow = null!;
private bool expanded;

View File

@ -22,13 +22,13 @@ public partial class TournamentBeatmapPanel : CompositeDrawable
{
public readonly TournamentBeatmap? Beatmap;
private readonly string mod;
private readonly string? mod;
public const float HEIGHT = 50;
private readonly Bindable<TournamentMatch?> currentMatch = new Bindable<TournamentMatch?>();
private Box flash = null!;
private Box? flash;
public TournamentBeatmapPanel(TournamentBeatmap? beatmap, string mod = "")
{
@ -135,25 +135,29 @@ private void matchChanged(ValueChangedEvent<TournamentMatch?> match)
match.OldValue.PicksBans.CollectionChanged -= picksBansOnCollectionChanged;
if (match.NewValue != null)
match.NewValue.PicksBans.CollectionChanged += picksBansOnCollectionChanged;
Scheduler.AddOnce(updateState);
updateState();
}
private void picksBansOnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
=> Scheduler.AddOnce(updateState);
=> updateState();
private BeatmapChoice? choice;
private void updateState()
{
var newChoice = currentMatch.Value?.PicksBans.FirstOrDefault(p => p.BeatmapID == Beatmap?.OnlineID);
if (currentMatch.Value == null)
{
return;
}
var newChoice = currentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == Beatmap?.OnlineID);
bool shouldFlash = newChoice != choice;
if (newChoice != null)
{
if (shouldFlash)
flash.FadeOutFromOne(500).Loop(0, 10);
flash?.FadeOutFromOne(500).Loop(0, 10);
BorderThickness = 6;

View File

@ -92,9 +92,9 @@ public MatchMessage(Message message, LadderInfo info)
{
if (info.CurrentMatch.Value is TournamentMatch match)
{
if (match.Team1.Value.Players.Any(u => u.OnlineID == Message.Sender.OnlineID))
if (match.Team1.Value?.Players.Any(u => u.OnlineID == Message.Sender.OnlineID) == true)
UsernameColour = TournamentGame.COLOUR_RED;
else if (match.Team2.Value.Players.Any(u => u.OnlineID == Message.Sender.OnlineID))
else if (match.Team2.Value?.Players.Any(u => u.OnlineID == Message.Sender.OnlineID) == true)
UsernameColour = TournamentGame.COLOUR_BLUE;
}
}

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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
@ -19,8 +17,8 @@ public partial class TourneyVideo : CompositeDrawable
{
private readonly string filename;
private readonly bool drawFallbackGradient;
private Video video;
private ManualClock manualClock;
private Video? video;
private ManualClock? manualClock;
public bool VideoAvailable => video != null;

View File

@ -1,12 +1,9 @@
// 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;
using System.IO;
using System.Linq;
using JetBrains.Annotations;
using Microsoft.Win32;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
@ -24,36 +21,35 @@ namespace osu.Game.Tournament.IPC
{
public partial class FileBasedIPC : MatchIPCInfo
{
public Storage IPCStorage { get; private set; }
public Storage? IPCStorage { get; private set; }
[Resolved]
protected IAPIProvider API { get; private set; }
protected IAPIProvider API { get; private set; } = null!;
[Resolved]
protected IRulesetStore Rulesets { get; private set; }
protected IRulesetStore Rulesets { get; private set; } = null!;
[Resolved]
private GameHost host { get; set; }
private GameHost host { get; set; } = null!;
[Resolved]
private LadderInfo ladder { get; set; }
private LadderInfo ladder { get; set; } = null!;
[Resolved]
private StableInfo stableInfo { get; set; }
private StableInfo stableInfo { get; set; } = null!;
private int lastBeatmapId;
private ScheduledDelegate scheduled;
private GetBeatmapRequest beatmapLookupRequest;
private ScheduledDelegate? scheduled;
private GetBeatmapRequest? beatmapLookupRequest;
[BackgroundDependencyLoader]
private void load()
{
string stablePath = stableInfo.StablePath ?? findStablePath();
string? stablePath = stableInfo.StablePath ?? findStablePath();
initialiseIPCStorage(stablePath);
}
[CanBeNull]
private Storage initialiseIPCStorage(string path)
private Storage? initialiseIPCStorage(string? path)
{
scheduled?.Cancel();
@ -89,9 +85,9 @@ private Storage initialiseIPCStorage(string path)
lastBeatmapId = beatmapId;
var existing = ladder.CurrentMatch.Value?.Round.Value?.Beatmaps.FirstOrDefault(b => b.ID == beatmapId && b.Beatmap != null);
var existing = ladder.CurrentMatch.Value?.Round.Value?.Beatmaps.FirstOrDefault(b => b.ID == beatmapId);
if (existing != null)
if (existing?.Beatmap != null)
Beatmap.Value = existing.Beatmap;
else
{
@ -114,7 +110,7 @@ private Storage initialiseIPCStorage(string path)
using (var stream = IPCStorage.GetStream(file_ipc_channel_filename))
using (var sr = new StreamReader(stream))
{
ChatChannel.Value = sr.ReadLine();
ChatChannel.Value = sr.ReadLine().AsNonNull();
}
}
catch (Exception)
@ -140,8 +136,8 @@ private Storage initialiseIPCStorage(string path)
using (var stream = IPCStorage.GetStream(file_ipc_scores_filename))
using (var sr = new StreamReader(stream))
{
Score1.Value = int.Parse(sr.ReadLine());
Score2.Value = int.Parse(sr.ReadLine());
Score1.Value = int.Parse(sr.ReadLine().AsNonNull());
Score2.Value = int.Parse(sr.ReadLine().AsNonNull());
}
}
catch (Exception)
@ -164,7 +160,7 @@ private Storage initialiseIPCStorage(string path)
/// </summary>
/// <param name="path">Path to the IPC directory</param>
/// <returns>Whether the supplied path was a valid IPC directory.</returns>
public bool SetIPCLocation(string path)
public bool SetIPCLocation(string? path)
{
if (path == null || !ipcFileExistsInDirectory(path))
return false;
@ -184,29 +180,28 @@ public bool SetIPCLocation(string path)
/// <returns>Whether an IPC directory was successfully auto-detected.</returns>
public bool AutoDetectIPCLocation() => SetIPCLocation(findStablePath());
private static bool ipcFileExistsInDirectory(string p) => p != null && File.Exists(Path.Combine(p, "ipc.txt"));
private static bool ipcFileExistsInDirectory(string? p) => p != null && File.Exists(Path.Combine(p, "ipc.txt"));
[CanBeNull]
private string findStablePath()
private string? findStablePath()
{
string stableInstallPath = findFromEnvVar() ??
findFromRegistry() ??
findFromLocalAppData() ??
findFromDotFolder();
string? stableInstallPath = findFromEnvVar() ??
findFromRegistry() ??
findFromLocalAppData() ??
findFromDotFolder();
Logger.Log($"Stable path for tourney usage: {stableInstallPath}");
return stableInstallPath;
}
private string findFromEnvVar()
private string? findFromEnvVar()
{
try
{
Logger.Log("Trying to find stable with environment variables");
string stableInstallPath = Environment.GetEnvironmentVariable("OSU_STABLE_PATH");
string? stableInstallPath = Environment.GetEnvironmentVariable("OSU_STABLE_PATH");
if (ipcFileExistsInDirectory(stableInstallPath))
return stableInstallPath;
return stableInstallPath!;
}
catch
{
@ -215,7 +210,7 @@ private string findFromEnvVar()
return null;
}
private string findFromLocalAppData()
private string? findFromLocalAppData()
{
Logger.Log("Trying to find stable in %LOCALAPPDATA%");
string stableInstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"osu!");
@ -226,7 +221,7 @@ private string findFromLocalAppData()
return null;
}
private string findFromDotFolder()
private string? findFromDotFolder()
{
Logger.Log("Trying to find stable in dotfolders");
string stableInstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".osu");
@ -237,16 +232,16 @@ private string findFromDotFolder()
return null;
}
private string findFromRegistry()
private string? findFromRegistry()
{
Logger.Log("Trying to find stable in registry");
try
{
string stableInstallPath;
string? stableInstallPath;
#pragma warning disable CA1416
using (RegistryKey key = Registry.ClassesRoot.OpenSubKey("osu"))
using (RegistryKey? key = Registry.ClassesRoot.OpenSubKey("osu"))
stableInstallPath = key?.OpenSubKey(@"shell\open\command")?.GetValue(string.Empty)?.ToString()?.Split('"')[1].Replace("osu!.exe", "");
#pragma warning restore CA1416

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;
using System.Diagnostics;
using System.Drawing;
@ -28,7 +26,7 @@ public override Point ReadJson(JsonReader reader, Type objectType, Point existin
if (reader.TokenType != JsonToken.StartObject)
{
// if there's no object present then this is using string representation (System.Drawing.Point serializes to "x,y")
string str = (string)reader.Value;
string? str = (string?)reader.Value;
Debug.Assert(str != null);
@ -45,9 +43,12 @@ public override Point ReadJson(JsonReader reader, Type objectType, Point existin
if (reader.TokenType == JsonToken.PropertyName)
{
string name = reader.Value?.ToString();
string? name = reader.Value?.ToString();
int? val = reader.ReadAsInt32();
if (name == null)
continue;
if (val == null)
continue;

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;
using System.Collections.Generic;
using Newtonsoft.Json;
@ -17,7 +15,7 @@ namespace osu.Game.Tournament.Models
[Serializable]
public class LadderInfo
{
public Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
public Bindable<RulesetInfo?> Ruleset = new Bindable<RulesetInfo?>();
public BindableList<TournamentMatch> Matches = new BindableList<TournamentMatch>();
public BindableList<TournamentRound> Rounds = new BindableList<TournamentRound>();
@ -27,7 +25,7 @@ public class LadderInfo
public List<TournamentProgression> Progressions = new List<TournamentProgression>();
[JsonIgnore] // updated manually in TournamentGameBase
public Bindable<TournamentMatch> CurrentMatch = new Bindable<TournamentMatch>();
public Bindable<TournamentMatch?> CurrentMatch = new Bindable<TournamentMatch?>();
public Bindable<int> ChromaKeyWidth = new BindableInt(1024)
{

View File

@ -8,7 +8,6 @@ namespace osu.Game.Tournament.Models
public class RoundBeatmap
{
public int ID;
public string Mods = string.Empty;
[JsonProperty("BeatmapInfo")]

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;
using System.IO;
using Newtonsoft.Json;
@ -20,12 +18,12 @@ public class StableInfo
/// <summary>
/// Path to the IPC directory used by the stable (cutting-edge) install.
/// </summary>
public string StablePath { get; set; }
public string? StablePath { get; set; }
/// <summary>
/// Fired whenever stable info is successfully saved to file.
/// </summary>
public event Action OnStableInfoSaved;
public event Action? OnStableInfoSaved;
private const string config_path = "stable.json";

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;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@ -33,16 +31,16 @@ public List<string> Acronyms
}
[JsonIgnore]
public readonly Bindable<TournamentTeam> Team1 = new Bindable<TournamentTeam>();
public readonly Bindable<TournamentTeam?> Team1 = new Bindable<TournamentTeam?>();
public string Team1Acronym;
public string? Team1Acronym;
public readonly Bindable<int?> Team1Score = new Bindable<int?>();
[JsonIgnore]
public readonly Bindable<TournamentTeam> Team2 = new Bindable<TournamentTeam>();
public readonly Bindable<TournamentTeam?> Team2 = new Bindable<TournamentTeam?>();
public string Team2Acronym;
public string? Team2Acronym;
public readonly Bindable<int?> Team2Score = new Bindable<int?>();
@ -53,13 +51,13 @@ public List<string> Acronyms
public readonly ObservableCollection<BeatmapChoice> PicksBans = new ObservableCollection<BeatmapChoice>();
[JsonIgnore]
public readonly Bindable<TournamentRound> Round = new Bindable<TournamentRound>();
public readonly Bindable<TournamentRound?> Round = new Bindable<TournamentRound?>();
[JsonIgnore]
public readonly Bindable<TournamentMatch> Progression = new Bindable<TournamentMatch>();
public readonly Bindable<TournamentMatch?> Progression = new Bindable<TournamentMatch?>();
[JsonIgnore]
public readonly Bindable<TournamentMatch> LosersProgression = new Bindable<TournamentMatch>();
public readonly Bindable<TournamentMatch?> LosersProgression = new Bindable<TournamentMatch?>();
/// <summary>
/// Should not be set directly. Use LadderInfo.CurrentMatch.Value = this instead.
@ -79,7 +77,7 @@ public TournamentMatch()
Team2.BindValueChanged(t => Team2Acronym = t.NewValue?.Acronym.Value, true);
}
public TournamentMatch(TournamentTeam team1 = null, TournamentTeam team2 = null)
public TournamentMatch(TournamentTeam? team1 = null, TournamentTeam? team2 = null)
: this()
{
Team1.Value = team1;
@ -87,10 +85,10 @@ public TournamentMatch(TournamentTeam team1 = null, TournamentTeam team2 = null)
}
[JsonIgnore]
public TournamentTeam Winner => !Completed.Value ? null : Team1Score.Value > Team2Score.Value ? Team1.Value : Team2.Value;
public TournamentTeam? Winner => !Completed.Value ? null : Team1Score.Value > Team2Score.Value ? Team1.Value : Team2.Value;
[JsonIgnore]
public TournamentTeam Loser => !Completed.Value ? null : Team1Score.Value > Team2Score.Value ? Team2.Value : Team1.Value;
public TournamentTeam? Loser => !Completed.Value ? null : Team1Score.Value > Team2Score.Value ? Team2.Value : Team1.Value;
public TeamColour WinnerColour => Winner == Team1.Value ? TeamColour.Red : TeamColour.Blue;

View File

@ -1,12 +1,11 @@
// 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;
using System.Linq;
using Newtonsoft.Json;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
namespace osu.Game.Tournament.Models
{
@ -39,7 +38,7 @@ public double AverageRank
{
int[] ranks = Players.Select(p => p.Rank)
.Where(i => i.HasValue)
.Select(i => i.Value)
.Select(i => i.AsNonNull().Value)
.ToArray();
if (ranks.Length == 0)
@ -66,14 +65,14 @@ public TournamentTeam()
{
// use a sane default flag name based on acronym.
if (val.OldValue.StartsWith(FlagName.Value, StringComparison.InvariantCultureIgnoreCase))
FlagName.Value = val.NewValue.Length >= 2 ? val.NewValue?.Substring(0, 2).ToUpperInvariant() : string.Empty;
FlagName.Value = val.NewValue?.Length >= 2 ? val.NewValue.Substring(0, 2).ToUpperInvariant() : string.Empty;
};
FullName.ValueChanged += val =>
{
// use a sane acronym based on full name.
if (val.OldValue.StartsWith(Acronym.Value, StringComparison.InvariantCultureIgnoreCase))
Acronym.Value = val.NewValue.Length >= 3 ? val.NewValue?.Substring(0, 3).ToUpperInvariant() : string.Empty;
Acronym.Value = val.NewValue?.Length >= 3 ? val.NewValue.Substring(0, 3).ToUpperInvariant() : string.Empty;
};
}

View File

@ -84,7 +84,7 @@ public void AddTeam(TournamentTeam team)
public bool ContainsTeam(string fullName)
{
return allTeams.Any(t => t.Team.FullName.Value == fullName);
return allTeams.Any(t => t.Team?.FullName.Value == fullName);
}
public bool RemoveTeam(TournamentTeam team)
@ -112,7 +112,7 @@ public string GetStringRepresentation()
{
StringBuilder sb = new StringBuilder();
foreach (GroupTeam gt in allTeams)
sb.AppendLine(gt.Team.FullName.Value);
sb.AppendLine(gt.Team?.FullName.Value);
return sb.ToString();
}
}

View File

@ -1,12 +1,11 @@
// 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;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
@ -22,8 +21,8 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
{
public partial class ScrollingTeamContainer : Container
{
public event Action OnScrollStarted;
public event Action<TournamentTeam> OnSelected;
public event Action? OnScrollStarted;
public event Action<TournamentTeam>? OnSelected;
private readonly List<TournamentTeam> availableTeams = new List<TournamentTeam>();
@ -42,7 +41,7 @@ public partial class ScrollingTeamContainer : Container
private double lastTime;
private ScheduledDelegate delayedStateChangeDelegate;
private ScheduledDelegate? delayedStateChangeDelegate;
public ScrollingTeamContainer()
{
@ -117,7 +116,7 @@ private void setScrollState(ScrollState newState)
if (!Children.Any())
break;
ScrollingTeam closest = null;
ScrollingTeam? closest = null;
foreach (var c in Children)
{
@ -139,15 +138,14 @@ private void setScrollState(ScrollState newState)
Trace.Assert(closest != null, "closest != null");
// ReSharper disable once PossibleNullReferenceException
offset += DrawWidth / 2f - (closest.Position.X + closest.DrawWidth / 2f);
offset += DrawWidth / 2f - (closest.AsNonNull().Position.X + closest.AsNonNull().DrawWidth / 2f);
ScrollingTeam st = closest;
ScrollingTeam st = closest.AsNonNull();
availableTeams.RemoveAll(at => at == st.Team);
st.Selected = true;
OnSelected?.Invoke(st.Team);
OnSelected?.Invoke(st.Team.AsNonNull());
delayedStateChangeDelegate = Scheduler.AddDelayed(() => setScrollState(ScrollState.Idle), 10000);
break;
@ -174,7 +172,7 @@ public void AddTeam(TournamentTeam team)
setScrollState(ScrollState.Idle);
}
public void AddTeams(IEnumerable<TournamentTeam> teams)
public void AddTeams(IEnumerable<TournamentTeam>? teams)
{
if (teams == null)
return;
@ -190,8 +188,11 @@ public void ClearTeams()
setScrollState(ScrollState.Idle);
}
public void RemoveTeam(TournamentTeam team)
public void RemoveTeam(TournamentTeam? team)
{
if (team == null)
return;
availableTeams.Remove(team);
foreach (var c in Children)
@ -311,6 +312,8 @@ protected enum ScrollState
public partial class ScrollingTeam : DrawableTournamentTeam
{
public new TournamentTeam Team => base.Team.AsNonNull();
public const float WIDTH = 58;
public const float HEIGHT = 44;

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;
using System.Collections.Generic;
using System.IO;
@ -39,7 +37,7 @@ public IEnumerable<TournamentTeam> Teams
{
while (sr.Peek() != -1)
{
string line = sr.ReadLine()?.Trim();
string? line = sr.ReadLine()?.Trim();
if (string.IsNullOrEmpty(line))
continue;
@ -56,7 +54,7 @@ public IEnumerable<TournamentTeam> Teams
teams.Add(new TournamentTeam
{
FullName = { Value = split[1], },
Acronym = { Value = split.Length >= 3 ? split[2] : null, },
Acronym = { Value = split.Length >= 3 ? split[2] : string.Empty, },
FlagName = { Value = split[0] }
});
}

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.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
@ -72,7 +70,7 @@ private partial class VisualiserLine : Container
private float leftPos => -(float)((Time.Current + Offset) / CycleTime) + expiredCount;
private Texture texture;
private Texture texture = null!;
private int expiredCount;

View File

@ -1,14 +1,13 @@
// 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;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
@ -28,27 +27,27 @@ public partial class DrawingsScreen : TournamentScreen
{
private const string results_filename = "drawings_results.txt";
private ScrollingTeamContainer teamsContainer;
private GroupContainer groupsContainer;
private TournamentSpriteText fullTeamNameText;
private ScrollingTeamContainer teamsContainer = null!;
private GroupContainer groupsContainer = null!;
private TournamentSpriteText fullTeamNameText = null!;
private readonly List<TournamentTeam> allTeams = new List<TournamentTeam>();
private DrawingsConfigManager drawingsConfig;
private DrawingsConfigManager drawingsConfig = null!;
private Task writeOp;
private Task? writeOp;
private Storage storage;
private Storage storage = null!;
public ITeamList TeamList;
public ITeamList? TeamList;
[BackgroundDependencyLoader]
private void load(Storage storage)
{
RelativeSizeAxes = Axes.Both;
this.storage = storage;
RelativeSizeAxes = Axes.Both;
TeamList ??= new StorageBackedTeamList(storage);
if (!TeamList.Teams.Any())
@ -224,7 +223,7 @@ private void reloadTeams()
teamsContainer.ClearTeams();
allTeams.Clear();
foreach (TournamentTeam t in TeamList.Teams)
foreach (TournamentTeam t in TeamList.AsNonNull().Teams)
{
if (groupsContainer.ContainsTeam(t.FullName.Value))
continue;
@ -251,7 +250,7 @@ private void reset(bool loadLastResults = false)
using (Stream stream = storage.GetStream(results_filename, FileAccess.Read, FileMode.Open))
using (StreamReader sr = new StreamReader(stream))
{
string line;
string? line;
while ((line = sr.ReadLine()?.Trim()) != null)
{
@ -261,8 +260,7 @@ private void reset(bool loadLastResults = false)
if (line.ToUpperInvariant().StartsWith("GROUP", StringComparison.Ordinal))
continue;
// ReSharper disable once AccessToModifiedClosure
TournamentTeam teamToAdd = allTeams.FirstOrDefault(t => t.FullName.Value == line);
TournamentTeam? teamToAdd = allTeams.FirstOrDefault(t => t.FullName.Value == line);
if (teamToAdd == null)
continue;

View File

@ -1,12 +1,9 @@
// 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;
using System.Drawing;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -35,13 +32,12 @@ public partial class LadderEditorScreen : LadderScreen, IHasContextMenu
[Cached]
private LadderEditorInfo editorInfo = new LadderEditorInfo();
private WarningBox rightClickMessage;
private WarningBox rightClickMessage = null!;
private RectangularPositionSnapGrid grid;
private RectangularPositionSnapGrid grid = null!;
[Resolved(canBeNull: true)]
[CanBeNull]
private IDialogOverlay dialogOverlay { get; set; }
private IDialogOverlay? dialogOverlay { get; set; }
protected override bool DrawLoserPaths => true;
@ -94,36 +90,28 @@ public void BeginJoin(TournamentMatch match, bool losers)
ScrollContent.Add(new JoinVisualiser(MatchesContainer, match, losers, UpdateLayout));
}
public MenuItem[] ContextMenuItems
{
get
public MenuItem[] ContextMenuItems =>
new MenuItem[]
{
if (editorInfo == null)
return Array.Empty<MenuItem>();
return new MenuItem[]
new OsuMenuItem("Create new match", MenuItemType.Highlighted, () =>
{
new OsuMenuItem("Create new match", MenuItemType.Highlighted, () =>
Vector2 pos = MatchesContainer.Count == 0 ? Vector2.Zero : lastMatchesContainerMouseDownPosition;
TournamentMatch newMatch = new TournamentMatch { Position = { Value = new Point((int)pos.X, (int)pos.Y) } };
LadderInfo.Matches.Add(newMatch);
editorInfo.Selected.Value = newMatch;
}),
new OsuMenuItem("Reset teams", MenuItemType.Destructive, () =>
{
dialogOverlay?.Push(new LadderResetTeamsDialog(() =>
{
Vector2 pos = MatchesContainer.Count == 0 ? Vector2.Zero : lastMatchesContainerMouseDownPosition;
TournamentMatch newMatch = new TournamentMatch { Position = { Value = new Point((int)pos.X, (int)pos.Y) } };
LadderInfo.Matches.Add(newMatch);
editorInfo.Selected.Value = newMatch;
}),
new OsuMenuItem("Reset teams", MenuItemType.Destructive, () =>
{
dialogOverlay?.Push(new LadderResetTeamsDialog(() =>
{
foreach (var p in MatchesContainer)
p.Match.Reset();
}));
})
};
}
}
foreach (var p in MatchesContainer)
p.Match.Reset();
}));
})
};
public void Remove(TournamentMatch match)
{
@ -135,11 +123,11 @@ private partial class JoinVisualiser : CompositeDrawable
private readonly Container<DrawableTournamentMatch> matchesContainer;
public readonly TournamentMatch Source;
private readonly bool losers;
private readonly Action complete;
private readonly Action? complete;
private ProgressionPath path;
private ProgressionPath? path;
public JoinVisualiser(Container<DrawableTournamentMatch> matchesContainer, TournamentMatch source, bool losers, Action complete)
public JoinVisualiser(Container<DrawableTournamentMatch> matchesContainer, TournamentMatch source, bool losers, Action? complete)
{
this.matchesContainer = matchesContainer;
RelativeSizeAxes = Axes.Both;
@ -153,7 +141,7 @@ public JoinVisualiser(Container<DrawableTournamentMatch> matchesContainer, Tourn
Source.Progression.Value = null;
}
private DrawableTournamentMatch findTarget(InputState state)
private DrawableTournamentMatch? findTarget(InputState state)
{
return matchesContainer.FirstOrDefault(d => d.ReceivePositionalInputAt(state.Mouse.Position));
}

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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -14,9 +12,9 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
{
public partial class MatchHeader : Container
{
private TeamScoreDisplay teamDisplay1;
private TeamScoreDisplay teamDisplay2;
private DrawableTournamentHeaderLogo logo;
private TeamScoreDisplay teamDisplay1 = null!;
private TeamScoreDisplay teamDisplay2 = null!;
private DrawableTournamentHeaderLogo logo = null!;
private bool showScores = true;

View File

@ -35,7 +35,7 @@ public bool ShowScore
}
}
public TeamDisplay(TournamentTeam team, TeamColour colour, Bindable<int?> currentTeamScore, int pointsToWin)
public TeamDisplay(TournamentTeam? team, TeamColour colour, Bindable<int?> currentTeamScore, int pointsToWin)
: base(team)
{
AutoSizeAxes = Axes.Both;

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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -17,16 +15,22 @@ public partial class TeamScoreDisplay : CompositeDrawable
{
private readonly TeamColour teamColour;
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
private readonly Bindable<TournamentTeam> currentTeam = new Bindable<TournamentTeam>();
private readonly Bindable<TournamentMatch?> currentMatch = new Bindable<TournamentMatch?>();
private readonly Bindable<TournamentTeam?> currentTeam = new Bindable<TournamentTeam?>();
private readonly Bindable<int?> currentTeamScore = new Bindable<int?>();
private TeamDisplay teamDisplay;
private TeamDisplay? teamDisplay;
public bool ShowScore
{
get => teamDisplay.ShowScore;
set => teamDisplay.ShowScore = value;
get => teamDisplay?.ShowScore ?? false;
set
{
if (teamDisplay != null)
{
teamDisplay.ShowScore = value;
}
}
}
public TeamScoreDisplay(TeamColour teamColour)
@ -48,7 +52,7 @@ private void load(LadderInfo ladder)
updateMatch();
}
private void matchChanged(ValueChangedEvent<TournamentMatch> match)
private void matchChanged(ValueChangedEvent<TournamentMatch?> match)
{
currentTeamScore.UnbindBindings();
currentTeam.UnbindBindings();
@ -78,7 +82,7 @@ protected override bool OnMouseDown(MouseDownEvent e)
switch (e.Button)
{
case MouseButton.Left:
if (currentTeamScore.Value < currentMatch.Value.PointsToWin)
if (currentTeamScore.Value < currentMatch.Value?.PointsToWin)
currentTeamScore.Value++;
return true;
@ -91,7 +95,7 @@ protected override bool OnMouseDown(MouseDownEvent e)
return base.OnMouseDown(e);
}
private void teamChanged(ValueChangedEvent<TournamentTeam> team)
private void teamChanged(ValueChangedEvent<TournamentTeam?> team)
{
bool wasShowingScores = teamDisplay?.ShowScore ?? false;

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;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -146,7 +144,7 @@ protected override void UpdateAfterChildren()
private partial class MatchScoreCounter : CommaSeparatedScoreCounter
{
private OsuSpriteText displayedSpriteText;
private OsuSpriteText displayedSpriteText = null!;
public MatchScoreCounter()
{

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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -26,16 +24,16 @@ public partial class GameplayScreen : BeatmapInfoScreen
private readonly BindableBool warmup = new BindableBool();
public readonly Bindable<TourneyState> State = new Bindable<TourneyState>();
private OsuButton warmupButton;
private MatchIPCInfo ipc;
private OsuButton warmupButton = null!;
private MatchIPCInfo ipc = null!;
[Resolved(canBeNull: true)]
private TournamentSceneManager sceneManager { get; set; }
private TournamentSceneManager? sceneManager { get; set; }
[Resolved]
private TournamentMatchChatDisplay chat { get; set; }
private TournamentMatchChatDisplay chat { get; set; } = null!;
private Drawable chroma;
private Drawable chroma = null!;
[BackgroundDependencyLoader]
private void load(LadderInfo ladder, MatchIPCInfo ipc)
@ -142,7 +140,7 @@ protected override void LoadComplete()
State.BindValueChanged(_ => updateState(), true);
}
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch?> match)
{
base.CurrentMatchChanged(match);
@ -153,29 +151,35 @@ protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> m
scheduledScreenChange?.Cancel();
}
private ScheduledDelegate scheduledScreenChange;
private ScheduledDelegate scheduledContract;
private ScheduledDelegate? scheduledScreenChange;
private ScheduledDelegate? scheduledContract;
private TournamentMatchScoreDisplay scoreDisplay;
private TournamentMatchScoreDisplay scoreDisplay = null!;
private TourneyState lastState;
private MatchHeader header;
private MatchHeader header = null!;
private void contract()
{
if (!IsLoaded)
return;
scheduledContract?.Cancel();
SongBar.Expanded = false;
scoreDisplay.FadeOut(100);
using (chat?.BeginDelayedSequence(500))
chat?.Expand();
using (chat.BeginDelayedSequence(500))
chat.Expand();
}
private void expand()
{
if (!IsLoaded)
return;
scheduledContract?.Cancel();
chat?.Contract();
chat.Contract();
using (BeginDelayedSequence(300))
{
@ -252,7 +256,7 @@ public override void Show()
private partial class ChromaArea : CompositeDrawable
{
[Resolved]
private LadderInfo ladder { get; set; }
private LadderInfo ladder { get; set; } = null!;
[BackgroundDependencyLoader]
private void load()

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;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -28,20 +26,20 @@ public partial class DrawableMatchTeam : DrawableTournamentTeam, IHasContextMenu
{
private readonly TournamentMatch match;
private readonly bool losers;
private TournamentSpriteText scoreText;
private Box background;
private Box backgroundRight;
private TournamentSpriteText scoreText = null!;
private Box background = null!;
private Box backgroundRight = null!;
private readonly Bindable<int?> score = new Bindable<int?>();
private readonly BindableBool completed = new BindableBool();
private Color4 colourWinner;
private readonly Func<bool> isWinner;
private LadderEditorScreen ladderEditor;
private readonly Func<bool>? isWinner;
private LadderEditorScreen ladderEditor = null!;
[Resolved(canBeNull: true)]
private LadderInfo ladderInfo { get; set; }
private LadderInfo? ladderInfo { get; set; }
private void setCurrent()
{
@ -56,9 +54,9 @@ private void setCurrent()
}
[Resolved(CanBeNull = true)]
private LadderEditorInfo editorInfo { get; set; }
private LadderEditorInfo? editorInfo { get; set; }
public DrawableMatchTeam(TournamentTeam team, TournamentMatch match, bool losers)
public DrawableMatchTeam(TournamentTeam? team, TournamentMatch match, bool losers)
: base(team)
{
this.match = match;
@ -72,14 +70,11 @@ public DrawableMatchTeam(TournamentTeam team, TournamentMatch match, bool losers
AcronymText.Padding = new MarginPadding { Left = 50 };
AcronymText.Font = OsuFont.Torus.With(size: 22, weight: FontWeight.Bold);
if (match != null)
{
isWinner = () => match.Winner == Team;
isWinner = () => match.Winner == Team;
completed.BindTo(match.Completed);
if (team != null)
score.BindTo(team == match.Team1.Value ? match.Team1Score : match.Team2Score);
}
completed.BindTo(match.Completed);
if (team != null)
score.BindTo(team == match.Team1.Value ? match.Team1Score : match.Team2Score);
}
[BackgroundDependencyLoader(true)]

View File

@ -1,10 +1,9 @@
// 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;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -27,13 +26,13 @@ public partial class DrawableTournamentMatch : CompositeDrawable
protected readonly FillFlowContainer<DrawableMatchTeam> Flow;
private readonly Drawable selectionBox;
private readonly Drawable currentMatchSelectionBox;
private Bindable<TournamentMatch> globalSelection;
private Bindable<TournamentMatch>? globalSelection;
[Resolved(CanBeNull = true)]
private LadderEditorInfo editorInfo { get; set; }
private LadderEditorInfo? editorInfo { get; set; }
[Resolved(CanBeNull = true)]
private LadderInfo ladderInfo { get; set; }
private LadderInfo? ladderInfo { get; set; }
public DrawableTournamentMatch(TournamentMatch match, bool editor = false)
{
@ -129,7 +128,7 @@ public DrawableTournamentMatch(TournamentMatch match, bool editor = false)
/// <summary>
/// Fired when something changed that requires a ladder redraw.
/// </summary>
public Action Changed;
public Action? Changed;
private readonly List<IUnbindable> refBindables = new List<IUnbindable>();
@ -201,20 +200,22 @@ private void updateProgression()
}
else
{
transferProgression(Match.Progression?.Value, Match.Winner);
transferProgression(Match.LosersProgression?.Value, Match.Loser);
Debug.Assert(Match.Winner != null);
transferProgression(Match.Progression.Value, Match.Winner);
Debug.Assert(Match.Loser != null);
transferProgression(Match.LosersProgression.Value, Match.Loser);
}
Changed?.Invoke();
}
private void transferProgression(TournamentMatch destination, TournamentTeam team)
private void transferProgression(TournamentMatch? destination, TournamentTeam team)
{
if (destination == null) return;
bool progressionAbove = destination.ID < Match.ID;
Bindable<TournamentTeam> destinationTeam;
Bindable<TournamentTeam?> destinationTeam;
// check for the case where we have already transferred out value
if (destination.Team1.Value == team)
@ -268,8 +269,8 @@ private void updateTeams()
{
foreach (var conditional in Match.ConditionalMatches)
{
bool team1Match = conditional.Acronyms.Contains(Match.Team1Acronym);
bool team2Match = conditional.Acronyms.Contains(Match.Team2Acronym);
bool team1Match = Match.Team1Acronym != null && conditional.Acronyms.Contains(Match.Team1Acronym);
bool team2Match = Match.Team2Acronym != null && conditional.Acronyms.Contains(Match.Team2Acronym);
if (team1Match && team2Match)
Match.Date.Value = conditional.Date.Value;
@ -344,6 +345,9 @@ public void Remove()
Match.Progression.Value = null;
Match.LosersProgression.Value = null;
if (ladderInfo == null)
return;
ladderInfo.Matches.Remove(Match);
foreach (var m in ladderInfo.Matches)

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 JetBrains.Annotations;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -52,7 +50,7 @@ public DrawableTournamentRound(TournamentRound round, bool losers = false)
name.BindValueChanged(_ => textName.Text = ((losers ? "Losers " : "") + round.Name).ToUpperInvariant(), true);
description = round.Description.GetBoundCopy();
description.BindValueChanged(_ => textDescription.Text = round.Description.Value?.ToUpperInvariant(), true);
description.BindValueChanged(_ => textDescription.Text = round.Description.Value?.ToUpperInvariant() ?? string.Empty, true);
}
}
}

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.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
@ -23,17 +21,17 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
{
public partial class LadderEditorSettings : CompositeDrawable
{
private SettingsDropdown<TournamentRound> roundDropdown;
private PlayerCheckbox losersCheckbox;
private DateTextBox dateTimeBox;
private SettingsTeamDropdown team1Dropdown;
private SettingsTeamDropdown team2Dropdown;
private SettingsDropdown<TournamentRound?> roundDropdown = null!;
private PlayerCheckbox losersCheckbox = null!;
private DateTextBox dateTimeBox = null!;
private SettingsTeamDropdown team1Dropdown = null!;
private SettingsTeamDropdown team2Dropdown = null!;
[Resolved]
private LadderEditorInfo editorInfo { get; set; }
private LadderEditorInfo editorInfo { get; set; } = null!;
[Resolved]
private LadderInfo ladderInfo { get; set; }
private LadderInfo ladderInfo { get; set; } = null!;
[BackgroundDependencyLoader]
private void load()
@ -77,7 +75,7 @@ private void load()
};
}
private void roundDropdownChanged(ValueChangedEvent<TournamentRound> round)
private void roundDropdownChanged(ValueChangedEvent<TournamentRound?> round)
{
if (editorInfo.Selected.Value?.Date.Value < round.NewValue?.StartDate.Value)
{
@ -101,11 +99,11 @@ protected override void OnHoverLost(HoverLostEvent e)
{
}
private partial class SettingsRoundDropdown : SettingsDropdown<TournamentRound>
private partial class SettingsRoundDropdown : SettingsDropdown<TournamentRound?>
{
public SettingsRoundDropdown(BindableList<TournamentRound> rounds)
{
Current = new Bindable<TournamentRound>();
Current = new Bindable<TournamentRound?>();
foreach (var r in rounds.Prepend(new TournamentRound()))
add(r);

View File

@ -12,7 +12,7 @@
namespace osu.Game.Tournament.Screens.Ladder.Components
{
public partial class SettingsTeamDropdown : SettingsDropdown<TournamentTeam>
public partial class SettingsTeamDropdown : SettingsDropdown<TournamentTeam?>
{
public SettingsTeamDropdown(BindableList<TournamentTeam> teams)
{

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.Collections.Specialized;
using System.Diagnostics;
using System.Linq;
@ -22,13 +20,13 @@ namespace osu.Game.Tournament.Screens.Ladder
{
public partial class LadderScreen : TournamentScreen
{
protected Container<DrawableTournamentMatch> MatchesContainer;
private Container<Path> paths;
private Container headings;
protected Container<DrawableTournamentMatch> MatchesContainer = null!;
private Container<Path> paths = null!;
private Container headings = null!;
protected LadderDragContainer ScrollContent;
protected LadderDragContainer ScrollContent = null!;
protected Container Content;
protected Container Content = null!;
[BackgroundDependencyLoader]
private void load()

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;
@ -24,20 +22,20 @@ namespace osu.Game.Tournament.Screens.MapPool
{
public partial class MapPoolScreen : TournamentMatchScreen
{
private FillFlowContainer<FillFlowContainer<TournamentBeatmapPanel>> mapFlows;
private FillFlowContainer<FillFlowContainer<TournamentBeatmapPanel>> mapFlows = null!;
[Resolved(canBeNull: true)]
private TournamentSceneManager sceneManager { get; set; }
private TournamentSceneManager? sceneManager { get; set; }
private TeamColour pickColour;
private ChoiceType pickType;
private OsuButton buttonRedBan;
private OsuButton buttonBlueBan;
private OsuButton buttonRedPick;
private OsuButton buttonBluePick;
private OsuButton buttonRedBan = null!;
private OsuButton buttonBlueBan = null!;
private OsuButton buttonRedPick = null!;
private OsuButton buttonBluePick = null!;
private ScheduledDelegate scheduledScreenChange;
private ScheduledDelegate? scheduledScreenChange;
[BackgroundDependencyLoader]
private void load(MatchIPCInfo ipc)
@ -113,7 +111,7 @@ private void load(MatchIPCInfo ipc)
ipc.Beatmap.BindValueChanged(beatmapChanged);
}
private Bindable<bool> splitMapPoolByMods;
private Bindable<bool>? splitMapPoolByMods;
protected override void LoadComplete()
{
@ -148,6 +146,9 @@ private void setMode(TeamColour colour, ChoiceType choiceType)
private void setNextMode()
{
if (CurrentMatch.Value == null)
return;
const TeamColour roll_winner = TeamColour.Red; //todo: draw from match
var nextColour = (CurrentMatch.Value.PicksBans.LastOrDefault()?.Team ?? roll_winner) == TeamColour.Red ? TeamColour.Blue : TeamColour.Red;
@ -169,11 +170,11 @@ protected override bool OnMouseDown(MouseDownEvent e)
addForBeatmap(map.Beatmap.OnlineID);
else
{
var existing = CurrentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == map.Beatmap?.OnlineID);
var existing = CurrentMatch.Value?.PicksBans.FirstOrDefault(p => p.BeatmapID == map.Beatmap?.OnlineID);
if (existing != null)
{
CurrentMatch.Value.PicksBans.Remove(existing);
CurrentMatch.Value?.PicksBans.Remove(existing);
setNextMode();
}
}
@ -186,13 +187,13 @@ protected override bool OnMouseDown(MouseDownEvent e)
private void reset()
{
CurrentMatch.Value.PicksBans.Clear();
CurrentMatch.Value?.PicksBans.Clear();
setNextMode();
}
private void addForBeatmap(int beatmapId)
{
if (CurrentMatch.Value == null)
if (CurrentMatch.Value?.Round.Value == null)
return;
if (CurrentMatch.Value.Round.Value.Beatmaps.All(b => b.Beatmap?.OnlineID != beatmapId))
@ -228,7 +229,7 @@ public override void Hide()
base.Hide();
}
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch?> match)
{
base.CurrentMatchChanged(match);
updateDisplay();
@ -245,12 +246,15 @@ private void updateDisplay()
if (CurrentMatch.Value.Round.Value != null)
{
FillFlowContainer<TournamentBeatmapPanel> currentFlow = null;
string currentMods = null;
FillFlowContainer<TournamentBeatmapPanel>? currentFlow = null;
string? currentMods = null;
int flowCount = 0;
foreach (var b in CurrentMatch.Value.Round.Value.Beatmaps)
{
if (b.Beatmap == null)
continue;
if (currentFlow == null || (LadderInfo.SplitMapPoolByMods.Value && currentMods != b.Mods))
{
mapFlows.Add(currentFlow = new FillFlowContainer<TournamentBeatmapPanel>

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;
using System.Linq;
using osu.Framework.Allocation;
@ -21,9 +19,9 @@ namespace osu.Game.Tournament.Screens.Schedule
{
public partial class ScheduleScreen : TournamentScreen
{
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
private Container mainContainer;
private LadderInfo ladder;
private readonly Bindable<TournamentMatch?> currentMatch = new Bindable<TournamentMatch?>();
private Container mainContainer = null!;
private LadderInfo ladder = null!;
[BackgroundDependencyLoader]
private void load(LadderInfo ladder)
@ -107,7 +105,7 @@ protected override void LoadComplete()
currentMatch.BindValueChanged(matchChanged, true);
}
private void matchChanged(ValueChangedEvent<TournamentMatch> match)
private void matchChanged(ValueChangedEvent<TournamentMatch?> match)
{
var upcoming = ladder.Matches.Where(p => !p.Completed.Value && p.Team1.Value != null && p.Team2.Value != null && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4);
var conditionals = ladder

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;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
@ -14,9 +12,9 @@ internal partial class ResolutionSelector : ActionableInfo
private const int minimum_window_height = 480;
private const int maximum_window_height = 2160;
public new Action<int> Action;
public new Action<int>? Action;
private OsuNumberBox numberBox;
private OsuNumberBox? numberBox;
protected override Drawable CreateComponent()
{

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.Drawing;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -24,27 +22,27 @@ namespace osu.Game.Tournament.Screens.Setup
{
public partial class SetupScreen : TournamentScreen
{
private FillFlowContainer fillFlow;
private FillFlowContainer fillFlow = null!;
private LoginOverlay loginOverlay;
private ResolutionSelector resolution;
private LoginOverlay? loginOverlay;
private ResolutionSelector resolution = null!;
[Resolved]
private MatchIPCInfo ipc { get; set; }
private MatchIPCInfo ipc { get; set; } = null!;
[Resolved]
private StableInfo stableInfo { get; set; }
private StableInfo stableInfo { get; set; } = null!;
[Resolved]
private IAPIProvider api { get; set; }
private IAPIProvider api { get; set; } = null!;
[Resolved]
private RulesetStore rulesets { get; set; }
private RulesetStore rulesets { get; set; } = null!;
[Resolved(canBeNull: true)]
private TournamentSceneManager sceneManager { get; set; }
private TournamentSceneManager? sceneManager { get; set; }
private Bindable<Size> windowSize;
private Bindable<Size> windowSize = null!;
[BackgroundDependencyLoader]
private void load(FrameworkConfigManager frameworkConfig)
@ -115,7 +113,7 @@ private void reload()
Failing = api.IsLoggedIn != true,
Description = "In order to access the API and display metadata, signing in is required."
},
new LabelledDropdown<RulesetInfo>
new LabelledDropdown<RulesetInfo?>
{
Label = "Ruleset",
Description = "Decides what stats are displayed and which ranks are retrieved for players. This requires a restart to reload data for an existing bracket.",

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.IO;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
@ -24,19 +22,19 @@ namespace osu.Game.Tournament.Screens.Setup
public partial class StablePathSelectScreen : TournamentScreen
{
[Resolved(canBeNull: true)]
private TournamentSceneManager sceneManager { get; set; }
private TournamentSceneManager? sceneManager { get; set; }
[Resolved]
private MatchIPCInfo ipc { get; set; }
private MatchIPCInfo ipc { get; set; } = null!;
private OsuDirectorySelector directorySelector;
private DialogOverlay overlay;
private OsuDirectorySelector directorySelector = null!;
private DialogOverlay? overlay;
[BackgroundDependencyLoader(true)]
private void load(Storage storage, OsuColour colours)
{
var initialStorage = (ipc as FileBasedIPC)?.IPCStorage ?? storage;
string initialPath = new DirectoryInfo(initialStorage.GetFullPath(string.Empty)).Parent?.FullName;
string? initialPath = new DirectoryInfo(initialStorage.GetFullPath(string.Empty)).Parent?.FullName;
AddRangeInternal(new Drawable[]
{

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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
@ -13,12 +11,12 @@ namespace osu.Game.Tournament.Screens.Setup
{
internal partial class TournamentSwitcher : ActionableInfo
{
private OsuDropdown<string> dropdown;
private OsuButton folderButton;
private OsuButton reloadTournamentsButton;
private OsuDropdown<string> dropdown = null!;
private OsuButton folderButton = null!;
private OsuButton reloadTournamentsButton = null!;
[Resolved]
private TournamentGameBase game { get; set; }
private TournamentGameBase game { get; set; } = null!;
[BackgroundDependencyLoader]
private void load(TournamentStorage storage)

View File

@ -42,7 +42,7 @@ private void load()
});
}
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch?> match)
{
// showcase screen doesn't care about a match being selected.
// base call intentionally omitted to not show match warning.

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.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -22,12 +20,12 @@ namespace osu.Game.Tournament.Screens.TeamIntro
{
public partial class SeedingScreen : TournamentMatchScreen
{
private Container mainContainer;
private Container mainContainer = null!;
private readonly Bindable<TournamentTeam> currentTeam = new Bindable<TournamentTeam>();
private readonly Bindable<TournamentTeam?> currentTeam = new Bindable<TournamentTeam?>();
private TourneyButton showFirstTeamButton;
private TourneyButton showSecondTeamButton;
private TourneyButton showFirstTeamButton = null!;
private TourneyButton showSecondTeamButton = null!;
[BackgroundDependencyLoader]
private void load()
@ -53,13 +51,13 @@ private void load()
{
RelativeSizeAxes = Axes.X,
Text = "Show first team",
Action = () => currentTeam.Value = CurrentMatch.Value.Team1.Value,
Action = () => currentTeam.Value = CurrentMatch.Value?.Team1.Value,
},
showSecondTeamButton = new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Show second team",
Action = () => currentTeam.Value = CurrentMatch.Value.Team2.Value,
Action = () => currentTeam.Value = CurrentMatch.Value?.Team2.Value,
},
new SettingsTeamDropdown(LadderInfo.Teams)
{
@ -73,7 +71,7 @@ private void load()
currentTeam.BindValueChanged(teamChanged, true);
}
private void teamChanged(ValueChangedEvent<TournamentTeam> team) => updateTeamDisplay();
private void teamChanged(ValueChangedEvent<TournamentTeam?> team) => updateTeamDisplay();
public override void Show()
{
@ -84,7 +82,7 @@ public override void Show()
updateTeamDisplay();
}
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch?> match)
{
base.CurrentMatchChanged(match);
@ -256,7 +254,7 @@ private void load(TextureStore textures)
private partial class LeftInfo : CompositeDrawable
{
public LeftInfo(TournamentTeam team)
public LeftInfo(TournamentTeam? team)
{
FillFlowContainer fill;
@ -315,7 +313,7 @@ public RowDisplay(string left, string right)
private partial class TeamDisplay : DrawableTournamentTeam
{
public TeamDisplay(TournamentTeam team)
public TeamDisplay(TournamentTeam? team)
: base(team)
{
AutoSizeAxes = Axes.Both;

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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -15,7 +13,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
{
public partial class TeamIntroScreen : TournamentMatchScreen
{
private Container mainContainer;
private Container mainContainer = null!;
[BackgroundDependencyLoader]
private void load()
@ -36,7 +34,7 @@ private void load()
};
}
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch?> match)
{
base.CurrentMatchChanged(match);

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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -16,12 +14,12 @@ namespace osu.Game.Tournament.Screens.TeamWin
{
public partial class TeamWinScreen : TournamentMatchScreen
{
private Container mainContainer;
private Container mainContainer = null!;
private readonly Bindable<bool> currentCompleted = new Bindable<bool>();
private TourneyVideo blueWinVideo;
private TourneyVideo redWinVideo;
private TourneyVideo blueWinVideo = null!;
private TourneyVideo redWinVideo = null!;
[BackgroundDependencyLoader]
private void load()
@ -51,7 +49,7 @@ private void load()
currentCompleted.BindValueChanged(_ => update());
}
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch?> match)
{
base.CurrentMatchChanged(match);
@ -70,7 +68,7 @@ private void update() => Scheduler.AddOnce(() =>
{
var match = CurrentMatch.Value;
if (match.Winner == null)
if (match?.Winner == null)
{
mainContainer.Clear();
return;

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 osu.Framework.Bindables;
using osu.Game.Tournament.Models;
@ -10,8 +8,8 @@ namespace osu.Game.Tournament.Screens
{
public abstract partial class TournamentMatchScreen : TournamentScreen
{
protected readonly Bindable<TournamentMatch> CurrentMatch = new Bindable<TournamentMatch>();
private WarningBox noMatchWarning;
protected readonly Bindable<TournamentMatch?> CurrentMatch = new Bindable<TournamentMatch?>();
private WarningBox? noMatchWarning;
protected override void LoadComplete()
{
@ -21,7 +19,7 @@ protected override void LoadComplete()
CurrentMatch.BindValueChanged(CurrentMatchChanged, true);
}
protected virtual void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
protected virtual void CurrentMatchChanged(ValueChangedEvent<TournamentMatch?> match)
{
if (match.NewValue == null)
{

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.Drawing;
using System.Linq;
using osu.Framework.Allocation;
@ -35,12 +33,12 @@ public partial class TournamentGame : TournamentGameBase
public static readonly Color4 ELEMENT_FOREGROUND_COLOUR = Color4Extensions.FromHex("#000");
public static readonly Color4 TEXT_COLOUR = Color4Extensions.FromHex("#fff");
private Drawable heightWarning;
private Drawable heightWarning = null!;
private Bindable<WindowMode> windowMode;
private Bindable<WindowMode> windowMode = null!;
private readonly BindableSize windowSize = new BindableSize();
private LoadingSpinner loadingSpinner;
private LoadingSpinner loadingSpinner = null!;
[Cached(typeof(IDialogOverlay))]
private readonly DialogOverlay dialogOverlay = new DialogOverlay();

View File

@ -1,14 +1,13 @@
// 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;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input;
@ -31,11 +30,11 @@ namespace osu.Game.Tournament
public partial class TournamentGameBase : OsuGameBase
{
public const string BRACKET_FILENAME = @"bracket.json";
private LadderInfo ladder;
private TournamentStorage storage;
private DependencyContainer dependencies;
private FileBasedIPC ipc;
private BeatmapLookupCache beatmapCache;
private LadderInfo ladder = null!;
private TournamentStorage storage = null!;
private DependencyContainer dependencies = null!;
private FileBasedIPC ipc = null!;
private BeatmapLookupCache beatmapCache = null!;
protected Task BracketLoadTask => bracketLoadTaskCompletionSource.Task;
@ -54,7 +53,7 @@ public override EndpointConfiguration CreateEndpoints()
return new ProductionEndpointConfiguration();
}
private TournamentSpriteText initialisationText;
private TournamentSpriteText initialisationText = null!;
[BackgroundDependencyLoader]
private void load(Storage baseStorage)
@ -78,6 +77,8 @@ private void load(Storage baseStorage)
dependencies.CacheAs(new StableInfo(storage));
beatmapCache = dependencies.Get<BeatmapLookupCache>();
ladder = new LadderInfo();
}
protected override void LoadComplete()
@ -100,11 +101,11 @@ private async Task readBracket()
{
using (Stream stream = storage.GetStream(BRACKET_FILENAME, FileAccess.Read, FileMode.Open))
using (var sr = new StreamReader(stream))
ladder = JsonConvert.DeserializeObject<LadderInfo>(await sr.ReadToEndAsync().ConfigureAwait(false), new JsonPointConverter());
{
ladder = JsonConvert.DeserializeObject<LadderInfo>(await sr.ReadToEndAsync().ConfigureAwait(false), new JsonPointConverter()) ?? ladder;
}
}
ladder ??= new LadderInfo();
var resolvedRuleset = ladder.Ruleset.Value != null
? RulesetStore.GetRuleset(ladder.Ruleset.Value.ShortName)
: RulesetStore.AvailableRulesets.First();
@ -283,7 +284,7 @@ private async Task<bool> addSeedingBeatmaps()
private void updateLoadProgressMessage(string s) => Schedule(() => initialisationText.Text = s);
public void PopulatePlayer(TournamentUser user, Action success = null, Action failure = null, bool immediate = false)
public void PopulatePlayer(TournamentUser user, Action? success = null, Action? failure = null, bool immediate = false)
{
var req = new GetUserRequest(user.OnlineID, ladder.Ruleset.Value);
@ -348,8 +349,8 @@ public string GetSerialisedLadder()
foreach (var r in ladder.Rounds)
r.Matches = ladder.Matches.Where(p => p.Round.Value == r).Select(p => p.ID).ToList();
ladder.Progressions = ladder.Matches.Where(p => p.Progression.Value != null).Select(p => new TournamentProgression(p.ID, p.Progression.Value.ID)).Concat(
ladder.Matches.Where(p => p.LosersProgression.Value != null).Select(p => new TournamentProgression(p.ID, p.LosersProgression.Value.ID, true)))
ladder.Progressions = ladder.Matches.Where(p => p.Progression.Value != null).Select(p => new TournamentProgression(p.ID, p.Progression.Value.AsNonNull().ID)).Concat(
ladder.Matches.Where(p => p.LosersProgression.Value != null).Select(p => new TournamentProgression(p.ID, p.LosersProgression.Value.AsNonNull().ID, true)))
.ToList();
return JsonConvert.SerializeObject(ladder,

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;
using System.Linq;
using osu.Framework.Allocation;
@ -35,8 +33,8 @@ namespace osu.Game.Tournament
[Cached]
public partial class TournamentSceneManager : CompositeDrawable
{
private Container screens;
private TourneyVideo video;
private Container screens = null!;
private TourneyVideo video = null!;
public const int CONTROL_AREA_WIDTH = 200;
@ -50,8 +48,8 @@ public partial class TournamentSceneManager : CompositeDrawable
[Cached]
private TournamentMatchChatDisplay chat = new TournamentMatchChatDisplay();
private Container chatContainer;
private FillFlowContainer buttons;
private Container chatContainer = null!;
private FillFlowContainer buttons = null!;
public TournamentSceneManager()
{
@ -166,10 +164,10 @@ private void load()
private float depth;
private Drawable currentScreen;
private ScheduledDelegate scheduledHide;
private Drawable? currentScreen;
private ScheduledDelegate? scheduledHide;
private Drawable temporaryScreen;
private Drawable? temporaryScreen;
public void SetScreen(Drawable screen)
{
@ -284,7 +282,7 @@ public ScreenButton(Type type, Key? shortcutKey = null)
Y = -2,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = shortcutKey.ToString(),
Text = shortcutKey.Value.ToString(),
}
}
});
@ -304,7 +302,7 @@ protected override bool OnKeyDown(KeyDownEvent e)
private bool isSelected;
public Action<Type> RequestSelection;
public Action<Type>? RequestSelection;
public bool IsSelected
{