1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-21 04:19:53 +08:00

Merge pull request #31885 from peppy/clock-align

This commit is contained in:
Dean Herbert
2025-02-16 13:58:56 +09:00
committed by GitHub
Unverified
@@ -7,8 +7,10 @@ using System;
using osu.Framework.Allocation;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osuTK;
namespace osu.Game.Overlays.Toolbar
{
@@ -17,6 +19,8 @@ namespace osu.Game.Overlays.Toolbar
private OsuSpriteText realTime;
private OsuSpriteText gameTime;
private FillFlowContainer runningText;
private bool showRuntime = true;
public bool ShowRuntime
@@ -52,17 +56,36 @@ namespace osu.Game.Overlays.Toolbar
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AutoSizeAxes = Axes.Y;
AutoSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
realTime = new OsuSpriteText(),
gameTime = new OsuSpriteText
realTime = new OsuSpriteText
{
Font = OsuFont.Default.With(fixedWidth: true),
Spacing = new Vector2(-1.5f, 0),
},
runningText = new FillFlowContainer
{
Y = 14,
Colour = colours.PinkLight,
Font = OsuFont.Default.With(size: 10, weight: FontWeight.SemiBold),
}
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(2, 0),
Children = new Drawable[]
{
new OsuSpriteText
{
Text = "running",
Font = OsuFont.Default.With(size: 10, weight: FontWeight.SemiBold),
},
gameTime = new OsuSpriteText
{
Font = OsuFont.Default.With(size: 10, fixedWidth: true, weight: FontWeight.SemiBold),
Spacing = new Vector2(-0.5f, 0),
}
}
},
};
updateMetrics();
@@ -71,14 +94,12 @@ namespace osu.Game.Overlays.Toolbar
protected override void UpdateDisplay(DateTimeOffset now)
{
realTime.Text = now.ToLocalisableString(use24HourDisplay ? @"HH:mm:ss" : @"h:mm:ss tt");
gameTime.Text = $"running {new TimeSpan(TimeSpan.TicksPerSecond * (int)(Clock.CurrentTime / 1000)):c}";
gameTime.Text = $"{new TimeSpan(TimeSpan.TicksPerSecond * (int)(Clock.CurrentTime / 1000)):c}";
}
private void updateMetrics()
{
Width = showRuntime || !use24HourDisplay ? 66 : 45; // Allows for space for game time up to 99 days (in the padding area since this is quite rare).
gameTime.FadeTo(showRuntime ? 1 : 0);
runningText.FadeTo(showRuntime ? 1 : 0);
}
}
}