diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Stages/StageElementCategoryChangeHandlerTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Stages/StageElementCategoryChangeHandlerTest.cs index 804b85012..6ed22ee16 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Stages/StageElementCategoryChangeHandlerTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Stages/StageElementCategoryChangeHandlerTest.cs @@ -225,7 +225,11 @@ public override IPlayfieldCommandProvider CreatePlayfieldCommandProvider(bool di #endregion } - private class TestCategory : StageElementCategory; + private class TestCategory : StageElementCategory + { + protected override TestStageElement CreateDefaultElement() + => new(); + } public class TestStageElement : StageElement, IComparable { diff --git a/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/Converters/KaraokeSkinElementConverterTest.cs b/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/Converters/KaraokeSkinElementConverterTest.cs index dc93a93c3..edec61ef6 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/Converters/KaraokeSkinElementConverterTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/Converters/KaraokeSkinElementConverterTest.cs @@ -43,34 +43,12 @@ public void TestLyricConfigDeserialize() ObjectAssert.ArePropertyEqual(expected, actual); } - [Test] - public void TestLyricStyleSerializer() - { - var lyricStyle = LyricStyle.CreateDefault(); - - const string expected = - "{\"$type\":1,\"left_lyric_text_shaders\":[{\"$type\":\"StepShader\",\"name\":\"Step shader\",\"draw\":true,\"step_shaders\":[{\"$type\":\"OutlineShader\",\"outline_colour\":\"#CCA532\",\"radius\":3.0},{\"$type\":\"ShadowShader\",\"shadow_colour\":\"#6B5B2D\",\"shadow_offset\":{\"x\":3.0,\"y\":3.0}}]}],\"right_lyric_text_shaders\":[{\"$type\":\"StepShader\",\"name\":\"Step shader\",\"draw\":true,\"step_shaders\":[{\"$type\":\"OutlineShader\",\"outline_colour\":\"#5932CC\",\"radius\":3.0},{\"$type\":\"ShadowShader\",\"shadow_colour\":\"#3D2D6B\",\"shadow_offset\":{\"x\":3.0,\"y\":3.0}}]}],\"name\":\"Default\"}"; - string actual = JsonConvert.SerializeObject(lyricStyle, CreateSettings()); - Assert.AreEqual(expected, actual); - } - - [Test] - public void TestLyricStyleDeserializer() - { - const string json = - "{\"$type\":1,\"left_lyric_text_shaders\":[{\"$type\":\"StepShader\",\"name\":\"Step shader\",\"draw\":true,\"step_shaders\":[{\"$type\":\"OutlineShader\",\"outline_colour\":\"#CCA532\",\"radius\":3.0},{\"$type\":\"ShadowShader\",\"shadow_colour\":\"#6B5B2D\",\"shadow_offset\":{\"x\":3.0,\"y\":3.0}}]}],\"right_lyric_text_shaders\":[{\"$type\":\"StepShader\",\"name\":\"Step shader\",\"draw\":true,\"step_shaders\":[{\"$type\":\"OutlineShader\",\"outline_colour\":\"#5932CC\",\"radius\":3.0},{\"$type\":\"ShadowShader\",\"shadow_colour\":\"#3D2D6B\",\"shadow_offset\":{\"x\":3.0,\"y\":3.0}}]}],\"name\":\"Default\"}"; - - var expected = LyricStyle.CreateDefault(); - var actual = (LyricStyle)JsonConvert.DeserializeObject(json, CreateSettings())!; - ObjectAssert.ArePropertyEqual(expected, actual); - } - [Test] public void TestNoteStyleSerializer() { var lyricConfig = NoteStyle.CreateDefault(); - const string expected = "{\"$type\":2,\"name\":\"Default\",\"note_color\":\"#44AADD\",\"blink_color\":\"#FF66AA\",\"text_color\":\"#FFFFFF\",\"bold_text\":true}"; + const string expected = "{\"$type\":1,\"name\":\"Default\",\"note_color\":\"#44AADD\",\"blink_color\":\"#FF66AA\",\"text_color\":\"#FFFFFF\",\"bold_text\":true}"; string actual = JsonConvert.SerializeObject(lyricConfig, CreateSettings()); Assert.AreEqual(expected, actual); } @@ -78,7 +56,7 @@ public void TestNoteStyleSerializer() [Test] public void TestNoteStyleDeserializer() { - const string json = "{\"$type\":2,\"name\":\"Default\",\"note_color\":\"#44AADD\",\"blink_color\":\"#FF66AA\",\"text_color\":\"#FFFFFF\",\"bold_text\":true}"; + const string json = "{\"$type\":1,\"name\":\"Default\",\"note_color\":\"#44AADD\",\"blink_color\":\"#FF66AA\",\"text_color\":\"#FFFFFF\",\"bold_text\":true}"; var expected = NoteStyle.CreateDefault(); var actual = (NoteStyle)JsonConvert.DeserializeObject(json, CreateSettings())!; diff --git a/osu.Game.Rulesets.Karaoke.Tests/Resources/special-skin/lyric-styles.json b/osu.Game.Rulesets.Karaoke.Tests/Resources/special-skin/lyric-styles.json deleted file mode 100644 index 05dac13a0..000000000 --- a/osu.Game.Rulesets.Karaoke.Tests/Resources/special-skin/lyric-styles.json +++ /dev/null @@ -1,51 +0,0 @@ -[ - { - "$type": 2, - "id": 1, - "name": "Customized lyric style", - "left_lyric_text_shaders": [ - { - "$type": "StepShader", - "name": "HelloShader", - "draw": true, - "step_shaders": [ - { - "$type": "OutlineShader", - "radius": 3, - "outline_colour": "#CCA532" - }, - { - "$type": "ShadowShader", - "shadow_colour": "#6B5B2D", - "shadow_offset": { - "x": 3.0, - "y": 3.0 - } - } - ] - } - ], - "right_lyric_text_shaders": [ - { - "$type": "StepShader", - "name": "HelloShader", - "draw": true, - "step_shaders": [ - { - "$type": "OutlineShader", - "radius": 3, - "outline_colour": "#5932CC" - }, - { - "$type": "ShadowShader", - "shadow_colour": "#3D2D6B", - "shadow_offset": { - "x": 3.0, - "y": 3.0 - } - } - ] - } - ] - } -] \ No newline at end of file diff --git a/osu.Game.Rulesets.Karaoke.Tests/Screens/Skin/TestSceneKaraokeSkinEditor.cs b/osu.Game.Rulesets.Karaoke.Tests/Screens/Skin/TestSceneKaraokeSkinEditor.cs index 872a6d571..c8d78472a 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Screens/Skin/TestSceneKaraokeSkinEditor.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Screens/Skin/TestSceneKaraokeSkinEditor.cs @@ -67,7 +67,6 @@ public TestingSkin(SkinInfo skin, IStorageResourceProvider? resources) : base(skin, resources) { DefaultElement[ElementType.LyricFontInfo] = LyricFontInfo.CreateDefault(); - DefaultElement[ElementType.LyricStyle] = LyricStyle.CreateDefault(); DefaultElement[ElementType.NoteStyle] = NoteStyle.CreateDefault(); } } diff --git a/osu.Game.Rulesets.Karaoke.Tests/Skinning/KaraokeBeatmapSkinDecodingTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Skinning/KaraokeBeatmapSkinDecodingTest.cs index 24347d1ec..00dc8d91f 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Skinning/KaraokeBeatmapSkinDecodingTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Skinning/KaraokeBeatmapSkinDecodingTest.cs @@ -27,17 +27,14 @@ public void TestKaraokeBeatmapSkinDefaultValue() // try to get default value from the skin. var defaultLyricFontInfo = skin.GetConfig(referencedLyric)!.Value; - var defaultLyricStyle = skin.GetConfig(referencedLyric)!.Value; var defaultNoteStyle = skin.GetConfig(testingNote)!.Value; // should be able to get the default value. Assert.IsNotNull(defaultLyricFontInfo); - Assert.IsNotNull(defaultLyricStyle); Assert.IsNotNull(defaultNoteStyle); // Check the content Assert.IsNotNull(defaultLyricFontInfo.Name, "Default lyric config"); - Assert.IsNotNull(defaultLyricStyle.Name, "Default lyric style"); Assert.IsNotNull(defaultNoteStyle.Name, "Default note style"); } } diff --git a/osu.Game.Rulesets.Karaoke.Tests/Skinning/KaraokeSkinDecodingTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Skinning/KaraokeSkinDecodingTest.cs index af5a8943c..839ac10af 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Skinning/KaraokeSkinDecodingTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Skinning/KaraokeSkinDecodingTest.cs @@ -27,17 +27,14 @@ public void TestKaraokeSkinDefaultValue() // try to get default value from the skin. var defaultLyricFontInfo = skin.GetConfig(referencedLyric)!.Value; - var defaultLyricStyle = skin.GetConfig(referencedLyric)!.Value; var defaultNoteStyle = skin.GetConfig(testingNote)!.Value; // should be able to get the default value. Assert.IsNotNull(defaultLyricFontInfo); - Assert.IsNotNull(defaultLyricStyle); Assert.IsNotNull(defaultNoteStyle); // Check the content Assert.IsNotNull(defaultLyricFontInfo.Name, "Default lyric config"); - Assert.IsNotNull(defaultLyricStyle.Name, "Default lyric style"); Assert.IsNotNull(defaultNoteStyle.Name, "Default note style"); } } diff --git a/osu.Game.Rulesets.Karaoke.Tests/Stages/Infos/StageElementCategoryTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Stages/Infos/StageElementCategoryTest.cs index 9d47b6937..312cfea8c 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Stages/Infos/StageElementCategoryTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Stages/Infos/StageElementCategoryTest.cs @@ -238,5 +238,9 @@ public int CompareTo(TestStageElement? other) } } - private class TestStageElementCategory : StageElementCategory; + private class TestStageElementCategory : StageElementCategory + { + protected override TestStageElement CreateDefaultElement() + => new(); + } } diff --git a/osu.Game.Rulesets.Karaoke/Graphics/Sprites/DrawableKaraokeSpriteText.cs b/osu.Game.Rulesets.Karaoke/Graphics/Sprites/DrawableKaraokeSpriteText.cs index 86a323f3f..2e0d2f8cd 100644 --- a/osu.Game.Rulesets.Karaoke/Graphics/Sprites/DrawableKaraokeSpriteText.cs +++ b/osu.Game.Rulesets.Karaoke/Graphics/Sprites/DrawableKaraokeSpriteText.cs @@ -1,8 +1,11 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Allocation; +using osu.Framework.Graphics.Shaders; using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Karaoke.Objects; +using osu.Game.Rulesets.Karaoke.Skinning.Tools; namespace osu.Game.Rulesets.Karaoke.Graphics.Sprites; @@ -18,6 +21,9 @@ public DrawableKaraokeSpriteText(Lyric lyric) { private readonly DisplayLyricProcessor processor; + [Resolved] + private ShaderManager? shaderManager { get; set; } + protected DrawableKaraokeSpriteText(Lyric lyric) { processor = new DisplayLyricProcessor(lyric) @@ -68,4 +74,14 @@ protected override void Dispose(bool isDisposing) base.Dispose(isDisposing); processor.Dispose(); } + + public void UpdateStyle(LyricStyle style) + { + // for prevent issue Collection was modified; enumeration operation may not execute. + Schedule(() => + { + LeftLyricTextShaders = SkinConverterTool.ConvertLeftSideShader(shaderManager, style); + RightLyricTextShaders = SkinConverterTool.ConvertRightSideShader(shaderManager, style); + }); + } } diff --git a/osu.Game.Rulesets.Karaoke/Skinning/Elements/LyricStyle.cs b/osu.Game.Rulesets.Karaoke/Graphics/Sprites/LyricStyle.cs similarity index 64% rename from osu.Game.Rulesets.Karaoke/Skinning/Elements/LyricStyle.cs rename to osu.Game.Rulesets.Karaoke/Graphics/Sprites/LyricStyle.cs index 18d13425e..305e239cd 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/Elements/LyricStyle.cs +++ b/osu.Game.Rulesets.Karaoke/Graphics/Sprites/LyricStyle.cs @@ -1,23 +1,18 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. +// 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 osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Graphics; using osu.Framework.Graphics.Shaders; -using osu.Game.Rulesets.Karaoke.Objects.Drawables; -using osu.Game.Rulesets.Karaoke.Skinning.Tools; using osuTK; -namespace osu.Game.Rulesets.Karaoke.Skinning.Elements; +namespace osu.Game.Rulesets.Karaoke.Graphics.Sprites; -public class LyricStyle : IKaraokeSkinElement +public class LyricStyle { public static LyricStyle CreateDefault() => new() { - Name = "Default", LeftLyricTextShaders = new ICustomizedShader[] { new StepShader @@ -60,25 +55,7 @@ public class LyricStyle : IKaraokeSkinElement }, }; - public int ID { get; set; } - - public string Name { get; set; } = string.Empty; - public IReadOnlyList LeftLyricTextShaders = Array.Empty(); public IReadOnlyList RightLyricTextShaders = Array.Empty(); - - public void ApplyTo(Drawable d) - { - if (d is not DrawableLyric drawableLyric) - throw new InvalidDrawableTypeException(nameof(d)); - - var shaderManager = drawableLyric.Dependencies.Get(); - drawableLyric.ApplyToLyricPieces(l => - { - // Apply shader. - l.LeftLyricTextShaders = SkinConverterTool.ConvertLeftSideShader(shaderManager, this); - l.RightLyricTextShaders = SkinConverterTool.ConvertRightSideShader(shaderManager, this); - }); - } } diff --git a/osu.Game.Rulesets.Karaoke/IO/Serialization/Converters/KaraokeSkinElementConverter.cs b/osu.Game.Rulesets.Karaoke/IO/Serialization/Converters/KaraokeSkinElementConverter.cs index 2f63c2e87..e40d3dabc 100644 --- a/osu.Game.Rulesets.Karaoke/IO/Serialization/Converters/KaraokeSkinElementConverter.cs +++ b/osu.Game.Rulesets.Karaoke/IO/Serialization/Converters/KaraokeSkinElementConverter.cs @@ -19,7 +19,6 @@ public static ElementType GetElementType(MemberInfo elementType) => elementType switch { _ when elementType == typeof(LyricFontInfo) => ElementType.LyricFontInfo, - _ when elementType == typeof(LyricStyle) => ElementType.LyricStyle, _ when elementType == typeof(NoteStyle) => ElementType.NoteStyle, _ => throw new NotSupportedException(), }; @@ -28,7 +27,6 @@ public static Type GetObjectType(ElementType elementType) => elementType switch { ElementType.LyricFontInfo => typeof(LyricFontInfo), - ElementType.LyricStyle => typeof(LyricStyle), ElementType.NoteStyle => typeof(NoteStyle), _ => throw new NotSupportedException(), }; diff --git a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs index be83178fb..fea816716 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs @@ -35,7 +35,6 @@ public partial class DrawableLyric : DrawableKaraokeHitObject private readonly Bindable romanisationMarginBindable = new(); private readonly Bindable translationFontUsageBindable = new(); - private readonly IBindableDictionary singersBindable = new BindableDictionary(); private readonly BindableDictionary translationTextBindable = new(); public event Action? OnLyricStart; @@ -89,7 +88,6 @@ private void load(KaraokeRulesetConfigManager? config) translationFontUsageBindable.BindValueChanged(_ => updateLyricFontInfo()); // property in hitobject. - singersBindable.BindCollectionChanged((_, _) => { updateFontStyle(); }); translationTextBindable.BindCollectionChanged((_, _) => { applyTranslation(); }); } @@ -121,7 +119,6 @@ protected override void OnApply() lyricPieces.Add(new DrawableKaraokeSpriteText(HitObject)); ApplySkin(CurrentSkin, false); - singersBindable.BindTo(HitObject.SingersBindable); translationTextBindable.BindTo(HitObject.TranslationsBindable); } @@ -129,7 +126,6 @@ protected override void OnFree() { base.OnFree(); - singersBindable.UnbindFrom(HitObject.SingersBindable); translationTextBindable.UnbindFrom(HitObject.TranslationsBindable); } @@ -137,22 +133,9 @@ protected override void ApplySkin(ISkinSource skin, bool allowFallback) { base.ApplySkin(skin, allowFallback); - updateFontStyle(); updateLyricFontInfo(); } - private void updateFontStyle() - { - if (CurrentSkin == null) - return; - - if (HitObject.IsNull()) - return; - - var lyricStyle = CurrentSkin.GetConfig(HitObject)?.Value; - lyricStyle?.ApplyTo(this); - } - private void updateLyricFontInfo() { if (CurrentSkin == null) diff --git a/osu.Game.Rulesets.Karaoke/Resources/Skin/Default/lyric-styles.json b/osu.Game.Rulesets.Karaoke/Resources/Skin/Default/lyric-styles.json deleted file mode 100644 index 0637a088a..000000000 --- a/osu.Game.Rulesets.Karaoke/Resources/Skin/Default/lyric-styles.json +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/PreviewKaraokeSpriteText.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/PreviewKaraokeSpriteText.cs index 4524523fd..f00781b10 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/PreviewKaraokeSpriteText.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/PreviewKaraokeSpriteText.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Shaders; @@ -13,10 +14,10 @@ using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Objects.Utils; using osu.Game.Rulesets.Karaoke.Skinning.Elements; -using osu.Game.Rulesets.Karaoke.Skinning.Tools; using osu.Game.Rulesets.Karaoke.Utils; using osu.Game.Skinning; using osuTK; +using LyricStyle = osu.Game.Rulesets.Karaoke.Graphics.Sprites.LyricStyle; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Components.Lyrics; @@ -39,6 +40,28 @@ public PreviewKaraokeSpriteText(Lyric lyric) DisplayType = LyricDisplayType.Lyric; DisplayProperty = LyricDisplayProperty.Both; + // give it a default style. + UpdateStyle(new LyricStyle + { + LeftLyricTextShaders = new List + { + new OutlineShader + { + Radius = 2, + Colour = Color4Extensions.FromHex("#3D2D6B"), + OutlineColour = Color4Extensions.FromHex("#CCA532"), + }, + }, + RightLyricTextShaders = new List + { + new OutlineShader + { + Radius = 2, + OutlineColour = Color4Extensions.FromHex("#5932CC"), + }, + }, + }); + spriteText = getSpriteText(); EditorLyricSpriteText getSpriteText() @@ -217,18 +240,6 @@ static float extraSpacing(IList timeTagsInLyric, TimeTag timeTag) [BackgroundDependencyLoader] private void load(ISkinSource skin, ShaderManager? shaderManager) { - skin.GetConfig(HitObject)?.BindValueChanged(lyricStyle => - { - var newStyle = lyricStyle.NewValue; - if (newStyle == null) - return; - - LeftLyricTextShaders = SkinConverterTool.ConvertLeftSideShader(shaderManager, newStyle); - RightLyricTextShaders = SkinConverterTool.ConvertRightSideShader(shaderManager, newStyle); - - triggerSizeChangedEvent(); - }, true); - skin.GetConfig(HitObject)?.BindValueChanged(e => { var newConfig = e.NewValue; diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorSkin.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorSkin.cs index 2bc3b1074..62173b567 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorSkin.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorSkin.cs @@ -44,27 +44,6 @@ public LyricEditorSkin(SkinInfo skin, IStorageResourceProvider? resources) : base(skin, resources) { DefaultElement[ElementType.LyricFontInfo] = LyricFontInfo.CreateDefault(); - DefaultElement[ElementType.LyricStyle] = new LyricStyle - { - Name = "Default", - LeftLyricTextShaders = new List - { - new OutlineShader - { - Radius = 2, - Colour = Color4Extensions.FromHex("#3D2D6B"), - OutlineColour = Color4Extensions.FromHex("#CCA532"), - }, - }, - RightLyricTextShaders = new List - { - new OutlineShader - { - Radius = 2, - OutlineColour = Color4Extensions.FromHex("#5932CC"), - }, - }, - }; DefaultElement[ElementType.NoteStyle] = NoteStyle.CreateDefault(); // todo: should use better way to handle overall size. diff --git a/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/LyricColorSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/LyricColorSection.cs index 31406875d..9a42a38f2 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/LyricColorSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/LyricColorSection.cs @@ -32,11 +32,6 @@ public LyricColorSection() }, }; } - - [BackgroundDependencyLoader] - private void load(StyleManager manager) - { - } } public enum ColorArea diff --git a/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/LyricStylePreview.cs b/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/LyricStylePreview.cs index 9ff1be5a3..2320cffdf 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/LyricStylePreview.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/LyricStylePreview.cs @@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Skin.Style; internal partial class LyricStylePreview : CompositeDrawable { [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider, StyleManager manager) + private void load(OverlayColourProvider colourProvider) { Masking = true; CornerRadius = 15; diff --git a/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/StyleManager.cs b/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/StyleManager.cs deleted file mode 100644 index f52c981d9..000000000 --- a/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/StyleManager.cs +++ /dev/null @@ -1,34 +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 osu.Framework.Allocation; -using osu.Framework.Bindables; -using osu.Framework.Graphics; -using osu.Game.Rulesets.Karaoke.Skinning.Elements; - -namespace osu.Game.Rulesets.Karaoke.Screens.Skin.Style; - -public partial class StyleManager : Component -{ - public readonly Bindable EditStyle = new(); - - public readonly Bindable EditNoteStyle = new(); - - [BackgroundDependencyLoader] - private void load() - { - } - - public void ApplyCurrentStyleChange(Action action) - { - action(EditStyle.Value); - EditStyle.TriggerChange(); - } - - public void ApplyCurrentNoteStyle(Action action) - { - action(EditNoteStyle.Value); - EditNoteStyle.TriggerChange(); - } -} diff --git a/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/StyleScreen.cs b/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/StyleScreen.cs index 92c69b621..725478ed1 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/StyleScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/StyleScreen.cs @@ -11,13 +11,9 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Skin.Style; public partial class StyleScreen : KaraokeSkinEditorScreen { - [Cached] - protected readonly StyleManager StyleManager; - public StyleScreen(ISkin skin) : base(skin, KaraokeSkinEditorScreenMode.Style) { - AddInternal(StyleManager = new StyleManager()); } protected override Section[] CreateSelectionContainer() diff --git a/osu.Game.Rulesets.Karaoke/Skinning/Elements/ElementType.cs b/osu.Game.Rulesets.Karaoke/Skinning/Elements/ElementType.cs index 60bd832d0..6db24cfee 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/Elements/ElementType.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/Elements/ElementType.cs @@ -7,7 +7,5 @@ public enum ElementType { LyricFontInfo, - LyricStyle, - NoteStyle, } diff --git a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeBeatmapSkin.cs b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeBeatmapSkin.cs index b623be191..706b47d87 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeBeatmapSkin.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeBeatmapSkin.cs @@ -61,7 +61,6 @@ static string getFileNameByType(ElementType elementType) => elementType switch { ElementType.LyricFontInfo => "lyric-font-infos", - ElementType.LyricStyle => "lyric-styles", ElementType.NoteStyle => "note-styles", _ => throw new InvalidEnumArgumentException(nameof(elementType)), }; @@ -97,7 +96,6 @@ static string getFileNameByType(ElementType elementType) case KaraokeIndexLookup indexLookup: return indexLookup switch { - KaraokeIndexLookup.Style => SkinUtils.As(getSelectionFromElementType(ElementType.LyricStyle)), KaraokeIndexLookup.Note => SkinUtils.As(getSelectionFromElementType(ElementType.NoteStyle)), _ => throw new InvalidEnumArgumentException(nameof(indexLookup)), }; diff --git a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeIndexLookup.cs b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeIndexLookup.cs index 7c5f4bea6..632247b80 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeIndexLookup.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeIndexLookup.cs @@ -10,7 +10,5 @@ public enum KaraokeIndexLookup { Layout, - Style, - Note, } diff --git a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkin.cs b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkin.cs index 3f2d44d1e..5a0494dea 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkin.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkin.cs @@ -33,7 +33,6 @@ public class KaraokeSkin : Skin public readonly IDictionary DefaultElement = new Dictionary { { ElementType.LyricFontInfo, LyricFontInfo.CreateDefault() }, - { ElementType.LyricStyle, LyricStyle.CreateDefault() }, { ElementType.NoteStyle, NoteStyle.CreateDefault() }, }; @@ -64,7 +63,6 @@ public KaraokeSkin(SkinInfo skin, IStorageResourceProvider? resources, IResource return; DefaultElement[ElementType.LyricFontInfo] = deserializedContent.LyricFontInfo; - DefaultElement[ElementType.LyricStyle] = deserializedContent.LyricStyle; DefaultElement[ElementType.NoteStyle] = deserializedContent.NoteStyle; } catch (Exception ex) @@ -129,7 +127,7 @@ public KaraokeSkin(SkinInfo skin, IStorageResourceProvider? resources, IResource return type switch { - ElementType.LyricStyle or ElementType.LyricFontInfo or ElementType.NoteStyle => SkinUtils.As(new Bindable((TValue)DefaultElement[type])), + ElementType.LyricFontInfo or ElementType.NoteStyle => SkinUtils.As(new Bindable((TValue)DefaultElement[type])), _ => throw new InvalidEnumArgumentException(nameof(type)), }; } @@ -162,7 +160,7 @@ public KaraokeSkin(SkinInfo skin, IStorageResourceProvider? resources, IResource private IKaraokeSkinElement? toElement(ElementType type) => type switch { - ElementType.LyricStyle or ElementType.LyricFontInfo or ElementType.NoteStyle => DefaultElement[type], + ElementType.LyricFontInfo or ElementType.NoteStyle => DefaultElement[type], _ => throw new InvalidEnumArgumentException(nameof(type)), }; @@ -170,8 +168,6 @@ private class DefaultSkinFormat { public LyricFontInfo LyricFontInfo { get; set; } = null!; - public LyricStyle LyricStyle { get; set; } = null!; - public NoteStyle NoteStyle { get; set; } = null!; } } diff --git a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkinLookup.cs b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkinLookup.cs index 081cb1dd6..a34e3f3db 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkinLookup.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkinLookup.cs @@ -26,7 +26,7 @@ public readonly struct KaraokeSkinLookup public int Lookup { get; } /// - /// Ctor for and + /// Ctor for /// /// /// @@ -35,7 +35,6 @@ public KaraokeSkinLookup(ElementType type, IEnumerable singers) { switch (type) { - case ElementType.LyricStyle: case ElementType.LyricFontInfo: case ElementType.NoteStyle: return; diff --git a/osu.Game.Rulesets.Karaoke/Skinning/Tools/SkinConverterTool.cs b/osu.Game.Rulesets.Karaoke/Skinning/Tools/SkinConverterTool.cs index 822256dd7..221a3b3f3 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/Tools/SkinConverterTool.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/Tools/SkinConverterTool.cs @@ -6,7 +6,7 @@ using System.Linq; using osu.Framework.Extensions; using osu.Framework.Graphics.Shaders; -using osu.Game.Rulesets.Karaoke.Skinning.Elements; +using osu.Game.Rulesets.Karaoke.Graphics.Sprites; namespace osu.Game.Rulesets.Karaoke.Skinning.Tools; diff --git a/osu.Game.Rulesets.Karaoke/Stages/Commands/Lyrics/LyricStyleCommand.cs b/osu.Game.Rulesets.Karaoke/Stages/Commands/Lyrics/LyricStyleCommand.cs new file mode 100644 index 000000000..e80272674 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Stages/Commands/Lyrics/LyricStyleCommand.cs @@ -0,0 +1,63 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Transforms; +using osu.Game.Rulesets.Karaoke.Graphics.Sprites; +using osu.Game.Rulesets.Karaoke.Objects.Drawables; + +namespace osu.Game.Rulesets.Karaoke.Stages.Commands.Lyrics; + +public class LyricStyleCommand : StageCommand +{ + public LyricStyleCommand(Easing easing, double startTime, double endTime, LyricStyle startValue, LyricStyle endValue) + : base(easing, startTime, endTime, startValue, endValue) + { + } + + public override string PropertyName => nameof(LyricStyle); + + public override void ApplyInitialValue(TDrawable d) + { + if (d is not DrawableLyric drawableLyric) + throw new InvalidOperationException(); + + drawableLyric.ApplyToLyricPieces(l => + { + l.UpdateStyle(StartValue); + }); + } + + public override TransformSequence ApplyTransforms(TDrawable d) + { + // note: because update shader cost lots of effect, if the duration is 0, we just use the initial value. + if (Duration == 0) + return d.Delay(0); + + return d.TransformTo(d.PopulateTransform(new ApplyLyricFontTransform(), StartValue)) + .Delay(Duration) + .Append(o => o.TransformTo(d.PopulateTransform(new ApplyLyricFontTransform(), EndValue))); + } + + private class ApplyLyricFontTransform : Transform + { + public override string TargetMember => nameof(LyricStyle); + + protected override void Apply(Drawable d, double time) + { + if (d is not DrawableLyric drawableLyric) + throw new InvalidOperationException(); + + drawableLyric.ApplyToLyricPieces(l => + { + l.UpdateStyle(EndValue); + }); + } + + protected override void ReadIntoStartValue(Drawable d) + { + // there's no start value for it. + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicLyricCommandProvider.cs b/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicLyricCommandProvider.cs index 97cbdce57..44d35fe48 100644 --- a/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicLyricCommandProvider.cs +++ b/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicLyricCommandProvider.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Stages.Commands; +using osu.Game.Rulesets.Karaoke.Stages.Commands.Lyrics; using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Karaoke.Stages.Infos.Classic; @@ -62,8 +63,8 @@ protected override IEnumerable GetInitialCommands(Lyric hitObject var elements = StageInfo.GetStageElements(hitObject); return elements.Select(e => e switch { - ClassicLyricLayout previewLyricLayout => updateInitialTransforms(previewLyricLayout), - ClassicStyle => Array.Empty(), // todo: implement. + ClassicLyricLayout layout => updateInitialTransforms(layout), + ClassicStyle style => updateInitialTransforms(style), _ => throw new NotSupportedException(), }).SelectMany(x => x); } @@ -116,6 +117,14 @@ static MarginPadding getPosition(ClassicStageDefinition definition, ClassicLyric } } + private IEnumerable updateInitialTransforms(ClassicStyle style) + { + if (style.LyricStyle != null) + { + yield return new LyricStyleCommand(Easing.None, 0, 0, style.LyricStyle, style.LyricStyle); + } + } + protected override IEnumerable GetStartTimeStateCommands(Lyric hitObject) { // there's no transformer in here. diff --git a/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicLyricLayoutCategory.cs b/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicLyricLayoutCategory.cs index 093ffecb6..4766a3c88 100644 --- a/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicLyricLayoutCategory.cs +++ b/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicLyricLayoutCategory.cs @@ -5,4 +5,8 @@ namespace osu.Game.Rulesets.Karaoke.Stages.Infos.Classic; -public class ClassicLyricLayoutCategory : StageElementCategory; +public class ClassicLyricLayoutCategory : StageElementCategory +{ + protected override ClassicLyricLayout CreateDefaultElement() + => new(); +} diff --git a/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicStyle.cs b/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicStyle.cs index 51c54f8cd..6085415f1 100644 --- a/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicStyle.cs +++ b/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicStyle.cs @@ -4,6 +4,7 @@ using System; using Newtonsoft.Json; using osu.Framework.Bindables; +using osu.Game.Rulesets.Karaoke.Graphics.Sprites; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Utils; @@ -11,17 +12,10 @@ namespace osu.Game.Rulesets.Karaoke.Stages.Infos.Classic; public class ClassicStyle : StageElement { - [JsonIgnore] - public readonly Bindable LyricStyleIndexBindable = new(); - /// - /// 's skin lookup index. + /// 's text style. /// - public int? LyricStyleIndex - { - get => LyricStyleIndexBindable.Value; - set => LyricStyleIndexBindable.Value = value; - } + public LyricStyle? LyricStyle { get; set; } [JsonIgnore] public readonly Bindable NoteStyleIndexBindable = new(); diff --git a/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicStyleCategory.cs b/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicStyleCategory.cs index ff6713d05..e72fbe818 100644 --- a/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicStyleCategory.cs +++ b/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicStyleCategory.cs @@ -1,9 +1,16 @@ // 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.Graphics.Sprites; using osu.Game.Rulesets.Karaoke.Objects; namespace osu.Game.Rulesets.Karaoke.Stages.Infos.Classic; -// todo: get the note style by throwing reference lyric. -public class ClassicStyleCategory : StageElementCategory; +public class ClassicStyleCategory : StageElementCategory +{ + protected override ClassicStyle CreateDefaultElement() + => new() + { + LyricStyle = LyricStyle.CreateDefault(), + }; +} diff --git a/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewLyricCommandProvider.cs b/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewLyricCommandProvider.cs index d4e2a9446..8caae1885 100644 --- a/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewLyricCommandProvider.cs +++ b/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewLyricCommandProvider.cs @@ -4,8 +4,10 @@ using System; using System.Collections.Generic; using System.Linq; +using osu.Framework.Graphics; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Stages.Commands; +using osu.Game.Rulesets.Karaoke.Stages.Commands.Lyrics; using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Karaoke.Stages.Infos.Preview; @@ -34,7 +36,7 @@ protected override IEnumerable GetInitialCommands(Lyric hitObject return elements.Select(e => e switch { PreviewLyricLayout previewLyricLayout => updateInitialTransforms(previewLyricLayout), - PreviewStyle => Array.Empty(), // todo: implement. + PreviewStyle style => updateInitialTransforms(style), _ => throw new NotSupportedException(), }).SelectMany(x => x); } @@ -94,6 +96,14 @@ static float getTargetAlpha(PreviewStageDefinition definition, PreviewLyricLayou static bool isLastLyricInView(PreviewLyricLayout layout) => layout.StartTime != 0; } + private IEnumerable updateInitialTransforms(PreviewStyle style) + { + if (style.LyricStyle != null) + { + yield return new LyricStyleCommand(Easing.None, 0, 0, style.LyricStyle, style.LyricStyle); + } + } + protected override IEnumerable GetStartTimeStateCommands(Lyric hitObject) { var elements = StageInfo.GetStageElements(hitObject); @@ -133,7 +143,7 @@ protected override IEnumerable GetHitStateCommands(Lyric hitObjec var elements = StageInfo.GetStageElements(hitObject); return elements.Select(e => e switch { - PreviewLyricLayout previewLyricLayout => updateHitStateTransforms(state, previewLyricLayout), + PreviewLyricLayout layout => updateHitStateTransforms(state, layout), PreviewStyle => Array.Empty(), // todo: implement. _ => throw new NotSupportedException(), }).SelectMany(x => x); diff --git a/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewLyricLayoutCategory.cs b/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewLyricLayoutCategory.cs index 74a38159e..6f605e112 100644 --- a/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewLyricLayoutCategory.cs +++ b/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewLyricLayoutCategory.cs @@ -5,4 +5,8 @@ namespace osu.Game.Rulesets.Karaoke.Stages.Infos.Preview; -public class PreviewLyricLayoutCategory : StageElementCategory; +public class PreviewLyricLayoutCategory : StageElementCategory +{ + protected override PreviewLyricLayout CreateDefaultElement() + => new(); +} diff --git a/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewStyle.cs b/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewStyle.cs index 9551edd61..e1bec4493 100644 --- a/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewStyle.cs +++ b/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewStyle.cs @@ -1,6 +1,7 @@ // 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.Graphics.Sprites; using osu.Game.Rulesets.Karaoke.Objects; namespace osu.Game.Rulesets.Karaoke.Stages.Infos.Preview; @@ -8,9 +9,9 @@ namespace osu.Game.Rulesets.Karaoke.Stages.Infos.Preview; public class PreviewStyle : StageElement { /// - /// 's skin lookup index. + /// 's text style. /// - public int? LyricStyleIndex { get; set; } + public LyricStyle? LyricStyle { get; set; } /// /// 's skin lookup index. diff --git a/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewStyleCategory.cs b/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewStyleCategory.cs index 61522c154..d79353afc 100644 --- a/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewStyleCategory.cs +++ b/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewStyleCategory.cs @@ -1,8 +1,16 @@ // 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.Graphics.Sprites; using osu.Game.Rulesets.Karaoke.Objects; namespace osu.Game.Rulesets.Karaoke.Stages.Infos.Preview; -public class PreviewStyleCategory : StageElementCategory; +public class PreviewStyleCategory : StageElementCategory +{ + protected override PreviewStyle CreateDefaultElement() + => new() + { + LyricStyle = LyricStyle.CreateDefault(), + }; +} diff --git a/osu.Game.Rulesets.Karaoke/Stages/Infos/StageElementCategory.cs b/osu.Game.Rulesets.Karaoke/Stages/Infos/StageElementCategory.cs index 7283fdcb0..768087e67 100644 --- a/osu.Game.Rulesets.Karaoke/Stages/Infos/StageElementCategory.cs +++ b/osu.Game.Rulesets.Karaoke/Stages/Infos/StageElementCategory.cs @@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Karaoke.Stages.Infos; /// Can add more customised role by inherit this class.
///
public abstract class StageElementCategory - where TStageElement : StageElement, new() + where TStageElement : StageElement where THitObject : KaraokeHitObject, IHasPrimaryKey { /// @@ -37,14 +37,15 @@ public abstract class StageElementCategory protected StageElementCategory() { - DefaultElement = new TStageElement(); + DefaultElement = CreateDefaultElement(); + DefaultElement.Name = "Default"; } #region Edit public TStageElement AddElement(Action? action = null) { - var element = new TStageElement(); + var element = CreateDefaultElement(); action?.Invoke(element); AvailableElements.Add(element); @@ -121,6 +122,8 @@ public virtual void ClearUnusedMapping(Func checkExist) } } + protected abstract TStageElement CreateDefaultElement(); + #endregion #region Query