diff --git a/.idea/.idea.osu.Android/.idea/.name b/.idea/.idea.osu.Android/.idea/.name
new file mode 100644
index 0000000000..86363b495c
--- /dev/null
+++ b/.idea/.idea.osu.Android/.idea/.name
@@ -0,0 +1 @@
+osu.Android
\ No newline at end of file
diff --git a/.idea/.idea.osu.Android/.idea/indexLayout.xml b/.idea/.idea.osu.Android/.idea/indexLayout.xml
new file mode 100644
index 0000000000..7b08163ceb
--- /dev/null
+++ b/.idea/.idea.osu.Android/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.osu.Android/.idea/misc.xml b/.idea/.idea.osu.Android/.idea/misc.xml
new file mode 100644
index 0000000000..1d8c84d0af
--- /dev/null
+++ b/.idea/.idea.osu.Android/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.osu.Android/.idea/projectSettingsUpdater.xml b/.idea/.idea.osu.Android/.idea/projectSettingsUpdater.xml
new file mode 100644
index 0000000000..4bb9f4d2a0
--- /dev/null
+++ b/.idea/.idea.osu.Android/.idea/projectSettingsUpdater.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.osu.Android/.idea/vcs.xml b/.idea/.idea.osu.Android/.idea/vcs.xml
new file mode 100644
index 0000000000..94a25f7f4c
--- /dev/null
+++ b/.idea/.idea.osu.Android/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.osu/.idea/misc.xml b/.idea/.idea.osu/.idea/misc.xml
new file mode 100644
index 0000000000..1d8c84d0af
--- /dev/null
+++ b/.idea/.idea.osu/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.osu/.idea/modules.xml b/.idea/.idea.osu/.idea/modules.xml
deleted file mode 100644
index 0360fdbc5e..0000000000
--- a/.idea/.idea.osu/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/.idea.osu/.idea/projectSettingsUpdater.xml b/.idea/.idea.osu/.idea/projectSettingsUpdater.xml
index 7515e76054..4bb9f4d2a0 100644
--- a/.idea/.idea.osu/.idea/projectSettingsUpdater.xml
+++ b/.idea/.idea.osu/.idea/projectSettingsUpdater.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/TestSceneOsuGame.cs b/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/TestSceneOsuGame.cs
index 536fdfc6df..5973db908c 100644
--- a/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/TestSceneOsuGame.cs
+++ b/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/TestSceneOsuGame.cs
@@ -4,7 +4,6 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
-using osu.Framework.Platform;
using osu.Game.Tests.Visual;
using osuTK.Graphics;
@@ -13,7 +12,7 @@ namespace osu.Game.Rulesets.EmptyFreeform.Tests
public class TestSceneOsuGame : OsuTestScene
{
[BackgroundDependencyLoader]
- private void load(GameHost host, OsuGameBase gameBase)
+ private void load()
{
Children = new Drawable[]
{
diff --git a/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/TestSceneOsuGame.cs b/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/TestSceneOsuGame.cs
index 3cdf44e6f1..b75a5ec187 100644
--- a/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/TestSceneOsuGame.cs
+++ b/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/TestSceneOsuGame.cs
@@ -4,7 +4,6 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
-using osu.Framework.Platform;
using osu.Game.Tests.Visual;
using osuTK.Graphics;
@@ -13,7 +12,7 @@ namespace osu.Game.Rulesets.Pippidon.Tests
public class TestSceneOsuGame : OsuTestScene
{
[BackgroundDependencyLoader]
- private void load(GameHost host, OsuGameBase gameBase)
+ private void load()
{
Children = new Drawable[]
{
diff --git a/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/TestSceneOsuGame.cs b/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/TestSceneOsuGame.cs
index 4d3f5086d9..ffe921b54c 100644
--- a/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/TestSceneOsuGame.cs
+++ b/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/TestSceneOsuGame.cs
@@ -4,7 +4,6 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
-using osu.Framework.Platform;
using osu.Game.Tests.Visual;
using osuTK.Graphics;
@@ -13,7 +12,7 @@ namespace osu.Game.Rulesets.EmptyScrolling.Tests
public class TestSceneOsuGame : OsuTestScene
{
[BackgroundDependencyLoader]
- private void load(GameHost host, OsuGameBase gameBase)
+ private void load()
{
Children = new Drawable[]
{
diff --git a/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/TestSceneOsuGame.cs b/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/TestSceneOsuGame.cs
index 3cdf44e6f1..b75a5ec187 100644
--- a/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/TestSceneOsuGame.cs
+++ b/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/TestSceneOsuGame.cs
@@ -4,7 +4,6 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
-using osu.Framework.Platform;
using osu.Game.Tests.Visual;
using osuTK.Graphics;
@@ -13,7 +12,7 @@ namespace osu.Game.Rulesets.Pippidon.Tests
public class TestSceneOsuGame : OsuTestScene
{
[BackgroundDependencyLoader]
- private void load(GameHost host, OsuGameBase gameBase)
+ private void load()
{
Children = new Drawable[]
{
diff --git a/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon/UI/PippidonPlayfield.cs b/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon/UI/PippidonPlayfield.cs
index 0e50030162..ab8c6bb2e9 100644
--- a/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon/UI/PippidonPlayfield.cs
+++ b/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon/UI/PippidonPlayfield.cs
@@ -7,7 +7,6 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
-using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
@@ -28,7 +27,7 @@ namespace osu.Game.Rulesets.Pippidon.UI
private PippidonCharacter pippidon;
[BackgroundDependencyLoader]
- private void load(TextureStore textures)
+ private void load()
{
AddRangeInternal(new Drawable[]
{
diff --git a/osu.Android.props b/osu.Android.props
index 4198cf2bf4..b296c114e9 100644
--- a/osu.Android.props
+++ b/osu.Android.props
@@ -51,11 +51,11 @@
-
-
+
+
-
+
diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs
index b234207848..cd3fb7eb61 100644
--- a/osu.Desktop/OsuGameDesktop.cs
+++ b/osu.Desktop/OsuGameDesktop.cs
@@ -10,14 +10,11 @@ using System.Runtime.Versioning;
using System.Threading.Tasks;
using Microsoft.Win32;
using osu.Desktop.Security;
-using osu.Desktop.Overlays;
using osu.Framework.Platform;
using osu.Game;
using osu.Desktop.Updater;
using osu.Framework;
using osu.Framework.Logging;
-using osu.Framework.Screens;
-using osu.Game.Screens.Menu;
using osu.Game.Updater;
using osu.Desktop.Windows;
using osu.Framework.Threading;
@@ -27,13 +24,9 @@ namespace osu.Desktop
{
internal class OsuGameDesktop : OsuGame
{
- private readonly bool noVersionOverlay;
- private VersionManager versionManager;
-
public OsuGameDesktop(string[] args = null)
: base(args)
{
- noVersionOverlay = args?.Any(a => a == "--no-version-overlay") ?? false;
}
public override StableStorage GetStorageForStableInstall()
@@ -114,9 +107,6 @@ namespace osu.Desktop
{
base.LoadComplete();
- if (!noVersionOverlay)
- LoadComponentAsync(versionManager = new VersionManager { Depth = int.MinValue }, ScreenContainer.Add);
-
LoadComponentAsync(new DiscordRichPresence(), Add);
if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows)
@@ -125,23 +115,6 @@ namespace osu.Desktop
LoadComponentAsync(new ElevatedPrivilegesChecker(), Add);
}
- protected override void ScreenChanged(IScreen lastScreen, IScreen newScreen)
- {
- base.ScreenChanged(lastScreen, newScreen);
-
- switch (newScreen)
- {
- case IntroScreen _:
- case MainMenu _:
- versionManager?.Show();
- break;
-
- default:
- versionManager?.Hide();
- break;
- }
- }
-
public override void SetHost(GameHost host)
{
base.SetHost(host);
diff --git a/osu.Desktop/Security/ElevatedPrivilegesChecker.cs b/osu.Desktop/Security/ElevatedPrivilegesChecker.cs
index 62ea3e0399..8f3ad853dc 100644
--- a/osu.Desktop/Security/ElevatedPrivilegesChecker.cs
+++ b/osu.Desktop/Security/ElevatedPrivilegesChecker.cs
@@ -73,7 +73,7 @@ namespace osu.Desktop.Security
}
[BackgroundDependencyLoader]
- private void load(OsuColour colours, NotificationOverlay notificationOverlay)
+ private void load(OsuColour colours)
{
Icon = FontAwesome.Solid.ShieldAlt;
IconBackground.Colour = colours.YellowDark;
diff --git a/osu.Game.Rulesets.Catch.Tests/Editor/CatchSelectionBlueprintTestScene.cs b/osu.Game.Rulesets.Catch.Tests/Editor/CatchSelectionBlueprintTestScene.cs
index d4c2c0f0af..e345e03c96 100644
--- a/osu.Game.Rulesets.Catch.Tests/Editor/CatchSelectionBlueprintTestScene.cs
+++ b/osu.Game.Rulesets.Catch.Tests/Editor/CatchSelectionBlueprintTestScene.cs
@@ -29,7 +29,13 @@ namespace osu.Game.Rulesets.Catch.Tests.Editor
protected CatchSelectionBlueprintTestScene()
{
- EditorBeatmap = new EditorBeatmap(new CatchBeatmap()) { Difficulty = { CircleSize = 0 } };
+ EditorBeatmap = new EditorBeatmap(new CatchBeatmap
+ {
+ BeatmapInfo =
+ {
+ Ruleset = new CatchRuleset().RulesetInfo,
+ }
+ }) { Difficulty = { CircleSize = 0 } };
EditorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint
{
BeatLength = 100
diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneAutoJuiceStream.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneAutoJuiceStream.cs
index f552c3c27b..1014158fc1 100644
--- a/osu.Game.Rulesets.Catch.Tests/TestSceneAutoJuiceStream.cs
+++ b/osu.Game.Rulesets.Catch.Tests/TestSceneAutoJuiceStream.cs
@@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Catch.Tests
{
BeatmapInfo = new BeatmapInfo
{
- BaseDifficulty = new BeatmapDifficulty { CircleSize = 6, SliderMultiplier = 3 },
+ Difficulty = new BeatmapDifficulty { CircleSize = 6, SliderMultiplier = 3 },
Ruleset = ruleset
}
};
diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneBananaShower.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneBananaShower.cs
index e89a95ae37..96ac5c4bf2 100644
--- a/osu.Game.Rulesets.Catch.Tests/TestSceneBananaShower.cs
+++ b/osu.Game.Rulesets.Catch.Tests/TestSceneBananaShower.cs
@@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Catch.Tests
{
BeatmapInfo = new BeatmapInfo
{
- BaseDifficulty = new BeatmapDifficulty { CircleSize = 6 },
+ Difficulty = new BeatmapDifficulty { CircleSize = 6 },
Ruleset = ruleset
}
};
diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneCatchStacker.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneCatchStacker.cs
index 1ff31697b8..0a4ef49e19 100644
--- a/osu.Game.Rulesets.Catch.Tests/TestSceneCatchStacker.cs
+++ b/osu.Game.Rulesets.Catch.Tests/TestSceneCatchStacker.cs
@@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Catch.Tests
{
BeatmapInfo = new BeatmapInfo
{
- BaseDifficulty = new BeatmapDifficulty { CircleSize = 6 },
+ Difficulty = new BeatmapDifficulty { CircleSize = 6 },
Ruleset = ruleset
}
};
diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableHitObjects.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableHitObjects.cs
index 23f6222eb6..4b8fede369 100644
--- a/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableHitObjects.cs
+++ b/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableHitObjects.cs
@@ -35,12 +35,12 @@ namespace osu.Game.Rulesets.Catch.Tests
HitObjects = new List { new Fruit() },
BeatmapInfo = new BeatmapInfo
{
- BaseDifficulty = new BeatmapDifficulty(),
+ Difficulty = new BeatmapDifficulty(),
Metadata = new BeatmapMetadata
{
Artist = @"Unknown",
Title = @"You're breathtaking",
- AuthorString = @"Everyone",
+ Author = { Username = @"Everyone" },
},
Ruleset = new CatchRuleset().RulesetInfo
},
diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs
index 163fee49fb..a5b44dc605 100644
--- a/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs
+++ b/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs
@@ -63,7 +63,7 @@ namespace osu.Game.Rulesets.Catch.Tests
BeatmapInfo =
{
Ruleset = ruleset,
- BaseDifficulty = new BeatmapDifficulty { CircleSize = 3.6f }
+ Difficulty = new BeatmapDifficulty { CircleSize = 3.6f }
}
};
diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneJuiceStream.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneJuiceStream.cs
index 269e783899..4601234669 100644
--- a/osu.Game.Rulesets.Catch.Tests/TestSceneJuiceStream.cs
+++ b/osu.Game.Rulesets.Catch.Tests/TestSceneJuiceStream.cs
@@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Catch.Tests
{
BeatmapInfo = new BeatmapInfo
{
- BaseDifficulty = new BeatmapDifficulty { CircleSize = 5, SliderMultiplier = 2 },
+ Difficulty = new BeatmapDifficulty { CircleSize = 5, SliderMultiplier = 2 },
Ruleset = ruleset
},
HitObjects = new List
diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaBeatSnapGrid.cs b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaBeatSnapGrid.cs
index 5ccb191a9b..50be13c4e0 100644
--- a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaBeatSnapGrid.cs
+++ b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaBeatSnapGrid.cs
@@ -29,7 +29,13 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
private ScrollingTestContainer.TestScrollingInfo scrollingInfo = new ScrollingTestContainer.TestScrollingInfo();
[Cached(typeof(EditorBeatmap))]
- private EditorBeatmap editorBeatmap = new EditorBeatmap(new ManiaBeatmap(new StageDefinition()));
+ private EditorBeatmap editorBeatmap = new EditorBeatmap(new ManiaBeatmap(new StageDefinition())
+ {
+ BeatmapInfo =
+ {
+ Ruleset = new ManiaRuleset().RulesetInfo
+ }
+ });
private readonly ManiaBeatSnapGrid beatSnapGrid;
diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaComposeScreen.cs b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaComposeScreen.cs
index a30e09cd29..5dd7c23ab6 100644
--- a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaComposeScreen.cs
+++ b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaComposeScreen.cs
@@ -31,10 +31,10 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
{
AddStep("setup compose screen", () =>
{
- var editorBeatmap = new EditorBeatmap(new ManiaBeatmap(new StageDefinition { Columns = 4 }))
+ var editorBeatmap = new EditorBeatmap(new ManiaBeatmap(new StageDefinition { Columns = 4 })
{
BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo },
- };
+ });
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaHitObjectComposer.cs b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaHitObjectComposer.cs
index 01d80881fa..9788dfe844 100644
--- a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaHitObjectComposer.cs
+++ b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaHitObjectComposer.cs
@@ -203,10 +203,10 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
{
InternalChildren = new Drawable[]
{
- EditorBeatmap = new EditorBeatmap(new ManiaBeatmap(new StageDefinition { Columns = 4 }))
+ EditorBeatmap = new EditorBeatmap(new ManiaBeatmap(new StageDefinition { Columns = 4 })
{
BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo }
- },
+ }),
Composer = new ManiaHitObjectComposer(new ManiaRuleset())
};
diff --git a/osu.Game.Rulesets.Mania.Tests/Resources/special-skin/skin.ini b/osu.Game.Rulesets.Mania.Tests/Resources/special-skin/skin.ini
index 36765d61bf..9c987efc60 100644
--- a/osu.Game.Rulesets.Mania.Tests/Resources/special-skin/skin.ini
+++ b/osu.Game.Rulesets.Mania.Tests/Resources/special-skin/skin.ini
@@ -4,11 +4,14 @@ Version: 2.5
[Mania]
Keys: 4
ColumnLineWidth: 3,1,3,1,1
-Hit0: mania/hit0
-Hit50: mania/hit50
-Hit100: mania/hit100
-Hit200: mania/hit200
-Hit300: mania/hit300
-Hit300g: mania/hit300g
+// some skins found in the wild had configuration keys where the @2x suffix was included in the values.
+// the expected compatibility behaviour is that the presence of the @2x suffix shouldn't change anything
+// if @2x assets are present.
+Hit0: mania/hit0@2x
+Hit50: mania/hit50@2x
+Hit100: mania/hit100@2x
+Hit200: mania/hit200@2x
+Hit300: mania/hit300@2x
+Hit300g: mania/hit300g@2x
StageLeft: mania/stage-left
StageRight: mania/stage-right
\ No newline at end of file
diff --git a/osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneDrawableJudgement.cs b/osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneDrawableJudgement.cs
index 75a5495078..d033676ec7 100644
--- a/osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneDrawableJudgement.cs
+++ b/osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneDrawableJudgement.cs
@@ -5,8 +5,10 @@ using System;
using System.Linq;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
+using osu.Framework.Testing;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Scoring;
+using osu.Game.Rulesets.Mania.Skinning.Legacy;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
@@ -23,15 +25,24 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
{
if (hitWindows.IsHitResultAllowed(result))
{
- AddStep("Show " + result.GetDescription(), () => SetContents(_ =>
- new DrawableManiaJudgement(new JudgementResult(new HitObject { StartTime = Time.Current }, new Judgement())
- {
- Type = result
- }, null)
- {
- Anchor = Anchor.Centre,
- Origin = Anchor.Centre,
- }));
+ AddStep("Show " + result.GetDescription(), () =>
+ {
+ SetContents(_ =>
+ new DrawableManiaJudgement(new JudgementResult(new HitObject { StartTime = Time.Current }, new Judgement())
+ {
+ Type = result
+ }, null)
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ });
+
+ // for test purposes, undo the Y adjustment related to the `ScorePosition` legacy positioning config value
+ // (see `LegacyManiaJudgementPiece.load()`).
+ // this prevents the judgements showing somewhere below or above the bounding box of the judgement.
+ foreach (var legacyPiece in this.ChildrenOfType())
+ legacyPiece.Y = 0;
+ });
}
}
}
diff --git a/osu.Game.Rulesets.Mania.Tests/TestSceneHoldNoteInput.cs b/osu.Game.Rulesets.Mania.Tests/TestSceneHoldNoteInput.cs
index 4387bc6b3b..f973cb5ed3 100644
--- a/osu.Game.Rulesets.Mania.Tests/TestSceneHoldNoteInput.cs
+++ b/osu.Game.Rulesets.Mania.Tests/TestSceneHoldNoteInput.cs
@@ -264,7 +264,7 @@ namespace osu.Game.Rulesets.Mania.Tests
},
BeatmapInfo =
{
- BaseDifficulty = new BeatmapDifficulty
+ Difficulty = new BeatmapDifficulty
{
SliderTickRate = 4,
OverallDifficulty = 10,
@@ -306,7 +306,7 @@ namespace osu.Game.Rulesets.Mania.Tests
},
BeatmapInfo =
{
- BaseDifficulty = new BeatmapDifficulty { SliderTickRate = tick_rate },
+ Difficulty = new BeatmapDifficulty { SliderTickRate = tick_rate },
Ruleset = new ManiaRuleset().RulesetInfo
},
};
@@ -383,7 +383,7 @@ namespace osu.Game.Rulesets.Mania.Tests
},
BeatmapInfo =
{
- BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 4 },
+ Difficulty = new BeatmapDifficulty { SliderTickRate = 4 },
Ruleset = new ManiaRuleset().RulesetInfo
},
};
diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs
index 9d0aaec2ba..47e0e6d7b1 100644
--- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs
+++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs
@@ -73,7 +73,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
public static int GetColumnCountForNonConvert(BeatmapInfo beatmapInfo)
{
- double roundedCircleSize = Math.Round(beatmapInfo.BaseDifficulty.CircleSize);
+ double roundedCircleSize = Math.Round(beatmapInfo.Difficulty.CircleSize);
return (int)Math.Max(1, roundedCircleSize);
}
diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs
index 5259fcbd5f..35889aea0c 100644
--- a/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs
+++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs
@@ -9,7 +9,6 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
using osu.Game.Rulesets.Mania.Objects;
-using osu.Game.Rulesets.UI.Scrolling;
using osuTK;
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
@@ -28,7 +27,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
}
[BackgroundDependencyLoader]
- private void load(IScrollingInfo scrollingInfo)
+ private void load()
{
InternalChildren = new Drawable[]
{
diff --git a/osu.Game.Rulesets.Osu.Tests/Editor/Checks/CheckTooShortSpinnersTest.cs b/osu.Game.Rulesets.Osu.Tests/Editor/Checks/CheckTooShortSpinnersTest.cs
index 787807a8ea..1f3d4297f1 100644
--- a/osu.Game.Rulesets.Osu.Tests/Editor/Checks/CheckTooShortSpinnersTest.cs
+++ b/osu.Game.Rulesets.Osu.Tests/Editor/Checks/CheckTooShortSpinnersTest.cs
@@ -107,7 +107,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
var beatmap = new Beatmap
{
HitObjects = hitObjects,
- BeatmapInfo = new BeatmapInfo { BaseDifficulty = new BeatmapDifficulty(beatmapDifficulty) }
+ BeatmapInfo = new BeatmapInfo { Difficulty = new BeatmapDifficulty(beatmapDifficulty) }
};
return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
diff --git a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuDistanceSnapGrid.cs b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuDistanceSnapGrid.cs
index ef43c3a696..c770e2d96f 100644
--- a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuDistanceSnapGrid.cs
+++ b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuDistanceSnapGrid.cs
@@ -40,7 +40,13 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
public TestSceneOsuDistanceSnapGrid()
{
- editorBeatmap = new EditorBeatmap(new OsuBeatmap());
+ editorBeatmap = new EditorBeatmap(new OsuBeatmap
+ {
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo
+ }
+ });
}
[SetUp]
diff --git a/osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModDifficultyAdjust.cs b/osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModDifficultyAdjust.cs
index db8546c71b..9d06ff5801 100644
--- a/osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModDifficultyAdjust.cs
+++ b/osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModDifficultyAdjust.cs
@@ -26,7 +26,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
{
BeatmapInfo = new BeatmapInfo
{
- BaseDifficulty = new BeatmapDifficulty
+ Difficulty = new BeatmapDifficulty
{
CircleSize = 8
}
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLongCombo.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLongCombo.cs
index 8cf29ddfbf..4e17c4c363 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLongCombo.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLongCombo.cs
@@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Osu.Tests
{
BeatmapInfo = new BeatmapInfo
{
- BaseDifficulty = new BeatmapDifficulty { CircleSize = 6 },
+ Difficulty = new BeatmapDifficulty { CircleSize = 6 },
Ruleset = ruleset
}
};
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneNoSpinnerStacking.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneNoSpinnerStacking.cs
index ef05bcd320..5e92bac986 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneNoSpinnerStacking.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneNoSpinnerStacking.cs
@@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Osu.Tests
{
BeatmapInfo = new BeatmapInfo
{
- BaseDifficulty = new BeatmapDifficulty { OverallDifficulty = 10 },
+ Difficulty = new BeatmapDifficulty { OverallDifficulty = 10 },
Ruleset = ruleset
}
};
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs
index f3392724ec..2368cc7365 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs
@@ -358,7 +358,7 @@ namespace osu.Game.Rulesets.Osu.Tests
},
BeatmapInfo =
{
- BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 3 },
+ Difficulty = new BeatmapDifficulty { SliderTickRate = 3 },
Ruleset = new OsuRuleset().RulesetInfo
},
});
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneStartTimeOrderedHitPolicy.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneStartTimeOrderedHitPolicy.cs
index 2d43e1b95e..53fa3624b8 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneStartTimeOrderedHitPolicy.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneStartTimeOrderedHitPolicy.cs
@@ -364,7 +364,7 @@ namespace osu.Game.Rulesets.Osu.Tests
HitObjects = hitObjects,
BeatmapInfo =
{
- BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 3 },
+ Difficulty = new BeatmapDifficulty { SliderTickRate = 3 },
Ruleset = new OsuRuleset().RulesetInfo
},
});
diff --git a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs
index fdf646ef85..604ab73454 100644
--- a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs
+++ b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs
@@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty
private int countMeh;
private int countMiss;
- private int effectiveMissCount;
+ private double effectiveMissCount;
public OsuPerformanceCalculator(Ruleset ruleset, DifficultyAttributes attributes, ScoreInfo score)
: base(ruleset, attributes, score)
@@ -97,7 +97,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty
// Penalize misses by assessing # of misses relative to the total # of objects. Default a 3% reduction for any # of misses.
if (effectiveMissCount > 0)
- aimValue *= 0.97 * Math.Pow(1 - Math.Pow((double)effectiveMissCount / totalHits, 0.775), effectiveMissCount);
+ aimValue *= 0.97 * Math.Pow(1 - Math.Pow(effectiveMissCount / totalHits, 0.775), effectiveMissCount);
aimValue *= getComboScalingFactor();
@@ -144,7 +144,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty
// Penalize misses by assessing # of misses relative to the total # of objects. Default a 3% reduction for any # of misses.
if (effectiveMissCount > 0)
- speedValue *= 0.97 * Math.Pow(1 - Math.Pow((double)effectiveMissCount / totalHits, 0.775), Math.Pow(effectiveMissCount, .875));
+ speedValue *= 0.97 * Math.Pow(1 - Math.Pow(effectiveMissCount / totalHits, 0.775), Math.Pow(effectiveMissCount, .875));
speedValue *= getComboScalingFactor();
@@ -228,7 +228,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty
// Penalize misses by assessing # of misses relative to the total # of objects. Default a 3% reduction for any # of misses.
if (effectiveMissCount > 0)
- flashlightValue *= 0.97 * Math.Pow(1 - Math.Pow((double)effectiveMissCount / totalHits, 0.775), Math.Pow(effectiveMissCount, .875));
+ flashlightValue *= 0.97 * Math.Pow(1 - Math.Pow(effectiveMissCount / totalHits, 0.775), Math.Pow(effectiveMissCount, .875));
flashlightValue *= getComboScalingFactor();
@@ -244,7 +244,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty
return flashlightValue;
}
- private int calculateEffectiveMissCount()
+ private double calculateEffectiveMissCount()
{
// Guess the number of misses + slider breaks from combo
double comboBasedMissCount = 0.0;
@@ -256,10 +256,10 @@ namespace osu.Game.Rulesets.Osu.Difficulty
comboBasedMissCount = fullComboThreshold / Math.Max(1.0, scoreMaxCombo);
}
- // Clamp misscount since it's derived from combo and can be higher than total hits and that breaks some calculations
+ // Clamp miss count since it's derived from combo and can be higher than total hits and that breaks some calculations
comboBasedMissCount = Math.Min(comboBasedMissCount, totalHits);
- return Math.Max(countMiss, (int)Math.Floor(comboBasedMissCount));
+ return Math.Max(countMiss, comboBasedMissCount);
}
private double getComboScalingFactor() => Attributes.MaxCombo <= 0 ? 1.0 : Math.Min(Math.Pow(scoreMaxCombo, 0.8) / Math.Pow(Attributes.MaxCombo, 0.8), 1.0);
diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderPlacementBlueprint.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderPlacementBlueprint.cs
index 07b6a1bdc2..b868c9a7ee 100644
--- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderPlacementBlueprint.cs
+++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderPlacementBlueprint.cs
@@ -9,7 +9,6 @@ using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps.ControlPoints;
-using osu.Game.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
@@ -50,7 +49,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
}
[BackgroundDependencyLoader]
- private void load(OsuColour colours)
+ private void load()
{
InternalChildren = new Drawable[]
{
diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs
index ec87d3bfdf..c6db02ee02 100644
--- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs
+++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs
@@ -10,7 +10,6 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Audio;
-using osu.Game.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
@@ -69,7 +68,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
}
[BackgroundDependencyLoader]
- private void load(OsuColour colours)
+ private void load()
{
Origin = Anchor.Centre;
RelativeSizeAxes = Axes.Both;
diff --git a/osu.Game.Rulesets.Osu/Objects/Spinner.cs b/osu.Game.Rulesets.Osu/Objects/Spinner.cs
index 0ad8e4ea68..1eddfb7fef 100644
--- a/osu.Game.Rulesets.Osu/Objects/Spinner.cs
+++ b/osu.Game.Rulesets.Osu/Objects/Spinner.cs
@@ -65,8 +65,8 @@ namespace osu.Game.Rulesets.Osu.Objects
double startTime = StartTime + (float)(i + 1) / totalSpins * Duration;
AddNested(i < SpinsRequired
- ? new SpinnerTick { StartTime = startTime }
- : new SpinnerBonusTick { StartTime = startTime });
+ ? new SpinnerTick { StartTime = startTime, Position = Position }
+ : new SpinnerBonusTick { StartTime = startTime, Position = Position });
}
}
diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/SpinnerBackgroundLayer.cs b/osu.Game.Rulesets.Osu/Skinning/Default/SpinnerBackgroundLayer.cs
index f8a6e1d3c9..a1184a15cd 100644
--- a/osu.Game.Rulesets.Osu/Skinning/Default/SpinnerBackgroundLayer.cs
+++ b/osu.Game.Rulesets.Osu/Skinning/Default/SpinnerBackgroundLayer.cs
@@ -3,15 +3,13 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
-using osu.Game.Graphics;
-using osu.Game.Rulesets.Objects.Drawables;
namespace osu.Game.Rulesets.Osu.Skinning.Default
{
public class SpinnerBackgroundLayer : SpinnerFill
{
[BackgroundDependencyLoader]
- private void load(OsuColour colours, DrawableHitObject drawableHitObject)
+ private void load()
{
Disc.Alpha = 0;
Anchor = Anchor.Centre;
diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyCursorParticles.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyCursorParticles.cs
index 611ddd08eb..b511444c44 100644
--- a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyCursorParticles.cs
+++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyCursorParticles.cs
@@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
private GameplayState gameplayState { get; set; }
[BackgroundDependencyLoader]
- private void load(ISkinSource skin, OsuColour colours)
+ private void load(ISkinSource skin)
{
var texture = skin.GetTexture("star2");
var starBreakAdditive = skin.GetConfig(OsuSkinColour.StarBreakAdditive)?.Value ?? new Color4(255, 182, 193, 255);
diff --git a/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs b/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs
index db4a6eb50b..6c76da7925 100644
--- a/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs
+++ b/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs
@@ -174,7 +174,7 @@ namespace osu.Game.Rulesets.Osu.Statistics
pointGrid.Content = points;
- if (score.HitEvents == null || score.HitEvents.Count == 0)
+ if (score.HitEvents.Count == 0)
return;
// Todo: This should probably not be done like this.
diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
index d1d9ee9f4d..b60ea5da21 100644
--- a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
+++ b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
@@ -58,7 +58,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
private OsuConfigManager config { get; set; }
[BackgroundDependencyLoader(true)]
- private void load(OsuConfigManager config, OsuRulesetConfigManager rulesetConfig)
+ private void load(OsuRulesetConfigManager rulesetConfig)
{
rulesetConfig?.BindWith(OsuRulesetSetting.ShowCursorTrail, showTrail);
}
diff --git a/osu.Game.Rulesets.Taiko.Tests/DrawableTaikoRulesetTestScene.cs b/osu.Game.Rulesets.Taiko.Tests/DrawableTaikoRulesetTestScene.cs
index 4bdb85ba60..f5e7304c12 100644
--- a/osu.Game.Rulesets.Taiko.Tests/DrawableTaikoRulesetTestScene.cs
+++ b/osu.Game.Rulesets.Taiko.Tests/DrawableTaikoRulesetTestScene.cs
@@ -32,12 +32,12 @@ namespace osu.Game.Rulesets.Taiko.Tests
HitObjects = new List { new Hit { Type = HitType.Centre } },
BeatmapInfo = new BeatmapInfo
{
- BaseDifficulty = new BeatmapDifficulty(),
+ Difficulty = new BeatmapDifficulty(),
Metadata = new BeatmapMetadata
{
Artist = @"Unknown",
Title = @"Sample Beatmap",
- AuthorString = @"peppy",
+ Author = { Username = @"peppy" },
},
Ruleset = new TaikoRuleset().RulesetInfo
},
diff --git a/osu.Game.Rulesets.Taiko.Tests/Editor/TestSceneTaikoHitObjectComposer.cs b/osu.Game.Rulesets.Taiko.Tests/Editor/TestSceneTaikoHitObjectComposer.cs
index 626537053a..55eb2fa66b 100644
--- a/osu.Game.Rulesets.Taiko.Tests/Editor/TestSceneTaikoHitObjectComposer.cs
+++ b/osu.Game.Rulesets.Taiko.Tests/Editor/TestSceneTaikoHitObjectComposer.cs
@@ -40,10 +40,10 @@ namespace osu.Game.Rulesets.Taiko.Tests.Editor
{
InternalChildren = new Drawable[]
{
- EditorBeatmap = new EditorBeatmap(new TaikoBeatmap())
+ EditorBeatmap = new EditorBeatmap(new TaikoBeatmap
{
BeatmapInfo = { Ruleset = new TaikoRuleset().RulesetInfo }
- },
+ }),
new TaikoHitObjectComposer(new TaikoRuleset())
};
diff --git a/osu.Game.Rulesets.Taiko.Tests/Skinning/TestSceneDrawableTaikoMascot.cs b/osu.Game.Rulesets.Taiko.Tests/Skinning/TestSceneDrawableTaikoMascot.cs
index b976735223..920a7cd1a1 100644
--- a/osu.Game.Rulesets.Taiko.Tests/Skinning/TestSceneDrawableTaikoMascot.cs
+++ b/osu.Game.Rulesets.Taiko.Tests/Skinning/TestSceneDrawableTaikoMascot.cs
@@ -158,12 +158,12 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
HitObjects = new List { new Hit { Type = HitType.Centre } },
BeatmapInfo = new BeatmapInfo
{
- BaseDifficulty = new BeatmapDifficulty(),
+ Difficulty = new BeatmapDifficulty(),
Metadata = new BeatmapMetadata
{
Artist = "Unknown",
Title = "Sample Beatmap",
- AuthorString = "Craftplacer",
+ Author = { Username = "Craftplacer" },
},
Ruleset = new TaikoRuleset().RulesetInfo
},
diff --git a/osu.Game.Rulesets.Taiko.Tests/TestSceneDrumRollJudgements.cs b/osu.Game.Rulesets.Taiko.Tests/TestSceneDrumRollJudgements.cs
new file mode 100644
index 0000000000..060c3c9443
--- /dev/null
+++ b/osu.Game.Rulesets.Taiko.Tests/TestSceneDrumRollJudgements.cs
@@ -0,0 +1,36 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Linq;
+using NUnit.Framework;
+using osu.Game.Beatmaps;
+using osu.Game.Rulesets.Taiko.Objects;
+
+namespace osu.Game.Rulesets.Taiko.Tests
+{
+ public class TestSceneDrumRollJudgements : TestSceneTaikoPlayer
+ {
+ [Test]
+ public void TestStrongDrumRollFullyJudgedOnKilled()
+ {
+ AddUntilStep("gameplay finished", () => Player.ScoreProcessor.HasCompleted.Value);
+ AddAssert("all judgements are misses", () => Player.Results.All(r => r.Type == r.Judgement.MinResult));
+ }
+
+ protected override bool Autoplay => false;
+
+ protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new Beatmap
+ {
+ BeatmapInfo = { Ruleset = new TaikoRuleset().RulesetInfo },
+ HitObjects =
+ {
+ new DrumRoll
+ {
+ StartTime = 1000,
+ Duration = 1000,
+ IsStrong = true
+ }
+ }
+ };
+ }
+}
diff --git a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs
index 9b2e9fedc5..613874b7d6 100644
--- a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs
+++ b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs
@@ -191,6 +191,9 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
protected override Beatmap CreateBeatmap() => new TaikoBeatmap();
+ // Important to note that this is subclassing a realm object.
+ // Realm doesn't allow this, but for now this can work since we aren't (in theory?) persisting this to the database.
+ // It is only used during beatmap conversion and processing.
internal class TaikoMultiplierAppliedDifficulty : BeatmapDifficulty
{
public TaikoMultiplierAppliedDifficulty(IBeatmapDifficultyInfo difficulty)
@@ -205,6 +208,8 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
#region Overrides of BeatmapDifficulty
+ public override BeatmapDifficulty Clone() => new TaikoMultiplierAppliedDifficulty(this);
+
public override void CopyTo(BeatmapDifficulty other)
{
base.CopyTo(other);
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs
index 521189d36c..b84db513f7 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs
@@ -197,6 +197,14 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
ApplyResult(r => r.Type = ParentHitObject.IsHit ? r.Judgement.MaxResult : r.Judgement.MinResult);
}
+ public override void OnKilled()
+ {
+ base.OnKilled();
+
+ if (Time.Current > ParentHitObject.HitObject.GetEndTime() && !Judged)
+ ApplyResult(r => r.Type = r.Judgement.MinResult);
+ }
+
public override bool OnPressed(KeyBindingPressEvent e) => false;
}
}
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs
index dc2ed200a1..e24923e482 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs
@@ -5,6 +5,7 @@ using System;
using JetBrains.Annotations;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
+using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Skinning.Default;
using osu.Game.Skinning;
@@ -52,6 +53,14 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
ApplyResult(r => r.Type = r.Judgement.MaxResult);
}
+ public override void OnKilled()
+ {
+ base.OnKilled();
+
+ if (Time.Current > HitObject.GetEndTime() && !Judged)
+ ApplyResult(r => r.Type = r.Judgement.MinResult);
+ }
+
protected override void UpdateHitStateTransforms(ArmedState state)
{
switch (state)
@@ -92,6 +101,14 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
ApplyResult(r => r.Type = ParentHitObject.IsHit ? r.Judgement.MaxResult : r.Judgement.MinResult);
}
+ public override void OnKilled()
+ {
+ base.OnKilled();
+
+ if (Time.Current > ParentHitObject.HitObject.GetEndTime() && !Judged)
+ ApplyResult(r => r.Type = r.Judgement.MinResult);
+ }
+
public override bool OnPressed(KeyBindingPressEvent e) => false;
}
}
diff --git a/osu.Game.Rulesets.Taiko/Skinning/Default/CentreHitCirclePiece.cs b/osu.Game.Rulesets.Taiko/Skinning/Default/CentreHitCirclePiece.cs
index 455b2fc596..25f895708f 100644
--- a/osu.Game.Rulesets.Taiko/Skinning/Default/CentreHitCirclePiece.cs
+++ b/osu.Game.Rulesets.Taiko/Skinning/Default/CentreHitCirclePiece.cs
@@ -5,7 +5,6 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
-using osu.Game.Graphics;
using osu.Game.Rulesets.Taiko.Objects;
using osuTK;
@@ -19,7 +18,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Default
}
[BackgroundDependencyLoader]
- private void load(OsuColour colours)
+ private void load()
{
AccentColour = Hit.COLOUR_CENTRE;
}
diff --git a/osu.Game.Rulesets.Taiko/Skinning/Default/RimHitCirclePiece.cs b/osu.Game.Rulesets.Taiko/Skinning/Default/RimHitCirclePiece.cs
index bd21d511b1..c6165495d8 100644
--- a/osu.Game.Rulesets.Taiko/Skinning/Default/RimHitCirclePiece.cs
+++ b/osu.Game.Rulesets.Taiko/Skinning/Default/RimHitCirclePiece.cs
@@ -5,7 +5,6 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
-using osu.Game.Graphics;
using osu.Game.Rulesets.Taiko.Objects;
using osuTK;
using osuTK.Graphics;
@@ -20,7 +19,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Default
}
[BackgroundDependencyLoader]
- private void load(OsuColour colours)
+ private void load()
{
AccentColour = Hit.COLOUR_RIM;
}
diff --git a/osu.Game.Rulesets.Taiko/UI/DrawableTaikoMascot.cs b/osu.Game.Rulesets.Taiko/UI/DrawableTaikoMascot.cs
index e1063e1071..7ba2618a63 100644
--- a/osu.Game.Rulesets.Taiko/UI/DrawableTaikoMascot.cs
+++ b/osu.Game.Rulesets.Taiko/UI/DrawableTaikoMascot.cs
@@ -7,7 +7,6 @@ using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
-using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Containers;
using osu.Game.Rulesets.Judgements;
@@ -39,7 +38,7 @@ namespace osu.Game.Rulesets.Taiko.UI
}
[BackgroundDependencyLoader(true)]
- private void load(TextureStore textures, GameplayState gameplayState)
+ private void load(GameplayState gameplayState)
{
InternalChildren = new[]
{
diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs
index 677aaf6f78..6ec14e6351 100644
--- a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs
+++ b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs
@@ -117,7 +117,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.AreEqual(string.Empty, metadata.Source);
Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", metadata.Tags);
Assert.AreEqual(557821, beatmapInfo.OnlineID);
- Assert.AreEqual(241526, beatmapInfo.BeatmapSet.OnlineID);
+ Assert.AreEqual(241526, beatmapInfo.BeatmapSet?.OnlineID);
}
}
diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyScoreDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyScoreDecoderTest.cs
index 9ac7838821..3d4b05b52b 100644
--- a/osu.Game.Tests/Beatmaps/Formats/LegacyScoreDecoderTest.cs
+++ b/osu.Game.Tests/Beatmaps/Formats/LegacyScoreDecoderTest.cs
@@ -128,7 +128,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
{
MD5Hash = md5Hash,
Ruleset = new OsuRuleset().RulesetInfo,
- BaseDifficulty = new BeatmapDifficulty()
+ Difficulty = new BeatmapDifficulty()
}
});
}
diff --git a/osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs
index bfd6ff0314..06ed638e0a 100644
--- a/osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs
+++ b/osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs
@@ -31,7 +31,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
{
var beatmap = decodeAsJson(normal);
var meta = beatmap.BeatmapInfo.Metadata;
- Assert.AreEqual(241526, beatmap.BeatmapInfo.BeatmapSet.OnlineID);
+ Assert.AreEqual(241526, beatmap.BeatmapInfo.BeatmapSet?.OnlineID);
Assert.AreEqual("Soleily", meta.Artist);
Assert.AreEqual("Soleily", meta.ArtistUnicode);
Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile);
diff --git a/osu.Game.Tests/Beatmaps/IO/BeatmapImportHelper.cs b/osu.Game.Tests/Beatmaps/IO/BeatmapImportHelper.cs
new file mode 100644
index 0000000000..44f6943871
--- /dev/null
+++ b/osu.Game.Tests/Beatmaps/IO/BeatmapImportHelper.cs
@@ -0,0 +1,86 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Game.Beatmaps;
+using osu.Game.Database;
+using osu.Game.Tests.Database;
+using osu.Game.Tests.Resources;
+
+namespace osu.Game.Tests.Beatmaps.IO
+{
+ public static class BeatmapImportHelper
+ {
+ public static async Task LoadQuickOszIntoOsu(OsuGameBase osu)
+ {
+ string temp = TestResources.GetQuickTestBeatmapForImport();
+
+ var manager = osu.Dependencies.Get();
+
+ var importedSet = await manager.Import(new ImportTask(temp)).ConfigureAwait(false);
+
+ Debug.Assert(importedSet != null);
+
+ ensureLoaded(osu);
+
+ waitForOrAssert(() => !File.Exists(temp), "Temporary file still exists after standard import", 5000);
+
+ return manager.GetAllUsableBeatmapSets().Find(beatmapSet => beatmapSet.ID == importedSet.ID);
+ }
+
+ public static async Task LoadOszIntoOsu(OsuGameBase osu, string path = null, bool virtualTrack = false)
+ {
+ string temp = path ?? TestResources.GetTestBeatmapForImport(virtualTrack);
+
+ var manager = osu.Dependencies.Get();
+
+ var importedSet = await manager.Import(new ImportTask(temp)).ConfigureAwait(false);
+
+ Debug.Assert(importedSet != null);
+
+ ensureLoaded(osu);
+
+ waitForOrAssert(() => !File.Exists(temp), "Temporary file still exists after standard import", 5000);
+
+ return manager.GetAllUsableBeatmapSets().Find(beatmapSet => beatmapSet.ID == importedSet.ID);
+ }
+
+ private static void ensureLoaded(OsuGameBase osu, int timeout = 60000)
+ {
+ var realmContextFactory = osu.Dependencies.Get();
+
+ using (var realm = realmContextFactory.CreateContext())
+ BeatmapImporterTests.EnsureLoaded(realm, timeout);
+
+ // TODO: add back some extra checks outside of the realm ones?
+ // var set = queryBeatmapSets().First();
+ // foreach (BeatmapInfo b in set.Beatmaps)
+ // Assert.IsTrue(set.Beatmaps.Any(c => c.OnlineID == b.OnlineID));
+ // Assert.IsTrue(set.Beatmaps.Count > 0);
+ // var beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 0))?.Beatmap;
+ // Assert.IsTrue(beatmap?.HitObjects.Any() == true);
+ // beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 1))?.Beatmap;
+ // Assert.IsTrue(beatmap?.HitObjects.Any() == true);
+ // beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 2))?.Beatmap;
+ // Assert.IsTrue(beatmap?.HitObjects.Any() == true);
+ // beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 3))?.Beatmap;
+ // Assert.IsTrue(beatmap?.HitObjects.Any() == true);
+ }
+
+ private static void waitForOrAssert(Func result, string failureMessage, int timeout = 60000)
+ {
+ Task task = Task.Run(() =>
+ {
+ while (!result()) Thread.Sleep(200);
+ });
+
+ Assert.IsTrue(task.Wait(timeout), failureMessage);
+ }
+ }
+}
diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs
deleted file mode 100644
index c02141bf9f..0000000000
--- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs
+++ /dev/null
@@ -1,1106 +0,0 @@
-// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
-// See the LICENCE file in the repository root for full licence text.
-
-using System;
-using System.IO;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using NUnit.Framework;
-using osu.Framework.Platform;
-using osu.Game.IPC;
-using osu.Framework.Allocation;
-using osu.Framework.Extensions;
-using osu.Framework.Extensions.ObjectExtensions;
-using osu.Framework.Logging;
-using osu.Game.Beatmaps;
-using osu.Game.Database;
-using osu.Game.Extensions;
-using osu.Game.IO;
-using osu.Game.Online.API.Requests.Responses;
-using osu.Game.Overlays.Notifications;
-using osu.Game.Rulesets.Osu;
-using osu.Game.Rulesets.Osu.Objects;
-using osu.Game.Scoring;
-using osu.Game.Tests.Resources;
-using osu.Game.Tests.Scores.IO;
-using SharpCompress.Archives;
-using SharpCompress.Archives.Zip;
-using SharpCompress.Common;
-using SharpCompress.Writers.Zip;
-using FileInfo = System.IO.FileInfo;
-
-namespace osu.Game.Tests.Beatmaps.IO
-{
- [TestFixture]
- public class ImportBeatmapTest : ImportTest
- {
- [Test]
- public async Task TestImportWhenClosed()
- {
- // unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- await LoadOszIntoOsu(LoadOsuIntoHost(host));
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public async Task TestImportThenDelete()
- {
- // unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
-
- var imported = await LoadOszIntoOsu(osu);
-
- deleteBeatmapSet(imported, osu);
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public async Task TestImportThenDeleteFromStream()
- {
- // unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
-
- string tempPath = TestResources.GetTestBeatmapForImport();
-
- var manager = osu.Dependencies.Get();
-
- ILive importedSet;
-
- using (var stream = File.OpenRead(tempPath))
- {
- importedSet = await manager.Import(new ImportTask(stream, Path.GetFileName(tempPath)));
- await ensureLoaded(osu);
- }
-
- Assert.IsTrue(File.Exists(tempPath), "Stream source file somehow went missing");
- File.Delete(tempPath);
-
- var imported = manager.GetAllUsableBeatmapSets().Find(beatmapSet => beatmapSet.ID == importedSet.Value.ID);
-
- deleteBeatmapSet(imported, osu);
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public async Task TestImportThenImport()
- {
- // unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
-
- var imported = await LoadOszIntoOsu(osu);
- var importedSecondTime = await LoadOszIntoOsu(osu);
-
- // check the newly "imported" beatmap is actually just the restored previous import. since it matches hash.
- Assert.IsTrue(imported.ID == importedSecondTime.ID);
- Assert.IsTrue(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID);
-
- checkBeatmapSetCount(osu, 1);
- checkSingleReferencedFileCount(osu, 18);
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public async Task TestImportThenImportWithReZip()
- {
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
-
- string temp = TestResources.GetTestBeatmapForImport();
-
- string extractedFolder = $"{temp}_extracted";
- Directory.CreateDirectory(extractedFolder);
-
- try
- {
- var imported = await LoadOszIntoOsu(osu);
-
- string hashBefore = hashFile(temp);
-
- using (var zip = ZipArchive.Open(temp))
- zip.WriteToDirectory(extractedFolder);
-
- using (var zip = ZipArchive.Create())
- {
- zip.AddAllFromDirectory(extractedFolder);
- zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate));
- }
-
- // zip files differ because different compression or encoder.
- Assert.AreNotEqual(hashBefore, hashFile(temp));
-
- var importedSecondTime = await osu.Dependencies.Get().Import(new ImportTask(temp));
-
- await ensureLoaded(osu);
-
- // but contents doesn't, so existing should still be used.
- Assert.IsTrue(imported.ID == importedSecondTime.Value.ID);
- Assert.IsTrue(imported.Beatmaps.First().ID == importedSecondTime.Value.Beatmaps.First().ID);
- }
- finally
- {
- Directory.Delete(extractedFolder, true);
- }
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public async Task TestImportThenImportWithChangedHashedFile()
- {
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
-
- string temp = TestResources.GetTestBeatmapForImport();
-
- string extractedFolder = $"{temp}_extracted";
- Directory.CreateDirectory(extractedFolder);
-
- try
- {
- var imported = await LoadOszIntoOsu(osu);
-
- await createScoreForBeatmap(osu, imported.Beatmaps.First());
-
- using (var zip = ZipArchive.Open(temp))
- zip.WriteToDirectory(extractedFolder);
-
- // arbitrary write to hashed file
- // this triggers the special BeatmapManager.PreImport deletion/replacement flow.
- using (var sw = new FileInfo(Directory.GetFiles(extractedFolder, "*.osu").First()).AppendText())
- await sw.WriteLineAsync("// changed");
-
- using (var zip = ZipArchive.Create())
- {
- zip.AddAllFromDirectory(extractedFolder);
- zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate));
- }
-
- var importedSecondTime = await osu.Dependencies.Get().Import(new ImportTask(temp));
-
- await ensureLoaded(osu);
-
- // check the newly "imported" beatmap is not the original.
- Assert.IsTrue(imported.ID != importedSecondTime.Value.ID);
- Assert.IsTrue(imported.Beatmaps.First().ID != importedSecondTime.Value.Beatmaps.First().ID);
- }
- finally
- {
- Directory.Delete(extractedFolder, true);
- }
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- [Ignore("intentionally broken by import optimisations")]
- public async Task TestImportThenImportWithChangedFile()
- {
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
-
- string temp = TestResources.GetTestBeatmapForImport();
-
- string extractedFolder = $"{temp}_extracted";
- Directory.CreateDirectory(extractedFolder);
-
- try
- {
- var imported = await LoadOszIntoOsu(osu);
-
- using (var zip = ZipArchive.Open(temp))
- zip.WriteToDirectory(extractedFolder);
-
- // arbitrary write to non-hashed file
- using (var sw = new FileInfo(Directory.GetFiles(extractedFolder, "*.mp3").First()).AppendText())
- await sw.WriteLineAsync("text");
-
- using (var zip = ZipArchive.Create())
- {
- zip.AddAllFromDirectory(extractedFolder);
- zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate));
- }
-
- var importedSecondTime = await osu.Dependencies.Get().Import(new ImportTask(temp));
-
- await ensureLoaded(osu);
-
- // check the newly "imported" beatmap is not the original.
- Assert.IsTrue(imported.ID != importedSecondTime.Value.ID);
- Assert.IsTrue(imported.Beatmaps.First().ID != importedSecondTime.Value.Beatmaps.First().ID);
- }
- finally
- {
- Directory.Delete(extractedFolder, true);
- }
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public async Task TestImportThenImportWithDifferentFilename()
- {
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
-
- string temp = TestResources.GetTestBeatmapForImport();
-
- string extractedFolder = $"{temp}_extracted";
- Directory.CreateDirectory(extractedFolder);
-
- try
- {
- var imported = await LoadOszIntoOsu(osu);
-
- using (var zip = ZipArchive.Open(temp))
- zip.WriteToDirectory(extractedFolder);
-
- // change filename
- var firstFile = new FileInfo(Directory.GetFiles(extractedFolder).First());
- firstFile.MoveTo(Path.Combine(firstFile.DirectoryName.AsNonNull(), $"{firstFile.Name}-changed{firstFile.Extension}"));
-
- using (var zip = ZipArchive.Create())
- {
- zip.AddAllFromDirectory(extractedFolder);
- zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate));
- }
-
- var importedSecondTime = await osu.Dependencies.Get().Import(new ImportTask(temp));
-
- await ensureLoaded(osu);
-
- // check the newly "imported" beatmap is not the original.
- Assert.IsTrue(imported.ID != importedSecondTime.Value.ID);
- Assert.IsTrue(imported.Beatmaps.First().ID != importedSecondTime.Value.Beatmaps.First().ID);
- }
- finally
- {
- Directory.Delete(extractedFolder, true);
- }
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- [Ignore("intentionally broken by import optimisations")]
- public async Task TestImportCorruptThenImport()
- {
- // unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
-
- var imported = await LoadOszIntoOsu(osu);
-
- var firstFile = imported.Files.First();
-
- var files = osu.Dependencies.Get();
-
- long originalLength;
- using (var stream = files.Storage.GetStream(firstFile.FileInfo.GetStoragePath()))
- originalLength = stream.Length;
-
- using (var stream = files.Storage.GetStream(firstFile.FileInfo.GetStoragePath(), FileAccess.Write, FileMode.Create))
- stream.WriteByte(0);
-
- var importedSecondTime = await LoadOszIntoOsu(osu);
-
- using (var stream = files.Storage.GetStream(firstFile.FileInfo.GetStoragePath()))
- Assert.AreEqual(stream.Length, originalLength, "Corruption was not fixed on second import");
-
- // check the newly "imported" beatmap is actually just the restored previous import. since it matches hash.
- Assert.IsTrue(imported.ID == importedSecondTime.ID);
- Assert.IsTrue(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID);
-
- checkBeatmapSetCount(osu, 1);
- checkSingleReferencedFileCount(osu, 18);
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public async Task TestModelCreationFailureDoesntReturn()
- {
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
- var importer = osu.Dependencies.Get();
-
- var progressNotification = new ImportProgressNotification();
-
- var zipStream = new MemoryStream();
-
- using (var zip = ZipArchive.Create())
- zip.SaveTo(zipStream, new ZipWriterOptions(CompressionType.Deflate));
-
- var imported = await importer.Import(
- progressNotification,
- new ImportTask(zipStream, string.Empty)
- );
-
- checkBeatmapSetCount(osu, 0);
- checkBeatmapCount(osu, 0);
-
- Assert.IsEmpty(imported);
- Assert.AreEqual(ProgressNotificationState.Cancelled, progressNotification.State);
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public async Task TestRollbackOnFailure()
- {
- // unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- int itemAddRemoveFireCount = 0;
- int loggedExceptionCount = 0;
-
- Logger.NewEntry += l =>
- {
- if (l.Target == LoggingTarget.Database && l.Exception != null)
- Interlocked.Increment(ref loggedExceptionCount);
- };
-
- var osu = LoadOsuIntoHost(host);
- var manager = osu.Dependencies.Get();
-
- // ReSharper disable once AccessToModifiedClosure
- manager.ItemUpdated += _ => Interlocked.Increment(ref itemAddRemoveFireCount);
- manager.ItemRemoved += _ => Interlocked.Increment(ref itemAddRemoveFireCount);
-
- var imported = await LoadOszIntoOsu(osu);
-
- Assert.AreEqual(0, itemAddRemoveFireCount -= 1);
-
- imported.Hash += "-changed";
- manager.Update(imported);
-
- Assert.AreEqual(0, itemAddRemoveFireCount -= 1);
-
- checkBeatmapSetCount(osu, 1);
- checkBeatmapCount(osu, 12);
- checkSingleReferencedFileCount(osu, 18);
-
- string brokenTempFilename = TestResources.GetTestBeatmapForImport();
-
- MemoryStream brokenOsu = new MemoryStream();
- MemoryStream brokenOsz = new MemoryStream(await File.ReadAllBytesAsync(brokenTempFilename));
-
- File.Delete(brokenTempFilename);
-
- using (var outStream = File.Open(brokenTempFilename, FileMode.CreateNew))
- using (var zip = ZipArchive.Open(brokenOsz))
- {
- zip.AddEntry("broken.osu", brokenOsu, false);
- zip.SaveTo(outStream, CompressionType.Deflate);
- }
-
- // this will trigger purging of the existing beatmap (online set id match) but should rollback due to broken osu.
- try
- {
- await manager.Import(new ImportTask(brokenTempFilename));
- }
- catch
- {
- }
-
- // no events should be fired in the case of a rollback.
- Assert.AreEqual(0, itemAddRemoveFireCount);
-
- checkBeatmapSetCount(osu, 1);
- checkBeatmapCount(osu, 12);
-
- checkSingleReferencedFileCount(osu, 18);
-
- Assert.AreEqual(1, loggedExceptionCount);
-
- File.Delete(brokenTempFilename);
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public async Task TestImportThenDeleteThenImport()
- {
- // unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
-
- var imported = await LoadOszIntoOsu(osu);
-
- deleteBeatmapSet(imported, osu);
-
- var importedSecondTime = await LoadOszIntoOsu(osu);
-
- // check the newly "imported" beatmap is actually just the restored previous import. since it matches hash.
- Assert.IsTrue(imported.ID == importedSecondTime.ID);
- Assert.IsTrue(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID);
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public async Task TestImportThenDeleteThenImportWithOnlineIDsMissing()
- {
- // unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
-
- var imported = await LoadOszIntoOsu(osu);
-
- foreach (var b in imported.Beatmaps)
- b.OnlineID = null;
-
- osu.Dependencies.Get().Update(imported);
-
- deleteBeatmapSet(imported, osu);
-
- var importedSecondTime = await LoadOszIntoOsu(osu);
-
- // check the newly "imported" beatmap has been reimported due to mismatch (even though hashes matched)
- Assert.IsTrue(imported.ID != importedSecondTime.ID);
- Assert.IsTrue(imported.Beatmaps.First().ID != importedSecondTime.Beatmaps.First().ID);
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public async Task TestImportWithDuplicateBeatmapIDs()
- {
- // unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
-
- var metadata = new BeatmapMetadata
- {
- Artist = "SomeArtist",
- AuthorString = "SomeAuthor"
- };
-
- var difficulty = new BeatmapDifficulty();
-
- var toImport = new BeatmapSetInfo
- {
- OnlineID = 1,
- Metadata = metadata,
- Beatmaps =
- {
- new BeatmapInfo
- {
- OnlineID = 2,
- Metadata = metadata,
- BaseDifficulty = difficulty
- },
- new BeatmapInfo
- {
- OnlineID = 2,
- Metadata = metadata,
- Status = BeatmapOnlineStatus.Loved,
- BaseDifficulty = difficulty
- }
- }
- };
-
- var manager = osu.Dependencies.Get();
-
- var imported = await manager.Import(toImport);
-
- Assert.NotNull(imported);
- Assert.AreEqual(null, imported.Value.Beatmaps[0].OnlineID);
- Assert.AreEqual(null, imported.Value.Beatmaps[1].OnlineID);
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- [NonParallelizable]
- public void TestImportOverIPC()
- {
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost(true))
- using (HeadlessGameHost client = new CleanRunHeadlessGameHost(true))
- {
- try
- {
- Assert.IsTrue(host.IsPrimaryInstance);
- Assert.IsFalse(client.IsPrimaryInstance);
-
- var osu = LoadOsuIntoHost(host);
-
- string temp = TestResources.GetTestBeatmapForImport();
-
- var importer = new ArchiveImportIPCChannel(client);
- if (!importer.ImportAsync(temp).Wait(10000))
- Assert.Fail(@"IPC took too long to send");
-
- ensureLoaded(osu).WaitSafely();
-
- waitForOrAssert(() => !File.Exists(temp), "Temporary still exists after IPC import", 5000);
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public async Task TestImportWhenFileOpen()
- {
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
- string temp = TestResources.GetTestBeatmapForImport();
- using (File.OpenRead(temp))
- await osu.Dependencies.Get().Import(temp);
- await ensureLoaded(osu);
- File.Delete(temp);
- Assert.IsFalse(File.Exists(temp), "We likely held a read lock on the file when we shouldn't");
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public async Task TestImportWithDuplicateHashes()
- {
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
-
- string temp = TestResources.GetTestBeatmapForImport();
-
- string extractedFolder = $"{temp}_extracted";
- Directory.CreateDirectory(extractedFolder);
-
- try
- {
- using (var zip = ZipArchive.Open(temp))
- zip.WriteToDirectory(extractedFolder);
-
- using (var zip = ZipArchive.Create())
- {
- zip.AddAllFromDirectory(extractedFolder);
- zip.AddEntry("duplicate.osu", Directory.GetFiles(extractedFolder, "*.osu").First());
- zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate));
- }
-
- await osu.Dependencies.Get().Import(temp);
-
- await ensureLoaded(osu);
- }
- finally
- {
- Directory.Delete(extractedFolder, true);
- }
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public async Task TestImportNestedStructure()
- {
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
-
- string temp = TestResources.GetTestBeatmapForImport();
-
- string extractedFolder = $"{temp}_extracted";
- string subfolder = Path.Combine(extractedFolder, "subfolder");
-
- Directory.CreateDirectory(subfolder);
-
- try
- {
- using (var zip = ZipArchive.Open(temp))
- zip.WriteToDirectory(subfolder);
-
- using (var zip = ZipArchive.Create())
- {
- zip.AddAllFromDirectory(extractedFolder);
- zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate));
- }
-
- var imported = await osu.Dependencies.Get().Import(new ImportTask(temp));
-
- await ensureLoaded(osu);
-
- Assert.IsFalse(imported.Value.Files.Any(f => f.Filename.Contains("subfolder")), "Files contain common subfolder");
- }
- finally
- {
- Directory.Delete(extractedFolder, true);
- }
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public async Task TestImportWithIgnoredDirectoryInArchive()
- {
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
-
- string temp = TestResources.GetTestBeatmapForImport();
-
- string extractedFolder = $"{temp}_extracted";
- string dataFolder = Path.Combine(extractedFolder, "actual_data");
- string resourceForkFolder = Path.Combine(extractedFolder, "__MACOSX");
- string resourceForkFilePath = Path.Combine(resourceForkFolder, ".extracted");
-
- Directory.CreateDirectory(dataFolder);
- Directory.CreateDirectory(resourceForkFolder);
-
- using (var resourceForkFile = File.CreateText(resourceForkFilePath))
- {
- await resourceForkFile.WriteLineAsync("adding content so that it's not empty");
- }
-
- try
- {
- using (var zip = ZipArchive.Open(temp))
- zip.WriteToDirectory(dataFolder);
-
- using (var zip = ZipArchive.Create())
- {
- zip.AddAllFromDirectory(extractedFolder);
- zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate));
- }
-
- var imported = await osu.Dependencies.Get().Import(new ImportTask(temp));
-
- await ensureLoaded(osu);
-
- Assert.IsFalse(imported.Value.Files.Any(f => f.Filename.Contains("__MACOSX")), "Files contain resource fork folder, which should be ignored");
- Assert.IsFalse(imported.Value.Files.Any(f => f.Filename.Contains("actual_data")), "Files contain common subfolder");
- }
- finally
- {
- Directory.Delete(extractedFolder, true);
- }
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public void TestUpdateBeatmapInfo()
- {
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
- var manager = osu.Dependencies.Get();
-
- string temp = TestResources.GetTestBeatmapForImport();
-
- osu.Dependencies.Get().Import(temp).WaitSafely();
-
- // Update via the beatmap, not the beatmap info, to ensure correct linking
- BeatmapSetInfo setToUpdate = manager.GetAllUsableBeatmapSets()[0];
- Beatmap beatmapToUpdate = (Beatmap)manager.GetWorkingBeatmap(setToUpdate.Beatmaps.First(b => b.RulesetID == 0)).Beatmap;
- beatmapToUpdate.BeatmapInfo.DifficultyName = "updated";
-
- manager.Update(setToUpdate);
-
- BeatmapInfo updatedInfo = manager.QueryBeatmap(b => b.ID == beatmapToUpdate.BeatmapInfo.ID);
- Assert.That(updatedInfo.DifficultyName, Is.EqualTo("updated"));
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public void TestUpdateBeatmapFile()
- {
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
- var manager = osu.Dependencies.Get();
-
- string temp = TestResources.GetTestBeatmapForImport();
-
- osu.Dependencies.Get().Import(temp).WaitSafely();
-
- BeatmapSetInfo setToUpdate = manager.GetAllUsableBeatmapSets()[0];
-
- var beatmapInfo = setToUpdate.Beatmaps.First(b => b.RulesetID == 0);
- Beatmap beatmapToUpdate = (Beatmap)manager.GetWorkingBeatmap(setToUpdate.Beatmaps.First(b => b.RulesetID == 0)).Beatmap;
- BeatmapSetFileInfo fileToUpdate = setToUpdate.Files.First(f => beatmapToUpdate.BeatmapInfo.Path.Contains(f.Filename));
-
- string oldMd5Hash = beatmapToUpdate.BeatmapInfo.MD5Hash;
-
- beatmapToUpdate.HitObjects.Clear();
- beatmapToUpdate.HitObjects.Add(new HitCircle { StartTime = 5000 });
-
- manager.Save(beatmapInfo, beatmapToUpdate);
-
- // Check that the old file reference has been removed
- Assert.That(manager.QueryBeatmapSet(s => s.ID == setToUpdate.ID).Files.All(f => f.ID != fileToUpdate.ID));
-
- // Check that the new file is referenced correctly by attempting a retrieval
- Beatmap updatedBeatmap = (Beatmap)manager.GetWorkingBeatmap(manager.QueryBeatmap(b => b.ID == beatmapToUpdate.BeatmapInfo.ID)).Beatmap;
- Assert.That(updatedBeatmap.HitObjects.Count, Is.EqualTo(1));
- Assert.That(updatedBeatmap.HitObjects[0].StartTime, Is.EqualTo(5000));
- Assert.That(updatedBeatmap.BeatmapInfo.MD5Hash, Is.Not.EqualTo(oldMd5Hash));
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- // TODO: needs to be pulled across to realm implementation when this file is nuked.
- [Test]
- public void TestSaveRemovesInvalidCharactersFromPath()
- {
- // unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
-
- var manager = osu.Dependencies.Get();
-
- var working = manager.CreateNew(new OsuRuleset().RulesetInfo, APIUser.SYSTEM_USER);
-
- var beatmap = working.Beatmap;
-
- beatmap.BeatmapInfo.DifficultyName = "difficulty";
- beatmap.BeatmapInfo.Metadata = new BeatmapMetadata
- {
- Artist = "Artist/With\\Slashes",
- Title = "Title",
- AuthorString = "mapper",
- };
-
- manager.Save(beatmap.BeatmapInfo, working.Beatmap);
-
- Assert.AreEqual("Artist_With_Slashes - Title (mapper) [difficulty].osu", beatmap.BeatmapInfo.Path);
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public void TestCreateNewEmptyBeatmap()
- {
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
- var manager = osu.Dependencies.Get();
-
- var working = manager.CreateNew(new OsuRuleset().RulesetInfo, APIUser.SYSTEM_USER);
-
- manager.Save(working.BeatmapInfo, working.Beatmap);
-
- var retrievedSet = manager.GetAllUsableBeatmapSets()[0];
-
- // Check that the new file is referenced correctly by attempting a retrieval
- Beatmap updatedBeatmap = (Beatmap)manager.GetWorkingBeatmap(retrievedSet.Beatmaps[0]).Beatmap;
- Assert.That(updatedBeatmap.HitObjects.Count, Is.EqualTo(0));
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- [Test]
- public void TestCreateNewBeatmapWithObject()
- {
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host);
- var manager = osu.Dependencies.Get();
-
- var working = manager.CreateNew(new OsuRuleset().RulesetInfo, APIUser.SYSTEM_USER);
-
- ((Beatmap)working.Beatmap).HitObjects.Add(new HitCircle { StartTime = 5000 });
-
- manager.Save(working.BeatmapInfo, working.Beatmap);
-
- var retrievedSet = manager.GetAllUsableBeatmapSets()[0];
-
- // Check that the new file is referenced correctly by attempting a retrieval
- Beatmap updatedBeatmap = (Beatmap)manager.GetWorkingBeatmap(retrievedSet.Beatmaps[0]).Beatmap;
- Assert.That(updatedBeatmap.HitObjects.Count, Is.EqualTo(1));
- Assert.That(updatedBeatmap.HitObjects[0].StartTime, Is.EqualTo(5000));
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
- public static Task LoadQuickOszIntoOsu(OsuGameBase osu) => Task.Factory.StartNew(() =>
- {
- string temp = TestResources.GetQuickTestBeatmapForImport();
-
- var manager = osu.Dependencies.Get();
-
- var importedSet = manager.Import(new ImportTask(temp)).GetResultSafely();
-
- ensureLoaded(osu).WaitSafely();
-
- waitForOrAssert(() => !File.Exists(temp), "Temporary file still exists after standard import", 5000);
-
- return manager.GetAllUsableBeatmapSets().Find(beatmapSet => beatmapSet.ID == importedSet.Value.ID);
- }, TaskCreationOptions.LongRunning);
-
- public static Task LoadOszIntoOsu(OsuGameBase osu, string path = null, bool virtualTrack = false) => Task.Factory.StartNew(() =>
- {
- string temp = path ?? TestResources.GetTestBeatmapForImport(virtualTrack);
-
- var manager = osu.Dependencies.Get();
-
- var importedSet = manager.Import(new ImportTask(temp)).GetResultSafely();
-
- ensureLoaded(osu).WaitSafely();
-
- waitForOrAssert(() => !File.Exists(temp), "Temporary file still exists after standard import", 5000);
-
- return manager.GetAllUsableBeatmapSets().Find(beatmapSet => beatmapSet.ID == importedSet.Value.ID);
- }, TaskCreationOptions.LongRunning);
-
- private void deleteBeatmapSet(BeatmapSetInfo imported, OsuGameBase osu)
- {
- var manager = osu.Dependencies.Get();
- manager.Delete(imported);
-
- checkBeatmapSetCount(osu, 0);
- checkBeatmapSetCount(osu, 1, true);
- checkSingleReferencedFileCount(osu, 0);
-
- Assert.IsTrue(manager.QueryBeatmapSets(_ => true).First().DeletePending);
- }
-
- private static Task createScoreForBeatmap(OsuGameBase osu, BeatmapInfo beatmapInfo)
- {
- return ImportScoreTest.LoadScoreIntoOsu(osu, new ScoreInfo
- {
- OnlineID = 2,
- BeatmapInfo = beatmapInfo,
- BeatmapInfoID = beatmapInfo.ID
- }, new ImportScoreTest.TestArchiveReader());
- }
-
- private static void checkBeatmapSetCount(OsuGameBase osu, int expected, bool includeDeletePending = false)
- {
- var manager = osu.Dependencies.Get();
-
- Assert.AreEqual(expected, includeDeletePending
- ? manager.QueryBeatmapSets(_ => true).ToList().Count
- : manager.GetAllUsableBeatmapSets().Count);
- }
-
- private static string hashFile(string filename)
- {
- using (var s = File.OpenRead(filename))
- return s.ComputeMD5Hash();
- }
-
- private static void checkBeatmapCount(OsuGameBase osu, int expected)
- {
- Assert.AreEqual(expected, osu.Dependencies.Get().QueryBeatmaps(_ => true).ToList().Count);
- }
-
- private static void checkSingleReferencedFileCount(OsuGameBase osu, int expected)
- {
- Assert.AreEqual(expected, osu.Dependencies.Get().Get().FileInfo.Count(f => f.ReferenceCount == 1));
- }
-
- private static Task ensureLoaded(OsuGameBase osu, int timeout = 60000) => Task.Factory.StartNew(() =>
- {
- IEnumerable resultSets = null;
- var store = osu.Dependencies.Get();
- waitForOrAssert(() => (resultSets = store.QueryBeatmapSets(s => s.OnlineID == 241526)).Any(),
- @"BeatmapSet did not import to the database in allocated time.", timeout);
-
- // ensure we were stored to beatmap database backing...
- Assert.IsTrue(resultSets.Count() == 1, $@"Incorrect result count found ({resultSets.Count()} but should be 1).");
- IEnumerable queryBeatmaps() => store.QueryBeatmaps(s => s.BeatmapSet.OnlineID == 241526 && s.BaseDifficultyID > 0);
- IEnumerable queryBeatmapSets() => store.QueryBeatmapSets(s => s.OnlineID == 241526);
-
- // if we don't re-check here, the set will be inserted but the beatmaps won't be present yet.
- waitForOrAssert(() => queryBeatmaps().Count() == 12,
- @"Beatmaps did not import to the database in allocated time", timeout);
- waitForOrAssert(() => queryBeatmapSets().Count() == 1,
- @"BeatmapSet did not import to the database in allocated time", timeout);
- int countBeatmapSetBeatmaps = 0;
- int countBeatmaps = 0;
- waitForOrAssert(() =>
- (countBeatmapSetBeatmaps = queryBeatmapSets().First().Beatmaps.Count) ==
- (countBeatmaps = queryBeatmaps().Count()),
- $@"Incorrect database beatmap count post-import ({countBeatmaps} but should be {countBeatmapSetBeatmaps}).", timeout);
-
- var set = queryBeatmapSets().First();
- foreach (BeatmapInfo b in set.Beatmaps)
- Assert.IsTrue(set.Beatmaps.Any(c => c.OnlineID == b.OnlineID));
- Assert.IsTrue(set.Beatmaps.Count > 0);
- var beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 0))?.Beatmap;
- Assert.IsTrue(beatmap?.HitObjects.Any() == true);
- beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 1))?.Beatmap;
- Assert.IsTrue(beatmap?.HitObjects.Any() == true);
- beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 2))?.Beatmap;
- Assert.IsTrue(beatmap?.HitObjects.Any() == true);
- beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 3))?.Beatmap;
- Assert.IsTrue(beatmap?.HitObjects.Any() == true);
- }, TaskCreationOptions.LongRunning);
-
- private static void waitForOrAssert(Func result, string failureMessage, int timeout = 60000)
- {
- Task task = Task.Factory.StartNew(() =>
- {
- while (!result()) Thread.Sleep(200);
- }, TaskCreationOptions.LongRunning);
-
- Assert.IsTrue(task.Wait(timeout), failureMessage);
- }
- }
-}
diff --git a/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs b/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs
index b2ab1eeaa6..810ea5dbd0 100644
--- a/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs
+++ b/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs
@@ -56,7 +56,7 @@ namespace osu.Game.Tests.Beatmaps.IO
var meta = beatmap.Metadata;
- Assert.AreEqual(241526, beatmap.BeatmapInfo.BeatmapSet.OnlineID);
+ Assert.AreEqual(241526, beatmap.BeatmapInfo.BeatmapSet?.OnlineID);
Assert.AreEqual("Soleily", meta.Artist);
Assert.AreEqual("Soleily", meta.ArtistUnicode);
Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile);
diff --git a/osu.Game.Tests/Beatmaps/TestSceneBeatmapDifficultyCache.cs b/osu.Game.Tests/Beatmaps/TestSceneBeatmapDifficultyCache.cs
index 26ab8808b9..f3456cf8e4 100644
--- a/osu.Game.Tests/Beatmaps/TestSceneBeatmapDifficultyCache.cs
+++ b/osu.Game.Tests/Beatmaps/TestSceneBeatmapDifficultyCache.cs
@@ -24,6 +24,8 @@ namespace osu.Game.Tests.Beatmaps
{
public const double BASE_STARS = 5.55;
+ private static readonly Guid guid = Guid.NewGuid();
+
private BeatmapSetInfo importedSet;
private TestBeatmapDifficultyCache difficultyCache;
@@ -33,7 +35,7 @@ namespace osu.Game.Tests.Beatmaps
[BackgroundDependencyLoader]
private void load(OsuGameBase osu)
{
- importedSet = ImportBeatmapTest.LoadQuickOszIntoOsu(osu).GetResultSafely();
+ importedSet = BeatmapImportHelper.LoadQuickOszIntoOsu(osu).GetResultSafely();
}
[SetUpSteps]
@@ -98,8 +100,8 @@ namespace osu.Game.Tests.Beatmaps
[Test]
public void TestKeyEqualsWithDifferentModInstances()
{
- var key1 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModHardRock(), new OsuModHidden() });
- var key2 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModHardRock(), new OsuModHidden() });
+ var key1 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = guid }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModHardRock(), new OsuModHidden() });
+ var key2 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = guid }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModHardRock(), new OsuModHidden() });
Assert.That(key1, Is.EqualTo(key2));
Assert.That(key1.GetHashCode(), Is.EqualTo(key2.GetHashCode()));
@@ -108,8 +110,8 @@ namespace osu.Game.Tests.Beatmaps
[Test]
public void TestKeyEqualsWithDifferentModOrder()
{
- var key1 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModHardRock(), new OsuModHidden() });
- var key2 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModHidden(), new OsuModHardRock() });
+ var key1 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = guid }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModHardRock(), new OsuModHidden() });
+ var key2 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = guid }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModHidden(), new OsuModHardRock() });
Assert.That(key1, Is.EqualTo(key2));
Assert.That(key1.GetHashCode(), Is.EqualTo(key2.GetHashCode()));
@@ -118,8 +120,8 @@ namespace osu.Game.Tests.Beatmaps
[Test]
public void TestKeyDoesntEqualWithDifferentModSettings()
{
- var key1 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 1.1 } } });
- var key2 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 1.9 } } });
+ var key1 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = guid }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 1.1 } } });
+ var key2 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = guid }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 1.9 } } });
Assert.That(key1, Is.Not.EqualTo(key2));
Assert.That(key1.GetHashCode(), Is.Not.EqualTo(key2.GetHashCode()));
@@ -128,8 +130,8 @@ namespace osu.Game.Tests.Beatmaps
[Test]
public void TestKeyEqualWithMatchingModSettings()
{
- var key1 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 1.25 } } });
- var key2 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 1.25 } } });
+ var key1 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = guid }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 1.25 } } });
+ var key2 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = guid }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 1.25 } } });
Assert.That(key1, Is.EqualTo(key2));
Assert.That(key1.GetHashCode(), Is.EqualTo(key2.GetHashCode()));
diff --git a/osu.Game.Tests/Beatmaps/TestSceneEditorBeatmap.cs b/osu.Game.Tests/Beatmaps/TestSceneEditorBeatmap.cs
index bf5b517603..153788c2cf 100644
--- a/osu.Game.Tests/Beatmaps/TestSceneEditorBeatmap.cs
+++ b/osu.Game.Tests/Beatmaps/TestSceneEditorBeatmap.cs
@@ -7,6 +7,7 @@ using System.Linq;
using NUnit.Framework;
using osu.Framework.Testing;
using osu.Game.Rulesets.Objects;
+using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Beatmaps;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit;
@@ -30,7 +31,13 @@ namespace osu.Game.Tests.Beatmaps
AddStep("add beatmap", () =>
{
- Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap());
+ Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap
+ {
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo,
+ },
+ });
editorBeatmap.HitObjectAdded += h => addedObject = h;
});
@@ -49,7 +56,14 @@ namespace osu.Game.Tests.Beatmaps
EditorBeatmap editorBeatmap = null;
AddStep("add beatmap", () =>
{
- Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap { HitObjects = { hitCircle } });
+ Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap
+ {
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo,
+ },
+ HitObjects = { hitCircle }
+ });
editorBeatmap.HitObjectRemoved += h => removedObject = h;
});
AddStep("remove hitobject", () => editorBeatmap.Remove(editorBeatmap.HitObjects.First()));
@@ -71,7 +85,14 @@ namespace osu.Game.Tests.Beatmaps
{
EditorBeatmap editorBeatmap;
- Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap { HitObjects = { hitCircle } });
+ Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap
+ {
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo,
+ },
+ HitObjects = { hitCircle }
+ });
editorBeatmap.HitObjectUpdated += h => changedObject = h;
});
@@ -91,7 +112,13 @@ namespace osu.Game.Tests.Beatmaps
AddStep("add beatmap", () =>
{
- Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap());
+ Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap
+ {
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo,
+ },
+ });
editorBeatmap.HitObjectUpdated += h => changedObject = h;
});
@@ -111,7 +138,14 @@ namespace osu.Game.Tests.Beatmaps
public void TestRemovedHitObjectStartTimeChangeEvent()
{
var hitCircle = new HitCircle();
- var editorBeatmap = new EditorBeatmap(new OsuBeatmap { HitObjects = { hitCircle } });
+ var editorBeatmap = new EditorBeatmap(new OsuBeatmap
+ {
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo,
+ },
+ HitObjects = { hitCircle }
+ });
HitObject changedObject = null;
editorBeatmap.HitObjectUpdated += h => changedObject = h;
@@ -131,6 +165,10 @@ namespace osu.Game.Tests.Beatmaps
{
var editorBeatmap = new EditorBeatmap(new OsuBeatmap
{
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo,
+ },
HitObjects =
{
new HitCircle(),
@@ -156,6 +194,10 @@ namespace osu.Game.Tests.Beatmaps
var editorBeatmap = new EditorBeatmap(new OsuBeatmap
{
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo,
+ },
HitObjects =
{
new HitCircle(),
@@ -185,7 +227,13 @@ namespace osu.Game.Tests.Beatmaps
{
updatedObjects.Clear();
- Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap());
+ Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap
+ {
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo,
+ },
+ });
for (int i = 0; i < 10; i++)
{
@@ -220,7 +268,13 @@ namespace osu.Game.Tests.Beatmaps
{
updatedObjects.Clear();
- Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap());
+ Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap
+ {
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo,
+ },
+ });
editorBeatmap.Add(new HitCircle());
});
diff --git a/osu.Game.Tests/Beatmaps/ToStringFormattingTest.cs b/osu.Game.Tests/Beatmaps/ToStringFormattingTest.cs
index 4a7d7505ad..10cac4ed9d 100644
--- a/osu.Game.Tests/Beatmaps/ToStringFormattingTest.cs
+++ b/osu.Game.Tests/Beatmaps/ToStringFormattingTest.cs
@@ -3,7 +3,7 @@
using NUnit.Framework;
using osu.Game.Beatmaps;
-using osu.Game.Online.API.Requests.Responses;
+using osu.Game.Models;
namespace osu.Game.Tests.Beatmaps
{
@@ -34,7 +34,7 @@ namespace osu.Game.Tests.Beatmaps
{
Artist = "artist",
Title = "title",
- Author = new APIUser { Username = "creator" }
+ Author = new RealmUser { Username = "creator" }
}
};
@@ -50,7 +50,7 @@ namespace osu.Game.Tests.Beatmaps
{
Artist = "artist",
Title = "title",
- Author = new APIUser { Username = "creator" }
+ Author = new RealmUser { Username = "creator" }
},
DifficultyName = "difficulty"
};
diff --git a/osu.Game.Tests/Database/BeatmapImporterTests.cs b/osu.Game.Tests/Database/BeatmapImporterTests.cs
index e47e24021f..227314cffd 100644
--- a/osu.Game.Tests/Database/BeatmapImporterTests.cs
+++ b/osu.Game.Tests/Database/BeatmapImporterTests.cs
@@ -19,6 +19,7 @@ using osu.Game.Extensions;
using osu.Game.IO.Archives;
using osu.Game.Models;
using osu.Game.Overlays.Notifications;
+using osu.Game.Rulesets;
using osu.Game.Stores;
using osu.Game.Tests.Resources;
using Realms;
@@ -34,33 +35,134 @@ namespace osu.Game.Tests.Database
[TestFixture]
public class BeatmapImporterTests : RealmTest
{
+ [Test]
+ public void TestDetachBeatmapSet()
+ {
+ RunTestWithRealmAsync(async (realmFactory, storage) =>
+ {
+ using (var importer = new BeatmapModelManager(realmFactory, storage))
+ using (new RulesetStore(realmFactory, storage))
+ {
+ ILive? beatmapSet;
+
+ using (var reader = new ZipArchiveReader(TestResources.GetTestBeatmapStream()))
+ beatmapSet = await importer.Import(reader);
+
+ Assert.NotNull(beatmapSet);
+ Debug.Assert(beatmapSet != null);
+
+ BeatmapSetInfo? detachedBeatmapSet = null;
+
+ beatmapSet.PerformRead(live =>
+ {
+ detachedBeatmapSet = live.Detach();
+
+ // files are omitted
+ Assert.AreEqual(0, detachedBeatmapSet.Files.Count);
+
+ Assert.AreEqual(live.Beatmaps.Count, detachedBeatmapSet.Beatmaps.Count);
+ Assert.AreEqual(live.Beatmaps.Select(f => f.Difficulty).Count(), detachedBeatmapSet.Beatmaps.Select(f => f.Difficulty).Count());
+ Assert.AreEqual(live.Metadata, detachedBeatmapSet.Metadata);
+ });
+
+ Debug.Assert(detachedBeatmapSet != null);
+
+ // Check detached instances can all be accessed without throwing.
+ Assert.AreEqual(0, detachedBeatmapSet.Files.Count);
+ Assert.NotNull(detachedBeatmapSet.Beatmaps.Count);
+ Assert.NotZero(detachedBeatmapSet.Beatmaps.Select(f => f.Difficulty).Count());
+ Assert.NotNull(detachedBeatmapSet.Metadata);
+
+ // Check cyclic reference to beatmap set
+ Assert.AreEqual(detachedBeatmapSet, detachedBeatmapSet.Beatmaps.First().BeatmapSet);
+ }
+ });
+ }
+
+ [Test]
+ public void TestUpdateDetachedBeatmapSet()
+ {
+ RunTestWithRealmAsync(async (realmFactory, storage) =>
+ {
+ using (var importer = new BeatmapModelManager(realmFactory, storage))
+ using (new RulesetStore(realmFactory, storage))
+ {
+ ILive? beatmapSet;
+
+ using (var reader = new ZipArchiveReader(TestResources.GetTestBeatmapStream()))
+ beatmapSet = await importer.Import(reader);
+
+ Assert.NotNull(beatmapSet);
+ Debug.Assert(beatmapSet != null);
+
+ // Detach at the BeatmapInfo point, similar to what GetWorkingBeatmap does.
+ BeatmapInfo? detachedBeatmap = null;
+
+ beatmapSet.PerformRead(s => detachedBeatmap = s.Beatmaps.First().Detach());
+
+ BeatmapSetInfo? detachedBeatmapSet = detachedBeatmap?.BeatmapSet;
+
+ Debug.Assert(detachedBeatmapSet != null);
+
+ var newUser = new RealmUser { Username = "peppy", OnlineID = 2 };
+
+ detachedBeatmapSet.Beatmaps.First().Metadata.Artist = "New Artist";
+ detachedBeatmapSet.Beatmaps.First().Metadata.Author = newUser;
+
+ Assert.AreNotEqual(detachedBeatmapSet.Status, BeatmapOnlineStatus.Ranked);
+ detachedBeatmapSet.Status = BeatmapOnlineStatus.Ranked;
+
+ beatmapSet.PerformWrite(s =>
+ {
+ detachedBeatmapSet.CopyChangesToRealm(s);
+ });
+
+ beatmapSet.PerformRead(s =>
+ {
+ // Check above changes explicitly.
+ Assert.AreEqual(BeatmapOnlineStatus.Ranked, s.Status);
+ Assert.AreEqual("New Artist", s.Beatmaps.First().Metadata.Artist);
+ Assert.AreEqual(newUser, s.Beatmaps.First().Metadata.Author);
+ Assert.NotZero(s.Files.Count);
+
+ // Check nothing was lost in the copy operation.
+ Assert.AreEqual(s.Files.Count, detachedBeatmapSet.Files.Count);
+ Assert.AreEqual(s.Files.Select(f => f.File).Count(), detachedBeatmapSet.Files.Select(f => f.File).Count());
+ Assert.AreEqual(s.Beatmaps.Count, detachedBeatmapSet.Beatmaps.Count);
+ Assert.AreEqual(s.Beatmaps.Select(f => f.Difficulty).Count(), detachedBeatmapSet.Beatmaps.Select(f => f.Difficulty).Count());
+ Assert.AreEqual(s.Metadata, detachedBeatmapSet.Metadata);
+ });
+ }
+ });
+ }
+
[Test]
public void TestImportBeatmapThenCleanup()
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using (var importer = new BeatmapImporter(realmFactory, storage))
- using (new RealmRulesetStore(realmFactory, storage))
+ using (var importer = new BeatmapModelManager(realmFactory, storage))
+ using (new RulesetStore(realmFactory, storage))
{
- ILive? imported;
+ ILive? imported;
using (var reader = new ZipArchiveReader(TestResources.GetTestBeatmapStream()))
imported = await importer.Import(reader);
- Assert.AreEqual(1, realmFactory.Context.All().Count());
+ Assert.AreEqual(1, realmFactory.Context.All().Count());
Assert.NotNull(imported);
Debug.Assert(imported != null);
imported.PerformWrite(s => s.DeletePending = true);
- Assert.AreEqual(1, realmFactory.Context.All().Count(s => s.DeletePending));
+ Assert.AreEqual(1, realmFactory.Context.All().Count(s => s.DeletePending));
}
});
Logger.Log("Running with no work to purge pending deletions");
- RunTestWithRealm((realmFactory, _) => { Assert.AreEqual(0, realmFactory.Context.All().Count()); });
+ RunTestWithRealm((realmFactory, _) => { Assert.AreEqual(0, realmFactory.Context.All().Count()); });
}
[Test]
@@ -68,8 +170,8 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
await LoadOszIntoStore(importer, realmFactory.Context);
});
@@ -80,8 +182,8 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
var imported = await LoadOszIntoStore(importer, realmFactory.Context);
@@ -98,8 +200,8 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
var imported = await LoadOszIntoStore(importer, realmFactory.Context);
@@ -112,17 +214,17 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
string? tempPath = TestResources.GetTestBeatmapForImport();
- ILive? importedSet;
+ ILive? importedSet;
using (var stream = File.OpenRead(tempPath))
{
importedSet = await importer.Import(new ImportTask(stream, Path.GetFileName(tempPath)));
- ensureLoaded(realmFactory.Context);
+ EnsureLoaded(realmFactory.Context);
}
Assert.NotNull(importedSet);
@@ -131,7 +233,7 @@ namespace osu.Game.Tests.Database
Assert.IsTrue(File.Exists(tempPath), "Stream source file somehow went missing");
File.Delete(tempPath);
- var imported = realmFactory.Context.All().First(beatmapSet => beatmapSet.ID == importedSet.ID);
+ var imported = realmFactory.Context.All().First(beatmapSet => beatmapSet.ID == importedSet.ID);
deleteBeatmapSet(imported, realmFactory.Context);
});
@@ -142,8 +244,8 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
var imported = await LoadOszIntoStore(importer, realmFactory.Context);
var importedSecondTime = await LoadOszIntoStore(importer, realmFactory.Context);
@@ -162,8 +264,8 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
string? temp = TestResources.GetTestBeatmapForImport();
@@ -190,7 +292,7 @@ namespace osu.Game.Tests.Database
var importedSecondTime = await importer.Import(new ImportTask(temp));
- ensureLoaded(realmFactory.Context);
+ EnsureLoaded(realmFactory.Context);
Assert.NotNull(importedSecondTime);
Debug.Assert(importedSecondTime != null);
@@ -211,8 +313,8 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
string? temp = TestResources.GetTestBeatmapForImport();
@@ -241,7 +343,7 @@ namespace osu.Game.Tests.Database
var importedSecondTime = await importer.Import(new ImportTask(temp));
- ensureLoaded(realmFactory.Context);
+ EnsureLoaded(realmFactory.Context);
// check the newly "imported" beatmap is not the original.
Assert.NotNull(importedSecondTime);
@@ -263,8 +365,8 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
string? temp = TestResources.GetTestBeatmapForImport();
@@ -290,7 +392,7 @@ namespace osu.Game.Tests.Database
var importedSecondTime = await importer.Import(new ImportTask(temp));
- ensureLoaded(realmFactory.Context);
+ EnsureLoaded(realmFactory.Context);
Assert.NotNull(importedSecondTime);
Debug.Assert(importedSecondTime != null);
@@ -311,8 +413,8 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
string? temp = TestResources.GetTestBeatmapForImport();
@@ -338,7 +440,7 @@ namespace osu.Game.Tests.Database
var importedSecondTime = await importer.Import(new ImportTask(temp));
- ensureLoaded(realmFactory.Context);
+ EnsureLoaded(realmFactory.Context);
Assert.NotNull(importedSecondTime);
Debug.Assert(importedSecondTime != null);
@@ -360,8 +462,8 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
var imported = await LoadOszIntoStore(importer, realmFactory.Context);
@@ -393,8 +495,8 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
var progressNotification = new ImportProgressNotification();
@@ -429,8 +531,8 @@ namespace osu.Game.Tests.Database
Interlocked.Increment(ref loggedExceptionCount);
};
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
var imported = await LoadOszIntoStore(importer, realmFactory.Context);
@@ -479,8 +581,8 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
var imported = await LoadOszIntoStore(importer, realmFactory.Context);
@@ -504,7 +606,7 @@ namespace osu.Game.Tests.Database
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
using var importer = new NonOptimisedBeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
var imported = await LoadOszIntoStore(importer, realmFactory.Context);
@@ -527,8 +629,8 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
var imported = await LoadOszIntoStore(importer, realmFactory.Context);
@@ -553,10 +655,10 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
- var metadata = new RealmBeatmapMetadata
+ var metadata = new BeatmapMetadata
{
Artist = "SomeArtist",
Author =
@@ -565,18 +667,18 @@ namespace osu.Game.Tests.Database
}
};
- var ruleset = realmFactory.Context.All().First();
+ var ruleset = realmFactory.Context.All().First();
- var toImport = new RealmBeatmapSet
+ var toImport = new BeatmapSetInfo
{
OnlineID = 1,
Beatmaps =
{
- new RealmBeatmap(ruleset, new RealmBeatmapDifficulty(), metadata)
+ new BeatmapInfo(ruleset, new BeatmapDifficulty(), metadata)
{
OnlineID = 2,
},
- new RealmBeatmap(ruleset, new RealmBeatmapDifficulty(), metadata)
+ new BeatmapInfo(ruleset, new BeatmapDifficulty(), metadata)
{
OnlineID = 2,
Status = BeatmapOnlineStatus.Loved,
@@ -599,13 +701,13 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
string? temp = TestResources.GetTestBeatmapForImport();
using (File.OpenRead(temp))
await importer.Import(temp);
- ensureLoaded(realmFactory.Context);
+ EnsureLoaded(realmFactory.Context);
File.Delete(temp);
Assert.IsFalse(File.Exists(temp), "We likely held a read lock on the file when we shouldn't");
});
@@ -616,8 +718,8 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
string? temp = TestResources.GetTestBeatmapForImport();
@@ -638,7 +740,7 @@ namespace osu.Game.Tests.Database
await importer.Import(temp);
- ensureLoaded(realmFactory.Context);
+ EnsureLoaded(realmFactory.Context);
}
finally
{
@@ -652,8 +754,8 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
string? temp = TestResources.GetTestBeatmapForImport();
@@ -678,7 +780,7 @@ namespace osu.Game.Tests.Database
Assert.NotNull(imported);
Debug.Assert(imported != null);
- ensureLoaded(realmFactory.Context);
+ EnsureLoaded(realmFactory.Context);
Assert.IsFalse(imported.PerformRead(s => s.Files.Any(f => f.Filename.Contains("subfolder"))), "Files contain common subfolder");
}
@@ -694,8 +796,8 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
string? temp = TestResources.GetTestBeatmapForImport();
@@ -728,7 +830,7 @@ namespace osu.Game.Tests.Database
Assert.NotNull(imported);
Debug.Assert(imported != null);
- ensureLoaded(realmFactory.Context);
+ EnsureLoaded(realmFactory.Context);
Assert.IsFalse(imported.PerformRead(s => s.Files.Any(f => f.Filename.Contains("__MACOSX"))), "Files contain resource fork folder, which should be ignored");
Assert.IsFalse(imported.PerformRead(s => s.Files.Any(f => f.Filename.Contains("actual_data"))), "Files contain common subfolder");
@@ -745,25 +847,25 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
- using var importer = new BeatmapImporter(realmFactory, storage);
- using var store = new RealmRulesetStore(realmFactory, storage);
+ using var importer = new BeatmapModelManager(realmFactory, storage);
+ using var store = new RulesetStore(realmFactory, storage);
string? temp = TestResources.GetTestBeatmapForImport();
await importer.Import(temp);
// Update via the beatmap, not the beatmap info, to ensure correct linking
- RealmBeatmapSet setToUpdate = realmFactory.Context.All().First();
+ BeatmapSetInfo setToUpdate = realmFactory.Context.All().First();
var beatmapToUpdate = setToUpdate.Beatmaps.First();
realmFactory.Context.Write(() => beatmapToUpdate.DifficultyName = "updated");
- RealmBeatmap updatedInfo = realmFactory.Context.All().First(b => b.ID == beatmapToUpdate.ID);
+ BeatmapInfo updatedInfo = realmFactory.Context.All().First(b => b.ID == beatmapToUpdate.ID);
Assert.That(updatedInfo.DifficultyName, Is.EqualTo("updated"));
});
}
- public static async Task LoadQuickOszIntoOsu(BeatmapImporter importer, Realm realm)
+ public static async Task LoadQuickOszIntoOsu(BeatmapImporter importer, Realm realm)
{
string? temp = TestResources.GetQuickTestBeatmapForImport();
@@ -771,14 +873,14 @@ namespace osu.Game.Tests.Database
Assert.NotNull(importedSet);
- ensureLoaded(realm);
+ EnsureLoaded(realm);
waitForOrAssert(() => !File.Exists(temp), "Temporary file still exists after standard import", 5000);
- return realm.All().FirstOrDefault(beatmapSet => beatmapSet.ID == importedSet!.ID);
+ return realm.All().FirstOrDefault(beatmapSet => beatmapSet.ID == importedSet!.ID);
}
- public static async Task LoadOszIntoStore(BeatmapImporter importer, Realm realm, string? path = null, bool virtualTrack = false)
+ public static async Task LoadOszIntoStore(BeatmapImporter importer, Realm realm, string? path = null, bool virtualTrack = false)
{
string? temp = path ?? TestResources.GetTestBeatmapForImport(virtualTrack);
@@ -787,24 +889,24 @@ namespace osu.Game.Tests.Database
Assert.NotNull(importedSet);
Debug.Assert(importedSet != null);
- ensureLoaded(realm);
+ EnsureLoaded(realm);
waitForOrAssert(() => !File.Exists(temp), "Temporary file still exists after standard import", 5000);
- return realm.All().First(beatmapSet => beatmapSet.ID == importedSet.ID);
+ return realm.All().First(beatmapSet => beatmapSet.ID == importedSet.ID);
}
- private void deleteBeatmapSet(RealmBeatmapSet imported, Realm realm)
+ private void deleteBeatmapSet(BeatmapSetInfo imported, Realm realm)
{
realm.Write(() => imported.DeletePending = true);
checkBeatmapSetCount(realm, 0);
checkBeatmapSetCount(realm, 1, true);
- Assert.IsTrue(realm.All().First(_ => true).DeletePending);
+ Assert.IsTrue(realm.All().First(_ => true).DeletePending);
}
- private static Task createScoreForBeatmap(Realm realm, RealmBeatmap beatmap)
+ private static Task createScoreForBeatmap(Realm realm, BeatmapInfo beatmap)
{
// TODO: reimplement when we have score support in realm.
// return ImportScoreTest.LoadScoreIntoOsu(osu, new ScoreInfo
@@ -820,8 +922,8 @@ namespace osu.Game.Tests.Database
private static void checkBeatmapSetCount(Realm realm, int expected, bool includeDeletePending = false)
{
Assert.AreEqual(expected, includeDeletePending
- ? realm.All().Count()
- : realm.All().Count(s => !s.DeletePending));
+ ? realm.All().Count()
+ : realm.All().Count(s => !s.DeletePending));
}
private static string hashFile(string filename)
@@ -832,7 +934,7 @@ namespace osu.Game.Tests.Database
private static void checkBeatmapCount(Realm realm, int expected)
{
- Assert.AreEqual(expected, realm.All().Where(_ => true).ToList().Count);
+ Assert.AreEqual(expected, realm.All().Where(_ => true).ToList().Count);
}
private static void checkSingleReferencedFileCount(Realm realm, int expected)
@@ -848,26 +950,25 @@ namespace osu.Game.Tests.Database
Assert.AreEqual(expected, singleReferencedCount);
}
- private static void ensureLoaded(Realm realm, int timeout = 60000)
+ internal static void EnsureLoaded(Realm realm, int timeout = 60000)
{
- IQueryable? resultSets = null;
+ IQueryable? resultSets = null;
waitForOrAssert(() =>
- {
- realm.Refresh();
- return (resultSets = realm.All().Where(s => !s.DeletePending && s.OnlineID == 241526)).Any();
- },
- @"BeatmapSet did not import to the database in allocated time.", timeout);
+ {
+ realm.Refresh();
+ return (resultSets = realm.All().Where(s => !s.DeletePending && s.OnlineID == 241526)).Any();
+ }, @"BeatmapSet did not import to the database in allocated time.", timeout);
// ensure we were stored to beatmap database backing...
Assert.IsTrue(resultSets?.Count() == 1, $@"Incorrect result count found ({resultSets?.Count()} but should be 1).");
- IEnumerable queryBeatmapSets() => realm.All().Where(s => !s.DeletePending && s.OnlineID == 241526);
+ IEnumerable queryBeatmapSets() => realm.All().Where(s => !s.DeletePending && s.OnlineID == 241526);
var set = queryBeatmapSets().First();
// ReSharper disable once PossibleUnintendedReferenceComparison
- IEnumerable queryBeatmaps() => realm.All().Where(s => s.BeatmapSet != null && s.BeatmapSet == set);
+ IEnumerable queryBeatmaps() => realm.All().Where(s => s.BeatmapSet != null && s.BeatmapSet == set);
Assert.AreEqual(12, queryBeatmaps().Count(), @"Beatmap count was not correct");
Assert.AreEqual(1, queryBeatmapSets().Count(), @"Beatmapset count was not correct");
@@ -880,7 +981,7 @@ namespace osu.Game.Tests.Database
countBeatmaps = queryBeatmaps().Count(),
$@"Incorrect database beatmap count post-import ({countBeatmaps} but should be {countBeatmapSetBeatmaps}).");
- foreach (RealmBeatmap b in set.Beatmaps)
+ foreach (BeatmapInfo b in set.Beatmaps)
Assert.IsTrue(set.Beatmaps.Any(c => c.OnlineID == b.OnlineID));
Assert.IsTrue(set.Beatmaps.Count > 0);
}
diff --git a/osu.Game.Tests/Database/GeneralUsageTests.cs b/osu.Game.Tests/Database/GeneralUsageTests.cs
index 2285b22a3a..0961ad71e4 100644
--- a/osu.Game.Tests/Database/GeneralUsageTests.cs
+++ b/osu.Game.Tests/Database/GeneralUsageTests.cs
@@ -5,8 +5,8 @@ using System;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
+using osu.Game.Beatmaps;
using osu.Game.Database;
-using osu.Game.Models;
#nullable enable
@@ -48,7 +48,7 @@ namespace osu.Game.Tests.Database
using (var context = realmFactory.CreateContext())
{
- var subscription = context.All().QueryAsyncWithNotifications((sender, changes, error) =>
+ var subscription = context.All().QueryAsyncWithNotifications((sender, changes, error) =>
{
using (realmFactory.CreateContext())
{
diff --git a/osu.Game.Tests/Database/RealmLiveTests.cs b/osu.Game.Tests/Database/RealmLiveTests.cs
index 9432a56741..187fcd3ca7 100644
--- a/osu.Game.Tests/Database/RealmLiveTests.cs
+++ b/osu.Game.Tests/Database/RealmLiveTests.cs
@@ -8,8 +8,8 @@ using System.Threading.Tasks;
using NUnit.Framework;
using osu.Framework.Extensions;
using osu.Framework.Testing;
+using osu.Game.Beatmaps;
using osu.Game.Database;
-using osu.Game.Models;
using Realms;
#nullable enable
@@ -23,9 +23,9 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealm((realmFactory, _) =>
{
- ILive beatmap = realmFactory.CreateContext().Write(r => r.Add(new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata()))).ToLive(realmFactory);
+ ILive beatmap = realmFactory.CreateContext().Write(r => r.Add(new BeatmapInfo(CreateRuleset(), new BeatmapDifficulty(), new BeatmapMetadata()))).ToLive(realmFactory);
- ILive beatmap2 = realmFactory.CreateContext().All().First().ToLive(realmFactory);
+ ILive beatmap2 = realmFactory.CreateContext().All().First().ToLive(realmFactory);
Assert.AreEqual(beatmap, beatmap2);
});
@@ -36,9 +36,9 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealm((realmFactory, storage) =>
{
- var beatmap = new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata());
+ var beatmap = new BeatmapInfo(CreateRuleset(), new BeatmapDifficulty(), new BeatmapMetadata());
- ILive liveBeatmap;
+ ILive liveBeatmap;
using (var context = realmFactory.CreateContext())
{
@@ -63,7 +63,7 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealm((realmFactory, _) =>
{
- var beatmap = new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata());
+ var beatmap = new BeatmapInfo(CreateRuleset(), new BeatmapDifficulty(), new BeatmapMetadata());
var liveBeatmap = beatmap.ToLive(realmFactory);
@@ -77,7 +77,7 @@ namespace osu.Game.Tests.Database
[Test]
public void TestAccessNonManaged()
{
- var beatmap = new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata());
+ var beatmap = new BeatmapInfo(CreateRuleset(), new BeatmapDifficulty(), new BeatmapMetadata());
var liveBeatmap = beatmap.ToLiveUnmanaged();
Assert.IsFalse(beatmap.Hidden);
@@ -96,12 +96,12 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealm((realmFactory, _) =>
{
- ILive? liveBeatmap = null;
+ ILive? liveBeatmap = null;
Task.Factory.StartNew(() =>
{
using (var threadContext = realmFactory.CreateContext())
{
- var beatmap = threadContext.Write(r => r.Add(new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata())));
+ var beatmap = threadContext.Write(r => r.Add(new BeatmapInfo(CreateRuleset(), new BeatmapDifficulty(), new BeatmapMetadata())));
liveBeatmap = beatmap.ToLive(realmFactory);
}
@@ -125,12 +125,12 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealm((realmFactory, _) =>
{
- ILive? liveBeatmap = null;
+ ILive? liveBeatmap = null;
Task.Factory.StartNew(() =>
{
using (var threadContext = realmFactory.CreateContext())
{
- var beatmap = threadContext.Write(r => r.Add(new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata())));
+ var beatmap = threadContext.Write(r => r.Add(new BeatmapInfo(CreateRuleset(), new BeatmapDifficulty(), new BeatmapMetadata())));
liveBeatmap = beatmap.ToLive(realmFactory);
}
@@ -151,7 +151,7 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealm((realmFactory, _) =>
{
- var beatmap = new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata());
+ var beatmap = new BeatmapInfo(CreateRuleset(), new BeatmapDifficulty(), new BeatmapMetadata());
var liveBeatmap = beatmap.ToLive(realmFactory);
Assert.DoesNotThrow(() =>
@@ -166,13 +166,13 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealm((realmFactory, _) =>
{
- ILive? liveBeatmap = null;
+ ILive? liveBeatmap = null;
Task.Factory.StartNew(() =>
{
using (var threadContext = realmFactory.CreateContext())
{
- var beatmap = threadContext.Write(r => r.Add(new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata())));
+ var beatmap = threadContext.Write(r => r.Add(new BeatmapInfo(CreateRuleset(), new BeatmapDifficulty(), new BeatmapMetadata())));
liveBeatmap = beatmap.ToLive(realmFactory);
}
@@ -205,12 +205,12 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealm((realmFactory, _) =>
{
- ILive? liveBeatmap = null;
+ ILive? liveBeatmap = null;
Task.Factory.StartNew(() =>
{
using (var threadContext = realmFactory.CreateContext())
{
- var beatmap = threadContext.Write(r => r.Add(new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata())));
+ var beatmap = threadContext.Write(r => r.Add(new BeatmapInfo(CreateRuleset(), new BeatmapDifficulty(), new BeatmapMetadata())));
liveBeatmap = beatmap.ToLive(realmFactory);
}
@@ -237,19 +237,19 @@ namespace osu.Game.Tests.Database
using (var updateThreadContext = realmFactory.CreateContext())
{
- updateThreadContext.All().QueryAsyncWithNotifications(gotChange);
- ILive? liveBeatmap = null;
+ updateThreadContext.All().QueryAsyncWithNotifications(gotChange);
+ ILive? liveBeatmap = null;
Task.Factory.StartNew(() =>
{
using (var threadContext = realmFactory.CreateContext())
{
var ruleset = CreateRuleset();
- var beatmap = threadContext.Write(r => r.Add(new RealmBeatmap(ruleset, new RealmBeatmapDifficulty(), new RealmBeatmapMetadata())));
+ var beatmap = threadContext.Write(r => r.Add(new BeatmapInfo(ruleset, new BeatmapDifficulty(), new BeatmapMetadata())));
// add a second beatmap to ensure that a full refresh occurs below.
// not just a refresh from the resolved Live.
- threadContext.Write(r => r.Add(new RealmBeatmap(ruleset, new RealmBeatmapDifficulty(), new RealmBeatmapMetadata())));
+ threadContext.Write(r => r.Add(new BeatmapInfo(ruleset, new BeatmapDifficulty(), new BeatmapMetadata())));
liveBeatmap = beatmap.ToLive(realmFactory);
}
@@ -258,14 +258,14 @@ namespace osu.Game.Tests.Database
Debug.Assert(liveBeatmap != null);
// not yet seen by main context
- Assert.AreEqual(0, updateThreadContext.All().Count());
+ Assert.AreEqual(0, updateThreadContext.All().Count());
Assert.AreEqual(0, changesTriggered);
liveBeatmap.PerformRead(resolved =>
{
// retrieval causes an implicit refresh. even changes that aren't related to the retrieval are fired at this point.
// ReSharper disable once AccessToDisposedClosure
- Assert.AreEqual(2, updateThreadContext.All().Count());
+ Assert.AreEqual(2, updateThreadContext.All().Count());
Assert.AreEqual(1, changesTriggered);
// can access properties without a crash.
@@ -280,7 +280,7 @@ namespace osu.Game.Tests.Database
});
}
- void gotChange(IRealmCollection sender, ChangeSet changes, Exception error)
+ void gotChange(IRealmCollection sender, ChangeSet changes, Exception error)
{
changesTriggered++;
}
diff --git a/osu.Game.Tests/Database/RealmTest.cs b/osu.Game.Tests/Database/RealmTest.cs
index 4e67f09dca..0cee165f75 100644
--- a/osu.Game.Tests/Database/RealmTest.cs
+++ b/osu.Game.Tests/Database/RealmTest.cs
@@ -9,9 +9,11 @@ using osu.Framework.Extensions;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Framework.Testing;
+using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.IO;
using osu.Game.Models;
+using osu.Game.Rulesets;
#nullable enable
@@ -74,24 +76,24 @@ namespace osu.Game.Tests.Database
}
}
- protected static RealmBeatmapSet CreateBeatmapSet(RealmRuleset ruleset)
+ protected static BeatmapSetInfo CreateBeatmapSet(RulesetInfo ruleset)
{
RealmFile createRealmFile() => new RealmFile { Hash = Guid.NewGuid().ToString().ComputeSHA2Hash() };
- var metadata = new RealmBeatmapMetadata
+ var metadata = new BeatmapMetadata
{
Title = "My Love",
Artist = "Kuba Oms"
};
- var beatmapSet = new RealmBeatmapSet
+ var beatmapSet = new BeatmapSetInfo
{
Beatmaps =
{
- new RealmBeatmap(ruleset, new RealmBeatmapDifficulty(), metadata) { DifficultyName = "Easy", },
- new RealmBeatmap(ruleset, new RealmBeatmapDifficulty(), metadata) { DifficultyName = "Normal", },
- new RealmBeatmap(ruleset, new RealmBeatmapDifficulty(), metadata) { DifficultyName = "Hard", },
- new RealmBeatmap(ruleset, new RealmBeatmapDifficulty(), metadata) { DifficultyName = "Insane", }
+ new BeatmapInfo(ruleset, new BeatmapDifficulty(), metadata) { DifficultyName = "Easy", },
+ new BeatmapInfo(ruleset, new BeatmapDifficulty(), metadata) { DifficultyName = "Normal", },
+ new BeatmapInfo(ruleset, new BeatmapDifficulty(), metadata) { DifficultyName = "Hard", },
+ new BeatmapInfo(ruleset, new BeatmapDifficulty(), metadata) { DifficultyName = "Insane", }
},
Files =
{
@@ -111,8 +113,8 @@ namespace osu.Game.Tests.Database
return beatmapSet;
}
- protected static RealmRuleset CreateRuleset() =>
- new RealmRuleset(0, "osu!", "osu", true);
+ protected static RulesetInfo CreateRuleset() =>
+ new RulesetInfo(0, "osu!", "osu", true);
private class RealmTestGame : Framework.Game
{
diff --git a/osu.Game.Tests/Database/RulesetStoreTests.cs b/osu.Game.Tests/Database/RulesetStoreTests.cs
index cc7e8a0c97..4416da6f92 100644
--- a/osu.Game.Tests/Database/RulesetStoreTests.cs
+++ b/osu.Game.Tests/Database/RulesetStoreTests.cs
@@ -3,8 +3,7 @@
using System.Linq;
using NUnit.Framework;
-using osu.Game.Models;
-using osu.Game.Stores;
+using osu.Game.Rulesets;
namespace osu.Game.Tests.Database
{
@@ -15,10 +14,10 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealm((realmFactory, storage) =>
{
- var rulesets = new RealmRulesetStore(realmFactory, storage);
+ var rulesets = new RulesetStore(realmFactory, storage);
Assert.AreEqual(4, rulesets.AvailableRulesets.Count());
- Assert.AreEqual(4, realmFactory.Context.All().Count());
+ Assert.AreEqual(4, realmFactory.Context.All().Count());
});
}
@@ -27,14 +26,14 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealm((realmFactory, storage) =>
{
- var rulesets = new RealmRulesetStore(realmFactory, storage);
- var rulesets2 = new RealmRulesetStore(realmFactory, storage);
+ var rulesets = new RulesetStore(realmFactory, storage);
+ var rulesets2 = new RulesetStore(realmFactory, storage);
Assert.AreEqual(4, rulesets.AvailableRulesets.Count());
Assert.AreEqual(4, rulesets2.AvailableRulesets.Count());
Assert.AreEqual(rulesets.AvailableRulesets.First(), rulesets2.AvailableRulesets.First());
- Assert.AreEqual(4, realmFactory.Context.All().Count());
+ Assert.AreEqual(4, realmFactory.Context.All().Count());
});
}
@@ -43,7 +42,7 @@ namespace osu.Game.Tests.Database
{
RunTestWithRealm((realmFactory, storage) =>
{
- var rulesets = new RealmRulesetStore(realmFactory, storage);
+ var rulesets = new RulesetStore(realmFactory, storage);
Assert.IsFalse(rulesets.AvailableRulesets.First().IsManaged);
Assert.IsFalse(rulesets.GetRuleset(0)?.IsManaged);
diff --git a/osu.Game.Tests/Editing/Checks/CheckAudioInVideoTest.cs b/osu.Game.Tests/Editing/Checks/CheckAudioInVideoTest.cs
index f9b7bfa586..614b9b4ac1 100644
--- a/osu.Game.Tests/Editing/Checks/CheckAudioInVideoTest.cs
+++ b/osu.Game.Tests/Editing/Checks/CheckAudioInVideoTest.cs
@@ -74,7 +74,7 @@ namespace osu.Game.Tests.Editing.Checks
[Test]
public void TestMissingFile()
{
- beatmap.BeatmapInfo.BeatmapSet.Files.Clear();
+ beatmap.BeatmapInfo.BeatmapSet?.Files.Clear();
var issues = check.Run(getContext(null)).ToList();
diff --git a/osu.Game.Tests/Editing/Checks/CheckFilePresenceTest.cs b/osu.Game.Tests/Editing/Checks/CheckFilePresenceTest.cs
index f36454aa71..01baaadc7d 100644
--- a/osu.Game.Tests/Editing/Checks/CheckFilePresenceTest.cs
+++ b/osu.Game.Tests/Editing/Checks/CheckFilePresenceTest.cs
@@ -46,7 +46,7 @@ namespace osu.Game.Tests.Editing.Checks
[Test]
public void TestBackgroundSetAndNotInFiles()
{
- beatmap.BeatmapInfo.BeatmapSet.Files.Clear();
+ beatmap.BeatmapInfo.BeatmapSet?.Files.Clear();
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
var issues = check.Run(context).ToList();
diff --git a/osu.Game.Tests/Editing/Checks/CheckTestHelpers.cs b/osu.Game.Tests/Editing/Checks/CheckTestHelpers.cs
index f702921986..9067714ff9 100644
--- a/osu.Game.Tests/Editing/Checks/CheckTestHelpers.cs
+++ b/osu.Game.Tests/Editing/Checks/CheckTestHelpers.cs
@@ -1,18 +1,13 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using osu.Game.Beatmaps;
-using osu.Game.IO;
+using osu.Game.Models;
namespace osu.Game.Tests.Editing.Checks
{
public static class CheckTestHelpers
{
- public static BeatmapSetFileInfo CreateMockFile(string extension) =>
- new BeatmapSetFileInfo
- {
- Filename = $"abc123.{extension}",
- FileInfo = new FileInfo { Hash = "abcdef" }
- };
+ public static RealmNamedFileUsage CreateMockFile(string extension) =>
+ new RealmNamedFileUsage(new RealmFile { Hash = "abcdef" }, $"abc123.{extension}");
}
}
diff --git a/osu.Game.Tests/Editing/Checks/CheckTooShortAudioFilesTest.cs b/osu.Game.Tests/Editing/Checks/CheckTooShortAudioFilesTest.cs
index 8adf0d3764..242fec2f68 100644
--- a/osu.Game.Tests/Editing/Checks/CheckTooShortAudioFilesTest.cs
+++ b/osu.Game.Tests/Editing/Checks/CheckTooShortAudioFilesTest.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System.Diagnostics;
using System.IO;
using System.Linq;
using ManagedBass;
@@ -45,6 +46,8 @@ namespace osu.Game.Tests.Editing.Checks
[Test]
public void TestDifferentExtension()
{
+ Debug.Assert(beatmap.BeatmapInfo.BeatmapSet != null);
+
beatmap.BeatmapInfo.BeatmapSet.Files.Clear();
beatmap.BeatmapInfo.BeatmapSet.Files.Add(CheckTestHelpers.CreateMockFile("jpg"));
diff --git a/osu.Game.Tests/Editing/EditorChangeHandlerTest.cs b/osu.Game.Tests/Editing/EditorChangeHandlerTest.cs
index 481cb3230e..2d61948a2a 100644
--- a/osu.Game.Tests/Editing/EditorChangeHandlerTest.cs
+++ b/osu.Game.Tests/Editing/EditorChangeHandlerTest.cs
@@ -2,7 +2,8 @@
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
-using osu.Game.Beatmaps;
+using osu.Game.Rulesets.Osu;
+using osu.Game.Rulesets.Osu.Beatmaps;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit;
@@ -158,7 +159,13 @@ namespace osu.Game.Tests.Editing
private (EditorChangeHandler, EditorBeatmap) createChangeHandler()
{
- var beatmap = new EditorBeatmap(new Beatmap());
+ var beatmap = new EditorBeatmap(new OsuBeatmap
+ {
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo,
+ },
+ });
var changeHandler = new EditorChangeHandler(beatmap);
diff --git a/osu.Game.Tests/Editing/TestSceneHitObjectComposerDistanceSnapping.cs b/osu.Game.Tests/Editing/TestSceneHitObjectComposerDistanceSnapping.cs
index 8eb9452736..43f22e4e90 100644
--- a/osu.Game.Tests/Editing/TestSceneHitObjectComposerDistanceSnapping.cs
+++ b/osu.Game.Tests/Editing/TestSceneHitObjectComposerDistanceSnapping.cs
@@ -35,7 +35,13 @@ namespace osu.Game.Tests.Editing
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
- editorBeatmap = new EditorBeatmap(new OsuBeatmap()),
+ editorBeatmap = new EditorBeatmap(new OsuBeatmap
+ {
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo,
+ },
+ }),
Content = new Container
{
RelativeSizeAxes = Axes.Both,
diff --git a/osu.Game.Tests/NonVisual/BeatmapSetInfoEqualityTest.cs b/osu.Game.Tests/NonVisual/BeatmapSetInfoEqualityTest.cs
index 534983f869..1b6049fcb7 100644
--- a/osu.Game.Tests/NonVisual/BeatmapSetInfoEqualityTest.cs
+++ b/osu.Game.Tests/NonVisual/BeatmapSetInfoEqualityTest.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Extensions;
@@ -23,8 +24,10 @@ namespace osu.Game.Tests.NonVisual
[Test]
public void TestDatabasedWithDatabased()
{
- var ourInfo = new BeatmapSetInfo { ID = 123 };
- var otherInfo = new BeatmapSetInfo { ID = 123 };
+ var guid = Guid.NewGuid();
+
+ var ourInfo = new BeatmapSetInfo { ID = guid };
+ var otherInfo = new BeatmapSetInfo { ID = guid };
Assert.AreEqual(ourInfo, otherInfo);
}
@@ -32,7 +35,7 @@ namespace osu.Game.Tests.NonVisual
[Test]
public void TestDatabasedWithOnline()
{
- var ourInfo = new BeatmapSetInfo { ID = 123, OnlineID = 12 };
+ var ourInfo = new BeatmapSetInfo { ID = Guid.NewGuid(), OnlineID = 12 };
var otherInfo = new BeatmapSetInfo { OnlineID = 12 };
Assert.AreNotEqual(ourInfo, otherInfo);
diff --git a/osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs b/osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs
index 4bb54f1625..61ef31e07e 100644
--- a/osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs
+++ b/osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs
@@ -179,7 +179,7 @@ namespace osu.Game.Tests.NonVisual
{
var osu = LoadOsuIntoHost(host);
- const string database_filename = "client.db";
+ const string database_filename = "client.realm";
Assert.DoesNotThrow(() => osu.Migrate(customPath));
Assert.That(File.Exists(Path.Combine(customPath, database_filename)));
diff --git a/osu.Game.Tests/NonVisual/Filtering/FilterMatchingTest.cs b/osu.Game.Tests/NonVisual/Filtering/FilterMatchingTest.cs
index 8ba3d1a6c7..74904f4585 100644
--- a/osu.Game.Tests/NonVisual/Filtering/FilterMatchingTest.cs
+++ b/osu.Game.Tests/NonVisual/Filtering/FilterMatchingTest.cs
@@ -17,9 +17,8 @@ namespace osu.Game.Tests.NonVisual.Filtering
private BeatmapInfo getExampleBeatmap() => new BeatmapInfo
{
Ruleset = new RulesetInfo { OnlineID = 0 },
- RulesetID = 0,
StarRating = 4.0d,
- BaseDifficulty = new BeatmapDifficulty
+ Difficulty = new BeatmapDifficulty
{
ApproachRate = 5.0f,
DrainRate = 3.0f,
@@ -31,7 +30,7 @@ namespace osu.Game.Tests.NonVisual.Filtering
ArtistUnicode = "check unicode too",
Title = "Title goes here",
TitleUnicode = "Title goes here",
- AuthorString = "The Author",
+ Author = { Username = "The Author" },
Source = "unit tests",
Tags = "look for tags too",
},
diff --git a/osu.Game.Tests/Online/TestAPIModJsonSerialization.cs b/osu.Game.Tests/Online/TestAPIModJsonSerialization.cs
index 4b160e1d67..1b7a7656b5 100644
--- a/osu.Game.Tests/Online/TestAPIModJsonSerialization.cs
+++ b/osu.Game.Tests/Online/TestAPIModJsonSerialization.cs
@@ -9,10 +9,12 @@ using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Online.API;
+using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Solo;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
+using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
@@ -93,7 +95,11 @@ namespace osu.Game.Tests.Online
[Test]
public void TestDeserialiseSubmittableScoreWithEmptyMods()
{
- var score = new SubmittableScore(new ScoreInfo());
+ var score = new SubmittableScore(new ScoreInfo
+ {
+ User = new APIUser(),
+ Ruleset = new OsuRuleset().RulesetInfo,
+ });
var deserialised = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(score));
@@ -105,7 +111,9 @@ namespace osu.Game.Tests.Online
{
var score = new SubmittableScore(new ScoreInfo
{
- Mods = new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 2 } } }
+ Mods = new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 2 } } },
+ User = new APIUser(),
+ Ruleset = new OsuRuleset().RulesetInfo,
});
var deserialised = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(score));
diff --git a/osu.Game.Tests/Online/TestSceneBeatmapDownloading.cs b/osu.Game.Tests/Online/TestSceneBeatmapDownloading.cs
index 4e77973655..ad9ea79646 100644
--- a/osu.Game.Tests/Online/TestSceneBeatmapDownloading.cs
+++ b/osu.Game.Tests/Online/TestSceneBeatmapDownloading.cs
@@ -5,6 +5,7 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
+using osu.Game.Models;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Notifications;
using osu.Game.Tests.Visual;
@@ -20,13 +21,19 @@ namespace osu.Game.Tests.Online
private static readonly BeatmapSetInfo test_db_model = new BeatmapSetInfo
{
OnlineID = 1,
- Metadata = new BeatmapMetadata
+ Beatmaps =
{
- Artist = "test author",
- Title = "test title",
- Author = new APIUser
+ new BeatmapInfo
{
- Username = "mapper"
+ Metadata = new BeatmapMetadata
+ {
+ Artist = "test author",
+ Title = "test title",
+ Author = new RealmUser
+ {
+ Username = "mapper"
+ }
+ }
}
}
};
diff --git a/osu.Game.Tests/Online/TestSceneOnlinePlayBeatmapAvailabilityTracker.cs b/osu.Game.Tests/Online/TestSceneOnlinePlayBeatmapAvailabilityTracker.cs
index a7b431fb6e..8c24b2eef8 100644
--- a/osu.Game.Tests/Online/TestSceneOnlinePlayBeatmapAvailabilityTracker.cs
+++ b/osu.Game.Tests/Online/TestSceneOnlinePlayBeatmapAvailabilityTracker.cs
@@ -60,9 +60,8 @@ namespace osu.Game.Tests.Online
testBeatmapInfo = getTestBeatmapInfo(testBeatmapFile);
testBeatmapSet = testBeatmapInfo.BeatmapSet;
- var existing = beatmaps.QueryBeatmapSet(s => s.OnlineID == testBeatmapSet.OnlineID);
- if (existing != null)
- beatmaps.Delete(existing);
+ ContextFactory.Context.Write(r => r.RemoveAll());
+ ContextFactory.Context.Write(r => r.RemoveAll());
selectedItem.Value = new PlaylistItem
{
@@ -103,10 +102,10 @@ namespace osu.Game.Tests.Online
AddStep("import beatmap", () => beatmaps.Import(testBeatmapFile).WaitSafely());
addAvailabilityCheckStep("state locally available", BeatmapAvailability.LocallyAvailable);
- AddStep("delete beatmap", () => beatmaps.Delete(beatmaps.QueryBeatmapSet(b => b.OnlineID == testBeatmapSet.OnlineID)));
+ AddStep("delete beatmap", () => beatmaps.Delete(beatmaps.QueryBeatmapSet(b => b.OnlineID == testBeatmapSet.OnlineID)!.Value));
addAvailabilityCheckStep("state not downloaded", BeatmapAvailability.NotDownloaded);
- AddStep("undelete beatmap", () => beatmaps.Undelete(beatmaps.QueryBeatmapSet(b => b.OnlineID == testBeatmapSet.OnlineID)));
+ AddStep("undelete beatmap", () => beatmaps.Undelete(beatmaps.QueryBeatmapSet(b => b.OnlineID == testBeatmapSet.OnlineID)!.Value));
addAvailabilityCheckStep("state locally available", BeatmapAvailability.LocallyAvailable);
}
@@ -154,7 +153,6 @@ namespace osu.Game.Tests.Online
Debug.Assert(info.BeatmapSet != null);
info.BeatmapSet.Beatmaps.Add(info);
- info.BeatmapSet.Metadata = info.Metadata;
info.MD5Hash = stream.ComputeMD5Hash();
info.Hash = stream.ComputeSHA2Hash();
}
@@ -168,22 +166,22 @@ namespace osu.Game.Tests.Online
public Task> CurrentImportTask { get; private set; }
- public TestBeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore resources, GameHost host = null, WorkingBeatmap defaultBeatmap = null)
+ public TestBeatmapManager(Storage storage, RealmContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore resources, GameHost host = null, WorkingBeatmap defaultBeatmap = null)
: base(storage, contextFactory, rulesets, api, audioManager, resources, host, defaultBeatmap)
{
}
- protected override BeatmapModelManager CreateBeatmapModelManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, GameHost host)
+ protected override BeatmapModelManager CreateBeatmapModelManager(Storage storage, RealmContextFactory contextFactory, RulesetStore rulesets, BeatmapOnlineLookupQueue onlineLookupQueue)
{
- return new TestBeatmapModelManager(this, storage, contextFactory, rulesets, api, host);
+ return new TestBeatmapModelManager(this, storage, contextFactory, rulesets, onlineLookupQueue);
}
internal class TestBeatmapModelManager : BeatmapModelManager
{
private readonly TestBeatmapManager testBeatmapManager;
- public TestBeatmapModelManager(TestBeatmapManager testBeatmapManager, Storage storage, IDatabaseContextFactory databaseContextFactory, RulesetStore rulesetStore, IAPIProvider apiProvider, GameHost gameHost)
- : base(storage, databaseContextFactory, rulesetStore, gameHost)
+ public TestBeatmapModelManager(TestBeatmapManager testBeatmapManager, Storage storage, RealmContextFactory databaseContextFactory, RulesetStore rulesetStore, BeatmapOnlineLookupQueue beatmapOnlineLookupQueue)
+ : base(databaseContextFactory, storage, beatmapOnlineLookupQueue)
{
this.testBeatmapManager = testBeatmapManager;
}
diff --git a/osu.Game.Tests/Resources/TestResources.cs b/osu.Game.Tests/Resources/TestResources.cs
index 445394fc77..d2cab09ac9 100644
--- a/osu.Game.Tests/Resources/TestResources.cs
+++ b/osu.Game.Tests/Resources/TestResources.cs
@@ -89,7 +89,7 @@ namespace osu.Game.Tests.Resources
// Create random metadata, then we can check if sorting works based on these
Artist = "Some Artist " + RNG.Next(0, 9),
Title = $"Some Song (set id {setId}) {Guid.NewGuid()}",
- AuthorString = "Some Guy " + RNG.Next(0, 9),
+ Author = { Username = "Some Guy " + RNG.Next(0, 9) },
};
var beatmapSet = new BeatmapSetInfo
@@ -97,7 +97,6 @@ namespace osu.Game.Tests.Resources
OnlineID = setId,
Hash = new MemoryStream(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString())).ComputeMD5Hash(),
DateAdded = DateTimeOffset.UtcNow,
- Metadata = metadata
};
foreach (var b in getBeatmaps(difficultyCount ?? RNG.Next(1, 20)))
@@ -131,10 +130,10 @@ namespace osu.Game.Tests.Resources
StarRating = diff,
Length = length,
BPM = bpm,
+ Hash = Guid.NewGuid().ToString().ComputeMD5Hash(),
Ruleset = rulesetInfo,
- RulesetID = rulesetInfo.ID ?? -1,
Metadata = metadata,
- BaseDifficulty = new BeatmapDifficulty
+ Difficulty = new BeatmapDifficulty
{
OverallDifficulty = diff,
}
@@ -166,7 +165,6 @@ namespace osu.Game.Tests.Resources
},
BeatmapInfo = beatmap,
Ruleset = beatmap.Ruleset,
- RulesetID = beatmap.Ruleset.ID ?? 0,
Mods = new Mod[] { new TestModHardRock(), new TestModDoubleTime() },
TotalScore = 2845370,
Accuracy = 0.95,
diff --git a/osu.Game.Tests/Scores/IO/ImportScoreTest.cs b/osu.Game.Tests/Scores/IO/ImportScoreTest.cs
index bbc92b7817..dd12c94855 100644
--- a/osu.Game.Tests/Scores/IO/ImportScoreTest.cs
+++ b/osu.Game.Tests/Scores/IO/ImportScoreTest.cs
@@ -8,8 +8,8 @@ using System.Linq;
using System.Threading.Tasks;
using NUnit.Framework;
using osu.Framework.Allocation;
+using osu.Framework.Extensions;
using osu.Framework.Platform;
-using osu.Game.Beatmaps;
using osu.Game.IO.Archives;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets.Mods;
@@ -17,6 +17,8 @@ using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
+using osu.Game.Tests.Beatmaps.IO;
+using osu.Game.Tests.Resources;
namespace osu.Game.Tests.Scores.IO
{
@@ -31,6 +33,8 @@ namespace osu.Game.Tests.Scores.IO
{
var osu = LoadOsuIntoHost(host, true);
+ var beatmap = BeatmapImportHelper.LoadOszIntoOsu(osu, TestResources.GetQuickTestBeatmapForImport()).GetResultSafely();
+
var toImport = new ScoreInfo
{
Rank = ScoreRank.B,
@@ -41,6 +45,8 @@ namespace osu.Game.Tests.Scores.IO
User = new APIUser { Username = "Test user" },
Date = DateTimeOffset.Now,
OnlineID = 12345,
+ Ruleset = new OsuRuleset().RulesetInfo,
+ BeatmapInfo = beatmap.Beatmaps.First()
};
var imported = await LoadScoreIntoOsu(osu, toImport);
@@ -49,7 +55,6 @@ namespace osu.Game.Tests.Scores.IO
Assert.AreEqual(toImport.TotalScore, imported.TotalScore);
Assert.AreEqual(toImport.Accuracy, imported.Accuracy);
Assert.AreEqual(toImport.MaxCombo, imported.MaxCombo);
- Assert.AreEqual(toImport.Combo, imported.Combo);
Assert.AreEqual(toImport.User.Username, imported.User.Username);
Assert.AreEqual(toImport.Date, imported.Date);
Assert.AreEqual(toImport.OnlineID, imported.OnlineID);
@@ -70,8 +75,13 @@ namespace osu.Game.Tests.Scores.IO
{
var osu = LoadOsuIntoHost(host, true);
+ var beatmap = BeatmapImportHelper.LoadOszIntoOsu(osu, TestResources.GetQuickTestBeatmapForImport()).GetResultSafely();
+
var toImport = new ScoreInfo
{
+ User = new APIUser { Username = "Test user" },
+ BeatmapInfo = beatmap.Beatmaps.First(),
+ Ruleset = new OsuRuleset().RulesetInfo,
Mods = new Mod[] { new OsuModHardRock(), new OsuModDoubleTime() },
};
@@ -96,8 +106,13 @@ namespace osu.Game.Tests.Scores.IO
{
var osu = LoadOsuIntoHost(host, true);
+ var beatmap = BeatmapImportHelper.LoadOszIntoOsu(osu, TestResources.GetQuickTestBeatmapForImport()).GetResultSafely();
+
var toImport = new ScoreInfo
{
+ User = new APIUser { Username = "Test user" },
+ BeatmapInfo = beatmap.Beatmaps.First(),
+ Ruleset = new OsuRuleset().RulesetInfo,
Statistics = new Dictionary
{
{ HitResult.Perfect, 100 },
@@ -117,43 +132,6 @@ namespace osu.Game.Tests.Scores.IO
}
}
- [Test]
- public async Task TestImportWithDeletedBeatmapSet()
- {
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
- {
- try
- {
- var osu = LoadOsuIntoHost(host, true);
-
- var toImport = new ScoreInfo
- {
- Hash = Guid.NewGuid().ToString(),
- Statistics = new Dictionary
- {
- { HitResult.Perfect, 100 },
- { HitResult.Miss, 50 }
- }
- };
-
- var imported = await LoadScoreIntoOsu(osu, toImport);
-
- var beatmapManager = osu.Dependencies.Get();
- var scoreManager = osu.Dependencies.Get();
-
- beatmapManager.Delete(beatmapManager.QueryBeatmapSet(s => s.Beatmaps.Any(b => b.ID == imported.BeatmapInfo.ID)));
- Assert.That(scoreManager.Query(s => s.Equals(imported)).DeletePending, Is.EqualTo(true));
-
- var secondImport = await LoadScoreIntoOsu(osu, imported);
- Assert.That(secondImport, Is.Null);
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
[Test]
public async Task TestOnlineScoreIsAvailableLocally()
{
@@ -163,12 +141,25 @@ namespace osu.Game.Tests.Scores.IO
{
var osu = LoadOsuIntoHost(host, true);
- await LoadScoreIntoOsu(osu, new ScoreInfo { OnlineID = 2 }, new TestArchiveReader());
+ var beatmap = BeatmapImportHelper.LoadOszIntoOsu(osu, TestResources.GetQuickTestBeatmapForImport()).GetResultSafely();
+
+ await LoadScoreIntoOsu(osu, new ScoreInfo
+ {
+ User = new APIUser { Username = "Test user" },
+ BeatmapInfo = beatmap.Beatmaps.First(),
+ Ruleset = new OsuRuleset().RulesetInfo,
+ OnlineID = 2
+ }, new TestArchiveReader());
var scoreManager = osu.Dependencies.Get();
// Note: A new score reference is used here since the import process mutates the original object to set an ID
- Assert.That(scoreManager.IsAvailableLocally(new ScoreInfo { OnlineID = 2 }));
+ Assert.That(scoreManager.IsAvailableLocally(new ScoreInfo
+ {
+ User = new APIUser { Username = "Test user" },
+ BeatmapInfo = beatmap.Beatmaps.First(),
+ OnlineID = 2
+ }));
}
finally
{
@@ -179,15 +170,13 @@ namespace osu.Game.Tests.Scores.IO
public static async Task LoadScoreIntoOsu(OsuGameBase osu, ScoreInfo score, ArchiveReader archive = null)
{
- var beatmapManager = osu.Dependencies.Get();
-
- score.BeatmapInfo ??= beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps.First();
- score.Ruleset ??= new OsuRuleset().RulesetInfo;
+ // clone to avoid attaching the input score to realm.
+ score = score.DeepClone();
var scoreManager = osu.Dependencies.Get();
await scoreManager.Import(score, archive);
- return scoreManager.GetAllUsableScores().FirstOrDefault();
+ return scoreManager.Query(_ => true);
}
internal class TestArchiveReader : ArchiveReader
diff --git a/osu.Game.Tests/Scores/IO/TestScoreEquality.cs b/osu.Game.Tests/Scores/IO/TestScoreEquality.cs
index 42fcb3acab..f898774ce6 100644
--- a/osu.Game.Tests/Scores/IO/TestScoreEquality.cs
+++ b/osu.Game.Tests/Scores/IO/TestScoreEquality.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using NUnit.Framework;
using osu.Game.Scoring;
@@ -29,8 +30,8 @@ namespace osu.Game.Tests.Scores.IO
[Test]
public void TestNonMatchingByPrimaryKey()
{
- ScoreInfo score1 = new ScoreInfo { ID = 1 };
- ScoreInfo score2 = new ScoreInfo { ID = 2 };
+ ScoreInfo score1 = new ScoreInfo { ID = Guid.NewGuid() };
+ ScoreInfo score2 = new ScoreInfo { ID = Guid.NewGuid() };
Assert.That(score1, Is.Not.EqualTo(score2));
}
@@ -38,8 +39,10 @@ namespace osu.Game.Tests.Scores.IO
[Test]
public void TestMatchingByPrimaryKey()
{
- ScoreInfo score1 = new ScoreInfo { ID = 1 };
- ScoreInfo score2 = new ScoreInfo { ID = 1 };
+ Guid id = Guid.NewGuid();
+
+ ScoreInfo score1 = new ScoreInfo { ID = id };
+ ScoreInfo score2 = new ScoreInfo { ID = id };
Assert.That(score1, Is.EqualTo(score2));
}
diff --git a/osu.Game.Tests/Skins/TestSceneBeatmapSkinResources.cs b/osu.Game.Tests/Skins/TestSceneBeatmapSkinResources.cs
index c20ab84a68..fe0423dcfc 100644
--- a/osu.Game.Tests/Skins/TestSceneBeatmapSkinResources.cs
+++ b/osu.Game.Tests/Skins/TestSceneBeatmapSkinResources.cs
@@ -26,8 +26,12 @@ namespace osu.Game.Tests.Skins
private void load()
{
var imported = beatmaps.Import(new ZipArchiveReader(TestResources.OpenResource("Archives/ogg-beatmap.osz"))).GetResultSafely();
- beatmap = beatmaps.GetWorkingBeatmap(imported.Value.Beatmaps[0]);
- beatmap.LoadTrack();
+
+ imported?.PerformRead(s =>
+ {
+ beatmap = beatmaps.GetWorkingBeatmap(s.Beatmaps[0]);
+ beatmap.LoadTrack();
+ });
}
[Test]
diff --git a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs
index 5b2cf877ba..4ab4c08353 100644
--- a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs
+++ b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs
@@ -50,6 +50,7 @@ namespace osu.Game.Tests.Visual.Background
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
Dependencies.Cache(new OsuConfigManager(LocalStorage));
+ Dependencies.Cache(ContextFactory);
manager.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
@@ -387,6 +388,9 @@ namespace osu.Game.Tests.Visual.Background
while (BlockLoad && !token.IsCancellationRequested)
Thread.Sleep(1);
+ if (!LoadedBeatmapSuccessfully)
+ return;
+
StoryboardEnabled = config.GetBindable(OsuSetting.ShowStoryboard);
DrawableRuleset.IsPaused.BindTo(IsPaused);
}
diff --git a/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapCard.cs b/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapCard.cs
index 7b5e1f4ec7..94b693363a 100644
--- a/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapCard.cs
+++ b/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapCard.cs
@@ -204,7 +204,7 @@ namespace osu.Game.Tests.Visual.Beatmaps
{
var beatmap = beatmaps.QueryBeatmapSet(b => b.OnlineID == online_id);
- if (beatmap != null) beatmaps.Delete(beatmap);
+ if (beatmap != null) beatmaps.Delete(beatmap.Value);
});
}
diff --git a/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapCardDifficultyList.cs b/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapCardDifficultyList.cs
index aec75884d6..e6fb4372ff 100644
--- a/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapCardDifficultyList.cs
+++ b/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapCardDifficultyList.cs
@@ -6,7 +6,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps.Drawables.Cards;
-using osu.Game.Graphics;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
@@ -18,7 +17,7 @@ namespace osu.Game.Tests.Visual.Beatmaps
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
[BackgroundDependencyLoader]
- private void load(OsuColour colours)
+ private void load()
{
var beatmapSet = new APIBeatmapSet
{
diff --git a/osu.Game.Tests/Visual/Collections/TestSceneManageCollectionsDialog.cs b/osu.Game.Tests/Visual/Collections/TestSceneManageCollectionsDialog.cs
index d2b0f7324b..18572ac211 100644
--- a/osu.Game.Tests/Visual/Collections/TestSceneManageCollectionsDialog.cs
+++ b/osu.Game.Tests/Visual/Collections/TestSceneManageCollectionsDialog.cs
@@ -38,6 +38,7 @@ namespace osu.Game.Tests.Visual.Collections
{
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
Dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, Audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(ContextFactory);
beatmapManager.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
diff --git a/osu.Game.Tests/Visual/Editing/TestSceneComposeScreen.cs b/osu.Game.Tests/Visual/Editing/TestSceneComposeScreen.cs
index 9b8567e853..d100fba8d6 100644
--- a/osu.Game.Tests/Visual/Editing/TestSceneComposeScreen.cs
+++ b/osu.Game.Tests/Visual/Editing/TestSceneComposeScreen.cs
@@ -29,9 +29,10 @@ namespace osu.Game.Tests.Visual.Editing
[Cached]
private EditorClipboard clipboard = new EditorClipboard();
- [BackgroundDependencyLoader]
- private void load()
+ protected override void LoadComplete()
{
+ base.LoadComplete();
+
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
Child = new ComposeScreen
diff --git a/osu.Game.Tests/Visual/Editing/TestSceneDesignSection.cs b/osu.Game.Tests/Visual/Editing/TestSceneDesignSection.cs
index 00f2979691..10917df075 100644
--- a/osu.Game.Tests/Visual/Editing/TestSceneDesignSection.cs
+++ b/osu.Game.Tests/Visual/Editing/TestSceneDesignSection.cs
@@ -11,6 +11,7 @@ using osu.Framework.Graphics.UserInterface;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterfaceV2;
+using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Setup;
using osuTK.Input;
@@ -25,7 +26,13 @@ namespace osu.Game.Tests.Visual.Editing
[SetUpSteps]
public void SetUp()
{
- AddStep("create blank beatmap", () => editorBeatmap = new EditorBeatmap(new Beatmap()));
+ AddStep("create blank beatmap", () => editorBeatmap = new EditorBeatmap(new Beatmap
+ {
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo
+ }
+ }));
AddStep("create section", () => Child = new DependencyProvidingContainer
{
RelativeSizeAxes = Axes.Both,
diff --git a/osu.Game.Tests/Visual/Editing/TestSceneDifficultySwitching.cs b/osu.Game.Tests/Visual/Editing/TestSceneDifficultySwitching.cs
index 516305079b..243bb71e26 100644
--- a/osu.Game.Tests/Visual/Editing/TestSceneDifficultySwitching.cs
+++ b/osu.Game.Tests/Visual/Editing/TestSceneDifficultySwitching.cs
@@ -33,7 +33,7 @@ namespace osu.Game.Tests.Visual.Editing
public override void SetUpSteps()
{
- AddStep("import test beatmap", () => importedBeatmapSet = ImportBeatmapTest.LoadOszIntoOsu(game, virtualTrack: true).GetResultSafely());
+ AddStep("import test beatmap", () => importedBeatmapSet = BeatmapImportHelper.LoadOszIntoOsu(game, virtualTrack: true).GetResultSafely());
base.SetUpSteps();
}
diff --git a/osu.Game.Tests/Visual/Editing/TestSceneDistanceSnapGrid.cs b/osu.Game.Tests/Visual/Editing/TestSceneDistanceSnapGrid.cs
index d1efd22d6f..0d9e06e471 100644
--- a/osu.Game.Tests/Visual/Editing/TestSceneDistanceSnapGrid.cs
+++ b/osu.Game.Tests/Visual/Editing/TestSceneDistanceSnapGrid.cs
@@ -8,6 +8,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
+using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Beatmaps;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose.Components;
@@ -29,7 +30,13 @@ namespace osu.Game.Tests.Visual.Editing
public TestSceneDistanceSnapGrid()
{
- editorBeatmap = new EditorBeatmap(new OsuBeatmap());
+ editorBeatmap = new EditorBeatmap(new OsuBeatmap
+ {
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo
+ }
+ });
editorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = beat_length });
}
diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs
index db20d3c7ba..2386446e96 100644
--- a/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs
+++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs
@@ -49,8 +49,7 @@ namespace osu.Game.Tests.Visual.Editing
public void TestCreateNewBeatmap()
{
AddStep("save beatmap", () => Editor.Save());
- AddAssert("new beatmap persisted", () => EditorBeatmap.BeatmapInfo.IsManaged);
- AddAssert("new beatmap in database", () => beatmapManager.QueryBeatmapSet(s => s.ID == EditorBeatmap.BeatmapInfo.BeatmapSet.ID)?.DeletePending == false);
+ AddAssert("new beatmap in database", () => beatmapManager.QueryBeatmapSet(s => s.ID == EditorBeatmap.BeatmapInfo.BeatmapSet.ID)?.Value.DeletePending == false);
}
[Test]
@@ -66,7 +65,7 @@ namespace osu.Game.Tests.Visual.Editing
});
AddUntilStep("wait for exit", () => !Editor.IsCurrentScreen());
- AddAssert("new beatmap not persisted", () => beatmapManager.QueryBeatmapSet(s => s.ID == editorBeatmap.BeatmapInfo.BeatmapSet.ID)?.DeletePending == true);
+ AddAssert("new beatmap not persisted", () => beatmapManager.QueryBeatmapSet(s => s.ID == editorBeatmap.BeatmapInfo.BeatmapSet.ID)?.Value.DeletePending == true);
}
[Test]
diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorClock.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorClock.cs
index 0abf0c47f8..4b9be77471 100644
--- a/osu.Game.Tests/Visual/Editing/TestSceneEditorClock.cs
+++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorClock.cs
@@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
-using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Osu;
@@ -37,9 +36,10 @@ namespace osu.Game.Tests.Visual.Editing
});
}
- [BackgroundDependencyLoader]
- private void load()
+ protected override void LoadComplete()
{
+ base.LoadComplete();
+
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
// ensure that music controller does not change this beatmap due to it
// completing naturally as part of the test.
diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorSeekSnapping.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorSeekSnapping.cs
index 3a19eabe81..863f42520b 100644
--- a/osu.Game.Tests/Visual/Editing/TestSceneEditorSeekSnapping.cs
+++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorSeekSnapping.cs
@@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
-using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@@ -23,9 +22,10 @@ namespace osu.Game.Tests.Visual.Editing
BeatDivisor.Value = 4;
}
- [BackgroundDependencyLoader]
- private void load()
+ protected override void LoadComplete()
{
+ base.LoadComplete();
+
var testBeatmap = new Beatmap
{
ControlPointInfo = new ControlPointInfo(),
diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs
index 6d48ef3ba7..bb630e5d5c 100644
--- a/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs
+++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs
@@ -39,7 +39,7 @@ namespace osu.Game.Tests.Visual.Editing
public override void SetUpSteps()
{
- AddStep("import test beatmap", () => importedBeatmapSet = ImportBeatmapTest.LoadOszIntoOsu(game).GetResultSafely());
+ AddStep("import test beatmap", () => importedBeatmapSet = BeatmapImportHelper.LoadOszIntoOsu(game).GetResultSafely());
base.SetUpSteps();
}
diff --git a/osu.Game.Tests/Visual/Editing/TestSceneHitObjectComposer.cs b/osu.Game.Tests/Visual/Editing/TestSceneHitObjectComposer.cs
index eee0d6672c..145d738f60 100644
--- a/osu.Game.Tests/Visual/Editing/TestSceneHitObjectComposer.cs
+++ b/osu.Game.Tests/Visual/Editing/TestSceneHitObjectComposer.cs
@@ -39,9 +39,16 @@ namespace osu.Game.Tests.Visual.Editing
{
Beatmap.Value = CreateWorkingBeatmap(new Beatmap
{
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo
+ },
HitObjects = new List
{
- new HitCircle { Position = new Vector2(256, 192), Scale = 0.5f },
+ new HitCircle
+ {
+ Position = new Vector2(256, 192), Scale = 0.5f
+ },
new HitCircle { Position = new Vector2(344, 148), Scale = 0.5f },
new Slider
{
diff --git a/osu.Game.Tests/Visual/Editing/TestSceneMetadataSection.cs b/osu.Game.Tests/Visual/Editing/TestSceneMetadataSection.cs
index 4621436cc6..4ecfb0975b 100644
--- a/osu.Game.Tests/Visual/Editing/TestSceneMetadataSection.cs
+++ b/osu.Game.Tests/Visual/Editing/TestSceneMetadataSection.cs
@@ -5,6 +5,7 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterfaceV2;
+using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Setup;
@@ -13,7 +14,13 @@ namespace osu.Game.Tests.Visual.Editing
public class TestSceneMetadataSection : OsuTestScene
{
[Cached]
- private EditorBeatmap editorBeatmap = new EditorBeatmap(new Beatmap());
+ private EditorBeatmap editorBeatmap = new EditorBeatmap(new Beatmap
+ {
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo
+ },
+ });
private TestMetadataSection metadataSection;
diff --git a/osu.Game.Tests/Visual/Editing/TestSceneSetupScreen.cs b/osu.Game.Tests/Visual/Editing/TestSceneSetupScreen.cs
index 03e78ce854..2f6cf46b21 100644
--- a/osu.Game.Tests/Visual/Editing/TestSceneSetupScreen.cs
+++ b/osu.Game.Tests/Visual/Editing/TestSceneSetupScreen.cs
@@ -29,7 +29,13 @@ namespace osu.Game.Tests.Visual.Editing
public TestSceneSetupScreen()
{
- editorBeatmap = new EditorBeatmap(new OsuBeatmap());
+ editorBeatmap = new EditorBeatmap(new OsuBeatmap
+ {
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo
+ }
+ });
}
[Test]
diff --git a/osu.Game.Tests/Visual/Editing/TestSceneTimingScreen.cs b/osu.Game.Tests/Visual/Editing/TestSceneTimingScreen.cs
index 4bbffbdc7a..17b8189fc7 100644
--- a/osu.Game.Tests/Visual/Editing/TestSceneTimingScreen.cs
+++ b/osu.Game.Tests/Visual/Editing/TestSceneTimingScreen.cs
@@ -29,9 +29,10 @@ namespace osu.Game.Tests.Visual.Editing
editorBeatmap = new EditorBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo));
}
- [BackgroundDependencyLoader]
- private void load()
+ protected override void LoadComplete()
{
+ base.LoadComplete();
+
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
Beatmap.Disabled = true;
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneAllRulesetPlayers.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneAllRulesetPlayers.cs
index c5ab3974a4..e10ef57a25 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneAllRulesetPlayers.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneAllRulesetPlayers.cs
@@ -25,7 +25,7 @@ namespace osu.Game.Tests.Visual.Gameplay
protected OsuConfigManager Config { get; private set; }
[BackgroundDependencyLoader]
- private void load(RulesetStore rulesets)
+ private void load()
{
Dependencies.Cache(Config = new OsuConfigManager(LocalStorage));
Config.GetBindable(OsuSetting.DimLevel).Value = 1.0;
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySampleTriggerSource.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySampleTriggerSource.cs
index fccc1a377c..ac39395567 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySampleTriggerSource.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySampleTriggerSource.cs
@@ -29,7 +29,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
BeatmapInfo = new BeatmapInfo
{
- BaseDifficulty = new BeatmapDifficulty { CircleSize = 6, SliderMultiplier = 3 },
+ Difficulty = new BeatmapDifficulty { CircleSize = 6, SliderMultiplier = 3 },
Ruleset = ruleset
}
};
diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerScoreSubmission.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerScoreSubmission.cs
index cf5aadde6d..a4a4f351ec 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerScoreSubmission.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerScoreSubmission.cs
@@ -237,7 +237,7 @@ namespace osu.Game.Tests.Visual.Gameplay
createPlayerTest(false, r =>
{
var beatmap = createTestBeatmap(r);
- beatmap.BeatmapInfo.OnlineID = null;
+ beatmap.BeatmapInfo.OnlineID = -1;
return beatmap;
});
@@ -255,7 +255,15 @@ namespace osu.Game.Tests.Visual.Gameplay
{
prepareTestAPI(true);
- createPlayerTest(false, createRuleset: () => new OsuRuleset { RulesetInfo = { OnlineID = rulesetId ?? -1 } });
+ createPlayerTest(false, createRuleset: () => new OsuRuleset
+ {
+ RulesetInfo =
+ {
+ Name = "custom",
+ ShortName = $"custom{rulesetId}",
+ OnlineID = rulesetId ?? -1
+ }
+ });
AddUntilStep("wait for token request", () => Player.TokenCreationRequested);
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs
index 3168c4b94e..8199389b36 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs
@@ -6,16 +6,18 @@ using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Game.Online;
using osu.Game.Online.API.Requests.Responses;
-using osu.Game.Scoring;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Testing;
+using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
+using osu.Game.Scoring;
using osu.Game.Screens.Ranking;
+using osu.Game.Tests.Resources;
using osuTK.Input;
using APIUser = osu.Game.Online.API.Requests.Responses.APIUser;
@@ -29,6 +31,18 @@ namespace osu.Game.Tests.Visual.Gameplay
private TestReplayDownloadButton downloadButton;
+ [Resolved]
+ private BeatmapManager beatmapManager { get; set; }
+
+ [Resolved]
+ private ScoreManager scoreManager { get; set; }
+
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ beatmapManager.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
+ }
+
[Test]
public void TestDisplayStates()
{
@@ -115,9 +129,6 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("button is not enabled", () => !downloadButton.ChildrenOfType().First().Enabled.Value);
}
- [Resolved]
- private ScoreManager scoreManager { get; set; }
-
[Test]
public void TestScoreImportThenDelete()
{
@@ -176,7 +187,7 @@ namespace osu.Game.Tests.Visual.Gameplay
Id = 39828,
Username = @"WubWoofWolf",
}
- }.CreateScoreInfo(rulesets, CreateBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo);
+ }.CreateScoreInfo(rulesets, beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps.First());
}
private class TestReplayDownloadButton : ReplayDownloadButton
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs
index e6361a15d7..4eab1a21da 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs
@@ -64,7 +64,11 @@ namespace osu.Game.Tests.Visual.Gameplay
Recorder = recorder = new TestReplayRecorder(new Score
{
Replay = replay,
- ScoreInfo = { BeatmapInfo = gameplayState.Beatmap.BeatmapInfo }
+ ScoreInfo =
+ {
+ BeatmapInfo = gameplayState.Beatmap.BeatmapInfo,
+ Ruleset = new OsuRuleset().RulesetInfo,
+ }
})
{
ScreenSpaceToGamefield = pos => recordingManager.ToLocalSpace(pos),
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs
index 242eca0bbc..8b7e1a1d85 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs
@@ -61,8 +61,8 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("import beatmap", () =>
{
- importedBeatmap = ImportBeatmapTest.LoadOszIntoOsu(game, virtualTrack: true).GetResultSafely();
- importedBeatmapId = importedBeatmap.Beatmaps.First(b => b.RulesetID == 0).OnlineID ?? -1;
+ importedBeatmap = BeatmapImportHelper.LoadOszIntoOsu(game, virtualTrack: true).GetResultSafely();
+ importedBeatmapId = importedBeatmap.Beatmaps.First(b => b.RulesetID == 0).OnlineID;
});
}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs
index f7e9a1fe16..4790bd44db 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs
@@ -372,7 +372,14 @@ namespace osu.Game.Tests.Visual.Gameplay
internal class TestReplayRecorder : ReplayRecorder
{
public TestReplayRecorder()
- : base(new Score { ScoreInfo = { BeatmapInfo = new BeatmapInfo() } })
+ : base(new Score
+ {
+ ScoreInfo =
+ {
+ BeatmapInfo = new BeatmapInfo(),
+ Ruleset = new OsuRuleset().RulesetInfo,
+ }
+ })
{
}
diff --git a/osu.Game.Tests/Visual/Menus/TestSceneMusicActionHandling.cs b/osu.Game.Tests/Visual/Menus/TestSceneMusicActionHandling.cs
index ee9363fa12..3ebc64cd0b 100644
--- a/osu.Game.Tests/Visual/Menus/TestSceneMusicActionHandling.cs
+++ b/osu.Game.Tests/Visual/Menus/TestSceneMusicActionHandling.cs
@@ -39,7 +39,10 @@ namespace osu.Game.Tests.Visual.Menus
AddStep("import beatmap with track", () =>
{
var setWithTrack = Game.BeatmapManager.Import(new ImportTask(TestResources.GetTestBeatmapForImport())).GetResultSafely();
- Beatmap.Value = Game.BeatmapManager.GetWorkingBeatmap(setWithTrack.Value.Beatmaps.First());
+ setWithTrack?.PerformRead(s =>
+ {
+ Beatmap.Value = Game.BeatmapManager.GetWorkingBeatmap(s.Beatmaps.First());
+ });
});
AddStep("bind to track change", () =>
diff --git a/osu.Game.Tests/Visual/Multiplayer/QueueModeTestScene.cs b/osu.Game.Tests/Visual/Multiplayer/QueueModeTestScene.cs
index c4d7bd7e6a..d4282ff21e 100644
--- a/osu.Game.Tests/Visual/Multiplayer/QueueModeTestScene.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/QueueModeTestScene.cs
@@ -49,6 +49,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(ContextFactory);
}
public override void SetUpSteps()
@@ -58,7 +59,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("import beatmap", () =>
{
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
- importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
+ importedSet = beatmaps.GetAllUsableBeatmapSets().First();
InitialBeatmap = importedSet.Beatmaps.First(b => b.RulesetID == 0);
OtherBeatmap = importedSet.Beatmaps.Last(b => b.RulesetID == 0);
});
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs
index 147bbf2626..99c867b014 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs
@@ -17,7 +17,7 @@ using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Database;
using osu.Game.Graphics.Containers;
-using osu.Game.Online.API.Requests.Responses;
+using osu.Game.Models;
using osu.Game.Online.Rooms;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
@@ -45,6 +45,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(ContextFactory);
}
[Test]
@@ -153,17 +154,20 @@ namespace osu.Game.Tests.Visual.Multiplayer
public void TestDownloadButtonHiddenWhenBeatmapExists()
{
var beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo;
+ ILive imported = null;
- AddStep("import beatmap", () => manager.Import(beatmap.BeatmapSet).WaitSafely());
+ Debug.Assert(beatmap.BeatmapSet != null);
- createPlaylistWithBeatmaps(beatmap);
+ AddStep("import beatmap", () => imported = manager.Import(beatmap.BeatmapSet).GetResultSafely());
+
+ createPlaylistWithBeatmaps(() => imported.PerformRead(s => s.Beatmaps.Detach()));
assertDownloadButtonVisible(false);
- AddStep("delete beatmap set", () => manager.Delete(manager.QueryBeatmapSets(_ => true).Single()));
+ AddStep("delete beatmap set", () => imported.PerformWrite(s => s.DeletePending = true));
assertDownloadButtonVisible(true);
- AddStep("undelete beatmap set", () => manager.Undelete(manager.QueryBeatmapSets(_ => true).Single()));
+ AddStep("undelete beatmap set", () => imported.PerformWrite(s => s.DeletePending = false));
assertDownloadButtonVisible(false);
void assertDownloadButtonVisible(bool visible) => AddUntilStep($"download button {(visible ? "shown" : "hidden")}",
@@ -179,7 +183,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
var byChecksum = CreateAPIBeatmap();
byChecksum.Checksum = "1337"; // Some random checksum that does not exist locally.
- createPlaylistWithBeatmaps(byOnlineId, byChecksum);
+ createPlaylistWithBeatmaps(() => new[] { byOnlineId, byChecksum });
AddAssert("download buttons shown", () => playlist.ChildrenOfType().All(d => d.IsPresent));
}
@@ -193,7 +197,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
beatmap.BeatmapSet.HasExplicitContent = true;
- createPlaylistWithBeatmaps(beatmap);
+ createPlaylistWithBeatmaps(() => new[] { beatmap });
}
[Test]
@@ -305,7 +309,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
Metadata = new BeatmapMetadata
{
Artist = "Artist",
- Author = new APIUser { Username = "Creator name here" },
+ Author = new RealmUser { Username = "Creator name here" },
Title = "Long title used to check background colour",
},
BeatmapSet = new BeatmapSetInfo()
@@ -325,7 +329,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddUntilStep("wait for items to load", () => playlist.ItemMap.Values.All(i => i.IsLoaded));
}
- private void createPlaylistWithBeatmaps(params IBeatmapInfo[] beatmaps)
+ private void createPlaylistWithBeatmaps(Func> beatmaps)
{
AddStep("create playlist", () =>
{
@@ -338,7 +342,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
int index = 0;
- foreach (var b in beatmaps)
+ foreach (var b in beatmaps())
{
playlist.Items.Add(new PlaylistItem
{
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiSpectatorScreen.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiSpectatorScreen.cs
index 61058bc87a..9d67742e4d 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiSpectatorScreen.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiSpectatorScreen.cs
@@ -47,9 +47,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
[BackgroundDependencyLoader]
private void load()
{
- importedSet = ImportBeatmapTest.LoadOszIntoOsu(game, virtualTrack: true).GetResultSafely();
+ importedSet = BeatmapImportHelper.LoadOszIntoOsu(game, virtualTrack: true).GetResultSafely();
importedBeatmap = importedSet.Beatmaps.First(b => b.RulesetID == 0);
- importedBeatmapId = importedBeatmap.OnlineID ?? -1;
+ importedBeatmapId = importedBeatmap.OnlineID;
}
[SetUp]
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs
index 3d8c5298dc..373b165acc 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs
@@ -62,7 +62,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
private void load(GameHost host, AudioManager audio)
{
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
- Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, API, audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(ContextFactory);
}
public override void SetUpSteps()
@@ -72,7 +73,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("import beatmap", () =>
{
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
- importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
+ importedSet = beatmaps.GetAllUsableBeatmapSets().First();
});
AddStep("load multiplayer", () => LoadScreen(multiplayerComponents = new TestMultiplayerComponents()));
@@ -588,7 +589,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("restore beatmap", () =>
{
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
- importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
+ importedSet = beatmaps.GetAllUsableBeatmapSets().First();
});
AddUntilStep("play started", () => multiplayerComponents.CurrentScreen is SpectatorScreen);
@@ -827,7 +828,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("join other user", () => client.AddUser(new APIUser { Id = 1234 }));
AddStep("add item as other user", () => client.AddUserPlaylistItem(1234, new MultiplayerPlaylistItem(new PlaylistItem
{
- BeatmapID = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.RulesetID == 0)).BeatmapInfo.OnlineID ?? -1
+ BeatmapID = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.RulesetID == 0)).BeatmapInfo.OnlineID
})));
AddUntilStep("item arrived in playlist", () => client.Room?.Playlist.Count == 2);
@@ -858,7 +859,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("join other user", () => client.AddUser(new APIUser { Id = 1234 }));
AddStep("add item as other user", () => client.AddUserPlaylistItem(1234, new MultiplayerPlaylistItem(new PlaylistItem
{
- BeatmapID = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.RulesetID == 0)).BeatmapInfo.OnlineID ?? -1
+ BeatmapID = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.RulesetID == 0)).BeatmapInfo.OnlineID
})));
AddUntilStep("item arrived in playlist", () => client.Room?.Playlist.Count == 2);
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboard.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboard.cs
index 07a8ef66e1..9b8e67b07a 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboard.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboard.cs
@@ -58,7 +58,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
foreach (int user in users)
{
- SpectatorClient.StartPlay(user, Beatmap.Value.BeatmapInfo.OnlineID ?? 0);
+ SpectatorClient.StartPlay(user, Beatmap.Value.BeatmapInfo.OnlineID);
multiplayerUsers.Add(OnlinePlayDependencies.Client.AddUser(new APIUser { Id = user }, true));
}
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboardTeams.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboardTeams.cs
index 1237a21e94..8a78c12042 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboardTeams.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboardTeams.cs
@@ -62,7 +62,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
foreach (int user in users)
{
- SpectatorClient.StartPlay(user, Beatmap.Value.BeatmapInfo.OnlineID ?? 0);
+ SpectatorClient.StartPlay(user, Beatmap.Value.BeatmapInfo.OnlineID);
var roomUser = OnlinePlayDependencies.Client.AddUser(new APIUser { Id = user }, true);
roomUser.MatchState = new TeamVersusUserState
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSongSelect.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSongSelect.cs
index bd4b38b9c0..15ebe0ee00 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSongSelect.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSongSelect.cs
@@ -44,6 +44,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(ContextFactory);
beatmaps = new List();
@@ -51,14 +52,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
Artist = "Some Artist",
Title = "Some Beatmap",
- AuthorString = "Some Author"
+ Author = { Username = "Some Author" },
};
var beatmapSetInfo = new BeatmapSetInfo
{
OnlineID = 10,
Hash = Guid.NewGuid().ToString().ComputeMD5Hash(),
- Metadata = metadata,
DateAdded = DateTimeOffset.UtcNow
};
@@ -71,12 +71,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
var beatmap = new BeatmapInfo
{
- Ruleset = rulesets.GetRuleset(i % 4),
+ Ruleset = rulesets.GetRuleset(i % 4) ?? throw new InvalidOperationException(),
OnlineID = beatmapId,
Length = length,
BPM = bpm,
Metadata = metadata,
- BaseDifficulty = new BeatmapDifficulty()
+ Difficulty = new BeatmapDifficulty()
};
beatmaps.Add(beatmap);
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSubScreen.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSubScreen.cs
index 52e46ef5af..012a2fd960 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSubScreen.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSubScreen.cs
@@ -40,9 +40,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(ContextFactory);
+
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
- importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
+ importedSet = beatmaps.GetAllUsableBeatmapSets().First();
}
[SetUp]
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs
index 464c0ea5b6..d547b42891 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs
@@ -35,6 +35,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(ContextFactory);
}
[SetUp]
@@ -55,7 +56,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("import beatmap", () =>
{
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
- importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
+ importedSet = beatmaps.GetAllUsableBeatmapSets().First();
importedBeatmap = importedSet.Beatmaps.First(b => b.RulesetID == 0);
});
@@ -169,7 +170,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
private void addItemStep(bool expired = false) => AddStep("add item", () => Client.AddPlaylistItem(new MultiplayerPlaylistItem(new PlaylistItem
{
Beatmap = { Value = importedBeatmap },
- BeatmapID = importedBeatmap.OnlineID ?? -1,
+ BeatmapID = importedBeatmap.OnlineID,
Expired = expired,
PlayedAt = DateTimeOffset.Now
})));
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerQueueList.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerQueueList.cs
index 29daff546d..965b142ed7 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerQueueList.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerQueueList.cs
@@ -39,7 +39,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
private void load(GameHost host, AudioManager audio)
{
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
- Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, API, audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(ContextFactory);
}
public override void SetUpSteps()
@@ -60,7 +61,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("import beatmap", () =>
{
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
- importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
+ importedSet = beatmaps.GetAllUsableBeatmapSets().First();
importedBeatmap = importedSet.Beatmaps.First(b => b.RulesetID == 0);
});
@@ -126,7 +127,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
MultiplayerPlaylistItem item = new MultiplayerPlaylistItem(new PlaylistItem
{
Beatmap = { Value = importedBeatmap },
- BeatmapID = importedBeatmap.OnlineID ?? -1,
+ BeatmapID = importedBeatmap.OnlineID,
});
Client.AddUserPlaylistItem(userId(), item);
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerReadyButton.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerReadyButton.cs
index 8f51b1e381..1c346e09d5 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerReadyButton.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerReadyButton.cs
@@ -42,6 +42,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(ContextFactory);
+
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
}
@@ -50,7 +52,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
AvailabilityTracker.SelectedItem.BindTo(selectedItem);
- importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
+ importedSet = beatmaps.GetAllUsableBeatmapSets().First();
Beatmap.Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First());
selectedItem.Value = new PlaylistItem
{
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerResults.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerResults.cs
index 4674601f28..44a1745eee 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerResults.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerResults.cs
@@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
PlaylistItem playlistItem = new PlaylistItem
{
- BeatmapID = beatmapInfo.OnlineID ?? -1,
+ BeatmapID = beatmapInfo.OnlineID,
};
Stack.Push(screen = new MultiplayerResultsScreen(score, 1, playlistItem));
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerSpectateButton.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerSpectateButton.cs
index d4ff9f8c41..221732910b 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerSpectateButton.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerSpectateButton.cs
@@ -43,6 +43,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(ContextFactory);
+
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
}
@@ -51,7 +53,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
AvailabilityTracker.SelectedItem.BindTo(selectedItem);
- importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
+ importedSet = beatmaps.GetAllUsableBeatmapSets().First();
Beatmap.Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First());
selectedItem.Value = new PlaylistItem
{
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerTeamResults.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerTeamResults.cs
index f5df8d7507..dfc16c44f2 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerTeamResults.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerTeamResults.cs
@@ -28,7 +28,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
PlaylistItem playlistItem = new PlaylistItem
{
- BeatmapID = beatmapInfo.OnlineID ?? -1,
+ BeatmapID = beatmapInfo.OnlineID,
};
SortedDictionary teamScores = new SortedDictionary
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestScenePlaylistsRoomSettingsPlaylist.cs b/osu.Game.Tests/Visual/Multiplayer/TestScenePlaylistsRoomSettingsPlaylist.cs
index 93ccd5f1e1..e63e58824f 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestScenePlaylistsRoomSettingsPlaylist.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestScenePlaylistsRoomSettingsPlaylist.cs
@@ -12,7 +12,7 @@ using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Database;
using osu.Game.Graphics.Containers;
-using osu.Game.Online.API.Requests.Responses;
+using osu.Game.Models;
using osu.Game.Online.Rooms;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Mods;
@@ -155,7 +155,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
Metadata = new BeatmapMetadata
{
Artist = "Artist",
- Author = new APIUser { Username = "Creator name here" },
+ Author = new RealmUser { Username = "Creator name here" },
Title = "Long title used to check background colour",
},
BeatmapSet = new BeatmapSetInfo()
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestScenePlaylistsSongSelect.cs b/osu.Game.Tests/Visual/Multiplayer/TestScenePlaylistsSongSelect.cs
index 08fcac125d..0b0006e437 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestScenePlaylistsSongSelect.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestScenePlaylistsSongSelect.cs
@@ -36,6 +36,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(ContextFactory);
var beatmapSet = TestResources.CreateTestBeatmapSetInfo();
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneTeamVersus.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneTeamVersus.cs
index d20fbd3539..39cde0ad87 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneTeamVersus.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneTeamVersus.cs
@@ -44,6 +44,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(ContextFactory);
}
public override void SetUpSteps()
@@ -53,7 +54,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("import beatmap", () =>
{
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
- importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
+ importedSet = beatmaps.GetAllUsableBeatmapSets().First();
});
AddStep("load multiplayer", () => LoadScreen(multiplayerComponents = new TestMultiplayerComponents()));
diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneChangeAndUseGameplayBindings.cs b/osu.Game.Tests/Visual/Navigation/TestSceneChangeAndUseGameplayBindings.cs
new file mode 100644
index 0000000000..0f314242b4
--- /dev/null
+++ b/osu.Game.Tests/Visual/Navigation/TestSceneChangeAndUseGameplayBindings.cs
@@ -0,0 +1,88 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Linq;
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Extensions;
+using osu.Framework.Input.Bindings;
+using osu.Framework.Testing;
+using osu.Game.Database;
+using osu.Game.Graphics.UserInterface;
+using osu.Game.Input.Bindings;
+using osu.Game.Overlays.Settings.Sections.Input;
+using osu.Game.Screens.Play;
+using osu.Game.Screens.Select;
+using osu.Game.Tests.Beatmaps.IO;
+using osuTK.Input;
+
+namespace osu.Game.Tests.Visual.Navigation
+{
+ public class TestSceneChangeAndUseGameplayBindings : OsuGameTestScene
+ {
+ [Test]
+ public void TestGameplayKeyBindings()
+ {
+ AddAssert("databased key is default", () => firstOsuRulesetKeyBindings.KeyCombination.Keys.SequenceEqual(new[] { InputKey.Z }));
+
+ AddStep("open settings", () => { Game.Settings.Show(); });
+
+ // Until step requires as settings has a delayed load.
+ AddUntilStep("wait for button", () => configureBindingsButton?.Enabled.Value == true);
+ AddStep("scroll to section", () => Game.Settings.SectionsContainer.ScrollTo(configureBindingsButton));
+ AddStep("press button", () => configureBindingsButton.TriggerClick());
+ AddUntilStep("wait for panel", () => keyBindingPanel?.IsLoaded == true);
+ AddUntilStep("wait for osu subsection", () => osuBindingSubsection?.IsLoaded == true);
+ AddStep("scroll to section", () => keyBindingPanel.SectionsContainer.ScrollTo(osuBindingSubsection));
+ AddWaitStep("wait for scroll to end", 3);
+ AddStep("start rebinding first osu! key", () =>
+ {
+ var button = osuBindingSubsection.ChildrenOfType().First();
+
+ InputManager.MoveMouseTo(button);
+ InputManager.Click(MouseButton.Left);
+ });
+
+ AddStep("Press 's'", () => InputManager.Key(Key.S));
+
+ AddUntilStep("wait for database updated", () => firstOsuRulesetKeyBindings.KeyCombination.Keys.SequenceEqual(new[] { InputKey.S }));
+
+ AddStep("close settings", () => Game.Settings.Hide());
+
+ AddStep("import beatmap", () => BeatmapImportHelper.LoadQuickOszIntoOsu(Game).WaitSafely());
+ PushAndConfirm(() => new PlaySongSelect());
+
+ AddStep("enter gameplay", () => InputManager.Key(Key.Enter));
+
+ AddUntilStep("wait for gameplay", () => player?.IsBreakTime.Value == false);
+
+ AddStep("press 'z'", () => InputManager.Key(Key.Z));
+ AddAssert("key counter didn't increase", () => keyCounter.CountPresses == 0);
+
+ AddStep("press 's'", () => InputManager.Key(Key.S));
+ AddAssert("key counter did increase", () => keyCounter.CountPresses == 1);
+ }
+
+ private KeyBindingsSubsection osuBindingSubsection => keyBindingPanel
+ .ChildrenOfType()
+ .FirstOrDefault(s => s.Ruleset.ShortName == "osu");
+
+ private OsuButton configureBindingsButton => Game.Settings
+ .ChildrenOfType().SingleOrDefault()?
+ .ChildrenOfType()?
+ .First(b => b.Text.ToString() == "Configure");
+
+ private KeyBindingPanel keyBindingPanel => Game.Settings
+ .ChildrenOfType().SingleOrDefault();
+
+ private RealmKeyBinding firstOsuRulesetKeyBindings => Game.Dependencies
+ .Get().Context
+ .All()
+ .AsEnumerable()
+ .First(k => k.RulesetName == "osu" && k.ActionInt == 0);
+
+ private Player player => Game.ScreenStack.CurrentScreen as Player;
+
+ private KeyCounter keyCounter => player.ChildrenOfType().First();
+ }
+}
diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneMouseWheelVolumeAdjust.cs b/osu.Game.Tests/Visual/Navigation/TestSceneMouseWheelVolumeAdjust.cs
index 701ab480f6..22a00a3e5a 100644
--- a/osu.Game.Tests/Visual/Navigation/TestSceneMouseWheelVolumeAdjust.cs
+++ b/osu.Game.Tests/Visual/Navigation/TestSceneMouseWheelVolumeAdjust.cs
@@ -83,7 +83,7 @@ namespace osu.Game.Tests.Visual.Navigation
PushAndConfirm(() => songSelect = new TestSceneScreenNavigation.TestPlaySongSelect());
AddUntilStep("wait for song select", () => songSelect.BeatmapSetsLoaded);
- AddStep("import beatmap", () => ImportBeatmapTest.LoadOszIntoOsu(Game, virtualTrack: true).WaitSafely());
+ AddStep("import beatmap", () => BeatmapImportHelper.LoadOszIntoOsu(Game, virtualTrack: true).WaitSafely());
AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault);
AddStep("press enter", () => InputManager.Key(Key.Enter));
diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneOsuGame.cs b/osu.Game.Tests/Visual/Navigation/TestSceneOsuGame.cs
index 28ff776d5f..b8d1636ea0 100644
--- a/osu.Game.Tests/Visual/Navigation/TestSceneOsuGame.cs
+++ b/osu.Game.Tests/Visual/Navigation/TestSceneOsuGame.cs
@@ -12,11 +12,9 @@ using osu.Framework.Platform;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
-using osu.Game.Database;
using osu.Game.Graphics;
using osu.Game.Input;
using osu.Game.Input.Bindings;
-using osu.Game.IO;
using osu.Game.Online.API;
using osu.Game.Online.Chat;
using osu.Game.Overlays;
@@ -58,7 +56,6 @@ namespace osu.Game.Tests.Visual.Navigation
private IReadOnlyList requiredGameBaseDependencies => new[]
{
typeof(OsuGameBase),
- typeof(DatabaseContextFactory),
typeof(Bindable),
typeof(IBindable),
typeof(Bindable>),
@@ -69,7 +66,6 @@ namespace osu.Game.Tests.Visual.Navigation
typeof(ISkinSource),
typeof(IAPIProvider),
typeof(RulesetStore),
- typeof(FileStore),
typeof(ScoreManager),
typeof(BeatmapManager),
typeof(IRulesetConfigCache),
diff --git a/osu.Game.Tests/Visual/Navigation/TestScenePerformFromScreen.cs b/osu.Game.Tests/Visual/Navigation/TestScenePerformFromScreen.cs
index 24f5808961..1ebceed15d 100644
--- a/osu.Game.Tests/Visual/Navigation/TestScenePerformFromScreen.cs
+++ b/osu.Game.Tests/Visual/Navigation/TestScenePerformFromScreen.cs
@@ -173,7 +173,7 @@ namespace osu.Game.Tests.Visual.Navigation
private void importAndWaitForSongSelect()
{
- AddStep("import beatmap", () => ImportBeatmapTest.LoadQuickOszIntoOsu(Game).WaitSafely());
+ AddStep("import beatmap", () => BeatmapImportHelper.LoadQuickOszIntoOsu(Game).WaitSafely());
PushAndConfirm(() => new TestPlaySongSelect());
AddUntilStep("beatmap updated", () => Game.Beatmap.Value.BeatmapSetInfo.OnlineID == 241526);
}
diff --git a/osu.Game.Tests/Visual/Navigation/TestScenePresentBeatmap.cs b/osu.Game.Tests/Visual/Navigation/TestScenePresentBeatmap.cs
index 6420e7b849..f6c53e76c4 100644
--- a/osu.Game.Tests/Visual/Navigation/TestScenePresentBeatmap.cs
+++ b/osu.Game.Tests/Visual/Navigation/TestScenePresentBeatmap.cs
@@ -97,11 +97,10 @@ namespace osu.Game.Tests.Visual.Navigation
BeatmapSetInfo imported = null;
AddStep($"import beatmap {i}", () =>
{
- var difficulty = new BeatmapDifficulty();
var metadata = new BeatmapMetadata
{
Artist = "SomeArtist",
- AuthorString = "SomeAuthor",
+ Author = { Username = "SomeAuthor" },
Title = $"import {i}"
};
@@ -109,25 +108,24 @@ namespace osu.Game.Tests.Visual.Navigation
{
Hash = Guid.NewGuid().ToString(),
OnlineID = i,
- Metadata = metadata,
Beatmaps =
{
new BeatmapInfo
{
OnlineID = i * 1024,
Metadata = metadata,
- BaseDifficulty = difficulty,
+ Difficulty = new BeatmapDifficulty(),
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
},
new BeatmapInfo
{
OnlineID = i * 2048,
Metadata = metadata,
- BaseDifficulty = difficulty,
+ Difficulty = new BeatmapDifficulty(),
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
},
}
- }).GetResultSafely().Value;
+ }).GetResultSafely()?.Value;
});
AddAssert($"import {i} succeeded", () => imported != null);
diff --git a/osu.Game.Tests/Visual/Navigation/TestScenePresentScore.cs b/osu.Game.Tests/Visual/Navigation/TestScenePresentScore.cs
index 5dc1808c12..7bd8110374 100644
--- a/osu.Game.Tests/Visual/Navigation/TestScenePresentScore.cs
+++ b/osu.Game.Tests/Visual/Navigation/TestScenePresentScore.cs
@@ -8,6 +8,7 @@ using osu.Framework.Extensions;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
+using osu.Game.Online.API;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mania;
using osu.Game.Rulesets.Osu;
@@ -28,37 +29,38 @@ namespace osu.Game.Tests.Visual.Navigation
{
AddStep("import beatmap", () =>
{
- var difficulty = new BeatmapDifficulty();
- var metadata = new BeatmapMetadata
- {
- Artist = "SomeArtist",
- AuthorString = "SomeAuthor",
- Title = "import"
- };
-
beatmap = Game.BeatmapManager.Import(new BeatmapSetInfo
{
Hash = Guid.NewGuid().ToString(),
OnlineID = 1,
- Metadata = metadata,
Beatmaps =
{
new BeatmapInfo
{
OnlineID = 1 * 1024,
- Metadata = metadata,
- BaseDifficulty = difficulty,
+ Metadata = new BeatmapMetadata
+ {
+ Artist = "SomeArtist",
+ Author = { Username = "SomeAuthor" },
+ Title = "import"
+ },
+ Difficulty = new BeatmapDifficulty(),
Ruleset = new OsuRuleset().RulesetInfo
},
new BeatmapInfo
{
OnlineID = 1 * 2048,
- Metadata = metadata,
- BaseDifficulty = difficulty,
+ Metadata = new BeatmapMetadata
+ {
+ Artist = "SomeArtist",
+ Author = { Username = "SomeAuthor" },
+ Title = "import"
+ },
+ Difficulty = new BeatmapDifficulty(),
Ruleset = new OsuRuleset().RulesetInfo
},
}
- }).GetResultSafely().Value;
+ }).GetResultSafely()?.Value;
});
}
@@ -131,7 +133,8 @@ namespace osu.Game.Tests.Visual.Navigation
Hash = Guid.NewGuid().ToString(),
OnlineID = i,
BeatmapInfo = beatmap.Beatmaps.First(),
- Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
+ Ruleset = ruleset ?? new OsuRuleset().RulesetInfo,
+ User = new GuestUser(),
}).GetResultSafely().Value;
});
diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs b/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs
index 60aabf5639..89dca77af4 100644
--- a/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs
+++ b/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs
@@ -71,7 +71,7 @@ namespace osu.Game.Tests.Visual.Navigation
PushAndConfirm(() => songSelect = new TestPlaySongSelect());
AddUntilStep("wait for song select", () => songSelect.BeatmapSetsLoaded);
- AddStep("import beatmap", () => ImportBeatmapTest.LoadQuickOszIntoOsu(Game).WaitSafely());
+ AddStep("import beatmap", () => BeatmapImportHelper.LoadQuickOszIntoOsu(Game).WaitSafely());
AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault);
@@ -105,7 +105,7 @@ namespace osu.Game.Tests.Visual.Navigation
PushAndConfirm(() => songSelect = new TestPlaySongSelect());
AddUntilStep("wait for song select", () => songSelect.BeatmapSetsLoaded);
- AddStep("import beatmap", () => ImportBeatmapTest.LoadQuickOszIntoOsu(Game).WaitSafely());
+ AddStep("import beatmap", () => BeatmapImportHelper.LoadQuickOszIntoOsu(Game).WaitSafely());
AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault);
@@ -139,7 +139,7 @@ namespace osu.Game.Tests.Visual.Navigation
PushAndConfirm(() => songSelect = new TestPlaySongSelect());
AddUntilStep("wait for song select", () => songSelect.BeatmapSetsLoaded);
- AddStep("import beatmap", () => ImportBeatmapTest.LoadOszIntoOsu(Game, virtualTrack: true).WaitSafely());
+ AddStep("import beatmap", () => BeatmapImportHelper.LoadOszIntoOsu(Game, virtualTrack: true).WaitSafely());
AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault);
diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneStartupRuleset.cs b/osu.Game.Tests/Visual/Navigation/TestSceneStartupRuleset.cs
new file mode 100644
index 0000000000..85dd501fd3
--- /dev/null
+++ b/osu.Game.Tests/Visual/Navigation/TestSceneStartupRuleset.cs
@@ -0,0 +1,32 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using NUnit.Framework;
+using osu.Framework.Development;
+using osu.Game.Configuration;
+
+namespace osu.Game.Tests.Visual.Navigation
+{
+ [TestFixture]
+ public class TestSceneStartupRuleset : OsuGameTestScene
+ {
+ protected override TestOsuGame CreateTestGame()
+ {
+ // Must be done in this function due to the RecycleLocalStorage call just before.
+ var config = DebugUtils.IsDebugBuild
+ ? new DevelopmentOsuConfigManager(LocalStorage)
+ : new OsuConfigManager(LocalStorage);
+
+ config.SetValue(OsuSetting.Ruleset, "mania");
+ config.Save();
+
+ return base.CreateTestGame();
+ }
+
+ [Test]
+ public void TestRulesetConsumed()
+ {
+ AddUntilStep("ruleset correct", () => Game.Ruleset.Value.ShortName == "mania");
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapDownloadButton.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapDownloadButton.cs
index 21bf8d1c5a..d9f01622da 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapDownloadButton.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapDownloadButton.cs
@@ -59,7 +59,7 @@ namespace osu.Game.Tests.Visual.Online
{
var beatmap = beatmaps.QueryBeatmapSet(b => b.OnlineID == 241526);
- if (beatmap != null) beatmaps.Delete(beatmap);
+ if (beatmap != null) beatmaps.Delete(beatmap.Value);
});
}
diff --git a/osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs
index be2db9a8a0..8a304110dd 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs
@@ -1,11 +1,15 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
+using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
@@ -24,10 +28,11 @@ namespace osu.Game.Tests.Visual.Online
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
- public TestSceneScoresContainer()
- {
- TestScoresContainer scoresContainer;
+ private TestScoresContainer scoresContainer;
+ [SetUpSteps]
+ public void SetUp() => Schedule(() =>
+ {
Child = new Container
{
Anchor = Anchor.TopCentre,
@@ -41,16 +46,110 @@ namespace osu.Game.Tests.Visual.Online
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
- scoresContainer = new TestScoresContainer(),
+ scoresContainer = new TestScoresContainer
+ {
+ Beatmap = { Value = CreateAPIBeatmap() }
+ }
}
};
+ });
- var allScores = new APIScoresCollection
+ [Test]
+ public void TestNoUserBest()
+ {
+ AddStep("Scores with no user best", () =>
+ {
+ var allScores = createScores();
+
+ allScores.UserScore = null;
+
+ scoresContainer.Scores = allScores;
+ });
+
+ AddUntilStep("wait for scores displayed", () => scoresContainer.ChildrenOfType().Any());
+ AddAssert("no user best displayed", () => scoresContainer.ChildrenOfType().Count() == 1);
+
+ AddStep("Load null scores", () => scoresContainer.Scores = null);
+
+ AddUntilStep("wait for scores not displayed", () => !scoresContainer.ChildrenOfType().Any());
+ AddAssert("no best score displayed", () => !scoresContainer.ChildrenOfType().Any());
+
+ AddStep("Load only one score", () =>
+ {
+ var allScores = createScores();
+
+ allScores.Scores.RemoveRange(1, allScores.Scores.Count - 1);
+
+ scoresContainer.Scores = allScores;
+ });
+
+ AddUntilStep("wait for scores not displayed", () => scoresContainer.ChildrenOfType().Count() == 1);
+ AddAssert("no best score displayed", () => scoresContainer.ChildrenOfType().Count() == 1);
+ }
+
+ [Test]
+ public void TestUserBest()
+ {
+ AddStep("Load scores with personal best", () =>
+ {
+ var allScores = createScores();
+ allScores.UserScore = createUserBest();
+ scoresContainer.Scores = allScores;
+ });
+
+ AddUntilStep("wait for scores displayed", () => scoresContainer.ChildrenOfType().Any());
+ AddAssert("best score displayed", () => scoresContainer.ChildrenOfType().Count() == 2);
+
+ AddStep("Load scores with personal best (null position)", () =>
+ {
+ var allScores = createScores();
+ var userBest = createUserBest();
+ userBest.Position = null;
+ allScores.UserScore = userBest;
+ scoresContainer.Scores = allScores;
+ });
+
+ AddUntilStep("wait for scores displayed", () => scoresContainer.ChildrenOfType().Any());
+ AddAssert("best score displayed", () => scoresContainer.ChildrenOfType().Count() == 2);
+
+ AddStep("Load scores with personal best (first place)", () =>
+ {
+ var allScores = createScores();
+ allScores.UserScore = new APIScoreWithPosition
+ {
+ Score = allScores.Scores.First(),
+ Position = 1,
+ };
+ scoresContainer.Scores = allScores;
+ });
+
+ AddUntilStep("wait for scores displayed", () => scoresContainer.ChildrenOfType().Any());
+ AddAssert("best score displayed", () => scoresContainer.ChildrenOfType().Count() == 1);
+
+ AddStep("Scores with no user best", () =>
+ {
+ var allScores = createScores();
+
+ allScores.UserScore = null;
+
+ scoresContainer.Scores = allScores;
+ });
+
+ AddUntilStep("best score not displayed", () => scoresContainer.ChildrenOfType().Count() == 1);
+ }
+
+ private int onlineID = 1;
+
+ private APIScoresCollection createScores()
+ {
+ var scores = new APIScoresCollection
{
Scores = new List
{
new APIScore
{
+ Date = DateTimeOffset.Now,
+ OnlineID = onlineID++,
User = new APIUser
{
Id = 6602580,
@@ -76,6 +175,8 @@ namespace osu.Game.Tests.Visual.Online
},
new APIScore
{
+ Date = DateTimeOffset.Now,
+ OnlineID = onlineID++,
User = new APIUser
{
Id = 4608074,
@@ -100,6 +201,8 @@ namespace osu.Game.Tests.Visual.Online
},
new APIScore
{
+ Date = DateTimeOffset.Now,
+ OnlineID = onlineID++,
User = new APIUser
{
Id = 1014222,
@@ -123,6 +226,8 @@ namespace osu.Game.Tests.Visual.Online
},
new APIScore
{
+ Date = DateTimeOffset.Now,
+ OnlineID = onlineID++,
User = new APIUser
{
Id = 1541390,
@@ -145,6 +250,8 @@ namespace osu.Game.Tests.Visual.Online
},
new APIScore
{
+ Date = DateTimeOffset.Now,
+ OnlineID = onlineID++,
User = new APIUser
{
Id = 7151382,
@@ -164,85 +271,7 @@ namespace osu.Game.Tests.Visual.Online
}
};
- var myBestScore = new APIScoreWithPosition
- {
- Score = new APIScore
- {
- User = new APIUser
- {
- Id = 7151382,
- Username = @"Mayuri Hana",
- Country = new Country
- {
- FullName = @"Thailand",
- FlagName = @"TH",
- },
- },
- Rank = ScoreRank.D,
- PP = 160,
- MaxCombo = 1234,
- TotalScore = 123456,
- Accuracy = 0.6543,
- },
- Position = 1337,
- };
-
- var myBestScoreWithNullPosition = new APIScoreWithPosition
- {
- Score = new APIScore
- {
- User = new APIUser
- {
- Id = 7151382,
- Username = @"Mayuri Hana",
- Country = new Country
- {
- FullName = @"Thailand",
- FlagName = @"TH",
- },
- },
- Rank = ScoreRank.D,
- PP = 160,
- MaxCombo = 1234,
- TotalScore = 123456,
- Accuracy = 0.6543,
- },
- Position = null,
- };
-
- var oneScore = new APIScoresCollection
- {
- Scores = new List
- {
- new APIScore
- {
- User = new APIUser
- {
- Id = 6602580,
- Username = @"waaiiru",
- Country = new Country
- {
- FullName = @"Spain",
- FlagName = @"ES",
- },
- },
- Mods = new[]
- {
- new APIMod { Acronym = new OsuModDoubleTime().Acronym },
- new APIMod { Acronym = new OsuModHidden().Acronym },
- new APIMod { Acronym = new OsuModFlashlight().Acronym },
- new APIMod { Acronym = new OsuModHardRock().Acronym },
- },
- Rank = ScoreRank.XH,
- PP = 200,
- MaxCombo = 1234,
- TotalScore = 1234567890,
- Accuracy = 1,
- }
- }
- };
-
- foreach (var s in allScores.Scores)
+ foreach (var s in scores.Scores)
{
s.Statistics = new Dictionary
{
@@ -253,26 +282,34 @@ namespace osu.Game.Tests.Visual.Online
};
}
- AddStep("Load all scores", () =>
- {
- allScores.UserScore = null;
- scoresContainer.Scores = allScores;
- });
- AddStep("Load null scores", () => scoresContainer.Scores = null);
- AddStep("Load only one score", () => scoresContainer.Scores = oneScore);
- AddStep("Load scores with my best", () =>
- {
- allScores.UserScore = myBestScore;
- scoresContainer.Scores = allScores;
- });
-
- AddStep("Load scores with null my best position", () =>
- {
- allScores.UserScore = myBestScoreWithNullPosition;
- scoresContainer.Scores = allScores;
- });
+ return scores;
}
+ private APIScoreWithPosition createUserBest() => new APIScoreWithPosition
+ {
+ Score = new APIScore
+ {
+ Date = DateTimeOffset.Now,
+ OnlineID = onlineID++,
+ User = new APIUser
+ {
+ Id = 7151382,
+ Username = @"Mayuri Hana",
+ Country = new Country
+ {
+ FullName = @"Thailand",
+ FlagName = @"TH",
+ },
+ },
+ Rank = ScoreRank.D,
+ PP = 160,
+ MaxCombo = 1234,
+ TotalScore = 123456,
+ Accuracy = 0.6543,
+ },
+ Position = 1337,
+ };
+
private class TestScoresContainer : ScoresContainer
{
public new APIScoresCollection Scores
diff --git a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsResultsScreen.cs b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsResultsScreen.cs
index e9210496ca..11df115b1a 100644
--- a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsResultsScreen.cs
+++ b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsResultsScreen.cs
@@ -44,6 +44,10 @@ namespace osu.Game.Tests.Visual.Playlists
requestComplete = false;
totalCount = 0;
bindHandler();
+
+ // beatmap is required to be an actual beatmap so the scores can get their scores correctly calculated for standardised scoring.
+ // else the tests that rely on ordering will fall over.
+ Beatmap.Value = CreateWorkingBeatmap(Ruleset.Value);
});
[Test]
diff --git a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsRoomCreation.cs b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsRoomCreation.cs
index e59884f4f4..bc9f759bdd 100644
--- a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsRoomCreation.cs
+++ b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsRoomCreation.cs
@@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
+using System.Diagnostics;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
@@ -18,6 +19,7 @@ using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.OnlinePlay.Components;
+using osu.Game.Screens.OnlinePlay.Match.Components;
using osu.Game.Screens.OnlinePlay.Playlists;
using osu.Game.Screens.Play;
using osu.Game.Tests.Beatmaps;
@@ -33,13 +35,14 @@ namespace osu.Game.Tests.Visual.Playlists
private TestPlaylistsRoomSubScreen match;
- private ILive importedBeatmap;
+ private BeatmapSetInfo importedBeatmap;
[BackgroundDependencyLoader]
private void load(GameHost host, AudioManager audio)
{
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
- Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, API, audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(ContextFactory);
}
[SetUpSteps]
@@ -64,13 +67,15 @@ namespace osu.Game.Tests.Visual.Playlists
room.EndDate.Value = DateTimeOffset.Now.AddMinutes(5);
room.Playlist.Add(new PlaylistItem
{
- Beatmap = { Value = importedBeatmap.Value.Beatmaps.First() },
+ Beatmap = { Value = importedBeatmap.Beatmaps.First() },
Ruleset = { Value = new OsuRuleset().RulesetInfo }
});
});
AddUntilStep("Progress details are hidden", () => match.ChildrenOfType().FirstOrDefault()?.Parent.Alpha == 0);
+ AddUntilStep("Leaderboard shows two aggregate scores", () => match.ChildrenOfType().Count(s => s.ScoreText.Text != "0") == 2);
+
AddStep("start match", () => match.ChildrenOfType().First().TriggerClick());
AddUntilStep("player loader loaded", () => Stack.CurrentScreen is PlayerLoader);
}
@@ -87,7 +92,7 @@ namespace osu.Game.Tests.Visual.Playlists
room.EndDate.Value = DateTimeOffset.Now.AddMinutes(5);
room.Playlist.Add(new PlaylistItem
{
- Beatmap = { Value = importedBeatmap.Value.Beatmaps.First() },
+ Beatmap = { Value = importedBeatmap.Beatmaps.First() },
Ruleset = { Value = new OsuRuleset().RulesetInfo }
});
});
@@ -104,7 +109,7 @@ namespace osu.Game.Tests.Visual.Playlists
room.Host.Value = API.LocalUser.Value;
room.Playlist.Add(new PlaylistItem
{
- Beatmap = { Value = importedBeatmap.Value.Beatmaps.First() },
+ Beatmap = { Value = importedBeatmap.Beatmaps.First() },
Ruleset = { Value = new OsuRuleset().RulesetInfo }
});
});
@@ -121,9 +126,9 @@ namespace osu.Game.Tests.Visual.Playlists
AddStep("store real beatmap values", () =>
{
- realHash = importedBeatmap.Value.Beatmaps[0].MD5Hash;
- realOnlineId = importedBeatmap.Value.Beatmaps[0].OnlineID ?? -1;
- realOnlineSetId = importedBeatmap.Value.OnlineID ?? -1;
+ realHash = importedBeatmap.Beatmaps[0].MD5Hash;
+ realOnlineId = importedBeatmap.Beatmaps[0].OnlineID;
+ realOnlineSetId = importedBeatmap.OnlineID;
});
AddStep("import modified beatmap", () =>
@@ -133,6 +138,7 @@ namespace osu.Game.Tests.Visual.Playlists
BeatmapInfo =
{
OnlineID = realOnlineId,
+ Metadata = new BeatmapMetadata(),
BeatmapSet =
{
OnlineID = realOnlineSetId
@@ -143,6 +149,8 @@ namespace osu.Game.Tests.Visual.Playlists
modifiedBeatmap.HitObjects.Clear();
modifiedBeatmap.HitObjects.Add(new HitCircle { StartTime = 5000 });
+ Debug.Assert(modifiedBeatmap.BeatmapInfo.BeatmapSet != null);
+
manager.Import(modifiedBeatmap.BeatmapInfo.BeatmapSet).WaitSafely();
});
@@ -159,6 +167,7 @@ namespace osu.Game.Tests.Visual.Playlists
{
MD5Hash = realHash,
OnlineID = realOnlineId,
+ Metadata = new BeatmapMetadata(),
BeatmapSet = new BeatmapSetInfo
{
OnlineID = realOnlineSetId,
@@ -185,6 +194,8 @@ namespace osu.Game.Tests.Visual.Playlists
},
};
+ Debug.Assert(originalBeatmap.BeatmapInfo.BeatmapSet != null);
+
manager.Import(originalBeatmap.BeatmapInfo.BeatmapSet).WaitSafely();
});
@@ -202,7 +213,14 @@ namespace osu.Game.Tests.Visual.Playlists
});
}
- private void importBeatmap() => AddStep("import beatmap", () => importedBeatmap = manager.Import(CreateBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapSet).GetResultSafely());
+ private void importBeatmap() => AddStep("import beatmap", () =>
+ {
+ var beatmap = CreateBeatmap(new OsuRuleset().RulesetInfo);
+
+ Debug.Assert(beatmap.BeatmapInfo.BeatmapSet != null);
+
+ importedBeatmap = manager.Import(beatmap.BeatmapInfo.BeatmapSet).GetResultSafely()?.Value.Detach();
+ });
private class TestPlaylistsRoomSubScreen : PlaylistsRoomSubScreen
{
diff --git a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsScreen.cs b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsScreen.cs
index e52f823f0b..63bd7c8068 100644
--- a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsScreen.cs
+++ b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsScreen.cs
@@ -2,8 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
-using osu.Framework.Allocation;
-using osu.Game.Overlays;
namespace osu.Game.Tests.Visual.Playlists
{
@@ -12,9 +10,6 @@ namespace osu.Game.Tests.Visual.Playlists
{
protected override bool UseOnlineAPI => true;
- [Cached]
- private MusicController musicController { get; set; } = new MusicController();
-
public TestScenePlaylistsScreen()
{
var multi = new Screens.OnlinePlay.Playlists.Playlists();
diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneAccuracyCircle.cs b/osu.Game.Tests/Visual/Ranking/TestSceneAccuracyCircle.cs
index 944941723e..ac736086fd 100644
--- a/osu.Game.Tests/Visual/Ranking/TestSceneAccuracyCircle.cs
+++ b/osu.Game.Tests/Visual/Ranking/TestSceneAccuracyCircle.cs
@@ -72,6 +72,7 @@ namespace osu.Game.Tests.Visual.Ranking
Username = "peppy",
},
BeatmapInfo = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo,
+ Ruleset = new OsuRuleset().RulesetInfo,
Mods = new Mod[] { new OsuModHardRock(), new OsuModDoubleTime() },
TotalScore = 2845370,
Accuracy = accuracy,
diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs b/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs
index 2cb4fb6b6b..8b646df362 100644
--- a/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs
+++ b/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs
@@ -12,7 +12,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Sprites;
-using osu.Game.Online.API.Requests.Responses;
+using osu.Game.Models;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu;
@@ -33,7 +33,7 @@ namespace osu.Game.Tests.Visual.Ranking
[Test]
public void TestMapWithKnownMapper()
{
- var author = new APIUser { Username = "mapper_name" };
+ var author = new RealmUser { Username = "mapper_name" };
AddStep("show example score", () => showPanel(TestResources.CreateTestScoreInfo(createTestBeatmap(author))));
}
@@ -43,7 +43,7 @@ namespace osu.Game.Tests.Visual.Ranking
{
AddStep("show excess mods score", () =>
{
- var author = new APIUser { Username = "mapper_name" };
+ var author = new RealmUser { Username = "mapper_name" };
var score = TestResources.CreateTestScoreInfo(createTestBeatmap(author));
score.Mods = score.BeatmapInfo.Ruleset.CreateInstance().CreateAllMods().ToArray();
@@ -57,7 +57,7 @@ namespace osu.Game.Tests.Visual.Ranking
[Test]
public void TestMapWithUnknownMapper()
{
- AddStep("show example score", () => showPanel(TestResources.CreateTestScoreInfo(createTestBeatmap(new APIUser()))));
+ AddStep("show example score", () => showPanel(TestResources.CreateTestScoreInfo(createTestBeatmap(new RealmUser()))));
AddAssert("mapped by text not present", () =>
this.ChildrenOfType().All(spriteText => !containsAny(spriteText.Text.ToString(), "mapped", "by")));
@@ -73,7 +73,7 @@ namespace osu.Game.Tests.Visual.Ranking
var ruleset = new OsuRuleset();
var mods = new Mod[] { ruleset.GetAutoplayMod() };
- var beatmap = createTestBeatmap(new APIUser());
+ var beatmap = createTestBeatmap(new RealmUser());
var score = TestResources.CreateTestScoreInfo(beatmap);
@@ -89,7 +89,7 @@ namespace osu.Game.Tests.Visual.Ranking
private void showPanel(ScoreInfo score) =>
Child = new ExpandedPanelMiddleContentContainer(score);
- private BeatmapInfo createTestBeatmap([NotNull] APIUser author)
+ private BeatmapInfo createTestBeatmap([NotNull] RealmUser author)
{
var beatmap = new TestBeatmap(rulesetStore.GetRuleset(0)).BeatmapInfo;
diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs b/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs
index 666cbf02b5..62500babc1 100644
--- a/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs
+++ b/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs
@@ -13,8 +13,10 @@ using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
+using osu.Game.Database;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
+using osu.Game.Rulesets;
using osu.Game.Scoring;
using osu.Game.Screens;
using osu.Game.Screens.Play;
@@ -23,6 +25,7 @@ using osu.Game.Screens.Ranking.Statistics;
using osu.Game.Tests.Resources;
using osuTK;
using osuTK.Input;
+using Realms;
namespace osu.Game.Tests.Visual.Ranking
{
@@ -32,13 +35,22 @@ namespace osu.Game.Tests.Visual.Ranking
[Resolved]
private BeatmapManager beatmaps { get; set; }
+ [Resolved]
+ private RealmContextFactory realmContextFactory { get; set; }
+
protected override void LoadComplete()
{
base.LoadComplete();
- var beatmapInfo = beatmaps.QueryBeatmap(b => b.RulesetID == 0);
- if (beatmapInfo != null)
- Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo);
+ using (var realm = realmContextFactory.CreateContext())
+ {
+ var beatmapInfo = realm.All()
+ .Filter($"{nameof(BeatmapInfo.Ruleset)}.{nameof(RulesetInfo.OnlineID)} = $0", 0)
+ .FirstOrDefault();
+
+ if (beatmapInfo != null)
+ Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo);
+ }
}
[Test]
@@ -203,7 +215,7 @@ namespace osu.Game.Tests.Visual.Ranking
{
DelayedFetchResultsScreen screen = null;
- var tcs = new TaskCompletionSource();
+ var tcs = new TaskCompletionSource();
AddStep("load results", () => Child = new TestResultsContainer(screen = new DelayedFetchResultsScreen(TestResources.CreateTestScoreInfo(), tcs.Task)));
@@ -218,7 +230,7 @@ namespace osu.Game.Tests.Visual.Ranking
AddAssert("no fetch yet", () => !screen.FetchCompleted);
- AddStep("allow fetch", () => tcs.SetResult());
+ AddStep("allow fetch", () => tcs.SetResult(true));
AddUntilStep("wait for fetch", () => screen.FetchCompleted);
AddAssert("expanded panel still on screen", () => this.ChildrenOfType().Single(p => p.State == PanelState.Expanded).ScreenSpaceDrawQuad.TopLeft.X > 0);
diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneScorePanelList.cs b/osu.Game.Tests/Visual/Ranking/TestSceneScorePanelList.cs
index f5ad352b9c..e786b85f78 100644
--- a/osu.Game.Tests/Visual/Ranking/TestSceneScorePanelList.cs
+++ b/osu.Game.Tests/Visual/Ranking/TestSceneScorePanelList.cs
@@ -7,6 +7,7 @@ using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Framework.Utils;
+using osu.Game.Models;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking;
using osu.Game.Tests.Resources;
@@ -157,10 +158,10 @@ namespace osu.Game.Tests.Visual.Ranking
public void TestSelectMultipleScores()
{
var firstScore = TestResources.CreateTestScoreInfo();
- var secondScore = TestResources.CreateTestScoreInfo();
+ firstScore.RealmUser = new RealmUser { Username = "A" };
- firstScore.UserString = "A";
- secondScore.UserString = "B";
+ var secondScore = TestResources.CreateTestScoreInfo();
+ secondScore.RealmUser = new RealmUser { Username = "B" };
createListStep(() => new ScorePanelList());
@@ -178,7 +179,7 @@ namespace osu.Game.Tests.Visual.Ranking
AddStep("select second score", () =>
{
- InputManager.MoveMouseTo(list.ChildrenOfType().Single(p => p.Score == secondScore));
+ InputManager.MoveMouseTo(list.ChildrenOfType().Single(p => p.Score.Equals(secondScore)));
InputManager.Click(MouseButton.Left);
});
@@ -303,6 +304,6 @@ namespace osu.Game.Tests.Visual.Ranking
=> AddUntilStep("first panel centred", () => Precision.AlmostEquals(list.ChildrenOfType().First().ScreenSpaceDrawQuad.Centre.X, list.ScreenSpaceDrawQuad.Centre.X, 1));
private void assertScoreState(ScoreInfo score, bool expanded)
- => AddUntilStep($"score expanded = {expanded}", () => (list.ChildrenOfType().Single(p => p.Score == score).State == PanelState.Expanded) == expanded);
+ => AddUntilStep($"score expanded = {expanded}", () => (list.ChildrenOfType().Single(p => p.Score.Equals(score)).State == PanelState.Expanded) == expanded);
}
}
diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneAdvancedStats.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneAdvancedStats.cs
index d57b3dec5d..7ceae0a69b 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestSceneAdvancedStats.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneAdvancedStats.cs
@@ -37,9 +37,8 @@ namespace osu.Game.Tests.Visual.SongSelect
private BeatmapInfo exampleBeatmapInfo => new BeatmapInfo
{
- RulesetID = 0,
Ruleset = rulesets.AvailableRulesets.First(),
- BaseDifficulty = new BeatmapDifficulty
+ Difficulty = new BeatmapDifficulty
{
CircleSize = 7.2f,
DrainRate = 3,
@@ -68,8 +67,8 @@ namespace osu.Game.Tests.Visual.SongSelect
{
AddStep("set beatmap", () => advancedStats.BeatmapInfo = new BeatmapInfo
{
- Ruleset = rulesets.GetRuleset(3),
- BaseDifficulty = new BeatmapDifficulty
+ Ruleset = rulesets.GetRuleset(3) ?? throw new InvalidOperationException(),
+ Difficulty = new BeatmapDifficulty
{
CircleSize = 5,
DrainRate = 4.3f,
diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs
index f637c715a1..0298c3bea9 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs
@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
+using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
@@ -27,7 +28,7 @@ namespace osu.Game.Tests.Visual.SongSelect
private RulesetStore rulesets;
private readonly Stack selectedSets = new Stack();
- private readonly HashSet eagerSelectedIDs = new HashSet();
+ private readonly HashSet eagerSelectedIDs = new HashSet();
private BeatmapInfo currentSelection => carousel.SelectedBeatmapInfo;
@@ -75,7 +76,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
AddStep("store selection", () => selection = carousel.SelectedBeatmapInfo);
if (isIterating)
- AddUntilStep("selection changed", () => !carousel.SelectedBeatmapInfo.Equals(selection));
+ AddUntilStep("selection changed", () => !carousel.SelectedBeatmapInfo?.Equals(selection) == true);
else
AddUntilStep("selection not changed", () => carousel.SelectedBeatmapInfo.Equals(selection));
}
@@ -377,11 +378,7 @@ namespace osu.Game.Tests.Visual.SongSelect
var rulesetBeatmapSet = TestResources.CreateTestBeatmapSetInfo(1);
var taikoRuleset = rulesets.AvailableRulesets.ElementAt(1);
- rulesetBeatmapSet.Beatmaps.ForEach(b =>
- {
- b.Ruleset = taikoRuleset;
- b.RulesetID = 1;
- });
+ rulesetBeatmapSet.Beatmaps.ForEach(b => b.Ruleset = taikoRuleset);
sets.Add(rulesetBeatmapSet);
});
@@ -409,10 +406,10 @@ namespace osu.Game.Tests.Visual.SongSelect
var set = TestResources.CreateTestBeatmapSetInfo();
if (i == 4)
- set.Metadata.Artist = zzz_string;
+ set.Beatmaps.ForEach(b => b.Metadata.Artist = zzz_string);
if (i == 16)
- set.Metadata.AuthorString = zzz_string;
+ set.Beatmaps.ForEach(b => b.Metadata.Author.Username = zzz_string);
sets.Add(set);
}
@@ -433,12 +430,17 @@ namespace osu.Game.Tests.Visual.SongSelect
for (int i = 0; i < 20; i++)
{
var set = TestResources.CreateTestBeatmapSetInfo();
- set.Metadata.Artist = "same artist";
- set.Metadata.Title = "same title";
+
+ // only need to set the first as they are a shared reference.
+ var beatmap = set.Beatmaps.First();
+
+ beatmap.Metadata.Artist = "same artist";
+ beatmap.Metadata.Title = "same title";
+
sets.Add(set);
}
- int idOffset = sets.First().OnlineID ?? 0;
+ int idOffset = sets.First().OnlineID;
loadBeatmaps(sets);
@@ -577,7 +579,6 @@ namespace osu.Game.Tests.Visual.SongSelect
for (int i = 0; i <= 2; i++)
{
testMixed.Beatmaps[i].Ruleset = rulesets.AvailableRulesets.ElementAt(i);
- testMixed.Beatmaps[i].RulesetID = i;
}
carousel.UpdateBeatmapSet(testMixed);
@@ -599,7 +600,6 @@ namespace osu.Game.Tests.Visual.SongSelect
testSingle.Beatmaps.ForEach(b =>
{
b.Ruleset = rulesets.AvailableRulesets.ElementAt(1);
- b.RulesetID = b.Ruleset.ID ?? 1;
});
carousel.UpdateBeatmapSet(testSingle);
@@ -674,7 +674,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("Restore different ruleset filter", () =>
{
carousel.Filter(new FilterCriteria { Ruleset = rulesets.GetRuleset(1) }, false);
- eagerSelectedIDs.Add(carousel.SelectedBeatmapSet.OnlineID ?? -1);
+ eagerSelectedIDs.Add(carousel.SelectedBeatmapSet.ID);
});
AddAssert("selection changed", () => !carousel.SelectedBeatmapInfo.Equals(manySets.First().Beatmaps.First()));
@@ -697,10 +697,9 @@ namespace osu.Game.Tests.Visual.SongSelect
for (int i = 1; i <= 15; i++)
{
- set.Beatmaps.Add(new BeatmapInfo
+ set.Beatmaps.Add(new BeatmapInfo(new OsuRuleset().RulesetInfo, new BeatmapDifficulty(), new BeatmapMetadata())
{
DifficultyName = $"Stars: {i}",
- Ruleset = new OsuRuleset().RulesetInfo,
StarRating = i,
});
}
@@ -872,8 +871,6 @@ namespace osu.Game.Tests.Visual.SongSelect
}
}
}
-
- protected override IEnumerable GetLoadableBeatmaps() => Enumerable.Empty();
}
}
}
diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs
index 9ad5242df4..fd3f739c34 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs
@@ -208,7 +208,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Metadata = new BeatmapMetadata
{
- AuthorString = $"{ruleset.ShortName}Author",
+ Author = { Username = $"{ruleset.ShortName}Author" },
Artist = $"{ruleset.ShortName}Artist",
Source = $"{ruleset.ShortName}Source",
Title = $"{ruleset.ShortName}Title"
@@ -216,7 +216,7 @@ namespace osu.Game.Tests.Visual.SongSelect
Ruleset = ruleset,
StarRating = 6,
DifficultyName = $"{ruleset.ShortName}Version",
- BaseDifficulty = new BeatmapDifficulty()
+ Difficulty = new BeatmapDifficulty()
},
HitObjects = objects
};
@@ -230,7 +230,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Metadata = new BeatmapMetadata
{
- AuthorString = "WWWWWWWWWWWWWWW",
+ Author = { Username = "WWWWWWWWWWWWWWW" },
Artist = "Verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long Artist",
Source = "Verrrrry long Source",
Title = "Verrrrry long Title"
diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs
index 605e03564d..2e1a66be5f 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs
@@ -16,6 +16,7 @@ using osu.Game.Online.Leaderboards;
using osu.Game.Overlays;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
+using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Scoring;
using osu.Game.Screens.Select.Leaderboards;
@@ -44,6 +45,7 @@ namespace osu.Game.Tests.Visual.SongSelect
dependencies.Cache(rulesetStore = new RulesetStore(ContextFactory));
dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, ContextFactory, rulesetStore, null, dependencies.Get(), Resources, dependencies.Get(), Beatmap.Default));
dependencies.Cache(scoreManager = new ScoreManager(rulesetStore, () => beatmapManager, LocalStorage, ContextFactory, Scheduler));
+ Dependencies.Cache(ContextFactory);
return dependencies;
}
@@ -135,6 +137,7 @@ namespace osu.Game.Tests.Visual.SongSelect
MaxCombo = 244,
TotalScore = 1707827,
Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock() },
+ Ruleset = new OsuRuleset().RulesetInfo,
User = new APIUser
{
Id = 6602580,
@@ -157,6 +160,7 @@ namespace osu.Game.Tests.Visual.SongSelect
Accuracy = 1,
MaxCombo = 244,
TotalScore = 1707827,
+ Ruleset = new OsuRuleset().RulesetInfo,
Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
User = new APIUser
{
@@ -182,7 +186,7 @@ namespace osu.Game.Tests.Visual.SongSelect
private void clearScores()
{
- AddStep("Clear all scores", () => scoreManager.Delete(scoreManager.GetAllUsableScores()));
+ AddStep("Clear all scores", () => scoreManager.Delete());
}
private void checkCount(int expected) =>
@@ -199,6 +203,7 @@ namespace osu.Game.Tests.Visual.SongSelect
MaxCombo = 244,
TotalScore = 1707827,
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
+ Ruleset = new OsuRuleset().RulesetInfo,
BeatmapInfo = beatmapInfo,
User = new APIUser
{
@@ -219,6 +224,7 @@ namespace osu.Game.Tests.Visual.SongSelect
TotalScore = 1707827,
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
BeatmapInfo = beatmapInfo,
+ Ruleset = new OsuRuleset().RulesetInfo,
User = new APIUser
{
Id = 4608074,
@@ -238,6 +244,8 @@ namespace osu.Game.Tests.Visual.SongSelect
TotalScore = 1707827,
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
BeatmapInfo = beatmapInfo,
+ Ruleset = new OsuRuleset().RulesetInfo,
+
User = new APIUser
{
Id = 1014222,
@@ -257,6 +265,8 @@ namespace osu.Game.Tests.Visual.SongSelect
TotalScore = 1707827,
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
BeatmapInfo = beatmapInfo,
+ Ruleset = new OsuRuleset().RulesetInfo,
+
User = new APIUser
{
Id = 1541390,
@@ -276,6 +286,8 @@ namespace osu.Game.Tests.Visual.SongSelect
TotalScore = 1707827,
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
BeatmapInfo = beatmapInfo,
+ Ruleset = new OsuRuleset().RulesetInfo,
+
User = new APIUser
{
Id = 2243452,
@@ -295,6 +307,8 @@ namespace osu.Game.Tests.Visual.SongSelect
TotalScore = 1707827,
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
BeatmapInfo = beatmapInfo,
+ Ruleset = new OsuRuleset().RulesetInfo,
+
User = new APIUser
{
Id = 2705430,
@@ -314,6 +328,8 @@ namespace osu.Game.Tests.Visual.SongSelect
TotalScore = 1707827,
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
BeatmapInfo = beatmapInfo,
+ Ruleset = new OsuRuleset().RulesetInfo,
+
User = new APIUser
{
Id = 7151382,
@@ -333,6 +349,8 @@ namespace osu.Game.Tests.Visual.SongSelect
TotalScore = 1707827,
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
BeatmapInfo = beatmapInfo,
+ Ruleset = new OsuRuleset().RulesetInfo,
+
User = new APIUser
{
Id = 2051389,
@@ -352,6 +370,8 @@ namespace osu.Game.Tests.Visual.SongSelect
TotalScore = 1707827,
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
BeatmapInfo = beatmapInfo,
+ Ruleset = new OsuRuleset().RulesetInfo,
+
User = new APIUser
{
Id = 6169483,
@@ -371,6 +391,8 @@ namespace osu.Game.Tests.Visual.SongSelect
TotalScore = 1707827,
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
BeatmapInfo = beatmapInfo,
+ Ruleset = new OsuRuleset().RulesetInfo,
+
User = new APIUser
{
Id = 6702666,
diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapMetadataDisplay.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapMetadataDisplay.cs
index e573c96ce9..fb6d9a0b4b 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapMetadataDisplay.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapMetadataDisplay.cs
@@ -77,7 +77,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
showMetadataForBeatmap(() =>
{
- var allBeatmapSets = manager.GetAllUsableBeatmapSets(IncludedDetails.Minimal);
+ var allBeatmapSets = manager.GetAllUsableBeatmapSets();
if (allBeatmapSets.Count == 0)
return manager.DefaultBeatmap;
diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapRecommendations.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapRecommendations.cs
index 08b5802713..b7bc0c37e1 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapRecommendations.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapRecommendations.cs
@@ -113,6 +113,8 @@ namespace osu.Game.Tests.Visual.SongSelect
// Switch to catch
presentAndConfirm(() => catchSet, 1);
+ AddAssert("game-wide ruleset changed", () => Game.Ruleset.Value.Equals(catchSet.Beatmaps.First().Ruleset));
+
// Present mixed difficulty set, expect current ruleset to be selected
presentAndConfirm(() => mixedSet, 2);
}
@@ -182,7 +184,7 @@ namespace osu.Game.Tests.Visual.SongSelect
beatmap.DifficultyName = $"SR{i + 1}";
}
- return Game.BeatmapManager.Import(beatmapSet).GetResultSafely().Value;
+ return Game.BeatmapManager.Import(beatmapSet).GetResultSafely()?.Value;
}
private bool ensureAllBeatmapSetsImported(IEnumerable beatmapSets) => beatmapSets.All(set => set != null);
diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs
index 1ee59eccc7..ca8e9d2eff 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs
@@ -38,6 +38,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
Dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, Audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(ContextFactory);
beatmapManager.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs
index 37f110e727..6295a52bdd 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs
@@ -45,7 +45,10 @@ namespace osu.Game.Tests.Visual.SongSelect
[BackgroundDependencyLoader]
private void load(GameHost host, AudioManager audio)
{
+ // These DI caches are required to ensure for interactive runs this test scene doesn't nuke all user beatmaps in the local install.
+ // At a point we have isolated interactive test runs enough, this can likely be removed.
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
+ Dependencies.Cache(ContextFactory);
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, defaultBeatmap = Beatmap.Default));
Dependencies.Cache(music = new MusicController());
@@ -585,7 +588,7 @@ namespace osu.Game.Tests.Visual.SongSelect
[Test]
public void TestHideSetSelectsCorrectBeatmap()
{
- int? previousID = null;
+ Guid? previousID = null;
createSongSelect();
addRulesetImportStep(0);
AddStep("Move to last difficulty", () => songSelect.Carousel.SelectBeatmap(songSelect.Carousel.BeatmapSets.First().Beatmaps.Last()));
@@ -637,8 +640,9 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("Get filtered icon", () =>
{
- filteredBeatmap = songSelect.Carousel.SelectedBeatmapSet.Beatmaps.First(b => b.BPM < maxBPM);
- int filteredBeatmapIndex = getBeatmapIndex(filteredBeatmap.BeatmapSet, filteredBeatmap);
+ var selectedSet = songSelect.Carousel.SelectedBeatmapSet;
+ filteredBeatmap = selectedSet.Beatmaps.First(b => b.BPM < maxBPM);
+ int filteredBeatmapIndex = getBeatmapIndex(selectedSet, filteredBeatmap);
filteredIcon = set.ChildrenOfType().ElementAt(filteredBeatmapIndex);
});
@@ -744,7 +748,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.OnlineID == 3);
- AddAssert("Selected beatmap still same set", () => songSelect.Carousel.SelectedBeatmapInfo.BeatmapSet.OnlineID == previousSetID);
+ AddAssert("Selected beatmap still same set", () => songSelect.Carousel.SelectedBeatmapInfo.BeatmapSet?.OnlineID == previousSetID);
AddAssert("Selected beatmap is mania", () => Beatmap.Value.BeatmapInfo.Ruleset.OnlineID == 3);
}
@@ -760,7 +764,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("import huge difficulty count map", () =>
{
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray();
- imported = manager.Import(TestResources.CreateTestBeatmapSetInfo(50, usableRulesets)).GetResultSafely().Value;
+ imported = manager.Import(TestResources.CreateTestBeatmapSetInfo(50, usableRulesets)).GetResultSafely()?.Value;
});
AddStep("select the first beatmap of import", () => Beatmap.Value = manager.GetWorkingBeatmap(imported.Beatmaps.First()));
@@ -796,8 +800,8 @@ namespace osu.Game.Tests.Visual.SongSelect
[Test]
public void TestChangeRulesetWhilePresentingScore()
{
- BeatmapInfo getPresentBeatmap() => manager.QueryBeatmap(b => !b.BeatmapSet.DeletePending && b.RulesetID == 0);
- BeatmapInfo getSwitchBeatmap() => manager.QueryBeatmap(b => !b.BeatmapSet.DeletePending && b.RulesetID == 1);
+ BeatmapInfo getPresentBeatmap() => manager.GetAllUsableBeatmapSets().Where(s => !s.DeletePending).SelectMany(s => s.Beatmaps).First(b => b.RulesetID == 0);
+ BeatmapInfo getSwitchBeatmap() => manager.GetAllUsableBeatmapSets().Where(s => !s.DeletePending).SelectMany(s => s.Beatmaps).First(b => b.RulesetID == 1);
changeRuleset(0);
@@ -828,8 +832,8 @@ namespace osu.Game.Tests.Visual.SongSelect
[Test]
public void TestChangeBeatmapWhilePresentingScore()
{
- BeatmapInfo getPresentBeatmap() => manager.QueryBeatmap(b => !b.BeatmapSet.DeletePending && b.RulesetID == 0);
- BeatmapInfo getSwitchBeatmap() => manager.QueryBeatmap(b => !b.BeatmapSet.DeletePending && b.RulesetID == 1);
+ BeatmapInfo getPresentBeatmap() => manager.GetAllUsableBeatmapSets().Where(s => !s.DeletePending).SelectMany(s => s.Beatmaps).First(b => b.RulesetID == 0);
+ BeatmapInfo getSwitchBeatmap() => manager.GetAllUsableBeatmapSets().Where(s => !s.DeletePending).SelectMany(s => s.Beatmaps).First(b => b.RulesetID == 1);
changeRuleset(0);
diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneTopLocalRank.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneTopLocalRank.cs
new file mode 100644
index 0000000000..3aa5a759e6
--- /dev/null
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneTopLocalRank.cs
@@ -0,0 +1,143 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Linq;
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Audio;
+using osu.Framework.Extensions;
+using osu.Framework.Graphics;
+using osu.Framework.Platform;
+using osu.Framework.Testing;
+using osu.Game.Beatmaps;
+using osu.Game.Rulesets;
+using osu.Game.Scoring;
+using osu.Game.Screens.Select.Carousel;
+using osu.Game.Tests.Resources;
+using osuTK;
+
+namespace osu.Game.Tests.Visual.SongSelect
+{
+ public class TestSceneTopLocalRank : OsuTestScene
+ {
+ private RulesetStore rulesets;
+ private BeatmapManager beatmapManager;
+ private ScoreManager scoreManager;
+ private TopLocalRank topLocalRank;
+
+ [BackgroundDependencyLoader]
+ private void load(GameHost host, AudioManager audio)
+ {
+ Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
+ Dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
+ Dependencies.Cache(scoreManager = new ScoreManager(rulesets, () => beatmapManager, LocalStorage, ContextFactory, Scheduler));
+ Dependencies.Cache(ContextFactory);
+
+ beatmapManager.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
+ }
+
+ private BeatmapInfo importedBeatmap => beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps.First(b => b.Ruleset.ShortName == "osu");
+
+ [SetUpSteps]
+ public void SetUpSteps()
+ {
+ AddStep("Delete all scores", () => scoreManager.Delete());
+
+ AddStep("Create local rank", () =>
+ {
+ Add(topLocalRank = new TopLocalRank(importedBeatmap)
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Scale = new Vector2(10),
+ });
+ });
+ }
+
+ [Test]
+ public void TestBasicImportDelete()
+ {
+ ScoreInfo testScoreInfo = null;
+
+ AddAssert("Initially not present", () => !topLocalRank.IsPresent);
+
+ AddStep("Add score for current user", () =>
+ {
+ testScoreInfo = TestResources.CreateTestScoreInfo(importedBeatmap);
+
+ testScoreInfo.User = API.LocalUser.Value;
+ testScoreInfo.Rank = ScoreRank.B;
+
+ scoreManager.Import(testScoreInfo);
+ });
+
+ AddUntilStep("Became present", () => topLocalRank.IsPresent);
+ AddAssert("Correct rank", () => topLocalRank.Rank == ScoreRank.B);
+
+ AddStep("Delete score", () =>
+ {
+ scoreManager.Delete(testScoreInfo);
+ });
+
+ AddUntilStep("Became not present", () => !topLocalRank.IsPresent);
+ }
+
+ [Test]
+ public void TestRulesetChange()
+ {
+ ScoreInfo testScoreInfo;
+
+ AddStep("Add score for current user", () =>
+ {
+ testScoreInfo = TestResources.CreateTestScoreInfo(importedBeatmap);
+
+ testScoreInfo.User = API.LocalUser.Value;
+ testScoreInfo.Rank = ScoreRank.B;
+
+ scoreManager.Import(testScoreInfo);
+ });
+
+ AddUntilStep("Wait for initial presence", () => topLocalRank.IsPresent);
+
+ AddStep("Change ruleset", () => Ruleset.Value = rulesets.GetRuleset("fruits"));
+ AddUntilStep("Became not present", () => !topLocalRank.IsPresent);
+
+ AddStep("Change ruleset back", () => Ruleset.Value = rulesets.GetRuleset("osu"));
+ AddUntilStep("Became present", () => topLocalRank.IsPresent);
+ }
+
+ [Test]
+ public void TestHigherScoreSet()
+ {
+ ScoreInfo testScoreInfo = null;
+
+ AddAssert("Initially not present", () => !topLocalRank.IsPresent);
+
+ AddStep("Add score for current user", () =>
+ {
+ testScoreInfo = TestResources.CreateTestScoreInfo(importedBeatmap);
+
+ testScoreInfo.User = API.LocalUser.Value;
+ testScoreInfo.Rank = ScoreRank.B;
+
+ scoreManager.Import(testScoreInfo);
+ });
+
+ AddUntilStep("Became present", () => topLocalRank.IsPresent);
+ AddAssert("Correct rank", () => topLocalRank.Rank == ScoreRank.B);
+
+ AddStep("Add higher score for current user", () =>
+ {
+ var testScoreInfo2 = TestResources.CreateTestScoreInfo(importedBeatmap);
+
+ testScoreInfo2.User = API.LocalUser.Value;
+ testScoreInfo2.Rank = ScoreRank.S;
+ testScoreInfo2.TotalScore = testScoreInfo.TotalScore + 1;
+
+ scoreManager.Import(testScoreInfo2);
+ });
+
+ AddAssert("Correct rank", () => topLocalRank.Rank == ScoreRank.S);
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneUserTopScoreContainer.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneUserTopScoreContainer.cs
index 7af9e9eb40..dd7f9951bf 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestSceneUserTopScoreContainer.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneUserTopScoreContainer.cs
@@ -10,6 +10,7 @@ using osuTK.Graphics;
using osu.Game.Online.Leaderboards;
using osu.Game.Overlays;
using osu.Game.Rulesets.Mods;
+using osu.Game.Rulesets.Osu;
using osu.Game.Scoring;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Users;
@@ -61,6 +62,7 @@ namespace osu.Game.Tests.Visual.SongSelect
MaxCombo = 244,
TotalScore = 1707827,
Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
+ Ruleset = new OsuRuleset().RulesetInfo,
User = new APIUser
{
Id = 6602580,
@@ -79,6 +81,7 @@ namespace osu.Game.Tests.Visual.SongSelect
Accuracy = 1,
MaxCombo = 244,
TotalScore = 1707827,
+ Ruleset = new OsuRuleset().RulesetInfo,
User = new APIUser
{
Id = 4608074,
@@ -97,6 +100,7 @@ namespace osu.Game.Tests.Visual.SongSelect
Accuracy = 1,
MaxCombo = 244,
TotalScore = 1707827,
+ Ruleset = new OsuRuleset().RulesetInfo,
User = new APIUser
{
Id = 1541390,
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs
index a436fc0bfa..1e14e4b3e5 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs
@@ -1,13 +1,14 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
-using osu.Framework.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Extensions;
+using osu.Framework.Graphics;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Platform;
using osu.Framework.Testing;
@@ -16,10 +17,12 @@ using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface;
+using osu.Game.Models;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Leaderboards;
using osu.Game.Overlays;
using osu.Game.Rulesets;
+using osu.Game.Rulesets.Osu;
using osu.Game.Scoring;
using osu.Game.Screens.Select.Leaderboards;
using osu.Game.Tests.Resources;
@@ -41,6 +44,9 @@ namespace osu.Game.Tests.Visual.UserInterface
private BeatmapInfo beatmapInfo;
+ [Resolved]
+ private RealmContextFactory realmFactory { get; set; }
+
[Cached]
private readonly DialogOverlay dialogOverlay;
@@ -59,13 +65,12 @@ namespace osu.Game.Tests.Visual.UserInterface
Scope = BeatmapLeaderboardScope.Local,
BeatmapInfo = new BeatmapInfo
{
- ID = 1,
+ ID = Guid.NewGuid(),
Metadata = new BeatmapMetadata
{
- ID = 1,
Title = "TestSong",
Artist = "TestArtist",
- Author = new APIUser
+ Author = new RealmUser
{
Username = "TestAuthor"
},
@@ -84,26 +89,32 @@ namespace osu.Game.Tests.Visual.UserInterface
dependencies.Cache(rulesetStore = new RulesetStore(ContextFactory));
dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, ContextFactory, rulesetStore, null, dependencies.Get(), Resources, dependencies.Get(), Beatmap.Default));
- dependencies.Cache(scoreManager = new ScoreManager(rulesetStore, () => beatmapManager, LocalStorage, ContextFactory, Scheduler));
+ dependencies.Cache(scoreManager = new ScoreManager(dependencies.Get(), () => beatmapManager, LocalStorage, ContextFactory, Scheduler));
+ Dependencies.Cache(ContextFactory);
- beatmapInfo = beatmapManager.Import(new ImportTask(TestResources.GetQuickTestBeatmapForImport())).GetResultSafely().Value.Beatmaps[0];
+ var imported = beatmapManager.Import(new ImportTask(TestResources.GetQuickTestBeatmapForImport())).GetResultSafely();
- for (int i = 0; i < 50; i++)
+ imported?.PerformRead(s =>
{
- var score = new ScoreInfo
- {
- OnlineID = i,
- BeatmapInfo = beatmapInfo,
- BeatmapInfoID = beatmapInfo.ID,
- Accuracy = RNG.NextDouble(),
- TotalScore = RNG.Next(1, 1000000),
- MaxCombo = RNG.Next(1, 1000),
- Rank = ScoreRank.XH,
- User = new APIUser { Username = "TestUser" },
- };
+ beatmapInfo = s.Beatmaps[0];
- importedScores.Add(scoreManager.Import(score).GetResultSafely().Value);
- }
+ for (int i = 0; i < 50; i++)
+ {
+ var score = new ScoreInfo
+ {
+ OnlineID = i,
+ BeatmapInfo = beatmapInfo,
+ Accuracy = RNG.NextDouble(),
+ TotalScore = RNG.Next(1, 1000000),
+ MaxCombo = RNG.Next(1, 1000),
+ Rank = ScoreRank.XH,
+ User = new APIUser { Username = "TestUser" },
+ Ruleset = new OsuRuleset().RulesetInfo,
+ };
+
+ importedScores.Add(scoreManager.Import(score).GetResultSafely().Value);
+ }
+ });
return dependencies;
}
@@ -111,8 +122,11 @@ namespace osu.Game.Tests.Visual.UserInterface
[SetUp]
public void Setup() => Schedule(() =>
{
- // Due to soft deletions, we can re-use deleted scores between test runs
- scoreManager.Undelete(scoreManager.QueryScores(s => s.DeletePending).ToList());
+ using (var realm = realmFactory.CreateContext())
+ {
+ // Due to soft deletions, we can re-use deleted scores between test runs
+ scoreManager.Undelete(realm.All().Where(s => s.DeletePending).ToList());
+ }
leaderboard.Scores = null;
leaderboard.FinishTransforms(true); // After setting scores, we may be waiting for transforms to expire drawables
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModDifficultyAdjustSettings.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModDifficultyAdjustSettings.cs
index f8652573f4..8e1f426f7b 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneModDifficultyAdjustSettings.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModDifficultyAdjustSettings.cs
@@ -267,7 +267,7 @@ namespace osu.Game.Tests.Visual.UserInterface
{
BeatmapInfo = new BeatmapInfo
{
- BaseDifficulty = new BeatmapDifficulty
+ Difficulty = new BeatmapDifficulty
{
OverallDifficulty = value,
CircleSize = value,
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs
index f196bbd76e..b429619044 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs
@@ -459,6 +459,8 @@ namespace osu.Game.Tests.Visual.UserInterface
private class TestUnimplementedModOsuRuleset : OsuRuleset
{
+ public override string ShortName => "unimplemented";
+
public override IEnumerable GetModsFor(ModType type)
{
if (type == ModType.Conversion) return base.GetModsFor(type).Concat(new[] { new TestUnimplementedMod() });
diff --git a/osu.Game.Tests/Visual/UserInterface/TestScenePlaylistOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestScenePlaylistOverlay.cs
index 39146d584c..62f3b63780 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestScenePlaylistOverlay.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestScenePlaylistOverlay.cs
@@ -71,7 +71,7 @@ namespace osu.Game.Tests.Visual.UserInterface
InputManager.MoveMouseTo(item.ScreenSpaceDrawQuad.Centre);
});
- AddAssert("song 1 is 5th", () => beatmapSets[4] == first);
+ AddAssert("song 1 is 5th", () => beatmapSets[4].Equals(first));
AddStep("release handle", () => InputManager.ReleaseButton(MouseButton.Left));
}
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs
index 6fe1ccc037..7109a55e7e 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs
@@ -14,7 +14,6 @@ using osu.Game.Graphics.Containers;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
-using osu.Game.Rulesets;
using osu.Game.Tests.Beatmaps.IO;
using osuTK;
@@ -28,11 +27,11 @@ namespace osu.Game.Tests.Visual.UserInterface
private IAPIProvider api;
[BackgroundDependencyLoader]
- private void load(OsuGameBase osu, IAPIProvider api, RulesetStore rulesets)
+ private void load(OsuGameBase osu, IAPIProvider api)
{
this.api = api;
- testBeatmap = ImportBeatmapTest.LoadOszIntoOsu(osu).GetResultSafely();
+ testBeatmap = BeatmapImportHelper.LoadOszIntoOsu(osu).GetResultSafely();
}
[Test]
diff --git a/osu.Game.Tournament.Tests/NonVisual/DataLoadTest.cs b/osu.Game.Tournament.Tests/NonVisual/DataLoadTest.cs
index db019f9242..65753bfe00 100644
--- a/osu.Game.Tournament.Tests/NonVisual/DataLoadTest.cs
+++ b/osu.Game.Tournament.Tests/NonVisual/DataLoadTest.cs
@@ -35,9 +35,9 @@ namespace osu.Game.Tournament.Tests.NonVisual
public class TestTournament : TournamentGameBase
{
- [BackgroundDependencyLoader]
- private void load()
+ protected override void LoadComplete()
{
+ base.LoadComplete();
Ruleset.Value = new RulesetInfo(); // not available
}
}
diff --git a/osu.Game.Tournament.Tests/TestSceneTournamentSceneManager.cs b/osu.Game.Tournament.Tests/TestSceneTournamentSceneManager.cs
index 4d134ce4af..53591da07b 100644
--- a/osu.Game.Tournament.Tests/TestSceneTournamentSceneManager.cs
+++ b/osu.Game.Tournament.Tests/TestSceneTournamentSceneManager.cs
@@ -2,14 +2,13 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
-using osu.Framework.Platform;
namespace osu.Game.Tournament.Tests
{
public class TestSceneTournamentSceneManager : TournamentTestScene
{
[BackgroundDependencyLoader]
- private void load(Storage storage)
+ private void load()
{
Add(new TournamentSceneManager());
}
diff --git a/osu.Game.Tournament/Components/DrawableTeamTitle.cs b/osu.Game.Tournament/Components/DrawableTeamTitle.cs
index 5aac37259f..6732eb152f 100644
--- a/osu.Game.Tournament/Components/DrawableTeamTitle.cs
+++ b/osu.Game.Tournament/Components/DrawableTeamTitle.cs
@@ -4,7 +4,6 @@
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
-using osu.Framework.Graphics.Textures;
using osu.Game.Tournament.Models;
namespace osu.Game.Tournament.Components
@@ -22,7 +21,7 @@ namespace osu.Game.Tournament.Components
}
[BackgroundDependencyLoader]
- private void load(TextureStore textures)
+ private void load()
{
if (team == null) return;
diff --git a/osu.Game.Tournament/Components/DrawableTournamentTeam.cs b/osu.Game.Tournament/Components/DrawableTournamentTeam.cs
index b9442a67f5..367e447947 100644
--- a/osu.Game.Tournament/Components/DrawableTournamentTeam.cs
+++ b/osu.Game.Tournament/Components/DrawableTournamentTeam.cs
@@ -5,7 +5,6 @@ using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Containers;
-using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
using osu.Game.Tournament.Models;
@@ -33,7 +32,7 @@ namespace osu.Game.Tournament.Components
}
[BackgroundDependencyLoader]
- private void load(TextureStore textures)
+ private void load()
{
if (Team == null) return;
diff --git a/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs b/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs
index 364cccd076..4189f3ccb5 100644
--- a/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs
+++ b/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs
@@ -9,7 +9,6 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
-using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics;
@@ -45,7 +44,7 @@ namespace osu.Game.Tournament.Components
}
[BackgroundDependencyLoader]
- private void load(LadderInfo ladder, TextureStore textures)
+ private void load(LadderInfo ladder)
{
currentMatch.BindValueChanged(matchChanged);
currentMatch.BindTo(ladder.CurrentMatch);
diff --git a/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs
index f6bc607447..5c12d83d1c 100644
--- a/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs
+++ b/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs
@@ -12,7 +12,6 @@ using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Settings;
-using osu.Game.Rulesets;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
using osuTK;
@@ -218,7 +217,7 @@ namespace osu.Game.Tournament.Screens.Editors
}
[BackgroundDependencyLoader]
- private void load(RulesetStore rulesets)
+ private void load()
{
beatmapId.Value = Model.ID;
beatmapId.BindValueChanged(id =>
diff --git a/osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs
index 5d2fddffd9..5cdfe7dc08 100644
--- a/osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs
+++ b/osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs
@@ -12,7 +12,6 @@ using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Settings;
-using osu.Game.Rulesets;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
using osuTK;
@@ -220,7 +219,7 @@ namespace osu.Game.Tournament.Screens.Editors
}
[BackgroundDependencyLoader]
- private void load(RulesetStore rulesets)
+ private void load()
{
beatmapId.Value = Model.ID;
beatmapId.BindValueChanged(id =>
diff --git a/osu.Game.Tournament/Screens/Gameplay/Components/TournamentMatchScoreDisplay.cs b/osu.Game.Tournament/Screens/Gameplay/Components/TournamentMatchScoreDisplay.cs
index 813bed86ae..db15a46fc8 100644
--- a/osu.Game.Tournament/Screens/Gameplay/Components/TournamentMatchScoreDisplay.cs
+++ b/osu.Game.Tournament/Screens/Gameplay/Components/TournamentMatchScoreDisplay.cs
@@ -11,7 +11,6 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Tournament.IPC;
-using osu.Game.Tournament.Models;
using osuTK;
namespace osu.Game.Tournament.Screens.Gameplay.Components
@@ -91,7 +90,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
}
[BackgroundDependencyLoader]
- private void load(LadderInfo ladder, MatchIPCInfo ipc)
+ private void load(MatchIPCInfo ipc)
{
score1.BindValueChanged(_ => updateScores());
score1.BindTo(ipc.Score1);
diff --git a/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs b/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs
index 7e7c719152..f900dd7eac 100644
--- a/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs
+++ b/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs
@@ -6,7 +6,6 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
-using osu.Framework.Platform;
using osu.Framework.Threading;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Settings;
@@ -37,7 +36,7 @@ namespace osu.Game.Tournament.Screens.Gameplay
private Drawable chroma;
[BackgroundDependencyLoader]
- private void load(LadderInfo ladder, MatchIPCInfo ipc, Storage storage)
+ private void load(LadderInfo ladder, MatchIPCInfo ipc)
{
this.ipc = ipc;
diff --git a/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs b/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs
index bb1e4d2eff..ea453a53ca 100644
--- a/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs
+++ b/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs
@@ -81,7 +81,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
}
[BackgroundDependencyLoader(true)]
- private void load(OsuColour colours, LadderEditorScreen ladderEditor)
+ private void load(LadderEditorScreen ladderEditor)
{
this.ladderEditor = ladderEditor;
diff --git a/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs b/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs
index 534c402f6c..ad6e304c80 100644
--- a/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs
+++ b/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs
@@ -9,8 +9,6 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Lines;
-using osu.Framework.Platform;
-using osu.Game.Graphics;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
using osu.Game.Tournament.Screens.Editors;
@@ -30,7 +28,7 @@ namespace osu.Game.Tournament.Screens.Ladder
protected Container Content;
[BackgroundDependencyLoader]
- private void load(OsuColour colours, Storage storage)
+ private void load()
{
normalPathColour = Color4Extensions.FromHex("#66D1FF");
losersPathColour = Color4Extensions.FromHex("#FFC700");
diff --git a/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs b/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs
index e08be65465..84f38170ea 100644
--- a/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs
+++ b/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs
@@ -8,7 +8,6 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
-using osu.Framework.Platform;
using osu.Game.Graphics;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
@@ -25,7 +24,7 @@ namespace osu.Game.Tournament.Screens.Schedule
private LadderInfo ladder;
[BackgroundDependencyLoader]
- private void load(LadderInfo ladder, Storage storage)
+ private void load(LadderInfo ladder)
{
this.ladder = ladder;
diff --git a/osu.Game.Tournament/Screens/TeamIntro/SeedingScreen.cs b/osu.Game.Tournament/Screens/TeamIntro/SeedingScreen.cs
index cd74a75b10..0003e213e7 100644
--- a/osu.Game.Tournament/Screens/TeamIntro/SeedingScreen.cs
+++ b/osu.Game.Tournament/Screens/TeamIntro/SeedingScreen.cs
@@ -8,7 +8,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
-using osu.Framework.Platform;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Tournament.Components;
@@ -25,7 +24,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
private readonly Bindable currentTeam = new Bindable();
[BackgroundDependencyLoader]
- private void load(Storage storage)
+ private void load()
{
RelativeSizeAxes = Axes.Both;
diff --git a/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs b/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs
index 74957cbca5..ef6f0b32ff 100644
--- a/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs
+++ b/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs
@@ -5,7 +5,6 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
-using osu.Framework.Platform;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
using osuTK;
@@ -17,7 +16,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
private Container mainContainer;
[BackgroundDependencyLoader]
- private void load(Storage storage)
+ private void load()
{
RelativeSizeAxes = Axes.Both;
diff --git a/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs b/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs
index ebe2908b74..11db7bfad9 100644
--- a/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs
+++ b/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs
@@ -5,7 +5,6 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
-using osu.Framework.Platform;
using osu.Game.Graphics;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
@@ -23,7 +22,7 @@ namespace osu.Game.Tournament.Screens.TeamWin
private TourneyVideo redWinVideo;
[BackgroundDependencyLoader]
- private void load(LadderInfo ladder, Storage storage)
+ private void load()
{
RelativeSizeAxes = Axes.Both;
diff --git a/osu.Game.Tournament/TournamentGameBase.cs b/osu.Game.Tournament/TournamentGameBase.cs
index d08322a3e8..f318c8bd85 100644
--- a/osu.Game.Tournament/TournamentGameBase.cs
+++ b/osu.Game.Tournament/TournamentGameBase.cs
@@ -81,8 +81,9 @@ namespace osu.Game.Tournament
ladder ??= new LadderInfo();
- ladder.Ruleset.Value = RulesetStore.GetRuleset(ladder.Ruleset.Value?.ShortName)
- ?? RulesetStore.AvailableRulesets.First();
+ ladder.Ruleset.Value = ladder.Ruleset.Value != null
+ ? RulesetStore.GetRuleset(ladder.Ruleset.Value.ShortName)
+ : RulesetStore.AvailableRulesets.First();
bool addedInfo = false;
diff --git a/osu.Game.Tournament/TournamentSceneManager.cs b/osu.Game.Tournament/TournamentSceneManager.cs
index 914d1163ad..80a9c07cde 100644
--- a/osu.Game.Tournament/TournamentSceneManager.cs
+++ b/osu.Game.Tournament/TournamentSceneManager.cs
@@ -7,11 +7,9 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
-using osu.Framework.Platform;
using osu.Framework.Threading;
using osu.Game.Graphics;
using osu.Game.Tournament.Components;
-using osu.Game.Tournament.Models;
using osu.Game.Tournament.Screens;
using osu.Game.Tournament.Screens.Drawings;
using osu.Game.Tournament.Screens.Editors;
@@ -52,7 +50,7 @@ namespace osu.Game.Tournament
}
[BackgroundDependencyLoader]
- private void load(LadderInfo ladder, Storage storage)
+ private void load()
{
InternalChildren = new Drawable[]
{
diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs
index 435183fe92..2fa5a56042 100644
--- a/osu.Game/Beatmaps/Beatmap.cs
+++ b/osu.Game/Beatmaps/Beatmap.cs
@@ -28,7 +28,7 @@ namespace osu.Game.Beatmaps
difficulty = value;
if (beatmapInfo != null)
- beatmapInfo.BaseDifficulty = difficulty.Clone();
+ beatmapInfo.Difficulty = difficulty.Clone();
}
}
@@ -41,8 +41,8 @@ namespace osu.Game.Beatmaps
{
beatmapInfo = value;
- if (beatmapInfo?.BaseDifficulty != null)
- Difficulty = beatmapInfo.BaseDifficulty.Clone();
+ if (beatmapInfo?.Difficulty != null)
+ Difficulty = beatmapInfo.Difficulty.Clone();
}
}
@@ -54,15 +54,15 @@ namespace osu.Game.Beatmaps
{
Artist = @"Unknown",
Title = @"Unknown",
- AuthorString = @"Unknown Creator",
+ Author = { Username = @"Unknown Creator" },
},
DifficultyName = @"Normal",
- BaseDifficulty = Difficulty,
+ Difficulty = Difficulty,
};
}
[JsonIgnore]
- public BeatmapMetadata Metadata => BeatmapInfo?.Metadata ?? BeatmapInfo?.BeatmapSet?.Metadata;
+ public BeatmapMetadata Metadata => BeatmapInfo.Metadata;
public ControlPointInfo ControlPointInfo { get; set; } = new ControlPointInfo();
diff --git a/osu.Game/Beatmaps/BeatmapDifficulty.cs b/osu.Game/Beatmaps/BeatmapDifficulty.cs
index 65d1fb8286..7e0462f1e8 100644
--- a/osu.Game/Beatmaps/BeatmapDifficulty.cs
+++ b/osu.Game/Beatmaps/BeatmapDifficulty.cs
@@ -1,27 +1,29 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using System;
-using osu.Game.Database;
+using osu.Framework.Testing;
+using Realms;
+
+#nullable enable
namespace osu.Game.Beatmaps
{
- public class BeatmapDifficulty : IHasPrimaryKey, IBeatmapDifficultyInfo
+ [ExcludeFromDynamicCompile]
+ [MapTo("BeatmapDifficulty")]
+ public class BeatmapDifficulty : EmbeddedObject, IBeatmapDifficultyInfo
{
///
/// The default value used for all difficulty settings except and .
///
public const float DEFAULT_DIFFICULTY = 5;
- public int ID { get; set; }
+ public float DrainRate { get; set; } = IBeatmapDifficultyInfo.DEFAULT_DIFFICULTY;
+ public float CircleSize { get; set; } = IBeatmapDifficultyInfo.DEFAULT_DIFFICULTY;
+ public float OverallDifficulty { get; set; } = IBeatmapDifficultyInfo.DEFAULT_DIFFICULTY;
+ public float ApproachRate { get; set; } = IBeatmapDifficultyInfo.DEFAULT_DIFFICULTY;
- public bool IsManaged => ID > 0;
-
- public float DrainRate { get; set; } = DEFAULT_DIFFICULTY;
- public float CircleSize { get; set; } = DEFAULT_DIFFICULTY;
- public float OverallDifficulty { get; set; } = DEFAULT_DIFFICULTY;
-
- private float? approachRate;
+ public double SliderMultiplier { get; set; } = 1;
+ public double SliderTickRate { get; set; } = 1;
public BeatmapDifficulty()
{
@@ -32,23 +34,20 @@ namespace osu.Game.Beatmaps
CopyFrom(source);
}
- public float ApproachRate
- {
- get => approachRate ?? OverallDifficulty;
- set => approachRate = value;
- }
-
- public double SliderMultiplier { get; set; } = 1;
- public double SliderTickRate { get; set; } = 1;
-
///
/// Returns a shallow-clone of this .
///
- public BeatmapDifficulty Clone()
+ public virtual BeatmapDifficulty Clone() => new BeatmapDifficulty(this);
+
+ public virtual void CopyTo(BeatmapDifficulty difficulty)
{
- var diff = (BeatmapDifficulty)Activator.CreateInstance(GetType());
- CopyTo(diff);
- return diff;
+ difficulty.ApproachRate = ApproachRate;
+ difficulty.DrainRate = DrainRate;
+ difficulty.CircleSize = CircleSize;
+ difficulty.OverallDifficulty = OverallDifficulty;
+
+ difficulty.SliderMultiplier = SliderMultiplier;
+ difficulty.SliderTickRate = SliderTickRate;
}
public virtual void CopyFrom(IBeatmapDifficultyInfo other)
@@ -61,16 +60,5 @@ namespace osu.Game.Beatmaps
SliderMultiplier = other.SliderMultiplier;
SliderTickRate = other.SliderTickRate;
}
-
- public virtual void CopyTo(BeatmapDifficulty other)
- {
- other.ApproachRate = ApproachRate;
- other.DrainRate = DrainRate;
- other.CircleSize = CircleSize;
- other.OverallDifficulty = OverallDifficulty;
-
- other.SliderMultiplier = SliderMultiplier;
- other.SliderTickRate = SliderTickRate;
- }
}
}
diff --git a/osu.Game/Beatmaps/BeatmapDifficultyCache.cs b/osu.Game/Beatmaps/BeatmapDifficultyCache.cs
index f760c25170..f102daeef5 100644
--- a/osu.Game/Beatmaps/BeatmapDifficultyCache.cs
+++ b/osu.Game/Beatmaps/BeatmapDifficultyCache.cs
@@ -136,7 +136,7 @@ namespace osu.Game.Beatmaps
var localRulesetInfo = rulesetInfo as RulesetInfo;
// Difficulty can only be computed if the beatmap and ruleset are locally available.
- if (localBeatmapInfo?.IsManaged != true || localRulesetInfo == null)
+ if (localBeatmapInfo == null || localRulesetInfo == null)
{
// If not, fall back to the existing star difficulty (e.g. from an online source).
return Task.FromResult(new StarDifficulty(beatmapInfo.StarRating, (beatmapInfo as IBeatmapOnlineInfo)?.MaxCombo ?? 0));
diff --git a/osu.Game/Beatmaps/BeatmapInfo.cs b/osu.Game/Beatmaps/BeatmapInfo.cs
index 4175d7ff6b..cddd7e9b30 100644
--- a/osu.Game/Beatmaps/BeatmapInfo.cs
+++ b/osu.Game/Beatmaps/BeatmapInfo.cs
@@ -2,102 +2,119 @@
// See the LICENCE file in the repository root for full licence text.
using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using JetBrains.Annotations;
using Newtonsoft.Json;
using osu.Framework.Testing;
using osu.Game.Database;
+using osu.Game.Models;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets;
using osu.Game.Scoring;
+using Realms;
+
+#nullable enable
namespace osu.Game.Beatmaps
{
+ ///
+ /// A single beatmap difficulty.
+ ///
[ExcludeFromDynamicCompile]
[Serializable]
- public class BeatmapInfo : IEquatable, IHasPrimaryKey, IBeatmapInfo
+ [MapTo("Beatmap")]
+ public class BeatmapInfo : RealmObject, IHasGuidPrimaryKey, IBeatmapInfo, IEquatable
{
- public int ID { get; set; }
+ [PrimaryKey]
+ public Guid ID { get; set; } = Guid.NewGuid();
- public bool IsManaged => ID > 0;
+ public string DifficultyName { get; set; } = string.Empty;
- public int BeatmapVersion;
+ public RulesetInfo Ruleset { get; set; }
- private int? onlineID;
-
- [JsonProperty("id")]
- [Column("OnlineBeatmapID")]
- public int? OnlineID
- {
- get => onlineID;
- set => onlineID = value > 0 ? value : null;
- }
-
- [JsonIgnore]
- public int BeatmapSetInfoID { get; set; }
-
- public BeatmapOnlineStatus Status { get; set; } = BeatmapOnlineStatus.None;
-
- [Required]
- public BeatmapSetInfo BeatmapSet { get; set; }
+ public BeatmapDifficulty Difficulty { get; set; }
public BeatmapMetadata Metadata { get; set; }
- [JsonIgnore]
- public int BaseDifficultyID { get; set; }
+ [Backlink(nameof(ScoreInfo.BeatmapInfo))]
+ public IQueryable Scores { get; } = null!;
- public BeatmapDifficulty BaseDifficulty { get; set; }
+ public BeatmapInfo(RulesetInfo ruleset, BeatmapDifficulty difficulty, BeatmapMetadata metadata)
+ {
+ Ruleset = ruleset;
+ Difficulty = difficulty;
+ Metadata = metadata;
+ }
- [NotMapped]
- public APIBeatmap OnlineInfo { get; set; }
+ [UsedImplicitly]
+ public BeatmapInfo() // TODO: consider removing this and migrating all usages to ctor with parameters.
+ {
+ Ruleset = new RulesetInfo
+ {
+ OnlineID = 0,
+ ShortName = @"osu",
+ Name = @"null placeholder ruleset"
+ };
+ Difficulty = new BeatmapDifficulty();
+ Metadata = new BeatmapMetadata();
+ }
- [NotMapped]
- public int? MaxCombo { get; set; }
+ public BeatmapSetInfo? BeatmapSet { get; set; }
+
+ [Ignored]
+ public RealmNamedFileUsage? File => BeatmapSet?.Files.FirstOrDefault(f => f.File.Hash == Hash);
+
+ [Ignored]
+ public BeatmapOnlineStatus Status
+ {
+ get => (BeatmapOnlineStatus)StatusInt;
+ set => StatusInt = (int)value;
+ }
+
+ [MapTo(nameof(Status))]
+ public int StatusInt { get; set; } = (int)BeatmapOnlineStatus.None;
+
+ [Indexed]
+ public int OnlineID { get; set; } = -1;
- ///
- /// The playable length in milliseconds of this beatmap.
- ///
public double Length { get; set; }
- ///
- /// The most common BPM of this beatmap.
- ///
public double BPM { get; set; }
- public string Path { get; set; }
+ public string Hash { get; set; } = string.Empty;
- [JsonProperty("file_sha2")]
- public string Hash { get; set; }
+ public double StarRating { get; set; }
+
+ public string MD5Hash { get; set; } = string.Empty;
[JsonIgnore]
public bool Hidden { get; set; }
- ///
- /// MD5 is kept for legacy support (matching against replays, osu-web-10 etc.).
- ///
- [JsonProperty("file_md5")]
- public string MD5Hash { get; set; }
+ #region Properties we may not want persisted (but also maybe no harm?)
- // General
public double AudioLeadIn { get; set; }
+
public float StackLeniency { get; set; } = 0.7f;
+
public bool SpecialStyle { get; set; }
- public int RulesetID { get; set; }
-
- public RulesetInfo Ruleset { get; set; }
-
public bool LetterboxInBreaks { get; set; }
+
public bool WidescreenStoryboard { get; set; }
+
public bool EpilepsyWarning { get; set; }
- ///
- /// Whether or not sound samples should change rate when playing with speed-changing mods.
- /// TODO: only read/write supported for now, requires implementation in gameplay.
- ///
public bool SamplesMatchPlaybackRate { get; set; }
+ public double DistanceSpacing { get; set; }
+
+ public int BeatDivisor { get; set; }
+
+ public int GridSize { get; set; }
+
+ public double TimelineZoom { get; set; }
+
+ [Ignored]
public CountdownType Countdown { get; set; } = CountdownType.Normal;
///
@@ -105,77 +122,75 @@ namespace osu.Game.Beatmaps
///
public int CountdownOffset { get; set; }
- [NotMapped]
- public int[] Bookmarks { get; set; } = Array.Empty();
+ #endregion
- public double DistanceSpacing { get; set; }
- public int BeatDivisor { get; set; }
- public int GridSize { get; set; }
- public double TimelineZoom { get; set; }
-
- // Metadata
- [Column("Version")]
- public string DifficultyName { get; set; }
-
- [JsonProperty("difficulty_rating")]
- [Column("StarDifficulty")]
- public double StarRating { get; set; }
-
- ///
- /// Currently only populated for beatmap deletion. Use to query scores.
- ///
- public List Scores { get; set; }
-
- [JsonIgnore]
- public DifficultyRating DifficultyRating => BeatmapDifficultyCache.GetDifficultyRating(StarRating);
-
- public override string ToString() => this.GetDisplayTitle();
-
- public bool Equals(BeatmapInfo other)
+ public bool Equals(BeatmapInfo? other)
{
if (ReferenceEquals(this, other)) return true;
if (other == null) return false;
- if (ID != 0 && other.ID != 0)
- return ID == other.ID;
-
- return false;
+ return ID == other.ID;
}
- public bool Equals(IBeatmapInfo other) => other is BeatmapInfo b && Equals(b);
+ public bool Equals(IBeatmapInfo? other) => other is BeatmapInfo b && Equals(b);
- public bool AudioEquals(BeatmapInfo other) => other != null && BeatmapSet != null && other.BeatmapSet != null &&
- BeatmapSet.Hash == other.BeatmapSet.Hash &&
- (Metadata ?? BeatmapSet.Metadata).AudioFile == (other.Metadata ?? other.BeatmapSet.Metadata).AudioFile;
+ public bool AudioEquals(BeatmapInfo? other) => other != null
+ && BeatmapSet != null
+ && other.BeatmapSet != null
+ && BeatmapSet.Hash == other.BeatmapSet.Hash
+ && Metadata.AudioFile == other.Metadata.AudioFile;
- public bool BackgroundEquals(BeatmapInfo other) => other != null && BeatmapSet != null && other.BeatmapSet != null &&
- BeatmapSet.Hash == other.BeatmapSet.Hash &&
- (Metadata ?? BeatmapSet.Metadata).BackgroundFile == (other.Metadata ?? other.BeatmapSet.Metadata).BackgroundFile;
+ public bool BackgroundEquals(BeatmapInfo? other) => other != null
+ && BeatmapSet != null
+ && other.BeatmapSet != null
+ && BeatmapSet.Hash == other.BeatmapSet.Hash
+ && Metadata.BackgroundFile == other.Metadata.BackgroundFile;
- ///
- /// Returns a shallow-clone of this .
- ///
- public BeatmapInfo Clone() => (BeatmapInfo)MemberwiseClone();
-
- #region Implementation of IHasOnlineID
-
- int IHasOnlineID.OnlineID => OnlineID ?? -1;
-
- #endregion
-
- #region Implementation of IBeatmapInfo
-
- [JsonIgnore]
- IBeatmapMetadataInfo IBeatmapInfo.Metadata => Metadata ?? BeatmapSet?.Metadata ?? new BeatmapMetadata();
-
- [JsonIgnore]
- IBeatmapDifficultyInfo IBeatmapInfo.Difficulty => BaseDifficulty;
-
- [JsonIgnore]
- IBeatmapSetInfo IBeatmapInfo.BeatmapSet => BeatmapSet;
-
- [JsonIgnore]
+ IBeatmapMetadataInfo IBeatmapInfo.Metadata => Metadata;
+ IBeatmapSetInfo? IBeatmapInfo.BeatmapSet => BeatmapSet;
IRulesetInfo IBeatmapInfo.Ruleset => Ruleset;
+ IBeatmapDifficultyInfo IBeatmapInfo.Difficulty => Difficulty;
+
+ #region Compatibility properties
+
+ [Ignored]
+ public int RulesetID
+ {
+ get => Ruleset.OnlineID;
+ set
+ {
+ if (!string.IsNullOrEmpty(Ruleset.InstantiationInfo))
+ throw new InvalidOperationException($"Cannot set a {nameof(RulesetID)} when {nameof(Ruleset)} is already set to an actual ruleset.");
+
+ Ruleset.OnlineID = value;
+ }
+ }
+
+ [Ignored]
+ [Obsolete("Use BeatmapInfo.Difficulty instead.")] // can be removed 20220719
+ public BeatmapDifficulty BaseDifficulty
+ {
+ get => Difficulty;
+ set => Difficulty = value;
+ }
+
+ [Ignored]
+ public string? Path => File?.Filename;
+
+ [Ignored]
+ public APIBeatmap? OnlineInfo { get; set; }
+
+ [Ignored]
+ public int? MaxCombo { get; set; }
+
+ [Ignored]
+ public int[] Bookmarks { get; set; } = Array.Empty();
+
+ public int BeatmapVersion;
+
+ public BeatmapInfo Clone() => (BeatmapInfo)this.Detach().MemberwiseClone();
+
+ public override string ToString() => this.GetDisplayTitle();
#endregion
}
diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs
index ed7fe0bc91..ee649ad960 100644
--- a/osu.Game/Beatmaps/BeatmapManager.cs
+++ b/osu.Game/Beatmaps/BeatmapManager.cs
@@ -8,7 +8,6 @@ using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
-using JetBrains.Annotations;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Extensions;
@@ -16,13 +15,16 @@ using osu.Framework.IO.Stores;
using osu.Framework.Platform;
using osu.Framework.Testing;
using osu.Game.Database;
-using osu.Game.IO;
using osu.Game.IO.Archives;
+using osu.Game.Models;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets;
using osu.Game.Skinning;
+using osu.Game.Stores;
+
+#nullable enable
namespace osu.Game.Beatmaps
{
@@ -30,41 +32,46 @@ namespace osu.Game.Beatmaps
/// Handles general operations related to global beatmap management.
///
[ExcludeFromDynamicCompile]
- public class BeatmapManager : IModelManager, IModelFileManager, IModelImporter, IWorkingBeatmapCache, IDisposable
+ public class BeatmapManager : IModelManager, IModelFileManager, IModelImporter, IWorkingBeatmapCache, IDisposable
{
public ITrackStore BeatmapTrackStore { get; }
private readonly BeatmapModelManager beatmapModelManager;
private readonly WorkingBeatmapCache workingBeatmapCache;
- private readonly BeatmapOnlineLookupQueue onlineBeatmapLookupQueue;
+ private readonly BeatmapOnlineLookupQueue? onlineBeatmapLookupQueue;
- public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore gameResources, GameHost host = null, WorkingBeatmap defaultBeatmap = null, bool performOnlineLookups = false)
+ private readonly RealmContextFactory contextFactory;
+
+ public BeatmapManager(Storage storage, RealmContextFactory contextFactory, RulesetStore rulesets, IAPIProvider? api, AudioManager audioManager, IResourceStore gameResources, GameHost? host = null, WorkingBeatmap? defaultBeatmap = null, bool performOnlineLookups = false)
{
- var userResources = new FileStore(contextFactory, storage).Store;
-
- BeatmapTrackStore = audioManager.GetTrackStore(userResources);
-
- beatmapModelManager = CreateBeatmapModelManager(storage, contextFactory, rulesets, api, host);
- workingBeatmapCache = CreateWorkingBeatmapCache(audioManager, gameResources, userResources, defaultBeatmap, host);
-
- workingBeatmapCache.BeatmapManager = beatmapModelManager;
- beatmapModelManager.WorkingBeatmapCache = workingBeatmapCache;
+ this.contextFactory = contextFactory;
if (performOnlineLookups)
{
+ if (api == null)
+ throw new ArgumentNullException(nameof(api), "API must be provided if online lookups are required.");
+
onlineBeatmapLookupQueue = new BeatmapOnlineLookupQueue(api, storage);
- beatmapModelManager.OnlineLookupQueue = onlineBeatmapLookupQueue;
}
+
+ var userResources = new RealmFileStore(contextFactory, storage).Store;
+
+ BeatmapTrackStore = audioManager.GetTrackStore(userResources);
+
+ beatmapModelManager = CreateBeatmapModelManager(storage, contextFactory, rulesets, onlineBeatmapLookupQueue);
+ workingBeatmapCache = CreateWorkingBeatmapCache(audioManager, gameResources, userResources, defaultBeatmap, host);
+
+ beatmapModelManager.WorkingBeatmapCache = workingBeatmapCache;
}
- protected virtual WorkingBeatmapCache CreateWorkingBeatmapCache(AudioManager audioManager, IResourceStore resources, IResourceStore storage, WorkingBeatmap defaultBeatmap, GameHost host)
+ protected virtual WorkingBeatmapCache CreateWorkingBeatmapCache(AudioManager audioManager, IResourceStore resources, IResourceStore storage, WorkingBeatmap? defaultBeatmap, GameHost? host)
{
return new WorkingBeatmapCache(BeatmapTrackStore, audioManager, resources, storage, defaultBeatmap, host);
}
- protected virtual BeatmapModelManager CreateBeatmapModelManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, GameHost host) =>
- new BeatmapModelManager(storage, contextFactory, rulesets, host);
+ protected virtual BeatmapModelManager CreateBeatmapModelManager(Storage storage, RealmContextFactory contextFactory, RulesetStore rulesets, BeatmapOnlineLookupQueue? onlineLookupQueue) =>
+ new BeatmapModelManager(contextFactory, storage, onlineLookupQueue);
///
/// Create a new .
@@ -73,17 +80,20 @@ namespace osu.Game.Beatmaps
{
var metadata = new BeatmapMetadata
{
- Author = user,
+ Author = new RealmUser
+ {
+ OnlineID = user.OnlineID,
+ Username = user.Username,
+ }
};
- var set = new BeatmapSetInfo
+ var beatmapSet = new BeatmapSetInfo
{
- Metadata = metadata,
Beatmaps =
{
new BeatmapInfo
{
- BaseDifficulty = new BeatmapDifficulty(),
+ Difficulty = new BeatmapDifficulty(),
Ruleset = ruleset,
Metadata = metadata,
WidescreenStoryboard = true,
@@ -92,30 +102,92 @@ namespace osu.Game.Beatmaps
}
};
- var imported = beatmapModelManager.Import(set).GetResultSafely().Value;
+ foreach (BeatmapInfo b in beatmapSet.Beatmaps)
+ b.BeatmapSet = beatmapSet;
- return GetWorkingBeatmap(imported.Beatmaps.First());
+ var imported = beatmapModelManager.Import(beatmapSet).GetResultSafely();
+
+ if (imported == null)
+ throw new InvalidOperationException("Failed to import new beatmap");
+
+ return imported.PerformRead(s => GetWorkingBeatmap(s.Beatmaps.First()));
+ }
+
+ ///
+ /// Delete a beatmap difficulty.
+ ///
+ /// The beatmap difficulty to hide.
+ public void Hide(BeatmapInfo beatmapInfo)
+ {
+ using (var realm = contextFactory.CreateContext())
+ using (var transaction = realm.BeginWrite())
+ {
+ if (!beatmapInfo.IsManaged)
+ beatmapInfo = realm.Find(beatmapInfo.ID);
+
+ beatmapInfo.Hidden = true;
+ transaction.Commit();
+ }
+ }
+
+ ///
+ /// Restore a beatmap difficulty.
+ ///
+ /// The beatmap difficulty to restore.
+ public void Restore(BeatmapInfo beatmapInfo)
+ {
+ using (var realm = contextFactory.CreateContext())
+ using (var transaction = realm.BeginWrite())
+ {
+ if (!beatmapInfo.IsManaged)
+ beatmapInfo = realm.Find(beatmapInfo.ID);
+
+ beatmapInfo.Hidden = false;
+ transaction.Commit();
+ }
+ }
+
+ public void RestoreAll()
+ {
+ using (var realm = contextFactory.CreateContext())
+ using (var transaction = realm.BeginWrite())
+ {
+ foreach (var beatmap in realm.All