mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:12:57 +08:00
Implement singular change events for ControlPoint
This commit is contained in:
parent
cd3b455341
commit
b8e0704554
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user