1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 19:22:54 +08:00

Add track timer

This commit is contained in:
EVAST9919 2017-11-18 08:24:09 +03:00
parent 58e7263108
commit 34d8f94f99
3 changed files with 43 additions and 6 deletions

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -17,6 +18,7 @@ namespace osu.Game.Screens.Edit.Components
private const float contents_padding = 15;
public Bindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
protected Track Track => Beatmap.Value.Track;
private readonly Drawable background;
private readonly Container content;

View File

@ -19,7 +19,6 @@ namespace osu.Game.Screens.Edit.Components
private readonly IconButton playButton;
private bool lastTrackState;
private Track track => Beatmap.Value.Track;
public PlaybackContainer()
{
@ -60,22 +59,22 @@ namespace osu.Game.Screens.Edit.Components
tabs.AddItem(0.75);
tabs.AddItem(1);
tabs.Current.ValueChanged += newValue => track.Tempo.Value = newValue;
tabs.Current.ValueChanged += newValue => Track.Tempo.Value = newValue;
}
private void play()
{
if (track.IsRunning)
track.Stop();
if (Track.IsRunning)
Track.Stop();
else
track.Start();
Track.Start();
}
protected override void Update()
{
base.Update();
var currentTrackState = track.IsRunning;
var currentTrackState = Track.IsRunning;
if (currentTrackState == lastTrackState)
return;

View File

@ -1,9 +1,45 @@
// 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.Graphics;
using osu.Game.Graphics.Sprites;
using System;
namespace osu.Game.Screens.Edit.Components
{
public class TimeInfoContainer : BottomBarContainer
{
private const int count_duration = 150;
private readonly OsuSpriteText trackTimer;
private double savedTime;
public TimeInfoContainer()
{
Children = new Drawable[]
{
trackTimer = new OsuSpriteText
{
Origin = Anchor.BottomLeft,
RelativePositionAxes = Axes.Y,
TextSize = 22,
FixedWidth = true,
Y = 0.5f,
}
};
}
protected override void Update()
{
base.Update();
var currentTime = Track.CurrentTime;
if (savedTime == currentTime)
return;
trackTimer.Text = TimeSpan.FromMilliseconds(currentTime).ToString(@"mm\:ss\:fff");
savedTime = currentTime;
}
}
}