From f86cb30e47f07356286829544b7c2a136cc08057 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Wed, 17 Jan 2018 20:35:28 +0100 Subject: [PATCH 1/3] prevent negative width on progress bar --- osu.Game/Overlays/BeatmapSet/PreviewButton.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/PreviewButton.cs b/osu.Game/Overlays/BeatmapSet/PreviewButton.cs index 11d1769f1e..87cd6f7af6 100644 --- a/osu.Game/Overlays/BeatmapSet/PreviewButton.cs +++ b/osu.Game/Overlays/BeatmapSet/PreviewButton.cs @@ -15,6 +15,7 @@ using OpenTK; using OpenTK.Graphics; using osu.Game.Overlays.Direct; using osu.Framework.Configuration; +using System; namespace osu.Game.Overlays.BeatmapSet { @@ -82,7 +83,8 @@ namespace osu.Game.Overlays.BeatmapSet if (Playing.Value && preview != null) { - progress.Width = (float)(preview.CurrentTime / preview.Length); + // prevent negative (potential infinite) width if a track without length was loaded + progress.Width = (float)Math.Max(preview.CurrentTime / preview.Length, 0); } } From 65bac6d31aa80ad8974e3eb4c5eadb5ee9d4d165 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Wed, 17 Jan 2018 20:36:47 +0100 Subject: [PATCH 2/3] return preview instead of nothing if it exists already allows listening to it again after reaching the end --- osu.Game/Overlays/Direct/PlayButton.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Direct/PlayButton.cs b/osu.Game/Overlays/Direct/PlayButton.cs index 1646591f7f..c00fb9b122 100644 --- a/osu.Game/Overlays/Direct/PlayButton.cs +++ b/osu.Game/Overlays/Direct/PlayButton.cs @@ -150,7 +150,12 @@ namespace osu.Game.Overlays.Direct private void beginAudioLoad() { - if (trackLoader != null) return; + if (trackLoader != null) + { + Preview = trackLoader.Preview; + Playing.TriggerChange(); + return; + } loading = true; From 56619ae926e180bb408a01cabcfe28551236e4de Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Thu, 18 Jan 2018 15:53:53 +0100 Subject: [PATCH 3/3] use ternary expression --- osu.Game/Overlays/BeatmapSet/PreviewButton.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/PreviewButton.cs b/osu.Game/Overlays/BeatmapSet/PreviewButton.cs index 87cd6f7af6..4f5a6ba718 100644 --- a/osu.Game/Overlays/BeatmapSet/PreviewButton.cs +++ b/osu.Game/Overlays/BeatmapSet/PreviewButton.cs @@ -15,7 +15,6 @@ using OpenTK; using OpenTK.Graphics; using osu.Game.Overlays.Direct; using osu.Framework.Configuration; -using System; namespace osu.Game.Overlays.BeatmapSet { @@ -84,7 +83,7 @@ namespace osu.Game.Overlays.BeatmapSet if (Playing.Value && preview != null) { // prevent negative (potential infinite) width if a track without length was loaded - progress.Width = (float)Math.Max(preview.CurrentTime / preview.Length, 0); + progress.Width = preview.Length > 0 ? (float)(preview.CurrentTime / preview.Length) : 0f; } }