mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
88 lines
2.8 KiB
C#
88 lines
2.8 KiB
C#
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Graphics.Primitives;
|
|
using osu.Game.Graphics;
|
|
using osu.Game.Graphics.Sprites;
|
|
using System;
|
|
|
|
namespace osu.Game.Screens.Play
|
|
{
|
|
public class SongProgressInfo : Container
|
|
{
|
|
private OsuSpriteText timeCurrentText;
|
|
private OsuSpriteText timeLeft;
|
|
private OsuSpriteText progressText;
|
|
|
|
private int progress;
|
|
private double timeCurrent;
|
|
|
|
private const int margin = 10;
|
|
|
|
public double TimeCurrent
|
|
{
|
|
set
|
|
{
|
|
timeCurrent = value;
|
|
if (value > 0)
|
|
timeCurrentText.Text = TimeSpan.FromMilliseconds(value).ToString(@"m\:ss");
|
|
}
|
|
}
|
|
public double TimeLeft { set { timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(timeCurrent < 0 ? value + timeCurrent : value).ToString(@"m\:ss"); } }
|
|
public int Progress
|
|
{
|
|
set
|
|
{
|
|
if (progress == value)
|
|
return;
|
|
|
|
progress = value;
|
|
if (value > 0)
|
|
progressText.Text = value.ToString() + @"%";
|
|
}
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load(OsuColour colours)
|
|
{
|
|
Children = new Drawable[]
|
|
{
|
|
timeCurrentText = new OsuSpriteText
|
|
{
|
|
Origin = Anchor.BottomLeft,
|
|
Anchor = Anchor.BottomLeft,
|
|
Colour = colours.BlueLighter,
|
|
Font = @"Venera",
|
|
Margin = new MarginPadding
|
|
{
|
|
Left = margin,
|
|
},
|
|
Text = @"0:00",
|
|
},
|
|
progressText = new OsuSpriteText
|
|
{
|
|
Origin = Anchor.BottomCentre,
|
|
Anchor = Anchor.BottomCentre,
|
|
Colour = colours.BlueLighter,
|
|
Font = @"Venera",
|
|
Text = @"0%",
|
|
},
|
|
timeLeft = new OsuSpriteText
|
|
{
|
|
Origin = Anchor.BottomRight,
|
|
Anchor = Anchor.BottomRight,
|
|
Colour = colours.BlueLighter,
|
|
Font = @"Venera",
|
|
Margin = new MarginPadding
|
|
{
|
|
Right = margin,
|
|
}
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|