Skip to content

Commit

Permalink
Merge pull request #24409 from cdwcgt/tournament-nullable
Browse files Browse the repository at this point in the history
Remove #nullable disable in tournament
  • Loading branch information
peppy authored Aug 10, 2023
2 parents 66e404f + 3501b7c commit 5b44124
Show file tree
Hide file tree
Showing 61 changed files with 345 additions and 420 deletions.
4 changes: 1 addition & 3 deletions osu.Game.Tournament.Tests/Components/TestSceneDateTextBox.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using NUnit.Framework;
using osu.Game.Tests.Visual;
using osu.Game.Tournament.Components;
Expand All @@ -13,7 +11,7 @@ namespace osu.Game.Tournament.Tests.Components
{
public partial class TestSceneDateTextBox : OsuManualInputManagerTestScene
{
private DateTextBox textBox;
private DateTextBox textBox = null!;

[SetUp]
public void Setup() => Schedule(() =>
Expand Down
4 changes: 1 addition & 3 deletions osu.Game.Tournament.Tests/Components/TestSceneSongBar.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
Expand All @@ -22,7 +20,7 @@ public partial class TestSceneSongBar : OsuTestScene
[Test]
public void TestSongBar()
{
SongBar songBar = null;
SongBar songBar = null!;

AddStep("create bar", () => Child = songBar = new SongBar
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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;
Expand All @@ -19,12 +17,12 @@ namespace osu.Game.Tournament.Tests.Components
public partial class TestSceneTournamentModDisplay : TournamentTestScene
{
[Resolved]
private IAPIProvider api { get; set; }
private IAPIProvider api { get; set; } = null!;

[Resolved]
private IRulesetStore rulesets { get; set; }
private IRulesetStore rulesets { get; set; } = null!;

private FillFlowContainer<TournamentBeatmapPanel> fillFlow;
private FillFlowContainer<TournamentBeatmapPanel> fillFlow = null!;

[BackgroundDependencyLoader]
private void load()
Expand All @@ -45,7 +43,7 @@ private void load()

private void success(APIBeatmap beatmap)
{
var ruleset = rulesets.GetRuleset(Ladder.Ruleset.Value.OnlineID);
var ruleset = rulesets.GetRuleset(Ladder.Ruleset.Value?.OnlineID ?? -1);

if (ruleset == null)
return;
Expand Down
6 changes: 2 additions & 4 deletions osu.Game.Tournament.Tests/NonVisual/DataLoadTest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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.Threading.Tasks;
Expand Down Expand Up @@ -81,11 +79,11 @@ public void TestUnavailableRuleset()
public partial class TestTournament : TournamentGameBase
{
private readonly bool resetRuleset;
private readonly Action runOnLoadComplete;
private readonly Action? runOnLoadComplete;

public new Task BracketLoadTask => base.BracketLoadTask;

public TestTournament(bool resetRuleset = false, [InstantHandle] Action runOnLoadComplete = null)
public TestTournament(bool resetRuleset = false, [InstantHandle] Action? runOnLoadComplete = null)
{
this.resetRuleset = resetRuleset;
this.runOnLoadComplete = runOnLoadComplete;
Expand Down
6 changes: 2 additions & 4 deletions osu.Game.Tournament.Tests/NonVisual/IPCLocationTest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System.IO;
using System.Linq;
using NUnit.Framework;
Expand Down Expand Up @@ -36,11 +34,11 @@ public void CheckIPCLocation()
{
var osu = LoadTournament(host);
TournamentStorage storage = (TournamentStorage)osu.Dependencies.Get<Storage>();
FileBasedIPC ipc = null;
FileBasedIPC? ipc = null;

WaitForOrAssert(() => (ipc = osu.Dependencies.Get<MatchIPCInfo>() as FileBasedIPC)?.IsLoaded == true, @"ipc could not be populated in a reasonable amount of time");

Assert.True(ipc.SetIPCLocation(testStableInstallDirectory));
Assert.True(ipc!.SetIPCLocation(testStableInstallDirectory));
Assert.True(storage.AllTournaments.Exists("stable.json"));
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ private static LadderInfo createSampleLadder()
PlayersPerTeam = { Value = 4 },
Teams =
{
match.Team1.Value,
match.Team2.Value,
match.Team1.Value!,
match.Team2.Value!,
},
Rounds =
{
Expand Down
4 changes: 1 addition & 3 deletions osu.Game.Tournament.Tests/NonVisual/TournamentHostTest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -13,7 +11,7 @@ namespace osu.Game.Tournament.Tests.NonVisual
{
public abstract class TournamentHostTest
{
public static TournamentGameBase LoadTournament(GameHost host, TournamentGameBase tournament = null)
public static TournamentGameBase LoadTournament(GameHost host, TournamentGameBase? tournament = null)
{
tournament ??= new TournamentGameBase();
Task.Factory.StartNew(() => host.Run(tournament), TaskCreationOptions.LongRunning)
Expand Down
2 changes: 0 additions & 2 deletions osu.Game.Tournament.Tests/Screens/TestSceneGameplayScreen.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
18 changes: 8 additions & 10 deletions osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
Expand All @@ -16,7 +14,7 @@ namespace osu.Game.Tournament.Tests.Screens
{
public partial class TestSceneMapPoolScreen : TournamentScreenTestScene
{
private MapPoolScreen screen;
private MapPoolScreen screen = null!;

[BackgroundDependencyLoader]
private void load()
Expand All @@ -32,7 +30,7 @@ public void TestFewMaps()
{
AddStep("load few maps", () =>
{
Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear();
Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Clear();
for (int i = 0; i < 8; i++)
addBeatmap();
Expand All @@ -52,7 +50,7 @@ public void TestJustEnoughMaps()
{
AddStep("load just enough maps", () =>
{
Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear();
Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Clear();
for (int i = 0; i < 18; i++)
addBeatmap();
Expand All @@ -72,7 +70,7 @@ public void TestManyMaps()
{
AddStep("load many maps", () =>
{
Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear();
Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Clear();
for (int i = 0; i < 19; i++)
addBeatmap();
Expand All @@ -92,7 +90,7 @@ public void TestJustEnoughMods()
{
AddStep("load many maps", () =>
{
Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear();
Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Clear();
for (int i = 0; i < 11; i++)
addBeatmap(i > 4 ? Ruleset.Value.CreateInstance().AllMods.ElementAt(i).Acronym : "NM");
Expand All @@ -118,7 +116,7 @@ public void TestManyMods()
{
AddStep("load many maps", () =>
{
Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear();
Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Clear();
for (int i = 0; i < 12; i++)
addBeatmap(i > 4 ? Ruleset.Value.CreateInstance().AllMods.ElementAt(i).Acronym : "NM");
Expand All @@ -138,7 +136,7 @@ public void TestSplitMapPoolByMods()
{
AddStep("load many maps", () =>
{
Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear();
Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Clear();
for (int i = 0; i < 12; i++)
addBeatmap(i > 4 ? Ruleset.Value.CreateInstance().AllMods.ElementAt(i).Acronym : "NM");
Expand All @@ -155,7 +153,7 @@ public void TestSplitMapPoolByMods()

private void addBeatmap(string mods = "NM")
{
Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Add(new RoundBeatmap
Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Add(new RoundBeatmap
{
Beatmap = CreateSampleBeatmap(),
Mods = mods
Expand Down
2 changes: 0 additions & 2 deletions osu.Game.Tournament.Tests/Screens/TestSceneScheduleScreen.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System;
using NUnit.Framework;
using osu.Framework.Allocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand Down
8 changes: 4 additions & 4 deletions osu.Game.Tournament.Tests/TournamentTestScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ private void load(TournamentStorage storage)

match = CreateSampleMatch();

Ladder.Rounds.Add(match.Round.Value);
Ladder.Rounds.Add(match.Round.Value!);
Ladder.Matches.Add(match);
Ladder.Teams.Add(match.Team1.Value);
Ladder.Teams.Add(match.Team2.Value);
Ladder.Teams.Add(match.Team1.Value!);
Ladder.Teams.Add(match.Team2.Value!);

Ruleset.BindTo(Ladder.Ruleset);
Dependencies.CacheAs(new StableInfo(storage));
Expand Down Expand Up @@ -152,7 +152,7 @@ public virtual void SetUpSteps()
},
Round =
{
Value = new TournamentRound { Name = { Value = "Quarterfinals" } }
Value = new TournamentRound { Name = { Value = "Quarterfinals" } },
}
};

Expand Down
10 changes: 4 additions & 6 deletions osu.Game.Tournament/Components/DrawableTeamFlag.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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;
Expand All @@ -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;
}
Expand Down
8 changes: 3 additions & 5 deletions osu.Game.Tournament/Components/DrawableTeamTitle.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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;
Expand All @@ -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;
}
Expand Down
11 changes: 5 additions & 6 deletions osu.Game.Tournament/Components/DrawableTournamentTeam.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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;
Expand All @@ -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;

Expand All @@ -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);
}
Expand Down
Loading

0 comments on commit 5b44124

Please sign in to comment.