mirror of
https://github.com/osukey/osukey.git
synced 2025-05-20 04:57:38 +09:00
Simplify implementation
This commit is contained in:
parent
3783fe8d6a
commit
415e1c05ff
@ -76,8 +76,8 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
boxes.Colour = color.Red;
|
boxes.Colour = color.Red;
|
||||||
|
|
||||||
fadePlayfieldWhenHealthLowSetting = config.GetBindable<bool>(OsuSetting.FadePlayfieldWhenHealthLow);
|
fadePlayfieldWhenHealthLowSetting = config.GetBindable<bool>(OsuSetting.FadePlayfieldWhenHealthLow);
|
||||||
fadePlayfieldWhenHealthLow.BindValueChanged(e => TryToFade(fade_time, Easing.OutQuint, e.NewValue), true);
|
fadePlayfieldWhenHealthLow.BindValueChanged(_ => updateState(), true);
|
||||||
ShowHealth.BindValueChanged(e => TryToFade(fade_time, Easing.OutQuint, e.NewValue), true);
|
ShowHealth.BindValueChanged(_ => updateState(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -108,26 +108,10 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
fadePlayfieldWhenHealthLow.Value = false;
|
fadePlayfieldWhenHealthLow.Value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private void updateState()
|
||||||
/// Tries to fade based on "Fade playfield when health is low" setting
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fadeDuration">Duration of the fade</param>
|
|
||||||
/// <param name="easing">Type of easing</param>
|
|
||||||
/// <param name="fadeIn">True when you want to fade in, false when you want to fade out</param>
|
|
||||||
public void TryToFade(float fadeDuration, Easing easing, bool fadeIn)
|
|
||||||
{
|
{
|
||||||
if (ShowHealth.Value)
|
var showLayer = fadePlayfieldWhenHealthLow.Value && ShowHealth.Value;
|
||||||
{
|
this.FadeTo(showLayer ? 1 : 0, fade_time, Easing.OutQuint);
|
||||||
if (fadeIn)
|
|
||||||
{
|
|
||||||
if (fadePlayfieldWhenHealthLow.Value)
|
|
||||||
this.FadeIn(fadeDuration, easing);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
this.FadeOut(fadeDuration, easing);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
this.FadeOut(fadeDuration, easing);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user