Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate the working property. #2091

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Should add the fill property in the interface.
andy840119 committed Aug 7, 2023
commit bda9855521c65b880ea30c9cc7c69274a4e4bcb7
Original file line number Diff line number Diff line change
@@ -9,9 +9,9 @@

namespace osu.Game.Rulesets.Karaoke.Tests.Objects.Workings;

public abstract class HitObjectWorkingPropertyValidatorTest<THitObject, TFlag>
public abstract class HitObjectWorkingPropertyValidatorTest<THitObject, TFlag, TFillProperty>
where TFlag : struct, Enum
where THitObject : KaraokeHitObject, IHasWorkingProperty<TFlag>, new()
where THitObject : KaraokeHitObject, IHasWorkingProperty<TFlag, TFillProperty>, new()
{
[Test]
public void CheckInitialState([Values] TFlag flag)
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@

namespace osu.Game.Rulesets.Karaoke.Tests.Objects.Workings;

public class LyricWorkingPropertyValidatorTest : HitObjectWorkingPropertyValidatorTest<Lyric, LyricWorkingProperty>
public class LyricWorkingPropertyValidatorTest : HitObjectWorkingPropertyValidatorTest<Lyric, LyricWorkingProperty, KaraokeBeatmap>
{
[Test]
public void TestStartTime()
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@

using System;
using NUnit.Framework;
using osu.Game.Rulesets.Karaoke.Beatmaps;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Rulesets.Karaoke.Objects.Stages.Classic;
using osu.Game.Rulesets.Karaoke.Objects.Workings;
@@ -13,7 +14,7 @@

namespace osu.Game.Rulesets.Karaoke.Tests.Objects.Workings;

public class NoteWorkingPropertyValidatorTest : HitObjectWorkingPropertyValidatorTest<Note, NoteWorkingProperty>
public class NoteWorkingPropertyValidatorTest : HitObjectWorkingPropertyValidatorTest<Note, NoteWorkingProperty, KaraokeBeatmap>
{
[Test]
public void TestPage()
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ private void applyInvalidProperty(KaraokeBeatmap beatmap)
{
// should convert to array here because validate the working property might change the start-time and the end time.
// which will cause got the wrong item in the array.
foreach (var hitObject in beatmap.HitObjects.OfType<IHasWorkingProperty>().ToArray())
foreach (var hitObject in beatmap.HitObjects.OfType<IHasWorkingProperty<KaraokeBeatmap>>().ToArray())
{
hitObject.ValidateWorkingProperty(beatmap);
}
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ protected void PerformOnSelection<T>(Action<T> action) where T : HitObject
protected void InvalidateAllHitObjectWorkingProperty<TWorkingProperty>(TWorkingProperty property)
where TWorkingProperty : struct, Enum
{
foreach (var hitObject in KaraokeBeatmap.HitObjects.OfType<IHasWorkingProperty<TWorkingProperty>>())
foreach (var hitObject in KaraokeBeatmap.HitObjects.OfType<IHasWorkingProperty<TWorkingProperty, KaraokeBeatmap>>())
{
hitObject.InvalidateWorkingProperty(property);
}
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/Objects/Lyric_Working.cs
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Karaoke.Objects;
/// Placing the properties that set by <see cref="KaraokeBeatmapProcessor"/> or being calculated.
/// Those properties will not be saved into the beatmap.
/// </summary>
public partial class Lyric : IHasWorkingProperty<LyricWorkingProperty>, IHasEffectApplier
public partial class Lyric : IHasWorkingProperty<LyricWorkingProperty, KaraokeBeatmap>, IHasEffectApplier
{
[JsonIgnore]
private readonly LyricWorkingPropertyValidator workingPropertyValidator;
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/Objects/Note_Working.cs
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Karaoke.Objects;
/// Placing the properties that set by <see cref="KaraokeBeatmapProcessor"/> or being calculated.
/// Those properties will not be saved into the beatmap.
/// </summary>
public partial class Note : IHasWorkingProperty<NoteWorkingProperty>, IHasEffectApplier
public partial class Note : IHasWorkingProperty<NoteWorkingProperty, KaraokeBeatmap>, IHasEffectApplier
{
[JsonIgnore]
private readonly NoteWorkingPropertyValidator workingPropertyValidator;
Original file line number Diff line number Diff line change
@@ -2,19 +2,18 @@
// See the LICENCE file in the repository root for full licence text.

using System;
using osu.Game.Rulesets.Karaoke.Beatmaps;

namespace osu.Game.Rulesets.Karaoke.Objects.Types;

public interface IHasWorkingProperty<TWorkingProperty> : IHasWorkingProperty
public interface IHasWorkingProperty<TWorkingProperty, TFillProperty> : IHasWorkingProperty<TFillProperty>
where TWorkingProperty : struct, Enum
{
bool InvalidateWorkingProperty(TWorkingProperty workingProperty);

TWorkingProperty[] GetAllInvalidWorkingProperties();
}

public interface IHasWorkingProperty
public interface IHasWorkingProperty<in TFillProperty>
{
void ValidateWorkingProperty(KaraokeBeatmap beatmap);
void ValidateWorkingProperty(TFillProperty fillProperty);
}