From f168ee660cef36f8932b9378048a2e36b8ba8540 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 18 Jul 2017 18:43:28 +0900 Subject: [PATCH] Move dummy to BeatmapDatabase --- osu.Game/Database/BeatmapDatabase.cs | 8 ++++++++ osu.Game/OsuGame.cs | 3 +++ osu.Game/Screens/OsuScreen.cs | 8 ++++---- osu.Game/Screens/Select/BeatmapCarousel.cs | 2 ++ osu.Game/Screens/Select/SongSelect.cs | 5 ----- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index efd5631077..51fa4412bf 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -28,6 +28,11 @@ namespace osu.Game.Database // ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised) private BeatmapIPCChannel ipc; + /// + /// A default representation of a WorkingBeatmap to use when no beatmap is available. + /// + public WorkingBeatmap DefaultBeatmap { get; set; } + public BeatmapDatabase(Storage storage, SQLiteConnection connection, RulesetDatabase rulesets, IIpcHost importHost = null) : base(storage, connection) { this.rulesets = rulesets; @@ -268,6 +273,9 @@ namespace osu.Game.Database public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null, bool withStoryboard = false) { + if (beatmapInfo == DefaultBeatmap?.BeatmapInfo) + return DefaultBeatmap; + if (beatmapInfo.BeatmapSet == null || beatmapInfo.Ruleset == null) beatmapInfo = GetChildren(beatmapInfo, true); diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 6bec2cb184..f63b2eb37a 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -21,6 +21,7 @@ using OpenTK; using System.Linq; using System.Threading.Tasks; using osu.Framework.Threading; +using osu.Game.Beatmaps; using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Rulesets.Scoring; @@ -99,6 +100,8 @@ namespace osu.Game Dependencies.Cache(this); + BeatmapDatabase.DefaultBeatmap = new DummyWorkingBeatmap(this); + configRuleset = LocalConfig.GetBindable(OsuSetting.Ruleset); Ruleset.Value = RulesetDatabase.GetRuleset(configRuleset.Value); Ruleset.ValueChanged += r => configRuleset.Value = r.ID ?? 0; diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 42e9baf318..460afb46d1 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -41,7 +41,7 @@ namespace osu.Game.Screens private SampleChannel sampleExit; - private DummyWorkingBeatmap dummyBeatmap; + private WorkingBeatmap defaultBeatmap; public WorkingBeatmap Beatmap { @@ -51,14 +51,14 @@ namespace osu.Game.Screens } set { - beatmap.Value = value ?? dummyBeatmap; + beatmap.Value = value ?? defaultBeatmap; } } [BackgroundDependencyLoader(permitNulls: true)] - private void load(OsuGameBase game, OsuGame osuGame, AudioManager audio) + private void load(OsuGameBase game, OsuGame osuGame, AudioManager audio, BeatmapDatabase beatmaps) { - dummyBeatmap = new DummyWorkingBeatmap(osuGame); + defaultBeatmap = beatmaps.DefaultBeatmap; if (game != null) { diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 647cac5bbe..2e8bb94752 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -137,6 +137,7 @@ namespace osu.Game.Screens.Select { selectedGroup = null; selectedPanel = null; + SelectionChanged?.Invoke(database.DefaultBeatmap.BeatmapInfo); return; } @@ -284,6 +285,7 @@ namespace osu.Game.Screens.Select private void load(BeatmapDatabase database, OsuConfigManager config) { this.database = database; + randomType = config.GetBindable(OsuSetting.SelectionRandomType); } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 481a99869d..bbdb195b77 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -230,11 +230,6 @@ namespace osu.Game.Screens.Select protected override void OnEntering(Screen last) { - // this catches the case we're playing the theme song, and falls back to a more sane default. - // actual selection is done by the carousel when possible. - if (Beatmap.BeatmapSetInfo.DeletePending) - Beatmap = null; - base.OnEntering(last); ensurePlayingSelected();