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