readd storyboard to beatmap + minor cleanup

This commit is contained in:
Aergwyn 2017-11-30 16:49:53 +01:00
parent 96f5bd3323
commit 016057ab01
3 changed files with 13 additions and 14 deletions

View File

@ -41,6 +41,11 @@ public class Beatmap<T>
/// </summary>
public double TotalBreakTime => Breaks.Sum(b => b.Duration);
/// <summary>
/// The Beatmap's Storyboard.
/// </summary>
public Storyboard Storyboard = new Storyboard();
/// <summary>
/// Constructs a new beatmap.
/// </summary>
@ -52,6 +57,7 @@ public Beatmap(Beatmap<T> original = null)
Breaks = original?.Breaks ?? Breaks;
ComboColors = original?.ComboColors ?? ComboColors;
HitObjects = original?.HitObjects ?? HitObjects;
Storyboard = original?.Storyboard ?? Storyboard;
if (original == null && Metadata == null)
{

View File

@ -569,16 +569,11 @@ protected override Beatmap GetBeatmap()
{
try
{
Beatmap beatmap;
BeatmapDecoder decoder;
using (var stream = new StreamReader(store.GetStream(getPathForFile(BeatmapInfo.Path))))
{
decoder = BeatmapDecoder.GetDecoder(stream);
beatmap = decoder.Decode(stream);
BeatmapDecoder decoder = BeatmapDecoder.GetDecoder(stream);
return decoder.Decode(stream);
}
return beatmap;
}
catch
{
@ -622,9 +617,7 @@ protected override Storyboard GetStoryboard()
{
try
{
Beatmap beatmap = Beatmap;
if (beatmap == null || BeatmapSetInfo.StoryboardFile == null)
if (Beatmap == null || BeatmapSetInfo.StoryboardFile == null)
return new Storyboard();
BeatmapDecoder decoder;
@ -632,9 +625,9 @@ protected override Storyboard GetStoryboard()
decoder = BeatmapDecoder.GetDecoder(stream);
using (var stream = new StreamReader(store.GetStream(getPathForFile(BeatmapSetInfo.StoryboardFile))))
decoder.Decode(stream, beatmap);
decoder.Decode(stream, Beatmap);
return beatmap.Storyboard;
return Beatmap.Storyboard;
}
catch
{

View File

@ -245,7 +245,7 @@ private void applyRateFromMods()
private void initializeStoryboard(bool asyncLoad)
{
var beatmap = Beatmap.Value.Beatmap;
var beatmap = Beatmap.Value;
storyboard = beatmap.Storyboard.CreateDrawable(Beatmap.Value);
storyboard.Masking = true;
@ -388,7 +388,7 @@ private void updateBackgroundElements()
initializeStoryboard(true);
var beatmap = Beatmap.Value;
var storyboardVisible = showStoryboard && beatmap.Beatmap.Storyboard.HasDrawable;
var storyboardVisible = showStoryboard && beatmap.Storyboard.HasDrawable;
storyboardContainer.FadeColour(new Color4(opacity, opacity, opacity, 1), 800);
storyboardContainer.FadeTo(storyboardVisible && opacity > 0 ? 1 : 0);