mirror of
https://github.com/ppy/osu
synced 2024-12-14 19:06:07 +00:00
Centralise logic further
This commit is contained in:
parent
3637bf2f9b
commit
678767918e
@ -36,10 +36,9 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private const double low_health_threshold = 0.20f;
|
private const double low_health_threshold = 0.20f;
|
||||||
|
|
||||||
private readonly Bindable<bool> fadePlayfieldWhenHealthLow = new Bindable<bool>();
|
|
||||||
private readonly Container boxes;
|
private readonly Container boxes;
|
||||||
|
|
||||||
private Bindable<bool> fadePlayfieldWhenHealthLowSetting;
|
private Bindable<bool> fadePlayfieldWhenHealthLow;
|
||||||
private HealthProcessor healthProcessor;
|
private HealthProcessor healthProcessor;
|
||||||
|
|
||||||
public FailingLayer()
|
public FailingLayer()
|
||||||
@ -78,15 +77,15 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
{
|
{
|
||||||
boxes.Colour = color.Red;
|
boxes.Colour = color.Red;
|
||||||
|
|
||||||
fadePlayfieldWhenHealthLowSetting = config.GetBindable<bool>(OsuSetting.FadePlayfieldWhenHealthLow);
|
fadePlayfieldWhenHealthLow = config.GetBindable<bool>(OsuSetting.FadePlayfieldWhenHealthLow);
|
||||||
fadePlayfieldWhenHealthLow.BindValueChanged(_ => updateState(), true);
|
fadePlayfieldWhenHealthLow.BindValueChanged(_ => updateState());
|
||||||
ShowHealth.BindValueChanged(_ => updateState(), true);
|
ShowHealth.BindValueChanged(_ => updateState());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
updateBindings();
|
updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void BindHealthProcessor(HealthProcessor processor)
|
public override void BindHealthProcessor(HealthProcessor processor)
|
||||||
@ -94,26 +93,13 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
base.BindHealthProcessor(processor);
|
base.BindHealthProcessor(processor);
|
||||||
|
|
||||||
healthProcessor = processor;
|
healthProcessor = processor;
|
||||||
updateBindings();
|
updateState();
|
||||||
}
|
|
||||||
|
|
||||||
private void updateBindings()
|
|
||||||
{
|
|
||||||
if (LoadState < LoadState.Ready)
|
|
||||||
return;
|
|
||||||
|
|
||||||
fadePlayfieldWhenHealthLow.UnbindBindings();
|
|
||||||
|
|
||||||
// Don't display ever if the ruleset is not using a draining health display.
|
|
||||||
if (healthProcessor is DrainingHealthProcessor)
|
|
||||||
fadePlayfieldWhenHealthLow.BindTo(fadePlayfieldWhenHealthLowSetting);
|
|
||||||
else
|
|
||||||
fadePlayfieldWhenHealthLow.Value = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateState()
|
private void updateState()
|
||||||
{
|
{
|
||||||
var showLayer = fadePlayfieldWhenHealthLow.Value && ShowHealth.Value;
|
// Don't display ever if the ruleset is not using a draining health display.
|
||||||
|
var showLayer = healthProcessor is DrainingHealthProcessor && fadePlayfieldWhenHealthLow.Value && ShowHealth.Value;
|
||||||
this.FadeTo(showLayer ? 1 : 0, fade_time, Easing.OutQuint);
|
this.FadeTo(showLayer ? 1 : 0, fade_time, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user