mirror of
https://github.com/ppy/osu
synced 2024-12-15 11:25:29 +00:00
Merge pull request #14342 from frenzibyte/fix-difficulty-adjust-controls
Fix difficuly adjust settings controls not raising `SettingsChanged` events
This commit is contained in:
commit
cb122eaf25
@ -1,8 +1,10 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -174,6 +176,60 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
checkBindableAtValue("Circle Size", null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestModSettingChangeTracker()
|
||||
{
|
||||
ModSettingChangeTracker tracker = null;
|
||||
Queue<Mod> settingsChangedQueue = null;
|
||||
|
||||
setBeatmapWithDifficultyParameters(5);
|
||||
|
||||
AddStep("add mod settings change tracker", () =>
|
||||
{
|
||||
settingsChangedQueue = new Queue<Mod>();
|
||||
|
||||
tracker = new ModSettingChangeTracker(modDifficultyAdjust.Yield())
|
||||
{
|
||||
SettingChanged = settingsChangedQueue.Enqueue
|
||||
};
|
||||
});
|
||||
|
||||
AddAssert("no settings changed", () => settingsChangedQueue.Count == 0);
|
||||
|
||||
setSliderValue("Circle Size", 3);
|
||||
|
||||
settingsChangedFired();
|
||||
|
||||
setSliderValue("Circle Size", 5);
|
||||
checkBindableAtValue("Circle Size", 5);
|
||||
|
||||
settingsChangedFired();
|
||||
|
||||
AddStep("reset mod settings", () => modDifficultyAdjust.CircleSize.SetDefault());
|
||||
checkBindableAtValue("Circle Size", null);
|
||||
|
||||
settingsChangedFired();
|
||||
|
||||
setExtendedLimits(true);
|
||||
|
||||
settingsChangedFired();
|
||||
|
||||
AddStep("dispose tracker", () =>
|
||||
{
|
||||
tracker.Dispose();
|
||||
tracker = null;
|
||||
});
|
||||
|
||||
void settingsChangedFired()
|
||||
{
|
||||
AddAssert("setting changed event fired", () =>
|
||||
{
|
||||
settingsChangedQueue.Dequeue();
|
||||
return settingsChangedQueue.Count == 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void resetToDefault(string name)
|
||||
{
|
||||
AddStep($"Reset {name} to default", () =>
|
||||
|
@ -91,7 +91,13 @@ namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
// This is required as SettingsItem relies heavily on this bindable for internal use.
|
||||
// The actual update flow is done via the bindable provided in the constructor.
|
||||
public Bindable<float?> Current { get; set; } = new Bindable<float?>();
|
||||
private readonly BindableWithCurrent<float?> current = new BindableWithCurrent<float?>();
|
||||
|
||||
public Bindable<float?> Current
|
||||
{
|
||||
get => current.Current;
|
||||
set => current.Current = value;
|
||||
}
|
||||
|
||||
public SliderControl(BindableNumber<float> currentNumber)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user