1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Rename fields for clarity

This commit is contained in:
Bartłomiej Dach 2020-06-26 19:03:41 +02:00
parent 798e8e7a8d
commit 3783fe8d6a
3 changed files with 20 additions and 19 deletions

View File

@ -15,7 +15,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
private FailingLayer layer;
private readonly Bindable<bool> enabledHUD = new Bindable<bool>();
private readonly Bindable<bool> showHealth = new Bindable<bool>();
[Resolved]
private OsuConfigManager config { get; set; }
@ -27,10 +27,10 @@ namespace osu.Game.Tests.Visual.Gameplay
{
Child = layer = new FailingLayer();
layer.BindHealthProcessor(new DrainingHealthProcessor(1));
layer.HUDEnabled.BindTo(enabledHUD);
layer.ShowHealth.BindTo(showHealth);
});
AddStep("enable HUDOverlay", () => enabledHUD.Value = true);
AddStep("show health", () => showHealth.Value = true);
AddStep("enable layer", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, true));
AddUntilStep("layer is visible", () => layer.IsPresent);
}
@ -80,19 +80,19 @@ namespace osu.Game.Tests.Visual.Gameplay
{
AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
AddStep("disable HUDOverlay", () => enabledHUD.Value = false);
AddStep("don't show health", () => showHealth.Value = false);
AddStep("disable FadePlayfieldWhenHealthLow", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, false));
AddUntilStep("layer fade is invisible", () => !layer.IsPresent);
AddStep("disable HUDOverlay", () => enabledHUD.Value = false);
AddStep("don't show health", () => showHealth.Value = false);
AddStep("enable FadePlayfieldWhenHealthLow", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, true));
AddUntilStep("layer fade is invisible", () => !layer.IsPresent);
AddStep("enable HUDOverlay", () => enabledHUD.Value = true);
AddStep("show health", () => showHealth.Value = true);
AddStep("disable FadePlayfieldWhenHealthLow", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, false));
AddUntilStep("layer fade is invisible", () => !layer.IsPresent);
AddStep("enable HUDOverlay", () => enabledHUD.Value = true);
AddStep("show health", () => showHealth.Value = true);
AddStep("enable FadePlayfieldWhenHealthLow", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, true));
AddUntilStep("layer fade is visible", () => layer.IsPresent);
}

View File

@ -31,11 +31,12 @@ namespace osu.Game.Screens.Play.HUD
/// </summary>
public double LowHealthThreshold = 0.20f;
public readonly Bindable<bool> HUDEnabled = new Bindable<bool>();
private readonly Bindable<bool> enabled = new Bindable<bool>();
public readonly Bindable<bool> ShowHealth = new Bindable<bool>();
private readonly Bindable<bool> fadePlayfieldWhenHealthLow = new Bindable<bool>();
private readonly Container boxes;
private Bindable<bool> configEnabled;
private Bindable<bool> fadePlayfieldWhenHealthLowSetting;
private HealthProcessor healthProcessor;
public FailingLayer()
@ -74,9 +75,9 @@ namespace osu.Game.Screens.Play.HUD
{
boxes.Colour = color.Red;
configEnabled = config.GetBindable<bool>(OsuSetting.FadePlayfieldWhenHealthLow);
enabled.BindValueChanged(e => TryToFade(fade_time, Easing.OutQuint, e.NewValue), true);
HUDEnabled.BindValueChanged(e => TryToFade(fade_time, Easing.OutQuint, e.NewValue), true);
fadePlayfieldWhenHealthLowSetting = config.GetBindable<bool>(OsuSetting.FadePlayfieldWhenHealthLow);
fadePlayfieldWhenHealthLow.BindValueChanged(e => TryToFade(fade_time, Easing.OutQuint, e.NewValue), true);
ShowHealth.BindValueChanged(e => TryToFade(fade_time, Easing.OutQuint, e.NewValue), true);
}
protected override void LoadComplete()
@ -98,13 +99,13 @@ namespace osu.Game.Screens.Play.HUD
if (LoadState < LoadState.Ready)
return;
enabled.UnbindBindings();
fadePlayfieldWhenHealthLow.UnbindBindings();
// Don't display ever if the ruleset is not using a draining health display.
if (healthProcessor is DrainingHealthProcessor)
enabled.BindTo(configEnabled);
fadePlayfieldWhenHealthLow.BindTo(fadePlayfieldWhenHealthLowSetting);
else
enabled.Value = false;
fadePlayfieldWhenHealthLow.Value = false;
}
/// <summary>
@ -115,11 +116,11 @@ namespace osu.Game.Screens.Play.HUD
/// <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 (HUDEnabled.Value)
if (ShowHealth.Value)
{
if (fadeIn)
{
if (enabled.Value)
if (fadePlayfieldWhenHealthLow.Value)
this.FadeIn(fadeDuration, easing);
}
else

View File

@ -154,7 +154,7 @@ namespace osu.Game.Screens.Play
// start all elements hidden
hideTargets.ForEach(d => d.Hide());
FailingLayer.HUDEnabled.BindTo(ShowHealthbar);
FailingLayer.ShowHealth.BindTo(ShowHealthbar);
}
public override void Hide() => throw new InvalidOperationException($"{nameof(HUDOverlay)} should not be hidden as it will remove the ability of a user to quit. Use {nameof(ShowHud)} instead.");