Introduce PreviewTrack class

This commit is contained in:
Roman Kapustin
2018-05-25 00:37:53 +03:00
parent d6076eb591
commit 498244a308
5 changed files with 76 additions and 46 deletions

View File

@ -2,13 +2,13 @@
// 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.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
@ -25,7 +25,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
private readonly Box bg, progress;
private readonly PlayButton playButton;
private Track preview => playButton.Preview;
private PreviewTrack preview => playButton.Preview;
public Bindable<bool> Playing => playButton.Playing;
public BeatmapSetInfo BeatmapSet
@ -83,7 +83,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
if (Playing.Value && preview != null)
{
// prevent negative (potential infinite) width if a track without length was loaded
progress.Width = preview.Length > 0 ? (float)(preview.CurrentTime / preview.Length) : 0f;
progress.Width = preview.Track.Length > 0 ? (float)(preview.Track.CurrentTime / preview.Track.Length) : 0f;
}
else
progress.Width = 0;