diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs index 9b33495ee..7e9dc7b40 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs @@ -33,19 +33,19 @@ private void applyInvalidProperty(IBeatmap beatmap) switch (hitObject) { case Lyric lyric: - foreach (var flag in lyric.Validator.GetAllInvalidFlags()) + foreach (var flag in lyric.WorkingPropertyValidator.GetAllInvalidFlags()) { applyInvalidProperty(lyric, flag); - lyric.Validator.Validate(flag); + lyric.WorkingPropertyValidator.Validate(flag); } break; case Note note: - foreach (var flag in note.Validator.GetAllInvalidFlags()) + foreach (var flag in note.WorkingPropertyValidator.GetAllInvalidFlags()) { applyInvalidProperty(note, flag); - note.Validator.Validate(flag); + note.WorkingPropertyValidator.Validate(flag); } break; diff --git a/osu.Game.Rulesets.Karaoke/Objects/Lyric.cs b/osu.Game.Rulesets.Karaoke/Objects/Lyric.cs index 577b1ad21..fc9ddddb7 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Lyric.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Lyric.cs @@ -179,12 +179,7 @@ public int? ReferenceLyricId set { referenceLyricId = value; - - if (referenceLyricId == ReferenceLyric?.ID) - return; - - // should trying to reload the reference lyric. - Validator.Invalidate(LyricWorkingProperty.ReferenceLyric); + WorkingPropertyValidator.Invalidate(LyricWorkingProperty.ReferenceLyric); } } @@ -214,6 +209,7 @@ public Lyric() { initInternalBindingEvent(); initReferenceLyricEvent(); + initWorkingPropertyValidator(); } public override Judgement CreateJudgement() => new KaraokeLyricJudgement(); diff --git a/osu.Game.Rulesets.Karaoke/Objects/Lyric_Working.cs b/osu.Game.Rulesets.Karaoke/Objects/Lyric_Working.cs index a12cbb81d..c84f936ab 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Lyric_Working.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Lyric_Working.cs @@ -14,8 +14,13 @@ namespace osu.Game.Rulesets.Karaoke.Objects; /// public partial class Lyric { + private void initWorkingPropertyValidator() + { + WorkingPropertyValidator = new LyricWorkingPropertyValidator(this); + } + [JsonIgnore] - public HitObjectWorkingPropertyValidator Validator { get; } = new(); + public LyricWorkingPropertyValidator WorkingPropertyValidator { get; private set; } = null!; [JsonIgnore] public double LyricStartTime { get; private set; } @@ -58,7 +63,11 @@ public override double StartTime public int? PageIndex { get => PageIndexBindable.Value; - set => PageIndexBindable.Value = value; + set + { + PageIndexBindable.Value = value; + WorkingPropertyValidator.Validate(LyricWorkingProperty.Page); + } } [JsonIgnore] @@ -75,11 +84,7 @@ public Lyric? ReferenceLyric set { ReferenceLyricBindable.Value = value; - - if (value?.ID != ReferenceLyricId) - { - throw new InvalidWorkingPropertyAssignException(); - } + WorkingPropertyValidator.Validate(LyricWorkingProperty.ReferenceLyric); } } } diff --git a/osu.Game.Rulesets.Karaoke/Objects/Note.cs b/osu.Game.Rulesets.Karaoke/Objects/Note.cs index 9c8790840..226659aec 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Note.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Note.cs @@ -107,12 +107,7 @@ public int? ReferenceLyricId set { referenceLyricId = value; - - if (referenceLyricId == ReferenceLyric?.ID) - return; - - // should trying to reload the reference lyric. - Validator.Invalidate(NoteWorkingProperty.ReferenceLyric); + WorkingPropertyValidator.Invalidate(NoteWorkingProperty.ReferenceLyric); } } @@ -129,6 +124,7 @@ public Note() { initInternalBindingEvent(); initReferenceLyricEvent(); + initWorkingPropertyValidator(); } public override Judgement CreateJudgement() => new KaraokeNoteJudgement(); diff --git a/osu.Game.Rulesets.Karaoke/Objects/Note_Working.cs b/osu.Game.Rulesets.Karaoke/Objects/Note_Working.cs index c13e87980..a534c3d36 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Note_Working.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Note_Working.cs @@ -16,8 +16,13 @@ namespace osu.Game.Rulesets.Karaoke.Objects; /// public partial class Note { + private void initWorkingPropertyValidator() + { + WorkingPropertyValidator = new NoteWorkingPropertyValidator(this); + } + [JsonIgnore] - public HitObjectWorkingPropertyValidator Validator { get; } = new(); + public NoteWorkingPropertyValidator WorkingPropertyValidator { get; private set; } = null!; [JsonIgnore] public readonly Bindable PageIndexBindable = new(); @@ -29,7 +34,11 @@ public partial class Note public int? PageIndex { get => PageIndexBindable.Value; - set => PageIndexBindable.Value = value; + set + { + PageIndexBindable.Value = value; + WorkingPropertyValidator.Validate(NoteWorkingProperty.Page); + } } /// @@ -78,11 +87,7 @@ public Lyric? ReferenceLyric set { ReferenceLyricBindable.Value = value; - - if (value?.ID != ReferenceLyricId) - { - throw new InvalidWorkingPropertyAssignException(); - } + WorkingPropertyValidator.Validate(NoteWorkingProperty.ReferenceLyric); } }