1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-24 11:07:20 +08:00

Move StoryboardReplacesBackground and StoryboardAspect properties to Storyboard.

This commit is contained in:
Damnae 2017-09-25 10:40:22 +02:00
parent 2c245f4c22
commit 0996867112
5 changed files with 21 additions and 19 deletions

View File

@ -46,21 +46,6 @@ namespace osu.Game.Beatmaps
/// </summary>
public Storyboard Storyboard = new Storyboard();
/// <summary>
/// Whether this beatmap's background should be hidden while its storyboard is being displayed.
/// </summary>
public bool StoryboardReplacesBackground
{
get
{
var backgroundPath = BeatmapInfo.BeatmapSet?.Metadata?.BackgroundFile?.ToLowerInvariant();
if (backgroundPath == null)
return false;
return Storyboard.GetLayer("Background").Elements.Any(e => e.Path.ToLowerInvariant() == backgroundPath);
}
}
/// <summary>
/// Constructs a new beatmap.
/// </summary>

View File

@ -75,7 +75,6 @@ namespace osu.Game.Beatmaps
public bool LetterboxInBreaks { get; set; }
public bool WidescreenStoryboard { get; set; }
public float StoryboardAspect => WidescreenStoryboard ? 16 / 9f : 4 / 3f;
// Editor
// This bookmarks stuff is necessary because DB doesn't know how to store int[]

View File

@ -232,10 +232,10 @@ namespace osu.Game.Screens.Play
var beatmap = Beatmap.Value.Beatmap;
storyboard = beatmap.Storyboard.CreateDrawable();
storyboard.Width = storyboard.Height * beatmap.BeatmapInfo.StoryboardAspect;
storyboard.Width = storyboard.Height * beatmap.Storyboard.AspectRatio(beatmap.BeatmapInfo);
storyboard.Masking = true;
if (!beatmap.StoryboardReplacesBackground)
if (!beatmap.Storyboard.ReplacesBackground(beatmap.BeatmapInfo))
storyboard.BackgroundTexture = Beatmap.Value.Background;
storyboardContainer.Add(asyncLoad ? new AsyncLoadWrapper(storyboard) { RelativeSizeAxes = Axes.Both } : (Drawable)storyboard);
}

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Beatmaps;
using osu.Game.Storyboards.Drawables;
using System.Collections.Generic;
using System.Linq;
@ -31,6 +32,21 @@ namespace osu.Game.Storyboards
return layer;
}
/// <summary>
/// Whether the beatmap's background should be hidden while this storyboard is being displayed.
/// </summary>
public bool ReplacesBackground(BeatmapInfo beatmapInfo)
{
var backgroundPath = beatmapInfo.BeatmapSet?.Metadata?.BackgroundFile?.ToLowerInvariant();
if (backgroundPath == null)
return false;
return GetLayer("Background").Elements.Any(e => e.Path.ToLowerInvariant() == backgroundPath);
}
public float AspectRatio(BeatmapInfo beatmapInfo)
=> beatmapInfo.WidescreenStoryboard ? 16 / 9f : 4 / 3f;
public DrawableStoryboard CreateDrawable()
=> new DrawableStoryboard(this);
}

View File

@ -83,7 +83,9 @@ namespace osu.Game.Tests.Visual
storyboard = working.Beatmap.Storyboard.CreateDrawable();
storyboard.Passing = false;
if (!working.Beatmap.StoryboardReplacesBackground)
var beatmap = working.Beatmap;
if (!beatmap.Storyboard.ReplacesBackground(beatmap.BeatmapInfo))
storyboard.BackgroundTexture = working.Background;
storyboardContainer.Add(storyboard);