From e360985d732ca356017394c6f19de60424fcc2e1 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 14 Aug 2018 18:15:09 +0900 Subject: [PATCH 1/2] Replace variables into the entire line --- .../Formats/LegacyStoryboardDecoderTest.cs | 14 ++++++++++++++ osu.Game.Tests/Resources/variable-with-suffix.osb | 5 +++++ .../Beatmaps/Formats/LegacyStoryboardDecoder.cs | 11 +++-------- 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 osu.Game.Tests/Resources/variable-with-suffix.osb 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; } From e04b2f4fa9261d0cf84028fe761361641d8cbcea Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 14 Aug 2018 18:31:32 +0900 Subject: [PATCH 2/2] Fix hitobject results not rewinding --- osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 2abb2eb289..7e3e955740 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -147,17 +147,15 @@ namespace osu.Game.Rulesets.Objects.Drawables /// public void PlaySamples() => Samples?.Play(); - private double lastUpdateTime; - protected override void Update() { base.Update(); - if (Result != null && lastUpdateTime > Time.Current) + if (Result != null && Result.HasResult) { var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime; - if (Result.TimeOffset + endTime < Time.Current) + if (Result.TimeOffset + endTime > Time.Current) { OnRevertResult?.Invoke(this, Result); @@ -165,8 +163,6 @@ namespace osu.Game.Rulesets.Objects.Drawables State.Value = ArmedState.Idle; } } - - lastUpdateTime = Time.Current; } protected override void UpdateAfterChildren()