mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 01:02:55 +08:00
Move dummy to BeatmapDatabase
This commit is contained in:
parent
3289d93f22
commit
f168ee660c
@ -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;
|
||||
|
||||
/// <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)
|
||||
{
|
||||
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);
|
||||
|
||||
|
@ -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<int>(OsuSetting.Ruleset);
|
||||
Ruleset.Value = RulesetDatabase.GetRuleset(configRuleset.Value);
|
||||
Ruleset.ValueChanged += r => configRuleset.Value = r.ID ?? 0;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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<SelectionRandomType>(OsuSetting.SelectionRandomType);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user