1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 14:02:55 +08:00

Move dummy to BeatmapDatabase

This commit is contained in:
Dean Herbert 2017-07-18 18:43:28 +09:00
parent 3289d93f22
commit f168ee660c
5 changed files with 17 additions and 9 deletions

View File

@ -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) // ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised)
private BeatmapIPCChannel ipc; private BeatmapIPCChannel ipc;
/// <summary>
/// A default representation of a WorkingBeatmap to use when no beatmap is available.
/// </summary>
public WorkingBeatmap DefaultBeatmap { get; set; }
public BeatmapDatabase(Storage storage, SQLiteConnection connection, RulesetDatabase rulesets, IIpcHost importHost = null) : base(storage, connection) public BeatmapDatabase(Storage storage, SQLiteConnection connection, RulesetDatabase rulesets, IIpcHost importHost = null) : base(storage, connection)
{ {
this.rulesets = rulesets; this.rulesets = rulesets;
@ -268,6 +273,9 @@ namespace osu.Game.Database
public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null, bool withStoryboard = false) public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null, bool withStoryboard = false)
{ {
if (beatmapInfo == DefaultBeatmap?.BeatmapInfo)
return DefaultBeatmap;
if (beatmapInfo.BeatmapSet == null || beatmapInfo.Ruleset == null) if (beatmapInfo.BeatmapSet == null || beatmapInfo.Ruleset == null)
beatmapInfo = GetChildren(beatmapInfo, true); beatmapInfo = GetChildren(beatmapInfo, true);

View File

@ -21,6 +21,7 @@ using OpenTK;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Game.Beatmaps;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
@ -99,6 +100,8 @@ namespace osu.Game
Dependencies.Cache(this); Dependencies.Cache(this);
BeatmapDatabase.DefaultBeatmap = new DummyWorkingBeatmap(this);
configRuleset = LocalConfig.GetBindable<int>(OsuSetting.Ruleset); configRuleset = LocalConfig.GetBindable<int>(OsuSetting.Ruleset);
Ruleset.Value = RulesetDatabase.GetRuleset(configRuleset.Value); Ruleset.Value = RulesetDatabase.GetRuleset(configRuleset.Value);
Ruleset.ValueChanged += r => configRuleset.Value = r.ID ?? 0; Ruleset.ValueChanged += r => configRuleset.Value = r.ID ?? 0;

View File

@ -41,7 +41,7 @@ namespace osu.Game.Screens
private SampleChannel sampleExit; private SampleChannel sampleExit;
private DummyWorkingBeatmap dummyBeatmap; private WorkingBeatmap defaultBeatmap;
public WorkingBeatmap Beatmap public WorkingBeatmap Beatmap
{ {
@ -51,14 +51,14 @@ namespace osu.Game.Screens
} }
set set
{ {
beatmap.Value = value ?? dummyBeatmap; beatmap.Value = value ?? defaultBeatmap;
} }
} }
[BackgroundDependencyLoader(permitNulls: true)] [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) if (game != null)
{ {

View File

@ -137,6 +137,7 @@ namespace osu.Game.Screens.Select
{ {
selectedGroup = null; selectedGroup = null;
selectedPanel = null; selectedPanel = null;
SelectionChanged?.Invoke(database.DefaultBeatmap.BeatmapInfo);
return; return;
} }
@ -284,6 +285,7 @@ namespace osu.Game.Screens.Select
private void load(BeatmapDatabase database, OsuConfigManager config) private void load(BeatmapDatabase database, OsuConfigManager config)
{ {
this.database = database; this.database = database;
randomType = config.GetBindable<SelectionRandomType>(OsuSetting.SelectionRandomType); randomType = config.GetBindable<SelectionRandomType>(OsuSetting.SelectionRandomType);
} }

View File

@ -230,11 +230,6 @@ namespace osu.Game.Screens.Select
protected override void OnEntering(Screen last) 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); base.OnEntering(last);
ensurePlayingSelected(); ensurePlayingSelected();