Skip to content

Commit

Permalink
Use new working property invalidator.
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed Mar 26, 2023
1 parent c79e612 commit bd55c98
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 30 deletions.
8 changes: 4 additions & 4 deletions osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions osu.Game.Rulesets.Karaoke/Objects/Lyric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -214,6 +209,7 @@ public Lyric()
{
initInternalBindingEvent();
initReferenceLyricEvent();
initWorkingPropertyValidator();
}

public override Judgement CreateJudgement() => new KaraokeLyricJudgement();
Expand Down
19 changes: 12 additions & 7 deletions osu.Game.Rulesets.Karaoke/Objects/Lyric_Working.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ namespace osu.Game.Rulesets.Karaoke.Objects;
/// </summary>
public partial class Lyric
{
private void initWorkingPropertyValidator()
{
WorkingPropertyValidator = new LyricWorkingPropertyValidator(this);
}

[JsonIgnore]
public HitObjectWorkingPropertyValidator<LyricWorkingProperty> Validator { get; } = new();
public LyricWorkingPropertyValidator WorkingPropertyValidator { get; private set; } = null!;

[JsonIgnore]
public double LyricStartTime { get; private set; }
Expand Down Expand Up @@ -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]
Expand All @@ -75,11 +84,7 @@ public Lyric? ReferenceLyric
set
{
ReferenceLyricBindable.Value = value;

if (value?.ID != ReferenceLyricId)
{
throw new InvalidWorkingPropertyAssignException();
}
WorkingPropertyValidator.Validate(LyricWorkingProperty.ReferenceLyric);
}
}
}
8 changes: 2 additions & 6 deletions osu.Game.Rulesets.Karaoke/Objects/Note.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -129,6 +124,7 @@ public Note()
{
initInternalBindingEvent();
initReferenceLyricEvent();
initWorkingPropertyValidator();
}

public override Judgement CreateJudgement() => new KaraokeNoteJudgement();
Expand Down
19 changes: 12 additions & 7 deletions osu.Game.Rulesets.Karaoke/Objects/Note_Working.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ namespace osu.Game.Rulesets.Karaoke.Objects;
/// </summary>
public partial class Note
{
private void initWorkingPropertyValidator()
{
WorkingPropertyValidator = new NoteWorkingPropertyValidator(this);
}

[JsonIgnore]
public HitObjectWorkingPropertyValidator<NoteWorkingProperty> Validator { get; } = new();
public NoteWorkingPropertyValidator WorkingPropertyValidator { get; private set; } = null!;

[JsonIgnore]
public readonly Bindable<int?> PageIndexBindable = new();
Expand All @@ -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);
}
}

/// <summary>
Expand Down Expand Up @@ -78,11 +87,7 @@ public Lyric? ReferenceLyric
set
{
ReferenceLyricBindable.Value = value;

if (value?.ID != ReferenceLyricId)
{
throw new InvalidWorkingPropertyAssignException();
}
WorkingPropertyValidator.Validate(NoteWorkingProperty.ReferenceLyric);
}
}

Expand Down

0 comments on commit bd55c98

Please sign in to comment.