2017-04-28 10:02:25 +08:00
|
|
|
|
// 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;
|
2017-04-28 09:56:34 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-05-01 12:00:44 +08:00
|
|
|
|
using System;
|
2017-04-28 09:56:34 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play
|
|
|
|
|
{
|
|
|
|
|
public class SongProgressInfo : Container
|
|
|
|
|
{
|
2017-05-09 00:14:19 +08:00
|
|
|
|
private OsuSpriteText timeCurrent;
|
2017-04-28 21:02:00 +08:00
|
|
|
|
private OsuSpriteText timeLeft;
|
2017-05-08 05:16:58 +08:00
|
|
|
|
private OsuSpriteText progressText;
|
|
|
|
|
|
2017-05-09 00:14:19 +08:00
|
|
|
|
private double currentTime;
|
|
|
|
|
private double songLenght;
|
2017-05-08 05:16:58 +08:00
|
|
|
|
private int progress;
|
2017-04-28 09:56:34 +08:00
|
|
|
|
|
|
|
|
|
private const int margin = 10;
|
|
|
|
|
|
2017-05-09 00:14:19 +08:00
|
|
|
|
public double SongLenght { set { songLenght = value; } }
|
|
|
|
|
public double CurrentTime
|
2017-05-08 05:16:58 +08:00
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
2017-05-09 00:14:19 +08:00
|
|
|
|
currentTime = value;
|
2017-05-08 05:16:58 +08:00
|
|
|
|
if (value > 0)
|
2017-05-09 00:14:19 +08:00
|
|
|
|
timeCurrent.Text = TimeSpan.FromMilliseconds(value).ToString(@"m\:ss");
|
2017-05-08 05:16:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public int Progress
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (progress == value)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
progress = value;
|
2017-05-09 00:14:19 +08:00
|
|
|
|
if (currentTime > 0)
|
2017-05-08 05:16:58 +08:00
|
|
|
|
progressText.Text = value.ToString() + @"%";
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-28 09:56:34 +08:00
|
|
|
|
|
2017-04-28 21:02:00 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
2017-04-28 09:56:34 +08:00
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-05-09 00:14:19 +08:00
|
|
|
|
timeCurrent = new OsuSpriteText
|
2017-04-28 09:56:34 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
2017-04-28 21:02:00 +08:00
|
|
|
|
Colour = colours.BlueLighter,
|
|
|
|
|
Font = @"Venera",
|
2017-04-28 09:56:34 +08:00
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Left = margin,
|
|
|
|
|
},
|
2017-05-08 05:16:58 +08:00
|
|
|
|
Text = @"0:00",
|
2017-04-28 09:56:34 +08:00
|
|
|
|
},
|
2017-05-08 05:16:58 +08:00
|
|
|
|
progressText = new OsuSpriteText
|
2017-04-28 09:56:34 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
2017-04-28 21:02:00 +08:00
|
|
|
|
Colour = colours.BlueLighter,
|
|
|
|
|
Font = @"Venera",
|
2017-05-08 05:16:58 +08:00
|
|
|
|
Text = @"0%",
|
2017-04-28 09:56:34 +08:00
|
|
|
|
},
|
2017-04-28 21:02:00 +08:00
|
|
|
|
timeLeft = new OsuSpriteText
|
2017-04-28 09:56:34 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.BottomRight,
|
|
|
|
|
Anchor = Anchor.BottomRight,
|
2017-04-28 21:02:00 +08:00
|
|
|
|
Colour = colours.BlueLighter,
|
|
|
|
|
Font = @"Venera",
|
2017-04-28 09:56:34 +08:00
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Right = margin,
|
2017-05-09 00:14:19 +08:00
|
|
|
|
},
|
|
|
|
|
Text = @"-" + TimeSpan.FromMilliseconds(songLenght).ToString(@"m\:ss"),
|
2017-04-28 09:56:34 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2017-05-09 00:14:19 +08:00
|
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
|
|
if(currentTime > 0)
|
|
|
|
|
timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(songLenght - currentTime).ToString(@"m\:ss");
|
|
|
|
|
}
|
2017-04-28 09:56:34 +08:00
|
|
|
|
}
|
|
|
|
|
}
|