mirror of
https://github.com/ppy/osu
synced 2024-12-15 11:25:29 +00:00
Merge pull request #9275 from H2n9/osu-modtimeramp
Add an adjust pitch setting to ModTimeRamp
This commit is contained in:
commit
f8badd77d6
@ -26,6 +26,9 @@ namespace osu.Game.Rulesets.Mods
|
||||
[SettingSource("Final rate", "The final speed to ramp to")]
|
||||
public abstract BindableNumber<double> FinalRate { get; }
|
||||
|
||||
[SettingSource("Adjust pitch", "Should pitch be adjusted with speed")]
|
||||
public abstract BindableBool AdjustPitch { get; }
|
||||
|
||||
public override string SettingDescription => $"{InitialRate.Value:N2}x to {FinalRate.Value:N2}x";
|
||||
|
||||
private double finalRateTime;
|
||||
@ -43,15 +46,16 @@ namespace osu.Game.Rulesets.Mods
|
||||
protected ModTimeRamp()
|
||||
{
|
||||
// for preview purpose at song select. eventually we'll want to be able to update every frame.
|
||||
FinalRate.BindValueChanged(val => applyAdjustment(1), true);
|
||||
FinalRate.BindValueChanged(val => applyRateAdjustment(1), true);
|
||||
AdjustPitch.BindValueChanged(applyPitchAdjustment);
|
||||
}
|
||||
|
||||
public void ApplyToTrack(Track track)
|
||||
{
|
||||
this.track = track;
|
||||
track.AddAdjustment(AdjustableProperty.Frequency, SpeedChange);
|
||||
|
||||
FinalRate.TriggerChange();
|
||||
AdjustPitch.TriggerChange();
|
||||
}
|
||||
|
||||
public virtual void ApplyToBeatmap(IBeatmap beatmap)
|
||||
@ -66,14 +70,25 @@ namespace osu.Game.Rulesets.Mods
|
||||
|
||||
public virtual void Update(Playfield playfield)
|
||||
{
|
||||
applyAdjustment((track.CurrentTime - beginRampTime) / finalRateTime);
|
||||
applyRateAdjustment((track.CurrentTime - beginRampTime) / finalRateTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjust the rate along the specified ramp
|
||||
/// </summary>
|
||||
/// <param name="amount">The amount of adjustment to apply (from 0..1).</param>
|
||||
private void applyAdjustment(double amount) =>
|
||||
private void applyRateAdjustment(double amount) =>
|
||||
SpeedChange.Value = InitialRate.Value + (FinalRate.Value - InitialRate.Value) * Math.Clamp(amount, 0, 1);
|
||||
|
||||
private void applyPitchAdjustment(ValueChangedEvent<bool> adjustPitchSetting)
|
||||
{
|
||||
// remove existing old adjustment
|
||||
track.RemoveAdjustment(adjustmentForPitchSetting(adjustPitchSetting.OldValue), SpeedChange);
|
||||
|
||||
track.AddAdjustment(adjustmentForPitchSetting(adjustPitchSetting.NewValue), SpeedChange);
|
||||
}
|
||||
|
||||
private AdjustableProperty adjustmentForPitchSetting(bool adjustPitchSettingValue)
|
||||
=> adjustPitchSettingValue ? AdjustableProperty.Frequency : AdjustableProperty.Tempo;
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,13 @@ namespace osu.Game.Rulesets.Mods
|
||||
Precision = 0.01,
|
||||
};
|
||||
|
||||
[SettingSource("Adjust pitch", "Should pitch be adjusted with speed")]
|
||||
public override BindableBool AdjustPitch { get; } = new BindableBool
|
||||
{
|
||||
Default = true,
|
||||
Value = true
|
||||
};
|
||||
|
||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModWindUp)).ToArray();
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,13 @@ namespace osu.Game.Rulesets.Mods
|
||||
Precision = 0.01,
|
||||
};
|
||||
|
||||
[SettingSource("Adjust pitch", "Should pitch be adjusted with speed")]
|
||||
public override BindableBool AdjustPitch { get; } = new BindableBool
|
||||
{
|
||||
Default = true,
|
||||
Value = true
|
||||
};
|
||||
|
||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModWindDown)).ToArray();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user