1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 16:27:26 +08:00

Use bindable for HealthDisplay.

This commit is contained in:
Dean Herbert 2017-01-18 13:40:13 +08:00
parent 8c7bb4990c
commit cd149f04fc
2 changed files with 6 additions and 5 deletions

View File

@ -14,6 +14,8 @@ namespace osu.Game.Modes.UI
private Box background;
private Box fill;
public BindableDouble Current = new BindableDouble();
public HealthDisplay()
{
Children = new Drawable[]
@ -30,13 +32,12 @@ namespace osu.Game.Modes.UI
Scale = new Vector2(0, 1),
},
};
Current.ValueChanged += current_ValueChanged;
}
public double Current;
public void Set(double value)
private void current_ValueChanged(object sender, EventArgs e)
{
Current = value;
fill.ScaleTo(new Vector2((float)Current, 1), 200, EasingTypes.OutQuint);
}
}

View File

@ -63,7 +63,7 @@ namespace osu.Game.Modes.UI
processor.TotalScore.ValueChanged += delegate { ScoreCounter?.Set((ulong)processor.TotalScore.Value); };
processor.Accuracy.ValueChanged += delegate { AccuracyCounter?.Set((float)processor.Accuracy.Value); };
processor.Combo.ValueChanged += delegate { ComboCounter?.Set((ulong)processor.Combo.Value); };
processor.Health.ValueChanged += delegate { HealthDisplay?.Set(processor.Health.Value); };
if (HealthDisplay != null) processor.Health.Weld(HealthDisplay.Current);
}
}
}