From 7800408221cb89c9c20693ed3dcf4a8dd8e82197 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 15 Apr 2023 10:50:23 +0800 Subject: [PATCH 01/11] Apply the effect into the drawable. --- .../Drawables/DrawableKaraokeHitObject.cs | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableKaraokeHitObject.cs b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableKaraokeHitObject.cs index d331e025f..2d6745d46 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableKaraokeHitObject.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableKaraokeHitObject.cs @@ -5,6 +5,7 @@ using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Karaoke.Judgements; +using osu.Game.Rulesets.Karaoke.Objects.Types; using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Karaoke.Objects.Drawables @@ -16,8 +17,43 @@ protected DrawableKaraokeHitObject(KaraokeHitObject hitObject) { } - protected sealed override double InitialLifetimeOffset => HitObject.TimePreempt; + protected sealed override double InitialLifetimeOffset + { + get + { + if (HitObject is IHasEffectApplier hitObjectWithEffectApplier) + { + return hitObjectWithEffectApplier.EffectApplier.PreemptTime; + } + + return base.InitialLifetimeOffset; + } + } protected override JudgementResult CreateResult(Judgement judgement) => new KaraokeJudgementResult(HitObject, judgement); + + protected override void UpdateInitialTransforms() + { + if (HitObject is IHasEffectApplier hitObjectWithEffectApplier) + { + hitObjectWithEffectApplier.EffectApplier.UpdateInitialTransforms(this); + } + } + + protected override void UpdateStartTimeStateTransforms() + { + if (HitObject is IHasEffectApplier hitObjectWithEffectApplier) + { + hitObjectWithEffectApplier.EffectApplier.UpdateStartTimeStateTransforms(this); + } + } + + protected override void UpdateHitStateTransforms(ArmedState state) + { + if (HitObject is IHasEffectApplier hitObjectWithEffectApplier) + { + hitObjectWithEffectApplier.EffectApplier.UpdateHitStateTransforms(this, state); + } + } } } From 94436ae7bc97e40017e010d63c3ebbc52e019e50 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 15 Apr 2023 10:51:44 +0800 Subject: [PATCH 02/11] Let's remove the old layout arrangement effect. --- .../Objects/Drawables/DrawableLyric.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs index 1b4b86524..9efa591da 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs @@ -150,7 +150,6 @@ protected override void ApplySkin(ISkinSource skin, bool allowFallback) updateFontStyle(); updateLyricFontInfo(); - updateLayout(); } private void updateFontStyle() @@ -177,18 +176,6 @@ private void updateLyricFontInfo() lyricFontInfo?.ApplyTo(this); } - private void updateLayout() - { - if (CurrentSkin == null) - return; - - if (HitObject == null) - return; - - var layout = CurrentSkin.GetConfig(HitObject)?.Value; - layout?.ApplyTo(this); - } - private void applyTranslate() { var language = preferLanguageBindable.Value; From 132d792f38ab6f8b31e8f8079932d02be5af3db9 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 15 Apr 2023 11:22:33 +0800 Subject: [PATCH 03/11] Remove the old pattern generator because it will change the lyric's start and end time. --- .../Beatmaps/KaraokeBeatmapProcessor.cs | 15 ------- .../Beatmaps/Patterns/IPatternGenerator.cs | 13 ------ .../Patterns/LegacyLyricTimeGenerator.cs | 45 ------------------- 3 files changed, 73 deletions(-) delete mode 100644 osu.Game.Rulesets.Karaoke/Beatmaps/Patterns/IPatternGenerator.cs delete mode 100644 osu.Game.Rulesets.Karaoke/Beatmaps/Patterns/LegacyLyricTimeGenerator.cs diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs index e082ad297..386a19ecc 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs @@ -4,11 +4,9 @@ using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Game.Beatmaps; -using osu.Game.Rulesets.Karaoke.Beatmaps.Patterns; using osu.Game.Rulesets.Karaoke.Beatmaps.Stages; using osu.Game.Rulesets.Karaoke.Beatmaps.Stages.Preview; using osu.Game.Rulesets.Karaoke.Beatmaps.Stages.Types; -using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Objects.Types; using osu.Game.Rulesets.Karaoke.Objects.Workings; @@ -62,18 +60,5 @@ private void applyInvalidProperty(KaraokeBeatmap beatmap) hitObject.ValidateWorkingProperty(beatmap); } } - - public override void PostProcess() - { - base.PostProcess(); - - var lyrics = Beatmap.HitObjects.OfType().ToList(); - - if (!lyrics.Any()) - return; - - var pattern = new LegacyLyricTimeGenerator(); - pattern.Generate(lyrics); - } } } diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/Patterns/IPatternGenerator.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/Patterns/IPatternGenerator.cs deleted file mode 100644 index c54ca47c7..000000000 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/Patterns/IPatternGenerator.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using System.Collections.Generic; -using osu.Game.Rulesets.Karaoke.Objects; - -namespace osu.Game.Rulesets.Karaoke.Beatmaps.Patterns -{ - public interface IPatternGenerator where TObject : KaraokeHitObject - { - void Generate(IEnumerable hitObjects); - } -} diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/Patterns/LegacyLyricTimeGenerator.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/Patterns/LegacyLyricTimeGenerator.cs deleted file mode 100644 index 7d5021af2..000000000 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/Patterns/LegacyLyricTimeGenerator.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using System.Collections.Generic; -using System.Linq; -using osu.Game.Rulesets.Karaoke.Objects; - -namespace osu.Game.Rulesets.Karaoke.Beatmaps.Patterns -{ - /// - /// Note: this class will be replaced by another lyric-time generator. - /// - public class LegacyLyricTimeGenerator : IPatternGenerator - { - private const int number_of_line = 2; - - public void Generate(IEnumerable hitObjects) - { - var lyrics = hitObjects.ToList(); - - // Re-assign time - assignLyricTime(lyrics); - } - - private void assignLyricTime(IList lyrics) - { - // Apply start time - for (int i = 0; i < lyrics.Count; i++) - { - var lastLyric = i >= number_of_line ? lyrics[i - number_of_line] : null; - var lyric = lyrics[i]; - - if (lastLyric == null) - continue; - - double lyricEndTime = lyric.LyricEndTime; - double lyricStartTime = lastLyric.EndTime + 1000; - - // Adjust start time and end time - lyric.StartTime = lyricStartTime; - lyric.Duration = lyricEndTime - lyricStartTime; - } - } - } -} From 961ee30d3025cdea1c54730a236e109973d34703 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 15 Apr 2023 11:23:53 +0800 Subject: [PATCH 04/11] Should not change the scale in here. --- osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs index 9efa591da..d284b6667 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs @@ -20,7 +20,6 @@ using osu.Game.Rulesets.Karaoke.Skinning.Elements; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Skinning; -using osuTK; namespace osu.Game.Rulesets.Karaoke.Objects.Drawables { @@ -67,7 +66,6 @@ public DrawableLyric([CanBeNull] Lyric hitObject) [BackgroundDependencyLoader(true)] private void load([CanBeNull] KaraokeSessionStatics session) { - Scale = new Vector2(2); AutoSizeAxes = Axes.Both; AddInternal(lyricPieces = new Container From 4c6a9a99d4218ae540be9d283c2d9df6c145e952 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 15 Apr 2023 18:10:34 +0800 Subject: [PATCH 05/11] Should not affect the fade-out effect in the drawable lyric. --- .../Objects/Drawables/DrawableLyric.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs index d284b6667..8f1816d35 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs @@ -18,7 +18,6 @@ using osu.Game.Rulesets.Karaoke.Scoring; using osu.Game.Rulesets.Karaoke.Skinning.Default; using osu.Game.Rulesets.Karaoke.Skinning.Elements; -using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Skinning; namespace osu.Game.Rulesets.Karaoke.Objects.Drawables @@ -216,14 +215,6 @@ protected override void UpdateInitialTransforms() lyricPieces.ForEach(x => x.RefreshStateTransforms()); } - protected override void UpdateHitStateTransforms(ArmedState state) - { - base.UpdateHitStateTransforms(state); - - const float fade_out_time = 500; - this.FadeOut(fade_out_time); - } - public void ApplyToLyricPieces(Action action) { foreach (var lyricPiece in lyricPieces) From 169fd9b25051ccec31571800745c4ab8c9906c30 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 15 Apr 2023 21:06:40 +0800 Subject: [PATCH 06/11] Should use the correct time. --- osu.Game.Rulesets.Karaoke/UI/LyricPlayfield.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/UI/LyricPlayfield.cs b/osu.Game.Rulesets.Karaoke/UI/LyricPlayfield.cs index bf852fa3e..23d77a020 100644 --- a/osu.Game.Rulesets.Karaoke/UI/LyricPlayfield.cs +++ b/osu.Game.Rulesets.Karaoke/UI/LyricPlayfield.cs @@ -71,12 +71,12 @@ public LyricHitObjectLifetimeEntry(HitObject hitObject) { // Manually set to reduce the number of future alive objects to a bare minimum. LifetimeEnd = Lyric.EndTime; - LifetimeStart = HitObject.StartTime - Lyric.TimePreempt; + LifetimeStart = HitObject.StartTime - Lyric.EffectApplier.PreemptTime; } protected Lyric Lyric => (Lyric)HitObject; - protected override double InitialLifetimeOffset => Lyric.TimePreempt; + protected override double InitialLifetimeOffset => Lyric.EffectApplier.PreemptTime; } } } From 166c574f98ddb5011af09aad28f564724cd9f872 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 21 Apr 2023 20:36:29 +0800 Subject: [PATCH 07/11] Should not override the property in the editor. --- osu.Game.Rulesets.Karaoke/Edit/KaraokeEditorPlayfield.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/KaraokeEditorPlayfield.cs b/osu.Game.Rulesets.Karaoke/Edit/KaraokeEditorPlayfield.cs index 8b3851465..84e8479f6 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/KaraokeEditorPlayfield.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/KaraokeEditorPlayfield.cs @@ -3,22 +3,13 @@ #nullable disable -using osu.Framework.Graphics; using osu.Game.Rulesets.Karaoke.UI; using osu.Game.Rulesets.Karaoke.UI.Scrolling; -using osuTK; namespace osu.Game.Rulesets.Karaoke.Edit { public partial class KaraokeEditorPlayfield : KaraokePlayfield { - public KaraokeEditorPlayfield() - { - LyricPlayfield.Anchor = LyricPlayfield.Origin = Anchor.BottomCentre; - LyricPlayfield.Margin = new MarginPadding { Top = 150, Bottom = -100 }; - LyricPlayfield.Scale = new Vector2(0.7f); - } - protected override ScrollingNotePlayfield CreateNotePlayfield(int columns) => new EditorNotePlayfield(columns); } From 35d33eb02b7d588736421801ba7a7f3a0c82e3b2 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 21 Apr 2023 20:36:47 +0800 Subject: [PATCH 08/11] Should not assign the padding in here. --- osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs index 8f1816d35..1db5f0d67 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs @@ -58,8 +58,6 @@ public DrawableLyric() public DrawableLyric([CanBeNull] Lyric hitObject) : base(hitObject) { - // todo: it's a reservable size, should be removed eventually. - Padding = new MarginPadding(30); } [BackgroundDependencyLoader(true)] From cba351d92377a47dc971130a3b9316f5517a3b0b Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 21 Apr 2023 20:37:19 +0800 Subject: [PATCH 09/11] Apply the stage into the playfield. Not the bast solution but should be OK for now. --- .../UI/DrawableKaraokeRuleset.cs | 6 ++++++ .../UI/DrawableKaraokeRuleset_Stage.cs | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 osu.Game.Rulesets.Karaoke/UI/DrawableKaraokeRuleset_Stage.cs diff --git a/osu.Game.Rulesets.Karaoke/UI/DrawableKaraokeRuleset.cs b/osu.Game.Rulesets.Karaoke/UI/DrawableKaraokeRuleset.cs index 03784ddb7..e648521a7 100644 --- a/osu.Game.Rulesets.Karaoke/UI/DrawableKaraokeRuleset.cs +++ b/osu.Game.Rulesets.Karaoke/UI/DrawableKaraokeRuleset.cs @@ -45,6 +45,8 @@ public partial class DrawableKaraokeRuleset : DrawableScrollingRuleset base.Beatmap as KaraokeBeatmap; + protected virtual bool DisplayNotePlayfield => Beatmap.IsScorable(); public DrawableKaraokeRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList mods) @@ -70,6 +72,10 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl [BackgroundDependencyLoader] private void load() { + // todo: use better way to assign the stage info. + // also, should monitor the stage info change. + updatePlayfieldArrangement(Beatmap.CurrentStageInfo); + // TODO : it should be moved into NotePlayfield new BarLineGenerator(Beatmap).BarLines.ForEach(bar => base.Playfield.Add(bar)); diff --git a/osu.Game.Rulesets.Karaoke/UI/DrawableKaraokeRuleset_Stage.cs b/osu.Game.Rulesets.Karaoke/UI/DrawableKaraokeRuleset_Stage.cs new file mode 100644 index 000000000..74c4c0b07 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/UI/DrawableKaraokeRuleset_Stage.cs @@ -0,0 +1,19 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Bindables; +using osu.Game.Rulesets.Karaoke.Beatmaps.Stages; + +namespace osu.Game.Rulesets.Karaoke.UI; + +public partial class DrawableKaraokeRuleset +{ + private readonly IBindable currentStageInfo = new Bindable(); + private readonly IBindable scorable = new Bindable(); + + private void updatePlayfieldArrangement(StageInfo stageInfo) + { + var applier = stageInfo.GetPlayfieldStageApplier(); + applier.UpdatePlayfieldArrangement(Playfield, DisplayNotePlayfield); + } +} From df5c75def46321986efd553012ef148a6461d0b7 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 21 Apr 2023 20:37:31 +0800 Subject: [PATCH 10/11] Remove container wrapper in the note playfield. --- osu.Game.Rulesets.Karaoke/UI/KaraokePlayfield.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/UI/KaraokePlayfield.cs b/osu.Game.Rulesets.Karaoke/UI/KaraokePlayfield.cs index 0753ded24..558a463c7 100644 --- a/osu.Game.Rulesets.Karaoke/UI/KaraokePlayfield.cs +++ b/osu.Game.Rulesets.Karaoke/UI/KaraokePlayfield.cs @@ -7,7 +7,6 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Game.Rulesets.Karaoke.Beatmaps; using osu.Game.Rulesets.Karaoke.Configuration; @@ -49,16 +48,10 @@ public KaraokePlayfield() x.RelativeSizeAxes = Axes.Both; })); - AddInternal(new Container + AddInternal(NotePlayfield = CreateNotePlayfield(9).With(x => { - Padding = new MarginPadding(50), - RelativeSizeAxes = Axes.Both, - Child = NotePlayfield = CreateNotePlayfield(9).With(x => - { - x.Alpha = 0; - x.RelativeSizeAxes = Axes.X; - }) - }); + x.RelativeSizeAxes = Axes.X; + })); AddNested(LyricPlayfield); AddNested(NotePlayfield); From e8bd79e319dbd8dcd5a51bfd72bbec6491bc38b8 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 22 Apr 2023 00:35:19 +0800 Subject: [PATCH 11/11] Fix the test case broken. --- .../Skinning/TestSceneLyric.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneLyric.cs b/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneLyric.cs index ade6b948d..9b92b851c 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneLyric.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneLyric.cs @@ -10,9 +10,11 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Rulesets.Karaoke.Beatmaps.Stages.Preview; using osu.Game.Rulesets.Karaoke.Configuration; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Objects.Drawables; +using osu.Game.Rulesets.Karaoke.Objects.Stages.Preview; using osu.Game.Rulesets.Mods; namespace osu.Game.Rulesets.Karaoke.Tests.Skinning; @@ -83,6 +85,18 @@ private Drawable testSingle(double timeOffset = 0) Text = "ke" } }, + EffectApplier = new LyricPreviewStageEffectApplier(new[] + { + new PreviewLyricLayout(1) + { + StartTime = startTime, + EndTime = startTime + duration, + Timings = new Dictionary + { + { 0, startTime } + } + } + }, new PreviewStageDefinition()) }; lyric.Translates.Add(cultureInfo, "karaoke");