mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 03:22:59 +08:00
using BindValueChanged and IsCurrentScreen for setting binding
This commit is contained in:
parent
c1876aac88
commit
d783998c81
@ -127,24 +127,21 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private Bindable<float> backgroundBlurLevel { get; set; } = new BindableFloat();
|
private Bindable<float> backgroundBlurLevel { get; set; } = new BindableFloat();
|
||||||
|
|
||||||
private void applyBackgroundBlur(float blurLevel)
|
|
||||||
{
|
|
||||||
ApplyToBackground(background =>
|
|
||||||
{
|
|
||||||
background.IgnoreUserSettings.Value = true;
|
|
||||||
background.BlurAmount.Value = blurLevel * BACKGROUND_BLUR;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void applyBackgroundBlur(ValueChangedEvent<float> blurLevelValueChange)
|
|
||||||
{
|
|
||||||
applyBackgroundBlur(blurLevelValueChange.NewValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(AudioManager audio, OsuColour colours, ManageCollectionsDialog? manageCollectionsDialog, DifficultyRecommender? recommender, OsuConfigManager config)
|
private void load(AudioManager audio, OsuColour colours, ManageCollectionsDialog? manageCollectionsDialog, DifficultyRecommender? recommender, OsuConfigManager config)
|
||||||
{
|
{
|
||||||
backgroundBlurLevel = config.GetBindable<float>(OsuSetting.SongSelectBackgoundBlurLevel);
|
backgroundBlurLevel = config.GetBindable<float>(OsuSetting.SongSelectBackgoundBlurLevel);
|
||||||
|
backgroundBlurLevel.BindValueChanged(e =>
|
||||||
|
{
|
||||||
|
if (this.IsCurrentScreen())
|
||||||
|
{
|
||||||
|
ApplyToBackground(background =>
|
||||||
|
{
|
||||||
|
background.IgnoreUserSettings.Value = true;
|
||||||
|
background.BlurAmount.Value = e.NewValue * BACKGROUND_BLUR;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
LoadComponentAsync(Carousel = new BeatmapCarousel
|
LoadComponentAsync(Carousel = new BeatmapCarousel
|
||||||
{
|
{
|
||||||
@ -568,9 +565,6 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
base.OnEntering(e);
|
base.OnEntering(e);
|
||||||
|
|
||||||
backgroundBlurLevel.ValueChanged += applyBackgroundBlur;
|
|
||||||
applyBackgroundBlur(backgroundBlurLevel.Value);
|
|
||||||
|
|
||||||
this.FadeInFromZero(250);
|
this.FadeInFromZero(250);
|
||||||
FilterControl.Activate();
|
FilterControl.Activate();
|
||||||
|
|
||||||
@ -618,8 +612,6 @@ namespace osu.Game.Screens.Select
|
|||||||
public override void OnResuming(ScreenTransitionEvent e)
|
public override void OnResuming(ScreenTransitionEvent e)
|
||||||
{
|
{
|
||||||
base.OnResuming(e);
|
base.OnResuming(e);
|
||||||
backgroundBlurLevel.ValueChanged += applyBackgroundBlur;
|
|
||||||
applyBackgroundBlur(backgroundBlurLevel.Value);
|
|
||||||
|
|
||||||
// required due to https://github.com/ppy/osu-framework/issues/3218
|
// required due to https://github.com/ppy/osu-framework/issues/3218
|
||||||
ModSelect.SelectedMods.Disabled = false;
|
ModSelect.SelectedMods.Disabled = false;
|
||||||
@ -665,8 +657,6 @@ namespace osu.Game.Screens.Select
|
|||||||
// Without this, it's possible for a transfer to happen while we are not the current screen.
|
// Without this, it's possible for a transfer to happen while we are not the current screen.
|
||||||
transferRulesetValue();
|
transferRulesetValue();
|
||||||
|
|
||||||
backgroundBlurLevel.ValueChanged -= applyBackgroundBlur;
|
|
||||||
|
|
||||||
ModSelect.SelectedMods.UnbindFrom(selectedMods);
|
ModSelect.SelectedMods.UnbindFrom(selectedMods);
|
||||||
|
|
||||||
playExitingTransition();
|
playExitingTransition();
|
||||||
@ -675,8 +665,6 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
public override bool OnExiting(ScreenExitEvent e)
|
public override bool OnExiting(ScreenExitEvent e)
|
||||||
{
|
{
|
||||||
backgroundBlurLevel.ValueChanged -= applyBackgroundBlur;
|
|
||||||
|
|
||||||
if (base.OnExiting(e))
|
if (base.OnExiting(e))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user