mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 07:43:00 +08:00
fall back to .osu file for storyboard if no .osb file is present
+ CI fixes
This commit is contained in:
parent
2bbfe0dda1
commit
cc76c58f5f
@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
@ -56,9 +55,9 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
Assert.IsTrue(foreground.EnabledWhenPassing);
|
||||
Assert.AreEqual("Foreground", foreground.Name);
|
||||
|
||||
int spriteCount = background.Elements.Where(x => x.GetType() == typeof(StoryboardSprite)).Count();
|
||||
int animationCount = background.Elements.Where(x => x.GetType() == typeof(StoryboardAnimation)).Count();
|
||||
int sampleCount = background.Elements.Where(x => x.GetType() == typeof(StoryboardSample)).Count();
|
||||
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);
|
||||
@ -66,6 +65,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
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);
|
||||
@ -73,6 +73,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
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);
|
||||
|
@ -615,7 +615,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
protected override Storyboard GetStoryboard()
|
||||
{
|
||||
if (BeatmapSetInfo?.StoryboardFile == null)
|
||||
if (BeatmapInfo?.Path == null && BeatmapSetInfo?.StoryboardFile == null)
|
||||
return new Storyboard();
|
||||
|
||||
try
|
||||
@ -624,7 +624,9 @@ namespace osu.Game.Beatmaps
|
||||
using (var stream = new StreamReader(store.GetStream(getPathForFile(BeatmapInfo.Path))))
|
||||
decoder = Decoder.GetDecoder(stream);
|
||||
|
||||
using (var stream = new StreamReader(store.GetStream(getPathForFile(BeatmapSetInfo.StoryboardFile))))
|
||||
// try for .osb first and fall back to .osu
|
||||
string storyboardFile = BeatmapSetInfo.StoryboardFile ?? BeatmapInfo.Path;
|
||||
using (var stream = new StreamReader(store.GetStream(getPathForFile(storyboardFile))))
|
||||
return decoder.GetStoryboardDecoder().DecodeStoryboard(stream);
|
||||
}
|
||||
catch
|
||||
|
@ -47,6 +47,13 @@ namespace osu.Game.Beatmaps.Formats
|
||||
hitObject.ApplyDefaults(this.beatmap.ControlPointInfo, this.beatmap.BeatmapInfo.BaseDifficulty);
|
||||
}
|
||||
|
||||
protected override bool ShouldSkipLine(string line)
|
||||
{
|
||||
if (base.ShouldSkipLine(line) || line.StartsWith(" ") || line.StartsWith("_"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void ProcessSection(Section section, string line)
|
||||
{
|
||||
switch (section)
|
||||
|
@ -52,10 +52,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
string line;
|
||||
while ((line = stream.ReadLine()) != null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
continue;
|
||||
|
||||
if (line.StartsWith("//"))
|
||||
if (ShouldSkipLine(line))
|
||||
continue;
|
||||
|
||||
// It's already set in ParseBeatmap... why do it again?
|
||||
@ -76,6 +73,13 @@ namespace osu.Game.Beatmaps.Formats
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual bool ShouldSkipLine(string line)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line) || line.StartsWith("//"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract void ProcessSection(Section section, string line);
|
||||
|
||||
/// <summary>
|
||||
|
@ -237,9 +237,9 @@ namespace osu.Game.Beatmaps.Formats
|
||||
}
|
||||
}
|
||||
|
||||
private static string parseLayer(string value) => Enum.Parse(typeof(StoryLayer), value).ToString();
|
||||
private string parseLayer(string value) => Enum.Parse(typeof(StoryLayer), value).ToString();
|
||||
|
||||
private static Anchor parseOrigin(string value)
|
||||
private Anchor parseOrigin(string value)
|
||||
{
|
||||
var origin = (LegacyOrigins)Enum.Parse(typeof(LegacyOrigins), value);
|
||||
switch (origin)
|
||||
@ -266,6 +266,6 @@ namespace osu.Game.Beatmaps.Formats
|
||||
throw new InvalidDataException($@"Unknown origin: {value}");
|
||||
}
|
||||
|
||||
private static string cleanFilename(string path) => FileSafety.PathStandardise(path.Trim('\"'));
|
||||
private string cleanFilename(string path) => FileSafety.PathStandardise(path.Trim('\"'));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user