mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Show game time display in clock
This commit is contained in:
parent
e8f5a8e3d6
commit
999ae88af2
@ -5,6 +5,7 @@ using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Overlays.Toolbar;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
@ -14,11 +15,13 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
[TestFixture]
|
||||
public class TestSceneToolbarClock : OsuManualInputManagerTestScene
|
||||
{
|
||||
private readonly Container mainContainer;
|
||||
|
||||
public TestSceneToolbarClock()
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
mainContainer = new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -60,5 +63,17 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRealGameTime()
|
||||
{
|
||||
AddStep("Set game time real", () => mainContainer.Clock = Clock);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLongGameTime()
|
||||
{
|
||||
AddStep("Set game time long", () => mainContainer.Clock = new FramedOffsetClock(Clock, false) { Offset = 3600.0 * 24 * 1000 * 98 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
public ToolbarClock()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
Width = 110;
|
||||
AutoSizeAxes = Axes.X;
|
||||
|
||||
Padding = new MarginPadding(10);
|
||||
}
|
||||
@ -28,43 +28,55 @@ namespace osu.Game.Overlays.Toolbar
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
new AnalogDisplay
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
},
|
||||
new DigitalDisplay
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
new AnalogDisplay
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
},
|
||||
new DigitalDisplay
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private class DigitalDisplay : ClockDisplay
|
||||
{
|
||||
private OsuSpriteText text;
|
||||
private OsuSpriteText realTime;
|
||||
private OsuSpriteText gameTime;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Width = 50;
|
||||
Width = 70; // Allows for space for game time up to 99 days.
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
text = new OsuSpriteText
|
||||
realTime = new OsuSpriteText(),
|
||||
gameTime = new OsuSpriteText
|
||||
{
|
||||
Text = "00:00:00",
|
||||
Y = 14,
|
||||
Colour = colours.PurpleLight,
|
||||
Scale = new Vector2(0.6f)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void UpdateDisplay(DateTimeOffset now)
|
||||
{
|
||||
text.Text = $"{now:HH:mm:ss}";
|
||||
realTime.Text = $"{now:HH:mm:ss}";
|
||||
gameTime.Text = $"running {new TimeSpan(TimeSpan.TicksPerSecond * (int)(Clock.CurrentTime / 1000)):c}";
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +87,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
private Drawable second;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load()
|
||||
{
|
||||
Size = new Vector2(30);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user