move logic to DirectPanel and reuse stuff for the PreviewButton

This commit is contained in:
Jorolf
2017-09-29 23:08:30 +02:00
parent 355a7b6649
commit 647304c14b
7 changed files with 166 additions and 169 deletions

View File

@ -26,6 +26,7 @@ namespace osu.Game.Overlays.Direct
private Box progressBar;
protected override PlayButton PlayButton => playButton;
protected override Box PreviewBar => progressBar;
public DirectGridPanel(BeatmapSetInfo beatmap) : base(beatmap)
{
@ -197,20 +198,8 @@ namespace osu.Game.Overlays.Direct
Margin = new MarginPadding { Top = 5, Left = 10 },
Size = new Vector2(30),
Alpha = 0,
TrackUrl = "https://b.ppy.sh/preview/" + SetInfo.OnlineBeatmapSetID + ".mp3",
},
});
PreviewPlaying.ValueChanged += newValue => playButton.FadeTo(newValue || IsHovered ? 1 : 0, 120, Easing.InOutQuint);
PreviewPlaying.ValueChanged += newValue => progressBar.FadeTo(newValue ? 1 : 0, 120, Easing.InOutQuint);
}
protected override void Update()
{
base.Update();
if (PreviewPlaying && playButton.Track != null)
progressBar.Width = (float)(playButton.Track.CurrentTime / playButton.Track.Length);
}
}
}