mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 12:42:54 +08:00
Fix calibrating offset from previous non-zero offset not applying adjustment correctly
This commit is contained in:
parent
6be031471e
commit
e9e92b991e
@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDisplay()
|
public void TestCalibrationFromZero()
|
||||||
{
|
{
|
||||||
const double average_error = -4.5;
|
const double average_error = -4.5;
|
||||||
|
|
||||||
@ -70,5 +70,33 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddStep("Remove reference score", () => offsetControl.ReferenceScore.Value = null);
|
AddStep("Remove reference score", () => offsetControl.ReferenceScore.Value = null);
|
||||||
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When a beatmap offset was already set, the calibration should take it into account.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestCalibrationFromNonZero()
|
||||||
|
{
|
||||||
|
const double average_error = -4.5;
|
||||||
|
const double initial_offset = -2;
|
||||||
|
|
||||||
|
AddStep("Set offset non-neutral", () => offsetControl.Current.Value = initial_offset);
|
||||||
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
||||||
|
AddStep("Set reference score", () =>
|
||||||
|
{
|
||||||
|
offsetControl.ReferenceScore.Value = new ScoreInfo
|
||||||
|
{
|
||||||
|
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(average_error)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert("Has calibration button", () => offsetControl.ChildrenOfType<SettingsButton>().Any());
|
||||||
|
AddStep("Press button", () => offsetControl.ChildrenOfType<SettingsButton>().Single().TriggerClick());
|
||||||
|
AddAssert("Offset is adjusted", () => offsetControl.Current.Value == initial_offset - average_error);
|
||||||
|
|
||||||
|
AddAssert("Button is disabled", () => !offsetControl.ChildrenOfType<SettingsButton>().Single().Enabled.Value);
|
||||||
|
AddStep("Remove reference score", () => offsetControl.ReferenceScore.Value = null);
|
||||||
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
private OsuColour colours { get; set; } = null!;
|
private OsuColour colours { get; set; } = null!;
|
||||||
|
|
||||||
private double lastPlayAverage;
|
private double lastPlayAverage;
|
||||||
|
private double lastPlayBeatmapOffset;
|
||||||
|
|
||||||
private SettingsButton? useAverageButton;
|
private SettingsButton? useAverageButton;
|
||||||
|
|
||||||
@ -130,7 +131,7 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (useAverageButton != null)
|
if (useAverageButton != null)
|
||||||
useAverageButton.Enabled.Value = !Precision.AlmostEquals(lastPlayAverage, -Current.Value, Current.Precision / 2);
|
useAverageButton.Enabled.Value = !Precision.AlmostEquals(lastPlayAverage, -Current.Value + lastPlayBeatmapOffset, Current.Precision / 2);
|
||||||
|
|
||||||
realmWriteTask = realm.WriteAsync(r =>
|
realmWriteTask = realm.WriteAsync(r =>
|
||||||
{
|
{
|
||||||
@ -187,6 +188,7 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
}
|
}
|
||||||
|
|
||||||
lastPlayAverage = average;
|
lastPlayAverage = average;
|
||||||
|
lastPlayBeatmapOffset = Current.Value;
|
||||||
|
|
||||||
referenceScoreContainer.AddRange(new Drawable[]
|
referenceScoreContainer.AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
@ -199,7 +201,7 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
useAverageButton = new SettingsButton
|
useAverageButton = new SettingsButton
|
||||||
{
|
{
|
||||||
Text = BeatmapOffsetControlStrings.CalibrateUsingLastPlay,
|
Text = BeatmapOffsetControlStrings.CalibrateUsingLastPlay,
|
||||||
Action = () => Current.Value = -lastPlayAverage
|
Action = () => Current.Value = lastPlayBeatmapOffset - lastPlayAverage
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user