mirror of
https://github.com/ppy/osu.git
synced 2025-03-14 05:07:26 +08:00
Merge pull request #9064 from bdach/storyboard-overlay-layer
Add support for storyboard overlay layer
This commit is contained in:
commit
d2350aba24
@ -26,7 +26,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
var storyboard = decoder.Decode(stream);
|
||||
|
||||
Assert.IsTrue(storyboard.HasDrawable);
|
||||
Assert.AreEqual(5, storyboard.Layers.Count());
|
||||
Assert.AreEqual(6, storyboard.Layers.Count());
|
||||
|
||||
StoryboardLayer background = storyboard.Layers.FirstOrDefault(l => l.Depth == 3);
|
||||
Assert.IsNotNull(background);
|
||||
@ -56,6 +56,13 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
Assert.IsTrue(foreground.VisibleWhenPassing);
|
||||
Assert.AreEqual("Foreground", foreground.Name);
|
||||
|
||||
StoryboardLayer overlay = storyboard.Layers.FirstOrDefault(l => l.Depth == int.MinValue);
|
||||
Assert.IsNotNull(overlay);
|
||||
Assert.IsEmpty(overlay.Elements);
|
||||
Assert.IsTrue(overlay.VisibleWhenFailing);
|
||||
Assert.IsTrue(overlay.VisibleWhenPassing);
|
||||
Assert.AreEqual("Overlay", overlay.Name);
|
||||
|
||||
int spriteCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardSprite));
|
||||
int animationCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardAnimation));
|
||||
int sampleCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardSampleInfo));
|
||||
|
@ -9,6 +9,7 @@ namespace osu.Game.Beatmaps.Legacy
|
||||
Fail = 1,
|
||||
Pass = 2,
|
||||
Foreground = 3,
|
||||
Video = 4
|
||||
Overlay = 4,
|
||||
Video = 5
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Storyboards.Drawables;
|
||||
@ -13,6 +14,8 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
public class DimmableStoryboard : UserDimContainer
|
||||
{
|
||||
public Container OverlayLayerContainer { get; private set; }
|
||||
|
||||
private readonly Storyboard storyboard;
|
||||
private DrawableStoryboard drawableStoryboard;
|
||||
|
||||
@ -24,6 +27,8 @@ namespace osu.Game.Screens.Play
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Add(OverlayLayerContainer = new Container());
|
||||
|
||||
initializeStoryboard(false);
|
||||
}
|
||||
|
||||
@ -46,9 +51,15 @@ namespace osu.Game.Screens.Play
|
||||
drawableStoryboard = storyboard.CreateDrawable();
|
||||
|
||||
if (async)
|
||||
LoadComponentAsync(drawableStoryboard, Add);
|
||||
LoadComponentAsync(drawableStoryboard, onStoryboardCreated);
|
||||
else
|
||||
Add(drawableStoryboard);
|
||||
onStoryboardCreated(drawableStoryboard);
|
||||
}
|
||||
|
||||
private void onStoryboardCreated(DrawableStoryboard storyboard)
|
||||
{
|
||||
Add(storyboard);
|
||||
OverlayLayerContainer.Add(storyboard.OverlayLayer.CreateProxy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -267,6 +267,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
target.AddRange(new[]
|
||||
{
|
||||
DimmableStoryboard.OverlayLayerContainer.CreateProxy(),
|
||||
BreakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, ScoreProcessor)
|
||||
{
|
||||
Clock = DrawableRuleset.FrameStableClock,
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using osuTK;
|
||||
using osu.Framework.Allocation;
|
||||
@ -72,6 +73,8 @@ namespace osu.Game.Storyboards.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
public DrawableStoryboardLayer OverlayLayer => Children.Single(layer => layer.Name == "Overlay");
|
||||
|
||||
private void updateLayerVisibility()
|
||||
{
|
||||
foreach (var layer in Children)
|
||||
|
@ -19,19 +19,26 @@ namespace osu.Game.Storyboards
|
||||
|
||||
public double FirstEventTime => Layers.Min(l => l.Elements.FirstOrDefault()?.StartTime ?? 0);
|
||||
|
||||
/// <summary>
|
||||
/// Depth of the currently front-most storyboard layer, excluding the overlay layer.
|
||||
/// </summary>
|
||||
private int minimumLayerDepth;
|
||||
|
||||
public Storyboard()
|
||||
{
|
||||
layers.Add("Video", new StoryboardLayer("Video", 4, false));
|
||||
layers.Add("Background", new StoryboardLayer("Background", 3));
|
||||
layers.Add("Fail", new StoryboardLayer("Fail", 2) { VisibleWhenPassing = false, });
|
||||
layers.Add("Pass", new StoryboardLayer("Pass", 1) { VisibleWhenFailing = false, });
|
||||
layers.Add("Foreground", new StoryboardLayer("Foreground", 0));
|
||||
layers.Add("Foreground", new StoryboardLayer("Foreground", minimumLayerDepth = 0));
|
||||
|
||||
layers.Add("Overlay", new StoryboardLayer("Overlay", int.MinValue));
|
||||
}
|
||||
|
||||
public StoryboardLayer GetLayer(string name)
|
||||
{
|
||||
if (!layers.TryGetValue(name, out var layer))
|
||||
layers[name] = layer = new StoryboardLayer(name, layers.Values.Min(l => l.Depth) - 1);
|
||||
layers[name] = layer = new StoryboardLayer(name, --minimumLayerDepth);
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
@ -33,6 +33,6 @@ namespace osu.Game.Storyboards
|
||||
}
|
||||
|
||||
public DrawableStoryboardLayer CreateDrawable()
|
||||
=> new DrawableStoryboardLayer(this) { Depth = Depth, };
|
||||
=> new DrawableStoryboardLayer(this) { Depth = Depth, Name = Name };
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user