1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-08 03:52:56 +08:00

Rename and make fields readonly

This commit is contained in:
Dean Herbert 2020-03-25 11:08:08 +09:00
parent 971249338d
commit 368bf58521
5 changed files with 21 additions and 17 deletions

View File

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

View File

@ -75,7 +75,7 @@ namespace osu.Game.Storyboards.Drawables
private void updateLayerVisibility() private void updateLayerVisibility()
{ {
foreach (var layer in Children) 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,7 @@ namespace osu.Game.Storyboards.Drawables
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
Anchor = Anchor.Centre; Anchor = Anchor.Centre;
Origin = Anchor.Centre; Origin = Anchor.Centre;
Enabled = layer.EnabledWhenPassing; Enabled = layer.VisibleWhenPassing;
Masking = layer.Masking; Masking = layer.Masking;
} }

View File

@ -22,8 +22,8 @@ namespace osu.Game.Storyboards
public Storyboard() public Storyboard()
{ {
layers.Add("Background", new StoryboardLayer("Background", 3)); layers.Add("Background", new StoryboardLayer("Background", 3));
layers.Add("Fail", new StoryboardLayer("Fail", 2) { EnabledWhenPassing = false, }); layers.Add("Fail", new StoryboardLayer("Fail", 2) { VisibleWhenPassing = false, });
layers.Add("Pass", new StoryboardLayer("Pass", 1) { EnabledWhenFailing = false, }); layers.Add("Pass", new StoryboardLayer("Pass", 1) { VisibleWhenFailing = false, });
layers.Add("Foreground", new StoryboardLayer("Foreground", 0)); layers.Add("Foreground", new StoryboardLayer("Foreground", 0));
} }

View File

@ -8,11 +8,15 @@ namespace osu.Game.Storyboards
{ {
public class StoryboardLayer public class StoryboardLayer
{ {
public string Name; public readonly string Name;
public int Depth;
public bool Masking; public readonly int Depth;
public bool EnabledWhenPassing = true;
public bool EnabledWhenFailing = true; public readonly bool Masking;
public bool VisibleWhenPassing = true;
public bool VisibleWhenFailing = true;
public List<IStoryboardElement> Elements = new List<IStoryboardElement>(); public List<IStoryboardElement> Elements = new List<IStoryboardElement>();