-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1633 from andy840119/refactor-some-skin-logic
Fix karaoke text not showing if use the legacy skin.
- Loading branch information
Showing
18 changed files
with
275 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/SkinJsonSerializableExtensionsTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using NUnit.Framework; | ||
using osu.Game.Rulesets.Karaoke.Tests.IO.Serialization.Converters; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Tests.IO.Serialization | ||
{ | ||
[Ignore($"Test case already in the {nameof(KaraokeSkinElementConvertorTest)}, {nameof(KaraokeSkinGroupConvertorTest)}, and {nameof(KaraokeSkinMappingRoleConvertorTest)}")] | ||
public class SkinJsonSerializableExtensionsTest | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using JetBrains.Annotations; | ||
using osu.Framework.Allocation; | ||
using osu.Game.Database; | ||
using osu.Game.IO; | ||
using osu.Game.Rulesets.Karaoke.Beatmaps; | ||
using osu.Game.Rulesets.Karaoke.Extensions; | ||
using osu.Game.Rulesets.Karaoke.Screens.Skin; | ||
using osu.Game.Rulesets.Karaoke.Skinning; | ||
using osu.Game.Rulesets.Karaoke.Skinning.Elements; | ||
using osu.Game.Screens.Edit; | ||
using osu.Game.Skinning; | ||
|
||
|
@@ -28,11 +33,43 @@ public class TestSceneKaraokeSkinEditor : ScreenTestScene<KaraokeSkinEditor> | |
[BackgroundDependencyLoader] | ||
private void load(SkinManager skinManager) | ||
{ | ||
skinManager.CurrentSkinInfo.Value = DefaultKaraokeSkin.CreateInfo().ToLiveUnmanaged(); | ||
skinManager.CurrentSkinInfo.Value = TestingSkin.CreateInfo().ToLiveUnmanaged(); | ||
|
||
karaokeSkin = skinManager.CurrentSkin.Value as KaraokeSkin; | ||
} | ||
|
||
protected override KaraokeSkinEditor CreateScreen() => new(karaokeSkin); | ||
|
||
/// <summary> | ||
/// todo: it's a tricky way to create ruleset's own skin class. | ||
/// should use generic skin like <see cref="LegacySkin"/> eventually. | ||
/// </summary> | ||
public class TestingSkin : KaraokeSkin | ||
{ | ||
internal static readonly Guid DEFAULT_SKIN = new("FEC5A291-5709-11EC-9F10-0800200C9A66"); | ||
|
||
public static SkinInfo CreateInfo() => new() | ||
{ | ||
ID = DEFAULT_SKIN, | ||
Name = "karaoke! (default skin)", | ||
Creator = "team karaoke!", | ||
Protected = true, | ||
InstantiationInfo = typeof(TestingSkin).GetInvariantInstantiationInfo() | ||
}; | ||
|
||
public TestingSkin(IStorageResourceProvider? resources) | ||
: this(CreateInfo(), resources) | ||
{ | ||
} | ||
|
||
[UsedImplicitly(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature)] | ||
public TestingSkin(SkinInfo skin, IStorageResourceProvider? resources) | ||
: base(skin, resources) | ||
{ | ||
DefaultElement[ElementType.LyricConfig] = LyricConfig.CreateDefault(); | ||
DefaultElement[ElementType.LyricStyle] = LyricStyle.CreateDefault(); | ||
DefaultElement[ElementType.NoteStyle] = NoteStyle.CreateDefault(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
osu.Game.Rulesets.Karaoke/IO/Serialization/SkinJsonSerializableExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using Newtonsoft.Json; | ||
using osu.Framework.IO.Serialization; | ||
using osu.Game.IO.Serialization; | ||
using osu.Game.Rulesets.Karaoke.IO.Serialization.Converters; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.IO.Serialization | ||
{ | ||
public static class SkinJsonSerializableExtensions | ||
{ | ||
public static JsonSerializerSettings CreateSkinElementGlobalSettings() | ||
{ | ||
var globalSetting = JsonSerializableExtensions.CreateGlobalSettings(); | ||
globalSetting.ContractResolver = new SnakeCaseKeyContractResolver(); | ||
globalSetting.Converters.Add(new KaraokeSkinElementConvertor()); | ||
globalSetting.Converters.Add(new ShaderConvertor()); | ||
globalSetting.Converters.Add(new Vector2Converter()); | ||
globalSetting.Converters.Add(new ColourConvertor()); | ||
globalSetting.Converters.Add(new FontUsageConvertor()); | ||
return globalSetting; | ||
} | ||
|
||
public static JsonSerializerSettings CreateSkinGroupGlobalSettings() | ||
{ | ||
var globalSetting = JsonSerializableExtensions.CreateGlobalSettings(); | ||
globalSetting.ContractResolver = new SnakeCaseKeyContractResolver(); | ||
globalSetting.Converters.Add(new KaraokeSkinGroupConvertor()); | ||
return globalSetting; | ||
} | ||
|
||
public static JsonSerializerSettings CreateSkinMappingGlobalSettings() | ||
{ | ||
var globalSetting = JsonSerializableExtensions.CreateGlobalSettings(); | ||
globalSetting.ContractResolver = new SnakeCaseKeyContractResolver(); | ||
globalSetting.Converters.Add(new KaraokeSkinMappingRoleConvertor()); | ||
return globalSetting; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
osu.Game.Rulesets.Karaoke/Skinning/Argon/KaraokeArgonSkinTransformer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Game.Beatmaps; | ||
using osu.Game.Rulesets.Karaoke.Skinning.Default; | ||
using osu.Game.Skinning; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Skinning.Argon | ||
{ | ||
public class KaraokeArgonSkinTransformer : KaraokeDefaultSkinTransformer | ||
{ | ||
public KaraokeArgonSkinTransformer(ISkin skin, IBeatmap beatmap) | ||
: base(skin, beatmap) | ||
{ | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
osu.Game.Rulesets.Karaoke/Skinning/Default/KaraokeDefaultSkinTransformer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Framework.Bindables; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Skinning; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Skinning.Default | ||
{ | ||
public class KaraokeDefaultSkinTransformer : SkinTransformer | ||
{ | ||
private readonly KaraokeSkin karaokeSkin; | ||
|
||
public KaraokeDefaultSkinTransformer(ISkin skin, IBeatmap beatmap) | ||
: base(skin) | ||
{ | ||
karaokeSkin = new KaraokeSkin(new SkinInfo(), new InternalSkinStorageResourceProvider("Default")); | ||
} | ||
|
||
public override IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup) | ||
=> karaokeSkin.GetConfig<TLookup, TValue>(lookup); | ||
} | ||
} |
Oops, something went wrong.