From 3858c778170b3fa24ac557d6962db3d99c8cd26c Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 28 Oct 2016 20:47:14 +0800 Subject: [PATCH] No longer holds OsuGame reference. --- osu.Game/Overlays/MusicController.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 97208a653a..e9ee3d2918 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework; @@ -15,7 +14,6 @@ using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Transformations; using osu.Game.Beatmaps; -using osu.Game.Beatmaps.IO; using osu.Game.Database; using osu.Game.Graphics; @@ -28,7 +26,6 @@ public class MusicController : OverlayContainer private TextAwesome playButton, listButton; private SpriteText title, artist; - private OsuGameBase osuGame; private TrackManager trackManager; private List playList; private BeatmapDatabase database; @@ -43,13 +40,17 @@ public MusicController(BeatmapDatabase db = null) public override void Load(BaseGame game) { base.Load(game); - osuGame = game as OsuGameBase; + var osuGame = game as OsuGameBase; - beatmapSource = osuGame.Beatmap ?? new Bindable(); + if (osuGame != null) + { + if (database == null) database = osuGame.Beatmaps; + trackManager = osuGame.Audio.Track; + } + + beatmapSource = osuGame?.Beatmap ?? new Bindable(); beatmapSource.ValueChanged += workingChanged; workingChanged(); - if (database == null) database = osuGame.Beatmaps; - trackManager = osuGame.Audio.Track; playList = database.GetAllWithChildren(); Width = 400;