From 93b26cd026786fa3ae75f97128686a77e0150fca Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 14 May 2019 13:04:49 +0900 Subject: [PATCH 1/3] Reduce unnecessary allocations --- .../Storyboards/Drawables/DrawableStoryboardAnimation.cs | 7 +++---- osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs index d01fba7d39..de3077c025 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osuTK; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -66,13 +67,11 @@ namespace osu.Game.Storyboards.Drawables [BackgroundDependencyLoader] private void load(IBindable beatmap, TextureStore textureStore) { - var basePath = Animation.Path.ToLowerInvariant(); - for (var frame = 0; frame < Animation.FrameCount; frame++) { - var framePath = basePath.Replace(".", frame + "."); + var framePath = Animation.Path.Replace(".", frame + "."); - var path = beatmap.Value.BeatmapSetInfo.Files.Find(f => f.Filename.ToLowerInvariant() == framePath)?.FileInfo.StoragePath; + var path = beatmap.Value.BeatmapSetInfo.Files.Find(f => f.Filename.Equals(framePath, StringComparison.InvariantCultureIgnoreCase))?.FileInfo.StoragePath; if (path == null) continue; diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs index 604260a38c..5f1f5ddacb 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osuTK; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -65,8 +66,7 @@ namespace osu.Game.Storyboards.Drawables [BackgroundDependencyLoader] private void load(IBindable beatmap, TextureStore textureStore) { - var spritePath = Sprite.Path.ToLowerInvariant(); - var path = beatmap.Value.BeatmapSetInfo.Files.Find(f => f.Filename.ToLowerInvariant() == spritePath)?.FileInfo.StoragePath; + var path = beatmap.Value.BeatmapSetInfo.Files.Find(f => f.Filename.Equals(Sprite.Path, StringComparison.InvariantCultureIgnoreCase))?.FileInfo.StoragePath; if (path == null) return; From 4abe987e11b834380f8371ce8d35f181b133c485 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 14 May 2019 13:27:09 +0900 Subject: [PATCH 2/3] Add new colour palette --- osu.Game/Graphics/OsuColour.cs | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs index e1e33b4c57..a73a8bcbc1 100644 --- a/osu.Game/Graphics/OsuColour.cs +++ b/osu.Game/Graphics/OsuColour.cs @@ -68,6 +68,48 @@ namespace osu.Game.Graphics public readonly Color4 GreenDark = FromHex(@"668800"); public readonly Color4 GreenDarker = FromHex(@"445500"); + public readonly Color4 Sky = FromHex(@"6bb5ff"); + public readonly Color4 GreySkyLighter = FromHex(@"c6e3f4"); + public readonly Color4 GreySkyLight = FromHex(@"8ab3cc"); + public readonly Color4 GreySky = FromHex(@"405461"); + public readonly Color4 GreySkyDark = FromHex(@"303d47"); + public readonly Color4 GreySkyDarker = FromHex(@"21272c"); + + public readonly Color4 Seafoam = FromHex(@"05ffa2"); + public readonly Color4 GreySeafoamLighter = FromHex(@"9ebab1"); + public readonly Color4 GreySeafoamLight = FromHex(@"4d7365"); + public readonly Color4 GreySeafoam = FromHex(@"33413c"); + public readonly Color4 GreySeafoamDark = FromHex(@"2c3532"); + public readonly Color4 GreySeafoamDarker = FromHex(@"1e2422"); + + public readonly Color4 Cyan = FromHex(@"05f4fd"); + public readonly Color4 GreyCyanLighter = FromHex(@"77b1b3"); + public readonly Color4 GreyCyanLight = FromHex(@"436d6f"); + public readonly Color4 GreyCyan = FromHex(@"293d3e"); + public readonly Color4 GreyCyanDark = FromHex(@"243536"); + public readonly Color4 GreyCyanDarker = FromHex(@"1e2929"); + + public readonly Color4 Lime = FromHex(@"82ff05"); + public readonly Color4 GreyLimeLighter = FromHex(@"deff87"); + public readonly Color4 GreyLimeLight = FromHex(@"657259"); + public readonly Color4 GreyLime = FromHex(@"3f443a"); + public readonly Color4 GreyLimeDark = FromHex(@"32352e"); + public readonly Color4 GreyLimeDarker = FromHex(@"2e302b"); + + public readonly Color4 Violet = FromHex(@"bf04ff"); + public readonly Color4 GreyVioletLighter = FromHex(@"ebb8fe"); + public readonly Color4 GreyVioletLight = FromHex(@"685370"); + public readonly Color4 GreyViolet = FromHex(@"46334d"); + public readonly Color4 GreyVioletDark = FromHex(@"2c2230"); + public readonly Color4 GreyVioletDarker = FromHex(@"201823"); + + public readonly Color4 Carmine = FromHex(@"ff0542"); + public readonly Color4 GreyCarmineLighter = FromHex(@"deaab4"); + public readonly Color4 GreyCarmineLight = FromHex(@"644f53"); + public readonly Color4 GreyCarmine = FromHex(@"342b2d"); + public readonly Color4 GreyCarmineDark = FromHex(@"302a2b"); + public readonly Color4 GreyCarmineDarker = FromHex(@"241d1e"); + public readonly Color4 Gray0 = FromHex(@"000"); public readonly Color4 Gray1 = FromHex(@"111"); public readonly Color4 Gray2 = FromHex(@"222"); From f1c9073338e32630eca13774e8b9b0143c6feaa9 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 14 May 2019 16:16:55 +0900 Subject: [PATCH 3/3] Fix commented line check not working with whitespace --- .../Beatmaps/Formats/LegacyDecoderTest.cs | 56 +++++++++++++++++++ osu.Game.Tests/Resources/comments.osu | 9 +++ osu.Game/Beatmaps/Formats/LegacyDecoder.cs | 2 +- 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Tests/Beatmaps/Formats/LegacyDecoderTest.cs create mode 100644 osu.Game.Tests/Resources/comments.osu diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyDecoderTest.cs new file mode 100644 index 0000000000..b4d219456c --- /dev/null +++ b/osu.Game.Tests/Beatmaps/Formats/LegacyDecoderTest.cs @@ -0,0 +1,56 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using System.IO; +using NUnit.Framework; +using osu.Game.Beatmaps.Formats; +using osu.Game.Tests.Resources; + +namespace osu.Game.Tests.Beatmaps.Formats +{ + [TestFixture] + public class LegacyDecoderTest + { + [Test] + public void TestDecodeComments() + { + var decoder = new LineLoggingDecoder(14); + + using (var resStream = TestResources.OpenResource("comments.osu")) + using (var stream = new StreamReader(resStream)) + { + decoder.Decode(stream); + + Assert.That(decoder.ParsedLines, Has.None.EqualTo("// Combo1: 0, 0, 0")); + Assert.That(decoder.ParsedLines, Has.None.EqualTo("//Combo2: 0, 0, 0")); + Assert.That(decoder.ParsedLines, Has.None.EqualTo(" // Combo3: 0, 0, 0")); + Assert.That(decoder.ParsedLines, Has.One.EqualTo("Combo1: 100, 100, 100 // Comment at end of line")); + } + } + + private class LineLoggingDecoder : LegacyDecoder + { + public readonly List ParsedLines = new List(); + + public LineLoggingDecoder(int version) + : base(version) + { + } + + protected override bool ShouldSkipLine(string line) + { + var result = base.ShouldSkipLine(line); + + if (!result) + ParsedLines.Add(line); + + return result; + } + } + + private class TestModel + { + } + } +} diff --git a/osu.Game.Tests/Resources/comments.osu b/osu.Game.Tests/Resources/comments.osu new file mode 100644 index 0000000000..78b48dd804 --- /dev/null +++ b/osu.Game.Tests/Resources/comments.osu @@ -0,0 +1,9 @@ +osu file format v14 + +[Colours] + +// Combo1: 0, 0, 0 +//Combo2: 0, 0, 0 + // Combo3: 0, 0, 0 + +Combo1: 100, 100, 100 // Comment at end of line \ No newline at end of file diff --git a/osu.Game/Beatmaps/Formats/LegacyDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyDecoder.cs index ad5089958c..eb5bcfe824 100644 --- a/osu.Game/Beatmaps/Formats/LegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyDecoder.cs @@ -54,7 +54,7 @@ namespace osu.Game.Beatmaps.Formats } } - protected virtual bool ShouldSkipLine(string line) => string.IsNullOrWhiteSpace(line) || line.StartsWith("//", StringComparison.Ordinal); + protected virtual bool ShouldSkipLine(string line) => string.IsNullOrWhiteSpace(line) || line.AsSpan().TrimStart().StartsWith("//".AsSpan(), StringComparison.Ordinal); protected virtual void ParseLine(T output, Section section, string line) {