mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Move nested classes to own files
This commit is contained in:
64
osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs
Normal file
64
osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs
Normal file
@ -0,0 +1,64 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
public class DigitalClockDisplay : ClockDisplay
|
||||
{
|
||||
private OsuSpriteText realTime;
|
||||
private OsuSpriteText gameTime;
|
||||
|
||||
private bool showRuntime = true;
|
||||
|
||||
public bool ShowRuntime
|
||||
{
|
||||
get => showRuntime;
|
||||
set
|
||||
{
|
||||
if (showRuntime == value)
|
||||
return;
|
||||
|
||||
showRuntime = value;
|
||||
updateMetrics();
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
realTime = new OsuSpriteText(),
|
||||
gameTime = new OsuSpriteText
|
||||
{
|
||||
Y = 14,
|
||||
Colour = colours.PinkLight,
|
||||
Scale = new Vector2(0.6f)
|
||||
}
|
||||
};
|
||||
|
||||
updateMetrics();
|
||||
}
|
||||
|
||||
protected override void UpdateDisplay(DateTimeOffset now)
|
||||
{
|
||||
realTime.Text = $"{now:HH:mm:ss}";
|
||||
gameTime.Text = $"running {new TimeSpan(TimeSpan.TicksPerSecond * (int)(Clock.CurrentTime / 1000)):c}";
|
||||
}
|
||||
|
||||
private void updateMetrics()
|
||||
{
|
||||
Width = showRuntime ? 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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user