diff --git a/osu.Game.Tests/Database/RulesetStoreTests.cs b/osu.Game.Tests/Database/RulesetStoreTests.cs
index f4e0838be1..cc7e8a0c97 100644
--- a/osu.Game.Tests/Database/RulesetStoreTests.cs
+++ b/osu.Game.Tests/Database/RulesetStoreTests.cs
@@ -45,9 +45,9 @@ namespace osu.Game.Tests.Database
{
var rulesets = new RealmRulesetStore(realmFactory, storage);
- Assert.IsTrue((rulesets.AvailableRulesets.First() as RealmRuleset)?.IsManaged == false);
- Assert.IsTrue((rulesets.GetRuleset(0) as RealmRuleset)?.IsManaged == false);
- Assert.IsTrue((rulesets.GetRuleset("mania") as RealmRuleset)?.IsManaged == false);
+ Assert.IsFalse(rulesets.AvailableRulesets.First().IsManaged);
+ Assert.IsFalse(rulesets.GetRuleset(0)?.IsManaged);
+ Assert.IsFalse(rulesets.GetRuleset("mania")?.IsManaged);
});
}
}
diff --git a/osu.Game.Tests/Visual/Menus/TestSceneToolbar.cs b/osu.Game.Tests/Visual/Menus/TestSceneToolbar.cs
index 57d60cea9e..c65595d82e 100644
--- a/osu.Game.Tests/Visual/Menus/TestSceneToolbar.cs
+++ b/osu.Game.Tests/Visual/Menus/TestSceneToolbar.cs
@@ -20,7 +20,7 @@ namespace osu.Game.Tests.Visual.Menus
private TestToolbar toolbar;
[Resolved]
- private RulesetStore rulesets { get; set; }
+ private IRulesetStore rulesets { get; set; }
[SetUp]
public void SetUp() => Schedule(() =>
diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs
index 90f3eb64e4..63741451f3 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs
@@ -25,7 +25,7 @@ namespace osu.Game.Tests.Visual.Online
}
[Resolved]
- private RulesetStore rulesets { get; set; }
+ private IRulesetStore rulesets { get; set; }
[Test]
public void TestMultipleRulesetsBeatmapSet()
diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs
index 3314e291e8..f87cca80b0 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs
@@ -30,7 +30,7 @@ namespace osu.Game.Tests.Visual.Online
}
[Resolved]
- private RulesetStore rulesets { get; set; }
+ private IRulesetStore rulesets { get; set; }
[Test]
public void TestLoading()
diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs b/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs
index 19e06beaad..52d5eb2c65 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs
@@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual.Online
private TestUserListPanel evast;
[Resolved]
- private RulesetStore rulesetStore { get; set; }
+ private IRulesetStore rulesetStore { get; set; }
[SetUp]
public void SetUp() => Schedule(() =>
diff --git a/osu.Game.Tournament.Tests/Components/TestSceneTournamentBeatmapPanel.cs b/osu.Game.Tournament.Tests/Components/TestSceneTournamentBeatmapPanel.cs
index a96c5123e0..b678f69b8f 100644
--- a/osu.Game.Tournament.Tests/Components/TestSceneTournamentBeatmapPanel.cs
+++ b/osu.Game.Tournament.Tests/Components/TestSceneTournamentBeatmapPanel.cs
@@ -6,12 +6,17 @@ using osu.Framework.Graphics;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
+using osu.Game.Tests.Visual;
using osu.Game.Tournament.Components;
namespace osu.Game.Tournament.Tests.Components
{
public class TestSceneTournamentBeatmapPanel : TournamentTestScene
{
+ ///
+ /// Warning: the below API instance is actually the online API, rather than the dummy API provided by the test.
+ /// It cannot be trivially replaced because setting to causes to no longer be usable.
+ ///
[Resolved]
private IAPIProvider api { get; set; }
diff --git a/osu.Game.Tournament.Tests/Components/TestSceneTournamentModDisplay.cs b/osu.Game.Tournament.Tests/Components/TestSceneTournamentModDisplay.cs
index 3cd13df0d3..9feef36a02 100644
--- a/osu.Game.Tournament.Tests/Components/TestSceneTournamentModDisplay.cs
+++ b/osu.Game.Tournament.Tests/Components/TestSceneTournamentModDisplay.cs
@@ -19,7 +19,7 @@ namespace osu.Game.Tournament.Tests.Components
private IAPIProvider api { get; set; }
[Resolved]
- private RulesetStore rulesets { get; set; }
+ private IRulesetStore rulesets { get; set; }
private FillFlowContainer fillFlow;
diff --git a/osu.Game.Tournament/Components/TournamentModIcon.cs b/osu.Game.Tournament/Components/TournamentModIcon.cs
index 0fde263bc8..ed8a36c220 100644
--- a/osu.Game.Tournament/Components/TournamentModIcon.cs
+++ b/osu.Game.Tournament/Components/TournamentModIcon.cs
@@ -21,7 +21,7 @@ namespace osu.Game.Tournament.Components
private readonly string modAcronym;
[Resolved]
- private RulesetStore rulesets { get; set; }
+ private IRulesetStore rulesets { get; set; }
public TournamentModIcon(string modAcronym)
{
diff --git a/osu.Game.Tournament/IPC/FileBasedIPC.cs b/osu.Game.Tournament/IPC/FileBasedIPC.cs
index a57f9fd691..5278d538d2 100644
--- a/osu.Game.Tournament/IPC/FileBasedIPC.cs
+++ b/osu.Game.Tournament/IPC/FileBasedIPC.cs
@@ -28,7 +28,7 @@ namespace osu.Game.Tournament.IPC
protected IAPIProvider API { get; private set; }
[Resolved]
- protected RulesetStore Rulesets { get; private set; }
+ protected IRulesetStore Rulesets { get; private set; }
[Resolved]
private GameHost host { get; set; }
diff --git a/osu.Game/Beatmaps/DifficultyRecommender.cs b/osu.Game/Beatmaps/DifficultyRecommender.cs
index 8b00d0f7f2..3949e84f4a 100644
--- a/osu.Game/Beatmaps/DifficultyRecommender.cs
+++ b/osu.Game/Beatmaps/DifficultyRecommender.cs
@@ -25,7 +25,7 @@ namespace osu.Game.Beatmaps
private IAPIProvider api { get; set; }
[Resolved]
- private RulesetStore rulesets { get; set; }
+ private IRulesetStore rulesets { get; set; }
[Resolved]
private Bindable ruleset { get; set; }
@@ -35,7 +35,7 @@ namespace osu.Game.Beatmaps
///
private int? requestedUserId;
- private readonly Dictionary recommendedDifficultyMapping = new Dictionary();
+ private readonly Dictionary recommendedDifficultyMapping = new Dictionary();
private readonly IBindable apiState = new Bindable();
@@ -101,7 +101,7 @@ namespace osu.Game.Beatmaps
/// Rulesets ordered descending by their respective recommended difficulties.
/// The currently selected ruleset will always be first.
///
- private IEnumerable orderedRulesets
+ private IEnumerable orderedRulesets
{
get
{
diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs
index 6e573cc2a0..82be0559a7 100644
--- a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs
+++ b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs
@@ -86,7 +86,7 @@ namespace osu.Game.Beatmaps.Drawables
}
[Resolved]
- private RulesetStore rulesets { get; set; }
+ private IRulesetStore rulesets { get; set; }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
diff --git a/osu.Game/Models/RealmRuleset.cs b/osu.Game/Models/RealmRuleset.cs
index 9a7488fda2..b959d0b4dc 100644
--- a/osu.Game/Models/RealmRuleset.cs
+++ b/osu.Game/Models/RealmRuleset.cs
@@ -50,6 +50,8 @@ namespace osu.Game.Models
public bool Equals(RealmRuleset? other) => other != null && OnlineID == other.OnlineID && Available == other.Available && Name == other.Name && InstantiationInfo == other.InstantiationInfo;
+ public bool Equals(IRulesetInfo? other) => other is RealmRuleset b && Equals(b);
+
public override string ToString() => Name;
public RealmRuleset Clone() => new RealmRuleset
diff --git a/osu.Game/Online/API/Requests/GetUserRequest.cs b/osu.Game/Online/API/Requests/GetUserRequest.cs
index e32451fc2f..28da5222f9 100644
--- a/osu.Game/Online/API/Requests/GetUserRequest.cs
+++ b/osu.Game/Online/API/Requests/GetUserRequest.cs
@@ -9,7 +9,7 @@ namespace osu.Game.Online.API.Requests
public class GetUserRequest : APIRequest
{
public readonly string Lookup;
- public readonly RulesetInfo Ruleset;
+ public readonly IRulesetInfo Ruleset;
private readonly LookupType lookupType;
///
@@ -24,7 +24,7 @@ namespace osu.Game.Online.API.Requests
///
/// The user to get.
/// The ruleset to get the user's info for.
- public GetUserRequest(long? userId = null, RulesetInfo ruleset = null)
+ public GetUserRequest(long? userId = null, IRulesetInfo ruleset = null)
{
Lookup = userId.ToString();
lookupType = LookupType.Id;
@@ -36,7 +36,7 @@ namespace osu.Game.Online.API.Requests
///
/// The user to get.
/// The ruleset to get the user's info for.
- public GetUserRequest(string username = null, RulesetInfo ruleset = null)
+ public GetUserRequest(string username = null, IRulesetInfo ruleset = null)
{
Lookup = username;
lookupType = LookupType.Username;
diff --git a/osu.Game/Online/Multiplayer/MultiplayerClient.cs b/osu.Game/Online/Multiplayer/MultiplayerClient.cs
index 555558eb6d..3ddd6ce62b 100644
--- a/osu.Game/Online/Multiplayer/MultiplayerClient.cs
+++ b/osu.Game/Online/Multiplayer/MultiplayerClient.cs
@@ -118,7 +118,7 @@ namespace osu.Game.Online.Multiplayer
protected IAPIProvider API { get; private set; } = null!;
[Resolved]
- protected RulesetStore Rulesets { get; private set; } = null!;
+ protected IRulesetStore Rulesets { get; private set; } = null!;
[Resolved]
private UserLookupCache userLookupCache { get; set; } = null!;
@@ -733,6 +733,9 @@ namespace osu.Game.Online.Multiplayer
var apiBeatmap = await GetAPIBeatmap(item.BeatmapID).ConfigureAwait(false);
var ruleset = Rulesets.GetRuleset(item.RulesetID);
+
+ Debug.Assert(ruleset != null);
+
var rulesetInstance = ruleset.CreateInstance();
var playlistItem = new PlaylistItem
diff --git a/osu.Game/Online/Rooms/PlaylistItem.cs b/osu.Game/Online/Rooms/PlaylistItem.cs
index 4d67864048..b8700fd067 100644
--- a/osu.Game/Online/Rooms/PlaylistItem.cs
+++ b/osu.Game/Online/Rooms/PlaylistItem.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 Newtonsoft.Json;
using osu.Framework.Bindables;
@@ -85,11 +86,13 @@ namespace osu.Game.Online.Rooms
public void MarkInvalid() => valid.Value = false;
- public void MapObjects(RulesetStore rulesets)
+ public void MapObjects(IRulesetStore rulesets)
{
Beatmap.Value ??= apiBeatmap;
Ruleset.Value ??= rulesets.GetRuleset(RulesetID);
+ Debug.Assert(Ruleset.Value != null);
+
Ruleset rulesetInstance = Ruleset.Value.CreateInstance();
if (allowedModsBacking != null)
diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs
index 34344f8022..e852e3955b 100644
--- a/osu.Game/OsuGameBase.cs
+++ b/osu.Game/OsuGameBase.cs
@@ -196,6 +196,7 @@ namespace osu.Game
runMigrations();
dependencies.Cache(RulesetStore = new RulesetStore(contextFactory, Storage));
+ dependencies.CacheAs(RulesetStore);
dependencies.Cache(realmFactory = new RealmContextFactory(Storage, "client", contextFactory));
diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
index a9723c9c62..25aed4c980 100644
--- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
+++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
@@ -47,7 +47,7 @@ namespace osu.Game.Overlays.BeatmapSet
}
[Resolved]
- private RulesetStore rulesets { get; set; }
+ private IRulesetStore rulesets { get; set; }
private void onRulesetChanged(ValueChangedEvent ruleset)
{
@@ -57,8 +57,13 @@ namespace osu.Game.Overlays.BeatmapSet
if (ruleset.NewValue == null)
return;
+ var rulesetInstance = rulesets.GetRuleset(ruleset.NewValue.OnlineID)?.CreateInstance();
+
+ if (rulesetInstance == null)
+ return;
+
modsContainer.Add(new ModButton(new ModNoMod()));
- modsContainer.AddRange(rulesets.GetRuleset(ruleset.NewValue.OnlineID).CreateInstance().AllMods.Where(m => m.UserPlayable).Select(m => new ModButton(m)));
+ modsContainer.AddRange(rulesetInstance.AllMods.Where(m => m.UserPlayable).Select(m => new ModButton(m)));
modsContainer.ForEach(button =>
{
diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedProfileSubsection.cs b/osu.Game/Overlays/Profile/Sections/PaginatedProfileSubsection.cs
index affe9ecb0c..130ae44273 100644
--- a/osu.Game/Overlays/Profile/Sections/PaginatedProfileSubsection.cs
+++ b/osu.Game/Overlays/Profile/Sections/PaginatedProfileSubsection.cs
@@ -1,21 +1,20 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using osuTK;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
-using osu.Game.Online.API;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using osu.Game.Graphics.UserInterface;
-using osu.Game.Rulesets;
-using osu.Game.Graphics.Sprites;
-using osu.Game.Graphics;
using osu.Framework.Localisation;
+using osu.Game.Graphics;
+using osu.Game.Graphics.Sprites;
+using osu.Game.Graphics.UserInterface;
+using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
+using osuTK;
namespace osu.Game.Overlays.Profile.Sections
{
@@ -24,9 +23,6 @@ namespace osu.Game.Overlays.Profile.Sections
[Resolved]
private IAPIProvider api { get; set; }
- [Resolved]
- protected RulesetStore Rulesets { get; private set; }
-
protected int VisiblePages;
protected int ItemsPerPage;
diff --git a/osu.Game/Overlays/Profile/Sections/Recent/DrawableRecentActivity.cs b/osu.Game/Overlays/Profile/Sections/Recent/DrawableRecentActivity.cs
index cb8dae0bbc..7a27c6e4e1 100644
--- a/osu.Game/Overlays/Profile/Sections/Recent/DrawableRecentActivity.cs
+++ b/osu.Game/Overlays/Profile/Sections/Recent/DrawableRecentActivity.cs
@@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
private IAPIProvider api { get; set; }
[Resolved]
- private RulesetStore rulesets { get; set; }
+ private IRulesetStore rulesets { get; set; }
private readonly APIRecentActivity activity;
diff --git a/osu.Game/Overlays/Rankings/SpotlightsLayout.cs b/osu.Game/Overlays/Rankings/SpotlightsLayout.cs
index dbfcfea414..a37f762532 100644
--- a/osu.Game/Overlays/Rankings/SpotlightsLayout.cs
+++ b/osu.Game/Overlays/Rankings/SpotlightsLayout.cs
@@ -1,21 +1,21 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using osu.Framework.Graphics;
-using osu.Framework.Bindables;
-using osu.Game.Rulesets;
-using osu.Framework.Graphics.Containers;
-using osu.Game.Online.API.Requests.Responses;
-using osuTK;
-using osu.Framework.Allocation;
-using osu.Game.Online.API;
-using osu.Game.Online.API.Requests;
-using osu.Game.Overlays.Rankings.Tables;
using System.Linq;
using System.Threading;
+using osu.Framework.Allocation;
+using osu.Framework.Bindables;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps.Drawables.Cards;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
+using osu.Game.Online.API;
+using osu.Game.Online.API.Requests;
+using osu.Game.Online.API.Requests.Responses;
+using osu.Game.Overlays.Rankings.Tables;
+using osu.Game.Rulesets;
+using osuTK;
namespace osu.Game.Overlays.Rankings
{
diff --git a/osu.Game/Rulesets/IRulesetInfo.cs b/osu.Game/Rulesets/IRulesetInfo.cs
index 4e529a73fb..6599e0d59d 100644
--- a/osu.Game/Rulesets/IRulesetInfo.cs
+++ b/osu.Game/Rulesets/IRulesetInfo.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 osu.Game.Database;
#nullable enable
@@ -10,7 +11,7 @@ namespace osu.Game.Rulesets
///
/// A representation of a ruleset's metadata.
///
- public interface IRulesetInfo : IHasOnlineID
+ public interface IRulesetInfo : IHasOnlineID, IEquatable
{
///
/// The user-exposed name of this ruleset.
diff --git a/osu.Game/Rulesets/IRulesetStore.cs b/osu.Game/Rulesets/IRulesetStore.cs
new file mode 100644
index 0000000000..08d907810b
--- /dev/null
+++ b/osu.Game/Rulesets/IRulesetStore.cs
@@ -0,0 +1,31 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Collections.Generic;
+
+#nullable enable
+
+namespace osu.Game.Rulesets
+{
+ public interface IRulesetStore
+ {
+ ///
+ /// Retrieve a ruleset using a known ID.
+ ///
+ /// The ruleset's internal ID.
+ /// A ruleset, if available, else null.
+ IRulesetInfo? GetRuleset(int id);
+
+ ///
+ /// Retrieve a ruleset using a known short name.
+ ///
+ /// The ruleset's short name.
+ /// A ruleset, if available, else null.
+ IRulesetInfo? GetRuleset(string shortName);
+
+ ///
+ /// All available rulesets.
+ ///
+ IEnumerable AvailableRulesets { get; }
+ }
+}
diff --git a/osu.Game/Rulesets/RulesetInfo.cs b/osu.Game/Rulesets/RulesetInfo.cs
index 4a146c05bf..d018cc4194 100644
--- a/osu.Game/Rulesets/RulesetInfo.cs
+++ b/osu.Game/Rulesets/RulesetInfo.cs
@@ -49,6 +49,8 @@ namespace osu.Game.Rulesets
public override bool Equals(object obj) => obj is RulesetInfo rulesetInfo && Equals(rulesetInfo);
+ public bool Equals(IRulesetInfo other) => other is RulesetInfo b && Equals(b);
+
[SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")]
public override int GetHashCode()
{
diff --git a/osu.Game/Rulesets/RulesetStore.cs b/osu.Game/Rulesets/RulesetStore.cs
index 6dd036c0e6..5cc6a75f43 100644
--- a/osu.Game/Rulesets/RulesetStore.cs
+++ b/osu.Game/Rulesets/RulesetStore.cs
@@ -13,7 +13,7 @@ using osu.Game.Database;
namespace osu.Game.Rulesets
{
- public class RulesetStore : DatabaseBackedStore, IDisposable
+ public class RulesetStore : DatabaseBackedStore, IRulesetStore, IDisposable
{
private const string ruleset_library_prefix = "osu.Game.Rulesets";
@@ -236,5 +236,13 @@ namespace osu.Game.Rulesets
{
AppDomain.CurrentDomain.AssemblyResolve -= resolveRulesetDependencyAssembly;
}
+
+ #region Implementation of IRulesetStore
+
+ IRulesetInfo IRulesetStore.GetRuleset(int id) => GetRuleset(id);
+ IRulesetInfo IRulesetStore.GetRuleset(string shortName) => GetRuleset(shortName);
+ IEnumerable IRulesetStore.AvailableRulesets => AvailableRulesets;
+
+ #endregion
}
}
diff --git a/osu.Game/Screens/OnlinePlay/Components/RoomManager.cs b/osu.Game/Screens/OnlinePlay/Components/RoomManager.cs
index 47055c9c36..02565c6ebe 100644
--- a/osu.Game/Screens/OnlinePlay/Components/RoomManager.cs
+++ b/osu.Game/Screens/OnlinePlay/Components/RoomManager.cs
@@ -27,7 +27,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
private readonly Bindable joinedRoom = new Bindable();
[Resolved]
- private RulesetStore rulesets { get; set; }
+ private IRulesetStore rulesets { get; set; }
[Resolved]
private IAPIProvider api { get; set; }
diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantPanel.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantPanel.cs
index 3152f50d3d..8fbaebadfe 100644
--- a/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantPanel.cs
+++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantPanel.cs
@@ -35,7 +35,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
private IAPIProvider api { get; set; }
[Resolved]
- private RulesetStore rulesets { get; set; }
+ private IRulesetStore rulesets { get; set; }
private SpriteIcon crown;
@@ -185,9 +185,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
const double fade_time = 50;
// Todo: Should use the room's selected item to determine ruleset.
- var ruleset = rulesets.GetRuleset(0).CreateInstance();
+ var ruleset = rulesets.GetRuleset(0)?.CreateInstance();
- int? currentModeRank = User.User?.RulesetsStatistics?.GetValueOrDefault(ruleset.ShortName)?.GlobalRank;
+ int? currentModeRank = ruleset != null ? User.User?.RulesetsStatistics?.GetValueOrDefault(ruleset.ShortName)?.GlobalRank : null;
userRankText.Text = currentModeRank != null ? $"#{currentModeRank.Value:N0}" : string.Empty;
userStateDisplay.UpdateStatus(User.State, User.BeatmapAvailability);
diff --git a/osu.Game/Screens/Play/SoloSpectator.cs b/osu.Game/Screens/Play/SoloSpectator.cs
index b48c787752..7fea44b3ea 100644
--- a/osu.Game/Screens/Play/SoloSpectator.cs
+++ b/osu.Game/Screens/Play/SoloSpectator.cs
@@ -27,7 +27,6 @@ using osu.Game.Screens.OnlinePlay.Match.Components;
using osu.Game.Screens.Spectate;
using osu.Game.Users;
using osuTK;
-using APIUser = osu.Game.Online.API.Requests.Responses.APIUser;
namespace osu.Game.Screens.Play
{
diff --git a/osu.Game/Stores/RealmRulesetStore.cs b/osu.Game/Stores/RealmRulesetStore.cs
index 0119aec9a4..93b6d29e7d 100644
--- a/osu.Game/Stores/RealmRulesetStore.cs
+++ b/osu.Game/Stores/RealmRulesetStore.cs
@@ -18,7 +18,7 @@ using osu.Game.Rulesets;
namespace osu.Game.Stores
{
- public class RealmRulesetStore : IDisposable
+ public class RealmRulesetStore : IRulesetStore, IDisposable
{
private readonly RealmContextFactory realmFactory;
@@ -29,9 +29,9 @@ namespace osu.Game.Stores
///
/// All available rulesets.
///
- public IEnumerable AvailableRulesets => availableRulesets;
+ public IEnumerable AvailableRulesets => availableRulesets;
- private readonly List availableRulesets = new List();
+ private readonly List availableRulesets = new List();
public RealmRulesetStore(RealmContextFactory realmFactory, Storage? storage = null)
{
@@ -64,14 +64,14 @@ namespace osu.Game.Stores
///
/// The ruleset's internal ID.
/// A ruleset, if available, else null.
- public IRulesetInfo? GetRuleset(int id) => AvailableRulesets.FirstOrDefault(r => r.OnlineID == id);
+ public RealmRuleset? GetRuleset(int id) => AvailableRulesets.FirstOrDefault(r => r.OnlineID == id);
///
/// Retrieve a ruleset using a known short name.
///
/// The ruleset's short name.
/// A ruleset, if available, else null.
- public IRulesetInfo? GetRuleset(string shortName) => AvailableRulesets.FirstOrDefault(r => r.ShortName == shortName);
+ public RealmRuleset? GetRuleset(string shortName) => AvailableRulesets.FirstOrDefault(r => r.ShortName == shortName);
private Assembly? resolveRulesetDependencyAssembly(object? sender, ResolveEventArgs args)
{
@@ -258,5 +258,13 @@ namespace osu.Game.Stores
{
AppDomain.CurrentDomain.AssemblyResolve -= resolveRulesetDependencyAssembly;
}
+
+ #region Implementation of IRulesetStore
+
+ IRulesetInfo? IRulesetStore.GetRuleset(int id) => GetRuleset(id);
+ IRulesetInfo? IRulesetStore.GetRuleset(string shortName) => GetRuleset(shortName);
+ IEnumerable IRulesetStore.AvailableRulesets => AvailableRulesets;
+
+ #endregion
}
}
diff --git a/osu.Game/Users/UserActivity.cs b/osu.Game/Users/UserActivity.cs
index 0874685f49..516aa80652 100644
--- a/osu.Game/Users/UserActivity.cs
+++ b/osu.Game/Users/UserActivity.cs
@@ -29,9 +29,9 @@ namespace osu.Game.Users
{
public IBeatmapInfo BeatmapInfo { get; }
- public RulesetInfo Ruleset { get; }
+ public IRulesetInfo Ruleset { get; }
- protected InGame(IBeatmapInfo beatmapInfo, RulesetInfo ruleset)
+ protected InGame(IBeatmapInfo beatmapInfo, IRulesetInfo ruleset)
{
BeatmapInfo = beatmapInfo;
Ruleset = ruleset;
@@ -42,7 +42,7 @@ namespace osu.Game.Users
public class InMultiplayerGame : InGame
{
- public InMultiplayerGame(IBeatmapInfo beatmapInfo, RulesetInfo ruleset)
+ public InMultiplayerGame(IBeatmapInfo beatmapInfo, IRulesetInfo ruleset)
: base(beatmapInfo, ruleset)
{
}
@@ -52,7 +52,7 @@ namespace osu.Game.Users
public class InPlaylistGame : InGame
{
- public InPlaylistGame(IBeatmapInfo beatmapInfo, RulesetInfo ruleset)
+ public InPlaylistGame(IBeatmapInfo beatmapInfo, IRulesetInfo ruleset)
: base(beatmapInfo, ruleset)
{
}
@@ -60,7 +60,7 @@ namespace osu.Game.Users
public class InSoloGame : InGame
{
- public InSoloGame(IBeatmapInfo beatmapInfo, RulesetInfo ruleset)
+ public InSoloGame(IBeatmapInfo beatmapInfo, IRulesetInfo ruleset)
: base(beatmapInfo, ruleset)
{
}