mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 11:42:54 +08:00
Merge pull request #29702 from peppy/fix-offset-control-wrong-order
Fix beatmap offset control not working correctly when calibrating from quitting gameplay
This commit is contained in:
commit
925710d9b3
@ -5,6 +5,7 @@ using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
@ -136,6 +137,59 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCalibrationFromNonZeroWithImmediateReferenceScore()
|
||||
{
|
||||
const double average_error = -4.5;
|
||||
const double initial_offset = -2;
|
||||
|
||||
AddStep("Set beatmap offset non-neutral", () => Realm.Write(r =>
|
||||
{
|
||||
r.Add(new BeatmapInfo
|
||||
{
|
||||
ID = Beatmap.Value.BeatmapInfo.ID,
|
||||
Ruleset = Beatmap.Value.BeatmapInfo.Ruleset,
|
||||
UserSettings =
|
||||
{
|
||||
Offset = initial_offset,
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
AddStep("Create control with preloaded reference score", () =>
|
||||
{
|
||||
Child = new PlayerSettingsGroup("Some settings")
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
offsetControl = new BeatmapOffsetControl
|
||||
{
|
||||
ReferenceScore =
|
||||
{
|
||||
Value = new ScoreInfo
|
||||
{
|
||||
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(average_error),
|
||||
BeatmapInfo = Beatmap.Value.BeatmapInfo,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
AddUntilStep("Has calibration button", () => offsetControl.ChildrenOfType<SettingsButton>().Any());
|
||||
AddStep("Press button", () => offsetControl.ChildrenOfType<SettingsButton>().Single().TriggerClick());
|
||||
AddAssert("Offset is adjusted", () => offsetControl.Current.Value, () => Is.EqualTo(initial_offset - average_error));
|
||||
|
||||
AddUntilStep("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());
|
||||
|
||||
AddStep("Clean up beatmap", () => Realm.Write(r => r.RemoveAll<BeatmapInfo>()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCalibrationNoChange()
|
||||
{
|
||||
|
@ -104,8 +104,6 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
ReferenceScore.BindValueChanged(scoreChanged, true);
|
||||
|
||||
beatmapOffsetSubscription = realm.SubscribeToPropertyChanged(
|
||||
r => r.Find<BeatmapInfo>(beatmap.Value.BeatmapInfo.ID)?.UserSettings,
|
||||
settings => settings.Offset,
|
||||
@ -124,6 +122,7 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
||||
});
|
||||
|
||||
Current.BindValueChanged(currentChanged);
|
||||
ReferenceScore.BindValueChanged(scoreChanged, true);
|
||||
}
|
||||
|
||||
private void currentChanged(ValueChangedEvent<double> offset)
|
||||
|
Loading…
Reference in New Issue
Block a user