Skip to content

Commit

Permalink
remove #nullable disable in tournament
Browse files Browse the repository at this point in the history
  • Loading branch information
cdwcgt committed Jul 29, 2023
1 parent a7ff084 commit 8a06914
Show file tree
Hide file tree
Showing 51 changed files with 330 additions and 379 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 =
{
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);
}
}
}
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 @@ -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
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
9 changes: 5 additions & 4 deletions osu.Game.Tournament.Tests/TournamentTestScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -152,7 +153,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 <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;
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 <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;
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 <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;
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
8 changes: 3 additions & 5 deletions osu.Game.Tournament/Components/SongBar.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
{
Expand All @@ -55,7 +53,7 @@ public LegacyMods Mods
}
}

private FillFlowContainer flow;
private FillFlowContainer flow = null!;

private bool expanded;

Expand Down
18 changes: 11 additions & 7 deletions osu.Game.Tournament/Components/TournamentBeatmapPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "")
{
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Tournament/Components/TournamentMatchChatDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
6 changes: 2 additions & 4 deletions osu.Game.Tournament/Components/TourneyVideo.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand Down
Loading

0 comments on commit 8a06914

Please sign in to comment.