1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-07 22:16:10 +08:00

Merge pull request #8426 from voidedWarranties/storyboard-masking

Allow individual storyboard layers to disable masking
This commit is contained in:
Dean Herbert 2020-03-25 11:28:36 +09:00 committed by GitHub
commit cf890efa42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 18 deletions

View File

@ -31,29 +31,29 @@ namespace osu.Game.Tests.Beatmaps.Formats
StoryboardLayer background = storyboard.Layers.FirstOrDefault(l => l.Depth == 3);
Assert.IsNotNull(background);
Assert.AreEqual(16, background.Elements.Count);
Assert.IsTrue(background.EnabledWhenFailing);
Assert.IsTrue(background.EnabledWhenPassing);
Assert.IsTrue(background.VisibleWhenFailing);
Assert.IsTrue(background.VisibleWhenPassing);
Assert.AreEqual("Background", background.Name);
StoryboardLayer fail = storyboard.Layers.FirstOrDefault(l => l.Depth == 2);
Assert.IsNotNull(fail);
Assert.AreEqual(0, fail.Elements.Count);
Assert.IsTrue(fail.EnabledWhenFailing);
Assert.IsFalse(fail.EnabledWhenPassing);
Assert.IsTrue(fail.VisibleWhenFailing);
Assert.IsFalse(fail.VisibleWhenPassing);
Assert.AreEqual("Fail", fail.Name);
StoryboardLayer pass = storyboard.Layers.FirstOrDefault(l => l.Depth == 1);
Assert.IsNotNull(pass);
Assert.AreEqual(0, pass.Elements.Count);
Assert.IsFalse(pass.EnabledWhenFailing);
Assert.IsTrue(pass.EnabledWhenPassing);
Assert.IsFalse(pass.VisibleWhenFailing);
Assert.IsTrue(pass.VisibleWhenPassing);
Assert.AreEqual("Pass", pass.Name);
StoryboardLayer foreground = storyboard.Layers.FirstOrDefault(l => l.Depth == 0);
Assert.IsNotNull(foreground);
Assert.AreEqual(151, foreground.Elements.Count);
Assert.IsTrue(foreground.EnabledWhenFailing);
Assert.IsTrue(foreground.EnabledWhenPassing);
Assert.IsTrue(foreground.VisibleWhenFailing);
Assert.IsTrue(foreground.VisibleWhenPassing);
Assert.AreEqual("Foreground", foreground.Name);
int spriteCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardSprite));

View File

@ -44,7 +44,6 @@ namespace osu.Game.Screens.Play
return;
drawableStoryboard = storyboard.CreateDrawable();
drawableStoryboard.Masking = true;
if (async)
LoadComponentAsync(drawableStoryboard, Add);

View File

@ -75,7 +75,7 @@ namespace osu.Game.Storyboards.Drawables
private void updateLayerVisibility()
{
foreach (var layer in Children)
layer.Enabled = passing ? layer.Layer.EnabledWhenPassing : layer.Layer.EnabledWhenFailing;
layer.Enabled = passing ? layer.Layer.VisibleWhenPassing : layer.Layer.VisibleWhenFailing;
}
}
}

View File

@ -21,7 +21,8 @@ namespace osu.Game.Storyboards.Drawables
RelativeSizeAxes = Axes.Both;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Enabled = layer.EnabledWhenPassing;
Enabled = layer.VisibleWhenPassing;
Masking = layer.Masking;
}
[BackgroundDependencyLoader]

View File

@ -22,8 +22,8 @@ namespace osu.Game.Storyboards
public Storyboard()
{
layers.Add("Background", new StoryboardLayer("Background", 3));
layers.Add("Fail", new StoryboardLayer("Fail", 2) { EnabledWhenPassing = false, });
layers.Add("Pass", new StoryboardLayer("Pass", 1) { EnabledWhenFailing = false, });
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));
}

View File

@ -8,17 +8,23 @@ namespace osu.Game.Storyboards
{
public class StoryboardLayer
{
public string Name;
public int Depth;
public bool EnabledWhenPassing = true;
public bool EnabledWhenFailing = true;
public readonly string Name;
public readonly int Depth;
public readonly bool Masking;
public bool VisibleWhenPassing = true;
public bool VisibleWhenFailing = true;
public List<IStoryboardElement> Elements = new List<IStoryboardElement>();
public StoryboardLayer(string name, int depth)
public StoryboardLayer(string name, int depth, bool masking = true)
{
Name = name;
Depth = depth;
Masking = masking;
}
public void Add(IStoryboardElement element)