1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

Rename IStoryboardElementHasDuration, remove unnecessary step in tests, add Duration field

This commit is contained in:
Christine Chen 2021-04-18 00:45:24 -04:00
parent f45aed1259
commit 98460c8feb
4 changed files with 11 additions and 8 deletions

View File

@ -35,7 +35,6 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestStoryboardSkipOutro()
{
AddUntilStep("storyboard loaded", () => Player.Beatmap.Value.StoryboardLoaded);
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
AddStep("skip outro", () => InputManager.Key(osuTK.Input.Key.Space));
AddAssert("score shown", () => Player.IsScoreShown);
@ -44,7 +43,6 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestStoryboardNoSkipOutro()
{
AddUntilStep("storyboard loaded", () => Player.Beatmap.Value.StoryboardLoaded);
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.GameplayClock.CurrentTime >= storyboard_duration);
AddUntilStep("wait for score shown", () => Player.IsScoreShown);
}
@ -52,7 +50,6 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestStoryboardExitToSkipOutro()
{
AddUntilStep("storyboard loaded", () => Player.Beatmap.Value.StoryboardLoaded);
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
AddStep("exit via pause", () => Player.ExitViaPause());
AddAssert("score shown", () => Player.IsScoreShown);
@ -63,7 +60,6 @@ namespace osu.Game.Tests.Visual.Gameplay
public void TestStoryboardToggle(bool enabledAtBeginning)
{
AddStep($"{(enabledAtBeginning ? "enable" : "disable")} storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, enabledAtBeginning));
AddUntilStep("storyboard loaded", () => Player.Beatmap.Value.StoryboardLoaded);
AddStep("toggle storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, !enabledAtBeginning));
AddUntilStep("wait for score shown", () => Player.IsScoreShown);
}

View File

@ -21,10 +21,10 @@ namespace osu.Game.Storyboards
/// Returns the end time of this storyboard element.
/// </summary>
/// <remarks>
/// This returns the <see cref="IStoryboardElementHasDuration.EndTime"/> where available, falling back to <see cref="IStoryboardElement.StartTime"/> otherwise.
/// This returns the <see cref="IStoryboardElementWithDuration.EndTime"/> where available, falling back to <see cref="IStoryboardElement.StartTime"/> otherwise.
/// </remarks>
/// <param name="element">The storyboard element.</param>
/// <returns>The end time of this element.</returns>
public static double GetEndTime(this IStoryboardElement element) => (element as IStoryboardElementHasDuration)?.EndTime ?? element.StartTime;
public static double GetEndTime(this IStoryboardElement element) => (element as IStoryboardElementWithDuration)?.EndTime ?? element.StartTime;
}
}

View File

@ -6,11 +6,16 @@ namespace osu.Game.Storyboards
/// <summary>
/// A <see cref="IStoryboardElement"/> that ends at a different time than its start time.
/// </summary>
public interface IStoryboardElementHasDuration
public interface IStoryboardElementWithDuration : IStoryboardElement
{
/// <summary>
/// The time at which the <see cref="IStoryboardElement"/> ends.
/// </summary>
double EndTime { get; }
/// <summary>
/// The duration of the StoryboardElement.
/// </summary>
double Duration { get; }
}
}

View File

@ -11,7 +11,7 @@ using JetBrains.Annotations;
namespace osu.Game.Storyboards
{
public class StoryboardSprite : IStoryboardElement, IStoryboardElementHasDuration
public class StoryboardSprite : IStoryboardElementWithDuration
{
private readonly List<CommandLoop> loops = new List<CommandLoop>();
private readonly List<CommandTrigger> triggers = new List<CommandTrigger>();
@ -65,6 +65,8 @@ namespace osu.Game.Storyboards
}
}
public double Duration => EndTime - StartTime;
public bool HasCommands => TimelineGroup.HasCommands || loops.Any(l => l.HasCommands);
private delegate void DrawablePropertyInitializer<in T>(Drawable drawable, T value);