Skip to content

Commit

Permalink
Revert "Add the preempt time for the lyric and the note."
Browse files Browse the repository at this point in the history
This reverts commit d761810.
  • Loading branch information
andy840119 committed Apr 16, 2023
1 parent b32a05b commit ce5739c
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Objects.Workings;

public class LyricWorkingPropertyValidatorTest : HitObjectWorkingPropertyValidatorTest<Lyric, LyricWorkingProperty>
{
[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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Objects.Workings;

public class NoteWorkingPropertyValidatorTest : HitObjectWorkingPropertyValidatorTest<Note, NoteWorkingProperty>
{
[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()
{
Expand Down
30 changes: 0 additions & 30 deletions osu.Game.Rulesets.Karaoke/Objects/Lyric_Working.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -136,22 +122,6 @@ static IStageEffectApplier getStageEffectApplier(KaraokeBeatmap beatmap, Karaoke
[JsonIgnore]
public double LyricDuration => LyricEndTime - LyricStartTime;

private double preemptTime;

/// <summary>
/// Lyric's preempt time is created from <see cref="StageInfo"/> and should not be saved.
/// </summary>
[JsonIgnore]
public double PreemptTime
{
get => preemptTime;
set
{
preemptTime = value;
updateStateByWorkingProperty(LyricWorkingProperty.PreemptTime);
}
}

/// <summary>
/// Lyric's start time is created from <see cref="StageInfo"/> and should not be saved.
/// </summary>
Expand Down
31 changes: 0 additions & 31 deletions osu.Game.Rulesets.Karaoke/Objects/Note_Working.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);

Expand Down Expand Up @@ -105,22 +90,6 @@ public int? PageIndex
}
}

private double preemptTime;

/// <summary>
/// Note's preempt time is created from <see cref="StageInfo"/> and should not be saved.
/// </summary>
[JsonIgnore]
public double PreemptTime
{
get => preemptTime;
set
{
preemptTime = value;
updateStateByWorkingProperty(NoteWorkingProperty.PreemptTime);
}
}

/// <summary>
/// Start time.
/// There's no need to save the time because it's calculated by the <see cref="TimeTag"/>
Expand Down
2 changes: 0 additions & 2 deletions osu.Game.Rulesets.Karaoke/Objects/Types/IHasEffectApplier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ namespace osu.Game.Rulesets.Karaoke.Objects.Types;

public interface IHasEffectApplier
{
double PreemptTime { get; }

IStageEffectApplier EffectApplier { get; }
}
19 changes: 7 additions & 12 deletions osu.Game.Rulesets.Karaoke/Objects/Workings/LyricWorkingProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,38 @@ namespace osu.Game.Rulesets.Karaoke.Objects.Workings;
[Flags]
public enum LyricWorkingProperty
{
/// <summary>
/// <see cref="Lyric.PreemptTime"/> is being invalidated.
/// </summary>
PreemptTime = 1,

/// <summary>
/// <see cref="Lyric.StartTime"/> is being invalidated.
/// </summary>
StartTime = 1 << 1,
StartTime = 1,

/// <summary>
/// <see cref="Lyric.Duration"/> is being invalidated.
/// </summary>
Duration = 1 << 2,
Duration = 1 << 1,

/// <summary>
/// <see cref="Lyric.StartTime"/> and <see cref="Lyric.Duration"/> is being invalidated.
/// </summary>
Timing = PreemptTime | StartTime | Duration,
Timing = StartTime | Duration,

/// <summary>
/// <see cref="Lyric.Singers"/> is being invalidated.
/// </summary>
Singers = 1 << 3,
Singers = 1 << 2,

/// <summary>
/// <see cref="Lyric.PageIndex"/> is being invalidated.
/// </summary>
Page = 1 << 4,
Page = 1 << 3,

/// <summary>
/// <see cref="Lyric.ReferenceLyric"/> is being invalidated.
/// </summary>
ReferenceLyric = 1 << 5,
ReferenceLyric = 1 << 4,

/// <summary>
/// <see cref="Lyric.EffectApplier"/> is being invalidated.
/// </summary>
EffectApplier = 1 << 6,
EffectApplier = 1 << 5,
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,18 @@ namespace osu.Game.Rulesets.Karaoke.Objects.Workings;
[Flags]
public enum NoteWorkingProperty
{
/// <summary>
/// <see cref="Note.PreemptTime"/> is being invalidated.
/// </summary>
PreemptTime = 1,

/// <summary>
/// <see cref="Note.PageIndex"/> is being invalidated.
/// </summary>
Page = 1 << 1,
Page = 1,

/// <summary>
/// <see cref="Note.ReferenceLyric"/> is being invalidated.
/// </summary>
ReferenceLyric = 1 << 2,
ReferenceLyric = 1 << 1,

/// <summary>
/// <see cref="Note.EffectApplier"/> is being invalidated.
/// </summary>
EffectApplier = 1 << 3,
EffectApplier = 1 << 2,
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit ce5739c

Please sign in to comment.