mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Fix too many things being exposed
This commit is contained in:
parent
e05d7d5f8d
commit
9c6f77b26e
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -61,14 +62,13 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
|
|
||||||
private partial class ApproachRateSettingsControl : DifficultyAdjustSettingsControl
|
private partial class ApproachRateSettingsControl : DifficultyAdjustSettingsControl
|
||||||
{
|
{
|
||||||
protected override Drawable CreateControl() => new SliderControl(SliderDisplayCurrent,
|
protected override RoundedSliderBar<float> CreateSlider(BindableNumber<float> current) =>
|
||||||
new ApproachRateSlider
|
new ApproachRateSlider
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Current = SliderDisplayCurrent,
|
Current = current,
|
||||||
KeyboardStep = 0.1f,
|
KeyboardStep = 0.1f,
|
||||||
}
|
};
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A slider bar with more detailed approach rate info for its given value
|
/// A slider bar with more detailed approach rate info for its given value
|
||||||
|
@ -27,16 +27,16 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
/// When the mod is overriding a default, this will match the value of <see cref="Current"/>.
|
/// When the mod is overriding a default, this will match the value of <see cref="Current"/>.
|
||||||
/// When there is no override (ie. <see cref="Current"/> is null), this value will match the beatmap provided default via <see cref="updateCurrentFromSlider"/>.
|
/// When there is no override (ie. <see cref="Current"/> is null), this value will match the beatmap provided default via <see cref="updateCurrentFromSlider"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
protected readonly BindableNumber<float> SliderDisplayCurrent = new BindableNumber<float>();
|
private readonly BindableNumber<float> sliderDisplayCurrent = new BindableNumber<float>();
|
||||||
|
|
||||||
protected override Drawable CreateControl() => new SliderControl(SliderDisplayCurrent,
|
protected sealed override Drawable CreateControl() => new SliderControl(sliderDisplayCurrent, CreateSlider);
|
||||||
new RoundedSliderBar<float>
|
|
||||||
{
|
protected virtual RoundedSliderBar<float> CreateSlider(BindableNumber<float> current) => new RoundedSliderBar<float>
|
||||||
RelativeSizeAxes = Axes.X,
|
{
|
||||||
Current = SliderDisplayCurrent,
|
RelativeSizeAxes = Axes.X,
|
||||||
KeyboardStep = 0.1f,
|
Current = current,
|
||||||
}
|
KeyboardStep = 0.1f,
|
||||||
);
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Guards against beatmap values displayed on slider bars being transferred to user override.
|
/// Guards against beatmap values displayed on slider bars being transferred to user override.
|
||||||
@ -53,7 +53,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
// Intercept and extract the internal number bindable from DifficultyBindable.
|
// Intercept and extract the internal number bindable from DifficultyBindable.
|
||||||
// This will provide bounds and precision specifications for the slider bar.
|
// This will provide bounds and precision specifications for the slider bar.
|
||||||
difficultyBindable = (DifficultyBindable)value.GetBoundCopy();
|
difficultyBindable = (DifficultyBindable)value.GetBoundCopy();
|
||||||
SliderDisplayCurrent.BindTo(difficultyBindable.CurrentNumber);
|
sliderDisplayCurrent.BindTo(difficultyBindable.CurrentNumber);
|
||||||
|
|
||||||
base.Current = difficultyBindable;
|
base.Current = difficultyBindable;
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
Current.BindValueChanged(_ => updateCurrentFromSlider());
|
Current.BindValueChanged(_ => updateCurrentFromSlider());
|
||||||
beatmap.BindValueChanged(_ => updateCurrentFromSlider(), true);
|
beatmap.BindValueChanged(_ => updateCurrentFromSlider(), true);
|
||||||
|
|
||||||
SliderDisplayCurrent.BindValueChanged(number =>
|
sliderDisplayCurrent.BindValueChanged(number =>
|
||||||
{
|
{
|
||||||
// this handles the transfer of the slider value to the main bindable.
|
// this handles the transfer of the slider value to the main bindable.
|
||||||
// as such, should be skipped if the slider is being updated via updateFromDifficulty().
|
// as such, should be skipped if the slider is being updated via updateFromDifficulty().
|
||||||
@ -80,7 +80,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
if (Current.Value != null)
|
if (Current.Value != null)
|
||||||
{
|
{
|
||||||
// a user override has been added or updated.
|
// a user override has been added or updated.
|
||||||
SliderDisplayCurrent.Value = Current.Value.Value;
|
sliderDisplayCurrent.Value = Current.Value.Value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,11 +91,11 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
isInternalChange = true;
|
isInternalChange = true;
|
||||||
SliderDisplayCurrent.Value = difficultyBindable.ReadCurrentFromDifficulty(difficulty);
|
sliderDisplayCurrent.Value = difficultyBindable.ReadCurrentFromDifficulty(difficulty);
|
||||||
isInternalChange = false;
|
isInternalChange = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected partial class SliderControl : CompositeDrawable, IHasCurrentValue<float?>
|
private partial class SliderControl : CompositeDrawable, IHasCurrentValue<float?>
|
||||||
{
|
{
|
||||||
// This is required as SettingsItem relies heavily on this bindable for internal use.
|
// 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.
|
// The actual update flow is done via the bindable provided in the constructor.
|
||||||
@ -107,11 +107,11 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
set => current.Current = value;
|
set => current.Current = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SliderControl(BindableNumber<float> currentNumber, RoundedSliderBar<float> slider)
|
public SliderControl(BindableNumber<float> currentNumber, Func<BindableNumber<float>, RoundedSliderBar<float>> createSlider)
|
||||||
{
|
{
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
slider
|
createSlider(currentNumber)
|
||||||
};
|
};
|
||||||
|
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
|
Loading…
Reference in New Issue
Block a user