mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 04:13:00 +08:00
Support absolute-sized health bar and use it for default layout
This commit is contained in:
parent
0dbba13686
commit
cbea2db4be
@ -36,12 +36,10 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
};
|
};
|
||||||
|
|
||||||
[SettingSource("Bar length")]
|
[SettingSource("Bar length")]
|
||||||
public BindableFloat BarLength { get; } = new BindableFloat(0.98f)
|
public BindableFloat BarLength { get; } = new BindableFloat(0.98f);
|
||||||
{
|
|
||||||
MinValue = 0.2f,
|
[SettingSource("Use relative size")]
|
||||||
MaxValue = 1,
|
public BindableBool UseRelativeSize { get; } = new BindableBool(true);
|
||||||
Precision = 0.01f,
|
|
||||||
};
|
|
||||||
|
|
||||||
private BarPath mainBar = null!;
|
private BarPath mainBar = null!;
|
||||||
|
|
||||||
@ -140,9 +138,23 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
Current.BindValueChanged(_ => Scheduler.AddOnce(updateCurrent), true);
|
Current.BindValueChanged(_ => Scheduler.AddOnce(updateCurrent), true);
|
||||||
|
|
||||||
BarLength.BindValueChanged(l => Width = l.NewValue, true);
|
// update relative axes first before reading width from bar length.
|
||||||
BarHeight.BindValueChanged(_ => updatePath());
|
RelativeSizeAxes = UseRelativeSize.Value ? Axes.X : Axes.None;
|
||||||
updatePath();
|
Width = BarLength.Value;
|
||||||
|
|
||||||
|
UseRelativeSize.BindValueChanged(v =>
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = v.NewValue ? Axes.X : Axes.None;
|
||||||
|
float newWidth = Width;
|
||||||
|
|
||||||
|
BarLength.MinValue = v.NewValue ? 0.2f : 200f;
|
||||||
|
BarLength.MaxValue = v.NewValue ? 1f : 1000f;
|
||||||
|
BarLength.Precision = v.NewValue ? 0.01f : 1f;
|
||||||
|
BarLength.Value = newWidth;
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
BarLength.ValueChanged += l => Width = l.NewValue;
|
||||||
|
BarHeight.BindValueChanged(_ => updatePath(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnInvalidate(Invalidation invalidation, InvalidationSource source)
|
protected override bool OnInvalidate(Invalidation invalidation, InvalidationSource source)
|
||||||
|
@ -129,7 +129,8 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
health.Anchor = Anchor.TopLeft;
|
health.Anchor = Anchor.TopLeft;
|
||||||
health.Origin = Anchor.TopLeft;
|
health.Origin = Anchor.TopLeft;
|
||||||
health.BarLength.Value = 0.22f;
|
health.UseRelativeSize.Value = false;
|
||||||
|
health.BarLength.Value = 300;
|
||||||
health.BarHeight.Value = 30f;
|
health.BarHeight.Value = 30f;
|
||||||
health.Position = new Vector2(components_x_offset, 20f);
|
health.Position = new Vector2(components_x_offset, 20f);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user