From b7554cc35cd561975ba6439fbcb6bad8fb7269ab Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 8 Dec 2024 17:34:05 +0800 Subject: [PATCH 01/13] refactor(code): P0.1 - Rename the params. --- .../Stages/Infos/Classic/ClassicLyricCommandProvider.cs | 2 +- .../Stages/Infos/Preview/PreviewLyricCommandProvider.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicLyricCommandProvider.cs b/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicLyricCommandProvider.cs index 97cbdce57..56d41cd37 100644 --- a/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicLyricCommandProvider.cs +++ b/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicLyricCommandProvider.cs @@ -62,7 +62,7 @@ protected override IEnumerable GetInitialCommands(Lyric hitObject var elements = StageInfo.GetStageElements(hitObject); return elements.Select(e => e switch { - ClassicLyricLayout previewLyricLayout => updateInitialTransforms(previewLyricLayout), + ClassicLyricLayout layout => updateInitialTransforms(layout), ClassicStyle => Array.Empty(), // todo: implement. _ => throw new NotSupportedException(), }).SelectMany(x => x); diff --git a/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewLyricCommandProvider.cs b/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewLyricCommandProvider.cs index d4e2a9446..5b0df618d 100644 --- a/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewLyricCommandProvider.cs +++ b/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewLyricCommandProvider.cs @@ -133,7 +133,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); From a3ca3c26e8b161e8c1af5b7c565047277f420143 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 10 Dec 2024 22:10:55 +0800 Subject: [PATCH 02/13] chore(stage): P0.2 - stage category should be able to create its own default element. --- .../Stages/StageElementCategoryChangeHandlerTest.cs | 6 +++++- .../Stages/Infos/StageElementCategoryTest.cs | 6 +++++- .../Stages/Infos/Classic/ClassicLyricLayoutCategory.cs | 6 +++++- .../Stages/Infos/Classic/ClassicStyleCategory.cs | 6 +++++- .../Stages/Infos/Preview/PreviewLyricLayoutCategory.cs | 6 +++++- .../Stages/Infos/Preview/PreviewStyleCategory.cs | 6 +++++- .../Stages/Infos/StageElementCategory.cs | 9 ++++++--- 7 files changed, 36 insertions(+), 9 deletions(-) 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/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/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/ClassicStyleCategory.cs b/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicStyleCategory.cs index ff6713d05..075556e17 100644 --- a/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicStyleCategory.cs +++ b/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicStyleCategory.cs @@ -6,4 +6,8 @@ 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(); +} 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/PreviewStyleCategory.cs b/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewStyleCategory.cs index 61522c154..147587f72 100644 --- a/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewStyleCategory.cs +++ b/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewStyleCategory.cs @@ -5,4 +5,8 @@ namespace osu.Game.Rulesets.Karaoke.Stages.Infos.Preview; -public class PreviewStyleCategory : StageElementCategory; +public class PreviewStyleCategory : StageElementCategory +{ + protected override PreviewStyle CreateDefaultElement() + => new(); +} 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 From 52b77e23fd27d205e86961bd331ec1097d3520b3 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 8 Dec 2024 23:10:03 +0800 Subject: [PATCH 03/13] feat(sprite): P1.1 - Create method for update the style. merge. --- .../Sprites/DrawableKaraokeSpriteText.cs | 16 +++++ .../Graphics/Sprites/LyricStyle.cs | 61 +++++++++++++++++++ .../Skinning/Tools/SkinConverterTool.cs | 2 +- 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Rulesets.Karaoke/Graphics/Sprites/LyricStyle.cs 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/Graphics/Sprites/LyricStyle.cs b/osu.Game.Rulesets.Karaoke/Graphics/Sprites/LyricStyle.cs new file mode 100644 index 000000000..305e239cd --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Graphics/Sprites/LyricStyle.cs @@ -0,0 +1,61 @@ +// 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.Extensions.Color4Extensions; +using osu.Framework.Graphics.Shaders; +using osuTK; + +namespace osu.Game.Rulesets.Karaoke.Graphics.Sprites; + +public class LyricStyle +{ + public static LyricStyle CreateDefault() => new() + { + LeftLyricTextShaders = new ICustomizedShader[] + { + new StepShader + { + Name = "Step shader", + StepShaders = new ICustomizedShader[] + { + new OutlineShader + { + Radius = 3, + OutlineColour = Color4Extensions.FromHex("#CCA532"), + }, + new ShadowShader + { + ShadowColour = Color4Extensions.FromHex("#6B5B2D"), + ShadowOffset = new Vector2(3), + }, + }, + }, + }, + RightLyricTextShaders = new ICustomizedShader[] + { + new StepShader + { + Name = "Step shader", + StepShaders = new ICustomizedShader[] + { + new OutlineShader + { + Radius = 3, + OutlineColour = Color4Extensions.FromHex("#5932CC"), + }, + new ShadowShader + { + ShadowColour = Color4Extensions.FromHex("#3D2D6B"), + ShadowOffset = new Vector2(3), + }, + }, + }, + }, + }; + + public IReadOnlyList LeftLyricTextShaders = Array.Empty(); + + public IReadOnlyList RightLyricTextShaders = Array.Empty(); +} 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; From be51f67452f9081b08edb95b895559a6b1801448 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 8 Dec 2024 23:11:24 +0800 Subject: [PATCH 04/13] feat(stage): P1.2 - Implement the transformer. --- .../Commands/Lyrics/LyricStyleCommand.cs | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 osu.Game.Rulesets.Karaoke/Stages/Commands/Lyrics/LyricStyleCommand.cs 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. + } + } +} From d12293d7d30f5b4e8191359888540e3323af1f1d Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 10 Dec 2024 21:17:01 +0800 Subject: [PATCH 05/13] feat(stage): P1.3 - Replace the object id into class instance. Also, give the category a default value. --- .../Stages/Infos/Classic/ClassicStyle.cs | 12 +++--------- .../Stages/Infos/Classic/ClassicStyleCategory.cs | 7 +++++-- .../Stages/Infos/Preview/PreviewStyle.cs | 5 +++-- .../Stages/Infos/Preview/PreviewStyleCategory.cs | 6 +++++- 4 files changed, 16 insertions(+), 14 deletions(-) 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 075556e17..e72fbe818 100644 --- a/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicStyleCategory.cs +++ b/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicStyleCategory.cs @@ -1,13 +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 { protected override ClassicStyle CreateDefaultElement() - => new(); + => new() + { + LyricStyle = LyricStyle.CreateDefault(), + }; } 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 147587f72..d79353afc 100644 --- a/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewStyleCategory.cs +++ b/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewStyleCategory.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,5 +9,8 @@ namespace osu.Game.Rulesets.Karaoke.Stages.Infos.Preview; public class PreviewStyleCategory : StageElementCategory { protected override PreviewStyle CreateDefaultElement() - => new(); + => new() + { + LyricStyle = LyricStyle.CreateDefault(), + }; } From 64442dbfbe326e327464189bf6fdb7e5099fa9f8 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 8 Dec 2024 17:37:08 +0800 Subject: [PATCH 06/13] feat(stage): P1.4 - Apply the style to the provider. --- .../Infos/Classic/ClassicLyricCommandProvider.cs | 11 ++++++++++- .../Infos/Preview/PreviewLyricCommandProvider.cs | 12 +++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicLyricCommandProvider.cs b/osu.Game.Rulesets.Karaoke/Stages/Infos/Classic/ClassicLyricCommandProvider.cs index 56d41cd37..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; @@ -63,7 +64,7 @@ protected override IEnumerable GetInitialCommands(Lyric hitObject return elements.Select(e => e switch { ClassicLyricLayout layout => updateInitialTransforms(layout), - ClassicStyle => Array.Empty(), // todo: implement. + 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/Preview/PreviewLyricCommandProvider.cs b/osu.Game.Rulesets.Karaoke/Stages/Infos/Preview/PreviewLyricCommandProvider.cs index 5b0df618d..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); From 65ba7f5402c6beb60741fb5e97ebdc16c40fed94 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 10 Dec 2024 21:26:08 +0800 Subject: [PATCH 07/13] fix(drawable): P2.1 - Change the singer should not affect the style. --- .../Objects/Drawables/DrawableLyric.cs | 17 ----------------- 1 file changed, 17 deletions(-) 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) From 7553a3f01172bed7b727eed37aca1bdde50039ac Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 10 Dec 2024 21:37:59 +0800 Subject: [PATCH 08/13] fix(drawable): P2.2 - Give this font a default style. --- .../Lyrics/PreviewKaraokeSpriteText.cs | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) 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; From ae8e8967d1b6b8f0cc85710f077d1140d59e317d Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 10 Dec 2024 21:24:39 +0800 Subject: [PATCH 09/13] chore(skin): P2.3 - remove the enum. --- .../Converters/KaraokeSkinElementConverter.cs | 2 -- .../Edit/Beatmaps/Lyrics/LyricEditorSkin.cs | 21 ------------------- .../Skinning/Elements/ElementType.cs | 2 -- .../Skinning/KaraokeBeatmapSkin.cs | 2 -- .../Skinning/KaraokeIndexLookup.cs | 2 -- .../Skinning/KaraokeSkin.cs | 8 ++----- .../Skinning/KaraokeSkinLookup.cs | 3 +-- 7 files changed, 3 insertions(+), 37 deletions(-) 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/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/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; From 1f99ef968ebc338f9a5965d1146169930b1b2dd0 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 10 Dec 2024 21:42:54 +0800 Subject: [PATCH 10/13] chore(skin): P2.4 - Remove the style manager. --- .../Screens/Skin/Style/LyricColorSection.cs | 5 --- .../Screens/Skin/Style/LyricStylePreview.cs | 2 +- .../Screens/Skin/Style/StyleManager.cs | 34 ------------------- .../Screens/Skin/Style/StyleScreen.cs | 4 --- 4 files changed, 1 insertion(+), 44 deletions(-) delete mode 100644 osu.Game.Rulesets.Karaoke/Screens/Skin/Style/StyleManager.cs 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() From 416ca3ed0a8ecafa511011b678142ccbde9c5729 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 10 Dec 2024 21:39:34 +0800 Subject: [PATCH 11/13] chore(skin): P2.5 - Remove the definition from skin element. --- .../Skinning/Elements/LyricStyle.cs | 84 ------------------- 1 file changed, 84 deletions(-) delete mode 100644 osu.Game.Rulesets.Karaoke/Skinning/Elements/LyricStyle.cs diff --git a/osu.Game.Rulesets.Karaoke/Skinning/Elements/LyricStyle.cs b/osu.Game.Rulesets.Karaoke/Skinning/Elements/LyricStyle.cs deleted file mode 100644 index 18d13425e..000000000 --- a/osu.Game.Rulesets.Karaoke/Skinning/Elements/LyricStyle.cs +++ /dev/null @@ -1,84 +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 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; - -public class LyricStyle : IKaraokeSkinElement -{ - public static LyricStyle CreateDefault() => new() - { - Name = "Default", - LeftLyricTextShaders = new ICustomizedShader[] - { - new StepShader - { - Name = "Step shader", - StepShaders = new ICustomizedShader[] - { - new OutlineShader - { - Radius = 3, - OutlineColour = Color4Extensions.FromHex("#CCA532"), - }, - new ShadowShader - { - ShadowColour = Color4Extensions.FromHex("#6B5B2D"), - ShadowOffset = new Vector2(3), - }, - }, - }, - }, - RightLyricTextShaders = new ICustomizedShader[] - { - new StepShader - { - Name = "Step shader", - StepShaders = new ICustomizedShader[] - { - new OutlineShader - { - Radius = 3, - OutlineColour = Color4Extensions.FromHex("#5932CC"), - }, - new ShadowShader - { - ShadowColour = Color4Extensions.FromHex("#3D2D6B"), - ShadowOffset = new Vector2(3), - }, - }, - }, - }, - }; - - 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); - }); - } -} From d17bdddd3c195e912cd761c5d4782d278c454aad Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 10 Dec 2024 21:45:26 +0800 Subject: [PATCH 12/13] chore(test): P3.1 - Remove unnecessary test case. --- .../KaraokeSkinElementConverterTest.cs | 26 ++----------------- .../Skin/TestSceneKaraokeSkinEditor.cs | 1 - .../KaraokeBeatmapSkinDecodingTest.cs | 3 --- .../Skinning/KaraokeSkinDecodingTest.cs | 3 --- 4 files changed, 2 insertions(+), 31 deletions(-) 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/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"); } } From 3c68ed30e9eaeee02781c837ec930b276bd682e3 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 10 Dec 2024 21:23:28 +0800 Subject: [PATCH 13/13] chore(test): P3.2 - Remove static resource. --- .../Resources/special-skin/lyric-styles.json | 51 ------------------- .../Resources/Skin/Default/lyric-styles.json | 1 - 2 files changed, 52 deletions(-) delete mode 100644 osu.Game.Rulesets.Karaoke.Tests/Resources/special-skin/lyric-styles.json delete mode 100644 osu.Game.Rulesets.Karaoke/Resources/Skin/Default/lyric-styles.json 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/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