diff --git a/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs b/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs index cede0160bc..5fd8fcc9c3 100644 --- a/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs @@ -68,7 +68,7 @@ namespace osu.Game.Tests.Visual IDatabaseContextFactory factory = new SingletonContextFactory(new OsuDbContext()); dependencies.Cache(rulesets = new RulesetStore(factory)); - dependencies.Cache(manager = new BeatmapManager(storage, factory, rulesets, null) + dependencies.Cache(manager = new BeatmapManager(storage, factory, rulesets, null, null) { DefaultBeatmap = defaultBeatmap = game.Beatmap.Default }); diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 817a3388e2..1113e38d7a 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Linq.Expressions; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; +using osu.Framework.Audio; using osu.Framework.Extensions; using osu.Framework.Logging; using osu.Framework.Platform; @@ -55,6 +56,8 @@ namespace osu.Game.Beatmaps private readonly APIAccess api; + private readonly AudioManager audioManager; + private readonly List currentDownloads = new List(); /// @@ -62,7 +65,7 @@ namespace osu.Game.Beatmaps /// public Func GetStableStorage { private get; set; } - public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, APIAccess api, IIpcHost importHost = null) + public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, APIAccess api, AudioManager audioManager, IIpcHost importHost = null) : base(storage, contextFactory, new BeatmapStore(contextFactory), importHost) { beatmaps = (BeatmapStore)ModelStore; @@ -71,6 +74,7 @@ namespace osu.Game.Beatmaps this.rulesets = rulesets; this.api = api; + this.audioManager = audioManager; } protected override void Populate(BeatmapSetInfo model, ArchiveReader archive) @@ -217,7 +221,7 @@ namespace osu.Game.Beatmaps if (beatmapInfo.Metadata == null) beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata; - WorkingBeatmap working = new BeatmapManagerWorkingBeatmap(Files.Store, beatmapInfo); + WorkingBeatmap working = new BeatmapManagerWorkingBeatmap(Files.Store, beatmapInfo, audioManager); previous?.TransferTo(working); diff --git a/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs b/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs index d7d17c980c..58b51085a4 100644 --- a/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs @@ -4,6 +4,7 @@ using System; using System.IO; using System.Linq; +using osu.Framework.Audio; using osu.Framework.Audio.Track; using osu.Framework.Graphics.Textures; using osu.Framework.IO.Stores; @@ -20,11 +21,13 @@ namespace osu.Game.Beatmaps protected class BeatmapManagerWorkingBeatmap : WorkingBeatmap { private readonly IResourceStore store; + private readonly AudioManager audioManager; - public BeatmapManagerWorkingBeatmap(IResourceStore store, BeatmapInfo beatmapInfo) + public BeatmapManagerWorkingBeatmap(IResourceStore store, BeatmapInfo beatmapInfo, AudioManager audioManager) : base(beatmapInfo) { this.store = store; + this.audioManager = audioManager; } protected override Beatmap GetBeatmap() @@ -107,8 +110,7 @@ namespace osu.Game.Beatmaps Skin skin; try { - // todo: this needs an AudioManager - skin = new BeatmapSkin(BeatmapInfo, store); + skin = new BeatmapSkin(BeatmapInfo, store, audioManager); } catch (Exception e) { diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 45fd45b4b5..f5d7d15a47 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -113,7 +113,7 @@ namespace osu.Game dependencies.Cache(RulesetStore = new RulesetStore(contextFactory)); dependencies.Cache(FileStore = new FileStore(contextFactory, Host.Storage)); - dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, contextFactory, RulesetStore, api, Host)); + dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, contextFactory, RulesetStore, api, Audio, Host)); dependencies.Cache(ScoreStore = new ScoreStore(Host.Storage, contextFactory, Host, BeatmapManager, RulesetStore)); dependencies.Cache(KeyBindingStore = new KeyBindingStore(contextFactory, RulesetStore)); dependencies.Cache(SettingsStore = new SettingsStore(contextFactory)); diff --git a/osu.Game/Skinning/BeatmapSkin.cs b/osu.Game/Skinning/BeatmapSkin.cs index beab2a42d7..815aac2f64 100644 --- a/osu.Game/Skinning/BeatmapSkin.cs +++ b/osu.Game/Skinning/BeatmapSkin.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.IO; +using osu.Framework.Audio; using osu.Framework.Graphics.Textures; using osu.Framework.IO.Stores; using osu.Game.Beatmaps; @@ -10,13 +11,12 @@ namespace osu.Game.Skinning { public class BeatmapSkin : LegacySkin { - public BeatmapSkin(BeatmapInfo beatmap, IResourceStore storage) + public BeatmapSkin(BeatmapInfo beatmap, IResourceStore storage, AudioManager audioManager) : base(new SkinInfo { Name = beatmap.ToString(), Creator = beatmap.Metadata.Author.ToString() }) { storage = new LegacySkinResourceStore(beatmap.BeatmapSet, storage); - // todo: sample support - // samples = audioManager.GetSampleManager(storage); + Samples = audioManager.GetSampleManager(storage); Textures = new TextureStore(new RawTextureLoaderStore(storage)); diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index bae0d5c997..cfee2cfab2 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -18,13 +18,13 @@ namespace osu.Game.Skinning { protected TextureStore Textures; - private readonly SampleManager samples; + protected SampleManager Samples; public LegacySkin(SkinInfo skin, IResourceStore storage, AudioManager audioManager) : this(skin) { storage = new LegacySkinResourceStore(skin, storage); - samples = audioManager.GetSampleManager(storage); + Samples = audioManager.GetSampleManager(storage); Textures = new TextureStore(new RawTextureLoaderStore(storage)); Stream stream = storage.GetStream("skin.ini"); @@ -63,7 +63,7 @@ namespace osu.Game.Skinning return new Sprite { Texture = texture }; } - public override SampleChannel GetSample(string sampleName) => samples.Get(sampleName); + public override SampleChannel GetSample(string sampleName) => Samples.Get(sampleName); protected class LegacySkinResourceStore : IResourceStore where T : INamedFileInfo