diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index bbd441d25a..8f604696b5 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -29,7 +29,7 @@ namespace osu.Game.Tests.Beatmaps.IO HeadlessGameHost host = new HeadlessGameHost(); var osu = loadOsu(host); - osu.Beatmaps.Import(osz_path); + osu.Dependencies.Get().Import(osz_path); ensureLoaded(osu); } @@ -60,7 +60,7 @@ namespace osu.Game.Tests.Beatmaps.IO Thread.Sleep(1); //reset beatmap database (sqlite and storage backing) - osu.Beatmaps.Reset(); + osu.Dependencies.Get().Reset(); return osu; } @@ -71,7 +71,8 @@ namespace osu.Game.Tests.Beatmaps.IO Action waitAction = () => { - while ((resultSets = osu.Beatmaps.Query().Where(s => s.BeatmapSetID == 241526)).Count() != 1) + while ((resultSets = osu.Dependencies.Get() + .Query().Where(s => s.BeatmapSetID == 241526)).Count() != 1) Thread.Sleep(1); }; @@ -87,7 +88,8 @@ namespace osu.Game.Tests.Beatmaps.IO //if we don't re-check here, the set will be inserted but the beatmaps won't be present yet. waitAction = () => { - while ((resultBeatmaps = osu.Beatmaps.Query().Where(s => s.BeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12) + while ((resultBeatmaps = osu.Dependencies.Get() + .Query().Where(s => s.BeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12) Thread.Sleep(1); }; @@ -95,7 +97,7 @@ namespace osu.Game.Tests.Beatmaps.IO @"Beatmaps did not import to the database"); //fetch children and check we can load from the post-storage path... - var set = osu.Beatmaps.GetChildren(resultSets.First()); + var set = osu.Dependencies.Get().GetChildren(resultSets.First()); Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count()); @@ -104,7 +106,7 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.IsTrue(set.Beatmaps.Count > 0); - var beatmap = osu.Beatmaps.GetBeatmap(set.Beatmaps.First(b => b.Mode == PlayMode.Osu)); + var beatmap = osu.Dependencies.Get().GetBeatmap(set.Beatmaps.First(b => b.Mode == PlayMode.Osu)); Assert.IsTrue(beatmap.HitObjects.Count > 0); } diff --git a/osu.Game/GameModes/Play/PlaySongSelect.cs b/osu.Game/GameModes/Play/PlaySongSelect.cs index a05e02ae3b..9a62d8f071 100644 --- a/osu.Game/GameModes/Play/PlaySongSelect.cs +++ b/osu.Game/GameModes/Play/PlaySongSelect.cs @@ -137,7 +137,7 @@ namespace osu.Game.GameModes.Play } if (database == null) - database = (game as OsuGameBase).Beatmaps; + database = game.Dependencies.Get(); database.BeatmapSetAdded += s => Schedule(() => addBeatmapSet(s)); diff --git a/osu.Game/GameModes/Play/Player.cs b/osu.Game/GameModes/Play/Player.cs index d48e252fa5..a76f29c49f 100644 --- a/osu.Game/GameModes/Play/Player.cs +++ b/osu.Game/GameModes/Play/Player.cs @@ -37,8 +37,9 @@ namespace osu.Game.GameModes.Play try { + var beatmaps = Game.Dependencies.Get(); if (Beatmap == null) - Beatmap = ((OsuGame)game).Beatmaps.GetWorkingBeatmap(BeatmapInfo); + Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo); } catch { diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 1323e65757..65179d5edb 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -19,6 +19,7 @@ using osu.Game.Input; using OpenTK.Input; using osu.Framework.Logging; using osu.Game.Graphics.UserInterface.Volume; +using osu.Game.Database; namespace osu.Game { @@ -61,7 +62,7 @@ namespace osu.Game base.Load(game); if (args?.Length > 0) - Schedule(delegate { Beatmaps.Import(args); }); + Schedule(delegate { Dependencies.Get().Import(args); }); //attach our bindables to the audio subsystem. Audio.Volume.Weld(Config.GetBindable(OsuConfig.VolumeUniversal)); diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 30a109c597..65f8974571 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -23,7 +23,6 @@ namespace osu.Game public class OsuGameBase : BaseGame { internal OsuConfigManager Config; - public BeatmapDatabase Beatmaps { get; private set; } protected override string MainResourceFile => @"osu.Game.Resources.dll"; @@ -57,8 +56,11 @@ namespace osu.Game { base.Load(game); + Dependencies.Cache(this); + Dependencies.Cache(); + Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host)); + OszArchiveReader.Register(); - Beatmaps = new BeatmapDatabase(Host.Storage, Host); //this completely overrides the framework default. will need to change once we make a proper FontStore. Fonts = new TextureStore() { ScaleAdjust = 0.01f };