diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Beatmaps/BeatmapStageElementCategoryChangeHandlerTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Beatmaps/BeatmapStageElementCategoryChangeHandlerTest.cs index 23ceeec58..1336f4761 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Beatmaps/BeatmapStageElementCategoryChangeHandlerTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Beatmaps/BeatmapStageElementCategoryChangeHandlerTest.cs @@ -277,16 +277,6 @@ protected override IStageEffectApplier ConvertToNoteStageAppliers(IEnumerable GetStartAndEndTime(Lyric lyric) { throw new NotImplementedException(); diff --git a/osu.Game.Rulesets.Karaoke.Tests/Objects/Workings/LyricWorkingPropertyValidatorTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Objects/Workings/LyricWorkingPropertyValidatorTest.cs index 6dbbc700e..2cd98ce78 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Objects/Workings/LyricWorkingPropertyValidatorTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Objects/Workings/LyricWorkingPropertyValidatorTest.cs @@ -15,16 +15,6 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Objects.Workings; public class LyricWorkingPropertyValidatorTest : HitObjectWorkingPropertyValidatorTest { - [Test] - public void TestPreemptTime() - { - var lyric = new Lyric(); - - // state is valid because assign the property. - Assert.DoesNotThrow(() => lyric.PreemptTime = 300); - AssetIsValid(lyric, LyricWorkingProperty.PreemptTime, true); - } - [Test] public void TestStartTime() { diff --git a/osu.Game.Rulesets.Karaoke.Tests/Objects/Workings/NoteWorkingPropertyValidatorTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Objects/Workings/NoteWorkingPropertyValidatorTest.cs index 6f4f5980d..311d1a594 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Objects/Workings/NoteWorkingPropertyValidatorTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Objects/Workings/NoteWorkingPropertyValidatorTest.cs @@ -13,16 +13,6 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Objects.Workings; public class NoteWorkingPropertyValidatorTest : HitObjectWorkingPropertyValidatorTest { - [Test] - public void TestPreemptTime() - { - var note = new Note(); - - // page state is valid because assign the property. - Assert.DoesNotThrow(() => note.PreemptTime = 300); - AssetIsValid(note, NoteWorkingProperty.PreemptTime, true); - } - [Test] public void TestPage() { diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/Stages/Classic/ClassicStageInfo.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/Stages/Classic/ClassicStageInfo.cs index 6403c5479..1bf1624f5 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/Stages/Classic/ClassicStageInfo.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/Stages/Classic/ClassicStageInfo.cs @@ -67,18 +67,6 @@ protected override IStageEffectApplier ConvertToNoteStageAppliers(IEnumerable GetStartAndEndTime(Lyric lyric) { return LyricTimingInfo.GetStartAndEndTime(lyric); diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/Stages/Preview/PreviewStageInfo.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/Stages/Preview/PreviewStageInfo.cs index a65446309..0cacbac06 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/Stages/Preview/PreviewStageInfo.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/Stages/Preview/PreviewStageInfo.cs @@ -123,17 +123,6 @@ protected override IStageEffectApplier ConvertToNoteStageAppliers(IEnumerable GetStartAndEndTime(Lyric lyric) { var element = layoutCategory.GetElementByItem(lyric); diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/Stages/StageInfo.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/Stages/StageInfo.cs index ab3849552..562658e5b 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/Stages/StageInfo.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/Stages/StageInfo.cs @@ -34,14 +34,6 @@ private IEnumerable getStageElements(KaraokeHitObject hitObject) = _ => Array.Empty() }; - public double GetPreemptTime(KaraokeHitObject hitObject) => - hitObject switch - { - Lyric lyric => GetPreemptTime(lyric), - Note note => GetPreemptTime(note), - _ => throw new InvalidOperationException() - }; - public Tuple GetStartAndEndTime(KaraokeHitObject hitObject) => hitObject switch { @@ -61,10 +53,6 @@ public double GetPreemptTime(KaraokeHitObject hitObject) => protected abstract IStageEffectApplier ConvertToNoteStageAppliers(IEnumerable elements); - protected abstract double GetPreemptTime(Lyric lyric); - - protected abstract double GetPreemptTime(Note note); - protected abstract Tuple GetStartAndEndTime(Lyric lyric); #endregion diff --git a/osu.Game.Rulesets.Karaoke/Objects/Lyric_Working.cs b/osu.Game.Rulesets.Karaoke/Objects/Lyric_Working.cs index ff90e0c00..ebd0f7ff4 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Lyric_Working.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Lyric_Working.cs @@ -41,10 +41,6 @@ public void ValidateWorkingProperty(KaraokeBeatmap beatmap) { switch (flag) { - case LyricWorkingProperty.PreemptTime: - PreemptTime = getPreemptTime(beatmap, this); - break; - case LyricWorkingProperty.StartTime: StartTime = getStartTime(beatmap, this); break; @@ -78,16 +74,6 @@ public void ValidateWorkingProperty(KaraokeBeatmap beatmap) } } - static double getPreemptTime(KaraokeBeatmap beatmap, KaraokeHitObject lyric) - { - var stageInfo = beatmap.CurrentStageInfo; - if (stageInfo == null) - throw new InvalidCastException(); - - double preemptTime = stageInfo.GetPreemptTime(lyric); - return preemptTime; - } - static double getStartTime(KaraokeBeatmap beatmap, KaraokeHitObject lyric) { var stageInfo = beatmap.CurrentStageInfo; @@ -136,22 +122,6 @@ static IStageEffectApplier getStageEffectApplier(KaraokeBeatmap beatmap, Karaoke [JsonIgnore] public double LyricDuration => LyricEndTime - LyricStartTime; - private double preemptTime; - - /// - /// Lyric's preempt time is created from and should not be saved. - /// - [JsonIgnore] - public double PreemptTime - { - get => preemptTime; - set - { - preemptTime = value; - updateStateByWorkingProperty(LyricWorkingProperty.PreemptTime); - } - } - /// /// Lyric's start time is created from and should not be saved. /// diff --git a/osu.Game.Rulesets.Karaoke/Objects/Note_Working.cs b/osu.Game.Rulesets.Karaoke/Objects/Note_Working.cs index cbea28846..8dc77a9f9 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Note_Working.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Note_Working.cs @@ -10,7 +10,6 @@ using osu.Game.Extensions; using osu.Game.Rulesets.Karaoke.Beatmaps; using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; -using osu.Game.Rulesets.Karaoke.Beatmaps.Stages; using osu.Game.Rulesets.Karaoke.Objects.Stages; using osu.Game.Rulesets.Karaoke.Objects.Types; using osu.Game.Rulesets.Karaoke.Objects.Workings; @@ -41,10 +40,6 @@ public void ValidateWorkingProperty(KaraokeBeatmap beatmap) { switch (flag) { - case NoteWorkingProperty.PreemptTime: - PreemptTime = getPreemptTime(beatmap, this); - break; - case NoteWorkingProperty.Page: PageIndex = getPageIndex(beatmap, StartTime); break; @@ -62,16 +57,6 @@ public void ValidateWorkingProperty(KaraokeBeatmap beatmap) } } - static double getPreemptTime(KaraokeBeatmap beatmap, KaraokeHitObject lyric) - { - var stageInfo = beatmap.CurrentStageInfo; - if (stageInfo == null) - throw new InvalidCastException(); - - double preemptTime = stageInfo.GetPreemptTime(lyric); - return preemptTime; - } - static int? getPageIndex(KaraokeBeatmap beatmap, double startTime) => beatmap.PageInfo.GetPageIndexAt(startTime); @@ -105,22 +90,6 @@ public int? PageIndex } } - private double preemptTime; - - /// - /// Note's preempt time is created from and should not be saved. - /// - [JsonIgnore] - public double PreemptTime - { - get => preemptTime; - set - { - preemptTime = value; - updateStateByWorkingProperty(NoteWorkingProperty.PreemptTime); - } - } - /// /// Start time. /// There's no need to save the time because it's calculated by the diff --git a/osu.Game.Rulesets.Karaoke/Objects/Stages/Classic/LyricClassicStageEffectApplier.cs b/osu.Game.Rulesets.Karaoke/Objects/Stages/Classic/LyricClassicStageEffectApplier.cs index 3c00c88d1..9b9a933b9 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Stages/Classic/LyricClassicStageEffectApplier.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Stages/Classic/LyricClassicStageEffectApplier.cs @@ -17,6 +17,12 @@ public LyricClassicStageEffectApplier(IEnumerable elements, Classi { } + protected override double GetPreemptTime(IEnumerable elements) + { + // todo: implementation needed. + return 0; + } + protected override void UpdateInitialTransforms(TransformSequence transformSequence, StageElement element) { throw new System.NotImplementedException(); diff --git a/osu.Game.Rulesets.Karaoke/Objects/Stages/Classic/NoteClassicStageEffectApplier.cs b/osu.Game.Rulesets.Karaoke/Objects/Stages/Classic/NoteClassicStageEffectApplier.cs index 31dc99764..a3dce4099 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Stages/Classic/NoteClassicStageEffectApplier.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Stages/Classic/NoteClassicStageEffectApplier.cs @@ -17,6 +17,12 @@ public NoteClassicStageEffectApplier(IEnumerable elements, Classic { } + protected override double GetPreemptTime(IEnumerable elements) + { + // todo: implementation needed. + return 0; + } + protected override void UpdateInitialTransforms(TransformSequence transformSequence, StageElement element) { throw new System.NotImplementedException(); diff --git a/osu.Game.Rulesets.Karaoke/Objects/Stages/Preview/LyricPreviewStageEffectApplier.cs b/osu.Game.Rulesets.Karaoke/Objects/Stages/Preview/LyricPreviewStageEffectApplier.cs index 56048116c..17cb00e9a 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Stages/Preview/LyricPreviewStageEffectApplier.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Stages/Preview/LyricPreviewStageEffectApplier.cs @@ -20,6 +20,11 @@ public LyricPreviewStageEffectApplier(IEnumerable elements, Previe { } + protected override double GetPreemptTime(IEnumerable elements) + { + return Definition.FadingTime; + } + protected override void UpdateInitialTransforms(TransformSequence transformSequence, StageElement element) { switch (element) diff --git a/osu.Game.Rulesets.Karaoke/Objects/Stages/Preview/NotePreviewStageEffectApplier.cs b/osu.Game.Rulesets.Karaoke/Objects/Stages/Preview/NotePreviewStageEffectApplier.cs index 6d8f94de2..4f3818172 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Stages/Preview/NotePreviewStageEffectApplier.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Stages/Preview/NotePreviewStageEffectApplier.cs @@ -17,6 +17,12 @@ public NotePreviewStageEffectApplier(IEnumerable elements, Preview { } + protected override double GetPreemptTime(IEnumerable elements) + { + // todo: implementation needed. + return 0; + } + protected override void UpdateInitialTransforms(TransformSequence transformSequence, StageElement element) { throw new System.NotImplementedException(); diff --git a/osu.Game.Rulesets.Karaoke/Objects/Stages/StageEffectApplier.cs b/osu.Game.Rulesets.Karaoke/Objects/Stages/StageEffectApplier.cs index 476099423..ed47f0524 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Stages/StageEffectApplier.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Stages/StageEffectApplier.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Transforms; using osu.Game.Rulesets.Karaoke.Beatmaps.Stages; @@ -14,14 +15,17 @@ public abstract class StageEffectApplier : where TStageDefinition : StageDefinition where TDrawableHitObject : DrawableHitObject { - private readonly IEnumerable elements; + private readonly StageElement[] elements; protected readonly TStageDefinition Definition; + public readonly double PreemptTime; protected StageEffectApplier(IEnumerable elements, TStageDefinition definition) { - this.elements = elements; + this.elements = elements.ToArray(); Definition = definition; + + PreemptTime = GetPreemptTime(this.elements); } /// @@ -88,6 +92,8 @@ public void UpdateHitStateTransforms(DrawableHitObject drawableHitObject, ArmedS transform.Then().FadeOut(); } + protected abstract double GetPreemptTime(IEnumerable elements); + protected abstract void UpdateInitialTransforms(TransformSequence transformSequence, StageElement element); protected abstract void UpdateStartTimeStateTransforms(TransformSequence transformSequence, StageElement element); diff --git a/osu.Game.Rulesets.Karaoke/Objects/Types/IHasEffectApplier.cs b/osu.Game.Rulesets.Karaoke/Objects/Types/IHasEffectApplier.cs index e04a657fa..8f03eafb7 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Types/IHasEffectApplier.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Types/IHasEffectApplier.cs @@ -7,7 +7,5 @@ namespace osu.Game.Rulesets.Karaoke.Objects.Types; public interface IHasEffectApplier { - double PreemptTime { get; } - IStageEffectApplier EffectApplier { get; } } diff --git a/osu.Game.Rulesets.Karaoke/Objects/Workings/LyricWorkingProperty.cs b/osu.Game.Rulesets.Karaoke/Objects/Workings/LyricWorkingProperty.cs index 556423221..7f45ff25d 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Workings/LyricWorkingProperty.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Workings/LyricWorkingProperty.cs @@ -11,43 +11,38 @@ namespace osu.Game.Rulesets.Karaoke.Objects.Workings; [Flags] public enum LyricWorkingProperty { - /// - /// is being invalidated. - /// - PreemptTime = 1, - /// /// is being invalidated. /// - StartTime = 1 << 1, + StartTime = 1, /// /// is being invalidated. /// - Duration = 1 << 2, + Duration = 1 << 1, /// /// and is being invalidated. /// - Timing = PreemptTime | StartTime | Duration, + Timing = StartTime | Duration, /// /// is being invalidated. /// - Singers = 1 << 3, + Singers = 1 << 2, /// /// is being invalidated. /// - Page = 1 << 4, + Page = 1 << 3, /// /// is being invalidated. /// - ReferenceLyric = 1 << 5, + ReferenceLyric = 1 << 4, /// /// is being invalidated. /// - EffectApplier = 1 << 6, + EffectApplier = 1 << 5, } diff --git a/osu.Game.Rulesets.Karaoke/Objects/Workings/LyricWorkingPropertyValidator.cs b/osu.Game.Rulesets.Karaoke/Objects/Workings/LyricWorkingPropertyValidator.cs index 25bd7f0b1..9b5965c19 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Workings/LyricWorkingPropertyValidator.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Workings/LyricWorkingPropertyValidator.cs @@ -17,7 +17,6 @@ public LyricWorkingPropertyValidator(Lyric hitObject) protected override bool CanCheckWorkingPropertySync(Lyric hitObject, LyricWorkingProperty flags) => flags switch { - LyricWorkingProperty.PreemptTime => false, LyricWorkingProperty.StartTime => false, LyricWorkingProperty.Duration => false, LyricWorkingProperty.Timing => false, @@ -31,7 +30,6 @@ protected override bool CanCheckWorkingPropertySync(Lyric hitObject, LyricWorkin protected override bool NeedToSyncWorkingProperty(Lyric hitObject, LyricWorkingProperty flags) => flags switch { - LyricWorkingProperty.PreemptTime => false, LyricWorkingProperty.StartTime => false, LyricWorkingProperty.Duration => false, LyricWorkingProperty.Timing => false, diff --git a/osu.Game.Rulesets.Karaoke/Objects/Workings/NoteWorkingProperty.cs b/osu.Game.Rulesets.Karaoke/Objects/Workings/NoteWorkingProperty.cs index 436b54838..bc7daf86b 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Workings/NoteWorkingProperty.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Workings/NoteWorkingProperty.cs @@ -11,23 +11,18 @@ namespace osu.Game.Rulesets.Karaoke.Objects.Workings; [Flags] public enum NoteWorkingProperty { - /// - /// is being invalidated. - /// - PreemptTime = 1, - /// /// is being invalidated. /// - Page = 1 << 1, + Page = 1, /// /// is being invalidated. /// - ReferenceLyric = 1 << 2, + ReferenceLyric = 1 << 1, /// /// is being invalidated. /// - EffectApplier = 1 << 3, + EffectApplier = 1 << 2, } diff --git a/osu.Game.Rulesets.Karaoke/Objects/Workings/NoteWorkingPropertyValidator.cs b/osu.Game.Rulesets.Karaoke/Objects/Workings/NoteWorkingPropertyValidator.cs index 6335be161..5fd048ec6 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Workings/NoteWorkingPropertyValidator.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Workings/NoteWorkingPropertyValidator.cs @@ -15,7 +15,6 @@ public NoteWorkingPropertyValidator(Note hitObject) protected override bool CanCheckWorkingPropertySync(Note hitObject, NoteWorkingProperty flags) => flags switch { - NoteWorkingProperty.PreemptTime => false, NoteWorkingProperty.Page => false, NoteWorkingProperty.ReferenceLyric => true, NoteWorkingProperty.EffectApplier => false, @@ -25,7 +24,6 @@ protected override bool CanCheckWorkingPropertySync(Note hitObject, NoteWorkingP protected override bool NeedToSyncWorkingProperty(Note hitObject, NoteWorkingProperty flags) => flags switch { - NoteWorkingProperty.PreemptTime => false, NoteWorkingProperty.Page => false, NoteWorkingProperty.ReferenceLyric => hitObject.ReferenceLyric?.ID != hitObject.ReferenceLyricId, NoteWorkingProperty.EffectApplier => false,