From c1077d909ca5e41270522714e8457733a36043f2 Mon Sep 17 00:00:00 2001 From: Ryuki Date: Sat, 17 Sep 2022 21:09:34 +0200 Subject: [PATCH 01/84] Basic avatar HUD implementation --- osu.Game/Screens/Play/HUD/SkinnableAvatar.cs | 50 ++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 osu.Game/Screens/Play/HUD/SkinnableAvatar.cs diff --git a/osu.Game/Screens/Play/HUD/SkinnableAvatar.cs b/osu.Game/Screens/Play/HUD/SkinnableAvatar.cs new file mode 100644 index 0000000000..abec4402a7 --- /dev/null +++ b/osu.Game/Screens/Play/HUD/SkinnableAvatar.cs @@ -0,0 +1,50 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Configuration; +using osu.Game.Skinning; +using osu.Game.Users.Drawables; +using osuTK; + +namespace osu.Game.Screens.Play.HUD +{ + public class SkinnableAvatar : CompositeDrawable, ISkinnableDrawable + { + [SettingSource("Corner radius", "How much the edges should be rounded.")] + public new BindableFloat CornerRadius { get; set; } = new BindableFloat(0) + { + MinValue = 0, + MaxValue = 100, + Precision = 0.01f + }; + + [Resolved] + private GameplayState gameplayState { get; set; } = null!; + + private readonly UpdateableAvatar avatar; + + public SkinnableAvatar() + { + Size = new Vector2(128f); + InternalChild = avatar = new UpdateableAvatar(isInteractive: false) + { + RelativeSizeAxes = Axes.Both, + Masking = true + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + avatar.User = gameplayState.Score.ScoreInfo.User; + CornerRadius.BindValueChanged(e => avatar.CornerRadius = e.NewValue); + } + + public bool UsesFixedAnchor { get; set; } + } +} From ecf71df8a23bfca5cbe5a78daef23908135d92c2 Mon Sep 17 00:00:00 2001 From: Ryuki Date: Sun, 18 Sep 2022 00:04:56 +0200 Subject: [PATCH 02/84] Change CornerRadius Max Value --- osu.Game/Screens/Play/HUD/SkinnableAvatar.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/SkinnableAvatar.cs b/osu.Game/Screens/Play/HUD/SkinnableAvatar.cs index abec4402a7..d675176a0a 100644 --- a/osu.Game/Screens/Play/HUD/SkinnableAvatar.cs +++ b/osu.Game/Screens/Play/HUD/SkinnableAvatar.cs @@ -15,10 +15,10 @@ namespace osu.Game.Screens.Play.HUD public class SkinnableAvatar : CompositeDrawable, ISkinnableDrawable { [SettingSource("Corner radius", "How much the edges should be rounded.")] - public new BindableFloat CornerRadius { get; set; } = new BindableFloat(0) + public new BindableFloat CornerRadius { get; set; } = new BindableFloat { MinValue = 0, - MaxValue = 100, + MaxValue = 63, Precision = 0.01f }; From 1f586c129c1b27fee148db26846e69eb6febc1d8 Mon Sep 17 00:00:00 2001 From: Cootz Date: Wed, 15 Feb 2023 22:15:44 +0300 Subject: [PATCH 03/84] fix applied --- osu.Game/Database/LegacyExporter.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs index 09d6913dd9..c56c17222d 100644 --- a/osu.Game/Database/LegacyExporter.cs +++ b/osu.Game/Database/LegacyExporter.cs @@ -3,6 +3,7 @@ #nullable disable +using System; using System.Collections.Generic; using System.IO; using osu.Framework.Platform; @@ -18,6 +19,14 @@ namespace osu.Game.Database public abstract class LegacyExporter where TModel : class, IHasNamedFiles { + /// + /// Max length of filename (including extension) + /// + /// + /// This constant is smaller 256 because adds additional "_" to the end of the path + /// + private const int max_path = 255 - (32 + 4 + 2); //max path - (Guid + Guid "D" format chars + Storage.CreateFileSafely chars) + /// /// The file extension for exports (including the leading '.'). /// @@ -33,7 +42,16 @@ namespace osu.Game.Database UserFileStorage = storage.GetStorageForDirectory(@"files"); } - protected virtual string GetFilename(TModel item) => item.GetDisplayString(); + protected virtual string GetFilename(TModel item) + { + string fileName = item.GetDisplayString(); + + int fileNameLength = fileName.Length - FileExtension.Length; + if (fileNameLength > max_path) + fileName = fileName.Remove(max_path - FileExtension.Length); //Truncating the name to fit the path limit + + return fileName; + } /// /// Exports an item to a legacy (.zip based) package. From 387a6f1330b3e22360565dd07a4a7048eae3e4d8 Mon Sep 17 00:00:00 2001 From: Cootz Date: Wed, 15 Feb 2023 22:43:43 +0300 Subject: [PATCH 04/84] Move logic to `Export` method --- osu.Game/Database/LegacyExporter.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs index cd0b50c109..483c3cbd5c 100644 --- a/osu.Game/Database/LegacyExporter.cs +++ b/osu.Game/Database/LegacyExporter.cs @@ -43,16 +43,7 @@ namespace osu.Game.Database UserFileStorage = storage.GetStorageForDirectory(@"files"); } - protected virtual string GetFilename(TModel item) - { - string fileName = item.GetDisplayString(); - - int fileNameLength = fileName.Length - FileExtension.Length; - if (fileNameLength > max_path) - fileName = fileName.Remove(max_path - FileExtension.Length); //Truncating the name to fit the path limit - - return fileName; - } + protected virtual string GetFilename(TModel item) => item.GetDisplayString(); /// /// Exports an item to a legacy (.zip based) package. @@ -68,6 +59,15 @@ namespace osu.Game.Database .Concat(exportStorage.GetDirectories(string.Empty)); string filename = NamingUtils.GetNextBestFilename(existingExports, $"{itemFilename}{FileExtension}"); + + if (filename.Length > max_path) + { + string filenameWithoutExtension = Path.GetFileNameWithoutExtension(filename); + + filenameWithoutExtension = filenameWithoutExtension.Remove(max_path - FileExtension.Length); //Truncating the name to fit the path limit + filename = $"{filenameWithoutExtension}{FileExtension}"; + } + using (var stream = exportStorage.CreateFileSafely(filename)) ExportModelTo(item, stream); From f1da213beaaaba85b82c785def1c43f6cb1f62ec Mon Sep 17 00:00:00 2001 From: Cootz Date: Thu, 16 Feb 2023 16:26:57 +0300 Subject: [PATCH 05/84] Add tests --- osu.Game.Tests/Database/LegacyExporterTest.cs | 85 +++++++++++++++++++ osu.Game/Database/LegacyExporter.cs | 6 +- 2 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 osu.Game.Tests/Database/LegacyExporterTest.cs diff --git a/osu.Game.Tests/Database/LegacyExporterTest.cs b/osu.Game.Tests/Database/LegacyExporterTest.cs new file mode 100644 index 0000000000..5f07e6c917 --- /dev/null +++ b/osu.Game.Tests/Database/LegacyExporterTest.cs @@ -0,0 +1,85 @@ +// 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.Diagnostics; +using System.IO; +using System.Text; +using NUnit.Framework; +using osu.Framework.Platform; +using osu.Framework.Testing; +using osu.Game.Database; + +namespace osu.Game.Tests.Database +{ + public class LegacyExporterTest + { + private TestLegacyExporter? legacyExporter; + private TemporaryNativeStorage? storage; + + [SetUp] + public void SetupLegacyExporter() + { + storage = new TemporaryNativeStorage("export-storage"); + legacyExporter = new TestLegacyExporter(storage); + } + + [Test] + public void ExportFileWithNormalName() + { + var exportStorage = storage?.GetStorageForDirectory(@"exports"); + + string filename = "normal file name"; + var item = new TestPathInfo(filename); + + Assert.That(item.FileName.Length < TestLegacyExporter.GetMaxPath(), Is.True); + Assert.DoesNotThrow(() => legacyExporter?.Export(item)); + Assert.That(exportStorage?.Exists($"{filename}{legacyExporter?.GetExtension()}"), Is.True); + } + + [Test] + public void ExportFileWithSuperLongName() + { + var exportStorage = storage?.GetStorageForDirectory(@"exports"); + + string fullname = "some file with super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name"; + + int capacity = TestLegacyExporter.GetMaxPath() - (legacyExporter?.GetExtension().Length ?? 0); + string expectedName = fullname.Remove(capacity); + + var item = new TestPathInfo(fullname); + + Assert.That(item.FileName.Length > TestLegacyExporter.GetMaxPath(), Is.True); + Assert.DoesNotThrow(() => legacyExporter?.Export(item)); + Assert.That(exportStorage?.Exists($"{expectedName}{legacyExporter?.GetExtension()}"), Is.True); + } + + [TearDown] + public void CleanupAfterTest() + { + storage?.Dispose(); + } + + private class TestPathInfo : IHasNamedFiles + { + public string FileName { get; set; } = string.Empty; + + public TestPathInfo(string fileName) => FileName = fileName; + + public IEnumerable Files { get; set; } = new List(); + + public override string ToString() => FileName; + } + + private class TestLegacyExporter : LegacyExporter + { + public TestLegacyExporter(Storage storage) : base(storage) { } + + public static int GetMaxPath() => MAX_PATH; + + public string GetExtension() => FileExtension; + + protected override string FileExtension => ".ots"; + } + } +} diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs index 483c3cbd5c..9041f58368 100644 --- a/osu.Game/Database/LegacyExporter.cs +++ b/osu.Game/Database/LegacyExporter.cs @@ -26,7 +26,7 @@ namespace osu.Game.Database /// /// This constant is smaller 256 because adds additional "_" to the end of the path /// - private const int max_path = 255 - (32 + 4 + 2); //max path - (Guid + Guid "D" format chars + Storage.CreateFileSafely chars) + protected const int MAX_PATH = 255 - (32 + 4 + 2); //max path - (Guid + Guid "D" format chars + Storage.CreateFileSafely chars) /// /// The file extension for exports (including the leading '.'). @@ -60,11 +60,11 @@ namespace osu.Game.Database string filename = NamingUtils.GetNextBestFilename(existingExports, $"{itemFilename}{FileExtension}"); - if (filename.Length > max_path) + if (filename.Length > MAX_PATH) { string filenameWithoutExtension = Path.GetFileNameWithoutExtension(filename); - filenameWithoutExtension = filenameWithoutExtension.Remove(max_path - FileExtension.Length); //Truncating the name to fit the path limit + filenameWithoutExtension = filenameWithoutExtension.Remove(MAX_PATH - FileExtension.Length); //Truncating the name to fit the path limit filename = $"{filenameWithoutExtension}{FileExtension}"; } From 6819a45a1bdba3fdd2b28a6d7983b73116ddbded Mon Sep 17 00:00:00 2001 From: Cootz Date: Thu, 16 Feb 2023 16:42:07 +0300 Subject: [PATCH 06/84] Improve code slightly --- osu.Game.Tests/Database/LegacyExporterTest.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Database/LegacyExporterTest.cs b/osu.Game.Tests/Database/LegacyExporterTest.cs index 5f07e6c917..c464eb5c28 100644 --- a/osu.Game.Tests/Database/LegacyExporterTest.cs +++ b/osu.Game.Tests/Database/LegacyExporterTest.cs @@ -2,9 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Text; using NUnit.Framework; using osu.Framework.Platform; using osu.Framework.Testing; @@ -29,7 +26,7 @@ namespace osu.Game.Tests.Database { var exportStorage = storage?.GetStorageForDirectory(@"exports"); - string filename = "normal file name"; + const string filename = "normal file name"; var item = new TestPathInfo(filename); Assert.That(item.FileName.Length < TestLegacyExporter.GetMaxPath(), Is.True); @@ -42,7 +39,7 @@ namespace osu.Game.Tests.Database { var exportStorage = storage?.GetStorageForDirectory(@"exports"); - string fullname = "some file with super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name"; + const string fullname = "some file with super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name"; int capacity = TestLegacyExporter.GetMaxPath() - (legacyExporter?.GetExtension().Length ?? 0); string expectedName = fullname.Remove(capacity); @@ -62,7 +59,7 @@ namespace osu.Game.Tests.Database private class TestPathInfo : IHasNamedFiles { - public string FileName { get; set; } = string.Empty; + public string FileName { get; set; } public TestPathInfo(string fileName) => FileName = fileName; @@ -73,7 +70,10 @@ namespace osu.Game.Tests.Database private class TestLegacyExporter : LegacyExporter { - public TestLegacyExporter(Storage storage) : base(storage) { } + public TestLegacyExporter(Storage storage) + : base(storage) + { + } public static int GetMaxPath() => MAX_PATH; From 6cb00cd42f22b7324df66a2863a0fe333875d2f8 Mon Sep 17 00:00:00 2001 From: Cootz Date: Fri, 17 Feb 2023 01:44:45 +0300 Subject: [PATCH 07/84] Add more test cases --- osu.Game.Tests/Database/LegacyExporterTest.cs | 54 ++++++++++++++++--- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tests/Database/LegacyExporterTest.cs b/osu.Game.Tests/Database/LegacyExporterTest.cs index c464eb5c28..c67ec75e92 100644 --- a/osu.Game.Tests/Database/LegacyExporterTest.cs +++ b/osu.Game.Tests/Database/LegacyExporterTest.cs @@ -22,7 +22,7 @@ namespace osu.Game.Tests.Database } [Test] - public void ExportFileWithNormalName() + public void ExportFileWithNormalNameTest() { var exportStorage = storage?.GetStorageForDirectory(@"exports"); @@ -30,23 +30,65 @@ namespace osu.Game.Tests.Database var item = new TestPathInfo(filename); Assert.That(item.FileName.Length < TestLegacyExporter.GetMaxPath(), Is.True); - Assert.DoesNotThrow(() => legacyExporter?.Export(item)); - Assert.That(exportStorage?.Exists($"{filename}{legacyExporter?.GetExtension()}"), Is.True); + exportItemWithLongNameAndAssert(item, exportStorage, filename); } [Test] - public void ExportFileWithSuperLongName() + public void ExportFileWithNormalNameMultipleTimesTest() + { + var exportStorage = storage?.GetStorageForDirectory(@"exports"); + + const string filename = "normal file name"; + var item = new TestPathInfo(filename); + + Assert.That(item.FileName.Length < TestLegacyExporter.GetMaxPath(), Is.True); + + //Export multiple times + string expectedFileName; + for (int i = 0; i < 10; i++) + { + expectedFileName = i == 0 ? filename : $"{filename} ({i})"; + exportItemWithLongNameAndAssert(item, exportStorage, expectedFileName); + } + } + + [Test] + public void ExportFileWithSuperLongNameTest() { var exportStorage = storage?.GetStorageForDirectory(@"exports"); const string fullname = "some file with super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name"; - int capacity = TestLegacyExporter.GetMaxPath() - (legacyExporter?.GetExtension().Length ?? 0); - string expectedName = fullname.Remove(capacity); + int expectedLength = TestLegacyExporter.GetMaxPath() - (legacyExporter?.GetExtension().Length ?? 0); + string expectedName = fullname.Remove(expectedLength); var item = new TestPathInfo(fullname); Assert.That(item.FileName.Length > TestLegacyExporter.GetMaxPath(), Is.True); + exportItemWithLongNameAndAssert(item, exportStorage, expectedName); + } + + [Test] + public void ExportFileWithSuperLongNameMultipleTimesTest() + { + var exportStorage = storage?.GetStorageForDirectory(@"exports"); + + const string fullname = "some file with super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name"; + + int expectedLength = TestLegacyExporter.GetMaxPath() - (legacyExporter?.GetExtension().Length ?? 0); + string expectedName = fullname.Remove(expectedLength); + + var item = new TestPathInfo(fullname); + + Assert.That(item.FileName.Length > TestLegacyExporter.GetMaxPath(), Is.True); + + //Export multiple times + for (int i = 0; i < 10; i++) + exportItemWithLongNameAndAssert(item, exportStorage, expectedName); + } + + private void exportItemWithLongNameAndAssert(IHasNamedFiles item, Storage? exportStorage, string expectedName) + { Assert.DoesNotThrow(() => legacyExporter?.Export(item)); Assert.That(exportStorage?.Exists($"{expectedName}{legacyExporter?.GetExtension()}"), Is.True); } From 1d8b348e4c72d29d44ce0f56d9d6e71f98000187 Mon Sep 17 00:00:00 2001 From: Cootz Date: Fri, 17 Feb 2023 01:46:15 +0300 Subject: [PATCH 08/84] Improve naming --- osu.Game.Tests/Database/LegacyExporterTest.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Database/LegacyExporterTest.cs b/osu.Game.Tests/Database/LegacyExporterTest.cs index c67ec75e92..97b32b0c51 100644 --- a/osu.Game.Tests/Database/LegacyExporterTest.cs +++ b/osu.Game.Tests/Database/LegacyExporterTest.cs @@ -30,7 +30,7 @@ namespace osu.Game.Tests.Database var item = new TestPathInfo(filename); Assert.That(item.FileName.Length < TestLegacyExporter.GetMaxPath(), Is.True); - exportItemWithLongNameAndAssert(item, exportStorage, filename); + exportItemAndAssert(item, exportStorage, filename); } [Test] @@ -48,7 +48,7 @@ namespace osu.Game.Tests.Database for (int i = 0; i < 10; i++) { expectedFileName = i == 0 ? filename : $"{filename} ({i})"; - exportItemWithLongNameAndAssert(item, exportStorage, expectedFileName); + exportItemAndAssert(item, exportStorage, expectedFileName); } } @@ -65,7 +65,7 @@ namespace osu.Game.Tests.Database var item = new TestPathInfo(fullname); Assert.That(item.FileName.Length > TestLegacyExporter.GetMaxPath(), Is.True); - exportItemWithLongNameAndAssert(item, exportStorage, expectedName); + exportItemAndAssert(item, exportStorage, expectedName); } [Test] @@ -84,10 +84,10 @@ namespace osu.Game.Tests.Database //Export multiple times for (int i = 0; i < 10; i++) - exportItemWithLongNameAndAssert(item, exportStorage, expectedName); + exportItemAndAssert(item, exportStorage, expectedName); } - private void exportItemWithLongNameAndAssert(IHasNamedFiles item, Storage? exportStorage, string expectedName) + private void exportItemAndAssert(IHasNamedFiles item, Storage? exportStorage, string expectedName) { Assert.DoesNotThrow(() => legacyExporter?.Export(item)); Assert.That(exportStorage?.Exists($"{expectedName}{legacyExporter?.GetExtension()}"), Is.True); From f4038a49a17f8670f3b3ed8613e12d197d4e96b6 Mon Sep 17 00:00:00 2001 From: Cootz Date: Fri, 17 Feb 2023 01:50:24 +0300 Subject: [PATCH 09/84] Fix inspectCode issues --- osu.Game.Tests/Database/LegacyExporterTest.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game.Tests/Database/LegacyExporterTest.cs b/osu.Game.Tests/Database/LegacyExporterTest.cs index 97b32b0c51..d67cb8abf1 100644 --- a/osu.Game.Tests/Database/LegacyExporterTest.cs +++ b/osu.Game.Tests/Database/LegacyExporterTest.cs @@ -44,10 +44,9 @@ namespace osu.Game.Tests.Database Assert.That(item.FileName.Length < TestLegacyExporter.GetMaxPath(), Is.True); //Export multiple times - string expectedFileName; for (int i = 0; i < 10; i++) { - expectedFileName = i == 0 ? filename : $"{filename} ({i})"; + string expectedFileName = i == 0 ? filename : $"{filename} ({i})"; exportItemAndAssert(item, exportStorage, expectedFileName); } } From 415220a44769fa8a7027ec8d56eb38b63fac6e04 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Feb 2023 13:30:00 +0900 Subject: [PATCH 10/84] Tidy up new test method code quality --- osu.Game.Tests/Database/LegacyExporterTest.cs | 55 +++++++++++-------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/osu.Game.Tests/Database/LegacyExporterTest.cs b/osu.Game.Tests/Database/LegacyExporterTest.cs index d67cb8abf1..803cd40132 100644 --- a/osu.Game.Tests/Database/LegacyExporterTest.cs +++ b/osu.Game.Tests/Database/LegacyExporterTest.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using NUnit.Framework; +using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Platform; using osu.Framework.Testing; using osu.Game.Database; @@ -11,11 +12,11 @@ namespace osu.Game.Tests.Database { public class LegacyExporterTest { - private TestLegacyExporter? legacyExporter; - private TemporaryNativeStorage? storage; + private TestLegacyExporter legacyExporter = null!; + private TemporaryNativeStorage storage = null!; [SetUp] - public void SetupLegacyExporter() + public void SetUp() { storage = new TemporaryNativeStorage("export-storage"); legacyExporter = new TestLegacyExporter(storage); @@ -24,24 +25,24 @@ namespace osu.Game.Tests.Database [Test] public void ExportFileWithNormalNameTest() { - var exportStorage = storage?.GetStorageForDirectory(@"exports"); + var exportStorage = storage.GetStorageForDirectory(@"exports"); const string filename = "normal file name"; var item = new TestPathInfo(filename); - Assert.That(item.FileName.Length < TestLegacyExporter.GetMaxPath(), Is.True); + Assert.That(item.Filename.Length < TestLegacyExporter.GetMaxPath(), Is.True); exportItemAndAssert(item, exportStorage, filename); } [Test] public void ExportFileWithNormalNameMultipleTimesTest() { - var exportStorage = storage?.GetStorageForDirectory(@"exports"); + var exportStorage = storage.GetStorageForDirectory(@"exports"); const string filename = "normal file name"; var item = new TestPathInfo(filename); - Assert.That(item.FileName.Length < TestLegacyExporter.GetMaxPath(), Is.True); + Assert.That(item.Filename.Length < TestLegacyExporter.GetMaxPath(), Is.True); //Export multiple times for (int i = 0; i < 10; i++) @@ -54,59 +55,65 @@ namespace osu.Game.Tests.Database [Test] public void ExportFileWithSuperLongNameTest() { - var exportStorage = storage?.GetStorageForDirectory(@"exports"); + var exportStorage = storage.GetStorageForDirectory(@"exports"); - const string fullname = "some file with super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name"; + const string fullname = + "some file with super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name"; - int expectedLength = TestLegacyExporter.GetMaxPath() - (legacyExporter?.GetExtension().Length ?? 0); + int expectedLength = TestLegacyExporter.GetMaxPath() - (legacyExporter.GetExtension().Length); string expectedName = fullname.Remove(expectedLength); var item = new TestPathInfo(fullname); - Assert.That(item.FileName.Length > TestLegacyExporter.GetMaxPath(), Is.True); + Assert.That(item.Filename.Length > TestLegacyExporter.GetMaxPath(), Is.True); exportItemAndAssert(item, exportStorage, expectedName); } [Test] public void ExportFileWithSuperLongNameMultipleTimesTest() { - var exportStorage = storage?.GetStorageForDirectory(@"exports"); + var exportStorage = storage.GetStorageForDirectory(@"exports"); - const string fullname = "some file with super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name"; + const string fullname = + "some file with super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name"; - int expectedLength = TestLegacyExporter.GetMaxPath() - (legacyExporter?.GetExtension().Length ?? 0); + int expectedLength = TestLegacyExporter.GetMaxPath() - (legacyExporter.GetExtension().Length); string expectedName = fullname.Remove(expectedLength); var item = new TestPathInfo(fullname); - Assert.That(item.FileName.Length > TestLegacyExporter.GetMaxPath(), Is.True); + Assert.That(item.Filename.Length > TestLegacyExporter.GetMaxPath(), Is.True); //Export multiple times for (int i = 0; i < 10; i++) exportItemAndAssert(item, exportStorage, expectedName); } - private void exportItemAndAssert(IHasNamedFiles item, Storage? exportStorage, string expectedName) + private void exportItemAndAssert(IHasNamedFiles item, Storage exportStorage, string expectedName) { - Assert.DoesNotThrow(() => legacyExporter?.Export(item)); - Assert.That(exportStorage?.Exists($"{expectedName}{legacyExporter?.GetExtension()}"), Is.True); + Assert.DoesNotThrow(() => legacyExporter.Export(item)); + Assert.That(exportStorage.Exists($"{expectedName}{legacyExporter.GetExtension()}"), Is.True); } [TearDown] - public void CleanupAfterTest() + public void TearDown() { - storage?.Dispose(); + if (storage.IsNotNull()) + storage.Dispose(); } private class TestPathInfo : IHasNamedFiles { - public string FileName { get; set; } + public string Filename { get; } - public TestPathInfo(string fileName) => FileName = fileName; + public IEnumerable Files { get; } = new List(); - public IEnumerable Files { get; set; } = new List(); + public TestPathInfo(string filename) + { + Filename = filename; + } - public override string ToString() => FileName; + public override string ToString() => Filename; } private class TestLegacyExporter : LegacyExporter From 96b1498932c4b93126a477cf1acc1b93d11c1b57 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Feb 2023 13:33:22 +0900 Subject: [PATCH 11/84] Rename max length variable to make sense (it's a filename limit, not path) --- osu.Game.Tests/Database/LegacyExporterTest.cs | 14 +++++++------- osu.Game/Database/LegacyExporter.cs | 12 +++++++----- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/osu.Game.Tests/Database/LegacyExporterTest.cs b/osu.Game.Tests/Database/LegacyExporterTest.cs index 803cd40132..6f144ee833 100644 --- a/osu.Game.Tests/Database/LegacyExporterTest.cs +++ b/osu.Game.Tests/Database/LegacyExporterTest.cs @@ -30,7 +30,7 @@ namespace osu.Game.Tests.Database const string filename = "normal file name"; var item = new TestPathInfo(filename); - Assert.That(item.Filename.Length < TestLegacyExporter.GetMaxPath(), Is.True); + Assert.That(item.Filename.Length, Is.LessThan(TestLegacyExporter.GetMaxPathLength())); exportItemAndAssert(item, exportStorage, filename); } @@ -42,7 +42,7 @@ namespace osu.Game.Tests.Database const string filename = "normal file name"; var item = new TestPathInfo(filename); - Assert.That(item.Filename.Length < TestLegacyExporter.GetMaxPath(), Is.True); + Assert.That(item.Filename.Length < TestLegacyExporter.GetMaxPathLength(), Is.True); //Export multiple times for (int i = 0; i < 10; i++) @@ -60,12 +60,12 @@ namespace osu.Game.Tests.Database const string fullname = "some file with super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name"; - int expectedLength = TestLegacyExporter.GetMaxPath() - (legacyExporter.GetExtension().Length); + int expectedLength = TestLegacyExporter.GetMaxPathLength() - (legacyExporter.GetExtension().Length); string expectedName = fullname.Remove(expectedLength); var item = new TestPathInfo(fullname); - Assert.That(item.Filename.Length > TestLegacyExporter.GetMaxPath(), Is.True); + Assert.That(item.Filename.Length > TestLegacyExporter.GetMaxPathLength(), Is.True); exportItemAndAssert(item, exportStorage, expectedName); } @@ -77,12 +77,12 @@ namespace osu.Game.Tests.Database const string fullname = "some file with super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name"; - int expectedLength = TestLegacyExporter.GetMaxPath() - (legacyExporter.GetExtension().Length); + int expectedLength = TestLegacyExporter.GetMaxPathLength() - (legacyExporter.GetExtension().Length); string expectedName = fullname.Remove(expectedLength); var item = new TestPathInfo(fullname); - Assert.That(item.Filename.Length > TestLegacyExporter.GetMaxPath(), Is.True); + Assert.That(item.Filename.Length > TestLegacyExporter.GetMaxPathLength(), Is.True); //Export multiple times for (int i = 0; i < 10; i++) @@ -123,7 +123,7 @@ namespace osu.Game.Tests.Database { } - public static int GetMaxPath() => MAX_PATH; + public static int GetMaxPathLength() => MAX_FILENAME_LENGTH; public string GetExtension() => FileExtension; diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs index 9041f58368..1b74454027 100644 --- a/osu.Game/Database/LegacyExporter.cs +++ b/osu.Game/Database/LegacyExporter.cs @@ -21,12 +21,14 @@ namespace osu.Game.Database where TModel : class, IHasNamedFiles { /// - /// Max length of filename (including extension) + /// Max length of filename (including extension). /// /// - /// This constant is smaller 256 because adds additional "_" to the end of the path + /// TODO: WHY? DOCUMENTATION PER PLATFORM LINKS HERE. + /// + /// This actual usable length is smaller 256 because adds additional "_" to the end of the path /// - protected const int MAX_PATH = 255 - (32 + 4 + 2); //max path - (Guid + Guid "D" format chars + Storage.CreateFileSafely chars) + protected const int MAX_FILENAME_LENGTH = 255 - (32 + 4 + 2); //max path - (Guid + Guid "D" format chars + Storage.CreateFileSafely chars) /// /// The file extension for exports (including the leading '.'). @@ -60,11 +62,11 @@ namespace osu.Game.Database string filename = NamingUtils.GetNextBestFilename(existingExports, $"{itemFilename}{FileExtension}"); - if (filename.Length > MAX_PATH) + if (filename.Length > MAX_FILENAME_LENGTH) { string filenameWithoutExtension = Path.GetFileNameWithoutExtension(filename); - filenameWithoutExtension = filenameWithoutExtension.Remove(MAX_PATH - FileExtension.Length); //Truncating the name to fit the path limit + filenameWithoutExtension = filenameWithoutExtension.Remove(MAX_FILENAME_LENGTH - FileExtension.Length); //Truncating the name to fit the path limit filename = $"{filenameWithoutExtension}{FileExtension}"; } From 8c772a723f0f8ae52cf3141fab286c64c2eba198 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Feb 2023 13:34:19 +0900 Subject: [PATCH 12/84] Expose constant `public`ly rather than reexposing business --- osu.Game/Database/LegacyExporter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs index 1b74454027..7434a46602 100644 --- a/osu.Game/Database/LegacyExporter.cs +++ b/osu.Game/Database/LegacyExporter.cs @@ -28,7 +28,7 @@ namespace osu.Game.Database /// /// This actual usable length is smaller 256 because adds additional "_" to the end of the path /// - protected const int MAX_FILENAME_LENGTH = 255 - (32 + 4 + 2); //max path - (Guid + Guid "D" format chars + Storage.CreateFileSafely chars) + public const int MAX_FILENAME_LENGTH = 255 - (32 + 4 + 2); //max path - (Guid + Guid "D" format chars + Storage.CreateFileSafely chars) /// /// The file extension for exports (including the leading '.'). From 99236f0ae80399d9fade78c7331dff63d59301e4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Feb 2023 13:39:24 +0900 Subject: [PATCH 13/84] Move long filename to fixture level --- osu.Game.Tests/Database/LegacyExporterTest.cs | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/osu.Game.Tests/Database/LegacyExporterTest.cs b/osu.Game.Tests/Database/LegacyExporterTest.cs index 6f144ee833..114872bcf8 100644 --- a/osu.Game.Tests/Database/LegacyExporterTest.cs +++ b/osu.Game.Tests/Database/LegacyExporterTest.cs @@ -15,6 +15,9 @@ namespace osu.Game.Tests.Database private TestLegacyExporter legacyExporter = null!; private TemporaryNativeStorage storage = null!; + private const string long_filename = + "some file with super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name"; + [SetUp] public void SetUp() { @@ -30,7 +33,7 @@ namespace osu.Game.Tests.Database const string filename = "normal file name"; var item = new TestPathInfo(filename); - Assert.That(item.Filename.Length, Is.LessThan(TestLegacyExporter.GetMaxPathLength())); + Assert.That(item.Filename.Length, Is.LessThan(TestLegacyExporter.MAX_FILENAME_LENGTH)); exportItemAndAssert(item, exportStorage, filename); } @@ -42,7 +45,7 @@ namespace osu.Game.Tests.Database const string filename = "normal file name"; var item = new TestPathInfo(filename); - Assert.That(item.Filename.Length < TestLegacyExporter.GetMaxPathLength(), Is.True); + Assert.That(item.Filename.Length < TestLegacyExporter.MAX_FILENAME_LENGTH, Is.True); //Export multiple times for (int i = 0; i < 10; i++) @@ -57,15 +60,12 @@ namespace osu.Game.Tests.Database { var exportStorage = storage.GetStorageForDirectory(@"exports"); - const string fullname = - "some file with super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name"; + int expectedLength = TestLegacyExporter.MAX_FILENAME_LENGTH - (legacyExporter.GetExtension().Length); + string expectedName = long_filename.Remove(expectedLength); - int expectedLength = TestLegacyExporter.GetMaxPathLength() - (legacyExporter.GetExtension().Length); - string expectedName = fullname.Remove(expectedLength); + var item = new TestPathInfo(long_filename); - var item = new TestPathInfo(fullname); - - Assert.That(item.Filename.Length > TestLegacyExporter.GetMaxPathLength(), Is.True); + Assert.That(item.Filename.Length > TestLegacyExporter.MAX_FILENAME_LENGTH, Is.True); exportItemAndAssert(item, exportStorage, expectedName); } @@ -74,15 +74,12 @@ namespace osu.Game.Tests.Database { var exportStorage = storage.GetStorageForDirectory(@"exports"); - const string fullname = - "some file with super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name"; + int expectedLength = TestLegacyExporter.MAX_FILENAME_LENGTH - (legacyExporter.GetExtension().Length); + string expectedName = long_filename.Remove(expectedLength); - int expectedLength = TestLegacyExporter.GetMaxPathLength() - (legacyExporter.GetExtension().Length); - string expectedName = fullname.Remove(expectedLength); + var item = new TestPathInfo(long_filename); - var item = new TestPathInfo(fullname); - - Assert.That(item.Filename.Length > TestLegacyExporter.GetMaxPathLength(), Is.True); + Assert.That(item.Filename.Length > TestLegacyExporter.MAX_FILENAME_LENGTH, Is.True); //Export multiple times for (int i = 0; i < 10; i++) @@ -123,8 +120,6 @@ namespace osu.Game.Tests.Database { } - public static int GetMaxPathLength() => MAX_FILENAME_LENGTH; - public string GetExtension() => FileExtension; protected override string FileExtension => ".ots"; From 4560ae6b026bd1ce575713ccab7d9052f73af40b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Feb 2023 13:39:31 +0900 Subject: [PATCH 14/84] Mark test as fixture --- osu.Game.Tests/Database/LegacyExporterTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Tests/Database/LegacyExporterTest.cs b/osu.Game.Tests/Database/LegacyExporterTest.cs index 114872bcf8..ec20028a2c 100644 --- a/osu.Game.Tests/Database/LegacyExporterTest.cs +++ b/osu.Game.Tests/Database/LegacyExporterTest.cs @@ -10,6 +10,7 @@ using osu.Game.Database; namespace osu.Game.Tests.Database { + [TestFixture] public class LegacyExporterTest { private TestLegacyExporter legacyExporter = null!; From 86d110e893cd2572377c575fc67e5260a1199e27 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Feb 2023 13:43:42 +0900 Subject: [PATCH 15/84] Simplify test storage by removing nested storage --- osu.Game.Tests/Database/LegacyExporterTest.cs | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/osu.Game.Tests/Database/LegacyExporterTest.cs b/osu.Game.Tests/Database/LegacyExporterTest.cs index ec20028a2c..f38ffb7db6 100644 --- a/osu.Game.Tests/Database/LegacyExporterTest.cs +++ b/osu.Game.Tests/Database/LegacyExporterTest.cs @@ -29,20 +29,16 @@ namespace osu.Game.Tests.Database [Test] public void ExportFileWithNormalNameTest() { - var exportStorage = storage.GetStorageForDirectory(@"exports"); - const string filename = "normal file name"; var item = new TestPathInfo(filename); Assert.That(item.Filename.Length, Is.LessThan(TestLegacyExporter.MAX_FILENAME_LENGTH)); - exportItemAndAssert(item, exportStorage, filename); + exportItemAndAssert(item, filename); } [Test] public void ExportFileWithNormalNameMultipleTimesTest() { - var exportStorage = storage.GetStorageForDirectory(@"exports"); - const string filename = "normal file name"; var item = new TestPathInfo(filename); @@ -52,29 +48,25 @@ namespace osu.Game.Tests.Database for (int i = 0; i < 10; i++) { string expectedFileName = i == 0 ? filename : $"{filename} ({i})"; - exportItemAndAssert(item, exportStorage, expectedFileName); + exportItemAndAssert(item, expectedFileName); } } [Test] public void ExportFileWithSuperLongNameTest() { - var exportStorage = storage.GetStorageForDirectory(@"exports"); - int expectedLength = TestLegacyExporter.MAX_FILENAME_LENGTH - (legacyExporter.GetExtension().Length); string expectedName = long_filename.Remove(expectedLength); var item = new TestPathInfo(long_filename); Assert.That(item.Filename.Length > TestLegacyExporter.MAX_FILENAME_LENGTH, Is.True); - exportItemAndAssert(item, exportStorage, expectedName); + exportItemAndAssert(item, expectedName); } [Test] public void ExportFileWithSuperLongNameMultipleTimesTest() { - var exportStorage = storage.GetStorageForDirectory(@"exports"); - int expectedLength = TestLegacyExporter.MAX_FILENAME_LENGTH - (legacyExporter.GetExtension().Length); string expectedName = long_filename.Remove(expectedLength); @@ -84,13 +76,13 @@ namespace osu.Game.Tests.Database //Export multiple times for (int i = 0; i < 10; i++) - exportItemAndAssert(item, exportStorage, expectedName); + exportItemAndAssert(item, expectedName); } - private void exportItemAndAssert(IHasNamedFiles item, Storage exportStorage, string expectedName) + private void exportItemAndAssert(IHasNamedFiles item, string expectedName) { Assert.DoesNotThrow(() => legacyExporter.Export(item)); - Assert.That(exportStorage.Exists($"{expectedName}{legacyExporter.GetExtension()}"), Is.True); + Assert.That(storage.Exists($"exports/{expectedName}{legacyExporter.GetExtension()}"), Is.True); } [TearDown] From 8ef3fb26e056b2c271a690be5539983f6d9d09b0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Feb 2023 13:45:27 +0900 Subject: [PATCH 16/84] More constants and assert fixes --- osu.Game.Tests/Database/LegacyExporterTest.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/osu.Game.Tests/Database/LegacyExporterTest.cs b/osu.Game.Tests/Database/LegacyExporterTest.cs index f38ffb7db6..b8dca6dc7b 100644 --- a/osu.Game.Tests/Database/LegacyExporterTest.cs +++ b/osu.Game.Tests/Database/LegacyExporterTest.cs @@ -16,6 +16,8 @@ namespace osu.Game.Tests.Database private TestLegacyExporter legacyExporter = null!; private TemporaryNativeStorage storage = null!; + private const string short_filename = "normal file name"; + private const string long_filename = "some file with super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name super long name"; @@ -29,25 +31,24 @@ namespace osu.Game.Tests.Database [Test] public void ExportFileWithNormalNameTest() { - const string filename = "normal file name"; - var item = new TestPathInfo(filename); + var item = new TestPathInfo(short_filename); Assert.That(item.Filename.Length, Is.LessThan(TestLegacyExporter.MAX_FILENAME_LENGTH)); - exportItemAndAssert(item, filename); + + exportItemAndAssert(item, short_filename); } [Test] public void ExportFileWithNormalNameMultipleTimesTest() { - const string filename = "normal file name"; - var item = new TestPathInfo(filename); + var item = new TestPathInfo(short_filename); - Assert.That(item.Filename.Length < TestLegacyExporter.MAX_FILENAME_LENGTH, Is.True); + Assert.That(item.Filename.Length, Is.LessThan(TestLegacyExporter.MAX_FILENAME_LENGTH)); //Export multiple times for (int i = 0; i < 10; i++) { - string expectedFileName = i == 0 ? filename : $"{filename} ({i})"; + string expectedFileName = i == 0 ? short_filename : $"{short_filename} ({i})"; exportItemAndAssert(item, expectedFileName); } } @@ -60,7 +61,7 @@ namespace osu.Game.Tests.Database var item = new TestPathInfo(long_filename); - Assert.That(item.Filename.Length > TestLegacyExporter.MAX_FILENAME_LENGTH, Is.True); + Assert.That(item.Filename.Length, Is.GreaterThan(TestLegacyExporter.MAX_FILENAME_LENGTH)); exportItemAndAssert(item, expectedName); } @@ -72,7 +73,7 @@ namespace osu.Game.Tests.Database var item = new TestPathInfo(long_filename); - Assert.That(item.Filename.Length > TestLegacyExporter.MAX_FILENAME_LENGTH, Is.True); + Assert.That(item.Filename.Length, Is.GreaterThan(TestLegacyExporter.MAX_FILENAME_LENGTH)); //Export multiple times for (int i = 0; i < 10; i++) From 372b6b794cae69dc16a882f0caa3b91dcfef0491 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Feb 2023 13:45:43 +0900 Subject: [PATCH 17/84] I don't know what .ots is but let's not use random file extension that make no sense --- osu.Game.Tests/Database/LegacyExporterTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Database/LegacyExporterTest.cs b/osu.Game.Tests/Database/LegacyExporterTest.cs index b8dca6dc7b..c9aea80585 100644 --- a/osu.Game.Tests/Database/LegacyExporterTest.cs +++ b/osu.Game.Tests/Database/LegacyExporterTest.cs @@ -116,7 +116,7 @@ namespace osu.Game.Tests.Database public string GetExtension() => FileExtension; - protected override string FileExtension => ".ots"; + protected override string FileExtension => ".test"; } } } From ceed3606cd7a3b0666c345ea768219ac5e65b91d Mon Sep 17 00:00:00 2001 From: Cootz <50776304+Cootz@users.noreply.github.com> Date: Fri, 17 Feb 2023 13:46:06 +0300 Subject: [PATCH 18/84] Remove redundant comment Co-authored-by: Dean Herbert --- osu.Game/Database/LegacyExporter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs index 7434a46602..7fe0428db3 100644 --- a/osu.Game/Database/LegacyExporter.cs +++ b/osu.Game/Database/LegacyExporter.cs @@ -66,7 +66,7 @@ namespace osu.Game.Database { string filenameWithoutExtension = Path.GetFileNameWithoutExtension(filename); - filenameWithoutExtension = filenameWithoutExtension.Remove(MAX_FILENAME_LENGTH - FileExtension.Length); //Truncating the name to fit the path limit + filenameWithoutExtension = filenameWithoutExtension.Remove(MAX_FILENAME_LENGTH - FileExtension.Length); filename = $"{filenameWithoutExtension}{FileExtension}"; } From a3b440493aeae5fc3fbea99e36be28758c8fe2ba Mon Sep 17 00:00:00 2001 From: Cootz Date: Fri, 17 Feb 2023 15:23:43 +0300 Subject: [PATCH 19/84] Update xml doc --- osu.Game/Database/LegacyExporter.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs index 7fe0428db3..2d0a1d3528 100644 --- a/osu.Game/Database/LegacyExporter.cs +++ b/osu.Game/Database/LegacyExporter.cs @@ -24,9 +24,18 @@ namespace osu.Game.Database /// Max length of filename (including extension). /// /// - /// TODO: WHY? DOCUMENTATION PER PLATFORM LINKS HERE. - /// - /// This actual usable length is smaller 256 because adds additional "_" to the end of the path + /// + /// Filename limit for most OSs is 255, this actual usable length is smaller because adds additional "_" to the end of the path. + /// + /// + /// For more information see: + ///
+ /// File specification syntax + ///
+ ///
+ /// File systems limitations + ///
+ ///
///
public const int MAX_FILENAME_LENGTH = 255 - (32 + 4 + 2); //max path - (Guid + Guid "D" format chars + Storage.CreateFileSafely chars) From fd1beaef87ef2156b5f5e56bf6d1656ece326a16 Mon Sep 17 00:00:00 2001 From: Cootz Date: Fri, 17 Feb 2023 15:24:27 +0300 Subject: [PATCH 20/84] Fix typo --- osu.Game/Database/LegacyExporter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs index 2d0a1d3528..04d5a3aebc 100644 --- a/osu.Game/Database/LegacyExporter.cs +++ b/osu.Game/Database/LegacyExporter.cs @@ -25,7 +25,7 @@ namespace osu.Game.Database ///
/// /// - /// Filename limit for most OSs is 255, this actual usable length is smaller because adds additional "_" to the end of the path. + /// The filename limit for most OSs is 255. This actual usable length is smaller because adds an additional "_" to the end of the path. /// /// /// For more information see: From e3bdb3d852a85748032ea468d1763849aee74249 Mon Sep 17 00:00:00 2001 From: Cootz Date: Fri, 17 Feb 2023 15:32:36 +0300 Subject: [PATCH 21/84] Align links in one line --- osu.Game/Database/LegacyExporter.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs index 04d5a3aebc..cf88efb151 100644 --- a/osu.Game/Database/LegacyExporter.cs +++ b/osu.Game/Database/LegacyExporter.cs @@ -28,13 +28,7 @@ namespace osu.Game.Database /// The filename limit for most OSs is 255. This actual usable length is smaller because adds an additional "_" to the end of the path. /// /// - /// For more information see: - ///
- /// File specification syntax - ///
- ///
- /// File systems limitations - ///
+ /// For more information see file specification syntax, file systems limitations ///
///
public const int MAX_FILENAME_LENGTH = 255 - (32 + 4 + 2); //max path - (Guid + Guid "D" format chars + Storage.CreateFileSafely chars) From 90aa4288d0a9a265d666c8e66545108bce4d8edd Mon Sep 17 00:00:00 2001 From: Cootz Date: Tue, 21 Feb 2023 18:35:53 +0300 Subject: [PATCH 22/84] Reduce the allowed length by 5 to account for (99) suffix. Move truncating logic to `GetFilename`. Update tests. --- osu.Game.Tests/Database/LegacyExporterTest.cs | 9 ++++++--- osu.Game/Database/LegacyExporter.cs | 20 +++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/osu.Game.Tests/Database/LegacyExporterTest.cs b/osu.Game.Tests/Database/LegacyExporterTest.cs index c9aea80585..d41b3a5017 100644 --- a/osu.Game.Tests/Database/LegacyExporterTest.cs +++ b/osu.Game.Tests/Database/LegacyExporterTest.cs @@ -46,7 +46,7 @@ namespace osu.Game.Tests.Database Assert.That(item.Filename.Length, Is.LessThan(TestLegacyExporter.MAX_FILENAME_LENGTH)); //Export multiple times - for (int i = 0; i < 10; i++) + for (int i = 0; i < 100; i++) { string expectedFileName = i == 0 ? short_filename : $"{short_filename} ({i})"; exportItemAndAssert(item, expectedFileName); @@ -76,8 +76,11 @@ namespace osu.Game.Tests.Database Assert.That(item.Filename.Length, Is.GreaterThan(TestLegacyExporter.MAX_FILENAME_LENGTH)); //Export multiple times - for (int i = 0; i < 10; i++) - exportItemAndAssert(item, expectedName); + for (int i = 0; i < 100; i++) + { + string expectedFilename = i == 0 ? expectedName : $"{expectedName} ({i})"; + exportItemAndAssert(item, expectedFilename); + } } private void exportItemAndAssert(IHasNamedFiles item, string expectedName) diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs index cf88efb151..0fa7b9e03c 100644 --- a/osu.Game/Database/LegacyExporter.cs +++ b/osu.Game/Database/LegacyExporter.cs @@ -31,7 +31,7 @@ namespace osu.Game.Database /// For more information see file specification syntax, file systems limitations /// /// - public const int MAX_FILENAME_LENGTH = 255 - (32 + 4 + 2); //max path - (Guid + Guid "D" format chars + Storage.CreateFileSafely chars) + public const int MAX_FILENAME_LENGTH = 255 - (32 + 4 + 2 + 5); //max path - (Guid + Guid "D" format chars + Storage.CreateFileSafely chars + account for ' (99)' suffix) /// /// The file extension for exports (including the leading '.'). @@ -48,7 +48,15 @@ namespace osu.Game.Database UserFileStorage = storage.GetStorageForDirectory(@"files"); } - protected virtual string GetFilename(TModel item) => item.GetDisplayString(); + protected virtual string GetFilename(TModel item) + { + string filename = item.GetDisplayString(); + + if (filename.Length > MAX_FILENAME_LENGTH - FileExtension.Length) + return filename.Remove(MAX_FILENAME_LENGTH - FileExtension.Length); + + return filename; + } /// /// Exports an item to a legacy (.zip based) package. @@ -65,14 +73,6 @@ namespace osu.Game.Database string filename = NamingUtils.GetNextBestFilename(existingExports, $"{itemFilename}{FileExtension}"); - if (filename.Length > MAX_FILENAME_LENGTH) - { - string filenameWithoutExtension = Path.GetFileNameWithoutExtension(filename); - - filenameWithoutExtension = filenameWithoutExtension.Remove(MAX_FILENAME_LENGTH - FileExtension.Length); - filename = $"{filenameWithoutExtension}{FileExtension}"; - } - using (var stream = exportStorage.CreateFileSafely(filename)) ExportModelTo(item, stream); From fc3d74472cc52b6e06cd1c0791f7277d7ed77744 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Tue, 21 Feb 2023 15:55:46 +0300 Subject: [PATCH 23/84] Add mobile local framework reference support --- UseLocalFramework.ps1 | 48 ++++++++++++++++++++++++++++++++++++++----- UseLocalFramework.sh | 39 +++++++++++++++++++++++++++++------ 2 files changed, 76 insertions(+), 11 deletions(-) diff --git a/UseLocalFramework.ps1 b/UseLocalFramework.ps1 index 837685f310..9f4547d980 100644 --- a/UseLocalFramework.ps1 +++ b/UseLocalFramework.ps1 @@ -3,15 +3,53 @@ # # https://github.com/ppy/osu-framework/wiki/Testing-local-framework-checkout-with-other-projects -$CSPROJ="osu.Game/osu.Game.csproj" +$GAME_CSPROJ="osu.Game/osu.Game.csproj" +$ANDROID_PROPS="osu.Android.props" +$IOS_PROPS="osu.iOS.props" $SLN="osu.sln" -dotnet remove $CSPROJ package ppy.osu.Framework; -dotnet sln $SLN add ../osu-framework/osu.Framework/osu.Framework.csproj ../osu-framework/osu.Framework.NativeLibs/osu.Framework.NativeLibs.csproj; -dotnet add $CSPROJ reference ../osu-framework/osu.Framework/osu.Framework.csproj +dotnet remove $GAME_CSPROJ reference ppy.osu.Framework; +dotnet remove $ANDROID_PROPS reference ppy.osu.Framework.Android; +dotnet remove $IOS_PROPS reference ppy.osu.Framework.iOS; + +dotnet sln $SLN add ../osu-framework/osu.Framework/osu.Framework.csproj ` + ../osu-framework/osu.Framework.NativeLibs/osu.Framework.NativeLibs.csproj ` + ../osu-framework/osu.Framework.Android/osu.Framework.Android.csproj ` + ../osu-framework/osu.Framework.iOS/osu.Framework.iOS.csproj; + +dotnet add $GAME_CSPROJ reference ../osu-framework/osu.Framework/osu.Framework.csproj; +dotnet add $ANDROID_PROPS reference ../osu-framework/osu.Framework.Android/osu.Framework.Android.csproj; +dotnet add $IOS_PROPS reference ../osu-framework/osu.Framework.iOS/osu.Framework.iOS.csproj; + +# workaround for dotnet add not inserting $(MSBuildThisFileDirectory) on props files +(Get-Content "osu.Android.props") -replace "`"..\\osu-framework", "`"`$(MSBuildThisFileDirectory)..\osu-framework" | Set-Content "osu.Android.props" +(Get-Content "osu.iOS.props") -replace "`"..\\osu-framework", "`"`$(MSBuildThisFileDirectory)..\osu-framework" | Set-Content "osu.iOS.props" + +# needed because iOS framework nupkg includes a set of properties to work around certain issues during building, +# and those get ignored when referencing framework via project, threfore we have to manually include it via props reference. +(Get-Content "osu.iOS.props") | + Foreach-Object { + if ($_ -match "") + { + " " + } + + $_ + } | Set-Content "osu.iOS.props" + +$TMP=New-TemporaryFile $SLNF=Get-Content "osu.Desktop.slnf" | ConvertFrom-Json -$TMP=New-TemporaryFile $SLNF.solution.projects += ("../osu-framework/osu.Framework/osu.Framework.csproj", "../osu-framework/osu.Framework.NativeLibs/osu.Framework.NativeLibs.csproj") ConvertTo-Json $SLNF | Out-File $TMP -Encoding UTF8 Move-Item -Path $TMP -Destination "osu.Desktop.slnf" -Force + +$SLNF=Get-Content "osu.Android.slnf" | ConvertFrom-Json +$SLNF.solution.projects += ("../osu-framework/osu.Framework/osu.Framework.csproj", "../osu-framework/osu.Framework.NativeLibs/osu.Framework.NativeLibs.csproj", "../osu-framework/osu.Framework.Android/osu.Framework.Android.csproj") +ConvertTo-Json $SLNF | Out-File $TMP -Encoding UTF8 +Move-Item -Path $TMP -Destination "osu.Android.slnf" -Force + +$SLNF=Get-Content "osu.iOS.slnf" | ConvertFrom-Json +$SLNF.solution.projects += ("../osu-framework/osu.Framework/osu.Framework.csproj", "../osu-framework/osu.Framework.NativeLibs/osu.Framework.NativeLibs.csproj", "../osu-framework/osu.Framework.iOS/osu.Framework.iOS.csproj") +ConvertTo-Json $SLNF | Out-File $TMP -Encoding UTF8 +Move-Item -Path $TMP -Destination "osu.iOS.slnf" -Force diff --git a/UseLocalFramework.sh b/UseLocalFramework.sh index 4fd1fdfd1b..c12b388e96 100755 --- a/UseLocalFramework.sh +++ b/UseLocalFramework.sh @@ -5,14 +5,41 @@ # # https://github.com/ppy/osu-framework/wiki/Testing-local-framework-checkout-with-other-projects -CSPROJ="osu.Game/osu.Game.csproj" +GAME_CSPROJ="osu.Game/osu.Game.csproj" +ANDROID_PROPS="osu.Android.props" +IOS_PROPS="osu.iOS.props" SLN="osu.sln" -dotnet remove $CSPROJ package ppy.osu.Framework -dotnet sln $SLN add ../osu-framework/osu.Framework/osu.Framework.csproj ../osu-framework/osu.Framework.NativeLibs/osu.Framework.NativeLibs.csproj -dotnet add $CSPROJ reference ../osu-framework/osu.Framework/osu.Framework.csproj +dotnet remove $GAME_CSPROJ reference ppy.osu.Framework +dotnet remove $ANDROID_PROPS reference ppy.osu.Framework.Android +dotnet remove $IOS_PROPS reference ppy.osu.Framework.iOS + +dotnet sln $SLN add ../osu-framework/osu.Framework/osu.Framework.csproj \ + ../osu-framework/osu.Framework.NativeLibs/osu.Framework.NativeLibs.csproj \ + ../osu-framework/osu.Framework.Android/osu.Framework.Android.csproj \ + ../osu-framework/osu.Framework.iOS/osu.Framework.iOS.csproj + +dotnet add $GAME_CSPROJ reference ../osu-framework/osu.Framework/osu.Framework.csproj +dotnet add $ANDROID_PROPS reference ../osu-framework/osu.Framework.Android/osu.Framework.Android.csproj +dotnet add $IOS_PROPS reference ../osu-framework/osu.Framework.iOS/osu.Framework.iOS.csproj + +# workaround for dotnet add not inserting $(MSBuildThisFileDirectory) on props files +sed -i.bak 's:"..\\osu-framework:"$(MSBuildThisFileDirectory)..\\osu-framework:g' ./osu.Android.props && rm osu.Android.props.bak +sed -i.bak 's:"..\\osu-framework:"$(MSBuildThisFileDirectory)..\\osu-framework:g' ./osu.iOS.props && rm osu.iOS.props.bak + +# needed because iOS framework nupkg includes a set of properties to work around certain issues during building, +# and those get ignored when referencing framework via project, threfore we have to manually include it via props reference. +sed -i.bak '/<\/Project>/i\ + \ +' ./osu.iOS.props && rm osu.iOS.props.bak -SLNF="osu.Desktop.slnf" tmp=$(mktemp) + jq '.solution.projects += ["../osu-framework/osu.Framework/osu.Framework.csproj", "../osu-framework/osu.Framework.NativeLibs/osu.Framework.NativeLibs.csproj"]' osu.Desktop.slnf > $tmp -mv -f $tmp $SLNF +mv -f $tmp osu.Desktop.slnf + +jq '.solution.projects += ["../osu-framework/osu.Framework/osu.Framework.csproj", "../osu-framework/osu.Framework.NativeLibs/osu.Framework.NativeLibs.csproj", "../osu-framework/osu.Framework.Android/osu.Framework.Android.csproj"]' osu.Android.slnf > $tmp +mv -f $tmp osu.Android.slnf + +jq '.solution.projects += ["../osu-framework/osu.Framework/osu.Framework.csproj", "../osu-framework/osu.Framework.NativeLibs/osu.Framework.NativeLibs.csproj", "../osu-framework/osu.Framework.iOS/osu.Framework.iOS.csproj"]' osu.iOS.slnf > $tmp +mv -f $tmp osu.iOS.slnf From ff0d1aa9f704560a96f6a3f1d048d44f70e33af8 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Sun, 26 Feb 2023 20:38:50 +0100 Subject: [PATCH 24/84] Make reverting changes to a given skin into a "dangerous action" --- osu.Game/Localisation/SkinEditorStrings.cs | 12 +++++++- osu.Game/Overlays/SkinEditor/SkinEditor.cs | 32 +++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/osu.Game/Localisation/SkinEditorStrings.cs b/osu.Game/Localisation/SkinEditorStrings.cs index 5cf2e5b5c5..029d50df32 100644 --- a/osu.Game/Localisation/SkinEditorStrings.cs +++ b/osu.Game/Localisation/SkinEditorStrings.cs @@ -42,7 +42,17 @@ namespace osu.Game.Localisation /// /// "Currently editing" /// - public static LocalisableString CurrentlyEditing => new TranslatableString(getKey(@"currently_editing"), "Currently editing"); + public static LocalisableString CurrentlyEditing => new TranslatableString(getKey(@"currently_editing"), @"Currently editing"); + + /// + /// "Revert?" + /// + public static LocalisableString Revert => new TranslatableString(getKey(@"revert"), @"Revert?"); + + /// + /// "The skin will return to the state it was in upon import" + /// + public static LocalisableString ResetDialogue => new TranslatableString(getKey(@"the_skin_will_return_to"), @"The skin will return to the state it was in upon import"); private static string getKey(string key) => $@"{prefix}:{key}"; } diff --git a/osu.Game/Overlays/SkinEditor/SkinEditor.cs b/osu.Game/Overlays/SkinEditor/SkinEditor.cs index 9d470f58f1..936dc7fa84 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditor.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditor.cs @@ -12,11 +12,13 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Framework.Localisation; +using web = osu.Game.Resources.Localisation.Web; using osu.Framework.Testing; using osu.Game.Database; using osu.Game.Graphics; @@ -24,6 +26,7 @@ using osu.Game.Graphics.Containers; using osu.Game.Graphics.Cursor; using osu.Game.Graphics.UserInterface; using osu.Game.Localisation; +using osu.Game.Overlays.Dialog; using osu.Game.Overlays.OSD; using osu.Game.Overlays.Settings; using osu.Game.Screens.Edit; @@ -97,6 +100,9 @@ namespace osu.Game.Overlays.SkinEditor [Resolved] private OnScreenDisplay? onScreenDisplay { get; set; } + [Resolved] + private IDialogOverlay? dialogOverlay { get; set; } + public SkinEditor() { } @@ -148,7 +154,7 @@ namespace osu.Game.Overlays.SkinEditor Items = new[] { new EditorMenuItem(Resources.Localisation.Web.CommonStrings.ButtonsSave, MenuItemType.Standard, () => Save()), - new EditorMenuItem(CommonStrings.RevertToDefault, MenuItemType.Destructive, revert), + new EditorMenuItem(CommonStrings.RevertToDefault, MenuItemType.Destructive, () => dialogOverlay?.Push(new ResetConfirmDialog(revert))), new EditorMenuItemSpacer(), new EditorMenuItem(CommonStrings.Exit, MenuItemType.Standard, () => skinEditorOverlay?.Hide()), }, @@ -625,6 +631,30 @@ namespace osu.Game.Overlays.SkinEditor } } + public partial class ResetConfirmDialog : PopupDialog + { + public ResetConfirmDialog(Action reset) + { + HeaderText = SkinEditorStrings.Revert; + BodyText = SkinEditorStrings.ResetDialogue; + + Icon = FontAwesome.Solid.ExclamationTriangle; + + Buttons = new PopupDialogButton[] + { + new PopupDialogDangerousButton + { + Text = BeatmapOverlayStrings.UserContentConfirmButtonText, + Action = reset + }, + new PopupDialogCancelButton + { + Text = web.CommonStrings.ButtonsCancel, + }, + }; + } + } + #region Delegation of IEditorChangeHandler public event Action? OnStateChange From d98d330da20e2bced3a4d753f40c6a50f614f926 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sun, 26 Feb 2023 14:30:46 -0800 Subject: [PATCH 25/84] Add expected behavior test for scroll back to previous position --- .../TestSceneOverlayScrollContainer.cs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayScrollContainer.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayScrollContainer.cs index 926bc01aea..ade950e2d5 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayScrollContainer.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayScrollContainer.cs @@ -61,6 +61,18 @@ namespace osu.Game.Tests.Visual.UserInterface AddStep("scroll to 500", () => scroll.ScrollTo(500)); AddUntilStep("scrolled to 500", () => Precision.AlmostEquals(scroll.Current, 500, 0.1f)); AddAssert("button is visible", () => scroll.Button.State == Visibility.Visible); + + AddStep("click button", () => + { + InputManager.MoveMouseTo(scroll.Button); + InputManager.Click(MouseButton.Left); + }); + + AddAssert("button is visible", () => scroll.Button.State == Visibility.Visible); + + AddStep("user scroll down by 1", () => InputManager.ScrollVerticalBy(-1)); + + AddAssert("button is hidden", () => scroll.Button.State == Visibility.Hidden); } [Test] @@ -71,6 +83,10 @@ namespace osu.Game.Tests.Visual.UserInterface AddStep("invoke action", () => scroll.Button.Action.Invoke()); AddUntilStep("scrolled back to start", () => Precision.AlmostEquals(scroll.Current, 0, 0.1f)); + + AddStep("invoke action", () => scroll.Button.Action.Invoke()); + + AddAssert("scrolled to end", () => scroll.IsScrolledToEnd()); } [Test] @@ -85,6 +101,14 @@ namespace osu.Game.Tests.Visual.UserInterface }); AddUntilStep("scrolled back to start", () => Precision.AlmostEquals(scroll.Current, 0, 0.1f)); + + AddStep("click button", () => + { + InputManager.MoveMouseTo(scroll.Button); + InputManager.Click(MouseButton.Left); + }); + + AddAssert("scrolled to end", () => scroll.IsScrolledToEnd()); } [Test] @@ -97,7 +121,7 @@ namespace osu.Game.Tests.Visual.UserInterface AddStep("hover button", () => InputManager.MoveMouseTo(scroll.Button)); AddRepeatStep("click button", () => InputManager.Click(MouseButton.Left), 3); - AddAssert("invocation count is 1", () => invocationCount == 1); + AddAssert("invocation count is 3", () => invocationCount == 3); } private partial class TestScrollContainer : OverlayScrollContainer From dc00905f8df0b24f974315a7efdac099373f09eb Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sun, 26 Feb 2023 14:38:51 -0800 Subject: [PATCH 26/84] Add ability to scroll back to previous position after scrolling to top via button on overlays --- osu.Game/Overlays/OverlayScrollContainer.cs | 50 +++++++++++++++++---- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/osu.Game/Overlays/OverlayScrollContainer.cs b/osu.Game/Overlays/OverlayScrollContainer.cs index 5bd7f014a9..8176ddb370 100644 --- a/osu.Game/Overlays/OverlayScrollContainer.cs +++ b/osu.Game/Overlays/OverlayScrollContainer.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -30,16 +31,20 @@ namespace osu.Game.Overlays /// private const int button_scroll_position = 200; - protected readonly ScrollToTopButton Button; + protected ScrollToTopButton Button; - public OverlayScrollContainer() + private readonly Bindable lastScrollTarget = new Bindable(); + + [BackgroundDependencyLoader] + private void load() { AddInternal(Button = new ScrollToTopButton { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, Margin = new MarginPadding(20), - Action = scrollToTop + Action = scrollBack, + LastScrollTarget = { BindTarget = lastScrollTarget } }); } @@ -53,13 +58,28 @@ namespace osu.Game.Overlays return; } - Button.State = Target > button_scroll_position ? Visibility.Visible : Visibility.Hidden; + Button.State = Target > button_scroll_position || lastScrollTarget.Value != null ? Visibility.Visible : Visibility.Hidden; } - private void scrollToTop() + protected override void OnUserScroll(float value, bool animated = true, double? distanceDecay = default) { - ScrollToStart(); - Button.State = Visibility.Hidden; + base.OnUserScroll(value, animated, distanceDecay); + + lastScrollTarget.Value = null; + } + + private void scrollBack() + { + if (lastScrollTarget.Value == null) + { + lastScrollTarget.Value = Target; + ScrollToStart(); + } + else + { + ScrollTo(lastScrollTarget.Value.Value); + lastScrollTarget.Value = null; + } } public partial class ScrollToTopButton : OsuHoverContainer @@ -88,6 +108,9 @@ namespace osu.Game.Overlays private readonly Container content; private readonly Box background; + private readonly SpriteIcon spriteIcon; + + public Bindable LastScrollTarget = new Bindable(); public ScrollToTopButton() : base(HoverSampleSet.ScrollToTop) @@ -113,7 +136,7 @@ namespace osu.Game.Overlays { RelativeSizeAxes = Axes.Both }, - new SpriteIcon + spriteIcon = new SpriteIcon { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -134,6 +157,17 @@ namespace osu.Game.Overlays flashColour = colourProvider.Light1; } + protected override void LoadComplete() + { + base.LoadComplete(); + + LastScrollTarget.BindValueChanged(target => + { + spriteIcon.RotateTo(target.NewValue != null ? 180 : 0, fade_duration, Easing.OutQuint); + TooltipText = target.NewValue != null ? CommonStrings.ButtonsBackToPrevious : CommonStrings.ButtonsBackToTop; + }, true); + } + protected override bool OnClick(ClickEvent e) { background.FlashColour(flashColour, 800, Easing.OutQuint); From fa710ae1b00dd9f618e481271b25aa2df5d558a4 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sun, 26 Feb 2023 14:39:34 -0800 Subject: [PATCH 27/84] Rename `ScrollToTopButton` to `ScrollBackButton` --- .../UserInterface/TestSceneOverlayScrollContainer.cs | 2 +- osu.Game/Overlays/OverlayScrollContainer.cs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayScrollContainer.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayScrollContainer.cs index ade950e2d5..77e7178c9e 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayScrollContainer.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayScrollContainer.cs @@ -126,7 +126,7 @@ namespace osu.Game.Tests.Visual.UserInterface private partial class TestScrollContainer : OverlayScrollContainer { - public new ScrollToTopButton Button => base.Button; + public new ScrollBackButton Button => base.Button; } } } diff --git a/osu.Game/Overlays/OverlayScrollContainer.cs b/osu.Game/Overlays/OverlayScrollContainer.cs index 8176ddb370..9752e04f44 100644 --- a/osu.Game/Overlays/OverlayScrollContainer.cs +++ b/osu.Game/Overlays/OverlayScrollContainer.cs @@ -22,23 +22,23 @@ using osuTK.Graphics; namespace osu.Game.Overlays { /// - /// which provides . Mostly used in . + /// which provides . Mostly used in . /// public partial class OverlayScrollContainer : UserTrackingScrollContainer { /// - /// Scroll position at which the will be shown. + /// Scroll position at which the will be shown. /// private const int button_scroll_position = 200; - protected ScrollToTopButton Button; + protected ScrollBackButton Button; private readonly Bindable lastScrollTarget = new Bindable(); [BackgroundDependencyLoader] private void load() { - AddInternal(Button = new ScrollToTopButton + AddInternal(Button = new ScrollBackButton { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, @@ -82,7 +82,7 @@ namespace osu.Game.Overlays } } - public partial class ScrollToTopButton : OsuHoverContainer + public partial class ScrollBackButton : OsuHoverContainer { private const int fade_duration = 500; @@ -112,7 +112,7 @@ namespace osu.Game.Overlays public Bindable LastScrollTarget = new Bindable(); - public ScrollToTopButton() + public ScrollBackButton() : base(HoverSampleSet.ScrollToTop) { Size = new Vector2(50); From bf1897a98fc5d215c9c75a1faffba4d853bf4b9e Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Mon, 27 Feb 2023 16:08:14 +0100 Subject: [PATCH 28/84] Adjust warning text slightly. --- osu.Game/Localisation/SkinEditorStrings.cs | 4 ++-- osu.Game/Overlays/SkinEditor/SkinEditor.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Localisation/SkinEditorStrings.cs b/osu.Game/Localisation/SkinEditorStrings.cs index 029d50df32..b83a105c14 100644 --- a/osu.Game/Localisation/SkinEditorStrings.cs +++ b/osu.Game/Localisation/SkinEditorStrings.cs @@ -45,9 +45,9 @@ namespace osu.Game.Localisation public static LocalisableString CurrentlyEditing => new TranslatableString(getKey(@"currently_editing"), @"Currently editing"); /// - /// "Revert?" + /// "Revert to default?" /// - public static LocalisableString Revert => new TranslatableString(getKey(@"revert"), @"Revert?"); + public static LocalisableString RevertToDefault => new TranslatableString(getKey(@"revert_to_default"), @"Revert to default?"); /// /// "The skin will return to the state it was in upon import" diff --git a/osu.Game/Overlays/SkinEditor/SkinEditor.cs b/osu.Game/Overlays/SkinEditor/SkinEditor.cs index 936dc7fa84..7661abc551 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditor.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditor.cs @@ -635,7 +635,7 @@ namespace osu.Game.Overlays.SkinEditor { public ResetConfirmDialog(Action reset) { - HeaderText = SkinEditorStrings.Revert; + HeaderText = SkinEditorStrings.RevertToDefault; BodyText = SkinEditorStrings.ResetDialogue; Icon = FontAwesome.Solid.ExclamationTriangle; From 1239de6f41fd36b0fca8d3e41708e0f8095d30fd Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Mon, 27 Feb 2023 21:34:07 +0100 Subject: [PATCH 29/84] Upper case web `using` alias --- osu.Game/Overlays/SkinEditor/SkinEditor.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinEditor.cs b/osu.Game/Overlays/SkinEditor/SkinEditor.cs index 7661abc551..53669e9f9c 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditor.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditor.cs @@ -18,7 +18,7 @@ using osu.Framework.Input; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Framework.Localisation; -using web = osu.Game.Resources.Localisation.Web; +using Web = osu.Game.Resources.Localisation.Web; using osu.Framework.Testing; using osu.Game.Database; using osu.Game.Graphics; @@ -153,7 +153,7 @@ namespace osu.Game.Overlays.SkinEditor { Items = new[] { - new EditorMenuItem(Resources.Localisation.Web.CommonStrings.ButtonsSave, MenuItemType.Standard, () => Save()), + new EditorMenuItem(Web.CommonStrings.ButtonsSave, MenuItemType.Standard, () => Save()), new EditorMenuItem(CommonStrings.RevertToDefault, MenuItemType.Destructive, () => dialogOverlay?.Push(new ResetConfirmDialog(revert))), new EditorMenuItemSpacer(), new EditorMenuItem(CommonStrings.Exit, MenuItemType.Standard, () => skinEditorOverlay?.Hide()), @@ -649,7 +649,7 @@ namespace osu.Game.Overlays.SkinEditor }, new PopupDialogCancelButton { - Text = web.CommonStrings.ButtonsCancel, + Text = Web.CommonStrings.ButtonsCancel, }, }; } From 00a00ead225c8426e83582a88969cb2e39418ebc Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Mon, 27 Feb 2023 21:50:27 +0100 Subject: [PATCH 30/84] Make `ResetConfirmDialog` inherit from `DeleteConfirmationDialog` --- osu.Game/Overlays/SkinEditor/SkinEditor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinEditor.cs b/osu.Game/Overlays/SkinEditor/SkinEditor.cs index 53669e9f9c..bab5344e1e 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditor.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditor.cs @@ -631,7 +631,7 @@ namespace osu.Game.Overlays.SkinEditor } } - public partial class ResetConfirmDialog : PopupDialog + public partial class ResetConfirmDialog : DeleteConfirmationDialog { public ResetConfirmDialog(Action reset) { From 90227a64966383e7a313132d339c84c434ad8be0 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Mon, 27 Feb 2023 21:57:59 +0100 Subject: [PATCH 31/84] Rename `DeleteConfirmationDialog.cs` into `DangerousActionDialog.cs` --- osu.Game/Collections/DeleteCollectionDialog.cs | 2 +- .../{DeleteConfirmationDialog.cs => DangerousActionDialog.cs} | 4 ++-- osu.Game/Overlays/Mods/DeleteModPresetDialog.cs | 2 +- .../Sections/Maintenance/MassDeleteConfirmationDialog.cs | 2 +- osu.Game/Overlays/SkinEditor/SkinEditor.cs | 2 +- osu.Game/Screens/Edit/DeleteDifficultyConfirmationDialog.cs | 2 +- osu.Game/Screens/Select/BeatmapClearScoresDialog.cs | 2 +- osu.Game/Screens/Select/BeatmapDeleteDialog.cs | 2 +- .../Screens/Select/Carousel/UpdateLocalConfirmationDialog.cs | 2 +- osu.Game/Screens/Select/LocalScoreDeleteDialog.cs | 2 +- osu.Game/Screens/Select/SkinDeleteDialog.cs | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) rename osu.Game/Overlays/Dialog/{DeleteConfirmationDialog.cs => DangerousActionDialog.cs} (91%) diff --git a/osu.Game/Collections/DeleteCollectionDialog.cs b/osu.Game/Collections/DeleteCollectionDialog.cs index 4b23f661f9..4da2979481 100644 --- a/osu.Game/Collections/DeleteCollectionDialog.cs +++ b/osu.Game/Collections/DeleteCollectionDialog.cs @@ -8,7 +8,7 @@ using osu.Game.Overlays.Dialog; namespace osu.Game.Collections { - public partial class DeleteCollectionDialog : DeleteConfirmationDialog + public partial class DeleteCollectionDialog : DangerousActionDialog { public DeleteCollectionDialog(Live collection, Action deleteAction) { diff --git a/osu.Game/Overlays/Dialog/DeleteConfirmationDialog.cs b/osu.Game/Overlays/Dialog/DangerousActionDialog.cs similarity index 91% rename from osu.Game/Overlays/Dialog/DeleteConfirmationDialog.cs rename to osu.Game/Overlays/Dialog/DangerousActionDialog.cs index ddb59c4c9e..aaec72fc4d 100644 --- a/osu.Game/Overlays/Dialog/DeleteConfirmationDialog.cs +++ b/osu.Game/Overlays/Dialog/DangerousActionDialog.cs @@ -12,14 +12,14 @@ namespace osu.Game.Overlays.Dialog /// Differs from in that the confirmation button is a "dangerous" one /// (requires the confirm button to be held). /// - public abstract partial class DeleteConfirmationDialog : PopupDialog + public abstract partial class DangerousActionDialog : PopupDialog { /// /// The action which performs the deletion. /// protected Action? DeleteAction { get; set; } - protected DeleteConfirmationDialog() + protected DangerousActionDialog() { HeaderText = DeleteConfirmationDialogStrings.HeaderText; diff --git a/osu.Game/Overlays/Mods/DeleteModPresetDialog.cs b/osu.Game/Overlays/Mods/DeleteModPresetDialog.cs index 800ebe8b4e..5b329a32d5 100644 --- a/osu.Game/Overlays/Mods/DeleteModPresetDialog.cs +++ b/osu.Game/Overlays/Mods/DeleteModPresetDialog.cs @@ -7,7 +7,7 @@ using osu.Game.Rulesets.Mods; namespace osu.Game.Overlays.Mods { - public partial class DeleteModPresetDialog : DeleteConfirmationDialog + public partial class DeleteModPresetDialog : DangerousActionDialog { public DeleteModPresetDialog(Live modPreset) { diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/MassDeleteConfirmationDialog.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/MassDeleteConfirmationDialog.cs index 948d646e3d..71226803c8 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/MassDeleteConfirmationDialog.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/MassDeleteConfirmationDialog.cs @@ -6,7 +6,7 @@ using osu.Game.Overlays.Dialog; namespace osu.Game.Overlays.Settings.Sections.Maintenance { - public partial class MassDeleteConfirmationDialog : DeleteConfirmationDialog + public partial class MassDeleteConfirmationDialog : DangerousActionDialog { public MassDeleteConfirmationDialog(Action deleteAction) { diff --git a/osu.Game/Overlays/SkinEditor/SkinEditor.cs b/osu.Game/Overlays/SkinEditor/SkinEditor.cs index bab5344e1e..770a3c5930 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditor.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditor.cs @@ -631,7 +631,7 @@ namespace osu.Game.Overlays.SkinEditor } } - public partial class ResetConfirmDialog : DeleteConfirmationDialog + public partial class ResetConfirmDialog : DangerousActionDialog { public ResetConfirmDialog(Action reset) { diff --git a/osu.Game/Screens/Edit/DeleteDifficultyConfirmationDialog.cs b/osu.Game/Screens/Edit/DeleteDifficultyConfirmationDialog.cs index 68a0ef4250..6db31967d6 100644 --- a/osu.Game/Screens/Edit/DeleteDifficultyConfirmationDialog.cs +++ b/osu.Game/Screens/Edit/DeleteDifficultyConfirmationDialog.cs @@ -7,7 +7,7 @@ using osu.Game.Overlays.Dialog; namespace osu.Game.Screens.Edit { - public partial class DeleteDifficultyConfirmationDialog : DeleteConfirmationDialog + public partial class DeleteDifficultyConfirmationDialog : DangerousActionDialog { public DeleteDifficultyConfirmationDialog(BeatmapInfo beatmapInfo, Action deleteAction) { diff --git a/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs b/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs index c0f97a05e2..2704a1afb4 100644 --- a/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs +++ b/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs @@ -10,7 +10,7 @@ using osu.Game.Scoring; namespace osu.Game.Screens.Select { - public partial class BeatmapClearScoresDialog : DeleteConfirmationDialog + public partial class BeatmapClearScoresDialog : DangerousActionDialog { [Resolved] private ScoreManager scoreManager { get; set; } = null!; diff --git a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs index 4ab23c3a3a..0692cc3745 100644 --- a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs +++ b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs @@ -7,7 +7,7 @@ using osu.Game.Overlays.Dialog; namespace osu.Game.Screens.Select { - public partial class BeatmapDeleteDialog : DeleteConfirmationDialog + public partial class BeatmapDeleteDialog : DangerousActionDialog { private readonly BeatmapSetInfo beatmapSet; diff --git a/osu.Game/Screens/Select/Carousel/UpdateLocalConfirmationDialog.cs b/osu.Game/Screens/Select/Carousel/UpdateLocalConfirmationDialog.cs index e1aa662942..ecb21d4e2c 100644 --- a/osu.Game/Screens/Select/Carousel/UpdateLocalConfirmationDialog.cs +++ b/osu.Game/Screens/Select/Carousel/UpdateLocalConfirmationDialog.cs @@ -8,7 +8,7 @@ using osu.Game.Localisation; namespace osu.Game.Screens.Select.Carousel { - public partial class UpdateLocalConfirmationDialog : DeleteConfirmationDialog + public partial class UpdateLocalConfirmationDialog : DangerousActionDialog { public UpdateLocalConfirmationDialog(Action onConfirm) { diff --git a/osu.Game/Screens/Select/LocalScoreDeleteDialog.cs b/osu.Game/Screens/Select/LocalScoreDeleteDialog.cs index 6349e9e5eb..660122c80e 100644 --- a/osu.Game/Screens/Select/LocalScoreDeleteDialog.cs +++ b/osu.Game/Screens/Select/LocalScoreDeleteDialog.cs @@ -10,7 +10,7 @@ using osu.Game.Beatmaps; namespace osu.Game.Screens.Select { - public partial class LocalScoreDeleteDialog : DeleteConfirmationDialog + public partial class LocalScoreDeleteDialog : DangerousActionDialog { private readonly ScoreInfo score; diff --git a/osu.Game/Screens/Select/SkinDeleteDialog.cs b/osu.Game/Screens/Select/SkinDeleteDialog.cs index 9e11629890..3c95de0620 100644 --- a/osu.Game/Screens/Select/SkinDeleteDialog.cs +++ b/osu.Game/Screens/Select/SkinDeleteDialog.cs @@ -7,7 +7,7 @@ using osu.Game.Overlays.Dialog; namespace osu.Game.Screens.Select { - public partial class SkinDeleteDialog : DeleteConfirmationDialog + public partial class SkinDeleteDialog : DangerousActionDialog { private readonly Skin skin; From 2615453b3143e59886a56adb2f5d835a241a2a5d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 28 Feb 2023 11:45:32 +0900 Subject: [PATCH 32/84] Rename `SettingSource` tests to match attribute name --- ...ingsSourceAttributeTest.cs => SettingSourceAttributeTest.cs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename osu.Game.Tests/Mods/{SettingsSourceAttributeTest.cs => SettingSourceAttributeTest.cs} (98%) diff --git a/osu.Game.Tests/Mods/SettingsSourceAttributeTest.cs b/osu.Game.Tests/Mods/SettingSourceAttributeTest.cs similarity index 98% rename from osu.Game.Tests/Mods/SettingsSourceAttributeTest.cs rename to osu.Game.Tests/Mods/SettingSourceAttributeTest.cs index bf59862787..5da303d3a7 100644 --- a/osu.Game.Tests/Mods/SettingsSourceAttributeTest.cs +++ b/osu.Game.Tests/Mods/SettingSourceAttributeTest.cs @@ -12,7 +12,7 @@ using osu.Game.Overlays.Settings; namespace osu.Game.Tests.Mods { [TestFixture] - public partial class SettingsSourceAttributeTest + public partial class SettingSourceAttributeTest { [Test] public void TestOrdering() From 1250c1f0c1f50bd28ce5b5c11cae68d0b095bf57 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 28 Feb 2023 19:27:46 +0900 Subject: [PATCH 33/84] Update test assertions to match stable expectations These changes were taken from https://github.com/ppy/osu/pull/22582. Minor adjustments were applied to match stable expectations, which is to say there cannot be an inherited control point with omit barline specification (in the editor the setting is greyed out when inheritance is turned on). --- .../Formats/LegacyBeatmapDecoderTest.cs | 28 +++++++++++++++++-- .../NonVisual/ControlPointInfoTest.cs | 22 +++++++++++---- .../Resources/omit-barline-control-points.osu | 27 ++++++++++++++++++ 3 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 osu.Game.Tests/Resources/omit-barline-control-points.osu diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs index 5787bd6066..85d304da9c 100644 --- a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs @@ -181,16 +181,19 @@ namespace osu.Game.Tests.Beatmaps.Formats Assert.AreEqual(956, timingPoint.Time); Assert.AreEqual(329.67032967033, timingPoint.BeatLength); Assert.AreEqual(TimeSignature.SimpleQuadruple, timingPoint.TimeSignature); + Assert.IsFalse(timingPoint.OmitFirstBarLine); timingPoint = controlPoints.TimingPointAt(48428); Assert.AreEqual(956, timingPoint.Time); Assert.AreEqual(329.67032967033d, timingPoint.BeatLength); Assert.AreEqual(TimeSignature.SimpleQuadruple, timingPoint.TimeSignature); + Assert.IsFalse(timingPoint.OmitFirstBarLine); timingPoint = controlPoints.TimingPointAt(119637); Assert.AreEqual(119637, timingPoint.Time); Assert.AreEqual(659.340659340659, timingPoint.BeatLength); Assert.AreEqual(TimeSignature.SimpleQuadruple, timingPoint.TimeSignature); + Assert.IsFalse(timingPoint.OmitFirstBarLine); var difficultyPoint = controlPoints.DifficultyPointAt(0); Assert.AreEqual(0, difficultyPoint.Time); @@ -222,17 +225,14 @@ namespace osu.Game.Tests.Beatmaps.Formats var effectPoint = controlPoints.EffectPointAt(0); Assert.AreEqual(0, effectPoint.Time); Assert.IsFalse(effectPoint.KiaiMode); - Assert.IsFalse(effectPoint.OmitFirstBarLine); effectPoint = controlPoints.EffectPointAt(53703); Assert.AreEqual(53703, effectPoint.Time); Assert.IsTrue(effectPoint.KiaiMode); - Assert.IsFalse(effectPoint.OmitFirstBarLine); effectPoint = controlPoints.EffectPointAt(116637); Assert.AreEqual(95901, effectPoint.Time); Assert.IsFalse(effectPoint.KiaiMode); - Assert.IsFalse(effectPoint.OmitFirstBarLine); } } @@ -273,6 +273,28 @@ namespace osu.Game.Tests.Beatmaps.Formats } } + [Test] + public void TestDecodeOmitBarLineEffect() + { + var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false }; + + using (var resStream = TestResources.OpenResource("omit-barline-control-points.osu")) + using (var stream = new LineBufferedReader(resStream)) + { + var controlPoints = (LegacyControlPointInfo)decoder.Decode(stream).ControlPointInfo; + + Assert.That(controlPoints.TimingPoints.Count, Is.EqualTo(6)); + Assert.That(controlPoints.EffectPoints.Count, Is.EqualTo(0)); + + Assert.That(controlPoints.TimingPointAt(500).OmitFirstBarLine, Is.False); + Assert.That(controlPoints.TimingPointAt(1500).OmitFirstBarLine, Is.True); + Assert.That(controlPoints.TimingPointAt(2500).OmitFirstBarLine, Is.False); + Assert.That(controlPoints.TimingPointAt(3500).OmitFirstBarLine, Is.False); + Assert.That(controlPoints.TimingPointAt(4500).OmitFirstBarLine, Is.False); + Assert.That(controlPoints.TimingPointAt(5500).OmitFirstBarLine, Is.True); + } + } + [Test] public void TestTimingPointResetsSpeedMultiplier() { diff --git a/osu.Game.Tests/NonVisual/ControlPointInfoTest.cs b/osu.Game.Tests/NonVisual/ControlPointInfoTest.cs index 554473cf77..a2ded643fa 100644 --- a/osu.Game.Tests/NonVisual/ControlPointInfoTest.cs +++ b/osu.Game.Tests/NonVisual/ControlPointInfoTest.cs @@ -43,6 +43,18 @@ namespace osu.Game.Tests.NonVisual Assert.That(cpi.Groups.Count, Is.EqualTo(2)); Assert.That(cpi.TimingPoints.Count, Is.EqualTo(2)); Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(2)); + + cpi.Add(1200, new TimingControlPoint { OmitFirstBarLine = true }); // is not redundant + + Assert.That(cpi.Groups.Count, Is.EqualTo(3)); + Assert.That(cpi.TimingPoints.Count, Is.EqualTo(3)); + Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(3)); + + cpi.Add(1500, new TimingControlPoint { OmitFirstBarLine = true }); // is not redundant + + Assert.That(cpi.Groups.Count, Is.EqualTo(4)); + Assert.That(cpi.TimingPoints.Count, Is.EqualTo(4)); + Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(4)); } [Test] @@ -95,12 +107,12 @@ namespace osu.Game.Tests.NonVisual Assert.That(cpi.EffectPoints.Count, Is.EqualTo(0)); Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(0)); - cpi.Add(1000, new EffectControlPoint { KiaiMode = true, OmitFirstBarLine = true }); // is not redundant - cpi.Add(1400, new EffectControlPoint { KiaiMode = true, OmitFirstBarLine = true }); // same settings, but is not redundant + cpi.Add(1000, new EffectControlPoint { KiaiMode = true }); // is not redundant + cpi.Add(1400, new EffectControlPoint { KiaiMode = true }); // is redundant - Assert.That(cpi.Groups.Count, Is.EqualTo(2)); - Assert.That(cpi.EffectPoints.Count, Is.EqualTo(2)); - Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(2)); + Assert.That(cpi.Groups.Count, Is.EqualTo(1)); + Assert.That(cpi.EffectPoints.Count, Is.EqualTo(1)); + Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(1)); } [Test] diff --git a/osu.Game.Tests/Resources/omit-barline-control-points.osu b/osu.Game.Tests/Resources/omit-barline-control-points.osu new file mode 100644 index 0000000000..839a59215b --- /dev/null +++ b/osu.Game.Tests/Resources/omit-barline-control-points.osu @@ -0,0 +1,27 @@ +osu file format v14 + +[TimingPoints] + +// Uninherited: none, inherited: none +0,500,4,2,0,100,1,0 +0,-50,4,3,0,100,0,0 + +// Uninherited: omit, inherited: none +1000,500,4,2,0,100,1,8 +1000,-50,4,3,0,100,0,0 + +// Uninherited: none, inherited: omit (should be ignored, inheriting cannot omit) +2000,500,4,2,0,100,1,0 +2000,-50,4,3,0,100,0,8 + +// Inherited: none, uninherited: none +3000,-50,4,3,0,100,0,0 +3000,500,4,2,0,100,1,0 + +// Inherited: omit, uninherited: none (should be ignored, inheriting cannot omit) +4000,-50,4,3,0,100,0,8 +4000,500,4,2,0,100,1,0 + +// Inherited: none, uninherited: omit +5000,-50,4,3,0,100,0,0 +5000,500,4,2,0,100,1,8 From 044b0604b260461acde4f89f5ad2719b06252b4f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 28 Feb 2023 19:29:31 +0900 Subject: [PATCH 34/84] Move `OmitFirstBarLine` to `TimingControlPoint` --- .../TestSceneBarLineGeneration.cs | 5 ++-- .../Beatmaps/TaikoBeatmapConverter.cs | 1 - .../ControlPoints/EffectControlPoint.cs | 23 ++----------------- .../ControlPoints/TimingControlPoint.cs | 19 ++++++++++++++- .../Beatmaps/Formats/LegacyBeatmapDecoder.cs | 2 +- .../Beatmaps/Formats/LegacyBeatmapEncoder.cs | 5 ++-- .../Containers/BeatSyncedContainer.cs | 2 +- osu.Game/Rulesets/Objects/BarLineGenerator.cs | 3 +-- osu.Game/Screens/Edit/Timing/EffectSection.cs | 5 ---- .../RowAttributes/EffectRowAttribute.cs | 5 ---- .../RowAttributes/TimingRowAttribute.cs | 11 ++++++++- osu.Game/Screens/Edit/Timing/TimingSection.cs | 9 ++++++-- 12 files changed, 45 insertions(+), 45 deletions(-) diff --git a/osu.Game.Rulesets.Taiko.Tests/TestSceneBarLineGeneration.cs b/osu.Game.Rulesets.Taiko.Tests/TestSceneBarLineGeneration.cs index 7b8c8926f0..8511ad9f00 100644 --- a/osu.Game.Rulesets.Taiko.Tests/TestSceneBarLineGeneration.cs +++ b/osu.Game.Rulesets.Taiko.Tests/TestSceneBarLineGeneration.cs @@ -73,11 +73,10 @@ namespace osu.Game.Rulesets.Taiko.Tests beatmap.ControlPointInfo.Add(start_time, new TimingControlPoint { BeatLength = beat_length, - TimeSignature = new TimeSignature(time_signature_numerator) + TimeSignature = new TimeSignature(time_signature_numerator), + OmitFirstBarLine = true }); - beatmap.ControlPointInfo.Add(start_time, new EffectControlPoint { OmitFirstBarLine = true }); - var barlines = new BarLineGenerator(beatmap).BarLines; AddAssert("first barline ommited", () => barlines.All(b => b.StartTime != start_time)); diff --git a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs index 3cc47deed0..6a35e9376b 100644 --- a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs +++ b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs @@ -72,7 +72,6 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps converted.ControlPointInfo.Add(hitObject.StartTime, new EffectControlPoint { KiaiMode = currentEffectPoint.KiaiMode, - OmitFirstBarLine = currentEffectPoint.OmitFirstBarLine, ScrollSpeed = lastScrollSpeed = nextScrollSpeed, }); } diff --git a/osu.Game/Beatmaps/ControlPoints/EffectControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/EffectControlPoint.cs index 7c4313a015..7edf892f35 100644 --- a/osu.Game/Beatmaps/ControlPoints/EffectControlPoint.cs +++ b/osu.Game/Beatmaps/ControlPoints/EffectControlPoint.cs @@ -13,15 +13,9 @@ namespace osu.Game.Beatmaps.ControlPoints public static readonly EffectControlPoint DEFAULT = new EffectControlPoint { KiaiModeBindable = { Disabled = true }, - OmitFirstBarLineBindable = { Disabled = true }, ScrollSpeedBindable = { Disabled = true } }; - /// - /// Whether the first bar line of this control point is ignored. - /// - public readonly BindableBool OmitFirstBarLineBindable = new BindableBool(); - /// /// The relative scroll speed at this control point. /// @@ -43,15 +37,6 @@ namespace osu.Game.Beatmaps.ControlPoints public override Color4 GetRepresentingColour(OsuColour colours) => colours.Purple; - /// - /// Whether the first bar line of this control point is ignored. - /// - public bool OmitFirstBarLine - { - get => OmitFirstBarLineBindable.Value; - set => OmitFirstBarLineBindable.Value = value; - } - /// /// Whether this control point enables Kiai mode. /// @@ -67,16 +52,13 @@ namespace osu.Game.Beatmaps.ControlPoints } public override bool IsRedundant(ControlPoint? existing) - => !OmitFirstBarLine - && existing is EffectControlPoint existingEffect + => existing is EffectControlPoint existingEffect && KiaiMode == existingEffect.KiaiMode - && OmitFirstBarLine == existingEffect.OmitFirstBarLine && ScrollSpeed == existingEffect.ScrollSpeed; public override void CopyFrom(ControlPoint other) { KiaiMode = ((EffectControlPoint)other).KiaiMode; - OmitFirstBarLine = ((EffectControlPoint)other).OmitFirstBarLine; ScrollSpeed = ((EffectControlPoint)other).ScrollSpeed; base.CopyFrom(other); @@ -88,10 +70,9 @@ namespace osu.Game.Beatmaps.ControlPoints public bool Equals(EffectControlPoint? other) => base.Equals(other) - && OmitFirstBarLine == other.OmitFirstBarLine && ScrollSpeed == other.ScrollSpeed && KiaiMode == other.KiaiMode; - public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), OmitFirstBarLine, ScrollSpeed, KiaiMode); + public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), ScrollSpeed, KiaiMode); } } diff --git a/osu.Game/Beatmaps/ControlPoints/TimingControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/TimingControlPoint.cs index 61cc060594..4e69486e2d 100644 --- a/osu.Game/Beatmaps/ControlPoints/TimingControlPoint.cs +++ b/osu.Game/Beatmaps/ControlPoints/TimingControlPoint.cs @@ -16,6 +16,11 @@ namespace osu.Game.Beatmaps.ControlPoints /// public readonly Bindable TimeSignatureBindable = new Bindable(TimeSignature.SimpleQuadruple); + /// + /// Whether the first bar line of this control point is ignored. + /// + public readonly BindableBool OmitFirstBarLineBindable = new BindableBool(); + /// /// Default length of a beat in milliseconds. Used whenever there is no beatmap or track playing. /// @@ -30,6 +35,7 @@ namespace osu.Game.Beatmaps.ControlPoints Value = default_beat_length, Disabled = true }, + OmitFirstBarLineBindable = { Disabled = true }, TimeSignatureBindable = { Disabled = true } }; @@ -42,6 +48,15 @@ namespace osu.Game.Beatmaps.ControlPoints set => TimeSignatureBindable.Value = value; } + /// + /// Whether the first bar line of this control point is ignored. + /// + public bool OmitFirstBarLine + { + get => OmitFirstBarLineBindable.Value; + set => OmitFirstBarLineBindable.Value = value; + } + public const double DEFAULT_BEAT_LENGTH = 1000; /// @@ -73,6 +88,7 @@ namespace osu.Game.Beatmaps.ControlPoints public override void CopyFrom(ControlPoint other) { TimeSignature = ((TimingControlPoint)other).TimeSignature; + OmitFirstBarLine = ((TimingControlPoint)other).OmitFirstBarLine; BeatLength = ((TimingControlPoint)other).BeatLength; base.CopyFrom(other); @@ -85,8 +101,9 @@ namespace osu.Game.Beatmaps.ControlPoints public bool Equals(TimingControlPoint? other) => base.Equals(other) && TimeSignature.Equals(other.TimeSignature) + && OmitFirstBarLine == other.OmitFirstBarLine && BeatLength.Equals(other.BeatLength); - public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), TimeSignature, BeatLength); + public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), TimeSignature, BeatLength, OmitFirstBarLine); } } diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs index 9c710b690e..eabc63b341 100644 --- a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs @@ -431,6 +431,7 @@ namespace osu.Game.Beatmaps.Formats controlPoint.BeatLength = beatLength; controlPoint.TimeSignature = timeSignature; + controlPoint.OmitFirstBarLine = omitFirstBarSignature; addControlPoint(time, controlPoint, true); } @@ -447,7 +448,6 @@ namespace osu.Game.Beatmaps.Formats var effectPoint = new EffectControlPoint { KiaiMode = kiaiMode, - OmitFirstBarLine = omitFirstBarSignature, }; // osu!taiko and osu!mania use effect points rather than difficulty points for scroll speed adjustments. diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs index 7e058d755e..072e442dea 100644 --- a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs @@ -222,6 +222,7 @@ namespace osu.Game.Beatmaps.Formats { var samplePoint = legacyControlPoints.SamplePointAt(time); var effectPoint = legacyControlPoints.EffectPointAt(time); + var timingPoint = legacyControlPoints.TimingPointAt(time); // Apply the control point to a hit sample to uncover legacy properties (e.g. suffix) HitSampleInfo tempHitSample = samplePoint.ApplyTo(new ConvertHitObjectParser.LegacyHitSampleInfo(string.Empty)); @@ -230,10 +231,10 @@ namespace osu.Game.Beatmaps.Formats LegacyEffectFlags effectFlags = LegacyEffectFlags.None; if (effectPoint.KiaiMode) effectFlags |= LegacyEffectFlags.Kiai; - if (effectPoint.OmitFirstBarLine) + if (timingPoint.OmitFirstBarLine) effectFlags |= LegacyEffectFlags.OmitFirstBarLine; - writer.Write(FormattableString.Invariant($"{legacyControlPoints.TimingPointAt(time).TimeSignature.Numerator},")); + writer.Write(FormattableString.Invariant($"{timingPoint.TimeSignature.Numerator},")); writer.Write(FormattableString.Invariant($"{(int)toLegacySampleBank(tempHitSample.Bank)},")); writer.Write(FormattableString.Invariant($"{toLegacyCustomSampleBank(tempHitSample)},")); writer.Write(FormattableString.Invariant($"{tempHitSample.Volume},")); diff --git a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs index 724005a0cc..42b30f9d18 100644 --- a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs +++ b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs @@ -114,7 +114,7 @@ namespace osu.Game.Graphics.Containers while (beatLength < MinimumBeatLength) beatLength *= 2; - int beatIndex = (int)((currentTrackTime - timingPoint.Time) / beatLength) - (effectPoint.OmitFirstBarLine ? 1 : 0); + int beatIndex = (int)((currentTrackTime - timingPoint.Time) / beatLength) - (timingPoint.OmitFirstBarLine ? 1 : 0); // The beats before the start of the first control point are off by 1, this should do the trick if (currentTrackTime < timingPoint.Time) diff --git a/osu.Game/Rulesets/Objects/BarLineGenerator.cs b/osu.Game/Rulesets/Objects/BarLineGenerator.cs index af32c7def3..affbcbd878 100644 --- a/osu.Game/Rulesets/Objects/BarLineGenerator.cs +++ b/osu.Game/Rulesets/Objects/BarLineGenerator.cs @@ -38,7 +38,6 @@ namespace osu.Game.Rulesets.Objects for (int i = 0; i < timingPoints.Count; i++) { TimingControlPoint currentTimingPoint = timingPoints[i]; - EffectControlPoint currentEffectPoint = beatmap.ControlPointInfo.EffectPointAt(currentTimingPoint.Time); int currentBeat = 0; // Don't generate barlines before the hit object or t=0 (whichever is earliest). Some beatmaps use very unrealistic values here (although none are ranked). @@ -66,7 +65,7 @@ namespace osu.Game.Rulesets.Objects startTime = currentTimingPoint.Time + barCount * barLength; } - if (currentEffectPoint.OmitFirstBarLine) + if (currentTimingPoint.OmitFirstBarLine) { startTime += barLength; } diff --git a/osu.Game/Screens/Edit/Timing/EffectSection.cs b/osu.Game/Screens/Edit/Timing/EffectSection.cs index 051ac97366..7e484433f7 100644 --- a/osu.Game/Screens/Edit/Timing/EffectSection.cs +++ b/osu.Game/Screens/Edit/Timing/EffectSection.cs @@ -14,7 +14,6 @@ namespace osu.Game.Screens.Edit.Timing internal partial class EffectSection : Section { private LabelledSwitchButton kiai = null!; - private LabelledSwitchButton omitBarLine = null!; private SliderWithTextBoxInput scrollSpeedSlider = null!; @@ -24,7 +23,6 @@ namespace osu.Game.Screens.Edit.Timing Flow.AddRange(new Drawable[] { kiai = new LabelledSwitchButton { Label = "Kiai Time" }, - omitBarLine = new LabelledSwitchButton { Label = "Skip Bar Line" }, scrollSpeedSlider = new SliderWithTextBoxInput("Scroll Speed") { Current = new EffectControlPoint().ScrollSpeedBindable, @@ -38,7 +36,6 @@ namespace osu.Game.Screens.Edit.Timing base.LoadComplete(); kiai.Current.BindValueChanged(_ => saveChanges()); - omitBarLine.Current.BindValueChanged(_ => saveChanges()); scrollSpeedSlider.Current.BindValueChanged(_ => saveChanges()); var drawableRuleset = Beatmap.BeatmapInfo.Ruleset.CreateInstance().CreateDrawableRulesetWith(Beatmap.PlayableBeatmap); @@ -60,7 +57,6 @@ namespace osu.Game.Screens.Edit.Timing isRebinding = true; kiai.Current = point.NewValue.KiaiModeBindable; - omitBarLine.Current = point.NewValue.OmitFirstBarLineBindable; scrollSpeedSlider.Current = point.NewValue.ScrollSpeedBindable; isRebinding = false; @@ -74,7 +70,6 @@ namespace osu.Game.Screens.Edit.Timing return new EffectControlPoint { KiaiMode = reference.KiaiMode, - OmitFirstBarLine = reference.OmitFirstBarLine, ScrollSpeed = reference.ScrollSpeed, }; } diff --git a/osu.Game/Screens/Edit/Timing/RowAttributes/EffectRowAttribute.cs b/osu.Game/Screens/Edit/Timing/RowAttributes/EffectRowAttribute.cs index 3b068699ca..ad22aa81fc 100644 --- a/osu.Game/Screens/Edit/Timing/RowAttributes/EffectRowAttribute.cs +++ b/osu.Game/Screens/Edit/Timing/RowAttributes/EffectRowAttribute.cs @@ -11,18 +11,15 @@ namespace osu.Game.Screens.Edit.Timing.RowAttributes public partial class EffectRowAttribute : RowAttribute { private readonly Bindable kiaiMode; - private readonly Bindable omitBarLine; private readonly BindableNumber scrollSpeed; private AttributeText kiaiModeBubble = null!; - private AttributeText omitBarLineBubble = null!; private AttributeText text = null!; public EffectRowAttribute(EffectControlPoint effect) : base(effect, "effect") { kiaiMode = effect.KiaiModeBindable.GetBoundCopy(); - omitBarLine = effect.OmitFirstBarLineBindable.GetBoundCopy(); scrollSpeed = effect.ScrollSpeedBindable.GetBoundCopy(); } @@ -37,11 +34,9 @@ namespace osu.Game.Screens.Edit.Timing.RowAttributes }, text = new AttributeText(Point) { Width = 45 }, kiaiModeBubble = new AttributeText(Point) { Text = "kiai" }, - omitBarLineBubble = new AttributeText(Point) { Text = "no barline" }, }); kiaiMode.BindValueChanged(enabled => kiaiModeBubble.FadeTo(enabled.NewValue ? 1 : 0), true); - omitBarLine.BindValueChanged(enabled => omitBarLineBubble.FadeTo(enabled.NewValue ? 1 : 0), true); scrollSpeed.BindValueChanged(_ => updateText(), true); } diff --git a/osu.Game/Screens/Edit/Timing/RowAttributes/TimingRowAttribute.cs b/osu.Game/Screens/Edit/Timing/RowAttributes/TimingRowAttribute.cs index a6d3816bd4..577e7a3134 100644 --- a/osu.Game/Screens/Edit/Timing/RowAttributes/TimingRowAttribute.cs +++ b/osu.Game/Screens/Edit/Timing/RowAttributes/TimingRowAttribute.cs @@ -4,6 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions; +using osu.Framework.Graphics; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.Timing; using osu.Game.Graphics.Sprites; @@ -14,24 +15,32 @@ namespace osu.Game.Screens.Edit.Timing.RowAttributes public partial class TimingRowAttribute : RowAttribute { private readonly BindableNumber beatLength; + private readonly Bindable omitBarLine; private readonly Bindable timeSignature; + private AttributeText omitBarLineBubble = null!; private OsuSpriteText text = null!; public TimingRowAttribute(TimingControlPoint timing) : base(timing, "timing") { timeSignature = timing.TimeSignatureBindable.GetBoundCopy(); + omitBarLine = timing.OmitFirstBarLineBindable.GetBoundCopy(); beatLength = timing.BeatLengthBindable.GetBoundCopy(); } [BackgroundDependencyLoader] private void load(OverlayColourProvider colourProvider) { - Content.Add(text = new AttributeText(Point)); + Content.AddRange(new[] + { + text = new AttributeText(Point), + omitBarLineBubble = new AttributeText(Point) { Text = "no barline" }, + }); Background.Colour = colourProvider.Background4; timeSignature.BindValueChanged(_ => updateText()); + omitBarLine.BindValueChanged(enabled => omitBarLineBubble.FadeTo(enabled.NewValue ? 1 : 0), true); beatLength.BindValueChanged(_ => updateText(), true); } diff --git a/osu.Game/Screens/Edit/Timing/TimingSection.cs b/osu.Game/Screens/Edit/Timing/TimingSection.cs index d2d524ccbe..2757753b07 100644 --- a/osu.Game/Screens/Edit/Timing/TimingSection.cs +++ b/osu.Game/Screens/Edit/Timing/TimingSection.cs @@ -12,6 +12,7 @@ namespace osu.Game.Screens.Edit.Timing internal partial class TimingSection : Section { private LabelledTimeSignature timeSignature = null!; + private LabelledSwitchButton omitBarLine = null!; private BPMTextBox bpmTextEntry = null!; [BackgroundDependencyLoader] @@ -24,7 +25,8 @@ namespace osu.Game.Screens.Edit.Timing timeSignature = new LabelledTimeSignature { Label = "Time Signature" - } + }, + omitBarLine = new LabelledSwitchButton { Label = "Skip Bar Line" }, }); } @@ -33,6 +35,7 @@ namespace osu.Game.Screens.Edit.Timing base.LoadComplete(); bpmTextEntry.Current.BindValueChanged(_ => saveChanges()); + omitBarLine.Current.BindValueChanged(_ => saveChanges()); timeSignature.Current.BindValueChanged(_ => saveChanges()); void saveChanges() @@ -51,6 +54,7 @@ namespace osu.Game.Screens.Edit.Timing bpmTextEntry.Bindable = point.NewValue.BeatLengthBindable; timeSignature.Current = point.NewValue.TimeSignatureBindable; + omitBarLine.Current = point.NewValue.OmitFirstBarLineBindable; isRebinding = false; } @@ -63,7 +67,8 @@ namespace osu.Game.Screens.Edit.Timing return new TimingControlPoint { BeatLength = reference.BeatLength, - TimeSignature = reference.TimeSignature + TimeSignature = reference.TimeSignature, + OmitFirstBarLine = reference.OmitFirstBarLine, }; } From 31f58a33ac13c675ee76701f38db56c2d98b6419 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 28 Feb 2023 18:47:27 +0300 Subject: [PATCH 35/84] Use ColourInfo.Interpolate where possible --- osu.Game/Graphics/Backgrounds/TrianglesV2.cs | 16 +--------------- .../Graphics/UserInterface/SegmentedGraph.cs | 8 +------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/osu.Game/Graphics/Backgrounds/TrianglesV2.cs b/osu.Game/Graphics/Backgrounds/TrianglesV2.cs index 3bc8bb6df1..e7af6cf70d 100644 --- a/osu.Game/Graphics/Backgrounds/TrianglesV2.cs +++ b/osu.Game/Graphics/Backgrounds/TrianglesV2.cs @@ -11,7 +11,6 @@ using osu.Framework.Allocation; using System.Collections.Generic; using osu.Framework.Graphics.Rendering; using osu.Framework.Graphics.Rendering.Vertices; -using osu.Framework.Graphics.Colour; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -259,8 +258,6 @@ namespace osu.Game.Graphics.Backgrounds Vector2Extensions.Transform(triangleQuad.BottomRight * size, DrawInfo.Matrix) ); - ColourInfo colourInfo = triangleColourInfo(DrawColourInfo.Colour, triangleQuad); - RectangleF textureCoords = new RectangleF( triangleQuad.TopLeft.X - topLeft.X, triangleQuad.TopLeft.Y - topLeft.Y, @@ -268,23 +265,12 @@ namespace osu.Game.Graphics.Backgrounds triangleQuad.Height ) / relativeSize; - renderer.DrawQuad(texture, drawQuad, colourInfo, new RectangleF(0, 0, 1, 1), vertexBatch.AddAction, textureCoords: textureCoords); + renderer.DrawQuad(texture, drawQuad, DrawColourInfo.Colour.Interpolate(triangleQuad), new RectangleF(0, 0, 1, 1), vertexBatch.AddAction, textureCoords: textureCoords); } shader.Unbind(); } - private static ColourInfo triangleColourInfo(ColourInfo source, Quad quad) - { - return new ColourInfo - { - TopLeft = source.Interpolate(quad.TopLeft), - TopRight = source.Interpolate(quad.TopRight), - BottomLeft = source.Interpolate(quad.BottomLeft), - BottomRight = source.Interpolate(quad.BottomRight) - }; - } - private static Quad clampToDrawable(Vector2 topLeft, Vector2 size) { float leftClamped = Math.Clamp(topLeft.X, 0f, 1f); diff --git a/osu.Game/Graphics/UserInterface/SegmentedGraph.cs b/osu.Game/Graphics/UserInterface/SegmentedGraph.cs index e8817d5275..91971e5af9 100644 --- a/osu.Game/Graphics/UserInterface/SegmentedGraph.cs +++ b/osu.Game/Graphics/UserInterface/SegmentedGraph.cs @@ -249,13 +249,7 @@ namespace osu.Game.Graphics.UserInterface private ColourInfo getSegmentColour(SegmentInfo segment) { - var segmentColour = new ColourInfo - { - TopLeft = DrawColourInfo.Colour.Interpolate(new Vector2(segment.Start, 0f)), - TopRight = DrawColourInfo.Colour.Interpolate(new Vector2(segment.End, 0f)), - BottomLeft = DrawColourInfo.Colour.Interpolate(new Vector2(segment.Start, 1f)), - BottomRight = DrawColourInfo.Colour.Interpolate(new Vector2(segment.End, 1f)) - }; + var segmentColour = DrawColourInfo.Colour.Interpolate(new Quad(segment.Start, 0f, segment.End - segment.Start, 1f)); var tierColour = segment.Tier >= 0 ? tierColours[segment.Tier] : new Colour4(0, 0, 0, 0); segmentColour.ApplyChild(tierColour); From af540de69b3494d8035de765478223319b7f904a Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Wed, 1 Mar 2023 22:10:15 -0800 Subject: [PATCH 36/84] Fix "talking with" text overflowing when usernames are too long --- osu.Game/Overlays/Chat/ChatTextBar.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatTextBar.cs b/osu.Game/Overlays/Chat/ChatTextBar.cs index 682c96a695..fd5e0e9836 100644 --- a/osu.Game/Overlays/Chat/ChatTextBar.cs +++ b/osu.Game/Overlays/Chat/ChatTextBar.cs @@ -39,6 +39,7 @@ namespace osu.Game.Overlays.Chat private const float chatting_text_width = 220; private const float search_icon_width = 40; + private const float padding = 5; [BackgroundDependencyLoader] private void load(OverlayColourProvider colourProvider) @@ -71,9 +72,10 @@ namespace osu.Game.Overlays.Chat RelativeSizeAxes = Axes.Y, Width = chatting_text_width, Masking = true, - Padding = new MarginPadding { Right = 5 }, + Padding = new MarginPadding { Horizontal = padding }, Child = chattingText = new OsuSpriteText { + MaxWidth = chatting_text_width - padding * 2, Font = OsuFont.Torus.With(size: 20), Colour = colourProvider.Background1, Anchor = Anchor.CentreRight, @@ -97,7 +99,7 @@ namespace osu.Game.Overlays.Chat new Container { RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Right = 5 }, + Padding = new MarginPadding { Right = padding }, Child = chatTextBox = new ChatTextBox { Anchor = Anchor.CentreLeft, From 6ff1fb6b1aac475a9a2d217ad0750d075d275be0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 2 Mar 2023 18:57:54 +0900 Subject: [PATCH 37/84] Adjust sizing to allow for timing point information now being longer than before --- osu.Game/Screens/Edit/Timing/ControlPointTable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Timing/ControlPointTable.cs b/osu.Game/Screens/Edit/Timing/ControlPointTable.cs index 08b2ce8562..b078e3fa44 100644 --- a/osu.Game/Screens/Edit/Timing/ControlPointTable.cs +++ b/osu.Game/Screens/Edit/Timing/ControlPointTable.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Edit.Timing [Resolved] private EditorClock clock { get; set; } = null!; - public const float TIMING_COLUMN_WIDTH = 230; + public const float TIMING_COLUMN_WIDTH = 300; public IEnumerable ControlGroups { From 82293c0c868d07b0a37237db787353431c280519 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 3 Mar 2023 16:28:09 +0900 Subject: [PATCH 38/84] Don't filter away results with missing data when using "Date Submitted" or "Date Ranked" sort modes From a user's perspective, changing a sort / order mode shouldn't filter away results, but we were doing this. In terms of UX expectations, in stable this kind of scenario would results in a group being added to the end of son select with "Not ranked" or "Unknown". I think we should aim to match this eventually. --- .../SongSelect/TestSceneBeatmapCarousel.cs | 11 +++++-- .../Select/Carousel/CarouselBeatmapSet.cs | 29 ++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index 65ce0429fc..5285c485ea 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -532,15 +532,20 @@ namespace osu.Game.Tests.Visual.SongSelect loadBeatmaps(sets); AddStep("Sort by date submitted", () => carousel.Filter(new FilterCriteria { Sort = SortMode.DateSubmitted }, false)); - checkVisibleItemCount(diff: false, count: 8); + checkVisibleItemCount(diff: false, count: 20); checkVisibleItemCount(diff: true, count: 5); + AddStep("Sort by date submitted and string", () => carousel.Filter(new FilterCriteria { Sort = SortMode.DateSubmitted, SearchText = zzz_string }, false)); - checkVisibleItemCount(diff: false, count: 3); + checkVisibleItemCount(diff: false, count: 5); checkVisibleItemCount(diff: true, count: 5); + + AddAssert("missing date submitted are at end", + () => carousel.Items.OfType().TakeLast(2).All(i => i.Item is CarouselBeatmapSet s && s.BeatmapSet.DateSubmitted == null)); + AddAssert("rest are at start", () => carousel.Items.OfType().Take(3).All(i => i.Item is CarouselBeatmapSet s && s.BeatmapSet.DateSubmitted != null)); } [Test] @@ -1129,7 +1134,7 @@ namespace osu.Game.Tests.Visual.SongSelect { // until step required as we are querying against alive items, which are loaded asynchronously inside DrawableCarouselBeatmapSet. AddUntilStep($"{count} {(diff ? "diffs" : "sets")} visible", () => - carousel.Items.Count(s => (diff ? s.Item is CarouselBeatmap : s.Item is CarouselBeatmapSet) && s.Item.Visible) == count); + carousel.Items.Count(s => (diff ? s.Item is CarouselBeatmap : s.Item is CarouselBeatmapSet) && s.Item.Visible), () => Is.EqualTo(count)); } private void checkSelectionIsCentered() diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs index c52b81f915..63493a3b02 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs @@ -61,7 +61,7 @@ namespace osu.Game.Screens.Select.Carousel if (!(other is CarouselBeatmapSet otherSet)) return base.CompareTo(criteria, other); - int comparison = 0; + int comparison; switch (criteria.Sort) { @@ -87,11 +87,7 @@ namespace osu.Game.Screens.Select.Carousel break; case SortMode.DateRanked: - // Beatmaps which have no ranked date should already be filtered away in this mode. - if (BeatmapSet.DateRanked == null || otherSet.BeatmapSet.DateRanked == null) - break; - - comparison = otherSet.BeatmapSet.DateRanked.Value.CompareTo(BeatmapSet.DateRanked.Value); + comparison = compareNullableDateTimeOffset(BeatmapSet.DateRanked, otherSet.BeatmapSet.DateRanked); break; case SortMode.LastPlayed: @@ -111,11 +107,7 @@ namespace osu.Game.Screens.Select.Carousel break; case SortMode.DateSubmitted: - // Beatmaps which have no submitted date should already be filtered away in this mode. - if (BeatmapSet.DateSubmitted == null || otherSet.BeatmapSet.DateSubmitted == null) - break; - - comparison = otherSet.BeatmapSet.DateSubmitted.Value.CompareTo(BeatmapSet.DateSubmitted.Value); + comparison = compareNullableDateTimeOffset(BeatmapSet.DateSubmitted, otherSet.BeatmapSet.DateSubmitted); break; } @@ -132,6 +124,14 @@ namespace osu.Game.Screens.Select.Carousel return otherSet.BeatmapSet.ID.CompareTo(BeatmapSet.ID); } + private static int compareNullableDateTimeOffset(DateTimeOffset? x, DateTimeOffset? y) + { + if (x == null) return 1; + if (y == null) return -1; + + return y.Value.CompareTo(x.Value); + } + /// /// All beatmaps which are not filtered and valid for display. /// @@ -153,12 +153,7 @@ namespace osu.Game.Screens.Select.Carousel { base.Filter(criteria); - bool filtered = Items.All(i => i.Filtered.Value); - - filtered |= criteria.Sort == SortMode.DateRanked && BeatmapSet.DateRanked == null; - filtered |= criteria.Sort == SortMode.DateSubmitted && BeatmapSet.DateSubmitted == null; - - Filtered.Value = filtered; + Filtered.Value = Items.All(i => i.Filtered.Value); } public override string ToString() => BeatmapSet.ToString(); From 7a092ea995436cbd987534a86648af05aa4161c4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 3 Mar 2023 17:18:14 +0900 Subject: [PATCH 39/84] Add better coverage and more comments explaining the structure of test setup --- .../SongSelect/TestSceneBeatmapCarousel.cs | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index 5285c485ea..deead47770 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -516,15 +516,20 @@ namespace osu.Game.Tests.Visual.SongSelect { sets.Clear(); - for (int i = 0; i < 20; i++) + for (int i = 0; i < 10; i++) { var set = TestResources.CreateTestBeatmapSetInfo(5); - if (i >= 2 && i < 10) + // A total of 6 sets have date submitted (4 don't) + // A total of 5 sets have artist string (3 of which also have date submitted) + + if (i >= 2 && i < 8) // i = 2, 3, 4, 5, 6, 7 have submitted date set.DateSubmitted = DateTimeOffset.Now.AddMinutes(i); - if (i < 5) + if (i < 5) // i = 0, 1, 2, 3, 4 have matching string set.Beatmaps.ForEach(b => b.Metadata.Artist = zzz_string); + set.Beatmaps.ForEach(b => b.Metadata.Title = $"submitted: {set.DateSubmitted}"); + sets.Add(set); } }); @@ -532,9 +537,14 @@ namespace osu.Game.Tests.Visual.SongSelect loadBeatmaps(sets); AddStep("Sort by date submitted", () => carousel.Filter(new FilterCriteria { Sort = SortMode.DateSubmitted }, false)); - checkVisibleItemCount(diff: false, count: 20); + checkVisibleItemCount(diff: false, count: 10); checkVisibleItemCount(diff: true, count: 5); + AddAssert("missing date are at end", + () => carousel.Items.OfType().Reverse().TakeWhile(i => i.Item is CarouselBeatmapSet s && s.BeatmapSet.DateSubmitted == null).Count(), () => Is.EqualTo(4)); + AddAssert("rest are at start", () => carousel.Items.OfType().TakeWhile(i => i.Item is CarouselBeatmapSet s && s.BeatmapSet.DateSubmitted != null).Count(), + () => Is.EqualTo(6)); + AddStep("Sort by date submitted and string", () => carousel.Filter(new FilterCriteria { Sort = SortMode.DateSubmitted, @@ -543,9 +553,10 @@ namespace osu.Game.Tests.Visual.SongSelect checkVisibleItemCount(diff: false, count: 5); checkVisibleItemCount(diff: true, count: 5); - AddAssert("missing date submitted are at end", - () => carousel.Items.OfType().TakeLast(2).All(i => i.Item is CarouselBeatmapSet s && s.BeatmapSet.DateSubmitted == null)); - AddAssert("rest are at start", () => carousel.Items.OfType().Take(3).All(i => i.Item is CarouselBeatmapSet s && s.BeatmapSet.DateSubmitted != null)); + AddAssert("missing date are at end", + () => carousel.Items.OfType().Reverse().TakeWhile(i => i.Item is CarouselBeatmapSet s && s.BeatmapSet.DateSubmitted == null).Count(), () => Is.EqualTo(2)); + AddAssert("rest are at start", () => carousel.Items.OfType().TakeWhile(i => i.Item is CarouselBeatmapSet s && s.BeatmapSet.DateSubmitted != null).Count(), + () => Is.EqualTo(3)); } [Test] From a14dede0360836429a954f57b4fc7aec1eb7c9f7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 3 Mar 2023 17:18:33 +0900 Subject: [PATCH 40/84] Ensure `TestBeatmapCarousel.Items` only returns actually visible items (and in correct order) Turns out that items could be in an order that isn't the same as how things look on the carousel, so this change ensures that for testing purposes they are sorted by Y position. Also uses the `CarouselItem.Visible` flag to ensure that we don't have to wait for drawable fade transitions after a filter operation. --- osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index deead47770..61a8322ee3 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -1206,8 +1206,11 @@ namespace osu.Game.Tests.Visual.SongSelect { get { - foreach (var item in Scroll.Children) + foreach (var item in Scroll.Children.OrderBy(c => c.Y)) { + if (item.Item?.Visible != true) + continue; + yield return item; if (item is DrawableCarouselBeatmapSet set) From 36058b3da25d5e089b06c30a2080bb6b6f224d68 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 3 Mar 2023 18:03:06 +0900 Subject: [PATCH 41/84] Fix upwards scroll direction not working with recent hold note display changes --- .../Skinning/Legacy/LegacyBodyPiece.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyBodyPiece.cs b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyBodyPiece.cs index 69eacda541..ef4810c40d 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyBodyPiece.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyBodyPiece.cs @@ -167,8 +167,8 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy { if (bodySprite != null) { - bodySprite.Origin = Anchor.BottomCentre; - bodySprite.Scale = new Vector2(bodySprite.Scale.X, Math.Abs(bodySprite.Scale.Y) * -1); + bodySprite.Origin = Anchor.TopCentre; + bodySprite.Anchor = Anchor.BottomCentre; // needs to be flipped due to scale flip in Update. } if (light != null) @@ -179,7 +179,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy if (bodySprite != null) { bodySprite.Origin = Anchor.TopCentre; - bodySprite.Scale = new Vector2(bodySprite.Scale.X, Math.Abs(bodySprite.Scale.Y)); + bodySprite.Anchor = Anchor.TopCentre; } if (light != null) @@ -211,11 +211,15 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy base.Update(); missFadeTime.Value ??= holdNote.HoldBrokenTime; + int scaleDirection = (direction.Value == ScrollingDirection.Down ? 1 : -1); + // here we go... switch (bodyStyle) { case LegacyNoteBodyStyle.Stretch: // this is how lazer works by default. nothing required. + if (bodySprite != null) + bodySprite.Scale = new Vector2(1, scaleDirection); break; default: @@ -228,7 +232,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy bodySprite.FillMode = FillMode.Stretch; // i dunno this looks about right?? - bodySprite.Scale = new Vector2(1, 32800 / sprite.DrawHeight); + bodySprite.Scale = new Vector2(1, scaleDirection * 32800 / sprite.DrawHeight); } break; From 2b7111867c348231a5bfb1a36f427e2cb1c6fc96 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Fri, 3 Mar 2023 15:12:20 +0100 Subject: [PATCH 42/84] Adjust reversion header text naming. --- osu.Game/Localisation/SkinEditorStrings.cs | 4 ++-- osu.Game/Overlays/SkinEditor/SkinEditor.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Localisation/SkinEditorStrings.cs b/osu.Game/Localisation/SkinEditorStrings.cs index b83a105c14..ea0c90e547 100644 --- a/osu.Game/Localisation/SkinEditorStrings.cs +++ b/osu.Game/Localisation/SkinEditorStrings.cs @@ -45,9 +45,9 @@ namespace osu.Game.Localisation public static LocalisableString CurrentlyEditing => new TranslatableString(getKey(@"currently_editing"), @"Currently editing"); /// - /// "Revert to default?" + /// "Revert to default." /// - public static LocalisableString RevertToDefault => new TranslatableString(getKey(@"revert_to_default"), @"Revert to default?"); + public static LocalisableString RevertToDefaultDescription => new TranslatableString(getKey(@"revert_to_default"), @"Revert to default."); /// /// "The skin will return to the state it was in upon import" diff --git a/osu.Game/Overlays/SkinEditor/SkinEditor.cs b/osu.Game/Overlays/SkinEditor/SkinEditor.cs index 770a3c5930..5ffdaa11d4 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditor.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditor.cs @@ -635,7 +635,7 @@ namespace osu.Game.Overlays.SkinEditor { public ResetConfirmDialog(Action reset) { - HeaderText = SkinEditorStrings.RevertToDefault; + HeaderText = SkinEditorStrings.RevertToDefaultDescription; BodyText = SkinEditorStrings.ResetDialogue; Icon = FontAwesome.Solid.ExclamationTriangle; From 3bff415909ea42d64b145c32bbb8f71375c0ca0d Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Fri, 3 Mar 2023 15:15:14 +0100 Subject: [PATCH 43/84] Change `ResetDialogue` text --- osu.Game/Localisation/SkinEditorStrings.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Localisation/SkinEditorStrings.cs b/osu.Game/Localisation/SkinEditorStrings.cs index ea0c90e547..a6b59418fd 100644 --- a/osu.Game/Localisation/SkinEditorStrings.cs +++ b/osu.Game/Localisation/SkinEditorStrings.cs @@ -50,9 +50,9 @@ namespace osu.Game.Localisation public static LocalisableString RevertToDefaultDescription => new TranslatableString(getKey(@"revert_to_default"), @"Revert to default."); /// - /// "The skin will return to the state it was in upon import" + /// "Return the skin to its default state" /// - public static LocalisableString ResetDialogue => new TranslatableString(getKey(@"the_skin_will_return_to"), @"The skin will return to the state it was in upon import"); + public static LocalisableString ResetDialogue => new TranslatableString(getKey(@"return_the_skin_to_its"), @"Return the skin to its default state"); private static string getKey(string key) => $@"{prefix}:{key}"; } From 91d206e8d2c0553266e5605ab454d0862c3e604b Mon Sep 17 00:00:00 2001 From: OliBomby Date: Fri, 3 Mar 2023 19:21:50 +0100 Subject: [PATCH 44/84] Optimised GetSearchableTerms Reduced memory allocations to 1 --- osu.Game/Beatmaps/BeatmapInfoExtensions.cs | 27 ++++++++++++--- .../Select/Carousel/CarouselBeatmap.cs | 34 ++++++++++++++++--- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapInfoExtensions.cs b/osu.Game/Beatmaps/BeatmapInfoExtensions.cs index eab66b9857..e14a44ec58 100644 --- a/osu.Game/Beatmaps/BeatmapInfoExtensions.cs +++ b/osu.Game/Beatmaps/BeatmapInfoExtensions.cs @@ -1,7 +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.Linq; +using System; using osu.Framework.Localisation; namespace osu.Game.Beatmaps @@ -29,10 +29,29 @@ namespace osu.Game.Beatmaps return new RomanisableString($"{metadata.GetPreferred(true)}".Trim(), $"{metadata.GetPreferred(false)}".Trim()); } - public static string[] GetSearchableTerms(this IBeatmapInfo beatmapInfo) => new[] + public static ReadOnlySpan GetSearchableTerms(this IBeatmapInfo beatmapInfo) { - beatmapInfo.DifficultyName - }.Concat(beatmapInfo.Metadata.GetSearchableTerms()).Where(s => !string.IsNullOrEmpty(s)).ToArray(); + Span terms = new string[8]; + int i = 0; + if (!string.IsNullOrEmpty(beatmapInfo.DifficultyName)) + terms[i++] = beatmapInfo.DifficultyName; + var metadata = beatmapInfo.Metadata; + if (!string.IsNullOrEmpty(metadata.Author.Username)) + terms[i++] = metadata.Author.Username; + if (!string.IsNullOrEmpty(metadata.Artist)) + terms[i++] = metadata.Artist; + if (!string.IsNullOrEmpty(metadata.ArtistUnicode)) + terms[i++] = metadata.ArtistUnicode; + if (!string.IsNullOrEmpty(metadata.Title)) + terms[i++] = metadata.Title; + if (!string.IsNullOrEmpty(metadata.TitleUnicode)) + terms[i++] = metadata.TitleUnicode; + if (!string.IsNullOrEmpty(metadata.Source)) + terms[i++] = metadata.Source; + if (!string.IsNullOrEmpty(metadata.Tags)) + terms[i++] = metadata.Tags; + return terms[..i]; + } private static string getVersionString(IBeatmapInfo beatmapInfo) => string.IsNullOrEmpty(beatmapInfo.DifficultyName) ? string.Empty : $"[{beatmapInfo.DifficultyName}]"; } diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs index 837939716b..75bf8b2bbc 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs @@ -55,12 +55,31 @@ namespace osu.Game.Screens.Select.Carousel match &= !criteria.UserStarDifficulty.HasFilter || criteria.UserStarDifficulty.IsInRange(BeatmapInfo.StarRating); - if (match && criteria.SearchTerms.Length > 0) + if (!match) { - string[] terms = BeatmapInfo.GetSearchableTerms(); + Filtered.Value = !match; + return; + } + + if (criteria.SearchTerms.Length > 0) + { + var terms = BeatmapInfo.GetSearchableTerms(); foreach (string criteriaTerm in criteria.SearchTerms) - match &= terms.Any(term => term.Contains(criteriaTerm, StringComparison.InvariantCultureIgnoreCase)); + { + bool any = false; + + // ReSharper disable once LoopCanBeConvertedToQuery + foreach (string term in terms) + { + if (!term.Contains(criteriaTerm, StringComparison.InvariantCultureIgnoreCase)) continue; + + any = true; + break; + } + + match &= any; + } // if a match wasn't found via text matching of terms, do a second catch-all check matching against online IDs. // this should be done after text matching so we can prioritise matching numbers in metadata. @@ -71,8 +90,13 @@ namespace osu.Game.Screens.Select.Carousel } } - if (match) - match &= criteria.CollectionBeatmapMD5Hashes?.Contains(BeatmapInfo.MD5Hash) ?? true; + if (!match) + { + Filtered.Value = !match; + return; + } + + match &= criteria.CollectionBeatmapMD5Hashes?.Contains(BeatmapInfo.MD5Hash) ?? true; if (match && criteria.RulesetCriteria != null) match &= criteria.RulesetCriteria.Matches(BeatmapInfo); From d39b8c7c23046b13af95c212f7278e4f3abcdf21 Mon Sep 17 00:00:00 2001 From: tsrk Date: Fri, 3 Mar 2023 19:35:45 +0000 Subject: [PATCH 45/84] fix(SkinnableAvatar): update outdated interface --- osu.Game/Screens/Play/HUD/SkinnableAvatar.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/HUD/SkinnableAvatar.cs b/osu.Game/Screens/Play/HUD/SkinnableAvatar.cs index d675176a0a..7bb1467c1d 100644 --- a/osu.Game/Screens/Play/HUD/SkinnableAvatar.cs +++ b/osu.Game/Screens/Play/HUD/SkinnableAvatar.cs @@ -12,7 +12,7 @@ using osuTK; namespace osu.Game.Screens.Play.HUD { - public class SkinnableAvatar : CompositeDrawable, ISkinnableDrawable + public partial class SkinnableAvatar : CompositeDrawable, ISerialisableDrawable { [SettingSource("Corner radius", "How much the edges should be rounded.")] public new BindableFloat CornerRadius { get; set; } = new BindableFloat From d5ba5eed88d154130802a92de8a33382f0334de8 Mon Sep 17 00:00:00 2001 From: tsrk Date: Fri, 3 Mar 2023 23:47:22 +0000 Subject: [PATCH 46/84] fix(SkinnableAvatar): init `avatar.CornerRadius` --- osu.Game/Screens/Play/HUD/SkinnableAvatar.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/Play/HUD/SkinnableAvatar.cs b/osu.Game/Screens/Play/HUD/SkinnableAvatar.cs index 7bb1467c1d..41fe8c6a06 100644 --- a/osu.Game/Screens/Play/HUD/SkinnableAvatar.cs +++ b/osu.Game/Screens/Play/HUD/SkinnableAvatar.cs @@ -42,6 +42,7 @@ namespace osu.Game.Screens.Play.HUD base.LoadComplete(); avatar.User = gameplayState.Score.ScoreInfo.User; + avatar.CornerRadius = CornerRadius.Value; CornerRadius.BindValueChanged(e => avatar.CornerRadius = e.NewValue); } From 3dd3b5e77ac8f7a5d9c51567b3e38cfd021b9ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 4 Mar 2023 13:17:54 +0100 Subject: [PATCH 47/84] Add failing test case --- .../TestSceneSkinEditorNavigation.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs b/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs index 467b943ea0..baafa630a1 100644 --- a/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs +++ b/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs @@ -188,6 +188,30 @@ namespace osu.Game.Tests.Visual.Navigation AddUntilStep("mod overlay closed", () => songSelect.ModSelectOverlay.State.Value == Visibility.Hidden); } + [Test] + public void TestChangeToNonSkinnableScreen() + { + advanceToSongSelect(); + openSkinEditor(); + AddAssert("blueprint container present", () => skinEditor.ChildrenOfType().Count(), () => Is.EqualTo(1)); + AddAssert("placeholder not present", () => skinEditor.ChildrenOfType().Count(), () => Is.Zero); + + AddStep("add skinnable component", () => + { + skinEditor.ChildrenOfType().First().TriggerClick(); + }); + AddUntilStep("newly added component selected", () => skinEditor.SelectedComponents, () => Has.Count.EqualTo(1)); + + AddStep("exit to main menu", () => Game.ScreenStack.CurrentScreen.Exit()); + AddAssert("selection cleared", () => skinEditor.SelectedComponents, () => Has.Count.Zero); + AddAssert("blueprint container not present", () => skinEditor.ChildrenOfType().Count(), () => Is.Zero); + AddAssert("placeholder present", () => skinEditor.ChildrenOfType().Count(), () => Is.EqualTo(1)); + + advanceToSongSelect(); + AddAssert("blueprint container present", () => skinEditor.ChildrenOfType().Count(), () => Is.EqualTo(1)); + AddAssert("placeholder not present", () => skinEditor.ChildrenOfType().Count(), () => Is.Zero); + } + private void advanceToSongSelect() { PushAndConfirm(() => songSelect = new TestPlaySongSelect()); From 15409b9c15fc827581ff97b809707fb506548b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 4 Mar 2023 13:18:34 +0100 Subject: [PATCH 48/84] Fix skin selection not clearing on exit to non-skinnable screen --- osu.Game/Overlays/SkinEditor/SkinEditor.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinEditor.cs b/osu.Game/Overlays/SkinEditor/SkinEditor.cs index 02ede8c08b..20de9bbe1c 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditor.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditor.cs @@ -323,13 +323,13 @@ namespace osu.Game.Overlays.SkinEditor foreach (var toolbox in componentsSidebar.OfType()) toolbox.Expire(); + SelectedComponents.Clear(); + if (target.NewValue == null) return; Debug.Assert(content != null); - SelectedComponents.Clear(); - var skinComponentsContainer = getTarget(target.NewValue); if (skinComponentsContainer == null) From 2f25fb4083b214ef02b0f2e527b7ef41251f41d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 4 Mar 2023 13:22:43 +0100 Subject: [PATCH 49/84] Move `NonSkinnableScreenPlaceholder` to outer scope --- .../TestSceneSkinEditorNavigation.cs | 6 +- .../NonSkinnableScreenPlaceholder.cs | 75 +++++++++++++++++++ .../SkinEditor/SkinBlueprintContainer.cs | 66 ---------------- 3 files changed, 78 insertions(+), 69 deletions(-) create mode 100644 osu.Game/Overlays/SkinEditor/NonSkinnableScreenPlaceholder.cs diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs b/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs index baafa630a1..10e8bb21cf 100644 --- a/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs +++ b/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs @@ -194,7 +194,7 @@ namespace osu.Game.Tests.Visual.Navigation advanceToSongSelect(); openSkinEditor(); AddAssert("blueprint container present", () => skinEditor.ChildrenOfType().Count(), () => Is.EqualTo(1)); - AddAssert("placeholder not present", () => skinEditor.ChildrenOfType().Count(), () => Is.Zero); + AddAssert("placeholder not present", () => skinEditor.ChildrenOfType().Count(), () => Is.Zero); AddStep("add skinnable component", () => { @@ -205,11 +205,11 @@ namespace osu.Game.Tests.Visual.Navigation AddStep("exit to main menu", () => Game.ScreenStack.CurrentScreen.Exit()); AddAssert("selection cleared", () => skinEditor.SelectedComponents, () => Has.Count.Zero); AddAssert("blueprint container not present", () => skinEditor.ChildrenOfType().Count(), () => Is.Zero); - AddAssert("placeholder present", () => skinEditor.ChildrenOfType().Count(), () => Is.EqualTo(1)); + AddAssert("placeholder present", () => skinEditor.ChildrenOfType().Count(), () => Is.EqualTo(1)); advanceToSongSelect(); AddAssert("blueprint container present", () => skinEditor.ChildrenOfType().Count(), () => Is.EqualTo(1)); - AddAssert("placeholder not present", () => skinEditor.ChildrenOfType().Count(), () => Is.Zero); + AddAssert("placeholder not present", () => skinEditor.ChildrenOfType().Count(), () => Is.Zero); } private void advanceToSongSelect() diff --git a/osu.Game/Overlays/SkinEditor/NonSkinnableScreenPlaceholder.cs b/osu.Game/Overlays/SkinEditor/NonSkinnableScreenPlaceholder.cs new file mode 100644 index 0000000000..daaa92035e --- /dev/null +++ b/osu.Game/Overlays/SkinEditor/NonSkinnableScreenPlaceholder.cs @@ -0,0 +1,75 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.UserInterfaceV2; +using osuTK; + +namespace osu.Game.Overlays.SkinEditor +{ + public partial class NonSkinnableScreenPlaceholder : CompositeDrawable + { + [Resolved] + private SkinEditorOverlay? skinEditorOverlay { get; set; } + + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { + RelativeSizeAxes = Axes.Both; + + InternalChildren = new Drawable[] + { + new Box + { + Colour = colourProvider.Dark6, + RelativeSizeAxes = Axes.Both, + Alpha = 0.95f, + }, + new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Spacing = new Vector2(0, 5), + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + new SpriteIcon + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Icon = FontAwesome.Solid.ExclamationCircle, + Size = new Vector2(24), + Y = -5, + }, + new OsuTextFlowContainer(t => t.Font = OsuFont.Default.With(weight: FontWeight.SemiBold, size: 18)) + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + TextAnchor = Anchor.Centre, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Text = "Please navigate to a skinnable screen using the scene library", + }, + new RoundedButton + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Width = 200, + Margin = new MarginPadding { Top = 20 }, + Action = () => skinEditorOverlay?.Hide(), + Text = "Return to game" + } + } + }, + }; + } + } +} diff --git a/osu.Game/Overlays/SkinEditor/SkinBlueprintContainer.cs b/osu.Game/Overlays/SkinEditor/SkinBlueprintContainer.cs index 08b4c85e4a..82322a2666 100644 --- a/osu.Game/Overlays/SkinEditor/SkinBlueprintContainer.cs +++ b/osu.Game/Overlays/SkinEditor/SkinBlueprintContainer.cs @@ -8,14 +8,8 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; using osu.Framework.Testing; -using osu.Game.Graphics; -using osu.Game.Graphics.Containers; -using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Rulesets.Edit; using osu.Game.Screens.Edit.Compose.Components; using osu.Game.Skinning; @@ -160,65 +154,5 @@ namespace osu.Game.Overlays.SkinEditor foreach (var list in targetComponents) list.UnbindAll(); } - - public partial class NonSkinnableScreenPlaceholder : CompositeDrawable - { - [Resolved] - private SkinEditorOverlay? skinEditorOverlay { get; set; } - - [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider) - { - RelativeSizeAxes = Axes.Both; - - InternalChildren = new Drawable[] - { - new Box - { - Colour = colourProvider.Dark6, - RelativeSizeAxes = Axes.Both, - Alpha = 0.95f, - }, - new FillFlowContainer - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Spacing = new Vector2(0, 5), - Direction = FillDirection.Vertical, - Children = new Drawable[] - { - new SpriteIcon - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Icon = FontAwesome.Solid.ExclamationCircle, - Size = new Vector2(24), - Y = -5, - }, - new OsuTextFlowContainer(t => t.Font = OsuFont.Default.With(weight: FontWeight.SemiBold, size: 18)) - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - TextAnchor = Anchor.Centre, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Text = "Please navigate to a skinnable screen using the scene library", - }, - new RoundedButton - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Width = 200, - Margin = new MarginPadding { Top = 20 }, - Action = () => skinEditorOverlay?.Hide(), - Text = "Return to game" - } - } - }, - }; - } - } } } From 49e298e3049760572133355a1518416b551dfe53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 4 Mar 2023 13:33:21 +0100 Subject: [PATCH 50/84] Accept `ISerialisableDrawableContainer` directly in `SkinBlueprintContainer` An end result of #22674 is that `SkinBlueprintContainer`s are only ever created by supplying a `SkinComponentsContainer` to them. However, `SkinBlueprintContainer` still contained remnants of code that suggested it was designed to handle cases where more than the drawable supplied to it contained more than one `ISerialisableDrawableContainer`, or even zero. The zero path is totally dead right now (because every `SkinComponentsContainer` is *by necessity* an `ISerialisableDrawableContainer`), and the more-than-one path is dead *for now* (and potentially forever?). Therefore, just hard-couple `SkinBlueprintContainer` to receive a single target container. --- .../SkinEditor/SkinBlueprintContainer.cs | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinBlueprintContainer.cs b/osu.Game/Overlays/SkinEditor/SkinBlueprintContainer.cs index 82322a2666..3f8d9f80d4 100644 --- a/osu.Game/Overlays/SkinEditor/SkinBlueprintContainer.cs +++ b/osu.Game/Overlays/SkinEditor/SkinBlueprintContainer.cs @@ -7,9 +7,7 @@ using System.Diagnostics; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Graphics; using osu.Framework.Input.Events; -using osu.Framework.Testing; using osu.Game.Rulesets.Edit; using osu.Game.Screens.Edit.Compose.Components; using osu.Game.Skinning; @@ -20,16 +18,16 @@ namespace osu.Game.Overlays.SkinEditor { public partial class SkinBlueprintContainer : BlueprintContainer { - private readonly Drawable target; + private readonly ISerialisableDrawableContainer targetContainer; private readonly List> targetComponents = new List>(); [Resolved] private SkinEditor editor { get; set; } = null!; - public SkinBlueprintContainer(Drawable target) + public SkinBlueprintContainer(ISerialisableDrawableContainer targetContainer) { - this.target = target; + this.targetContainer = targetContainer; } protected override void LoadComplete() @@ -38,22 +36,10 @@ namespace osu.Game.Overlays.SkinEditor SelectedItems.BindTo(editor.SelectedComponents); - // track each target container on the current screen. - var targetContainers = target.ChildrenOfType().ToArray(); + var bindableList = new BindableList { BindTarget = targetContainer.Components }; + bindableList.BindCollectionChanged(componentsChanged, true); - if (targetContainers.Length == 0) - { - AddInternal(new NonSkinnableScreenPlaceholder()); - return; - } - - foreach (var targetContainer in targetContainers) - { - var bindableList = new BindableList { BindTarget = targetContainer.Components }; - bindableList.BindCollectionChanged(componentsChanged, true); - - targetComponents.Add(bindableList); - } + targetComponents.Add(bindableList); } private void componentsChanged(object? sender, NotifyCollectionChangedEventArgs e) => Schedule(() => From d233f3a3ab5f606c308d7682b6b3a121e2e0af6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 4 Mar 2023 13:49:10 +0100 Subject: [PATCH 51/84] Show non-skinnable screen placeholder at higher level --- osu.Game/Overlays/SkinEditor/SkinEditor.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinEditor.cs b/osu.Game/Overlays/SkinEditor/SkinEditor.cs index 20de9bbe1c..769cf49fbc 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditor.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditor.cs @@ -304,7 +304,8 @@ namespace osu.Game.Overlays.SkinEditor changeHandler?.Dispose(); // Immediately clear the previous blueprint container to ensure it doesn't try to interact with the old target. - content?.Clear(); + if (content?.Child is SkinBlueprintContainer) + content.Clear(); Scheduler.AddOnce(loadBlueprintContainer); Scheduler.AddOnce(populateSettings); @@ -325,15 +326,15 @@ namespace osu.Game.Overlays.SkinEditor SelectedComponents.Clear(); - if (target.NewValue == null) - return; - Debug.Assert(content != null); var skinComponentsContainer = getTarget(target.NewValue); - if (skinComponentsContainer == null) + if (target.NewValue == null || skinComponentsContainer == null) + { + content.Child = new NonSkinnableScreenPlaceholder(); return; + } changeHandler = new SkinEditorChangeHandler(skinComponentsContainer); changeHandler.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true); From 9d4bb2ecf7664fb5cdfd97c0e1701d05b77f3f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 4 Mar 2023 14:07:35 +0100 Subject: [PATCH 52/84] Add failing test coverage for clearing sidebar contents --- .../Visual/Navigation/TestSceneSkinEditorNavigation.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs b/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs index 10e8bb21cf..bedb2ceaa1 100644 --- a/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs +++ b/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs @@ -15,6 +15,7 @@ using osu.Game.Overlays.Settings; using osu.Game.Overlays.SkinEditor; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Osu.Mods; +using osu.Game.Screens.Edit.Components; using osu.Game.Screens.Play; using osu.Game.Screens.Play.HUD.HitErrorMeters; using osu.Game.Tests.Beatmaps.IO; @@ -195,6 +196,7 @@ namespace osu.Game.Tests.Visual.Navigation openSkinEditor(); AddAssert("blueprint container present", () => skinEditor.ChildrenOfType().Count(), () => Is.EqualTo(1)); AddAssert("placeholder not present", () => skinEditor.ChildrenOfType().Count(), () => Is.Zero); + AddAssert("editor sidebars not empty", () => skinEditor.ChildrenOfType().SelectMany(sidebar => sidebar.Children).Count(), () => Is.GreaterThan(0)); AddStep("add skinnable component", () => { @@ -206,10 +208,12 @@ namespace osu.Game.Tests.Visual.Navigation AddAssert("selection cleared", () => skinEditor.SelectedComponents, () => Has.Count.Zero); AddAssert("blueprint container not present", () => skinEditor.ChildrenOfType().Count(), () => Is.Zero); AddAssert("placeholder present", () => skinEditor.ChildrenOfType().Count(), () => Is.EqualTo(1)); + AddAssert("editor sidebars empty", () => skinEditor.ChildrenOfType().SelectMany(sidebar => sidebar.Children).Count(), () => Is.Zero); advanceToSongSelect(); AddAssert("blueprint container present", () => skinEditor.ChildrenOfType().Count(), () => Is.EqualTo(1)); AddAssert("placeholder not present", () => skinEditor.ChildrenOfType().Count(), () => Is.Zero); + AddAssert("editor sidebars not empty", () => skinEditor.ChildrenOfType().SelectMany(sidebar => sidebar.Children).Count(), () => Is.GreaterThan(0)); } private void advanceToSongSelect() From 60cdd3c0706a7be59eeef64eb6cb3b362d842aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 4 Mar 2023 14:09:58 +0100 Subject: [PATCH 53/84] Clear components sidebar unconditionally on every target change Fixes the working layer dropdown lingering after exiting from a skinnable screen to a non-skinnable one. --- osu.Game/Overlays/SkinEditor/SkinEditor.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Overlays/SkinEditor/SkinEditor.cs b/osu.Game/Overlays/SkinEditor/SkinEditor.cs index 769cf49fbc..49cacf9498 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditor.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditor.cs @@ -324,6 +324,7 @@ namespace osu.Game.Overlays.SkinEditor foreach (var toolbox in componentsSidebar.OfType()) toolbox.Expire(); + componentsSidebar.Clear(); SelectedComponents.Clear(); Debug.Assert(content != null); From 31854188348e34fc28ba34c63ba3bc215301ad43 Mon Sep 17 00:00:00 2001 From: OliBomby Date: Sat, 4 Mar 2023 15:14:22 +0100 Subject: [PATCH 54/84] Add benchmarks for carousel beatmap filter --- .../BenchmarkCarouselFilter.cs | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 osu.Game.Benchmarks/BenchmarkCarouselFilter.cs diff --git a/osu.Game.Benchmarks/BenchmarkCarouselFilter.cs b/osu.Game.Benchmarks/BenchmarkCarouselFilter.cs new file mode 100644 index 0000000000..8f7027da17 --- /dev/null +++ b/osu.Game.Benchmarks/BenchmarkCarouselFilter.cs @@ -0,0 +1,123 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using BenchmarkDotNet.Attributes; +using osu.Game.Beatmaps; +using osu.Game.Rulesets; +using osu.Game.Screens.Select; +using osu.Game.Screens.Select.Carousel; + +namespace osu.Game.Benchmarks +{ + public class BenchmarkCarouselFilter : BenchmarkTest + { + private BeatmapInfo getExampleBeatmap() => new BeatmapInfo + { + Ruleset = new RulesetInfo + { + ShortName = "osu", + OnlineID = 0 + }, + StarRating = 4.0d, + Difficulty = new BeatmapDifficulty + { + ApproachRate = 5.0f, + DrainRate = 3.0f, + CircleSize = 2.0f, + }, + Metadata = new BeatmapMetadata + { + Artist = "The Artist", + ArtistUnicode = "check unicode too", + Title = "Title goes here", + TitleUnicode = "Title goes here", + Author = { Username = "The Author" }, + Source = "unit tests", + Tags = "look for tags too", + }, + DifficultyName = "version as well", + Length = 2500, + BPM = 160, + BeatDivisor = 12, + Status = BeatmapOnlineStatus.Loved + }; + + private CarouselBeatmap carouselBeatmap = null!; + private FilterCriteria criteria1 = null!; + private FilterCriteria criteria2 = null!; + private FilterCriteria criteria3 = null!; + private FilterCriteria criteria4 = null!; + private FilterCriteria criteria5 = null!; + private FilterCriteria criteria6 = null!; + + public override void SetUp() + { + var beatmap = getExampleBeatmap(); + beatmap.OnlineID = 20201010; + beatmap.BeatmapSet = new BeatmapSetInfo { OnlineID = 1535 }; + carouselBeatmap = new CarouselBeatmap(beatmap); + criteria1 = new FilterCriteria(); + criteria2 = new FilterCriteria + { + Ruleset = new RulesetInfo { ShortName = "catch" } + }; + criteria3 = new FilterCriteria + { + Ruleset = new RulesetInfo { OnlineID = 6 }, + AllowConvertedBeatmaps = true, + BPM = new FilterCriteria.OptionalRange + { + IsUpperInclusive = false, + Max = 160d + } + }; + criteria4 = new FilterCriteria + { + Ruleset = new RulesetInfo { OnlineID = 6 }, + AllowConvertedBeatmaps = true, + SearchText = "an artist" + }; + criteria5 = new FilterCriteria + { + Creator = new FilterCriteria.OptionalTextFilter { SearchTerm = "the author AND then something else" } + }; + criteria6 = new FilterCriteria { SearchText = "20201010" }; + } + + [Benchmark] + public void CarouselBeatmapFilter() + { + carouselBeatmap.Filter(criteria1); + } + + [Benchmark] + public void CriteriaMatchingSpecificRuleset() + { + carouselBeatmap.Filter(criteria2); + } + + [Benchmark] + public void CriteriaMatchingRangeMax() + { + carouselBeatmap.Filter(criteria3); + } + + [Benchmark] + public void CriteriaMatchingTerms() + { + carouselBeatmap.Filter(criteria4); + } + + [Benchmark] + public void CriteriaMatchingCreator() + { + carouselBeatmap.Filter(criteria5); + } + + [Benchmark] + public void CriteriaMatchingBeatmapIDs() + { + carouselBeatmap.Filter(criteria6); + } + } +} From b90c389ff04ffa90bce040bbaa3f531173f93867 Mon Sep 17 00:00:00 2001 From: OliBomby Date: Sat, 4 Mar 2023 15:42:35 +0100 Subject: [PATCH 55/84] using List instead of Span in GetSearchableTerms --- osu.Game/Beatmaps/BeatmapInfoExtensions.cs | 39 +++++++++---------- .../Select/Carousel/CarouselBeatmap.cs | 2 +- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapInfoExtensions.cs b/osu.Game/Beatmaps/BeatmapInfoExtensions.cs index e14a44ec58..7e336dcde2 100644 --- a/osu.Game/Beatmaps/BeatmapInfoExtensions.cs +++ b/osu.Game/Beatmaps/BeatmapInfoExtensions.cs @@ -1,7 +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 System.Collections.Generic; using osu.Framework.Localisation; namespace osu.Game.Beatmaps @@ -29,28 +29,25 @@ namespace osu.Game.Beatmaps return new RomanisableString($"{metadata.GetPreferred(true)}".Trim(), $"{metadata.GetPreferred(false)}".Trim()); } - public static ReadOnlySpan GetSearchableTerms(this IBeatmapInfo beatmapInfo) + public static List GetSearchableTerms(this IBeatmapInfo beatmapInfo) { - Span terms = new string[8]; - int i = 0; - if (!string.IsNullOrEmpty(beatmapInfo.DifficultyName)) - terms[i++] = beatmapInfo.DifficultyName; + var terms = new List(8); var metadata = beatmapInfo.Metadata; - if (!string.IsNullOrEmpty(metadata.Author.Username)) - terms[i++] = metadata.Author.Username; - if (!string.IsNullOrEmpty(metadata.Artist)) - terms[i++] = metadata.Artist; - if (!string.IsNullOrEmpty(metadata.ArtistUnicode)) - terms[i++] = metadata.ArtistUnicode; - if (!string.IsNullOrEmpty(metadata.Title)) - terms[i++] = metadata.Title; - if (!string.IsNullOrEmpty(metadata.TitleUnicode)) - terms[i++] = metadata.TitleUnicode; - if (!string.IsNullOrEmpty(metadata.Source)) - terms[i++] = metadata.Source; - if (!string.IsNullOrEmpty(metadata.Tags)) - terms[i++] = metadata.Tags; - return terms[..i]; + addIfNotNull(beatmapInfo.DifficultyName); + addIfNotNull(metadata.Author.Username); + addIfNotNull(metadata.Artist); + addIfNotNull(metadata.ArtistUnicode); + addIfNotNull(metadata.Title); + addIfNotNull(metadata.TitleUnicode); + addIfNotNull(metadata.Source); + addIfNotNull(metadata.Tags); + return terms; + + void addIfNotNull(string? s) + { + if (!string.IsNullOrEmpty(s)) + terms.Add(s); + } } private static string getVersionString(IBeatmapInfo beatmapInfo) => string.IsNullOrEmpty(beatmapInfo.DifficultyName) ? string.Empty : $"[{beatmapInfo.DifficultyName}]"; diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs index 75bf8b2bbc..eb9fd09224 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs @@ -69,7 +69,7 @@ namespace osu.Game.Screens.Select.Carousel { bool any = false; - // ReSharper disable once LoopCanBeConvertedToQuery + // ReSharper disable once ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator foreach (string term in terms) { if (!term.Contains(criteriaTerm, StringComparison.InvariantCultureIgnoreCase)) continue; From 70a925aab178706afc2fedff3c3ed47ec1f72002 Mon Sep 17 00:00:00 2001 From: OliBomby Date: Sat, 4 Mar 2023 16:49:33 +0100 Subject: [PATCH 56/84] added extra early-returns --- osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs index eb9fd09224..2cfa163b7a 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs @@ -49,6 +49,12 @@ namespace osu.Game.Screens.Select.Carousel match &= !criteria.BeatDivisor.HasFilter || criteria.BeatDivisor.IsInRange(BeatmapInfo.BeatDivisor); match &= !criteria.OnlineStatus.HasFilter || criteria.OnlineStatus.IsInRange(BeatmapInfo.Status); + if (!match) + { + Filtered.Value = !match; + return; + } + match &= !criteria.Creator.HasFilter || criteria.Creator.Matches(BeatmapInfo.Metadata.Author.Username); match &= !criteria.Artist.HasFilter || criteria.Artist.Matches(BeatmapInfo.Metadata.Artist) || criteria.Artist.Matches(BeatmapInfo.Metadata.ArtistUnicode); @@ -78,7 +84,10 @@ namespace osu.Game.Screens.Select.Carousel break; } - match &= any; + if (any) continue; + + match = false; + break; } // if a match wasn't found via text matching of terms, do a second catch-all check matching against online IDs. From 5146f7c9784b38988b5dbfa2397e91330dd942dc Mon Sep 17 00:00:00 2001 From: OliBomby Date: Sat, 4 Mar 2023 16:49:46 +0100 Subject: [PATCH 57/84] using array again in GetSearchableTerms --- osu.Game/Beatmaps/BeatmapInfoExtensions.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapInfoExtensions.cs b/osu.Game/Beatmaps/BeatmapInfoExtensions.cs index 7e336dcde2..7d6667cdcd 100644 --- a/osu.Game/Beatmaps/BeatmapInfoExtensions.cs +++ b/osu.Game/Beatmaps/BeatmapInfoExtensions.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 System.Collections.Generic; using osu.Framework.Localisation; @@ -29,9 +30,10 @@ namespace osu.Game.Beatmaps return new RomanisableString($"{metadata.GetPreferred(true)}".Trim(), $"{metadata.GetPreferred(false)}".Trim()); } - public static List GetSearchableTerms(this IBeatmapInfo beatmapInfo) + public static ReadOnlySpan GetSearchableTerms(this IBeatmapInfo beatmapInfo) { - var terms = new List(8); + string[] terms = new string[8]; + int i = 0; var metadata = beatmapInfo.Metadata; addIfNotNull(beatmapInfo.DifficultyName); addIfNotNull(metadata.Author.Username); @@ -41,12 +43,12 @@ namespace osu.Game.Beatmaps addIfNotNull(metadata.TitleUnicode); addIfNotNull(metadata.Source); addIfNotNull(metadata.Tags); - return terms; + return terms.AsSpan(0, i); void addIfNotNull(string? s) { if (!string.IsNullOrEmpty(s)) - terms.Add(s); + terms[i++] = s; } } From b0cd801405c26fe325cd11aad75a6e2734c198a5 Mon Sep 17 00:00:00 2001 From: OliBomby Date: Sat, 4 Mar 2023 19:34:22 +0100 Subject: [PATCH 58/84] fix code quality --- osu.Game/Beatmaps/BeatmapInfoExtensions.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Beatmaps/BeatmapInfoExtensions.cs b/osu.Game/Beatmaps/BeatmapInfoExtensions.cs index 7d6667cdcd..460944d2fa 100644 --- a/osu.Game/Beatmaps/BeatmapInfoExtensions.cs +++ b/osu.Game/Beatmaps/BeatmapInfoExtensions.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System; -using System.Collections.Generic; using osu.Framework.Localisation; namespace osu.Game.Beatmaps From 92f94278c1307d194cf9db6b378c743a495b0f63 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sat, 4 Mar 2023 13:32:44 -0800 Subject: [PATCH 59/84] Fix external links not working on Android --- osu.Android/AndroidManifest.xml | 7 +++++++ osu.Game.Rulesets.Catch.Tests.Android/AndroidManifest.xml | 7 +++++++ osu.Game.Rulesets.Mania.Tests.Android/AndroidManifest.xml | 7 +++++++ osu.Game.Rulesets.Osu.Tests.Android/AndroidManifest.xml | 7 +++++++ osu.Game.Rulesets.Taiko.Tests.Android/AndroidManifest.xml | 7 +++++++ osu.Game.Tests.Android/AndroidManifest.xml | 7 +++++++ 6 files changed, 42 insertions(+) diff --git a/osu.Android/AndroidManifest.xml b/osu.Android/AndroidManifest.xml index bc2f49b1a9..d97089a870 100644 --- a/osu.Android/AndroidManifest.xml +++ b/osu.Android/AndroidManifest.xml @@ -2,4 +2,11 @@ + + + + + + + \ No newline at end of file diff --git a/osu.Game.Rulesets.Catch.Tests.Android/AndroidManifest.xml b/osu.Game.Rulesets.Catch.Tests.Android/AndroidManifest.xml index bf7c0bfeca..09da3c7dcc 100644 --- a/osu.Game.Rulesets.Catch.Tests.Android/AndroidManifest.xml +++ b/osu.Game.Rulesets.Catch.Tests.Android/AndroidManifest.xml @@ -3,4 +3,11 @@ + + + + + + + \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania.Tests.Android/AndroidManifest.xml b/osu.Game.Rulesets.Mania.Tests.Android/AndroidManifest.xml index 4a1545a423..b565c16697 100644 --- a/osu.Game.Rulesets.Mania.Tests.Android/AndroidManifest.xml +++ b/osu.Game.Rulesets.Mania.Tests.Android/AndroidManifest.xml @@ -2,4 +2,11 @@ + + + + + + + \ No newline at end of file diff --git a/osu.Game.Rulesets.Osu.Tests.Android/AndroidManifest.xml b/osu.Game.Rulesets.Osu.Tests.Android/AndroidManifest.xml index 45d27dda70..b9569dab31 100644 --- a/osu.Game.Rulesets.Osu.Tests.Android/AndroidManifest.xml +++ b/osu.Game.Rulesets.Osu.Tests.Android/AndroidManifest.xml @@ -2,4 +2,11 @@ + + + + + + + \ No newline at end of file diff --git a/osu.Game.Rulesets.Taiko.Tests.Android/AndroidManifest.xml b/osu.Game.Rulesets.Taiko.Tests.Android/AndroidManifest.xml index 452b9683ec..7c10c319ed 100644 --- a/osu.Game.Rulesets.Taiko.Tests.Android/AndroidManifest.xml +++ b/osu.Game.Rulesets.Taiko.Tests.Android/AndroidManifest.xml @@ -2,4 +2,11 @@ + + + + + + + \ No newline at end of file diff --git a/osu.Game.Tests.Android/AndroidManifest.xml b/osu.Game.Tests.Android/AndroidManifest.xml index f25b2e5328..be4a67147d 100644 --- a/osu.Game.Tests.Android/AndroidManifest.xml +++ b/osu.Game.Tests.Android/AndroidManifest.xml @@ -2,4 +2,11 @@ + + + + + + + \ No newline at end of file From 5d6ab5f465a3778285d805634418d1ab5b94d3db Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sat, 4 Mar 2023 16:07:29 -0800 Subject: [PATCH 60/84] Add `mailto` scheme to intent queries --- osu.Android/AndroidManifest.xml | 5 +++++ osu.Game.Rulesets.Catch.Tests.Android/AndroidManifest.xml | 5 +++++ osu.Game.Rulesets.Mania.Tests.Android/AndroidManifest.xml | 5 +++++ osu.Game.Rulesets.Osu.Tests.Android/AndroidManifest.xml | 5 +++++ osu.Game.Rulesets.Taiko.Tests.Android/AndroidManifest.xml | 5 +++++ osu.Game.Tests.Android/AndroidManifest.xml | 5 +++++ 6 files changed, 30 insertions(+) diff --git a/osu.Android/AndroidManifest.xml b/osu.Android/AndroidManifest.xml index d97089a870..9ea57969b7 100644 --- a/osu.Android/AndroidManifest.xml +++ b/osu.Android/AndroidManifest.xml @@ -8,5 +8,10 @@ + + + + + \ No newline at end of file diff --git a/osu.Game.Rulesets.Catch.Tests.Android/AndroidManifest.xml b/osu.Game.Rulesets.Catch.Tests.Android/AndroidManifest.xml index 09da3c7dcc..22b4ea9191 100644 --- a/osu.Game.Rulesets.Catch.Tests.Android/AndroidManifest.xml +++ b/osu.Game.Rulesets.Catch.Tests.Android/AndroidManifest.xml @@ -9,5 +9,10 @@ + + + + + \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania.Tests.Android/AndroidManifest.xml b/osu.Game.Rulesets.Mania.Tests.Android/AndroidManifest.xml index b565c16697..c8b0de9f42 100644 --- a/osu.Game.Rulesets.Mania.Tests.Android/AndroidManifest.xml +++ b/osu.Game.Rulesets.Mania.Tests.Android/AndroidManifest.xml @@ -8,5 +8,10 @@ + + + + + \ No newline at end of file diff --git a/osu.Game.Rulesets.Osu.Tests.Android/AndroidManifest.xml b/osu.Game.Rulesets.Osu.Tests.Android/AndroidManifest.xml index b9569dab31..d91fc062fe 100644 --- a/osu.Game.Rulesets.Osu.Tests.Android/AndroidManifest.xml +++ b/osu.Game.Rulesets.Osu.Tests.Android/AndroidManifest.xml @@ -8,5 +8,10 @@ + + + + + \ No newline at end of file diff --git a/osu.Game.Rulesets.Taiko.Tests.Android/AndroidManifest.xml b/osu.Game.Rulesets.Taiko.Tests.Android/AndroidManifest.xml index 7c10c319ed..f678d63dbb 100644 --- a/osu.Game.Rulesets.Taiko.Tests.Android/AndroidManifest.xml +++ b/osu.Game.Rulesets.Taiko.Tests.Android/AndroidManifest.xml @@ -8,5 +8,10 @@ + + + + + \ No newline at end of file diff --git a/osu.Game.Tests.Android/AndroidManifest.xml b/osu.Game.Tests.Android/AndroidManifest.xml index be4a67147d..105f2b1e8b 100644 --- a/osu.Game.Tests.Android/AndroidManifest.xml +++ b/osu.Game.Tests.Android/AndroidManifest.xml @@ -8,5 +8,10 @@ + + + + + \ No newline at end of file From d120638e68bef2e0f9a0b890955e8e0421014f8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 5 Mar 2023 13:17:46 +0100 Subject: [PATCH 61/84] Use manifest overlay and merger for intent query specs Co-authored-by: Susko3 --- osu.Android.props | 4 ++++ osu.Android/AndroidManifest.xml | 12 ------------ osu.Android/Properties/AndroidManifestOverlay.xml | 15 +++++++++++++++ .../AndroidManifest.xml | 12 ------------ .../AndroidManifest.xml | 12 ------------ .../AndroidManifest.xml | 12 ------------ .../AndroidManifest.xml | 12 ------------ osu.Game.Tests.Android/AndroidManifest.xml | 12 ------------ 8 files changed, 19 insertions(+), 72 deletions(-) create mode 100644 osu.Android/Properties/AndroidManifestOverlay.xml diff --git a/osu.Android.props b/osu.Android.props index abd8406cf7..234575fc62 100644 --- a/osu.Android.props +++ b/osu.Android.props @@ -8,10 +8,14 @@ true true + manifestmerger.jar + + + diff --git a/osu.Android/AndroidManifest.xml b/osu.Android/AndroidManifest.xml index 9ea57969b7..bc2f49b1a9 100644 --- a/osu.Android/AndroidManifest.xml +++ b/osu.Android/AndroidManifest.xml @@ -2,16 +2,4 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/osu.Android/Properties/AndroidManifestOverlay.xml b/osu.Android/Properties/AndroidManifestOverlay.xml new file mode 100644 index 0000000000..815f935383 --- /dev/null +++ b/osu.Android/Properties/AndroidManifestOverlay.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/osu.Game.Rulesets.Catch.Tests.Android/AndroidManifest.xml b/osu.Game.Rulesets.Catch.Tests.Android/AndroidManifest.xml index 22b4ea9191..bf7c0bfeca 100644 --- a/osu.Game.Rulesets.Catch.Tests.Android/AndroidManifest.xml +++ b/osu.Game.Rulesets.Catch.Tests.Android/AndroidManifest.xml @@ -3,16 +3,4 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania.Tests.Android/AndroidManifest.xml b/osu.Game.Rulesets.Mania.Tests.Android/AndroidManifest.xml index c8b0de9f42..4a1545a423 100644 --- a/osu.Game.Rulesets.Mania.Tests.Android/AndroidManifest.xml +++ b/osu.Game.Rulesets.Mania.Tests.Android/AndroidManifest.xml @@ -2,16 +2,4 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/osu.Game.Rulesets.Osu.Tests.Android/AndroidManifest.xml b/osu.Game.Rulesets.Osu.Tests.Android/AndroidManifest.xml index d91fc062fe..45d27dda70 100644 --- a/osu.Game.Rulesets.Osu.Tests.Android/AndroidManifest.xml +++ b/osu.Game.Rulesets.Osu.Tests.Android/AndroidManifest.xml @@ -2,16 +2,4 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/osu.Game.Rulesets.Taiko.Tests.Android/AndroidManifest.xml b/osu.Game.Rulesets.Taiko.Tests.Android/AndroidManifest.xml index f678d63dbb..452b9683ec 100644 --- a/osu.Game.Rulesets.Taiko.Tests.Android/AndroidManifest.xml +++ b/osu.Game.Rulesets.Taiko.Tests.Android/AndroidManifest.xml @@ -2,16 +2,4 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/osu.Game.Tests.Android/AndroidManifest.xml b/osu.Game.Tests.Android/AndroidManifest.xml index 105f2b1e8b..f25b2e5328 100644 --- a/osu.Game.Tests.Android/AndroidManifest.xml +++ b/osu.Game.Tests.Android/AndroidManifest.xml @@ -2,16 +2,4 @@ - - - - - - - - - - - - \ No newline at end of file From 908651cc11251cf80e13b8b539abcfc0bd4454a2 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Sun, 5 Mar 2023 20:57:26 +0100 Subject: [PATCH 62/84] make `ResetConfirmDialog` properly utilise its parent's logic Adjust name of `DeleteAction` to `DangerousAction` --- .../Collections/DeleteCollectionDialog.cs | 2 +- .../Overlays/Dialog/DangerousActionDialog.cs | 4 ++-- .../Overlays/Mods/DeleteModPresetDialog.cs | 2 +- .../MassDeleteConfirmationDialog.cs | 2 +- osu.Game/Overlays/SkinEditor/SkinEditor.cs | 19 ++----------------- .../DeleteDifficultyConfirmationDialog.cs | 2 +- .../Select/BeatmapClearScoresDialog.cs | 2 +- .../Screens/Select/BeatmapDeleteDialog.cs | 2 +- .../Carousel/UpdateLocalConfirmationDialog.cs | 2 +- .../Screens/Select/LocalScoreDeleteDialog.cs | 2 +- osu.Game/Screens/Select/SkinDeleteDialog.cs | 2 +- 11 files changed, 13 insertions(+), 28 deletions(-) diff --git a/osu.Game/Collections/DeleteCollectionDialog.cs b/osu.Game/Collections/DeleteCollectionDialog.cs index 4da2979481..9edc213077 100644 --- a/osu.Game/Collections/DeleteCollectionDialog.cs +++ b/osu.Game/Collections/DeleteCollectionDialog.cs @@ -13,7 +13,7 @@ namespace osu.Game.Collections public DeleteCollectionDialog(Live collection, Action deleteAction) { BodyText = collection.PerformRead(c => $"{c.Name} ({"beatmap".ToQuantity(c.BeatmapMD5Hashes.Count)})"); - DeleteAction = deleteAction; + DangerousAction = deleteAction; } } } diff --git a/osu.Game/Overlays/Dialog/DangerousActionDialog.cs b/osu.Game/Overlays/Dialog/DangerousActionDialog.cs index aaec72fc4d..85cae5e0d2 100644 --- a/osu.Game/Overlays/Dialog/DangerousActionDialog.cs +++ b/osu.Game/Overlays/Dialog/DangerousActionDialog.cs @@ -17,7 +17,7 @@ namespace osu.Game.Overlays.Dialog /// /// The action which performs the deletion. /// - protected Action? DeleteAction { get; set; } + protected Action? DangerousAction { get; set; } protected DangerousActionDialog() { @@ -30,7 +30,7 @@ namespace osu.Game.Overlays.Dialog new PopupDialogDangerousButton { Text = DeleteConfirmationDialogStrings.Confirm, - Action = () => DeleteAction?.Invoke() + Action = () => DangerousAction?.Invoke() }, new PopupDialogCancelButton { diff --git a/osu.Game/Overlays/Mods/DeleteModPresetDialog.cs b/osu.Game/Overlays/Mods/DeleteModPresetDialog.cs index 5b329a32d5..9788764453 100644 --- a/osu.Game/Overlays/Mods/DeleteModPresetDialog.cs +++ b/osu.Game/Overlays/Mods/DeleteModPresetDialog.cs @@ -12,7 +12,7 @@ namespace osu.Game.Overlays.Mods public DeleteModPresetDialog(Live modPreset) { BodyText = modPreset.PerformRead(preset => preset.Name); - DeleteAction = () => modPreset.PerformWrite(preset => preset.DeletePending = true); + DangerousAction = () => modPreset.PerformWrite(preset => preset.DeletePending = true); } } } diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/MassDeleteConfirmationDialog.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/MassDeleteConfirmationDialog.cs index 71226803c8..99ef62d94b 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/MassDeleteConfirmationDialog.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/MassDeleteConfirmationDialog.cs @@ -11,7 +11,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance public MassDeleteConfirmationDialog(Action deleteAction) { BodyText = "Everything?"; - DeleteAction = deleteAction; + DangerousAction = deleteAction; } } } diff --git a/osu.Game/Overlays/SkinEditor/SkinEditor.cs b/osu.Game/Overlays/SkinEditor/SkinEditor.cs index 5ffdaa11d4..a7fe459aa4 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditor.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditor.cs @@ -12,7 +12,6 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Framework.Input.Bindings; @@ -633,25 +632,11 @@ namespace osu.Game.Overlays.SkinEditor public partial class ResetConfirmDialog : DangerousActionDialog { - public ResetConfirmDialog(Action reset) + public ResetConfirmDialog(Action revert) { HeaderText = SkinEditorStrings.RevertToDefaultDescription; BodyText = SkinEditorStrings.ResetDialogue; - - Icon = FontAwesome.Solid.ExclamationTriangle; - - Buttons = new PopupDialogButton[] - { - new PopupDialogDangerousButton - { - Text = BeatmapOverlayStrings.UserContentConfirmButtonText, - Action = reset - }, - new PopupDialogCancelButton - { - Text = Web.CommonStrings.ButtonsCancel, - }, - }; + DangerousAction = revert; } } diff --git a/osu.Game/Screens/Edit/DeleteDifficultyConfirmationDialog.cs b/osu.Game/Screens/Edit/DeleteDifficultyConfirmationDialog.cs index 6db31967d6..8556949528 100644 --- a/osu.Game/Screens/Edit/DeleteDifficultyConfirmationDialog.cs +++ b/osu.Game/Screens/Edit/DeleteDifficultyConfirmationDialog.cs @@ -12,7 +12,7 @@ namespace osu.Game.Screens.Edit public DeleteDifficultyConfirmationDialog(BeatmapInfo beatmapInfo, Action deleteAction) { BodyText = $"\"{beatmapInfo.DifficultyName}\" difficulty"; - DeleteAction = deleteAction; + DangerousAction = deleteAction; } } } diff --git a/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs b/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs index 2704a1afb4..8efad451df 100644 --- a/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs +++ b/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs @@ -18,7 +18,7 @@ namespace osu.Game.Screens.Select public BeatmapClearScoresDialog(BeatmapInfo beatmapInfo, Action onCompletion) { BodyText = $"All local scores on {beatmapInfo.GetDisplayTitle()}"; - DeleteAction = () => + DangerousAction = () => { Task.Run(() => scoreManager.Delete(beatmapInfo)) .ContinueWith(_ => onCompletion); diff --git a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs index 0692cc3745..e98af8cca2 100644 --- a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs +++ b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs @@ -20,7 +20,7 @@ namespace osu.Game.Screens.Select [BackgroundDependencyLoader] private void load(BeatmapManager beatmapManager) { - DeleteAction = () => beatmapManager.Delete(beatmapSet); + DangerousAction = () => beatmapManager.Delete(beatmapSet); } } } diff --git a/osu.Game/Screens/Select/Carousel/UpdateLocalConfirmationDialog.cs b/osu.Game/Screens/Select/Carousel/UpdateLocalConfirmationDialog.cs index ecb21d4e2c..6157e8f6a5 100644 --- a/osu.Game/Screens/Select/Carousel/UpdateLocalConfirmationDialog.cs +++ b/osu.Game/Screens/Select/Carousel/UpdateLocalConfirmationDialog.cs @@ -15,7 +15,7 @@ namespace osu.Game.Screens.Select.Carousel HeaderText = PopupDialogStrings.UpdateLocallyModifiedText; BodyText = PopupDialogStrings.UpdateLocallyModifiedDescription; Icon = FontAwesome.Solid.ExclamationTriangle; - DeleteAction = onConfirm; + DangerousAction = onConfirm; } } } diff --git a/osu.Game/Screens/Select/LocalScoreDeleteDialog.cs b/osu.Game/Screens/Select/LocalScoreDeleteDialog.cs index 660122c80e..c4add31a4f 100644 --- a/osu.Game/Screens/Select/LocalScoreDeleteDialog.cs +++ b/osu.Game/Screens/Select/LocalScoreDeleteDialog.cs @@ -28,7 +28,7 @@ namespace osu.Game.Screens.Select BodyText = $"{score.User} ({score.DisplayAccuracy}, {score.Rank})"; Icon = FontAwesome.Regular.TrashAlt; - DeleteAction = () => scoreManager.Delete(score); + DangerousAction = () => scoreManager.Delete(score); } } } diff --git a/osu.Game/Screens/Select/SkinDeleteDialog.cs b/osu.Game/Screens/Select/SkinDeleteDialog.cs index 3c95de0620..6612ae837a 100644 --- a/osu.Game/Screens/Select/SkinDeleteDialog.cs +++ b/osu.Game/Screens/Select/SkinDeleteDialog.cs @@ -20,7 +20,7 @@ namespace osu.Game.Screens.Select [BackgroundDependencyLoader] private void load(SkinManager manager) { - DeleteAction = () => + DangerousAction = () => { manager.Delete(skin.SkinInfo.Value); manager.CurrentSkinInfo.SetDefault(); From 082bfe3621f8502b81376f5a92e031cf3c7d4803 Mon Sep 17 00:00:00 2001 From: tsrk Date: Sun, 5 Mar 2023 23:09:02 +0000 Subject: [PATCH 63/84] refactor: `SkinnableAvatar` to `PlayerAvatar` --- .../Screens/Play/HUD/{SkinnableAvatar.cs => PlayerAvatar.cs} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename osu.Game/Screens/Play/HUD/{SkinnableAvatar.cs => PlayerAvatar.cs} (92%) diff --git a/osu.Game/Screens/Play/HUD/SkinnableAvatar.cs b/osu.Game/Screens/Play/HUD/PlayerAvatar.cs similarity index 92% rename from osu.Game/Screens/Play/HUD/SkinnableAvatar.cs rename to osu.Game/Screens/Play/HUD/PlayerAvatar.cs index 41fe8c6a06..d4ab555d04 100644 --- a/osu.Game/Screens/Play/HUD/SkinnableAvatar.cs +++ b/osu.Game/Screens/Play/HUD/PlayerAvatar.cs @@ -12,7 +12,7 @@ using osuTK; namespace osu.Game.Screens.Play.HUD { - public partial class SkinnableAvatar : CompositeDrawable, ISerialisableDrawable + public partial class PlayerAvatar : CompositeDrawable, ISerialisableDrawable { [SettingSource("Corner radius", "How much the edges should be rounded.")] public new BindableFloat CornerRadius { get; set; } = new BindableFloat @@ -27,7 +27,7 @@ namespace osu.Game.Screens.Play.HUD private readonly UpdateableAvatar avatar; - public SkinnableAvatar() + public PlayerAvatar() { Size = new Vector2(128f); InternalChild = avatar = new UpdateableAvatar(isInteractive: false) From 654eacd4496cde2601015abc053d8d081f25869d Mon Sep 17 00:00:00 2001 From: tsrk Date: Sun, 5 Mar 2023 23:10:42 +0000 Subject: [PATCH 64/84] feat(l10n): localise `CornerRadius` --- .../SkinComponents/SkinnableComponentStrings.cs | 10 ++++++++++ osu.Game/Screens/Play/HUD/PlayerAvatar.cs | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs b/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs index 547df86fc7..5cec9442e4 100644 --- a/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs +++ b/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs @@ -39,6 +39,16 @@ namespace osu.Game.Localisation.SkinComponents /// public static LocalisableString TextElementTextDescription => new TranslatableString(getKey(@"text_element_text_description"), "The text to be displayed."); + /// + /// "Corner Radius" + /// + public static LocalisableString CornerRadius => new TranslatableString(getKey(@"corner_radius"), "Corner Radius"); + + /// + /// "How rounded the corners should be." + /// + public static LocalisableString CornerRadiusDescription => new TranslatableString(getKey(@"corner_radius_description"), "How rounded the corners should be."); + private static string getKey(string key) => $"{prefix}:{key}"; } } diff --git a/osu.Game/Screens/Play/HUD/PlayerAvatar.cs b/osu.Game/Screens/Play/HUD/PlayerAvatar.cs index d4ab555d04..6cea463193 100644 --- a/osu.Game/Screens/Play/HUD/PlayerAvatar.cs +++ b/osu.Game/Screens/Play/HUD/PlayerAvatar.cs @@ -6,6 +6,7 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Configuration; +using osu.Game.Localisation.SkinComponents; using osu.Game.Skinning; using osu.Game.Users.Drawables; using osuTK; @@ -14,7 +15,7 @@ namespace osu.Game.Screens.Play.HUD { public partial class PlayerAvatar : CompositeDrawable, ISerialisableDrawable { - [SettingSource("Corner radius", "How much the edges should be rounded.")] + [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.CornerRadius), nameof(SkinnableComponentStrings.CornerRadiusDescription))] public new BindableFloat CornerRadius { get; set; } = new BindableFloat { MinValue = 0, From 20a610ea6c4c407cedcdffc8a9ac3ae0fbd1f8b0 Mon Sep 17 00:00:00 2001 From: tsrk Date: Sun, 5 Mar 2023 23:15:58 +0000 Subject: [PATCH 65/84] style: a NRT pass on `UpdateableFlag` --- osu.Game/Users/Drawables/UpdateableFlag.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/osu.Game/Users/Drawables/UpdateableFlag.cs b/osu.Game/Users/Drawables/UpdateableFlag.cs index a208f3c7c4..8f8d7052e5 100644 --- a/osu.Game/Users/Drawables/UpdateableFlag.cs +++ b/osu.Game/Users/Drawables/UpdateableFlag.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -30,14 +28,14 @@ namespace osu.Game.Users.Drawables /// Perform an action in addition to showing the country ranking. /// This should be used to perform auxiliary tasks and not as a primary action for clicking a flag (to maintain a consistent UX). /// - public Action Action; + public Action? Action; public UpdateableFlag(CountryCode countryCode = CountryCode.Unknown) { CountryCode = countryCode; } - protected override Drawable CreateDrawable(CountryCode countryCode) + protected override Drawable? CreateDrawable(CountryCode countryCode) { if (countryCode == CountryCode.Unknown && !ShowPlaceholderOnUnknown) return null; @@ -56,8 +54,8 @@ namespace osu.Game.Users.Drawables }; } - [Resolved(canBeNull: true)] - private RankingsOverlay rankingsOverlay { get; set; } + [Resolved] + private RankingsOverlay? rankingsOverlay { get; set; } protected override bool OnClick(ClickEvent e) { From 07bde4990d50836a64e62f61a60f991165bb6436 Mon Sep 17 00:00:00 2001 From: tsrk Date: Sun, 5 Mar 2023 23:17:30 +0000 Subject: [PATCH 66/84] feat: implement `PlayerAvatar` --- osu.Game/Screens/Play/HUD/PlayerFlag.cs | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 osu.Game/Screens/Play/HUD/PlayerFlag.cs diff --git a/osu.Game/Screens/Play/HUD/PlayerFlag.cs b/osu.Game/Screens/Play/HUD/PlayerFlag.cs new file mode 100644 index 0000000000..17188d0009 --- /dev/null +++ b/osu.Game/Screens/Play/HUD/PlayerFlag.cs @@ -0,0 +1,38 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Skinning; +using osu.Game.Users.Drawables; +using osuTK; + +namespace osu.Game.Screens.Play.HUD +{ + public partial class PlayerFlag : CompositeDrawable, ISerialisableDrawable + { + [Resolved] + private GameplayState gameplayState { get; set; } = null!; + + private readonly UpdateableFlag flag; + + public PlayerFlag() + { + Size = new Vector2(114, 80); + InternalChild = flag = new UpdateableFlag + { + RelativeSizeAxes = Axes.Both, + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + flag.CountryCode = gameplayState.Score.ScoreInfo.User.CountryCode; + } + + public bool UsesFixedAnchor { get; set; } + } +} From ddee6400dfa3c28f476e0c9fea11a17874c82257 Mon Sep 17 00:00:00 2001 From: tsrk Date: Sun, 5 Mar 2023 23:46:51 +0000 Subject: [PATCH 67/84] test: add coverage for `Player{Avatar,Flag}` --- .../Archives/modified-argon-20230305.osk | Bin 0 -> 1897 bytes osu.Game.Tests/Skins/SkinDeserialisationTest.cs | 7 ++++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Tests/Resources/Archives/modified-argon-20230305.osk diff --git a/osu.Game.Tests/Resources/Archives/modified-argon-20230305.osk b/osu.Game.Tests/Resources/Archives/modified-argon-20230305.osk new file mode 100644 index 0000000000000000000000000000000000000000..c85f3b6352af3357089a797c287659a0d8e848f7 GIT binary patch literal 1897 zcmZ`)2{ha37XJrDwM>j<6dg)aofm6Nl`=@FlHetRpxP!SwNw*ZQW6}y5s4*KF={EH zN^R8^#bCygmIl?)Djh?_UPTSDj7j_Ey*c&X`@VC}J@-4`@1A?V@7~`N?B_rB4NU|rVlAmS1QZ5D)sBQZsC%Y@)DD`?fvQgW%$c95cG#nwX5eaNBy!>}^x zSMnoc3Ae1r;c-(M3B@4=N}}*4N1bz$rM~DOQvG&rj>c9JM;D3N!SAoqeU77@MDnSzO%AM%6NUOL18A1WCPf&1x=^Hr@-YKH;#HEae+Y?K$)9#Y zp;nQ74leahsHb|mF3#Vh5!whYHwEo9pbyiB4LJ|=_WzS(|IFS21k?HUW@x)deu|SE zay7-W`RrQ#+Um2lqAv@=yCBKoklbWQt{}W1+)sdtTOW(bo;~2>!=EPb*$XDIi@-{# zJdTBE@q7q;9w5sc$)t(`K$Q{zC<+5~!21zxU97E0*8@pJ0x>k?Q>067Xwn-aaFkl@ z9*+0=gl%$GFDSe>pM2y|arf9e_DM01wq8$Pm^!<`W^m8^Y2CufVp;Vdp8Vb2E8{mN zZwtncE^kiH6pF`XhGLyWl%Go~&CPFdp0mECH6>MyEWXe-D>w<=HN&b+n zHvTxQ&#A2@r^Q?FE^O+n-!W*D@YYu?FVAORzPojLrfOT|EO}!VJ9mclb(~0#l>XZb z(c4ukV&`+0>4li7y=#00?T+CDS8+PE_$gE_IC#8$Y^|wb)Tlbg4m)q;`(f9V$V8vB(W^<3RQMb^q4L(#q25!yjaJWPgxI?H|lk0dHv z69fR(A^`A(uv;-Cq7Q};K=2Cv)TZPNB(YN;oVan5Dgj;SmGVPav9<4gD884XAvs>8 zYp)cWU}zI{S3OH~UA5KiwxyKpxwm~0duCDLlo4!vSQCT-xC(8*>Fw(iJ434N=Sk_qq46_?0cwbTrb3fm^Ie z_w9``>IV!Cb~kcIe9W1q@W}E(?v0LzBjo0Ex0GAwih;z|%R|JIw ziO2*0f5ZqM^wjSYAg1##)PG2RKXgCg{tfjKe(e9I-~B%Jm%-mY YWDopTQJ|0q#6MmT6Yf=^#(%Q@1WNchY5)KL literal 0 HcmV?d00001 diff --git a/osu.Game.Tests/Skins/SkinDeserialisationTest.cs b/osu.Game.Tests/Skins/SkinDeserialisationTest.cs index 04b8c6dd4e..eb1df954aa 100644 --- a/osu.Game.Tests/Skins/SkinDeserialisationTest.cs +++ b/osu.Game.Tests/Skins/SkinDeserialisationTest.cs @@ -9,6 +9,7 @@ using osu.Framework.Audio.Sample; using osu.Framework.Bindables; using osu.Framework.Graphics.Textures; using osu.Framework.IO.Stores; +using osu.Framework.Logging; using osu.Game.Audio; using osu.Game.IO; using osu.Game.IO.Archives; @@ -48,7 +49,9 @@ namespace osu.Game.Tests.Skins // Covers BPM counter. "Archives/modified-default-20221205.osk", // Covers judgement counter. - "Archives/modified-default-20230117.osk" + "Archives/modified-default-20230117.osk", + // Covers player avatar and flag. + "Archives/modified-argon-20230305.osk", }; /// @@ -61,6 +64,8 @@ namespace osu.Game.Tests.Skins foreach (string oskFile in available_skins) { + Logger.Log($"Testing file {oskFile}..."); + using (var stream = TestResources.OpenResource(oskFile)) using (var storage = new ZipArchiveReader(stream)) { From 87d0bef313fc9e5563dc3d368f3daf59b437c6aa Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 6 Mar 2023 15:16:31 +0900 Subject: [PATCH 68/84] Use nullable comparison helper method instead of manual implementation --- .../Screens/Select/Carousel/CarouselBeatmapSet.cs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs index 63493a3b02..67822a27ee 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs @@ -87,7 +87,7 @@ namespace osu.Game.Screens.Select.Carousel break; case SortMode.DateRanked: - comparison = compareNullableDateTimeOffset(BeatmapSet.DateRanked, otherSet.BeatmapSet.DateRanked); + comparison = Nullable.Compare(otherSet.BeatmapSet.DateRanked, BeatmapSet.DateRanked); break; case SortMode.LastPlayed: @@ -107,7 +107,7 @@ namespace osu.Game.Screens.Select.Carousel break; case SortMode.DateSubmitted: - comparison = compareNullableDateTimeOffset(BeatmapSet.DateSubmitted, otherSet.BeatmapSet.DateSubmitted); + comparison = Nullable.Compare(otherSet.BeatmapSet.DateSubmitted, BeatmapSet.DateSubmitted); break; } @@ -124,14 +124,6 @@ namespace osu.Game.Screens.Select.Carousel return otherSet.BeatmapSet.ID.CompareTo(BeatmapSet.ID); } - private static int compareNullableDateTimeOffset(DateTimeOffset? x, DateTimeOffset? y) - { - if (x == null) return 1; - if (y == null) return -1; - - return y.Value.CompareTo(x.Value); - } - /// /// All beatmaps which are not filtered and valid for display. /// From 3a240aaa5fa1e55bcc9b50c26345ebdf0c001d99 Mon Sep 17 00:00:00 2001 From: tsrk Date: Mon, 6 Mar 2023 10:27:59 +0000 Subject: [PATCH 69/84] style: use 64 radius --- osu.Game/Screens/Play/HUD/PlayerAvatar.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/HUD/PlayerAvatar.cs b/osu.Game/Screens/Play/HUD/PlayerAvatar.cs index 6cea463193..32ed045df7 100644 --- a/osu.Game/Screens/Play/HUD/PlayerAvatar.cs +++ b/osu.Game/Screens/Play/HUD/PlayerAvatar.cs @@ -19,7 +19,7 @@ namespace osu.Game.Screens.Play.HUD public new BindableFloat CornerRadius { get; set; } = new BindableFloat { MinValue = 0, - MaxValue = 63, + MaxValue = 64, Precision = 0.01f }; From 1fcf41379d5d5c37d211644fc96e4e99c4710ab0 Mon Sep 17 00:00:00 2001 From: OliBomby Date: Mon, 6 Mar 2023 16:20:36 +0100 Subject: [PATCH 70/84] Added maintainability patch by bdach --- osu.Game/Beatmaps/BeatmapInfoExtensions.cs | 22 +++++------- .../Beatmaps/BeatmapMetadataInfoExtensions.cs | 35 +++++++++++++------ 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapInfoExtensions.cs b/osu.Game/Beatmaps/BeatmapInfoExtensions.cs index 460944d2fa..3aab9a24e1 100644 --- a/osu.Game/Beatmaps/BeatmapInfoExtensions.cs +++ b/osu.Game/Beatmaps/BeatmapInfoExtensions.cs @@ -1,7 +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 System.Collections.Generic; using osu.Framework.Localisation; namespace osu.Game.Beatmaps @@ -29,25 +29,19 @@ namespace osu.Game.Beatmaps return new RomanisableString($"{metadata.GetPreferred(true)}".Trim(), $"{metadata.GetPreferred(false)}".Trim()); } - public static ReadOnlySpan GetSearchableTerms(this IBeatmapInfo beatmapInfo) + public static List GetSearchableTerms(this IBeatmapInfo beatmapInfo) { - string[] terms = new string[8]; - int i = 0; - var metadata = beatmapInfo.Metadata; + var termsList = new List(BeatmapMetadataInfoExtensions.MAX_SEARCHABLE_TERM_COUNT + 1); + addIfNotNull(beatmapInfo.DifficultyName); - addIfNotNull(metadata.Author.Username); - addIfNotNull(metadata.Artist); - addIfNotNull(metadata.ArtistUnicode); - addIfNotNull(metadata.Title); - addIfNotNull(metadata.TitleUnicode); - addIfNotNull(metadata.Source); - addIfNotNull(metadata.Tags); - return terms.AsSpan(0, i); + + BeatmapMetadataInfoExtensions.CollectSearchableTerms(beatmapInfo.Metadata, termsList); + return termsList; void addIfNotNull(string? s) { if (!string.IsNullOrEmpty(s)) - terms[i++] = s; + termsList.Add(s); } } diff --git a/osu.Game/Beatmaps/BeatmapMetadataInfoExtensions.cs b/osu.Game/Beatmaps/BeatmapMetadataInfoExtensions.cs index 738bdb0839..fe4e815e62 100644 --- a/osu.Game/Beatmaps/BeatmapMetadataInfoExtensions.cs +++ b/osu.Game/Beatmaps/BeatmapMetadataInfoExtensions.cs @@ -3,7 +3,7 @@ #nullable disable -using System.Linq; +using System.Collections.Generic; using osu.Framework.Localisation; namespace osu.Game.Beatmaps @@ -13,16 +13,31 @@ namespace osu.Game.Beatmaps /// /// An array of all searchable terms provided in contained metadata. /// - public static string[] GetSearchableTerms(this IBeatmapMetadataInfo metadataInfo) => new[] + public static string[] GetSearchableTerms(this IBeatmapMetadataInfo metadataInfo) { - metadataInfo.Author.Username, - metadataInfo.Artist, - metadataInfo.ArtistUnicode, - metadataInfo.Title, - metadataInfo.TitleUnicode, - metadataInfo.Source, - metadataInfo.Tags - }.Where(s => !string.IsNullOrEmpty(s)).ToArray(); + var termsList = new List(MAX_SEARCHABLE_TERM_COUNT); + CollectSearchableTerms(metadataInfo, termsList); + return termsList.ToArray(); + } + + internal const int MAX_SEARCHABLE_TERM_COUNT = 7; + + internal static void CollectSearchableTerms(IBeatmapMetadataInfo metadataInfo, IList termsList) + { + addIfNotNull(metadataInfo.Author.Username); + addIfNotNull(metadataInfo.Artist); + addIfNotNull(metadataInfo.ArtistUnicode); + addIfNotNull(metadataInfo.Title); + addIfNotNull(metadataInfo.TitleUnicode); + addIfNotNull(metadataInfo.Source); + addIfNotNull(metadataInfo.Tags); + + void addIfNotNull(string s) + { + if (!string.IsNullOrEmpty(s)) + termsList.Add(s); + } + } /// /// A user-presentable display title representing this metadata. From 952814604ed43ab85b799198268cd222b7f9b9a9 Mon Sep 17 00:00:00 2001 From: tsrk Date: Mon, 6 Mar 2023 20:06:56 +0000 Subject: [PATCH 71/84] style: fix late night oopsies --- osu.Game.Tests/Skins/SkinDeserialisationTest.cs | 3 --- osu.Game/Screens/Play/HUD/PlayerAvatar.cs | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/osu.Game.Tests/Skins/SkinDeserialisationTest.cs b/osu.Game.Tests/Skins/SkinDeserialisationTest.cs index eb1df954aa..bd8088cfb6 100644 --- a/osu.Game.Tests/Skins/SkinDeserialisationTest.cs +++ b/osu.Game.Tests/Skins/SkinDeserialisationTest.cs @@ -9,7 +9,6 @@ using osu.Framework.Audio.Sample; using osu.Framework.Bindables; using osu.Framework.Graphics.Textures; using osu.Framework.IO.Stores; -using osu.Framework.Logging; using osu.Game.Audio; using osu.Game.IO; using osu.Game.IO.Archives; @@ -64,8 +63,6 @@ namespace osu.Game.Tests.Skins foreach (string oskFile in available_skins) { - Logger.Log($"Testing file {oskFile}..."); - using (var stream = TestResources.OpenResource(oskFile)) using (var storage = new ZipArchiveReader(stream)) { diff --git a/osu.Game/Screens/Play/HUD/PlayerAvatar.cs b/osu.Game/Screens/Play/HUD/PlayerAvatar.cs index 32ed045df7..d2f4f0be17 100644 --- a/osu.Game/Screens/Play/HUD/PlayerAvatar.cs +++ b/osu.Game/Screens/Play/HUD/PlayerAvatar.cs @@ -43,8 +43,7 @@ namespace osu.Game.Screens.Play.HUD base.LoadComplete(); avatar.User = gameplayState.Score.ScoreInfo.User; - avatar.CornerRadius = CornerRadius.Value; - CornerRadius.BindValueChanged(e => avatar.CornerRadius = e.NewValue); + CornerRadius.BindValueChanged(e => avatar.CornerRadius = e.NewValue, true); } public bool UsesFixedAnchor { get; set; } From fc0e27fb15e3eb1a143e5924a9adf3f472944a06 Mon Sep 17 00:00:00 2001 From: tsrk Date: Mon, 6 Mar 2023 20:11:52 +0000 Subject: [PATCH 72/84] style: use normalised `CornerRadius` values --- osu.Game/Screens/Play/HUD/PlayerAvatar.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/PlayerAvatar.cs b/osu.Game/Screens/Play/HUD/PlayerAvatar.cs index d2f4f0be17..f293199911 100644 --- a/osu.Game/Screens/Play/HUD/PlayerAvatar.cs +++ b/osu.Game/Screens/Play/HUD/PlayerAvatar.cs @@ -16,10 +16,10 @@ namespace osu.Game.Screens.Play.HUD public partial class PlayerAvatar : CompositeDrawable, ISerialisableDrawable { [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.CornerRadius), nameof(SkinnableComponentStrings.CornerRadiusDescription))] - public new BindableFloat CornerRadius { get; set; } = new BindableFloat + public new BindableFloat CornerRadius { get; set; } = new BindableFloat(0.25f) { MinValue = 0, - MaxValue = 64, + MaxValue = 0.5f, Precision = 0.01f }; @@ -43,7 +43,7 @@ namespace osu.Game.Screens.Play.HUD base.LoadComplete(); avatar.User = gameplayState.Score.ScoreInfo.User; - CornerRadius.BindValueChanged(e => avatar.CornerRadius = e.NewValue, true); + CornerRadius.BindValueChanged(e => avatar.CornerRadius = e.NewValue * 128f, true); } public bool UsesFixedAnchor { get; set; } From 2cce785fa5bb7fd1ab6b77d1a757a76a6fc3f94b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 7 Mar 2023 15:54:33 +0900 Subject: [PATCH 73/84] Fix storyboard videos not fading out on completion Closes https://github.com/ppy/osu/issues/22802. Stable uses a 1,000 ms fade-in / out. Rather than matching that, I've stuck with 500ms (what lazer was already using for the fade-in) because I think it feels better. Tested using the beatmap linked in the issue thread. --- osu.Game/Storyboards/Drawables/DrawableStoryboardVideo.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardVideo.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardVideo.cs index f4b0692619..eec2cd6a60 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardVideo.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardVideo.cs @@ -58,7 +58,11 @@ namespace osu.Game.Storyboards.Drawables using (drawableVideo.BeginAbsoluteSequence(Video.StartTime)) { Schedule(() => drawableVideo.PlaybackPosition = Time.Current - Video.StartTime); + drawableVideo.FadeIn(500); + + using (drawableVideo.BeginDelayedSequence(drawableVideo.Duration - 500)) + drawableVideo.FadeOut(500); } } } From f7f1dff6471784c79a14c27e79f168597ca30a0c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 7 Mar 2023 16:45:33 +0900 Subject: [PATCH 74/84] Fix incorrect case of localisable string for "corner radius" --- .../Localisation/SkinComponents/SkinnableComponentStrings.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs b/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs index 5cec9442e4..7c11ea6ac6 100644 --- a/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs +++ b/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs @@ -40,9 +40,9 @@ namespace osu.Game.Localisation.SkinComponents public static LocalisableString TextElementTextDescription => new TranslatableString(getKey(@"text_element_text_description"), "The text to be displayed."); /// - /// "Corner Radius" + /// "Corner radius" /// - public static LocalisableString CornerRadius => new TranslatableString(getKey(@"corner_radius"), "Corner Radius"); + public static LocalisableString CornerRadius => new TranslatableString(getKey(@"corner_radius"), "Corner radius"); /// /// "How rounded the corners should be." From d98199961b2d0820a3e4ff12816ac1c8e2190004 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 7 Mar 2023 17:00:10 +0900 Subject: [PATCH 75/84] Adjust default sizing to fit a bit better with existing elements --- osu.Game/Screens/Play/HUD/PlayerAvatar.cs | 7 +++++-- osu.Game/Screens/Play/HUD/PlayerFlag.cs | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/PlayerAvatar.cs b/osu.Game/Screens/Play/HUD/PlayerAvatar.cs index f293199911..1c558aaa8a 100644 --- a/osu.Game/Screens/Play/HUD/PlayerAvatar.cs +++ b/osu.Game/Screens/Play/HUD/PlayerAvatar.cs @@ -28,9 +28,12 @@ namespace osu.Game.Screens.Play.HUD private readonly UpdateableAvatar avatar; + private const float default_size = 80f; + public PlayerAvatar() { - Size = new Vector2(128f); + Size = new Vector2(default_size); + InternalChild = avatar = new UpdateableAvatar(isInteractive: false) { RelativeSizeAxes = Axes.Both, @@ -43,7 +46,7 @@ namespace osu.Game.Screens.Play.HUD base.LoadComplete(); avatar.User = gameplayState.Score.ScoreInfo.User; - CornerRadius.BindValueChanged(e => avatar.CornerRadius = e.NewValue * 128f, true); + CornerRadius.BindValueChanged(e => avatar.CornerRadius = e.NewValue * default_size, true); } public bool UsesFixedAnchor { get; set; } diff --git a/osu.Game/Screens/Play/HUD/PlayerFlag.cs b/osu.Game/Screens/Play/HUD/PlayerFlag.cs index 17188d0009..bf65ee23d8 100644 --- a/osu.Game/Screens/Play/HUD/PlayerFlag.cs +++ b/osu.Game/Screens/Play/HUD/PlayerFlag.cs @@ -17,9 +17,11 @@ namespace osu.Game.Screens.Play.HUD private readonly UpdateableFlag flag; + private const float default_size = 40f; + public PlayerFlag() { - Size = new Vector2(114, 80); + Size = new Vector2(default_size, default_size / 1.4f); InternalChild = flag = new UpdateableFlag { RelativeSizeAxes = Axes.Both, From 5e90b67be09b842a9fb4b7114f49e4463afdce52 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 7 Mar 2023 17:01:29 +0900 Subject: [PATCH 76/84] Move `GameplayState` usage to BDL --- osu.Game/Screens/Play/HUD/PlayerFlag.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/PlayerFlag.cs b/osu.Game/Screens/Play/HUD/PlayerFlag.cs index bf65ee23d8..85799c03d3 100644 --- a/osu.Game/Screens/Play/HUD/PlayerFlag.cs +++ b/osu.Game/Screens/Play/HUD/PlayerFlag.cs @@ -12,9 +12,6 @@ namespace osu.Game.Screens.Play.HUD { public partial class PlayerFlag : CompositeDrawable, ISerialisableDrawable { - [Resolved] - private GameplayState gameplayState { get; set; } = null!; - private readonly UpdateableFlag flag; private const float default_size = 40f; @@ -28,10 +25,9 @@ namespace osu.Game.Screens.Play.HUD }; } - protected override void LoadComplete() + [BackgroundDependencyLoader] + private void load(GameplayState gameplayState) { - base.LoadComplete(); - flag.CountryCode = gameplayState.Score.ScoreInfo.User.CountryCode; } From 5af41bb1c81054205c4cb77ccc9b0faf4686288d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 7 Mar 2023 17:24:17 +0900 Subject: [PATCH 77/84] Move filter matching code into own method to simplify early returns --- .../Select/Carousel/CarouselBeatmap.cs | 28 +++++++------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs index 2cfa163b7a..7e48bc5cdd 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs @@ -26,6 +26,11 @@ namespace osu.Game.Screens.Select.Carousel { base.Filter(criteria); + Filtered.Value = !checkMatch(criteria); + } + + private bool checkMatch(FilterCriteria criteria) + { bool match = criteria.Ruleset == null || BeatmapInfo.Ruleset.ShortName == criteria.Ruleset.ShortName || @@ -34,8 +39,7 @@ namespace osu.Game.Screens.Select.Carousel if (BeatmapInfo.BeatmapSet?.Equals(criteria.SelectedBeatmapSet) == true) { // only check ruleset equality or convertability for selected beatmap - Filtered.Value = !match; - return; + return match; } match &= !criteria.StarDifficulty.HasFilter || criteria.StarDifficulty.IsInRange(BeatmapInfo.StarRating); @@ -49,11 +53,7 @@ namespace osu.Game.Screens.Select.Carousel match &= !criteria.BeatDivisor.HasFilter || criteria.BeatDivisor.IsInRange(BeatmapInfo.BeatDivisor); match &= !criteria.OnlineStatus.HasFilter || criteria.OnlineStatus.IsInRange(BeatmapInfo.Status); - if (!match) - { - Filtered.Value = !match; - return; - } + if (!match) return false; match &= !criteria.Creator.HasFilter || criteria.Creator.Matches(BeatmapInfo.Metadata.Author.Username); match &= !criteria.Artist.HasFilter || criteria.Artist.Matches(BeatmapInfo.Metadata.Artist) || @@ -61,11 +61,7 @@ namespace osu.Game.Screens.Select.Carousel match &= !criteria.UserStarDifficulty.HasFilter || criteria.UserStarDifficulty.IsInRange(BeatmapInfo.StarRating); - if (!match) - { - Filtered.Value = !match; - return; - } + if (!match) return false; if (criteria.SearchTerms.Length > 0) { @@ -99,18 +95,14 @@ namespace osu.Game.Screens.Select.Carousel } } - if (!match) - { - Filtered.Value = !match; - return; - } + if (!match) return false; match &= criteria.CollectionBeatmapMD5Hashes?.Contains(BeatmapInfo.MD5Hash) ?? true; if (match && criteria.RulesetCriteria != null) match &= criteria.RulesetCriteria.Matches(BeatmapInfo); - Filtered.Value = !match; + return match; } public override int CompareTo(FilterCriteria criteria, CarouselItem other) From dc2945f4f8635a08c83c84fd57f65c6da4eb8e47 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 7 Mar 2023 17:39:21 +0900 Subject: [PATCH 78/84] Move avatar user loading to BDL also --- osu.Game/Screens/Play/HUD/PlayerAvatar.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/PlayerAvatar.cs b/osu.Game/Screens/Play/HUD/PlayerAvatar.cs index 1c558aaa8a..e3fab499f3 100644 --- a/osu.Game/Screens/Play/HUD/PlayerAvatar.cs +++ b/osu.Game/Screens/Play/HUD/PlayerAvatar.cs @@ -23,9 +23,6 @@ namespace osu.Game.Screens.Play.HUD Precision = 0.01f }; - [Resolved] - private GameplayState gameplayState { get; set; } = null!; - private readonly UpdateableAvatar avatar; private const float default_size = 80f; @@ -41,11 +38,16 @@ namespace osu.Game.Screens.Play.HUD }; } + [BackgroundDependencyLoader] + private void load(GameplayState gameplayState) + { + avatar.User = gameplayState.Score.ScoreInfo.User; + } + protected override void LoadComplete() { base.LoadComplete(); - avatar.User = gameplayState.Score.ScoreInfo.User; CornerRadius.BindValueChanged(e => avatar.CornerRadius = e.NewValue * default_size, true); } From 55467fcbe35cc6c8c7a94740c372b665eaa77519 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 7 Mar 2023 18:00:37 +0900 Subject: [PATCH 79/84] Update xmldoc for `DangerousActionDialog` to match new behaviour --- osu.Game/Overlays/Dialog/DangerousActionDialog.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Dialog/DangerousActionDialog.cs b/osu.Game/Overlays/Dialog/DangerousActionDialog.cs index 85cae5e0d2..c86570386f 100644 --- a/osu.Game/Overlays/Dialog/DangerousActionDialog.cs +++ b/osu.Game/Overlays/Dialog/DangerousActionDialog.cs @@ -8,10 +8,14 @@ using osu.Game.Localisation; namespace osu.Game.Overlays.Dialog { /// - /// Base class for various confirmation dialogs that concern deletion actions. + /// A dialog which provides confirmation for actions which result in permanent consequences. /// Differs from in that the confirmation button is a "dangerous" one /// (requires the confirm button to be held). /// + /// + /// The default implementation comes with text for a generic deletion operation. + /// This can be further customised by specifying custom . + /// public abstract partial class DangerousActionDialog : PopupDialog { /// From 26ef7c2637ddde346c65ff6bd853a48c03d5863e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 7 Mar 2023 18:01:13 +0900 Subject: [PATCH 80/84] Rename confirmation dialog class to mention `revert` not `reset` --- osu.Game/Overlays/SkinEditor/SkinEditor.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinEditor.cs b/osu.Game/Overlays/SkinEditor/SkinEditor.cs index a7fe459aa4..c6d190502b 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditor.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditor.cs @@ -153,7 +153,7 @@ namespace osu.Game.Overlays.SkinEditor Items = new[] { new EditorMenuItem(Web.CommonStrings.ButtonsSave, MenuItemType.Standard, () => Save()), - new EditorMenuItem(CommonStrings.RevertToDefault, MenuItemType.Destructive, () => dialogOverlay?.Push(new ResetConfirmDialog(revert))), + new EditorMenuItem(CommonStrings.RevertToDefault, MenuItemType.Destructive, () => dialogOverlay?.Push(new RevertConfirmDialog(revert))), new EditorMenuItemSpacer(), new EditorMenuItem(CommonStrings.Exit, MenuItemType.Standard, () => skinEditorOverlay?.Hide()), }, @@ -630,9 +630,9 @@ namespace osu.Game.Overlays.SkinEditor } } - public partial class ResetConfirmDialog : DangerousActionDialog + public partial class RevertConfirmDialog : DangerousActionDialog { - public ResetConfirmDialog(Action revert) + public RevertConfirmDialog(Action revert) { HeaderText = SkinEditorStrings.RevertToDefaultDescription; BodyText = SkinEditorStrings.ResetDialogue; From 97bee4db89048419265aeb9a1a6c9ffa478cc68a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 7 Mar 2023 18:07:53 +0900 Subject: [PATCH 81/84] Fix localisations --- osu.Game/Localisation/SkinEditorStrings.cs | 9 ++------- osu.Game/Overlays/SkinEditor/SkinEditor.cs | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/osu.Game/Localisation/SkinEditorStrings.cs b/osu.Game/Localisation/SkinEditorStrings.cs index a6b59418fd..3c1d1ff40d 100644 --- a/osu.Game/Localisation/SkinEditorStrings.cs +++ b/osu.Game/Localisation/SkinEditorStrings.cs @@ -45,14 +45,9 @@ namespace osu.Game.Localisation public static LocalisableString CurrentlyEditing => new TranslatableString(getKey(@"currently_editing"), @"Currently editing"); /// - /// "Revert to default." + /// "All layout elements for layers in the current screen will be reset to defaults." /// - public static LocalisableString RevertToDefaultDescription => new TranslatableString(getKey(@"revert_to_default"), @"Revert to default."); - - /// - /// "Return the skin to its default state" - /// - public static LocalisableString ResetDialogue => new TranslatableString(getKey(@"return_the_skin_to_its"), @"Return the skin to its default state"); + public static LocalisableString RevertToDefaultDescription => new TranslatableString(getKey(@"revert_to_default_description"), @"All layout elements for layers in the current screen will be reset to defaults."); private static string getKey(string key) => $@"{prefix}:{key}"; } diff --git a/osu.Game/Overlays/SkinEditor/SkinEditor.cs b/osu.Game/Overlays/SkinEditor/SkinEditor.cs index c6d190502b..ac40d1335e 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditor.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditor.cs @@ -634,8 +634,8 @@ namespace osu.Game.Overlays.SkinEditor { public RevertConfirmDialog(Action revert) { - HeaderText = SkinEditorStrings.RevertToDefaultDescription; - BodyText = SkinEditorStrings.ResetDialogue; + HeaderText = CommonStrings.RevertToDefault; + BodyText = SkinEditorStrings.RevertToDefaultDescription; DangerousAction = revert; } } From 5191204569241e0e92c93b51681a9384d711a019 Mon Sep 17 00:00:00 2001 From: Cootz Date: Tue, 7 Mar 2023 15:39:43 +0300 Subject: [PATCH 82/84] Bring truncating logic back to `Export` method --- osu.Game/Database/LegacyExporter.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs index 0fa7b9e03c..9981e08442 100644 --- a/osu.Game/Database/LegacyExporter.cs +++ b/osu.Game/Database/LegacyExporter.cs @@ -48,15 +48,7 @@ namespace osu.Game.Database UserFileStorage = storage.GetStorageForDirectory(@"files"); } - protected virtual string GetFilename(TModel item) - { - string filename = item.GetDisplayString(); - - if (filename.Length > MAX_FILENAME_LENGTH - FileExtension.Length) - return filename.Remove(MAX_FILENAME_LENGTH - FileExtension.Length); - - return filename; - } + protected virtual string GetFilename(TModel item) => item.GetDisplayString(); /// /// Exports an item to a legacy (.zip based) package. @@ -73,6 +65,14 @@ namespace osu.Game.Database string filename = NamingUtils.GetNextBestFilename(existingExports, $"{itemFilename}{FileExtension}"); + if (filename.Length > MAX_FILENAME_LENGTH) + { + string filenameWithoutExtension = Path.GetFileNameWithoutExtension(filename); + + filenameWithoutExtension = filenameWithoutExtension.Remove(MAX_FILENAME_LENGTH - FileExtension.Length); + filename = $"{filenameWithoutExtension}{FileExtension}"; + } + using (var stream = exportStorage.CreateFileSafely(filename)) ExportModelTo(item, stream); From 7107834b9ec297062ff29442fa1a550c03ff5a94 Mon Sep 17 00:00:00 2001 From: Cootz Date: Tue, 7 Mar 2023 15:43:03 +0300 Subject: [PATCH 83/84] Fix truncating bug --- osu.Game/Database/LegacyExporter.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs index 9981e08442..8da285daa3 100644 --- a/osu.Game/Database/LegacyExporter.cs +++ b/osu.Game/Database/LegacyExporter.cs @@ -58,6 +58,9 @@ namespace osu.Game.Database { string itemFilename = GetFilename(item).GetValidFilename(); + if (itemFilename.Length > MAX_FILENAME_LENGTH - FileExtension.Length) + itemFilename = itemFilename.Remove(MAX_FILENAME_LENGTH - FileExtension.Length); + IEnumerable existingExports = exportStorage .GetFiles(string.Empty, $"{itemFilename}*{FileExtension}") @@ -65,14 +68,6 @@ namespace osu.Game.Database string filename = NamingUtils.GetNextBestFilename(existingExports, $"{itemFilename}{FileExtension}"); - if (filename.Length > MAX_FILENAME_LENGTH) - { - string filenameWithoutExtension = Path.GetFileNameWithoutExtension(filename); - - filenameWithoutExtension = filenameWithoutExtension.Remove(MAX_FILENAME_LENGTH - FileExtension.Length); - filename = $"{filenameWithoutExtension}{FileExtension}"; - } - using (var stream = exportStorage.CreateFileSafely(filename)) ExportModelTo(item, stream); From 7ade525eef4a3c887de1d50123682140ee9c605a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 7 Mar 2023 19:43:52 +0100 Subject: [PATCH 84/84] Display corner radius setting as percentage --- .../Settings/SettingsPercentageSlider.cs | 20 +++++++++++++++++++ .../Rulesets/Mods/ModAccuracyChallenge.cs | 11 +--------- osu.Game/Screens/Play/HUD/PlayerAvatar.cs | 4 +++- 3 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 osu.Game/Overlays/Settings/SettingsPercentageSlider.cs diff --git a/osu.Game/Overlays/Settings/SettingsPercentageSlider.cs b/osu.Game/Overlays/Settings/SettingsPercentageSlider.cs new file mode 100644 index 0000000000..fa59d18de1 --- /dev/null +++ b/osu.Game/Overlays/Settings/SettingsPercentageSlider.cs @@ -0,0 +1,20 @@ +// 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 osu.Framework.Graphics; +using osu.Game.Configuration; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Overlays.Settings +{ + /// + /// A that displays its value as a percentage by default. + /// Mostly provided for convenience of use with . + /// + public partial class SettingsPercentageSlider : SettingsSlider + where TValue : struct, IEquatable, IComparable, IConvertible + { + protected override Drawable CreateControl() => ((RoundedSliderBar)base.CreateControl()).With(sliderBar => sliderBar.DisplayAsPercentage = true); + } +} diff --git a/osu.Game/Rulesets/Mods/ModAccuracyChallenge.cs b/osu.Game/Rulesets/Mods/ModAccuracyChallenge.cs index dc7594f469..d4223a80c2 100644 --- a/osu.Game/Rulesets/Mods/ModAccuracyChallenge.cs +++ b/osu.Game/Rulesets/Mods/ModAccuracyChallenge.cs @@ -7,7 +7,6 @@ using System.Linq; using osu.Framework.Bindables; using osu.Framework.Localisation; using osu.Game.Configuration; -using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.Settings; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Judgements; @@ -33,7 +32,7 @@ namespace osu.Game.Rulesets.Mods public override string SettingDescription => base.SettingDescription.Replace(MinimumAccuracy.ToString(), MinimumAccuracy.Value.ToString("##%", NumberFormatInfo.InvariantInfo)); - [SettingSource("Minimum accuracy", "Trigger a failure if your accuracy goes below this value.", SettingControlType = typeof(SettingsSlider))] + [SettingSource("Minimum accuracy", "Trigger a failure if your accuracy goes below this value.", SettingControlType = typeof(SettingsPercentageSlider))] public BindableNumber MinimumAccuracy { get; } = new BindableDouble { MinValue = 0.60, @@ -69,12 +68,4 @@ namespace osu.Game.Rulesets.Mods return scoreProcessor.ComputeAccuracy(score); } } - - public partial class PercentSlider : RoundedSliderBar - { - public PercentSlider() - { - DisplayAsPercentage = true; - } - } } diff --git a/osu.Game/Screens/Play/HUD/PlayerAvatar.cs b/osu.Game/Screens/Play/HUD/PlayerAvatar.cs index e3fab499f3..1d0331593a 100644 --- a/osu.Game/Screens/Play/HUD/PlayerAvatar.cs +++ b/osu.Game/Screens/Play/HUD/PlayerAvatar.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Configuration; using osu.Game.Localisation.SkinComponents; +using osu.Game.Overlays.Settings; using osu.Game.Skinning; using osu.Game.Users.Drawables; using osuTK; @@ -15,7 +16,8 @@ namespace osu.Game.Screens.Play.HUD { public partial class PlayerAvatar : CompositeDrawable, ISerialisableDrawable { - [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.CornerRadius), nameof(SkinnableComponentStrings.CornerRadiusDescription))] + [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.CornerRadius), nameof(SkinnableComponentStrings.CornerRadiusDescription), + SettingControlType = typeof(SettingsPercentageSlider))] public new BindableFloat CornerRadius { get; set; } = new BindableFloat(0.25f) { MinValue = 0,