mirror of
https://github.com/ppy/osu
synced 2025-01-11 08:39:31 +00:00
Merge pull request #30056 from bdach/speed-change-hotkeys-lose-pitch
Fix rate change hotkeys sometimes losing track of adjust pitch setting
This commit is contained in:
commit
7d756d0de2
@ -175,6 +175,29 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
increaseModSpeed();
|
||||
AddAssert("adaptive speed still active", () => songSelect!.Mods.Value.First() is ModAdaptiveSpeed);
|
||||
|
||||
OsuModDoubleTime dtWithAdjustPitch = new OsuModDoubleTime
|
||||
{
|
||||
SpeedChange = { Value = 1.05 },
|
||||
AdjustPitch = { Value = true },
|
||||
};
|
||||
changeMods(dtWithAdjustPitch);
|
||||
|
||||
decreaseModSpeed();
|
||||
AddAssert("no mods selected", () => songSelect!.Mods.Value.Count == 0);
|
||||
|
||||
decreaseModSpeed();
|
||||
AddAssert("half time activated at 0.95x", () => songSelect!.Mods.Value.OfType<ModHalfTime>().Single().SpeedChange.Value, () => Is.EqualTo(0.95).Within(0.005));
|
||||
AddAssert("half time has adjust pitch active", () => songSelect!.Mods.Value.OfType<ModHalfTime>().Single().AdjustPitch.Value, () => Is.True);
|
||||
|
||||
AddStep("turn off adjust pitch", () => songSelect!.Mods.Value.OfType<ModHalfTime>().Single().AdjustPitch.Value = false);
|
||||
|
||||
increaseModSpeed();
|
||||
AddAssert("no mods selected", () => songSelect!.Mods.Value.Count == 0);
|
||||
|
||||
increaseModSpeed();
|
||||
AddAssert("double time activated at 1.05x", () => songSelect!.Mods.Value.OfType<ModDoubleTime>().Single().SpeedChange.Value, () => Is.EqualTo(1.05).Within(0.005));
|
||||
AddAssert("double time has adjust pitch inactive", () => songSelect!.Mods.Value.OfType<ModDoubleTime>().Single().AdjustPitch.Value, () => Is.False);
|
||||
|
||||
void increaseModSpeed() => AddStep("increase mod speed", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.ControlLeft);
|
||||
|
@ -27,6 +27,7 @@ namespace osu.Game.Screens.Select
|
||||
private OnScreenDisplay? onScreenDisplay { get; set; }
|
||||
|
||||
private ModRateAdjust? lastActiveRateAdjustMod;
|
||||
private ModSettingChangeTracker? settingChangeTracker;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
@ -34,10 +35,19 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
selectedMods.BindValueChanged(val =>
|
||||
{
|
||||
lastActiveRateAdjustMod = val.NewValue.OfType<ModRateAdjust>().SingleOrDefault() ?? lastActiveRateAdjustMod;
|
||||
storeLastActiveRateAdjustMod();
|
||||
|
||||
settingChangeTracker?.Dispose();
|
||||
settingChangeTracker = new ModSettingChangeTracker(val.NewValue);
|
||||
settingChangeTracker.SettingChanged += _ => storeLastActiveRateAdjustMod();
|
||||
}, true);
|
||||
}
|
||||
|
||||
private void storeLastActiveRateAdjustMod()
|
||||
{
|
||||
lastActiveRateAdjustMod = (ModRateAdjust?)selectedMods.Value.OfType<ModRateAdjust>().SingleOrDefault()?.DeepClone() ?? lastActiveRateAdjustMod;
|
||||
}
|
||||
|
||||
public bool ChangeSpeed(double delta, IEnumerable<Mod> availableMods)
|
||||
{
|
||||
double targetSpeed = (selectedMods.Value.OfType<ModRateAdjust>().SingleOrDefault()?.SpeedChange.Value ?? 1) + delta;
|
||||
|
Loading…
Reference in New Issue
Block a user