private void loadStoryboardNoVideo() { if (storyboard != null) { storyboardContainer.Remove(storyboard); } var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true }; storyboardContainer.Clock = decoupledClock; Storyboard sb; using (var str = TestResources.OpenResource("storyboard_no_video.osu")) using (var bfr = new LineBufferedReader(str)) { var decoder = new LegacyStoryboardDecoder(); sb = decoder.Decode(bfr); } storyboard = sb.CreateDrawable(Beatmap.Value); storyboardContainer.Add(storyboard); decoupledClock.ChangeSource(Beatmap.Value.Track); }
public void TestDecodeLoopCount() { // all loop sequences in loop-count.osb have a total duration of 2000ms (fade in 0->1000ms, fade out 1000->2000ms). const double loop_duration = 2000; var decoder = new LegacyStoryboardDecoder(); using (var resStream = TestResources.OpenResource("loop-count.osb")) using (var stream = new LineBufferedReader(resStream)) { var storyboard = decoder.Decode(stream); StoryboardLayer background = storyboard.Layers.Single(l => l.Depth == 3); // stable ensures that any loop command executes at least once, even if the loop count specified in the .osb is zero or negative. StoryboardSprite zeroTimes = background.Elements.OfType <StoryboardSprite>().Single(s => s.Path == "zero-times.png"); Assert.That(zeroTimes.EndTime, Is.EqualTo(1000 + loop_duration)); StoryboardSprite oneTime = background.Elements.OfType <StoryboardSprite>().Single(s => s.Path == "one-time.png"); Assert.That(oneTime.EndTime, Is.EqualTo(4000 + loop_duration)); StoryboardSprite manyTimes = background.Elements.OfType <StoryboardSprite>().Single(s => s.Path == "many-times.png"); Assert.That(manyTimes.EndTime, Is.EqualTo(9000 + 40 * loop_duration)); } }
public void TestDecodeVariableWithSuffix() { var decoder = new LegacyStoryboardDecoder(); using (var resStream = TestResources.OpenResource("variable-with-suffix.osb")) using (var stream = new StreamReader(resStream)) { var storyboard = decoder.Decode(stream); StoryboardLayer background = storyboard.Layers.Single(l => l.Depth == 3); Assert.AreEqual(123456, ((StoryboardSprite)background.Elements.Single()).InitialPosition.X); } }
public void TestOutOfOrderStartTimes() { var decoder = new LegacyStoryboardDecoder(); using (var resStream = TestResources.OpenResource("out-of-order-starttimes.osb")) using (var stream = new LineBufferedReader(resStream)) { var storyboard = decoder.Decode(stream); StoryboardLayer background = storyboard.Layers.Single(l => l.Depth == 3); Assert.AreEqual(2, background.Elements.Count); Assert.AreEqual(1500, background.Elements[0].StartTime); Assert.AreEqual(1000, background.Elements[1].StartTime); Assert.AreEqual(1000, storyboard.EarliestEventTime); } }
public void TestDecodeOutOfRangeLoopAnimationType() { var decoder = new LegacyStoryboardDecoder(); using (var resStream = TestResources.OpenResource("animation-types.osb")) using (var stream = new LineBufferedReader(resStream)) { var storyboard = decoder.Decode(stream); StoryboardLayer foreground = storyboard.Layers.Single(l => l.Depth == 0); Assert.AreEqual(AnimationLoopType.LoopForever, ((StoryboardAnimation)foreground.Elements[0]).LoopType); Assert.AreEqual(AnimationLoopType.LoopOnce, ((StoryboardAnimation)foreground.Elements[1]).LoopType); Assert.AreEqual(AnimationLoopType.LoopForever, ((StoryboardAnimation)foreground.Elements[2]).LoopType); Assert.AreEqual(AnimationLoopType.LoopOnce, ((StoryboardAnimation)foreground.Elements[3]).LoopType); Assert.AreEqual(AnimationLoopType.LoopForever, ((StoryboardAnimation)foreground.Elements[4]).LoopType); Assert.AreEqual(AnimationLoopType.LoopForever, ((StoryboardAnimation)foreground.Elements[5]).LoopType); } }
public void TestDecodeStoryboardEvents() { var decoder = new LegacyStoryboardDecoder(); using (var resStream = TestResources.OpenResource("Himeringo - Yotsuya-san ni Yoroshiku (RLC) [Winber1's Extreme].osu")) using (var stream = new StreamReader(resStream)) { var storyboard = decoder.Decode(stream); Assert.IsTrue(storyboard.HasDrawable); Assert.AreEqual(4, storyboard.Layers.Count()); 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.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.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.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.AreEqual("Foreground", foreground.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(StoryboardSample)); Assert.AreEqual(15, spriteCount); Assert.AreEqual(1, animationCount); Assert.AreEqual(0, sampleCount); Assert.AreEqual(background.Elements.Count(), spriteCount + animationCount + sampleCount); var sprite = background.Elements.ElementAt(0) as StoryboardSprite; Assert.NotNull(sprite); Assert.IsTrue(sprite.HasCommands); Assert.AreEqual(new Vector2(320, 240), sprite.InitialPosition); Assert.IsTrue(sprite.IsDrawable); Assert.AreEqual(Anchor.Centre, sprite.Origin); Assert.AreEqual("SB/lyric/ja-21.png", sprite.Path); var animation = background.Elements.ElementAt(12) as StoryboardAnimation; Assert.NotNull(animation); Assert.AreEqual(141175, animation.EndTime); Assert.AreEqual(10, animation.FrameCount); Assert.AreEqual(30, animation.FrameDelay); Assert.IsTrue(animation.HasCommands); Assert.AreEqual(new Vector2(320, 240), animation.InitialPosition); Assert.IsTrue(animation.IsDrawable); Assert.AreEqual(AnimationLoopType.LoopForever, animation.LoopType); Assert.AreEqual(Anchor.Centre, animation.Origin); Assert.AreEqual("SB/red jitter/red_0000.jpg", animation.Path); Assert.AreEqual(78993, animation.StartTime); } }