1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 08:27:49 +08:00

Implement singular change events for ControlPoint

This commit is contained in:
Bartłomiej Dach 2024-06-11 09:14:46 +02:00
parent cd3b455341
commit b8e0704554
No known key found for this signature in database
5 changed files with 45 additions and 1 deletions

View File

@ -11,8 +11,28 @@ namespace osu.Game.Beatmaps.ControlPoints
{
public abstract class ControlPoint : IComparable<ControlPoint>, IDeepCloneable<ControlPoint>, IEquatable<ControlPoint>, IControlPoint
{
/// <summary>
/// Invoked when any of this <see cref="ControlPoint"/>'s properties have changed.
/// </summary>
public event Action<ControlPoint>? Changed;
protected void RaiseChanged() => Changed?.Invoke(this);
private double time;
[JsonIgnore]
public double Time { get; set; }
public double Time
{
get => time;
set
{
if (time == value)
return;
time = value;
RaiseChanged();
}
}
public void AttachGroup(ControlPointGroup pointGroup) => Time = pointGroup.Time;

View File

@ -44,6 +44,11 @@ namespace osu.Game.Beatmaps.ControlPoints
set => SliderVelocityBindable.Value = value;
}
public DifficultyControlPoint()
{
SliderVelocityBindable.BindValueChanged(_ => RaiseChanged());
}
public override bool IsRedundant(ControlPoint? existing)
=> existing is DifficultyControlPoint existingDifficulty
&& GenerateTicks == existingDifficulty.GenerateTicks

View File

@ -50,6 +50,12 @@ namespace osu.Game.Beatmaps.ControlPoints
set => KiaiModeBindable.Value = value;
}
public EffectControlPoint()
{
KiaiModeBindable.BindValueChanged(_ => RaiseChanged());
ScrollSpeedBindable.BindValueChanged(_ => RaiseChanged());
}
public override bool IsRedundant(ControlPoint? existing)
=> existing is EffectControlPoint existingEffect
&& KiaiMode == existingEffect.KiaiMode

View File

@ -56,6 +56,12 @@ namespace osu.Game.Beatmaps.ControlPoints
set => SampleVolumeBindable.Value = value;
}
public SampleControlPoint()
{
SampleBankBindable.BindValueChanged(_ => RaiseChanged());
SampleVolumeBindable.BindValueChanged(_ => RaiseChanged());
}
/// <summary>
/// Create a SampleInfo based on the sample settings in this control point.
/// </summary>

View File

@ -82,6 +82,13 @@ namespace osu.Game.Beatmaps.ControlPoints
/// </summary>
public double BPM => 60000 / BeatLength;
public TimingControlPoint()
{
TimeSignatureBindable.BindValueChanged(_ => RaiseChanged());
OmitFirstBarLineBindable.BindValueChanged(_ => RaiseChanged());
BeatLengthBindable.BindValueChanged(_ => RaiseChanged());
}
// Timing points are never redundant as they can change the time signature.
public override bool IsRedundant(ControlPoint? existing) => false;