1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 04:13:00 +08:00

Use UprightUnscaledContainer instead of KeepUprightAndUnscaled

This commit is contained in:
HiddenNode 2022-08-07 13:20:22 +01:00
parent 0bfa6fa975
commit ed86255e2b

View File

@ -15,10 +15,6 @@ namespace osu.Game.Screens.Play.HUD
{ {
public class SongProgressInfo : Container public class SongProgressInfo : Container
{ {
private GrowToFitContainer timeCurrentContainer;
private GrowToFitContainer timeLeftContainer;
private GrowToFitContainer progressContainer;
private OsuSpriteText timeCurrent; private OsuSpriteText timeCurrent;
private OsuSpriteText timeLeft; private OsuSpriteText timeLeft;
private OsuSpriteText progress; private OsuSpriteText progress;
@ -59,7 +55,12 @@ namespace osu.Game.Screens.Play.HUD
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Child = timeCurrentContainer = new GrowToFitContainer Child = new UprightUnscaledContainer
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Child = new GrowToFitContainer
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
@ -71,13 +72,19 @@ namespace osu.Game.Screens.Play.HUD
Font = OsuFont.Numeric, Font = OsuFont.Numeric,
} }
} }
}
}, },
new Container new Container
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Child = timeLeftContainer = new GrowToFitContainer Child = new UprightUnscaledContainer
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Child = new GrowToFitContainer
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
@ -89,13 +96,19 @@ namespace osu.Game.Screens.Play.HUD
Font = OsuFont.Numeric, Font = OsuFont.Numeric,
} }
} }
}
}, },
new Container new Container
{ {
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Child = progressContainer = new GrowToFitContainer Child = new UprightUnscaledContainer
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Child = new GrowToFitContainer
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
@ -108,13 +121,8 @@ namespace osu.Game.Screens.Play.HUD
} }
} }
} }
};
} }
};
protected override void LoadComplete()
{
base.LoadComplete();
keepTextSpritesUpright();
} }
protected override void Update() protected override void Update()
@ -143,12 +151,5 @@ namespace osu.Game.Screens.Play.HUD
} }
private string formatTime(TimeSpan timeSpan) => $"{(timeSpan < TimeSpan.Zero ? "-" : "")}{Math.Floor(timeSpan.Duration().TotalMinutes)}:{timeSpan.Duration().Seconds:D2}"; private string formatTime(TimeSpan timeSpan) => $"{(timeSpan < TimeSpan.Zero ? "-" : "")}{Math.Floor(timeSpan.Duration().TotalMinutes)}:{timeSpan.Duration().Seconds:D2}";
private void keepTextSpritesUpright()
{
timeCurrentContainer.OnUpdate += Extensions.DrawableExtensions.KeepUprightAndUnscaled;
progressContainer.OnUpdate += Extensions.DrawableExtensions.KeepUprightAndUnscaled;
timeLeftContainer.OnUpdate += Extensions.DrawableExtensions.KeepUprightAndUnscaled;
}
} }
} }