Give storyboards a BeatmapInfo to reduce weird method calls

Also removes unnecessary background texture (the actual storyboard background spec wasn't implemented correctly anyway).
This commit is contained in:
Dean Herbert
2018-02-16 12:07:59 +09:00
parent e1f81488cd
commit 21b641b302
4 changed files with 26 additions and 39 deletions

View File

@ -14,6 +14,8 @@ namespace osu.Game.Storyboards
private readonly Dictionary<string, StoryboardLayer> layers = new Dictionary<string, StoryboardLayer>();
public IEnumerable<StoryboardLayer> Layers => layers.Values;
public BeatmapInfo BeatmapInfo = new BeatmapInfo();
public bool HasDrawable => Layers.Any(l => l.Elements.Any(e => e.IsDrawable));
public Storyboard()
@ -36,28 +38,22 @@ namespace osu.Game.Storyboards
/// <summary>
/// Whether the beatmap's background should be hidden while this storyboard is being displayed.
/// </summary>
public bool ReplacesBackground(BeatmapInfo beatmapInfo)
public bool ReplacesBackground
{
var backgroundPath = beatmapInfo.BeatmapSet?.Metadata?.BackgroundFile?.ToLowerInvariant();
if (backgroundPath == null)
return false;
get
{
var backgroundPath = BeatmapInfo.BeatmapSet?.Metadata?.BackgroundFile?.ToLowerInvariant();
if (backgroundPath == null)
return false;
return GetLayer("Background").Elements.Any(e => e.Path.ToLowerInvariant() == backgroundPath);
return GetLayer("Background").Elements.Any(e => e.Path.ToLowerInvariant() == backgroundPath);
}
}
public float AspectRatio(BeatmapInfo beatmapInfo)
=> beatmapInfo.WidescreenStoryboard ? 16 / 9f : 4 / 3f;
public DrawableStoryboard CreateDrawable(WorkingBeatmap working = null)
{
var drawable = new DrawableStoryboard(this);
if (working != null)
{
var beatmapInfo = working.Beatmap.BeatmapInfo;
drawable.Width = drawable.Height * AspectRatio(beatmapInfo);
if (!ReplacesBackground(beatmapInfo))
drawable.BackgroundTexture = working.Background;
}
drawable.Width = drawable.Height * (BeatmapInfo.WidescreenStoryboard ? 16 / 9f : 4 / 3f);
return drawable;
}