diff --git a/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/Converters/KaraokeSkinGroupConverterTest.cs b/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/Converters/KaraokeSkinGroupConverterTest.cs deleted file mode 100644 index 66cbf535e..000000000 --- a/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/Converters/KaraokeSkinGroupConverterTest.cs +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using Newtonsoft.Json; -using NUnit.Framework; -using osu.Game.Rulesets.Karaoke.IO.Serialization.Converters; -using osu.Game.Rulesets.Karaoke.Skinning.Groups; -using osu.Game.Rulesets.Karaoke.Tests.Asserts; - -namespace osu.Game.Rulesets.Karaoke.Tests.IO.Serialization.Converters; - -public class KaraokeSkinGroupConverterTest : BaseSingleConverterTest -{ - [Test] - public void TestGroupBySingerIdsSerializer() - { - var group = new GroupBySingerIds - { - ID = 123, - Name = "Singer 1 and 2", - SingerIds = new[] { 1, 2 } - }; - - const string expected = "{\"$type\":\"GroupBySingerIds\",\"singer_ids\":[1,2],\"id\":123,\"name\":\"Singer 1 and 2\"}"; - string actual = JsonConvert.SerializeObject(group, CreateSettings()); - Assert.AreEqual(expected, actual); - } - - [Test] - public void TestGroupBySingerIdsDeserializer() - { - const string json = "{\"$type\":\"GroupBySingerIds\",\"singer_ids\":[1,2],\"id\":123,\"name\":\"Singer 1 and 2\"}"; - - var expected = new GroupBySingerIds - { - ID = 123, - Name = "Singer 1 and 2", - SingerIds = new[] { 1, 2 } - }; - var actual = (GroupBySingerIds)JsonConvert.DeserializeObject(json, CreateSettings())!; - ObjectAssert.ArePropertyEqual(expected, actual); - } - - [Test] - public void TestGroupBySingerNumberSerializer() - { - var group = new GroupBySingerNumber - { - ID = 123, - Name = "Two singers", - SingerNumber = 2, - }; - - const string expected = "{\"$type\":\"GroupBySingerNumber\",\"singer_number\":2,\"id\":123,\"name\":\"Two singers\"}"; - string actual = JsonConvert.SerializeObject(group, CreateSettings()); - Assert.AreEqual(expected, actual); - } - - [Test] - public void TestGroupBySingerNumberDeserializer() - { - const string json = "{\"$type\":\"GroupBySingerNumber\",\"singer_number\":2,\"id\":123,\"name\":\"Two singers\"}"; - - var expected = new GroupBySingerNumber - { - ID = 123, - Name = "Two singers", - SingerNumber = 2, - }; - var actual = (GroupBySingerNumber)JsonConvert.DeserializeObject(json, CreateSettings())!; - ObjectAssert.ArePropertyEqual(expected, actual); - } - - [Test] - public void TestGroupByLyricIdsSerializer() - { - var group = new GroupByLyricIds - { - ID = 123, - Name = "Lyric 1 and 2", - LyricIds = new[] { 1, 2 } - }; - - const string expected = "{\"$type\":\"GroupByLyricIds\",\"lyric_ids\":[1,2],\"id\":123,\"name\":\"Lyric 1 and 2\"}"; - string actual = JsonConvert.SerializeObject(group, CreateSettings()); - Assert.AreEqual(expected, actual); - } - - [Test] - public void TestGroupByLyricIdsDeserializer() - { - const string json = "{\"$type\":\"GroupByLyricIds\",\"lyric_ids\":[1,2],\"id\":123,\"name\":\"Lyric 1 and 2\"}"; - - var expected = new GroupByLyricIds - { - ID = 123, - Name = "Lyric 1 and 2", - LyricIds = new[] { 1, 2 } - }; - var actual = (GroupByLyricIds)JsonConvert.DeserializeObject(json, CreateSettings())!; - ObjectAssert.ArePropertyEqual(expected, actual); - } -} diff --git a/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/SkinJsonSerializableExtensionsTest.cs b/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/SkinJsonSerializableExtensionsTest.cs index eaf0da930..bc4f56b72 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/SkinJsonSerializableExtensionsTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/SkinJsonSerializableExtensionsTest.cs @@ -6,7 +6,7 @@ namespace osu.Game.Rulesets.Karaoke.Tests.IO.Serialization; -[Ignore($"Test case already in the {nameof(KaraokeSkinElementConverterTest)} and {nameof(KaraokeSkinGroupConverterTest)}")] +[Ignore($"Test case already in the {nameof(KaraokeSkinElementConverterTest)}")] public class SkinJsonSerializableExtensionsTest { } diff --git a/osu.Game.Rulesets.Karaoke.Tests/Resources/special-skin/groups.json b/osu.Game.Rulesets.Karaoke.Tests/Resources/special-skin/groups.json deleted file mode 100644 index 967c06b90..000000000 --- a/osu.Game.Rulesets.Karaoke.Tests/Resources/special-skin/groups.json +++ /dev/null @@ -1,56 +0,0 @@ -[ - { - "$type": "GroupByLyricIds", - "lyric_ids": [ - 1, - 3, - 5, - 7, - 9, - 11, - 13, - 15, - 17, - 19, - 21, - 23, - 25, - 27, - 29, - 31, - 33, - 35, - 37, - 39 - ], - "id": 1, - "name": "Odd lyric" - }, - { - "$type": "GroupByLyricIds", - "lyric_ids": [ - 0, - 2, - 4, - 6, - 8, - 10, - 12, - 14, - 16, - 18, - 20, - 22, - 24, - 26, - 28, - 30, - 32, - 34, - 36, - 38 - ], - "id": 2, - "name": "Even lyric" - } -] \ No newline at end of file diff --git a/osu.Game.Rulesets.Karaoke/IO/Serialization/Converters/KaraokeSkinGroupConverter.cs b/osu.Game.Rulesets.Karaoke/IO/Serialization/Converters/KaraokeSkinGroupConverter.cs deleted file mode 100644 index 563ea9dd5..000000000 --- a/osu.Game.Rulesets.Karaoke/IO/Serialization/Converters/KaraokeSkinGroupConverter.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using System.Diagnostics; -using System.Reflection; -using osu.Game.Rulesets.Karaoke.Skinning.Groups; - -namespace osu.Game.Rulesets.Karaoke.IO.Serialization.Converters -{ - public class KaraokeSkinGroupConverter : GenericTypeConverter - { - protected override Type GetTypeByName(string name) - { - // only get name from font - var assembly = Assembly.GetExecutingAssembly(); - var type = assembly.GetType($"osu.Game.Rulesets.Karaoke.Skinning.Groups.{name}"); - Debug.Assert(type != null); - return type; - } - } -} diff --git a/osu.Game.Rulesets.Karaoke/IO/Serialization/SkinJsonSerializableExtensions.cs b/osu.Game.Rulesets.Karaoke/IO/Serialization/SkinJsonSerializableExtensions.cs index 559a6a6c8..737658375 100644 --- a/osu.Game.Rulesets.Karaoke/IO/Serialization/SkinJsonSerializableExtensions.cs +++ b/osu.Game.Rulesets.Karaoke/IO/Serialization/SkinJsonSerializableExtensions.cs @@ -21,13 +21,5 @@ public static JsonSerializerSettings CreateSkinElementGlobalSettings() globalSetting.Converters.Add(new FontUsageConverter()); return globalSetting; } - - public static JsonSerializerSettings CreateSkinGroupGlobalSettings() - { - var globalSetting = JsonSerializableExtensions.CreateGlobalSettings(); - globalSetting.ContractResolver = new SnakeCaseKeyContractResolver(); - globalSetting.Converters.Add(new KaraokeSkinGroupConverter()); - return globalSetting; - } } } diff --git a/osu.Game.Rulesets.Karaoke/Resources/Skin/Default/groups.json b/osu.Game.Rulesets.Karaoke/Resources/Skin/Default/groups.json deleted file mode 100644 index 967c06b90..000000000 --- a/osu.Game.Rulesets.Karaoke/Resources/Skin/Default/groups.json +++ /dev/null @@ -1,56 +0,0 @@ -[ - { - "$type": "GroupByLyricIds", - "lyric_ids": [ - 1, - 3, - 5, - 7, - 9, - 11, - 13, - 15, - 17, - 19, - 21, - 23, - 25, - 27, - 29, - 31, - 33, - 35, - 37, - 39 - ], - "id": 1, - "name": "Odd lyric" - }, - { - "$type": "GroupByLyricIds", - "lyric_ids": [ - 0, - 2, - 4, - 6, - 8, - 10, - 12, - 14, - 16, - 18, - 20, - 22, - 24, - 26, - 28, - 30, - 32, - 34, - 36, - 38 - ], - "id": 2, - "name": "Even lyric" - } -] \ No newline at end of file diff --git a/osu.Game.Rulesets.Karaoke/Skinning/Groups/BaseGroup.cs b/osu.Game.Rulesets.Karaoke/Skinning/Groups/BaseGroup.cs deleted file mode 100644 index 3dbb44cc2..000000000 --- a/osu.Game.Rulesets.Karaoke/Skinning/Groups/BaseGroup.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using System.ComponentModel; -using osu.Game.Rulesets.Karaoke.Objects; -using osu.Game.Rulesets.Karaoke.Skinning.Elements; - -namespace osu.Game.Rulesets.Karaoke.Skinning.Groups -{ - public abstract class BaseGroup : IGroup where THitObject : KaraokeHitObject - { - public int ID { get; set; } - - public string Name { get; set; } = string.Empty; - - public bool InTheGroup(KaraokeHitObject hitObject, ElementType elementType) - { - bool accepted = isTypeAccepted(hitObject, elementType); - return accepted && InTheGroup((THitObject)hitObject); - } - - protected abstract bool InTheGroup(THitObject hitObject); - - private static bool isTypeAccepted(KaraokeHitObject hitObject, ElementType elementType) - { - switch (elementType) - { - case ElementType.LyricFontInfo: - case ElementType.LyricLayout: - case ElementType.LyricStyle: - return hitObject is Lyric; - - case ElementType.NoteStyle: - return hitObject is Note; - - default: - throw new InvalidEnumArgumentException(nameof(elementType)); - } - } - } -} diff --git a/osu.Game.Rulesets.Karaoke/Skinning/Groups/GroupByLyricIds.cs b/osu.Game.Rulesets.Karaoke/Skinning/Groups/GroupByLyricIds.cs deleted file mode 100644 index 0d2924726..000000000 --- a/osu.Game.Rulesets.Karaoke/Skinning/Groups/GroupByLyricIds.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using System.Collections.Generic; -using System.Linq; -using osu.Game.Rulesets.Karaoke.Objects; - -namespace osu.Game.Rulesets.Karaoke.Skinning.Groups -{ - public class GroupByLyricIds : BaseGroup - { - public IReadOnlyList LyricIds { get; set; } = Array.Empty(); - - protected override bool InTheGroup(KaraokeHitObject hitObject) - { - return hitObject switch - { - Lyric lyric => LyricIds.Contains(lyric.ID), - Note note => note.ReferenceLyricId != null && LyricIds.Contains(note.ReferenceLyricId.Value), - _ => false - }; - } - } -} diff --git a/osu.Game.Rulesets.Karaoke/Skinning/Groups/GroupBySingerIds.cs b/osu.Game.Rulesets.Karaoke/Skinning/Groups/GroupBySingerIds.cs deleted file mode 100644 index 0314c03c5..000000000 --- a/osu.Game.Rulesets.Karaoke/Skinning/Groups/GroupBySingerIds.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using System.Collections.Generic; -using System.Linq; -using osu.Game.Rulesets.Karaoke.Objects; - -namespace osu.Game.Rulesets.Karaoke.Skinning.Groups -{ - public class GroupBySingerIds : BaseGroup - { - public IReadOnlyList SingerIds { get; set; } = Array.Empty(); - - protected override bool InTheGroup(Lyric hitObject) - { - return SingerIds.Any(x => hitObject.SingerIds.Contains(x)); - } - } -} diff --git a/osu.Game.Rulesets.Karaoke/Skinning/Groups/GroupBySingerNumber.cs b/osu.Game.Rulesets.Karaoke/Skinning/Groups/GroupBySingerNumber.cs deleted file mode 100644 index 073b192f5..000000000 --- a/osu.Game.Rulesets.Karaoke/Skinning/Groups/GroupBySingerNumber.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Game.Rulesets.Karaoke.Objects; - -namespace osu.Game.Rulesets.Karaoke.Skinning.Groups -{ - public class GroupBySingerNumber : BaseGroup - { - public int SingerNumber { get; set; } - - protected override bool InTheGroup(Lyric hitObject) - { - if (SingerNumber == 0) - return false; - - return hitObject.SingerIds.Count == SingerNumber; - } - } -} diff --git a/osu.Game.Rulesets.Karaoke/Skinning/Groups/IGroup.cs b/osu.Game.Rulesets.Karaoke/Skinning/Groups/IGroup.cs deleted file mode 100644 index 87cd4f3bc..000000000 --- a/osu.Game.Rulesets.Karaoke/Skinning/Groups/IGroup.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Game.Rulesets.Karaoke.Objects; -using osu.Game.Rulesets.Karaoke.Skinning.Elements; - -namespace osu.Game.Rulesets.Karaoke.Skinning.Groups -{ - public interface IGroup - { - public int ID { get; set; } - - public string Name { get; set; } - - bool InTheGroup(KaraokeHitObject hitObject, ElementType elementType); - } -} diff --git a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeBeatmapSkin.cs b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeBeatmapSkin.cs index 2d5944030..642ab33d2 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeBeatmapSkin.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeBeatmapSkin.cs @@ -13,7 +13,6 @@ using osu.Game.Rulesets.Karaoke.IO.Serialization; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Skinning.Elements; -using osu.Game.Rulesets.Karaoke.Skinning.Groups; using osu.Game.Skinning; namespace osu.Game.Rulesets.Karaoke.Skinning @@ -24,7 +23,6 @@ namespace osu.Game.Rulesets.Karaoke.Skinning public class KaraokeBeatmapSkin : KaraokeSkin { public readonly IDictionary> Elements = new Dictionary>(); - public readonly List Groups = new(); public KaraokeBeatmapSkin(SkinInfo skin, IStorageResourceProvider? resources, IResourceStore? storage = null) : base(skin, resources, storage) @@ -69,30 +67,6 @@ static string getFileNameByType(ElementType elementType) _ => throw new InvalidEnumArgumentException(nameof(elementType)) }; }); - - SkinInfo.PerformRead(s => - { - const string filename = "groups.json"; - - try - { - string? jsonContent = GetElementStringContentFromSkinInfo(s, filename); - if (string.IsNullOrEmpty(jsonContent)) - return; - - var globalSetting = SkinJsonSerializableExtensions.CreateSkinGroupGlobalSettings(); - var deserializedContent = JsonConvert.DeserializeObject(jsonContent, globalSetting); - - if (deserializedContent == null) - return; - - Groups.AddRange(deserializedContent); - } - catch (Exception ex) - { - Logger.Error(ex, "Failed to load skin element."); - } - }); } public override IBindable? GetConfig(TLookup lookup)