1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-09 13:13:04 +08:00

Merge branch 'master' into close-playlists

This commit is contained in:
Bartłomiej Dach 2024-11-22 09:02:41 +01:00
commit 3b2f43012e
No known key found for this signature in database
108 changed files with 742 additions and 606 deletions

View File

@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Catch.Tests.Mods
}, },
Autoplay = true, Autoplay = true,
PassCondition = () => Player.ScoreProcessor.Combo.Value == 2, PassCondition = () => Player.ScoreProcessor.Combo.Value == 2,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -59,7 +59,7 @@ namespace osu.Game.Rulesets.Catch.Tests.Mods
}, },
Autoplay = true, Autoplay = true,
PassCondition = () => true, PassCondition = () => true,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -99,7 +99,7 @@ namespace osu.Game.Rulesets.Catch.Tests.Mods
}, },
Autoplay = true, Autoplay = true,
PassCondition = () => true, PassCondition = () => true,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {

View File

@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Catch.Tests.Mods
Mod = new CatchModRelax(), Mod = new CatchModRelax(),
Autoplay = false, Autoplay = false,
PassCondition = passCondition, PassCondition = passCondition,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {

View File

@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Catch.Tests
{ {
CreateModTest(new ModTestData CreateModTest(new ModTestData
{ {
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {

View File

@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Catch.Edit
{ {
public partial class CatchDistanceSnapProvider : ComposerDistanceSnapProvider public partial class CatchDistanceSnapProvider : ComposerDistanceSnapProvider
{ {
protected override double ReadCurrentDistanceSnap(HitObject before, HitObject after) public override double ReadCurrentDistanceSnap(HitObject before, HitObject after)
{ {
// osu!catch's distance snap implementation is limited, in that a custom spacing cannot be specified. // osu!catch's distance snap implementation is limited, in that a custom spacing cannot be specified.
// Therefore this functionality is not currently used. // Therefore this functionality is not currently used.

View File

@ -70,6 +70,8 @@ namespace osu.Game.Rulesets.Catch.Edit
})); }));
} }
protected override Drawable CreateHitObjectInspector() => new CatchHitObjectInspector(DistanceSnapProvider);
protected override IEnumerable<TernaryButton> CreateTernaryButtons() protected override IEnumerable<TernaryButton> CreateTernaryButtons()
=> base.CreateTernaryButtons() => base.CreateTernaryButtons()
.Concat(DistanceSnapProvider.CreateTernaryButtons()); .Concat(DistanceSnapProvider.CreateTernaryButtons());

View File

@ -0,0 +1,41 @@
// 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.
using System.Linq;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Objects;
using osu.Game.Screens.Edit.Compose.Components;
namespace osu.Game.Rulesets.Catch.Edit
{
public partial class CatchHitObjectInspector(CatchDistanceSnapProvider snapProvider) : HitObjectInspector
{
protected override void AddInspectorValues(HitObject[] objects)
{
base.AddInspectorValues(objects);
if (objects.Length > 0)
{
HitObject firstSelectedHitObject = objects.MinBy(ho => ho.StartTime)!;
HitObject lastSelectedHitObject = objects.MaxBy(ho => ho.GetEndTime())!;
HitObject? precedingObject = EditorBeatmap.HitObjects.LastOrDefault(ho => ho.GetEndTime() < firstSelectedHitObject.StartTime);
HitObject? nextObject = EditorBeatmap.HitObjects.FirstOrDefault(ho => ho.StartTime > lastSelectedHitObject.GetEndTime());
if (precedingObject != null && precedingObject is not BananaShower)
{
double previousSnap = snapProvider.ReadCurrentDistanceSnap(precedingObject, firstSelectedHitObject);
AddHeader("To previous");
AddValue($"{previousSnap:#,0.##}x");
}
if (nextObject != null && nextObject is not BananaShower)
{
double nextSnap = snapProvider.ReadCurrentDistanceSnap(lastSelectedHitObject, nextObject);
AddHeader("To next");
AddValue($"{nextSnap:#,0.##}x");
}
}
}
}
}

View File

@ -0,0 +1,39 @@
// 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.
using System.Collections.Generic;
using NUnit.Framework;
using osu.Game.Rulesets.Mania.Scoring;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
namespace osu.Game.Rulesets.Mania.Tests
{
[TestFixture]
public class ManiaScoreProcessorTest
{
[TestCase(ScoreRank.X, 1, HitResult.Perfect)]
[TestCase(ScoreRank.X, 0.99, HitResult.Great)]
[TestCase(ScoreRank.D, 0.1, HitResult.Great)]
[TestCase(ScoreRank.X, 0.99, HitResult.Perfect, HitResult.Great)]
[TestCase(ScoreRank.X, 0.99, HitResult.Great, HitResult.Great)]
[TestCase(ScoreRank.S, 0.99, HitResult.Perfect, HitResult.Good)]
[TestCase(ScoreRank.S, 0.99, HitResult.Perfect, HitResult.Ok)]
[TestCase(ScoreRank.S, 0.99, HitResult.Perfect, HitResult.Meh)]
[TestCase(ScoreRank.S, 0.99, HitResult.Perfect, HitResult.Miss)]
[TestCase(ScoreRank.S, 0.99, HitResult.Great, HitResult.Good)]
[TestCase(ScoreRank.S, 0.99, HitResult.Great, HitResult.Ok)]
[TestCase(ScoreRank.S, 0.99, HitResult.Great, HitResult.Meh)]
[TestCase(ScoreRank.S, 0.99, HitResult.Great, HitResult.Miss)]
public void TestRanks(ScoreRank expected, double accuracy, params HitResult[] results)
{
var scoreProcessor = new ManiaScoreProcessor();
Dictionary<HitResult, int> resultsDict = new Dictionary<HitResult, int>();
foreach (var result in results)
resultsDict[result] = resultsDict.GetValueOrDefault(result) + 1;
Assert.That(scoreProcessor.RankFromScore(accuracy, resultsDict), Is.EqualTo(expected));
}
}
}

View File

@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
CreateModTest(new ModTestData CreateModTest(new ModTestData
{ {
Autoplay = true, Autoplay = true,
Beatmap = new ManiaBeatmap(new StageDefinition(1)) CreateBeatmap = () => new ManiaBeatmap(new StageDefinition(1))
{ {
HitObjects = new List<ManiaHitObject> HitObjects = new List<ManiaHitObject>
{ {

View File

@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
&& Precision.AlmostEquals(Player.ScoreProcessor.Accuracy.Value, 0.9836, 0.01) && Precision.AlmostEquals(Player.ScoreProcessor.Accuracy.Value, 0.9836, 0.01)
&& Player.ScoreProcessor.TotalScore.Value == 946_049, && Player.ScoreProcessor.TotalScore.Value == 946_049,
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo }, BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo },
Difficulty = { OverallDifficulty = 10 }, Difficulty = { OverallDifficulty = 10 },
@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
&& Player.ScoreProcessor.Accuracy.Value == 1 && Player.ScoreProcessor.Accuracy.Value == 1
&& Player.ScoreProcessor.TotalScore.Value == (long)(1_000_000 * doubleTime.ScoreMultiplier), && Player.ScoreProcessor.TotalScore.Value == (long)(1_000_000 * doubleTime.ScoreMultiplier),
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo }, BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo },
Difficulty = { OverallDifficulty = 10 }, Difficulty = { OverallDifficulty = 10 },

View File

@ -74,7 +74,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
CreateModTest(new ModTestData CreateModTest(new ModTestData
{ {
Mod = new ManiaModHidden(), Mod = new ManiaModHidden(),
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = Enumerable.Range(1, 100).Select(i => (HitObject)new Note { StartTime = 1000 + 200 * i }).ToList(), HitObjects = Enumerable.Range(1, 100).Select(i => (HitObject)new Note { StartTime = 1000 + 200 * i }).ToList(),
Breaks = { new BreakPeriod(2000, 28000) } Breaks = { new BreakPeriod(2000, 28000) }

View File

@ -74,7 +74,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
CreateModTest(new ModTestData CreateModTest(new ModTestData
{ {
Mod = new ManiaModHidden(), Mod = new ManiaModHidden(),
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = Enumerable.Range(1, 100).Select(i => (HitObject)new Note { StartTime = 1000 + 200 * i }).ToList(), HitObjects = Enumerable.Range(1, 100).Select(i => (HitObject)new Note { StartTime = 1000 + 200 * i }).ToList(),
Breaks = { new BreakPeriod(2000, 28000) } Breaks = { new BreakPeriod(2000, 28000) }

View File

@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
Mod = new ManiaModPerfect(), Mod = new ManiaModPerfect(),
PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(false), PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(false),
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -59,7 +59,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
Mod = new ManiaModPerfect(), Mod = new ManiaModPerfect(),
PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(true) && Player.Results.Count == 2, PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(true) && Player.Results.Count == 2,
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {

View File

@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
Mod = new ManiaModSuddenDeath(), Mod = new ManiaModSuddenDeath(),
PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(false), PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(false),
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
Mod = new ManiaModSuddenDeath(), Mod = new ManiaModSuddenDeath(),
PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(true) && Player.Results.Count == 2, PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(true) && Player.Results.Count == 2,
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {

View File

@ -9,6 +9,7 @@ using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
namespace osu.Game.Rulesets.Mania.Scoring namespace osu.Game.Rulesets.Mania.Scoring
{ {
@ -58,6 +59,24 @@ namespace osu.Game.Rulesets.Mania.Scoring
return GetBaseScoreForResult(result); return GetBaseScoreForResult(result);
} }
public override ScoreRank RankFromScore(double accuracy, IReadOnlyDictionary<HitResult, int> results)
{
ScoreRank rank = base.RankFromScore(accuracy, results);
if (rank != ScoreRank.S)
return rank;
// SS is expected as long as all hitobjects have been hit with either a GREAT or PERFECT result.
bool anyImperfect =
results.GetValueOrDefault(HitResult.Good) > 0
|| results.GetValueOrDefault(HitResult.Ok) > 0
|| results.GetValueOrDefault(HitResult.Meh) > 0
|| results.GetValueOrDefault(HitResult.Miss) > 0;
return anyImperfect ? rank : ScoreRank.X;
}
private class JudgementOrderComparer : IComparer<HitObject> private class JudgementOrderComparer : IComparer<HitObject>
{ {
public static readonly JudgementOrderComparer DEFAULT = new JudgementOrderComparer(); public static readonly JudgementOrderComparer DEFAULT = new JudgementOrderComparer();

View File

@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
Mod = new OsuModAlternate(), Mod = new OsuModAlternate(),
PassCondition = () => Player.ScoreProcessor.Combo.Value == 4, PassCondition = () => Player.ScoreProcessor.Combo.Value == 4,
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -68,7 +68,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
Mod = new OsuModAlternate(), Mod = new OsuModAlternate(),
PassCondition = () => Player.ScoreProcessor.Combo.Value == 0 && Player.ScoreProcessor.HighestCombo.Value == 1, PassCondition = () => Player.ScoreProcessor.Combo.Value == 0 && Player.ScoreProcessor.HighestCombo.Value == 1,
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -101,7 +101,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
Mod = new OsuModAlternate(), Mod = new OsuModAlternate(),
PassCondition = () => Player.ScoreProcessor.Combo.Value == 1, PassCondition = () => Player.ScoreProcessor.Combo.Value == 1,
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -131,7 +131,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
Mod = new OsuModAlternate(), Mod = new OsuModAlternate(),
PassCondition = () => Player.ScoreProcessor.Combo.Value == 0 && Player.ScoreProcessor.HighestCombo.Value == 2, PassCondition = () => Player.ScoreProcessor.Combo.Value == 0 && Player.ScoreProcessor.HighestCombo.Value == 2,
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
Breaks = Breaks =
{ {

View File

@ -60,7 +60,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
CreateModTest(new ModTestData CreateModTest(new ModTestData
{ {
Autoplay = true, Autoplay = true,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -90,7 +90,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
Autoplay = true, Autoplay = true,
Mod = mod, Mod = mod,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = HitObjects =
{ {

View File

@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
public void TestNoAdjustment() => CreateModTest(new ModTestData public void TestNoAdjustment() => CreateModTest(new ModTestData
{ {
Mod = new OsuModDifficultyAdjust(), Mod = new OsuModDifficultyAdjust(),
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
BeatmapInfo = new BeatmapInfo BeatmapInfo = new BeatmapInfo
{ {

View File

@ -68,7 +68,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
Player.GameplayClockContainer.CurrentTime < 1000 && Player.ChildrenOfType<ModFlashlight<OsuHitObject>.Flashlight>().Single().FlashlightDim > 0; Player.GameplayClockContainer.CurrentTime < 1000 && Player.ChildrenOfType<ModFlashlight<OsuHitObject>.Flashlight>().Single().FlashlightDim > 0;
return Player.GameplayState.HasPassed && !sliderDimmedBeforeStartTime; return Player.GameplayState.HasPassed && !sliderDimmedBeforeStartTime;
}, },
Beatmap = new OsuBeatmap CreateBeatmap = () => new OsuBeatmap
{ {
HitObjects = new List<OsuHitObject> HitObjects = new List<OsuHitObject>
{ {
@ -114,7 +114,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
Player.GameplayClockContainer.CurrentTime >= 1000 && Player.ChildrenOfType<ModFlashlight<OsuHitObject>.Flashlight>().Single().FlashlightDim > 0; Player.GameplayClockContainer.CurrentTime >= 1000 && Player.ChildrenOfType<ModFlashlight<OsuHitObject>.Flashlight>().Single().FlashlightDim > 0;
return Player.GameplayState.HasPassed && sliderDimmed; return Player.GameplayState.HasPassed && sliderDimmed;
}, },
Beatmap = new OsuBeatmap CreateBeatmap = () => new OsuBeatmap
{ {
HitObjects = new List<OsuHitObject> HitObjects = new List<OsuHitObject>
{ {
@ -153,7 +153,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
Player.GameplayClockContainer.CurrentTime >= 1000 && Player.ChildrenOfType<ModFlashlight<OsuHitObject>.Flashlight>().Single().FlashlightDim > 0; Player.GameplayClockContainer.CurrentTime >= 1000 && Player.ChildrenOfType<ModFlashlight<OsuHitObject>.Flashlight>().Single().FlashlightDim > 0;
return Player.GameplayState.HasPassed && sliderDimmed; return Player.GameplayState.HasPassed && sliderDimmed;
}, },
Beatmap = new OsuBeatmap CreateBeatmap = () => new OsuBeatmap
{ {
HitObjects = new List<OsuHitObject> HitObjects = new List<OsuHitObject>
{ {

View File

@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
Mod = new TestOsuModHidden(), Mod = new TestOsuModHidden(),
Autoplay = true, Autoplay = true,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -63,7 +63,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
Mod = new TestOsuModHidden(), Mod = new TestOsuModHidden(),
Autoplay = true, Autoplay = true,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -98,7 +98,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
Mod = new TestOsuModHidden(), Mod = new TestOsuModHidden(),
Autoplay = true, Autoplay = true,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -122,7 +122,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
Mod = new OsuModHidden { OnlyFadeApproachCircles = { Value = true } }, Mod = new OsuModHidden { OnlyFadeApproachCircles = { Value = true } },
Autoplay = true, Autoplay = true,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {

View File

@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
public void TestCorrectReflections([Values] OsuModMirror.MirrorType type, [Values] bool withStrictTracking) => CreateModTest(new ModTestData public void TestCorrectReflections([Values] OsuModMirror.MirrorType type, [Values] bool withStrictTracking) => CreateModTest(new ModTestData
{ {
Autoplay = true, Autoplay = true,
Beatmap = new OsuBeatmap CreateBeatmap = () => new OsuBeatmap
{ {
HitObjects = HitObjects =
{ {

View File

@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
}, },
Autoplay = true, Autoplay = true,
PassCondition = () => true, PassCondition = () => true,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -71,7 +71,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
}, },
Autoplay = true, Autoplay = true,
PassCondition = () => true, PassCondition = () => true,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -113,7 +113,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
}, },
Autoplay = true, Autoplay = true,
PassCondition = () => true, PassCondition = () => true,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {

View File

@ -61,7 +61,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
Mod = new OsuModPerfect(), Mod = new OsuModPerfect(),
PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(true), PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(true),
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {

View File

@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
AngleSharpness = { Value = angleSharpness } AngleSharpness = { Value = angleSharpness }
}, },
Beatmap = jumpBeatmap, CreateBeatmap = jumpBeatmap,
Autoplay = true, Autoplay = true,
PassCondition = () => true PassCondition = () => true
}); });
@ -50,15 +50,15 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
AngleSharpness = { Value = angleSharpness } AngleSharpness = { Value = angleSharpness }
}, },
Beatmap = streamBeatmap, CreateBeatmap = streamBeatmap,
Autoplay = true, Autoplay = true,
PassCondition = () => true PassCondition = () => true
}); });
private OsuBeatmap jumpBeatmap => private OsuBeatmap jumpBeatmap() =>
createHitCircleBeatmap(new[] { 100, 200, 300, 400 }, 8, 300, 2 * 300); createHitCircleBeatmap(new[] { 100, 200, 300, 400 }, 8, 300, 2 * 300);
private OsuBeatmap streamBeatmap => private OsuBeatmap streamBeatmap() =>
createHitCircleBeatmap(new[] { 10, 20, 30, 40, 50, 60, 70, 80 }, 16, 150, 4 * 150); createHitCircleBeatmap(new[] { 10, 20, 30, 40, 50, 60, 70, 80 }, 16, 150, 4 * 150);
private OsuBeatmap createHitCircleBeatmap(IEnumerable<int> spacings, int objectsPerSpacing, int interval, int beatLength) private OsuBeatmap createHitCircleBeatmap(IEnumerable<int> spacings, int objectsPerSpacing, int interval, int beatLength)

View File

@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
Mod = new OsuModSingleTap(), Mod = new OsuModSingleTap(),
PassCondition = () => Player.ScoreProcessor.Combo.Value == 2, PassCondition = () => Player.ScoreProcessor.Combo.Value == 2,
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -62,7 +62,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
Mod = new OsuModSingleTap(), Mod = new OsuModSingleTap(),
PassCondition = () => Player.ScoreProcessor.Combo.Value == 0 && Player.ScoreProcessor.HighestCombo.Value == 1, PassCondition = () => Player.ScoreProcessor.Combo.Value == 0 && Player.ScoreProcessor.HighestCombo.Value == 1,
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -100,7 +100,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
Mod = new OsuModSingleTap(), Mod = new OsuModSingleTap(),
PassCondition = () => Player.ScoreProcessor.Combo.Value == 1, PassCondition = () => Player.ScoreProcessor.Combo.Value == 1,
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -130,7 +130,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
Mod = new OsuModSingleTap(), Mod = new OsuModSingleTap(),
PassCondition = () => Player.ScoreProcessor.Combo.Value == 0 && Player.ScoreProcessor.HighestCombo.Value == 2, PassCondition = () => Player.ScoreProcessor.Combo.Value == 0 && Player.ScoreProcessor.HighestCombo.Value == 2,
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
Breaks = Breaks =
{ {

View File

@ -35,7 +35,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
Mod = new OsuModSpunOut(), Mod = new OsuModSpunOut(),
Autoplay = false, Autoplay = false,
Beatmap = singleSpinnerBeatmap, CreateBeatmap = singleSpinnerBeatmap,
PassCondition = () => PassCondition = () =>
{ {
// Bind to the first spinner's results for further tracking. // Bind to the first spinner's results for further tracking.
@ -71,7 +71,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
Mods = mods, Mods = mods,
Autoplay = false, Autoplay = false,
Beatmap = singleSpinnerBeatmap, CreateBeatmap = singleSpinnerBeatmap,
PassCondition = () => PassCondition = () =>
{ {
var counter = Player.ChildrenOfType<SpinnerSpmCalculator>().SingleOrDefault(); var counter = Player.ChildrenOfType<SpinnerSpmCalculator>().SingleOrDefault();
@ -101,7 +101,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
Mod = new OsuModSpunOut(), Mod = new OsuModSpunOut(),
Autoplay = false, Autoplay = false,
Beatmap = singleSpinnerBeatmap, CreateBeatmap = singleSpinnerBeatmap,
PassCondition = () => PassCondition = () =>
{ {
// Bind to the first spinner's results for further tracking. // Bind to the first spinner's results for further tracking.
@ -130,7 +130,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
}); });
} }
private Beatmap singleSpinnerBeatmap => new Beatmap private Beatmap singleSpinnerBeatmap() => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {

View File

@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
Mod = new OsuModStrictTracking(), Mod = new OsuModStrictTracking(),
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {

View File

@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
Mod = new OsuModSuddenDeath(), Mod = new OsuModSuddenDeath(),
PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(false), PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(false),
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -55,7 +55,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
Mod = new OsuModSuddenDeath(), Mod = new OsuModSuddenDeath(),
PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(true), PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(true),
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {

View File

@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
Autoplay = false, Autoplay = false,
Mod = new TestAutoMod(), Mod = new TestAutoMod(),
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = { new HitCircle { Position = new Vector2(256, 192) } } HitObjects = { new HitCircle { Position = new Vector2(256, 192) } }
}, },
@ -47,18 +47,16 @@ namespace osu.Game.Rulesets.Osu.Tests
[Test] [Test]
public void TestMissViaNotHitting() public void TestMissViaNotHitting()
{ {
var beatmap = new Beatmap
{
HitObjects = { new HitCircle { Position = new Vector2(256, 192) } }
};
var hitWindows = new OsuHitWindows(); var hitWindows = new OsuHitWindows();
hitWindows.SetDifficulty(beatmap.Difficulty.OverallDifficulty); hitWindows.SetDifficulty(IBeatmapDifficultyInfo.DEFAULT_DIFFICULTY);
CreateModTest(new ModTestData CreateModTest(new ModTestData
{ {
Autoplay = false, Autoplay = false,
Beatmap = beatmap, CreateBeatmap = () => new Beatmap
{
HitObjects = { new HitCircle { Position = new Vector2(256, 192) } }
},
PassCondition = () => Player.Results.Count > 0 && Player.Results[0].TimeOffset >= hitWindows.WindowFor(HitResult.Meh) && !Player.Results[0].IsHit PassCondition = () => Player.Results.Count > 0 && Player.Results[0].TimeOffset >= hitWindows.WindowFor(HitResult.Meh) && !Player.Results[0].IsHit
}); });
} }

View File

@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Osu.Edit
{ {
public partial class OsuDistanceSnapProvider : ComposerDistanceSnapProvider public partial class OsuDistanceSnapProvider : ComposerDistanceSnapProvider
{ {
protected override double ReadCurrentDistanceSnap(HitObject before, HitObject after) public override double ReadCurrentDistanceSnap(HitObject before, HitObject after)
{ {
float expectedDistance = DurationToDistance(before, after.StartTime - before.GetEndTime()); float expectedDistance = DurationToDistance(before, after.StartTime - before.GetEndTime());
float actualDistance = Vector2.Distance(((OsuHitObject)before).EndPosition, ((OsuHitObject)after).Position); float actualDistance = Vector2.Distance(((OsuHitObject)before).EndPosition, ((OsuHitObject)after).Position);

View File

@ -31,6 +31,13 @@ namespace osu.Game.Rulesets.Taiko.Tests.Mods
{ {
const double hit_time = 1; const double hit_time = 1;
CreateModTest(new ModTestData
{
Mod = new TaikoModHidden(),
Autoplay = true,
PassCondition = checkAllMaxResultJudgements(2),
CreateBeatmap = () =>
{
var beatmap = new Beatmap<TaikoHitObject> var beatmap = new Beatmap<TaikoHitObject>
{ {
HitObjects = new List<TaikoHitObject> HitObjects = new List<TaikoHitObject>
@ -58,13 +65,8 @@ namespace osu.Game.Rulesets.Taiko.Tests.Mods
}; };
beatmap.ControlPointInfo.Add(0, new EffectControlPoint { ScrollSpeed = 0.1f }); beatmap.ControlPointInfo.Add(0, new EffectControlPoint { ScrollSpeed = 0.1f });
return beatmap;
CreateModTest(new ModTestData },
{
Mod = new TaikoModHidden(),
Autoplay = true,
PassCondition = checkAllMaxResultJudgements(2),
Beatmap = beatmap,
}); });
} }
} }

View File

@ -15,7 +15,26 @@ namespace osu.Game.Rulesets.Taiko.Tests.Mods
[Test] [Test]
public void TestRelax() public void TestRelax()
{ {
var beatmap = new TaikoBeatmap var beatmapForReplay = createBeatmap();
foreach (var ho in beatmapForReplay.HitObjects)
ho.ApplyDefaults(beatmapForReplay.ControlPointInfo, beatmapForReplay.Difficulty);
var replay = new TaikoAutoGenerator(beatmapForReplay).Generate();
foreach (var frame in replay.Frames.OfType<TaikoReplayFrame>().Where(r => r.Actions.Any()))
frame.Actions = [TaikoAction.LeftCentre];
CreateModTest(new ModTestData
{
Mod = new TaikoModRelax(),
CreateBeatmap = createBeatmap,
ReplayFrames = replay.Frames,
Autoplay = false,
PassCondition = () => Player.ScoreProcessor.HasCompleted.Value && Player.ScoreProcessor.Accuracy.Value == 1,
});
TaikoBeatmap createBeatmap() => new TaikoBeatmap
{ {
HitObjects = HitObjects =
{ {
@ -25,22 +44,6 @@ namespace osu.Game.Rulesets.Taiko.Tests.Mods
new Swell { StartTime = 1250, Duration = 500 }, new Swell { StartTime = 1250, Duration = 500 },
} }
}; };
foreach (var ho in beatmap.HitObjects)
ho.ApplyDefaults(beatmap.ControlPointInfo, beatmap.Difficulty);
var replay = new TaikoAutoGenerator(beatmap).Generate();
foreach (var frame in replay.Frames.OfType<TaikoReplayFrame>().Where(r => r.Actions.Any()))
frame.Actions = [TaikoAction.LeftCentre];
CreateModTest(new ModTestData
{
Mod = new TaikoModRelax(),
Beatmap = beatmap,
ReplayFrames = replay.Frames,
Autoplay = false,
PassCondition = () => Player.ScoreProcessor.HasCompleted.Value && Player.ScoreProcessor.Accuracy.Value == 1,
});
} }
} }
} }

View File

@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Mods
{ {
Mod = new TaikoModSingleTap(), Mod = new TaikoModSingleTap(),
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -65,7 +65,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Mods
{ {
Mod = new TaikoModSingleTap(), Mod = new TaikoModSingleTap(),
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -110,7 +110,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Mods
{ {
Mod = new TaikoModSingleTap(), Mod = new TaikoModSingleTap(),
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -136,7 +136,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Mods
{ {
Mod = new TaikoModSingleTap(), Mod = new TaikoModSingleTap(),
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = new List<HitObject> HitObjects = new List<HitObject>
{ {
@ -175,7 +175,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Mods
{ {
Mod = new TaikoModSingleTap(), Mod = new TaikoModSingleTap(),
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
Breaks = Breaks =
{ {

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.IO; using System.IO;
using System.Text;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions; using osu.Framework.Extensions;
@ -9,6 +10,7 @@ using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.IO.Archives;
using osu.Game.Tests.Resources; using osu.Game.Tests.Resources;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using MemoryStream = System.IO.MemoryStream; using MemoryStream = System.IO.MemoryStream;
@ -48,6 +50,47 @@ namespace osu.Game.Tests.Beatmaps.IO
AddAssert("hit object is snapped", () => beatmap.Beatmap.HitObjects[0].StartTime, () => Is.EqualTo(28519).Within(0.001)); AddAssert("hit object is snapped", () => beatmap.Beatmap.HitObjects[0].StartTime, () => Is.EqualTo(28519).Within(0.001));
} }
[Test]
public void TestExportStability()
{
IWorkingBeatmap beatmap = null!;
MemoryStream firstExport = null!;
MemoryStream secondExport = null!;
// Ensure importer encoding is correct
AddStep("import beatmap", () => beatmap = importBeatmapFromArchives(@"legacy-export-stability-test.olz"));
AddStep("export once", () =>
{
firstExport = new MemoryStream();
new LegacyBeatmapExporter(LocalStorage)
.ExportToStream((BeatmapSetInfo)beatmap.BeatmapInfo.BeatmapSet!, firstExport, null);
});
AddStep("import beatmap again", () => beatmap = importBeatmapFromStream(firstExport));
AddStep("export again", () =>
{
secondExport = new MemoryStream();
new LegacyBeatmapExporter(LocalStorage)
.ExportToStream((BeatmapSetInfo)beatmap.BeatmapInfo.BeatmapSet!, secondExport, null);
});
const string osu_filename = @"legacy export - stability test (spaceman_atlas) [].osu";
AddAssert("exports are identical",
() => getStringContentsOf(osu_filename, firstExport.GetBuffer()),
() => Is.EqualTo(getStringContentsOf(osu_filename, secondExport.GetBuffer())));
string getStringContentsOf(string filename, byte[] archiveBytes)
{
using var memoryStream = new MemoryStream(archiveBytes);
using var archiveReader = new ZipArchiveReader(memoryStream);
byte[] fileContent = archiveReader.GetStream(filename).ReadAllBytesToArray();
return Encoding.UTF8.GetString(fileContent);
}
}
private IWorkingBeatmap importBeatmapFromStream(Stream stream) private IWorkingBeatmap importBeatmapFromStream(Stream stream)
{ {
var imported = beatmaps.Import(new ImportTask(stream, "filename.osz")).GetResultSafely(); var imported = beatmaps.Import(new ImportTask(stream, "filename.osz")).GetResultSafely();

View File

@ -73,7 +73,7 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
AddStep("create room initially in gameplay", () => AddStep("create room initially in gameplay", () =>
{ {
var newRoom = new Room(); var newRoom = new Room();
newRoom.CopyFrom(SelectedRoom.Value); newRoom.CopyFrom(SelectedRoom.Value!);
newRoom.RoomID = null; newRoom.RoomID = null;
MultiplayerClient.RoomSetupAction = room => MultiplayerClient.RoomSetupAction = room =>

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
@ -21,12 +19,12 @@ namespace osu.Game.Tests.OnlinePlay
[HeadlessTest] [HeadlessTest]
public partial class TestSceneCatchUpSyncManager : OsuTestScene public partial class TestSceneCatchUpSyncManager : OsuTestScene
{ {
private GameplayClockContainer master; private GameplayClockContainer master = null!;
private SpectatorSyncManager syncManager; private SpectatorSyncManager syncManager = null!;
private Dictionary<SpectatorPlayerClock, int> clocksById; private Dictionary<SpectatorPlayerClock, int> clocksById = null!;
private SpectatorPlayerClock player1; private SpectatorPlayerClock player1 = null!;
private SpectatorPlayerClock player2; private SpectatorPlayerClock player2 = null!;
[SetUp] [SetUp]
public void Setup() public void Setup()

View File

@ -18,6 +18,7 @@ using osu.Framework.Testing;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.Notifications; using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
@ -207,7 +208,25 @@ namespace osu.Game.Tests.Visual.Gameplay
} }
[Test] [Test]
public void TestBlockLoadViaFocus() public void TestLoadNotBlockedViaArbitraryFocus()
{
AddStep("load dummy beatmap", () => resetPlayer(false));
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
AddUntilStep("click settings slider", () =>
{
InputManager.MoveMouseTo(loader.ChildrenOfType<OsuSliderBar<float>>().First());
InputManager.Click(MouseButton.Left);
return InputManager.FocusedDrawable is OsuSliderBar<float>;
});
AddUntilStep("wait for load ready", () => player?.LoadState == LoadState.Ready);
AddUntilStep("loads", () => !loader.IsCurrentScreen());
}
[Test]
public void TestBlockLoadViaOverlayFocus()
{ {
AddStep("load dummy beatmap", () => resetPlayer(false)); AddStep("load dummy beatmap", () => resetPlayer(false));
AddUntilStep("wait for current", () => loader.IsCurrentScreen()); AddUntilStep("wait for current", () => loader.IsCurrentScreen());

View File

@ -35,7 +35,7 @@ namespace osu.Game.Tests.Visual.Mods
MinimumAccuracy = { Value = 0.6 } MinimumAccuracy = { Value = 0.6 }
}, },
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = Enumerable.Range(0, 5).Select(i => new HitCircle HitObjects = Enumerable.Range(0, 5).Select(i => new HitCircle
{ {
@ -56,7 +56,7 @@ namespace osu.Game.Tests.Visual.Mods
AccuracyJudgeMode = { Value = ModAccuracyChallenge.AccuracyMode.Standard } AccuracyJudgeMode = { Value = ModAccuracyChallenge.AccuracyMode.Standard }
}, },
Autoplay = false, Autoplay = false,
Beatmap = new Beatmap CreateBeatmap = () => new Beatmap
{ {
HitObjects = Enumerable.Range(0, 5).Select(i => new HitCircle HitObjects = Enumerable.Range(0, 5).Select(i => new HitCircle
{ {

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
@ -31,7 +29,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
protected readonly BindableList<MultiplayerRoomUser> MultiplayerUsers = new BindableList<MultiplayerRoomUser>(); protected readonly BindableList<MultiplayerRoomUser> MultiplayerUsers = new BindableList<MultiplayerRoomUser>();
protected MultiplayerGameplayLeaderboard Leaderboard { get; private set; } protected MultiplayerGameplayLeaderboard? Leaderboard { get; private set; }
protected virtual MultiplayerRoomUser CreateUser(int userId) => new MultiplayerRoomUser(userId); protected virtual MultiplayerRoomUser CreateUser(int userId) => new MultiplayerRoomUser(userId);
@ -40,7 +38,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
private readonly BindableList<int> multiplayerUserIds = new BindableList<int>(); private readonly BindableList<int> multiplayerUserIds = new BindableList<int>();
private readonly BindableDictionary<int, SpectatorState> watchedUserStates = new BindableDictionary<int, SpectatorState>(); private readonly BindableDictionary<int, SpectatorState> watchedUserStates = new BindableDictionary<int, SpectatorState>();
private OsuConfigManager config; private OsuConfigManager config = null!;
private readonly Mock<SpectatorClient> spectatorClient = new Mock<SpectatorClient>(); private readonly Mock<SpectatorClient> spectatorClient = new Mock<SpectatorClient>();
private readonly Mock<MultiplayerClient> multiplayerClient = new Mock<MultiplayerClient>(); private readonly Mock<MultiplayerClient> multiplayerClient = new Mock<MultiplayerClient>();
@ -133,7 +131,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
LoadComponentAsync(Leaderboard = CreateLeaderboard(), Add); LoadComponentAsync(Leaderboard = CreateLeaderboard(), Add);
}); });
AddUntilStep("wait for load", () => Leaderboard.IsLoaded); AddUntilStep("wait for load", () => Leaderboard!.IsLoaded);
AddStep("check watch requests were sent", () => AddStep("check watch requests were sent", () =>
{ {
@ -146,7 +144,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
public void TestScoreUpdates() public void TestScoreUpdates()
{ {
AddRepeatStep("update state", UpdateUserStatesRandomly, 100); AddRepeatStep("update state", UpdateUserStatesRandomly, 100);
AddToggleStep("switch compact mode", expanded => Leaderboard.Expanded.Value = expanded); AddToggleStep("switch compact mode", expanded => Leaderboard!.Expanded.Value = expanded);
} }
[Test] [Test]

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -12,7 +10,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
public partial class TestSceneCreateMultiplayerMatchButton : MultiplayerTestScene public partial class TestSceneCreateMultiplayerMatchButton : MultiplayerTestScene
{ {
private CreateMultiplayerMatchButton button; private CreateMultiplayerMatchButton button = null!;
public override void SetUpSteps() public override void SetUpSteps()
{ {
@ -29,7 +27,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Test] [Test]
public void TestButtonEnableStateChanges() public void TestButtonEnableStateChanges()
{ {
IDisposable joiningRoomOperation = null; IDisposable joiningRoomOperation = null!;
assertButtonEnableState(true); assertButtonEnableState(true);

View File

@ -119,7 +119,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("4 circles displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 4); AddAssert("4 circles displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 4);
AddAssert("46 hidden users", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Count == 46); AddAssert("46 hidden users", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Count == 46);
AddStep("remove from end", () => removeUserAt(SelectedRoom.Value.RecentParticipants.Count - 1)); AddStep("remove from end", () => removeUserAt(SelectedRoom.Value!.RecentParticipants.Count - 1));
AddAssert("4 circles displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 4); AddAssert("4 circles displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 4);
AddAssert("45 hidden users", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Count == 45); AddAssert("45 hidden users", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Count == 45);
@ -138,18 +138,18 @@ namespace osu.Game.Tests.Visual.Multiplayer
private void addUser(int id) private void addUser(int id)
{ {
SelectedRoom.Value.RecentParticipants = SelectedRoom.Value.RecentParticipants.Append(new APIUser SelectedRoom.Value!.RecentParticipants = SelectedRoom.Value!.RecentParticipants.Append(new APIUser
{ {
Id = id, Id = id,
Username = $"User {id}" Username = $"User {id}"
}).ToArray(); }).ToArray();
SelectedRoom.Value.ParticipantCount++; SelectedRoom.Value!.ParticipantCount++;
} }
private void removeUserAt(int index) private void removeUserAt(int index)
{ {
SelectedRoom.Value.RecentParticipants = SelectedRoom.Value.RecentParticipants.Where(u => !u.Equals(SelectedRoom.Value.RecentParticipants[index])).ToArray(); SelectedRoom.Value!.RecentParticipants = SelectedRoom.Value!.RecentParticipants.Where(u => !u.Equals(SelectedRoom.Value!.RecentParticipants[index])).ToArray();
SelectedRoom.Value.ParticipantCount--; SelectedRoom.Value!.ParticipantCount--;
} }
} }
} }

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
@ -39,9 +37,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
public partial class TestSceneDrawableRoomPlaylist : MultiplayerTestScene public partial class TestSceneDrawableRoomPlaylist : MultiplayerTestScene
{ {
private TestPlaylist playlist; private TestPlaylist playlist = null!;
private BeatmapManager manager = null!;
private BeatmapManager manager;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(GameHost host, AudioManager audio) private void load(GameHost host, AudioManager audio)
@ -199,14 +196,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Test] [Test]
public void TestDownloadButtonHiddenWhenBeatmapExists() public void TestDownloadButtonHiddenWhenBeatmapExists()
{ {
Live<BeatmapSetInfo> imported = null; Live<BeatmapSetInfo> imported = null!;
AddStep("import beatmap", () => AddStep("import beatmap", () =>
{ {
var beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo; var beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo;
Debug.Assert(beatmap.BeatmapSet != null); Debug.Assert(beatmap.BeatmapSet != null);
imported = manager.Import(beatmap.BeatmapSet); imported = manager.Import(beatmap.BeatmapSet)!;
}); });
createPlaylistWithBeatmaps(() => imported.PerformRead(s => s.Beatmaps.Detach())); createPlaylistWithBeatmaps(() => imported.PerformRead(s => s.Beatmaps.Detach()));
@ -378,7 +375,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
} }
}); });
private void createPlaylist(Action<TestPlaylist> setupPlaylist = null) private void createPlaylist(Action<TestPlaylist>? setupPlaylist = null)
{ {
AddStep("create playlist", () => AddStep("create playlist", () =>
{ {

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -26,9 +24,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
public partial class TestSceneFreeModSelectOverlay : MultiplayerTestScene public partial class TestSceneFreeModSelectOverlay : MultiplayerTestScene
{ {
private FreeModSelectOverlay freeModSelectOverlay; private FreeModSelectOverlay freeModSelectOverlay = null!;
private FooterButtonFreeMods footerButtonFreeMods; private FooterButtonFreeMods footerButtonFreeMods = null!;
private ScreenFooter footer; private ScreenFooter footer = null!;
private readonly Bindable<Dictionary<ModType, IReadOnlyList<Mod>>> availableMods = new Bindable<Dictionary<ModType, IReadOnlyList<Mod>>>(); private readonly Bindable<Dictionary<ModType, IReadOnlyList<Mod>>> availableMods = new Bindable<Dictionary<ModType, IReadOnlyList<Mod>>>();
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -49,7 +47,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddToggleStep("toggle visibility", visible => AddToggleStep("toggle visibility", visible =>
{ {
if (freeModSelectOverlay != null)
freeModSelectOverlay.State.Value = visible ? Visibility.Visible : Visibility.Hidden; freeModSelectOverlay.State.Value = visible ? Visibility.Visible : Visibility.Hidden;
}); });
} }

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Linq; using System.Linq;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
@ -20,7 +18,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
public partial class TestSceneGameplayChatDisplay : OsuManualInputManagerTestScene public partial class TestSceneGameplayChatDisplay : OsuManualInputManagerTestScene
{ {
private GameplayChatDisplay chatDisplay; private GameplayChatDisplay chatDisplay = null!;
[Cached(typeof(ILocalUserPlayInfo))] [Cached(typeof(ILocalUserPlayInfo))]
private ILocalUserPlayInfo localUserInfo; private ILocalUserPlayInfo localUserInfo;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
@ -70,13 +68,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
RunGameplay(); RunGameplay();
IBeatmapInfo firstBeatmap = null; IBeatmapInfo firstBeatmap = null!;
AddStep("get first playlist item beatmap", () => firstBeatmap = MultiplayerClient.ServerAPIRoom?.Playlist[0].Beatmap); AddStep("get first playlist item beatmap", () => firstBeatmap = MultiplayerClient.ServerAPIRoom!.Playlist[0].Beatmap);
selectNewItem(() => OtherBeatmap); selectNewItem(() => OtherBeatmap);
AddUntilStep("first playlist item hasn't changed", () => MultiplayerClient.ServerAPIRoom?.Playlist[0].Beatmap == firstBeatmap); AddUntilStep("first playlist item hasn't changed", () => MultiplayerClient.ServerAPIRoom!.Playlist[0].Beatmap == firstBeatmap);
AddUntilStep("second playlist item changed", () => MultiplayerClient.ClientAPIRoom?.Playlist[1].Beatmap != firstBeatmap); AddUntilStep("second playlist item changed", () => MultiplayerClient.ClientAPIRoom!.Playlist[1].Beatmap != firstBeatmap);
} }
[Test] [Test]
@ -103,7 +101,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddUntilStep("wait for song select", () => CurrentSubScreen is Screens.Select.SongSelect select && select.BeatmapSetsLoaded); AddUntilStep("wait for song select", () => CurrentSubScreen is Screens.Select.SongSelect select && select.BeatmapSetsLoaded);
BeatmapInfo otherBeatmap = null; BeatmapInfo otherBeatmap = null!;
AddStep("select other beatmap", () => ((Screens.Select.SongSelect)CurrentSubScreen).FinaliseSelection(otherBeatmap = beatmap())); AddStep("select other beatmap", () => ((Screens.Select.SongSelect)CurrentSubScreen).FinaliseSelection(otherBeatmap = beatmap()));
AddUntilStep("wait for return to match", () => CurrentSubScreen is MultiplayerMatchSubScreen); AddUntilStep("wait for return to match", () => CurrentSubScreen is MultiplayerMatchSubScreen);

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -23,7 +21,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
protected new TestRoomManager RoomManager => (TestRoomManager)base.RoomManager; protected new TestRoomManager RoomManager => (TestRoomManager)base.RoomManager;
private RoomsContainer container; private RoomsContainer container = null!;
public override void SetUpSteps() public override void SetUpSteps()
{ {
@ -65,7 +63,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("select first room", () => container.Rooms.First().TriggerClick()); AddStep("select first room", () => container.Rooms.First().TriggerClick());
AddAssert("first spotlight selected", () => checkRoomSelected(RoomManager.Rooms.First(r => r.Category == RoomCategory.Spotlight))); AddAssert("first spotlight selected", () => checkRoomSelected(RoomManager.Rooms.First(r => r.Category == RoomCategory.Spotlight)));
AddStep("remove last room", () => RoomManager.RemoveRoom(RoomManager.Rooms.MinBy(r => r.RoomID))); AddStep("remove last room", () => RoomManager.RemoveRoom(RoomManager.Rooms.MinBy(r => r.RoomID)!));
AddAssert("first spotlight still selected", () => checkRoomSelected(RoomManager.Rooms.First(r => r.Category == RoomCategory.Spotlight))); AddAssert("first spotlight still selected", () => checkRoomSelected(RoomManager.Rooms.First(r => r.Category == RoomCategory.Spotlight)));
AddStep("remove spotlight room", () => RoomManager.RemoveRoom(RoomManager.Rooms.Single(r => r.Category == RoomCategory.Spotlight))); AddStep("remove spotlight room", () => RoomManager.RemoveRoom(RoomManager.Rooms.Single(r => r.Category == RoomCategory.Spotlight)));
@ -157,7 +155,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("add rooms", () => RoomManager.AddRooms(3, new CatchRuleset().RulesetInfo)); AddStep("add rooms", () => RoomManager.AddRooms(3, new CatchRuleset().RulesetInfo));
// Todo: What even is this case...? // Todo: What even is this case...?
AddStep("set empty filter criteria", () => container.Filter.Value = null); AddStep("set empty filter criteria", () => container.Filter.Value = new FilterCriteria());
AddUntilStep("5 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 5); AddUntilStep("5 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 5);
AddStep("filter osu! rooms", () => container.Filter.Value = new FilterCriteria { Ruleset = new OsuRuleset().RulesetInfo }); AddStep("filter osu! rooms", () => container.Filter.Value = new FilterCriteria { Ruleset = new OsuRuleset().RulesetInfo });
@ -195,9 +193,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("add rooms", () => RoomManager.AddRooms(3, withPassword: true)); AddStep("add rooms", () => RoomManager.AddRooms(3, withPassword: true));
} }
private bool checkRoomSelected(Room room) => SelectedRoom.Value == room; private bool checkRoomSelected(Room? room) => SelectedRoom.Value == room;
private Room getRoomInFlow(int index) => private Room? getRoomInFlow(int index) =>
(container.ChildrenOfType<FillFlowContainer<DrawableLoungeRoom>>().First().FlowingChildren.ElementAt(index) as DrawableRoom)?.Room; (container.ChildrenOfType<FillFlowContainer<DrawableLoungeRoom>>().First().FlowingChildren.ElementAt(index) as DrawableRoom)?.Room;
} }
} }

View File

@ -36,7 +36,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
private void createNewItem() private void createNewItem()
{ {
SelectedRoom.Value.Playlist = SelectedRoom.Value.Playlist.Append(new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo) SelectedRoom.Value!.Playlist = SelectedRoom.Value.Playlist.Append(new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
{ {
ID = SelectedRoom.Value.Playlist.Count, ID = SelectedRoom.Value.Playlist.Count,
RulesetID = new OsuRuleset().RulesetInfo.OnlineID, RulesetID = new OsuRuleset().RulesetInfo.OnlineID,

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
@ -18,8 +16,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
public partial class TestSceneMultiSpectatorLeaderboard : MultiplayerTestScene public partial class TestSceneMultiSpectatorLeaderboard : MultiplayerTestScene
{ {
private Dictionary<int, ManualClock> clocks; private Dictionary<int, ManualClock> clocks = null!;
private MultiSpectatorLeaderboard leaderboard; private MultiSpectatorLeaderboard? leaderboard;
[SetUpSteps] [SetUpSteps]
public override void SetUpSteps() public override void SetUpSteps()
@ -55,13 +53,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
}, Add); }, Add);
}); });
AddUntilStep("wait for load", () => leaderboard.IsLoaded); AddUntilStep("wait for load", () => leaderboard!.IsLoaded);
AddUntilStep("wait for user population", () => leaderboard.ChildrenOfType<GameplayLeaderboardScore>().Count() == 2); AddUntilStep("wait for user population", () => leaderboard.ChildrenOfType<GameplayLeaderboardScore>().Count() == 2);
AddStep("add clock sources", () => AddStep("add clock sources", () =>
{ {
foreach ((int userId, var clock) in clocks) foreach ((int userId, var clock) in clocks)
leaderboard.AddClock(userId, clock); leaderboard!.AddClock(userId, clock);
}); });
} }

View File

@ -455,7 +455,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
applyToBeatmap?.Invoke(Beatmap.Value); applyToBeatmap?.Invoke(Beatmap.Value);
LoadScreen(spectatorScreen = new MultiSpectatorScreen(SelectedRoom.Value, playingUsers.ToArray())); LoadScreen(spectatorScreen = new MultiSpectatorScreen(SelectedRoom.Value!, playingUsers.ToArray()));
}); });
AddUntilStep("wait for screen load", () => spectatorScreen.LoadState == LoadState.Loaded && (!waitForPlayerLoad || spectatorScreen.AllPlayersLoaded)); AddUntilStep("wait for screen load", () => spectatorScreen.LoadState == LoadState.Loaded && (!waitForPlayerLoad || spectatorScreen.AllPlayersLoaded));

View File

@ -37,10 +37,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Test] [Test]
public void TestPerUserMods() public void TestPerUserMods()
{ {
AddStep("first user has no mods", () => Assert.That(((TestLeaderboard)Leaderboard).UserMods[0], Is.Empty)); AddStep("first user has no mods", () => Assert.That(((TestLeaderboard)Leaderboard!).UserMods[0], Is.Empty));
AddStep("last user has NF mod", () => AddStep("last user has NF mod", () =>
{ {
Assert.That(((TestLeaderboard)Leaderboard).UserMods[TOTAL_USERS - 1], Has.One.Items); Assert.That(((TestLeaderboard)Leaderboard!).UserMods[TOTAL_USERS - 1], Has.One.Items);
Assert.That(((TestLeaderboard)Leaderboard).UserMods[TOTAL_USERS - 1].Single(), Is.TypeOf<OsuModNoFail>()); Assert.That(((TestLeaderboard)Leaderboard).UserMods[TOTAL_USERS - 1].Single(), Is.TypeOf<OsuModNoFail>());
}); });
} }

View File

@ -39,7 +39,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
LoadComponentAsync(new MatchScoreDisplay LoadComponentAsync(new MatchScoreDisplay
{ {
Team1Score = { BindTarget = Leaderboard.TeamScores[0] }, Team1Score = { BindTarget = Leaderboard!.TeamScores[0] },
Team2Score = { BindTarget = Leaderboard.TeamScores[1] } Team2Score = { BindTarget = Leaderboard.TeamScores[1] }
}, Add); }, Add);

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -22,10 +20,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
protected new TestRoomManager RoomManager => (TestRoomManager)base.RoomManager; protected new TestRoomManager RoomManager => (TestRoomManager)base.RoomManager;
private LoungeSubScreen loungeScreen; private LoungeSubScreen loungeScreen = null!;
private Room? lastJoinedRoom;
private Room lastJoinedRoom; private string? lastJoinedPassword;
private string lastJoinedPassword;
public override void SetUpSteps() public override void SetUpSteps()
{ {
@ -87,7 +84,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Test] [Test]
public void TestJoinRoomWithIncorrectPasswordViaButton() public void TestJoinRoomWithIncorrectPasswordViaButton()
{ {
DrawableLoungeRoom.PasswordEntryPopover passwordEntryPopover = null; DrawableLoungeRoom.PasswordEntryPopover? passwordEntryPopover = null;
AddStep("add room", () => RoomManager.AddRooms(1, withPassword: true)); AddStep("add room", () => RoomManager.AddRooms(1, withPassword: true));
AddStep("select room", () => InputManager.Key(Key.Down)); AddStep("select room", () => InputManager.Key(Key.Down));
@ -97,14 +94,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("press join room button", () => passwordEntryPopover.ChildrenOfType<OsuButton>().First().TriggerClick()); AddStep("press join room button", () => passwordEntryPopover.ChildrenOfType<OsuButton>().First().TriggerClick());
AddAssert("room not joined", () => loungeScreen.IsCurrentScreen()); AddAssert("room not joined", () => loungeScreen.IsCurrentScreen());
AddUntilStep("password prompt still visible", () => passwordEntryPopover.State.Value == Visibility.Visible); AddUntilStep("password prompt still visible", () => passwordEntryPopover!.State.Value == Visibility.Visible);
AddAssert("textbox still focused", () => InputManager.FocusedDrawable is OsuPasswordTextBox); AddAssert("textbox still focused", () => InputManager.FocusedDrawable is OsuPasswordTextBox);
} }
[Test] [Test]
public void TestJoinRoomWithIncorrectPasswordViaEnter() public void TestJoinRoomWithIncorrectPasswordViaEnter()
{ {
DrawableLoungeRoom.PasswordEntryPopover passwordEntryPopover = null; DrawableLoungeRoom.PasswordEntryPopover? passwordEntryPopover = null;
AddStep("add room", () => RoomManager.AddRooms(1, withPassword: true)); AddStep("add room", () => RoomManager.AddRooms(1, withPassword: true));
AddStep("select room", () => InputManager.Key(Key.Down)); AddStep("select room", () => InputManager.Key(Key.Down));
@ -114,14 +111,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("press enter", () => InputManager.Key(Key.Enter)); AddStep("press enter", () => InputManager.Key(Key.Enter));
AddAssert("room not joined", () => loungeScreen.IsCurrentScreen()); AddAssert("room not joined", () => loungeScreen.IsCurrentScreen());
AddUntilStep("password prompt still visible", () => passwordEntryPopover.State.Value == Visibility.Visible); AddUntilStep("password prompt still visible", () => passwordEntryPopover!.State.Value == Visibility.Visible);
AddAssert("textbox still focused", () => InputManager.FocusedDrawable is OsuPasswordTextBox); AddAssert("textbox still focused", () => InputManager.FocusedDrawable is OsuPasswordTextBox);
} }
[Test] [Test]
public void TestJoinRoomWithCorrectPassword() public void TestJoinRoomWithCorrectPassword()
{ {
DrawableLoungeRoom.PasswordEntryPopover passwordEntryPopover = null; DrawableLoungeRoom.PasswordEntryPopover? passwordEntryPopover = null;
AddStep("add room", () => RoomManager.AddRooms(1, withPassword: true)); AddStep("add room", () => RoomManager.AddRooms(1, withPassword: true));
AddStep("select room", () => InputManager.Key(Key.Down)); AddStep("select room", () => InputManager.Key(Key.Down));
@ -137,7 +134,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Test] [Test]
public void TestJoinRoomWithPasswordViaKeyboardOnly() public void TestJoinRoomWithPasswordViaKeyboardOnly()
{ {
DrawableLoungeRoom.PasswordEntryPopover passwordEntryPopover = null; DrawableLoungeRoom.PasswordEntryPopover? passwordEntryPopover = null;
AddStep("add room", () => RoomManager.AddRooms(1, withPassword: true)); AddStep("add room", () => RoomManager.AddRooms(1, withPassword: true));
AddStep("select room", () => InputManager.Key(Key.Down)); AddStep("select room", () => InputManager.Key(Key.Down));
@ -150,7 +147,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("room join password correct", () => lastJoinedPassword == "password"); AddAssert("room join password correct", () => lastJoinedPassword == "password");
} }
private void onRoomJoined(Room room, string password) private void onRoomJoined(Room room, string? password)
{ {
lastJoinedRoom = room; lastJoinedRoom = room;
lastJoinedPassword = password; lastJoinedPassword = password;

View File

@ -1,12 +1,9 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
@ -35,17 +32,16 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
public partial class TestSceneMultiplayerMatchSongSelect : MultiplayerTestScene public partial class TestSceneMultiplayerMatchSongSelect : MultiplayerTestScene
{ {
private BeatmapManager manager; private BeatmapManager manager = null!;
private RulesetStore rulesets; private RulesetStore rulesets = null!;
private IList<BeatmapInfo> beatmaps => importedBeatmapSet?.PerformRead(s => s.Beatmaps) ?? new List<BeatmapInfo>(); private IList<BeatmapInfo> beatmaps => importedBeatmapSet.PerformRead(s => s.Beatmaps);
private TestMultiplayerMatchSongSelect songSelect; private TestMultiplayerMatchSongSelect songSelect = null!;
private Live<BeatmapSetInfo> importedBeatmapSet = null!;
private Live<BeatmapSetInfo> importedBeatmapSet;
[Resolved] [Resolved]
private OsuConfigManager configManager { get; set; } private OsuConfigManager configManager { get; set; } = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(GameHost host, AudioManager audio) private void load(GameHost host, AudioManager audio)
@ -57,7 +53,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
Dependencies.Cache(detachedBeatmapStore = new DetachedBeatmapStore()); Dependencies.Cache(detachedBeatmapStore = new DetachedBeatmapStore());
Dependencies.Cache(Realm); Dependencies.Cache(Realm);
importedBeatmapSet = manager.Import(TestResources.CreateTestBeatmapSetInfo(8, rulesets.AvailableRulesets.ToArray())); importedBeatmapSet = manager.Import(TestResources.CreateTestBeatmapSetInfo(8, rulesets.AvailableRulesets.ToArray()))!;
Add(detachedBeatmapStore); Add(detachedBeatmapStore);
} }
@ -71,7 +67,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
SelectedMods.SetDefault(); SelectedMods.SetDefault();
}); });
AddStep("create song select", () => LoadScreen(songSelect = new TestMultiplayerMatchSongSelect(SelectedRoom.Value))); AddStep("create song select", () => LoadScreen(songSelect = new TestMultiplayerMatchSongSelect(SelectedRoom.Value!)));
AddUntilStep("wait for present", () => songSelect.IsCurrentScreen() && songSelect.BeatmapSetsLoaded); AddUntilStep("wait for present", () => songSelect.IsCurrentScreen() && songSelect.BeatmapSetsLoaded);
} }
@ -88,7 +84,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Test] [Test]
public void TestBeatmapConfirmed() public void TestBeatmapConfirmed()
{ {
BeatmapInfo selectedBeatmap = null; BeatmapInfo selectedBeatmap = null!;
setUp(); setUp();
@ -117,8 +113,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
setUp(); setUp();
AddStep("change ruleset", () => Ruleset.Value = new OsuRuleset().RulesetInfo); AddStep("change ruleset", () => Ruleset.Value = new OsuRuleset().RulesetInfo);
AddStep($"select {allowedMod.ReadableName()} as allowed", () => songSelect.FreeMods.Value = new[] { (Mod)Activator.CreateInstance(allowedMod) }); AddStep($"select {allowedMod.ReadableName()} as allowed", () => songSelect.FreeMods.Value = new[] { (Mod)Activator.CreateInstance(allowedMod)! });
AddStep($"select {requiredMod.ReadableName()} as required", () => songSelect.Mods.Value = new[] { (Mod)Activator.CreateInstance(requiredMod) }); AddStep($"select {requiredMod.ReadableName()} as required", () => songSelect.Mods.Value = new[] { (Mod)Activator.CreateInstance(requiredMod)! });
AddAssert("freemods empty", () => songSelect.FreeMods.Value.Count == 0); AddAssert("freemods empty", () => songSelect.FreeMods.Value.Count == 0);
@ -141,7 +137,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("create song select", () => AddStep("create song select", () =>
{ {
SelectedRoom.Value.Playlist.Single().RulesetID = 2; SelectedRoom.Value!.Playlist.Single().RulesetID = 2;
songSelect = new TestMultiplayerMatchSongSelect(SelectedRoom.Value, SelectedRoom.Value.Playlist.Single()); songSelect = new TestMultiplayerMatchSongSelect(SelectedRoom.Value, SelectedRoom.Value.Playlist.Single());
songSelect.OnLoadComplete += _ => Ruleset.Value = new TaikoRuleset().RulesetInfo; songSelect.OnLoadComplete += _ => Ruleset.Value = new TaikoRuleset().RulesetInfo;
LoadScreen(songSelect); LoadScreen(songSelect);
@ -171,7 +167,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
public new BeatmapCarousel Carousel => base.Carousel; public new BeatmapCarousel Carousel => base.Carousel;
public TestMultiplayerMatchSongSelect(Room room, [CanBeNull] PlaylistItem itemToEdit = null) public TestMultiplayerMatchSongSelect(Room room, PlaylistItem? itemToEdit = null)
: base(room, itemToEdit) : base(room, itemToEdit)
{ {
} }

View File

@ -1,10 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
@ -42,10 +39,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
public partial class TestSceneMultiplayerMatchSubScreen : MultiplayerTestScene public partial class TestSceneMultiplayerMatchSubScreen : MultiplayerTestScene
{ {
private MultiplayerMatchSubScreen screen; private MultiplayerMatchSubScreen screen = null!;
private BeatmapManager beatmaps = null!;
private BeatmapManager beatmaps; private BeatmapSetInfo importedSet = null!;
private BeatmapSetInfo importedSet;
public TestSceneMultiplayerMatchSubScreen() public TestSceneMultiplayerMatchSubScreen()
: base(false) : base(false)
@ -70,7 +66,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("load match", () => AddStep("load match", () =>
{ {
SelectedRoom.Value = new Room { Name = "Test Room" }; SelectedRoom.Value = new Room { Name = "Test Room" };
LoadScreen(screen = new TestMultiplayerMatchSubScreen(SelectedRoom.Value)); LoadScreen(screen = new TestMultiplayerMatchSubScreen(SelectedRoom.Value!));
}); });
AddUntilStep("wait for load", () => screen.IsCurrentScreen()); AddUntilStep("wait for load", () => screen.IsCurrentScreen());
@ -81,7 +77,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
AddStep("add playlist item", () => AddStep("add playlist item", () =>
{ {
SelectedRoom.Value.Playlist = SelectedRoom.Value!.Playlist =
[ [
new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo) new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
{ {
@ -100,7 +96,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
AddStep("add playlist item", () => AddStep("add playlist item", () =>
{ {
SelectedRoom.Value.Playlist = SelectedRoom.Value!.Playlist =
[ [
new PlaylistItem(new TestBeatmap(new TaikoRuleset().RulesetInfo).BeatmapInfo) new PlaylistItem(new TestBeatmap(new TaikoRuleset().RulesetInfo).BeatmapInfo)
{ {
@ -125,7 +121,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("set playlist", () => AddStep("set playlist", () =>
{ {
SelectedRoom.Value.Playlist = SelectedRoom.Value!.Playlist =
[ [
new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo) new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
{ {
@ -142,7 +138,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
AddStep("set playlist", () => AddStep("set playlist", () =>
{ {
SelectedRoom.Value.Playlist = SelectedRoom.Value!.Playlist =
[ [
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First()).BeatmapInfo) new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First()).BeatmapInfo)
{ {
@ -173,7 +169,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
AddStep("add playlist item with allowed mod", () => AddStep("add playlist item with allowed mod", () =>
{ {
SelectedRoom.Value.Playlist = SelectedRoom.Value!.Playlist =
[ [
new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo) new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
{ {
@ -202,7 +198,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
AddStep("add playlist item with allowed mod", () => AddStep("add playlist item with allowed mod", () =>
{ {
SelectedRoom.Value.Playlist = SelectedRoom.Value!.Playlist =
[ [
new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo) new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
{ {
@ -226,7 +222,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
AddStep("add playlist item with no allowed mods", () => AddStep("add playlist item with no allowed mods", () =>
{ {
SelectedRoom.Value.Playlist = SelectedRoom.Value!.Playlist =
[ [
new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo) new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
{ {
@ -249,7 +245,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
AddStep("add two playlist items", () => AddStep("add two playlist items", () =>
{ {
SelectedRoom.Value.Playlist = SelectedRoom.Value!.Playlist =
[ [
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First()).BeatmapInfo) new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First()).BeatmapInfo)
{ {
@ -285,7 +281,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
AddStep("add playlist item", () => AddStep("add playlist item", () =>
{ {
SelectedRoom.Value.Playlist = SelectedRoom.Value!.Playlist =
[ [
new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo) new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
{ {
@ -320,8 +316,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
private partial class TestMultiplayerMatchSubScreen : MultiplayerMatchSubScreen private partial class TestMultiplayerMatchSubScreen : MultiplayerMatchSubScreen
{ {
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
[CanBeNull] private IDialogOverlay? dialogOverlay { get; set; }
private IDialogOverlay dialogOverlay { get; set; }
public TestMultiplayerMatchSubScreen(Room room) public TestMultiplayerMatchSubScreen(Room room)
: base(room) : base(room)

View File

@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("create list", () => AddStep("create list", () =>
{ {
Child = list = new MultiplayerPlaylist(SelectedRoom.Value) Child = list = new MultiplayerPlaylist(SelectedRoom.Value!)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,

View File

@ -44,7 +44,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("create playlist", () => AddStep("create playlist", () =>
{ {
Child = playlist = new MultiplayerQueueList(SelectedRoom.Value) Child = playlist = new MultiplayerQueueList(SelectedRoom.Value!)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using NUnit.Framework; using NUnit.Framework;
using osu.Game.Online.Rooms; using osu.Game.Online.Rooms;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
@ -16,7 +14,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Test] [Test]
public void TestDisplayResults() public void TestDisplayResults()
{ {
MultiplayerResultsScreen screen = null; MultiplayerResultsScreen screen = null!;
AddStep("show results screen", () => AddStep("show results screen", () =>
{ {

View File

@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("create button", () => AddStep("create button", () =>
{ {
PlaylistItem item = SelectedRoom.Value.Playlist.First(); PlaylistItem item = SelectedRoom.Value!.Playlist.First();
AvailabilityTracker.SelectedItem.Value = item; AvailabilityTracker.SelectedItem.Value = item;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -16,7 +14,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
public partial class TestSceneMultiplayerSpectatorPlayerGrid : OsuManualInputManagerTestScene public partial class TestSceneMultiplayerSpectatorPlayerGrid : OsuManualInputManagerTestScene
{ {
private PlayerGrid grid; private PlayerGrid grid = null!;
[SetUp] [SetUp]
public void Setup() => Schedule(() => public void Setup() => Schedule(() =>

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -32,7 +30,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
[TestCase(1048576, 1048576)] [TestCase(1048576, 1048576)]
public void TestDisplayTeamResults(int team1Score, int team2Score) public void TestDisplayTeamResults(int team1Score, int team2Score)
{ {
MultiplayerResultsScreen screen = null; MultiplayerResultsScreen screen = null!;
AddStep("show results screen", () => AddStep("show results screen", () =>
{ {

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -28,18 +26,18 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
public partial class TestScenePlaylistsRoomSettingsPlaylist : OnlinePlayTestScene public partial class TestScenePlaylistsRoomSettingsPlaylist : OnlinePlayTestScene
{ {
private TestPlaylist playlist; private TestPlaylist playlist = null!;
[Test] [Test]
public void TestItemRemovedOnDeletion() public void TestItemRemovedOnDeletion()
{ {
PlaylistItem selectedItem = null; PlaylistItem selectedItem = null!;
createPlaylist(); createPlaylist();
moveToItem(0); moveToItem(0);
AddStep("click", () => InputManager.Click(MouseButton.Left)); AddStep("click", () => InputManager.Click(MouseButton.Left));
AddStep("retrieve selection", () => selectedItem = playlist.SelectedItem.Value); AddStep("retrieve selection", () => selectedItem = playlist.SelectedItem.Value!);
moveToDeleteButton(0); moveToDeleteButton(0);
AddStep("click delete button", () => InputManager.Click(MouseButton.Left)); AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
@ -122,7 +120,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(0), offset); InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(0), offset);
}); });
private void createPlaylist(Action<TestPlaylist> setupPlaylist = null) private void createPlaylist(Action<TestPlaylist>? setupPlaylist = null)
{ {
AddStep("create playlist", () => AddStep("create playlist", () =>
{ {

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
@ -27,9 +25,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
public partial class TestScenePlaylistsSongSelect : OnlinePlayTestScene public partial class TestScenePlaylistsSongSelect : OnlinePlayTestScene
{ {
private BeatmapManager manager; private BeatmapManager manager = null!;
private TestPlaylistsSongSelect songSelect = null!;
private TestPlaylistsSongSelect songSelect;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(GameHost host, AudioManager audio) private void load(GameHost host, AudioManager audio)
@ -60,7 +57,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
SelectedMods.Value = Array.Empty<Mod>(); SelectedMods.Value = Array.Empty<Mod>();
}); });
AddStep("create song select", () => LoadScreen(songSelect = new TestPlaylistsSongSelect(SelectedRoom.Value))); AddStep("create song select", () => LoadScreen(songSelect = new TestPlaylistsSongSelect(SelectedRoom.Value!)));
AddUntilStep("wait for present", () => songSelect.IsCurrentScreen() && songSelect.BeatmapSetsLoaded); AddUntilStep("wait for present", () => songSelect.IsCurrentScreen() && songSelect.BeatmapSetsLoaded);
} }
@ -68,14 +65,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
public void TestItemAddedIfEmptyOnStart() public void TestItemAddedIfEmptyOnStart()
{ {
AddStep("finalise selection", () => songSelect.FinaliseSelection()); AddStep("finalise selection", () => songSelect.FinaliseSelection());
AddAssert("playlist has 1 item", () => SelectedRoom.Value.Playlist.Count == 1); AddAssert("playlist has 1 item", () => SelectedRoom.Value!.Playlist.Count == 1);
} }
[Test] [Test]
public void TestItemAddedWhenCreateNewItemClicked() public void TestItemAddedWhenCreateNewItemClicked()
{ {
AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem!()); AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem!());
AddAssert("playlist has 1 item", () => SelectedRoom.Value.Playlist.Count == 1); AddAssert("playlist has 1 item", () => SelectedRoom.Value!.Playlist.Count == 1);
} }
[Test] [Test]
@ -83,7 +80,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem!()); AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem!());
AddStep("finalise selection", () => songSelect.FinaliseSelection()); AddStep("finalise selection", () => songSelect.FinaliseSelection());
AddAssert("playlist has 1 item", () => SelectedRoom.Value.Playlist.Count == 1); AddAssert("playlist has 1 item", () => SelectedRoom.Value!.Playlist.Count == 1);
} }
[Test] [Test]
@ -91,7 +88,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem!()); AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem!());
AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem!()); AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem!());
AddAssert("playlist has 2 items", () => SelectedRoom.Value.Playlist.Count == 2); AddAssert("playlist has 2 items", () => SelectedRoom.Value!.Playlist.Count == 2);
} }
[Test] [Test]
@ -99,10 +96,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem!()); AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem!());
AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem!()); AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem!());
AddStep("rearrange", () => SelectedRoom.Value.Playlist = SelectedRoom.Value.Playlist.Skip(1).Append(SelectedRoom.Value.Playlist[0]).ToArray()); AddStep("rearrange", () => SelectedRoom.Value!.Playlist = SelectedRoom.Value!.Playlist.Skip(1).Append(SelectedRoom.Value!.Playlist[0]).ToArray());
AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem!()); AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem!());
AddAssert("new item has id 2", () => SelectedRoom.Value.Playlist.Last().ID == 2); AddAssert("new item has id 2", () => SelectedRoom.Value!.Playlist.Last().ID == 2);
} }
/// <summary> /// <summary>
@ -118,13 +115,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("item 1 has rate 1.5", () => AddAssert("item 1 has rate 1.5", () =>
{ {
var mod = (OsuModDoubleTime)SelectedRoom.Value.Playlist.First().RequiredMods[0].ToMod(new OsuRuleset()); var mod = (OsuModDoubleTime)SelectedRoom.Value!.Playlist.First().RequiredMods[0].ToMod(new OsuRuleset());
return Precision.AlmostEquals(1.5, mod.SpeedChange.Value); return Precision.AlmostEquals(1.5, mod.SpeedChange.Value);
}); });
AddAssert("item 2 has rate 2", () => AddAssert("item 2 has rate 2", () =>
{ {
var mod = (OsuModDoubleTime)SelectedRoom.Value.Playlist.Last().RequiredMods[0].ToMod(new OsuRuleset()); var mod = (OsuModDoubleTime)SelectedRoom.Value!.Playlist.Last().RequiredMods[0].ToMod(new OsuRuleset());
return Precision.AlmostEquals(2, mod.SpeedChange.Value); return Precision.AlmostEquals(2, mod.SpeedChange.Value);
}); });
} }
@ -135,7 +132,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Test] [Test]
public void TestGlobalModInstancesNotRetained() public void TestGlobalModInstancesNotRetained()
{ {
OsuModDoubleTime mod = null; OsuModDoubleTime mod = null!;
AddStep("set dt mod and store", () => AddStep("set dt mod and store", () =>
{ {
@ -150,7 +147,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("change stored mod rate", () => mod.SpeedChange.Value = 2); AddStep("change stored mod rate", () => mod.SpeedChange.Value = 2);
AddAssert("item has rate 1.5", () => AddAssert("item has rate 1.5", () =>
{ {
var m = (OsuModDoubleTime)SelectedRoom.Value.Playlist.First().RequiredMods[0].ToMod(new OsuRuleset()); var m = (OsuModDoubleTime)SelectedRoom.Value!.Playlist.First().RequiredMods[0].ToMod(new OsuRuleset());
return Precision.AlmostEquals(1.5, m.SpeedChange.Value); return Precision.AlmostEquals(1.5, m.SpeedChange.Value);
}); });
} }

View File

@ -33,7 +33,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
AddStep("set playlist", () => AddStep("set playlist", () =>
{ {
SelectedRoom.Value.Playlist = SelectedRoom.Value!.Playlist =
[ [
new PlaylistItem(new BeatmapInfo { StarRating = min }), new PlaylistItem(new BeatmapInfo { StarRating = min }),
new PlaylistItem(new BeatmapInfo { StarRating = max }), new PlaylistItem(new BeatmapInfo { StarRating = max }),

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -21,7 +19,7 @@ namespace osu.Game.Tests.Visual.Playlists
{ {
protected new TestRoomManager RoomManager => (TestRoomManager)base.RoomManager; protected new TestRoomManager RoomManager => (TestRoomManager)base.RoomManager;
private TestLoungeSubScreen loungeScreen; private TestLoungeSubScreen loungeScreen = null!;
public override void SetUpSteps() public override void SetUpSteps()
{ {
@ -97,7 +95,7 @@ namespace osu.Game.Tests.Visual.Playlists
private partial class TestLoungeSubScreen : PlaylistsLoungeSubScreen private partial class TestLoungeSubScreen : PlaylistsLoungeSubScreen
{ {
public new Bindable<Room> SelectedRoom => base.SelectedRoom; public new Bindable<Room?> SelectedRoom => base.SelectedRoom;
} }
} }
} }

View File

@ -32,7 +32,7 @@ namespace osu.Game.Tests.Visual.Playlists
{ {
SelectedRoom.Value = new Room(); SelectedRoom.Value = new Room();
Child = settings = new TestRoomSettings(SelectedRoom.Value) Child = settings = new TestRoomSettings(SelectedRoom.Value!)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
State = { Value = Visibility.Visible } State = { Value = Visibility.Visible }
@ -45,19 +45,19 @@ namespace osu.Game.Tests.Visual.Playlists
{ {
AddStep("clear name and beatmap", () => AddStep("clear name and beatmap", () =>
{ {
SelectedRoom.Value.Name = ""; SelectedRoom.Value!.Name = "";
SelectedRoom.Value.Playlist = []; SelectedRoom.Value!.Playlist = [];
}); });
AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value); AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value);
AddStep("set name", () => SelectedRoom.Value.Name = "Room name"); AddStep("set name", () => SelectedRoom.Value!.Name = "Room name");
AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value); AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value);
AddStep("set beatmap", () => SelectedRoom.Value.Playlist = [new PlaylistItem(CreateBeatmap(Ruleset.Value).BeatmapInfo)]); AddStep("set beatmap", () => SelectedRoom.Value!.Playlist = [new PlaylistItem(CreateBeatmap(Ruleset.Value).BeatmapInfo)]);
AddAssert("button enabled", () => settings.ApplyButton.Enabled.Value); AddAssert("button enabled", () => settings.ApplyButton.Enabled.Value);
AddStep("clear name", () => SelectedRoom.Value.Name = ""); AddStep("clear name", () => SelectedRoom.Value!.Name = "");
AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value); AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value);
} }
@ -73,7 +73,7 @@ namespace osu.Game.Tests.Visual.Playlists
{ {
settings.NameField.Current.Value = expected_name; settings.NameField.Current.Value = expected_name;
settings.DurationField.Current.Value = expectedDuration; settings.DurationField.Current.Value = expectedDuration;
SelectedRoom.Value.Playlist = [new PlaylistItem(CreateBeatmap(Ruleset.Value).BeatmapInfo)]; SelectedRoom.Value!.Playlist = [new PlaylistItem(CreateBeatmap(Ruleset.Value).BeatmapInfo)];
RoomManager.CreateRequested = r => RoomManager.CreateRequested = r =>
{ {
@ -98,8 +98,8 @@ namespace osu.Game.Tests.Visual.Playlists
{ {
var beatmap = CreateBeatmap(Ruleset.Value).BeatmapInfo; var beatmap = CreateBeatmap(Ruleset.Value).BeatmapInfo;
SelectedRoom.Value.Name = "Test Room"; SelectedRoom.Value!.Name = "Test Room";
SelectedRoom.Value.Playlist = [new PlaylistItem(beatmap)]; SelectedRoom.Value!.Playlist = [new PlaylistItem(beatmap)];
errorMessage = $"{not_found_prefix} {beatmap.OnlineID}"; errorMessage = $"{not_found_prefix} {beatmap.OnlineID}";
@ -107,13 +107,13 @@ namespace osu.Game.Tests.Visual.Playlists
}); });
AddAssert("error not displayed", () => !settings.ErrorText.IsPresent); AddAssert("error not displayed", () => !settings.ErrorText.IsPresent);
AddAssert("playlist item valid", () => SelectedRoom.Value.Playlist[0].Valid.Value); AddAssert("playlist item valid", () => SelectedRoom.Value!.Playlist[0].Valid.Value);
AddStep("create room", () => settings.ApplyButton.Action.Invoke()); AddStep("create room", () => settings.ApplyButton.Action.Invoke());
AddAssert("error displayed", () => settings.ErrorText.IsPresent); AddAssert("error displayed", () => settings.ErrorText.IsPresent);
AddAssert("error has custom text", () => settings.ErrorText.Text != errorMessage); AddAssert("error has custom text", () => settings.ErrorText.Text != errorMessage);
AddAssert("playlist item marked invalid", () => !SelectedRoom.Value.Playlist[0].Valid.Value); AddAssert("playlist item marked invalid", () => !SelectedRoom.Value!.Playlist[0].Valid.Value);
} }
[Test] [Test]
@ -125,8 +125,8 @@ namespace osu.Game.Tests.Visual.Playlists
AddStep("setup", () => AddStep("setup", () =>
{ {
SelectedRoom.Value.Name = "Test Room"; SelectedRoom.Value!.Name = "Test Room";
SelectedRoom.Value.Playlist = [new PlaylistItem(CreateBeatmap(Ruleset.Value).BeatmapInfo)]; SelectedRoom.Value!.Playlist = [new PlaylistItem(CreateBeatmap(Ruleset.Value).BeatmapInfo)];
RoomManager.CreateRequested = _ => failText; RoomManager.CreateRequested = _ => failText;
}); });

View File

@ -38,7 +38,7 @@ namespace osu.Game.Tests.Visual.Playlists
{ {
AddStep("create component", () => AddStep("create component", () =>
{ {
Child = new ParticipantsDisplay(SelectedRoom.Value, Direction.Horizontal) Child = new ParticipantsDisplay(SelectedRoom.Value!, Direction.Horizontal)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -52,7 +52,7 @@ namespace osu.Game.Tests.Visual.Playlists
{ {
AddStep("create component", () => AddStep("create component", () =>
{ {
Child = new ParticipantsDisplay(SelectedRoom.Value, Direction.Vertical) Child = new ParticipantsDisplay(SelectedRoom.Value!, Direction.Vertical)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,

View File

@ -1,13 +1,10 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using JetBrains.Annotations;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -34,14 +31,14 @@ namespace osu.Game.Tests.Visual.Playlists
private const int scores_per_result = 10; private const int scores_per_result = 10;
private const int real_user_position = 200; private const int real_user_position = 200;
private TestResultsScreen resultsScreen; private TestResultsScreen resultsScreen = null!;
private int lowestScoreId; // Score ID of the lowest score in the list. private int lowestScoreId; // Score ID of the lowest score in the list.
private int highestScoreId; // Score ID of the highest score in the list. private int highestScoreId; // Score ID of the highest score in the list.
private bool requestComplete; private bool requestComplete;
private int totalCount; private int totalCount;
private ScoreInfo userScore; private ScoreInfo userScore = null!;
[SetUpSteps] [SetUpSteps]
public override void SetUpSteps() public override void SetUpSteps()
@ -205,7 +202,7 @@ namespace osu.Game.Tests.Visual.Playlists
AddAssert("placeholder shown", () => this.ChildrenOfType<MessagePlaceholder>().Count(), () => Is.EqualTo(1)); AddAssert("placeholder shown", () => this.ChildrenOfType<MessagePlaceholder>().Count(), () => Is.EqualTo(1));
} }
private void createResults(Func<ScoreInfo> getScore = null) private void createResults(Func<ScoreInfo>? getScore = null)
{ {
AddStep("load results", () => AddStep("load results", () =>
{ {
@ -229,7 +226,7 @@ namespace osu.Game.Tests.Visual.Playlists
AddWaitStep("wait for display", 5); AddWaitStep("wait for display", 5);
} }
private void bindHandler(bool delayed = false, ScoreInfo userScore = null, bool failRequests = false, bool noScores = false) => ((DummyAPIAccess)API).HandleRequest = request => private void bindHandler(bool delayed = false, ScoreInfo? userScore = null, bool failRequests = false, bool noScores = false) => ((DummyAPIAccess)API).HandleRequest = request =>
{ {
// pre-check for requests we should be handling (as they are scheduled below). // pre-check for requests we should be handling (as they are scheduled below).
switch (request) switch (request)
@ -286,7 +283,7 @@ namespace osu.Game.Tests.Visual.Playlists
req.TriggerFailure(new WebException("Failed.")); req.TriggerFailure(new WebException("Failed."));
} }
private MultiplayerScore createUserResponse([NotNull] ScoreInfo userScore) private MultiplayerScore createUserResponse(ScoreInfo userScore)
{ {
var multiplayerUserScore = new MultiplayerScore var multiplayerUserScore = new MultiplayerScore
{ {
@ -420,7 +417,7 @@ namespace osu.Game.Tests.Visual.Playlists
public new LoadingSpinner RightSpinner => base.RightSpinner; public new LoadingSpinner RightSpinner => base.RightSpinner;
public new ScorePanelList ScorePanelList => base.ScorePanelList; public new ScorePanelList ScorePanelList => base.ScorePanelList;
public TestResultsScreen([CanBeNull] ScoreInfo score, int roomId, PlaylistItem playlistItem) public TestResultsScreen(ScoreInfo? score, int roomId, PlaylistItem playlistItem)
: base(score, roomId, playlistItem) : base(score, roomId, playlistItem)
{ {
AllowRetry = true; AllowRetry = true;

View File

@ -51,7 +51,7 @@ namespace osu.Game.Tests.Visual.Playlists
importBeatmap(); importBeatmap();
AddStep("load match", () => LoadScreen(match = new TestPlaylistsRoomSubScreen(SelectedRoom.Value))); AddStep("load match", () => LoadScreen(match = new TestPlaylistsRoomSubScreen(SelectedRoom.Value!)));
AddUntilStep("wait for load", () => match.IsCurrentScreen()); AddUntilStep("wait for load", () => match.IsCurrentScreen());
} }
@ -119,7 +119,7 @@ namespace osu.Game.Tests.Visual.Playlists
]; ];
}); });
AddAssert("first playlist item selected", () => match.SelectedItem.Value == SelectedRoom.Value.Playlist[0]); AddAssert("first playlist item selected", () => match.SelectedItem.Value == SelectedRoom.Value!.Playlist[0]);
} }
[Test] [Test]
@ -199,7 +199,7 @@ namespace osu.Game.Tests.Visual.Playlists
private void setupAndCreateRoom(Action<Room> room) private void setupAndCreateRoom(Action<Room> room)
{ {
AddStep("setup room", () => room(SelectedRoom.Value)); AddStep("setup room", () => room(SelectedRoom.Value!));
AddStep("click create button", () => AddStep("click create button", () =>
{ {
@ -218,7 +218,7 @@ namespace osu.Game.Tests.Visual.Playlists
private partial class TestPlaylistsRoomSubScreen : PlaylistsRoomSubScreen private partial class TestPlaylistsRoomSubScreen : PlaylistsRoomSubScreen
{ {
public new Bindable<PlaylistItem> SelectedItem => base.SelectedItem; public new Bindable<PlaylistItem?> SelectedItem => base.SelectedItem;
public new Bindable<WorkingBeatmap> Beatmap => base.Beatmap; public new Bindable<WorkingBeatmap> Beatmap => base.Beatmap;

View File

@ -0,0 +1,41 @@
// 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.
using System;
using NUnit.Framework;
using osu.Framework.Screens;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Rooms;
using osu.Game.Online.Rooms.RoomStatuses;
using osu.Game.Screens.OnlinePlay.Playlists;
using osu.Game.Tests.Visual.OnlinePlay;
namespace osu.Game.Tests.Visual.Playlists
{
public partial class TestScenePlaylistsRoomSubScreen : OnlinePlayTestScene
{
protected new TestRoomManager RoomManager => (TestRoomManager)base.RoomManager;
[Test]
public void TestStatusUpdateOnEnter()
{
Room room = null!;
PlaylistsRoomSubScreen roomScreen = null!;
AddStep("create room", () =>
{
RoomManager.AddRoom(room = new Room
{
Name = @"Test Room",
Host = new APIUser { Username = @"Host" },
Category = RoomCategory.Normal,
EndDate = DateTimeOffset.Now.AddMinutes(-1)
});
});
AddStep("push screen", () => LoadScreen(roomScreen = new PlaylistsRoomSubScreen(room)));
AddUntilStep("wait for screen load", () => roomScreen.IsCurrentScreen());
AddAssert("status is still ended", () => roomScreen.Room.Status, Is.TypeOf<RoomStatusEnded>);
}
}
}

View File

@ -73,10 +73,10 @@ namespace osu.Game.Tests.Visual.UserInterface
}); });
}); });
[TestCase(BeatmapAttribute.CircleSize, "Circle Size: 1.00")] [TestCase(BeatmapAttribute.CircleSize, "Circle Size: 1")]
[TestCase(BeatmapAttribute.HPDrain, "HP Drain: 2.00")] [TestCase(BeatmapAttribute.HPDrain, "HP Drain: 2")]
[TestCase(BeatmapAttribute.Accuracy, "Accuracy: 3.00")] [TestCase(BeatmapAttribute.Accuracy, "Accuracy: 3")]
[TestCase(BeatmapAttribute.ApproachRate, "Approach Rate: 4.00")] [TestCase(BeatmapAttribute.ApproachRate, "Approach Rate: 4")]
[TestCase(BeatmapAttribute.Title, "Title: _Title")] [TestCase(BeatmapAttribute.Title, "Title: _Title")]
[TestCase(BeatmapAttribute.Artist, "Artist: _Artist")] [TestCase(BeatmapAttribute.Artist, "Artist: _Artist")]
[TestCase(BeatmapAttribute.Creator, "Creator: _Creator")] [TestCase(BeatmapAttribute.Creator, "Creator: _Creator")]
@ -121,15 +121,15 @@ namespace osu.Game.Tests.Visual.UserInterface
Difficulty = Difficulty =
{ {
ApproachRate = 10, ApproachRate = 10,
CircleSize = 9 CircleSize = 9.5f
} }
} }
})); }));
test(BeatmapAttribute.BPM, new OsuModDoubleTime(), "BPM: 100.00", "BPM: 150.00"); test(BeatmapAttribute.BPM, new OsuModDoubleTime(), "BPM: 100", "BPM: 150");
test(BeatmapAttribute.Length, new OsuModDoubleTime(), "Length: 00:30", "Length: 00:20"); test(BeatmapAttribute.Length, new OsuModDoubleTime(), "Length: 00:30", "Length: 00:20");
test(BeatmapAttribute.ApproachRate, new OsuModDoubleTime(), "Approach Rate: 10.00", "Approach Rate: 11.00"); test(BeatmapAttribute.ApproachRate, new OsuModDoubleTime(), "Approach Rate: 10", "Approach Rate: 11");
test(BeatmapAttribute.CircleSize, new OsuModHardRock(), "Circle Size: 9.00", "Circle Size: 10.00"); test(BeatmapAttribute.CircleSize, new OsuModHardRock(), "Circle Size: 9.5", "Circle Size: 10");
void test(BeatmapAttribute attribute, Mod mod, string before, string after) void test(BeatmapAttribute attribute, Mod mod, string before, string after)
{ {

View File

@ -54,7 +54,7 @@ namespace osu.Game.Configuration
SetDefault(OsuSetting.ModSelectHotkeyStyle, ModSelectHotkeyStyle.Sequential); SetDefault(OsuSetting.ModSelectHotkeyStyle, ModSelectHotkeyStyle.Sequential);
SetDefault(OsuSetting.ModSelectTextSearchStartsActive, true); SetDefault(OsuSetting.ModSelectTextSearchStartsActive, true);
SetDefault(OsuSetting.ChatDisplayHeight, ChatOverlay.DEFAULT_HEIGHT, 0.2f, 1f); SetDefault(OsuSetting.ChatDisplayHeight, ChatOverlay.DEFAULT_HEIGHT, 0.2f, 1f, 0.01f);
SetDefault(OsuSetting.BeatmapListingCardSize, BeatmapCardSize.Normal); SetDefault(OsuSetting.BeatmapListingCardSize, BeatmapCardSize.Normal);
@ -132,7 +132,7 @@ namespace osu.Game.Configuration
SetDefault(OsuSetting.Prefer24HourTime, !CultureInfoHelper.SystemCulture.DateTimeFormat.ShortTimePattern.Contains(@"tt")); SetDefault(OsuSetting.Prefer24HourTime, !CultureInfoHelper.SystemCulture.DateTimeFormat.ShortTimePattern.Contains(@"tt"));
// Gameplay // Gameplay
SetDefault(OsuSetting.PositionalHitsoundsLevel, 0.2f, 0, 1); SetDefault(OsuSetting.PositionalHitsoundsLevel, 0.2f, 0, 1, 0.01f);
SetDefault(OsuSetting.DimLevel, 0.7, 0, 1, 0.01); SetDefault(OsuSetting.DimLevel, 0.7, 0, 1, 0.01);
SetDefault(OsuSetting.BlurLevel, 0, 0, 1, 0.01); SetDefault(OsuSetting.BlurLevel, 0, 0, 1, 0.01);
SetDefault(OsuSetting.LightenDuringBreaks, true); SetDefault(OsuSetting.LightenDuringBreaks, true);
@ -169,13 +169,13 @@ namespace osu.Game.Configuration
SetDefault(OsuSetting.Scaling, ScalingMode.Off); SetDefault(OsuSetting.Scaling, ScalingMode.Off);
SetDefault(OsuSetting.SafeAreaConsiderations, true); SetDefault(OsuSetting.SafeAreaConsiderations, true);
SetDefault(OsuSetting.ScalingBackgroundDim, 0.9f, 0.5f, 1f); SetDefault(OsuSetting.ScalingBackgroundDim, 0.9f, 0.5f, 1f, 0.01f);
SetDefault(OsuSetting.ScalingSizeX, 0.8f, 0.2f, 1f); SetDefault(OsuSetting.ScalingSizeX, 0.8f, 0.2f, 1f, 0.01f);
SetDefault(OsuSetting.ScalingSizeY, 0.8f, 0.2f, 1f); SetDefault(OsuSetting.ScalingSizeY, 0.8f, 0.2f, 1f, 0.01f);
SetDefault(OsuSetting.ScalingPositionX, 0.5f, 0f, 1f); SetDefault(OsuSetting.ScalingPositionX, 0.5f, 0f, 1f, 0.01f);
SetDefault(OsuSetting.ScalingPositionY, 0.5f, 0f, 1f); SetDefault(OsuSetting.ScalingPositionY, 0.5f, 0f, 1f, 0.01f);
SetDefault(OsuSetting.UIScale, 1f, 0.8f, 1.6f, 0.01f); SetDefault(OsuSetting.UIScale, 1f, 0.8f, 1.6f, 0.01f);

View File

@ -1,12 +1,10 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.IO.Network; using osu.Framework.IO.Network;
using osu.Game.Extensions; using osu.Game.Extensions;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.Rooms.RoomStatuses;
using osu.Game.Screens.OnlinePlay.Lounge.Components; using osu.Game.Screens.OnlinePlay.Lounge.Components;
namespace osu.Game.Online.Rooms namespace osu.Game.Online.Rooms
@ -35,25 +33,6 @@ namespace osu.Game.Online.Rooms
return req; return req;
} }
protected override void PostProcess()
{
base.PostProcess();
if (Response != null)
{
// API doesn't populate status so let's do it here.
foreach (var room in Response)
{
if (room.EndDate != null && DateTimeOffset.Now >= room.EndDate)
room.Status = new RoomStatusEnded();
else if (room.HasPassword)
room.Status = new RoomStatusOpenPrivate();
else
room.Status = new RoomStatusOpen();
}
}
}
protected override string Target => "rooms"; protected override string Target => "rooms";
} }
} }

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Game.IO.Serialization.Converters; using osu.Game.IO.Serialization.Converters;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
@ -264,6 +265,18 @@ namespace osu.Game.Online.Rooms
set => SetField(ref availability, value); set => SetField(ref availability, value);
} }
[OnDeserialized]
private void onDeserialised(StreamingContext context)
{
// API doesn't populate status so let's do it here.
if (EndDate != null && DateTimeOffset.Now >= EndDate)
Status = new RoomStatusEnded();
else if (HasPassword)
Status = new RoomStatusOpenPrivate();
else
Status = new RoomStatusOpen();
}
[JsonProperty("id")] [JsonProperty("id")]
private long? roomId; private long? roomId;

View File

@ -163,7 +163,7 @@ namespace osu.Game.Rulesets.Edit
return (lastBefore, firstAfter); return (lastBefore, firstAfter);
} }
protected abstract double ReadCurrentDistanceSnap(HitObject before, HitObject after); public abstract double ReadCurrentDistanceSnap(HitObject before, HitObject after);
protected override void Update() protected override void Update()
{ {

View File

@ -18,7 +18,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
public IBindable<bool> InitialRoomsReceived => initialRoomsReceived; public IBindable<bool> InitialRoomsReceived => initialRoomsReceived;
private readonly Bindable<bool> initialRoomsReceived = new Bindable<bool>(); private readonly Bindable<bool> initialRoomsReceived = new Bindable<bool>();
public readonly Bindable<FilterCriteria> Filter = new Bindable<FilterCriteria>(); public readonly Bindable<FilterCriteria?> Filter = new Bindable<FilterCriteria?>();
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Linq; using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -26,22 +24,22 @@ namespace osu.Game.Screens.OnlinePlay
/// The currently-selected item. Selection is visually represented with a border. /// The currently-selected item. Selection is visually represented with a border.
/// May be updated by clicking playlist items if <see cref="AllowSelection"/> is <c>true</c>. /// May be updated by clicking playlist items if <see cref="AllowSelection"/> is <c>true</c>.
/// </summary> /// </summary>
public readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>(); public readonly Bindable<PlaylistItem?> SelectedItem = new Bindable<PlaylistItem?>();
/// <summary> /// <summary>
/// Invoked when an item is requested to be deleted. /// Invoked when an item is requested to be deleted.
/// </summary> /// </summary>
public Action<PlaylistItem> RequestDeletion; public Action<PlaylistItem>? RequestDeletion;
/// <summary> /// <summary>
/// Invoked when an item requests its results to be shown. /// Invoked when an item requests its results to be shown.
/// </summary> /// </summary>
public Action<PlaylistItem> RequestResults; public Action<PlaylistItem>? RequestResults;
/// <summary> /// <summary>
/// Invoked when an item requests to be edited. /// Invoked when an item requests to be edited.
/// </summary> /// </summary>
public Action<PlaylistItem> RequestEdit; public Action<PlaylistItem>? RequestEdit;
private bool allowReordering; private bool allowReordering;
@ -235,7 +233,7 @@ namespace osu.Game.Screens.OnlinePlay
{ {
var visibleItems = ListContainer.AsEnumerable().Where(r => r.IsPresent); var visibleItems = ListContainer.AsEnumerable().Where(r => r.IsPresent);
PlaylistItem item; PlaylistItem? item;
if (SelectedItem.Value == null) if (SelectedItem.Value == null)
item = visibleItems.FirstOrDefault()?.Model; item = visibleItems.FirstOrDefault()?.Model;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -54,23 +52,23 @@ namespace osu.Game.Screens.OnlinePlay
/// <summary> /// <summary>
/// Invoked when this item requests to be deleted. /// Invoked when this item requests to be deleted.
/// </summary> /// </summary>
public Action<PlaylistItem> RequestDeletion; public Action<PlaylistItem>? RequestDeletion;
/// <summary> /// <summary>
/// Invoked when this item requests its results to be shown. /// Invoked when this item requests its results to be shown.
/// </summary> /// </summary>
public Action<PlaylistItem> RequestResults; public Action<PlaylistItem>? RequestResults;
/// <summary> /// <summary>
/// Invoked when this item requests to be edited. /// Invoked when this item requests to be edited.
/// </summary> /// </summary>
public Action<PlaylistItem> RequestEdit; public Action<PlaylistItem>? RequestEdit;
/// <summary> /// <summary>
/// The currently-selected item, used to show a border around this item. /// The currently-selected item, used to show a border around this item.
/// May be updated by this item if <see cref="AllowSelection"/> is <c>true</c>. /// May be updated by this item if <see cref="AllowSelection"/> is <c>true</c>.
/// </summary> /// </summary>
public readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>(); public readonly Bindable<PlaylistItem?> SelectedItem = new Bindable<PlaylistItem?>();
public readonly PlaylistItem Item; public readonly PlaylistItem Item;
@ -79,48 +77,48 @@ namespace osu.Game.Screens.OnlinePlay
private readonly DelayedLoadWrapper onScreenLoader = new DelayedLoadWrapper(Empty) { RelativeSizeAxes = Axes.Both }; private readonly DelayedLoadWrapper onScreenLoader = new DelayedLoadWrapper(Empty) { RelativeSizeAxes = Axes.Both };
private readonly IBindable<bool> valid = new Bindable<bool>(); private readonly IBindable<bool> valid = new Bindable<bool>();
private IBeatmapInfo beatmap; private IBeatmapInfo? beatmap;
private IRulesetInfo ruleset; private IRulesetInfo? ruleset;
private Mod[] requiredMods = Array.Empty<Mod>(); private Mod[] requiredMods = Array.Empty<Mod>();
private Container borderContainer; private Container? borderContainer;
private FillFlowContainer difficultyIconContainer; private FillFlowContainer? difficultyIconContainer;
private LinkFlowContainer beatmapText; private LinkFlowContainer? beatmapText;
private LinkFlowContainer authorText; private LinkFlowContainer? authorText;
private ExplicitContentBeatmapBadge explicitContent; private ExplicitContentBeatmapBadge? explicitContent;
private ModDisplay modDisplay; private ModDisplay? modDisplay;
private FillFlowContainer buttonsFlow; private FillFlowContainer? buttonsFlow;
private UpdateableAvatar ownerAvatar; private UpdateableAvatar? ownerAvatar;
private Drawable showResultsButton; private Drawable? showResultsButton;
private Drawable editButton; private Drawable? editButton;
private Drawable removeButton; private Drawable? removeButton;
private PanelBackground panelBackground; private PanelBackground? panelBackground;
private FillFlowContainer mainFillFlow; private FillFlowContainer? mainFillFlow;
private BeatmapCardThumbnail thumbnail; private BeatmapCardThumbnail? thumbnail;
[Resolved] [Resolved]
private RealmAccess realm { get; set; } private RealmAccess realm { get; set; } = null!;
[Resolved] [Resolved]
private RulesetStore rulesets { get; set; } private RulesetStore rulesets { get; set; } = null!;
[Resolved] [Resolved]
private BeatmapManager beatmaps { get; set; } private BeatmapManager beatmaps { get; set; } = null!;
[Resolved] [Resolved]
private OsuColour colours { get; set; } private OsuColour colours { get; set; } = null!;
[Resolved] [Resolved]
private UserLookupCache userLookupCache { get; set; } private UserLookupCache userLookupCache { get; set; } = null!;
[Resolved] [Resolved]
private BeatmapLookupCache beatmapLookupCache { get; set; } private BeatmapLookupCache beatmapLookupCache { get; set; } = null!;
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
private BeatmapSetOverlay beatmapOverlay { get; set; } private BeatmapSetOverlay? beatmapOverlay { get; set; }
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
private ManageCollectionsDialog manageCollectionsDialog { get; set; } private ManageCollectionsDialog? manageCollectionsDialog { get; set; }
public DrawableRoomPlaylistItem(PlaylistItem item) public DrawableRoomPlaylistItem(PlaylistItem item)
: base(item) : base(item)
@ -136,6 +134,7 @@ namespace osu.Game.Screens.OnlinePlay
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
if (borderContainer != null)
borderContainer.BorderColour = colours.Yellow; borderContainer.BorderColour = colours.Yellow;
ruleset = rulesets.GetRuleset(Item.RulesetID); ruleset = rulesets.GetRuleset(Item.RulesetID);
@ -163,6 +162,7 @@ namespace osu.Game.Screens.OnlinePlay
return; return;
} }
if (borderContainer != null)
borderContainer.BorderThickness = IsSelectedItem ? border_thickness : 0; borderContainer.BorderThickness = IsSelectedItem ? border_thickness : 0;
}, true); }, true);
@ -177,7 +177,11 @@ namespace osu.Game.Screens.OnlinePlay
if (showItemOwner) if (showItemOwner)
{ {
var foundUser = await userLookupCache.GetUserAsync(Item.OwnerID).ConfigureAwait(false); var foundUser = await userLookupCache.GetUserAsync(Item.OwnerID).ConfigureAwait(false);
Schedule(() => ownerAvatar.User = foundUser); Schedule(() =>
{
if (ownerAvatar != null)
ownerAvatar.User = foundUser;
});
} }
beatmap = await beatmapLookupCache.GetBeatmapAsync(Item.Beatmap.OnlineID).ConfigureAwait(false); beatmap = await beatmapLookupCache.GetBeatmapAsync(Item.Beatmap.OnlineID).ConfigureAwait(false);
@ -277,13 +281,18 @@ namespace osu.Game.Screens.OnlinePlay
} }
private void refresh() private void refresh()
{
if (borderContainer != null)
{ {
if (!valid.Value) if (!valid.Value)
{ {
borderContainer.BorderThickness = border_thickness; borderContainer.BorderThickness = border_thickness;
borderContainer.BorderColour = colours.Red; borderContainer.BorderColour = colours.Red;
} }
}
if (difficultyIconContainer != null)
{
if (beatmap != null) if (beatmap != null)
{ {
difficultyIconContainer.Children = new Drawable[] difficultyIconContainer.Children = new Drawable[]
@ -309,9 +318,13 @@ namespace osu.Game.Screens.OnlinePlay
} }
else else
difficultyIconContainer.Clear(); difficultyIconContainer.Clear();
}
if (panelBackground != null)
panelBackground.Beatmap.Value = beatmap; panelBackground.Beatmap.Value = beatmap;
if (beatmapText != null)
{
beatmapText.Clear(); beatmapText.Clear();
if (beatmap != null) if (beatmap != null)
@ -325,7 +338,10 @@ namespace osu.Game.Screens.OnlinePlay
text.Truncate = true; text.Truncate = true;
}); });
} }
}
if (authorText != null)
{
authorText.Clear(); authorText.Clear();
if (!string.IsNullOrEmpty(beatmap?.Metadata.Author.Username)) if (!string.IsNullOrEmpty(beatmap?.Metadata.Author.Username))
@ -333,14 +349,22 @@ namespace osu.Game.Screens.OnlinePlay
authorText.AddText("mapped by "); authorText.AddText("mapped by ");
authorText.AddUserLink(beatmap.Metadata.Author); authorText.AddUserLink(beatmap.Metadata.Author);
} }
}
if (explicitContent != null)
{
bool hasExplicitContent = (beatmap?.BeatmapSet as IBeatmapSetOnlineInfo)?.HasExplicitContent == true; bool hasExplicitContent = (beatmap?.BeatmapSet as IBeatmapSetOnlineInfo)?.HasExplicitContent == true;
explicitContent.Alpha = hasExplicitContent ? 1 : 0; explicitContent.Alpha = hasExplicitContent ? 1 : 0;
}
if (modDisplay != null)
modDisplay.Current.Value = requiredMods.ToArray(); modDisplay.Current.Value = requiredMods.ToArray();
if (buttonsFlow != null)
{
buttonsFlow.Clear(); buttonsFlow.Clear();
buttonsFlow.ChildrenEnumerable = createButtons(); buttonsFlow.ChildrenEnumerable = createButtons();
}
difficultyIconContainer.FadeInFromZero(500, Easing.OutQuint); difficultyIconContainer.FadeInFromZero(500, Easing.OutQuint);
mainFillFlow.FadeInFromZero(500, Easing.OutQuint); mainFillFlow.FadeInFromZero(500, Easing.OutQuint);
@ -601,7 +625,7 @@ namespace osu.Game.Screens.OnlinePlay
private readonly IBeatmapInfo beatmap; private readonly IBeatmapInfo beatmap;
[Resolved] [Resolved]
private BeatmapManager beatmapManager { get; set; } private BeatmapManager beatmapManager { get; set; } = null!;
// required for download tracking, as this button hides itself. can probably be removed with a bit of consideration. // required for download tracking, as this button hides itself. can probably be removed with a bit of consideration.
public override bool IsPresent => true; public override bool IsPresent => true;
@ -656,7 +680,7 @@ namespace osu.Game.Screens.OnlinePlay
// For now, this is the same implementation as in PanelBackground, but supports a beatmap info rather than a working beatmap // For now, this is the same implementation as in PanelBackground, but supports a beatmap info rather than a working beatmap
private partial class PanelBackground : Container // todo: should be a buffered container (https://github.com/ppy/osu-framework/issues/3222) private partial class PanelBackground : Container // todo: should be a buffered container (https://github.com/ppy/osu-framework/issues/3222)
{ {
public readonly Bindable<IBeatmapInfo> Beatmap = new Bindable<IBeatmapInfo>(); public readonly Bindable<IBeatmapInfo?> Beatmap = new Bindable<IBeatmapInfo?>();
public PanelBackground() public PanelBackground()
{ {

View File

@ -1,18 +1,16 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Game.Rulesets; using osu.Game.Rulesets;
namespace osu.Game.Screens.OnlinePlay.Lounge.Components namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{ {
public class FilterCriteria public class FilterCriteria
{ {
public string SearchString; public string SearchString = string.Empty;
public RoomStatusFilter Status; public RoomStatusFilter Status;
public string Category; public string Category = string.Empty;
public RulesetInfo Ruleset; public RulesetInfo? Ruleset;
public RoomPermissionsFilter Permissions; public RoomPermissionsFilter Permissions;
} }
} }

View File

@ -1,13 +1,10 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions; using osu.Framework.Extensions;
@ -54,42 +51,42 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
AutoSizeAxes = Axes.Both AutoSizeAxes = Axes.Both
}; };
protected ListingPollingComponent ListingPollingComponent { get; private set; } protected ListingPollingComponent ListingPollingComponent { get; private set; } = null!;
protected readonly Bindable<Room> SelectedRoom = new Bindable<Room>(); protected readonly Bindable<Room?> SelectedRoom = new Bindable<Room?>();
[Resolved] [Resolved]
private MusicController music { get; set; } private MusicController music { get; set; } = null!;
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
private OngoingOperationTracker ongoingOperationTracker { get; set; } private OngoingOperationTracker? ongoingOperationTracker { get; set; }
[Resolved] [Resolved]
private IBindable<RulesetInfo> ruleset { get; set; } private IBindable<RulesetInfo> ruleset { get; set; } = null!;
[Resolved] [Resolved]
private IAPIProvider api { get; set; } private IAPIProvider api { get; set; } = null!;
[CanBeNull] [Resolved(CanBeNull = true)]
private IDisposable joiningRoomOperation { get; set; } private IdleTracker? idleTracker { get; set; }
[CanBeNull]
private LeasedBindable<Room> selectionLease;
[Resolved] [Resolved]
protected OsuConfigManager Config { get; private set; } protected OsuConfigManager Config { get; private set; } = null!;
private readonly Bindable<FilterCriteria> filter = new Bindable<FilterCriteria>(new FilterCriteria()); private IDisposable? joiningRoomOperation { get; set; }
private LeasedBindable<Room?>? selectionLease;
private readonly Bindable<FilterCriteria?> filter = new Bindable<FilterCriteria?>();
private readonly IBindable<bool> operationInProgress = new Bindable<bool>(); private readonly IBindable<bool> operationInProgress = new Bindable<bool>();
private readonly IBindable<bool> isIdle = new BindableBool(); private readonly IBindable<bool> isIdle = new BindableBool();
private PopoverContainer popoverContainer; private PopoverContainer popoverContainer = null!;
private LoadingLayer loadingLayer; private LoadingLayer loadingLayer = null!;
private RoomsContainer roomsContainer; private RoomsContainer roomsContainer = null!;
private SearchTextBox searchTextBox; private SearchTextBox searchTextBox = null!;
private Dropdown<RoomStatusFilter> statusDropdown; private Dropdown<RoomStatusFilter> statusDropdown = null!;
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load([CanBeNull] IdleTracker idleTracker) private void load()
{ {
const float controls_area_height = 25f; const float controls_area_height = 25f;
@ -208,7 +205,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
public void UpdateFilter() => Scheduler.AddOnce(updateFilter); public void UpdateFilter() => Scheduler.AddOnce(updateFilter);
private ScheduledDelegate scheduledFilterUpdate; private ScheduledDelegate? scheduledFilterUpdate;
private void updateFilterDebounced() private void updateFilterDebounced()
{ {
@ -262,7 +259,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
if (SelectedRoom.Value?.RoomID == null) if (SelectedRoom.Value?.RoomID == null)
SelectedRoom.Value = new Room(); SelectedRoom.Value = new Room();
music?.EnsurePlayingSomething(); music.EnsurePlayingSomething();
onReturning(); onReturning();
} }
@ -299,7 +296,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
popoverContainer.HidePopover(); popoverContainer.HidePopover();
} }
public virtual void Join(Room room, string password, Action<Room> onSuccess = null, Action<string> onFailure = null) => Schedule(() => public virtual void Join(Room room, string? password, Action<Room>? onSuccess = null, Action<string>? onFailure = null) => Schedule(() =>
{ {
if (joiningRoomOperation != null) if (joiningRoomOperation != null)
return; return;
@ -364,7 +361,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
/// Push a room as a new subscreen. /// Push a room as a new subscreen.
/// </summary> /// </summary>
/// <param name="room">An optional template to use when creating the room.</param> /// <param name="room">An optional template to use when creating the room.</param>
public void Open(Room room = null) => Schedule(() => public void Open(Room? room = null) => Schedule(() =>
{ {
// Handles the case where a room is clicked 3 times in quick succession // Handles the case where a room is clicked 3 times in quick succession
if (!this.IsCurrentScreen()) if (!this.IsCurrentScreen())

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
@ -17,7 +15,7 @@ namespace osu.Game.Screens.OnlinePlay.Match.Components
{ {
private readonly APIUserScoreAggregate score; private readonly APIUserScoreAggregate score;
public override ScoreInfo TooltipContent => null; // match aggregate scores can't show statistics that the custom tooltip displays. public override ScoreInfo? TooltipContent => null; // match aggregate scores can't show statistics that the custom tooltip displays.
public MatchLeaderboardScore(APIUserScoreAggregate score, int? rank, bool isOnlineScope = true) public MatchLeaderboardScore(APIUserScoreAggregate score, int? rank, bool isOnlineScope = true)
: base(score.CreateScoreInfo(), rank, isOnlineScope) : base(score.CreateScoreInfo(), rank, isOnlineScope)

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
@ -26,7 +24,7 @@ namespace osu.Game.Screens.OnlinePlay.Match.Components
protected override TabItem<MatchType> CreateTabItem(MatchType value) => new GameTypePickerItem(value); protected override TabItem<MatchType> CreateTabItem(MatchType value) => new GameTypePickerItem(value);
protected override Dropdown<MatchType> CreateDropdown() => null; protected override Dropdown<MatchType>? CreateDropdown() => null;
public MatchTypePicker() public MatchTypePicker()
{ {
@ -41,7 +39,8 @@ namespace osu.Game.Screens.OnlinePlay.Match.Components
{ {
private const float transition_duration = 200; private const float transition_duration = 200;
private readonly CircularContainer hover, selection; private readonly CircularContainer hover;
private readonly CircularContainer selection;
public GameTypePickerItem(MatchType value) public GameTypePickerItem(MatchType value)
: base(value) : base(value)
@ -84,7 +83,7 @@ namespace osu.Game.Screens.OnlinePlay.Match.Components
}; };
} }
private Sample selectSample; private Sample selectSample = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours, AudioManager audio) private void load(OsuColour colours, AudioManager audio)

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
@ -22,7 +20,7 @@ namespace osu.Game.Screens.OnlinePlay.Match.Components
public partial class RoomAvailabilityPicker : DisableableTabControl<RoomAvailability> public partial class RoomAvailabilityPicker : DisableableTabControl<RoomAvailability>
{ {
protected override TabItem<RoomAvailability> CreateTabItem(RoomAvailability value) => new RoomAvailabilityPickerItem(value); protected override TabItem<RoomAvailability> CreateTabItem(RoomAvailability value) => new RoomAvailabilityPickerItem(value);
protected override Dropdown<RoomAvailability> CreateDropdown() => null; protected override Dropdown<RoomAvailability>? CreateDropdown() => null;
public RoomAvailabilityPicker() public RoomAvailabilityPicker()
{ {

View File

@ -16,7 +16,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
{ {
public partial class RoomModSelectOverlay : UserModSelectOverlay public partial class RoomModSelectOverlay : UserModSelectOverlay
{ {
public Bindable<PlaylistItem> SelectedItem { get; } = new Bindable<PlaylistItem>(); public Bindable<PlaylistItem?> SelectedItem { get; } = new Bindable<PlaylistItem?>();
[Resolved] [Resolved]
private RulesetStore rulesets { get; set; } = null!; private RulesetStore rulesets { get; set; } = null!;

View File

@ -1,14 +1,11 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
@ -37,7 +34,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
[Cached(typeof(IPreviewTrackOwner))] [Cached(typeof(IPreviewTrackOwner))]
public abstract partial class RoomSubScreen : OnlinePlaySubScreen, IPreviewTrackOwner public abstract partial class RoomSubScreen : OnlinePlaySubScreen, IPreviewTrackOwner
{ {
public readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>(); public readonly Bindable<PlaylistItem?> SelectedItem = new Bindable<PlaylistItem?>();
public override bool? ApplyModTrackAdjustments => true; public override bool? ApplyModTrackAdjustments => true;
@ -52,9 +49,9 @@ namespace osu.Game.Screens.OnlinePlay.Match
/// A container that provides controls for selection of user mods. /// A container that provides controls for selection of user mods.
/// This will be shown/hidden automatically when applicable. /// This will be shown/hidden automatically when applicable.
/// </summary> /// </summary>
protected Drawable UserModsSection; protected Drawable? UserModsSection;
private Sample sampleStart; private Sample? sampleStart;
/// <summary> /// <summary>
/// Any mods applied by/to the local user. /// Any mods applied by/to the local user.
@ -62,28 +59,28 @@ namespace osu.Game.Screens.OnlinePlay.Match
protected readonly Bindable<IReadOnlyList<Mod>> UserMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>()); protected readonly Bindable<IReadOnlyList<Mod>> UserMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
private IOverlayManager overlayManager { get; set; } private IOverlayManager? overlayManager { get; set; }
[Resolved] [Resolved]
private MusicController music { get; set; } private MusicController music { get; set; } = null!;
[Resolved] [Resolved]
private BeatmapManager beatmapManager { get; set; } private BeatmapManager beatmapManager { get; set; } = null!;
[Resolved] [Resolved]
protected RulesetStore Rulesets { get; private set; } protected RulesetStore Rulesets { get; private set; } = null!;
[Resolved] [Resolved]
private IAPIProvider api { get; set; } = null!; private IAPIProvider api { get; set; } = null!;
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
protected OnlinePlayScreen ParentScreen { get; private set; } protected OnlinePlayScreen? ParentScreen { get; private set; }
[Resolved] [Resolved]
private PreviewTrackManager previewTrackManager { get; set; } = null!; private PreviewTrackManager previewTrackManager { get; set; } = null!;
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
private IDialogOverlay dialogOverlay { get; set; } private IDialogOverlay? dialogOverlay { get; set; }
[Cached] [Cached]
private readonly OnlinePlayBeatmapAvailabilityTracker beatmapAvailabilityTracker = new OnlinePlayBeatmapAvailabilityTracker(); private readonly OnlinePlayBeatmapAvailabilityTracker beatmapAvailabilityTracker = new OnlinePlayBeatmapAvailabilityTracker();
@ -93,13 +90,11 @@ namespace osu.Game.Screens.OnlinePlay.Match
public readonly Room Room; public readonly Room Room;
private readonly bool allowEdit; private readonly bool allowEdit;
internal ModSelectOverlay UserModsSelectOverlay { get; private set; } internal ModSelectOverlay UserModsSelectOverlay { get; private set; } = null!;
[CanBeNull] private IDisposable? userModsSelectOverlayRegistration;
private IDisposable userModsSelectOverlayRegistration; private RoomSettingsOverlay settingsOverlay = null!;
private Drawable mainContent = null!;
private RoomSettingsOverlay settingsOverlay;
private Drawable mainContent;
/// <summary> /// <summary>
/// Creates a new <see cref="RoomSubScreen"/>. /// Creates a new <see cref="RoomSubScreen"/>.
@ -265,7 +260,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
updateSetupState(); updateSetupState();
} }
private void onRoomPropertyChanged(object sender, PropertyChangedEventArgs e) private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e)
{ {
if (e.PropertyName == nameof(Room.RoomID)) if (e.PropertyName == nameof(Room.RoomID))
updateSetupState(); updateSetupState();
@ -388,6 +383,9 @@ namespace osu.Game.Screens.OnlinePlay.Match
protected void StartPlay() protected void StartPlay()
{ {
if (SelectedItem.Value == null)
return;
// User may be at song select or otherwise when the host starts gameplay. // User may be at song select or otherwise when the host starts gameplay.
// Ensure that they first return to this screen, else global bindables (beatmap etc.) may be in a bad state. // Ensure that they first return to this screen, else global bindables (beatmap etc.) may be in a bad state.
if (!this.IsCurrentScreen()) if (!this.IsCurrentScreen())
@ -401,29 +399,28 @@ namespace osu.Game.Screens.OnlinePlay.Match
sampleStart?.Play(); sampleStart?.Play();
// fallback is to allow this class to operate when there is no parent OnlineScreen (testing purposes). // fallback is to allow this class to operate when there is no parent OnlineScreen (testing purposes).
var targetScreen = (Screen)ParentScreen ?? this; var targetScreen = (Screen?)ParentScreen ?? this;
targetScreen.Push(CreateGameplayScreen()); targetScreen.Push(CreateGameplayScreen(SelectedItem.Value));
} }
/// <summary> /// <summary>
/// Creates the gameplay screen to be entered. /// Creates the gameplay screen to be entered.
/// </summary> /// </summary>
/// <param name="selectedItem">The playlist item about to be played.</param>
/// <returns>The screen to enter.</returns> /// <returns>The screen to enter.</returns>
protected abstract Screen CreateGameplayScreen(); protected abstract Screen CreateGameplayScreen(PlaylistItem selectedItem);
private void selectedItemChanged() private void selectedItemChanged()
{ {
updateWorkingBeatmap(); updateWorkingBeatmap();
var selected = SelectedItem.Value; if (SelectedItem.Value is not PlaylistItem selected)
if (selected == null)
return; return;
var rulesetInstance = Rulesets.GetRuleset(SelectedItem.Value.RulesetID)?.CreateInstance(); var rulesetInstance = Rulesets.GetRuleset(selected.RulesetID)?.CreateInstance();
Debug.Assert(rulesetInstance != null); Debug.Assert(rulesetInstance != null);
var allowedMods = SelectedItem.Value.AllowedMods.Select(m => m.ToMod(rulesetInstance)); var allowedMods = selected.AllowedMods.Select(m => m.ToMod(rulesetInstance));
// Remove any user mods that are no longer allowed. // Remove any user mods that are no longer allowed.
UserMods.Value = UserMods.Value.Where(m => allowedMods.Any(a => m.GetType() == a.GetType())).ToList(); UserMods.Value = UserMods.Value.Where(m => allowedMods.Any(a => m.GetType() == a.GetType())).ToList();
@ -494,7 +491,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
cancelTrackLooping(); cancelTrackLooping();
} }
private void applyLoopingToTrack(ValueChangedEvent<WorkingBeatmap> _ = null) private void applyLoopingToTrack(ValueChangedEvent<WorkingBeatmap>? _ = null)
{ {
if (!this.IsCurrentScreen()) if (!this.IsCurrentScreen())
return; return;
@ -503,8 +500,8 @@ namespace osu.Game.Screens.OnlinePlay.Match
if (track != null) if (track != null)
{ {
Beatmap.Value.PrepareTrackForPreview(true); Beatmap.Value!.PrepareTrackForPreview(true);
music?.EnsurePlayingSomething(); music.EnsurePlayingSomething();
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
@ -12,14 +10,14 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
{ {
public partial class CreateMultiplayerMatchButton : CreateRoomButton public partial class CreateMultiplayerMatchButton : CreateRoomButton
{ {
private IBindable<bool> isConnected; private IBindable<bool> isConnected = null!;
private IBindable<bool> operationInProgress; private IBindable<bool> operationInProgress = null!;
[Resolved] [Resolved]
private MultiplayerClient multiplayerClient { get; set; } private MultiplayerClient multiplayerClient { get; set; } = null!;
[Resolved] [Resolved]
private OngoingOperationTracker ongoingOperationTracker { get; set; } private OngoingOperationTracker ongoingOperationTracker { get; set; } = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()

View File

@ -1,9 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -20,8 +17,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
public partial class GameplayChatDisplay : MatchChatDisplay, IKeyBindingHandler<GlobalAction> public partial class GameplayChatDisplay : MatchChatDisplay, IKeyBindingHandler<GlobalAction>
{ {
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
[CanBeNull] private ILocalUserPlayInfo? localUserInfo { get; set; }
private ILocalUserPlayInfo localUserInfo { get; set; }
private readonly IBindable<LocalUserPlayingState> localUserPlaying = new Bindable<LocalUserPlayingState>(); private readonly IBindable<LocalUserPlayingState> localUserPlaying = new Bindable<LocalUserPlayingState>();

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Linq; using System.Linq;
using Humanizer; using Humanizer;
@ -33,15 +31,14 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
TimeSpan.FromMinutes(2) TimeSpan.FromMinutes(2)
}; };
public new Action<TimeSpan> Action; public new required Action<TimeSpan> Action;
public required Action CancelAction;
public Action CancelAction;
[Resolved] [Resolved]
private MultiplayerClient multiplayerClient { get; set; } private MultiplayerClient multiplayerClient { get; set; } = null!;
[Resolved] [Resolved]
private OsuColour colours { get; set; } private OsuColour colours { get; set; } = null!;
private readonly Drawable background; private readonly Drawable background;

View File

@ -1,14 +1,13 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Diagnostics;
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -20,17 +19,16 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
public partial class MultiplayerReadyButton : ReadyButton public partial class MultiplayerReadyButton : ReadyButton
{ {
[Resolved] [Resolved]
private MultiplayerClient multiplayerClient { get; set; } private MultiplayerClient multiplayerClient { get; set; } = null!;
[Resolved] [Resolved]
private OsuColour colours { get; set; } private OsuColour colours { get; set; } = null!;
[CanBeNull] private MultiplayerRoom? room => multiplayerClient.Room;
private MultiplayerRoom room => multiplayerClient.Room;
private Sample countdownTickSample; private Sample? countdownTickSample;
private Sample countdownWarnSample; private Sample? countdownWarnSample;
private Sample countdownWarnFinalSample; private Sample? countdownWarnFinalSample;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio)
@ -48,13 +46,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
onRoomUpdated(); onRoomUpdated();
} }
private MultiplayerCountdown countdown; private MultiplayerCountdown? countdown;
private double countdownChangeTime; private double countdownChangeTime;
private ScheduledDelegate countdownUpdateDelegate; private ScheduledDelegate? countdownUpdateDelegate;
private void onRoomUpdated() => Scheduler.AddOnce(() => private void onRoomUpdated() => Scheduler.AddOnce(() =>
{ {
MultiplayerCountdown newCountdown = room?.ActiveCountdowns.SingleOrDefault(c => c is MatchStartCountdown); MultiplayerCountdown? newCountdown = room?.ActiveCountdowns.SingleOrDefault(c => c is MatchStartCountdown);
if (newCountdown != countdown) if (newCountdown != countdown)
{ {
@ -171,6 +169,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
{ {
get get
{ {
Debug.Assert(countdown != null);
double timeElapsed = Time.Current - countdownChangeTime; double timeElapsed = Time.Current - countdownChangeTime;
TimeSpan remaining; TimeSpan remaining;
@ -224,7 +224,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
{ {
base.Dispose(isDisposing); base.Dispose(isDisposing);
if (multiplayerClient != null) if (multiplayerClient.IsNotNull())
multiplayerClient.RoomUpdated -= onRoomUpdated; multiplayerClient.RoomUpdated -= onRoomUpdated;
} }

View File

@ -58,7 +58,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
client.ToggleSpectate().ContinueWith(_ => endOperation()); client.ToggleSpectate().ContinueWith(_ => endOperation());
void endOperation() => clickOperation?.Dispose(); void endOperation() => clickOperation.Dispose();
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -27,12 +25,12 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
public partial class MultiplayerLoungeSubScreen : LoungeSubScreen public partial class MultiplayerLoungeSubScreen : LoungeSubScreen
{ {
[Resolved] [Resolved]
private IAPIProvider api { get; set; } private IAPIProvider api { get; set; } = null!;
[Resolved] [Resolved]
private MultiplayerClient client { get; set; } private MultiplayerClient client { get; set; } = null!;
private Dropdown<RoomPermissionsFilter> roomAccessTypeDropdown; private Dropdown<RoomPermissionsFilter> roomAccessTypeDropdown = null!;
public override void OnResuming(ScreenTransitionEvent e) public override void OnResuming(ScreenTransitionEvent e)
{ {
@ -83,7 +81,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
protected override void OpenNewRoom(Room room) protected override void OpenNewRoom(Room room)
{ {
if (client?.IsConnected.Value != true) if (!client.IsConnected.Value)
{ {
Logger.Log("Not currently connected to the multiplayer server.", LoggingTarget.Runtime, LogLevel.Important); Logger.Log("Not currently connected to the multiplayer server.", LoggingTarget.Runtime, LogLevel.Important);
return; return;
@ -95,7 +93,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
private partial class MultiplayerListingPollingComponent : ListingPollingComponent private partial class MultiplayerListingPollingComponent : ListingPollingComponent
{ {
[Resolved] [Resolved]
private MultiplayerClient client { get; set; } private MultiplayerClient client { get; set; } = null!;
private readonly IBindable<bool> isConnected = new Bindable<bool>(); private readonly IBindable<bool> isConnected = new Bindable<bool>();

View File

@ -401,7 +401,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
StartPlay(); StartPlay();
} }
protected override Screen CreateGameplayScreen() protected override Screen CreateGameplayScreen(PlaylistItem selectedItem)
{ {
Debug.Assert(client.LocalUser != null); Debug.Assert(client.LocalUser != null);
Debug.Assert(client.Room != null); Debug.Assert(client.Room != null);
@ -415,7 +415,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
return new MultiSpectatorScreen(Room, users.Take(PlayerGrid.MAX_PLAYERS).ToArray()); return new MultiSpectatorScreen(Room, users.Take(PlayerGrid.MAX_PLAYERS).ToArray());
default: default:
return new MultiplayerPlayerLoader(() => new MultiplayerPlayer(Room, SelectedItem.Value, users)); return new MultiplayerPlayerLoader(() => new MultiplayerPlayer(Room, selectedItem, users));
} }
} }

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using osu.Framework.Allocation; using osu.Framework.Allocation;
@ -18,9 +16,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
public bool GameplayPassed => player?.GameplayState.HasPassed == true; public bool GameplayPassed => player?.GameplayState.HasPassed == true;
[Resolved] [Resolved]
private MultiplayerClient multiplayerClient { get; set; } private MultiplayerClient multiplayerClient { get; set; } = null!;
private Player player; private Player? player;
public MultiplayerPlayerLoader(Func<Player> createPlayer) public MultiplayerPlayerLoader(Func<Player> createPlayer)
: base(createPlayer) : base(createPlayer)
@ -45,7 +43,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
.ContinueWith(task => failAndBail(task.Exception?.Message ?? "Server error"), TaskContinuationOptions.NotOnRanToCompletion); .ContinueWith(task => failAndBail(task.Exception?.Message ?? "Server error"), TaskContinuationOptions.NotOnRanToCompletion);
} }
private void failAndBail(string message = null) private void failAndBail(string? message = null)
{ {
if (!string.IsNullOrEmpty(message)) if (!string.IsNullOrEmpty(message))
Logger.Log(message, LoggingTarget.Runtime, LogLevel.Important); Logger.Log(message, LoggingTarget.Runtime, LogLevel.Important);

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -22,7 +20,7 @@ namespace osu.Game.Screens.OnlinePlay
private readonly Bindable<bool> inProgress = new BindableBool(); private readonly Bindable<bool> inProgress = new BindableBool();
private LeasedBindable<bool> leasedInProgress; private LeasedBindable<bool>? leasedInProgress;
public OngoingOperationTracker() public OngoingOperationTracker()
{ {

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Diagnostics; using System.Diagnostics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -27,16 +25,16 @@ namespace osu.Game.Screens.OnlinePlay
public IScreen CurrentSubScreen => screenStack.CurrentScreen; public IScreen CurrentSubScreen => screenStack.CurrentScreen;
public override bool CursorVisible => (screenStack?.CurrentScreen as IOnlinePlaySubScreen)?.CursorVisible ?? true; public override bool CursorVisible => (screenStack.CurrentScreen as IOnlinePlaySubScreen)?.CursorVisible ?? true;
// this is required due to PlayerLoader eventually being pushed to the main stack // this is required due to PlayerLoader eventually being pushed to the main stack
// while leases may be taken out by a subscreen. // while leases may be taken out by a subscreen.
public override bool DisallowExternalBeatmapRulesetChanges => true; public override bool DisallowExternalBeatmapRulesetChanges => true;
protected LoungeSubScreen Lounge { get; private set; } protected LoungeSubScreen Lounge { get; private set; } = null!;
private OnlinePlayScreenWaveContainer waves; private readonly ScreenStack screenStack = new OnlinePlaySubScreenStack { RelativeSizeAxes = Axes.Both };
private ScreenStack screenStack; private OnlinePlayScreenWaveContainer waves = null!;
[Cached(Type = typeof(IRoomManager))] [Cached(Type = typeof(IRoomManager))]
protected RoomManager RoomManager { get; private set; } protected RoomManager RoomManager { get; private set; }
@ -45,7 +43,7 @@ namespace osu.Game.Screens.OnlinePlay
private readonly OngoingOperationTracker ongoingOperationTracker = new OngoingOperationTracker(); private readonly OngoingOperationTracker ongoingOperationTracker = new OngoingOperationTracker();
[Resolved] [Resolved]
protected IAPIProvider API { get; private set; } protected IAPIProvider API { get; private set; } = null!;
protected OnlinePlayScreen() protected OnlinePlayScreen()
{ {
@ -67,7 +65,7 @@ namespace osu.Game.Screens.OnlinePlay
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
screenStack = new OnlinePlaySubScreenStack { RelativeSizeAxes = Axes.Both }, screenStack,
new Header(ScreenTitle, screenStack), new Header(ScreenTitle, screenStack),
RoomManager, RoomManager,
ongoingOperationTracker, ongoingOperationTracker,

View File

@ -273,10 +273,13 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
Logger.Log($"Polling adjusted (selection: {selectionPollingComponent.TimeBetweenPolls.Value})"); Logger.Log($"Polling adjusted (selection: {selectionPollingComponent.TimeBetweenPolls.Value})");
} }
protected override Screen CreateGameplayScreen() => new PlayerLoader(() => new PlaylistsPlayer(Room, SelectedItem.Value) protected override Screen CreateGameplayScreen(PlaylistItem selectedItem)
{
return new PlayerLoader(() => new PlaylistsPlayer(Room, selectedItem)
{ {
Exited = () => leaderboard.RefetchScores() Exited = () => leaderboard.RefetchScores()
}); });
}
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {

View File

@ -166,7 +166,7 @@ namespace osu.Game.Screens.Play
return; return;
float timeBoxTargetWidth = (float)Math.Max(0, (remainingTimeForCurrentPeriod - timingPoint.BeatLength / currentPeriod.Value.Value.Duration)); float timeBoxTargetWidth = (float)Math.Max(0, (remainingTimeForCurrentPeriod - timingPoint.BeatLength / currentPeriod.Value.Value.Duration));
remainingTimeBox.ResizeWidthTo(timeBoxTargetWidth, timingPoint.BeatLength * 2, Easing.OutQuint); remainingTimeBox.ResizeWidthTo(timeBoxTargetWidth, timingPoint.BeatLength * 3.5, Easing.OutQuint);
} }
private void updateDisplay(ValueChangedEvent<Period?> period) private void updateDisplay(ValueChangedEvent<Period?> period)

View File

@ -122,7 +122,9 @@ namespace osu.Game.Screens.Play
// not ready if the user is dragging a slider or otherwise. // not ready if the user is dragging a slider or otherwise.
&& (inputManager.DraggedDrawable == null || inputManager.DraggedDrawable is OsuLogo) && (inputManager.DraggedDrawable == null || inputManager.DraggedDrawable is OsuLogo)
// not ready if a focused overlay is visible, like settings. // not ready if a focused overlay is visible, like settings.
&& inputManager.FocusedDrawable == null; && inputManager.FocusedDrawable is not OsuFocusedOverlayContainer
// or if a child of a focused overlay is focused, like settings' search textbox.
&& inputManager.FocusedDrawable?.FindClosestParent<OsuFocusedOverlayContainer>() == null;
private readonly Func<Player> createPlayer; private readonly Func<Player> createPlayer;

View File

@ -219,7 +219,7 @@ namespace osu.Game.Screens.Play
float progress = (float)(gameplayClock.CurrentTime - displayTime) / (float)(fadeOutBeginTime - displayTime); float progress = (float)(gameplayClock.CurrentTime - displayTime) / (float)(fadeOutBeginTime - displayTime);
float newWidth = 1 - Math.Clamp(progress, 0, 1); float newWidth = 1 - Math.Clamp(progress, 0, 1);
remainingTimeBox.ResizeWidthTo(newWidth, timingPoint.BeatLength * 2, Easing.OutQuint); remainingTimeBox.ResizeWidthTo(newWidth, timingPoint.BeatLength * 3.5, Easing.OutQuint);
} }
public partial class FadeContainer : Container, IStateful<Visibility> public partial class FadeContainer : Container, IStateful<Visibility>

View File

@ -298,7 +298,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy
{ {
foreach (var badge in badges) foreach (var badge in badges)
{ {
if (badge.Accuracy > score.Accuracy) if (badge.Rank > score.Rank)
continue; continue;
using (BeginDelayedSequence( using (BeginDelayedSequence(

Some files were not shown because too many files have changed in this diff Show More