mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 23:53:51 +09:00
Improve safety of bindings in HealthDisplay
This commit is contained in:
@ -17,7 +17,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class HealthDisplay : Container
|
public abstract class HealthDisplay : Container
|
||||||
{
|
{
|
||||||
private Bindable<bool> showHealthbar;
|
private readonly Bindable<bool> showHealthbar = new Bindable<bool>(true);
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
protected HealthProcessor HealthProcessor { get; private set; }
|
protected HealthProcessor HealthProcessor { get; private set; }
|
||||||
@ -32,18 +32,21 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[Resolved(canBeNull: true)]
|
||||||
private void load(HUDOverlay hud)
|
private HUDOverlay hudOverlay { get; set; }
|
||||||
{
|
|
||||||
Current.BindTo(HealthProcessor.Health);
|
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
Current.BindTo(HealthProcessor.Health);
|
||||||
HealthProcessor.NewJudgement += onNewJudgement;
|
HealthProcessor.NewJudgement += onNewJudgement;
|
||||||
|
|
||||||
if (hud != null)
|
if (hudOverlay != null)
|
||||||
{
|
showHealthbar.BindTo(hudOverlay.ShowHealthbar);
|
||||||
showHealthbar = hud.ShowHealthbar.GetBoundCopy();
|
|
||||||
showHealthbar.BindValueChanged(healthBar => this.FadeTo(healthBar.NewValue ? 1 : 0, HUDOverlay.FADE_DURATION, HUDOverlay.FADE_EASING), true);
|
// this probably shouldn't be operating on `this.`
|
||||||
}
|
showHealthbar.BindValueChanged(healthBar => this.FadeTo(healthBar.NewValue ? 1 : 0, HUDOverlay.FADE_DURATION, HUDOverlay.FADE_EASING), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onNewJudgement(JudgementResult judgement)
|
private void onNewJudgement(JudgementResult judgement)
|
||||||
|
Reference in New Issue
Block a user