Keep TextSprites in SongProgressInfo upright

This commit is contained in:
HiddenNode 2022-08-01 21:46:37 +01:00
parent bc059cc1d2
commit df85bd74d7

View File

@ -46,30 +46,51 @@ namespace osu.Game.Screens.Play.HUD
if (clock != null) if (clock != null)
gameplayClock = clock; gameplayClock = clock;
Children = new Drawable[]
{
new Container
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
AutoSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
timeCurrent = new OsuSpriteText timeCurrent = new OsuSpriteText
{ {
Origin = Anchor.BottomLeft, Origin = Anchor.Centre,
Anchor = Anchor.BottomLeft, Anchor = Anchor.Centre,
Colour = colours.BlueLighter, Colour = colours.BlueLighter,
Font = OsuFont.Numeric, Font = OsuFont.Numeric,
Margin = new MarginPadding }
{ }
Left = margin,
}, },
}, new Container
progress = new OsuSpriteText
{ {
Origin = Anchor.BottomCentre, Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
progress = new OsuSpriteText
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Colour = colours.BlueLighter, Colour = colours.BlueLighter,
Font = OsuFont.Numeric, Font = OsuFont.Numeric,
}
}
}, },
timeLeft = new OsuSpriteText new Container
{ {
Origin = Anchor.BottomRight, Origin = Anchor.BottomRight,
Anchor = Anchor.BottomRight, Anchor = Anchor.BottomRight,
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
timeLeft = new OsuSpriteText
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Colour = colours.BlueLighter, Colour = colours.BlueLighter,
Font = OsuFont.Numeric, Font = OsuFont.Numeric,
Margin = new MarginPadding Margin = new MarginPadding
@ -77,9 +98,17 @@ namespace osu.Game.Screens.Play.HUD
Right = margin, Right = margin,
}, },
} }
}
}
}; };
} }
protected override void LoadComplete()
{
base.LoadComplete();
keepTextSpritesUpright();
}
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
@ -106,5 +135,13 @@ 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()
{
timeCurrent.OnUpdate += (timeCurrent) => { Extensions.DrawableExtensions.KeepUpright(timeCurrent); };
progress.OnUpdate += (timeCurrent) => { Extensions.DrawableExtensions.KeepUpright(timeCurrent); };
timeLeft.OnUpdate += (timeCurrent) => { Extensions.DrawableExtensions.KeepUpright(timeCurrent); };
}
} }
} }