diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyStoryboardDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyStoryboardDecoderTest.cs index 3431be91f9..82adc88c6b 100644 --- a/osu.Game.Tests/Beatmaps/Formats/LegacyStoryboardDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/LegacyStoryboardDecoderTest.cs @@ -86,5 +86,19 @@ namespace osu.Game.Tests.Beatmaps.Formats Assert.AreEqual(78993, animation.StartTime); } } + + [Test] + public void TestDecodeVariableWithSuffix() + { + var decoder = new LegacyStoryboardDecoder(); + using (var resStream = Resource.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); + } + } } } diff --git a/osu.Game.Tests/Resources/variable-with-suffix.osb b/osu.Game.Tests/Resources/variable-with-suffix.osb new file mode 100644 index 0000000000..5c9b46ca98 --- /dev/null +++ b/osu.Game.Tests/Resources/variable-with-suffix.osb @@ -0,0 +1,5 @@ +[Variables] +$var=1234 + +[Events] +Sprite,Background,TopCentre,"img.jpg",$var56,240 diff --git a/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs index b418cbd5ec..a8a62013b1 100644 --- a/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs @@ -289,15 +289,10 @@ namespace osu.Game.Beatmaps.Formats while (line.IndexOf('$') >= 0) { string origLine = line; - string[] split = line.Split(','); - for (int i = 0; i < split.Length; i++) - { - var item = split[i]; - if (item.StartsWith("$") && variables.ContainsKey(item)) - split[i] = variables[item]; - } - line = string.Join(",", split); + foreach (var v in variables) + line = line.Replace(v.Key, v.Value); + if (line == origLine) break; }