mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 16:43:52 +09:00
Add stable sorting of storyboard elements
This commit is contained in:
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -38,6 +39,10 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
{
|
{
|
||||||
this.storyboard = storyboard;
|
this.storyboard = storyboard;
|
||||||
base.ParseStreamInto(stream, storyboard);
|
base.ParseStreamInto(stream, storyboard);
|
||||||
|
|
||||||
|
// OrderBy is used to guarantee that the parsing order of hitobjects with equal start times is maintained (stably-sorted)
|
||||||
|
foreach (StoryboardLayer layer in storyboard.Layers)
|
||||||
|
layer.Elements = layer.Elements.OrderBy(h => h.StartTime).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ParseLine(Storyboard storyboard, Section section, string line)
|
protected override void ParseLine(Storyboard storyboard, Section section, string line)
|
||||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
public DrawableStoryboardSample(StoryboardSample sample)
|
public DrawableStoryboardSample(StoryboardSample sample)
|
||||||
{
|
{
|
||||||
this.sample = sample;
|
this.sample = sample;
|
||||||
LifetimeStart = sample.Time;
|
LifetimeStart = sample.StartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -43,27 +43,27 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
// TODO: this logic will need to be consolidated with other game samples like hit sounds.
|
// TODO: this logic will need to be consolidated with other game samples like hit sounds.
|
||||||
if (Time.Current < sample.Time)
|
if (Time.Current < sample.StartTime)
|
||||||
{
|
{
|
||||||
// We've rewound before the start time of the sample
|
// We've rewound before the start time of the sample
|
||||||
channel?.Stop();
|
channel?.Stop();
|
||||||
|
|
||||||
// In the case that the user fast-forwards to a point far beyond the start time of the sample,
|
// In the case that the user fast-forwards to a point far beyond the start time of the sample,
|
||||||
// we want to be able to fall into the if-conditional below (therefore we must not have a life time end)
|
// we want to be able to fall into the if-conditional below (therefore we must not have a life time end)
|
||||||
LifetimeStart = sample.Time;
|
LifetimeStart = sample.StartTime;
|
||||||
LifetimeEnd = double.MaxValue;
|
LifetimeEnd = double.MaxValue;
|
||||||
}
|
}
|
||||||
else if (Time.Current - Time.Elapsed < sample.Time)
|
else if (Time.Current - Time.Elapsed < sample.StartTime)
|
||||||
{
|
{
|
||||||
// We've passed the start time of the sample. We only play the sample if we're within an allowable range
|
// We've passed the start time of the sample. We only play the sample if we're within an allowable range
|
||||||
// from the sample's start, to reduce layering if we've been fast-forwarded far into the future
|
// from the sample's start, to reduce layering if we've been fast-forwarded far into the future
|
||||||
if (Time.Current - sample.Time < allowable_late_start)
|
if (Time.Current - sample.StartTime < allowable_late_start)
|
||||||
channel?.Play();
|
channel?.Play();
|
||||||
|
|
||||||
// In the case that the user rewinds to a point far behind the start time of the sample,
|
// In the case that the user rewinds to a point far behind the start time of the sample,
|
||||||
// we want to be able to fall into the if-conditional above (therefore we must not have a life time start)
|
// we want to be able to fall into the if-conditional above (therefore we must not have a life time start)
|
||||||
LifetimeStart = double.MinValue;
|
LifetimeStart = double.MinValue;
|
||||||
LifetimeEnd = sample.Time;
|
LifetimeEnd = sample.StartTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ namespace osu.Game.Storyboards
|
|||||||
string Path { get; }
|
string Path { get; }
|
||||||
bool IsDrawable { get; }
|
bool IsDrawable { get; }
|
||||||
|
|
||||||
|
double StartTime { get; }
|
||||||
|
|
||||||
Drawable CreateDrawable();
|
Drawable CreateDrawable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,7 @@ namespace osu.Game.Storyboards
|
|||||||
public bool EnabledWhenPassing = true;
|
public bool EnabledWhenPassing = true;
|
||||||
public bool EnabledWhenFailing = true;
|
public bool EnabledWhenFailing = true;
|
||||||
|
|
||||||
private readonly List<IStoryboardElement> elements = new List<IStoryboardElement>();
|
public List<IStoryboardElement> Elements = new List<IStoryboardElement>();
|
||||||
public IEnumerable<IStoryboardElement> Elements => elements;
|
|
||||||
|
|
||||||
public StoryboardLayer(string name, int depth)
|
public StoryboardLayer(string name, int depth)
|
||||||
{
|
{
|
||||||
@ -24,7 +23,7 @@ namespace osu.Game.Storyboards
|
|||||||
|
|
||||||
public void Add(IStoryboardElement element)
|
public void Add(IStoryboardElement element)
|
||||||
{
|
{
|
||||||
elements.Add(element);
|
Elements.Add(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DrawableStoryboardLayer CreateDrawable()
|
public DrawableStoryboardLayer CreateDrawable()
|
||||||
|
@ -11,13 +11,14 @@ namespace osu.Game.Storyboards
|
|||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
public bool IsDrawable => true;
|
public bool IsDrawable => true;
|
||||||
|
|
||||||
public double Time;
|
public double StartTime { get; }
|
||||||
|
|
||||||
public float Volume;
|
public float Volume;
|
||||||
|
|
||||||
public StoryboardSample(string path, double time, float volume)
|
public StoryboardSample(string path, double time, float volume)
|
||||||
{
|
{
|
||||||
Path = path;
|
Path = path;
|
||||||
Time = time;
|
StartTime = time;
|
||||||
Volume = volume;
|
Volume = volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user