mirror of
https://github.com/ppy/osu
synced 2024-12-16 20:05:41 +00:00
Merge pull request #3221 from smoogipoo/fix-variables-parsing
Fix storyboard variables not supporting prefixes/suffixes
This commit is contained in:
commit
c2fe0241e3
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
5
osu.Game.Tests/Resources/variable-with-suffix.osb
Normal file
5
osu.Game.Tests/Resources/variable-with-suffix.osb
Normal file
@ -0,0 +1,5 @@
|
||||
[Variables]
|
||||
$var=1234
|
||||
|
||||
[Events]
|
||||
Sprite,Background,TopCentre,"img.jpg",$var56,240
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user