mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Add second definition of EndTime
for storyboard elements to account for loops in lifetime
This commit is contained in:
parent
dce0c5fac8
commit
e330052852
@ -110,7 +110,9 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
|
||||
Assert.AreEqual(2000, background.Elements[0].StartTime);
|
||||
Assert.AreEqual(2000, (background.Elements[0] as StoryboardAnimation)?.EarliestTransformTime);
|
||||
Assert.AreEqual(12000, (background.Elements[0] as StoryboardAnimation)?.GetEndTime());
|
||||
|
||||
Assert.AreEqual(3000, (background.Elements[0] as StoryboardAnimation)?.GetEndTime());
|
||||
Assert.AreEqual(12000, (background.Elements[0] as StoryboardAnimation)?.EndTimeForDisplay);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -311,6 +311,7 @@ namespace osu.Game.Tests.Visual.Background
|
||||
public bool IsDrawable => true;
|
||||
public double StartTime => double.MinValue;
|
||||
public double EndTime => double.MaxValue;
|
||||
public double EndTimeForDisplay => double.MaxValue;
|
||||
|
||||
public Drawable CreateDrawable() => new DrawableTestStoryboardElement();
|
||||
}
|
||||
|
@ -12,9 +12,17 @@ namespace osu.Game.Storyboards
|
||||
{
|
||||
/// <summary>
|
||||
/// The time at which the <see cref="IStoryboardElement"/> ends.
|
||||
/// This is consumed to extend the length of a storyboard to ensure all visuals are played to completion.
|
||||
/// </summary>
|
||||
double EndTime { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The time this element displays until.
|
||||
/// This is used for lifetime purposes, and includes long playing animations which don't necessarily extend
|
||||
/// a storyboard's play time.
|
||||
/// </summary>
|
||||
double EndTimeForDisplay { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The duration of the StoryboardElement.
|
||||
/// </summary>
|
||||
|
@ -81,6 +81,19 @@ namespace osu.Game.Storyboards
|
||||
}
|
||||
}
|
||||
|
||||
public double EndTimeForDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
double latestEndTime = TimelineGroup.EndTime;
|
||||
|
||||
foreach (var l in loops)
|
||||
latestEndTime = Math.Max(latestEndTime, l.StartTime + l.CommandsDuration * l.TotalIterations);
|
||||
|
||||
return latestEndTime;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasCommands => TimelineGroup.HasCommands || loops.Any(l => l.HasCommands);
|
||||
|
||||
private delegate void DrawablePropertyInitializer<in T>(Drawable drawable, T value);
|
||||
|
Loading…
Reference in New Issue
Block a user