From 23d1c89a670b0426d414b197c83b74193c16e3d9 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Sun, 18 Jun 2017 20:12:28 +0200 Subject: [PATCH 01/24] Fix not applying song select preview seek --- osu.Game/Screens/Select/SongSelect.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index dc6dfdfd81..2ff0635be0 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -321,21 +321,19 @@ namespace osu.Game.Screens.Select if (beatmap.Equals(Beatmap?.BeatmapInfo)) return; - bool beatmapSetChange = false; + bool preview = beatmap.BeatmapSetInfoID != Beatmap.BeatmapInfo.BeatmapSetInfoID; + if (beatmap.BeatmapSetInfoID == selectionChangeNoBounce?.BeatmapSetInfoID) sampleChangeDifficulty.Play(); else - { sampleChangeBeatmap.Play(); - beatmapSetChange = true; - } selectionChangeNoBounce = beatmap; selectionChangedDebounce = Scheduler.AddDelayed(delegate { Beatmap = database.GetWorkingBeatmap(beatmap, Beatmap); - ensurePlayingSelected(beatmapSetChange); + ensurePlayingSelected(preview); }, 100); } @@ -346,6 +344,7 @@ namespace osu.Game.Screens.Select if (track != null) { trackManager.SetExclusive(track); + System.Diagnostics.Debug.WriteLine("Preview: {0}", preview); if (preview) track.Seek(Beatmap.Metadata.PreviewTime); track.Start(); From 3b3cc59471bfa83ea8968afbb9c014b849bf12b0 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Sun, 18 Jun 2017 20:21:24 +0200 Subject: [PATCH 02/24] Fix NullReferenceException --- osu.Game/Screens/Select/SongSelect.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 2ff0635be0..b5d50664fc 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -321,7 +321,7 @@ namespace osu.Game.Screens.Select if (beatmap.Equals(Beatmap?.BeatmapInfo)) return; - bool preview = beatmap.BeatmapSetInfoID != Beatmap.BeatmapInfo.BeatmapSetInfoID; + bool preview = beatmap.BeatmapSetInfoID != Beatmap?.BeatmapInfo.BeatmapSetInfoID; if (beatmap.BeatmapSetInfoID == selectionChangeNoBounce?.BeatmapSetInfoID) sampleChangeDifficulty.Play(); From a399b188379876b10f97f145a6314b5bb24dade5 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Mon, 19 Jun 2017 00:11:47 +0200 Subject: [PATCH 03/24] Removed debug line --- osu.Game/Screens/Select/SongSelect.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index b5d50664fc..801eb72ba5 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -344,7 +344,6 @@ namespace osu.Game.Screens.Select if (track != null) { trackManager.SetExclusive(track); - System.Diagnostics.Debug.WriteLine("Preview: {0}", preview); if (preview) track.Seek(Beatmap.Metadata.PreviewTime); track.Start(); From ce2242a979e900b19e7e3394f8ed2d4f02af9d11 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Thu, 22 Jun 2017 16:32:50 +0100 Subject: [PATCH 04/24] Removed dragbar from MusicController --- osu.Game/Overlays/MusicController.cs | 73 +++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index e1e920ec0f..35a683d1d4 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -8,12 +8,14 @@ using System.Threading.Tasks; using OpenTK; using OpenTK.Graphics; 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.Sprites; using osu.Framework.Graphics.Textures; +using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Framework.Localisation; using osu.Game.Beatmaps; @@ -38,7 +40,7 @@ namespace osu.Game.Overlays private const float bottom_black_area_height = 55; private Drawable currentBackground; - private DragBar progressBar; + private ProgressBar progressBar; private IconButton playButton; private IconButton playlistButton; @@ -183,13 +185,13 @@ namespace osu.Game.Overlays }, } }, - progressBar = new DragBar + progressBar = new ProgressBar { Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, Height = progress_height, - Colour = colours.Yellow, - SeekRequested = seek + FillColour = colours.Yellow, + OnSeek = progress => current?.Track.Seek(progress) } }, }, @@ -224,7 +226,7 @@ namespace osu.Game.Overlays { var track = current.Track; - progressBar.UpdatePosition(track.Length == 0 ? 0 : (float)(track.CurrentTime / track.Length)); + progressBar.Progress = track.CurrentTime; playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o; if (track.HasCompleted && !track.Looping) next(); @@ -266,8 +268,6 @@ namespace osu.Game.Overlays private void beatmapChanged(WorkingBeatmap beatmap) { - progressBar.IsEnabled = beatmap != null; - TransformDirection direction = TransformDirection.None; if (current != null) @@ -293,10 +293,19 @@ namespace osu.Game.Overlays current = beatmapBacking.Value; + updateProgressBar(current?.Track); updateDisplay(beatmapBacking, direction); queuedDirection = null; } + private void updateProgressBar(Track t) + { + if (t?.IsLoaded ?? false) + progressBar.EndTime = t.Length; + else if (t != null) + t.OnLoaded += loadedTrack => progressBar.EndTime = loadedTrack.Length; + } + private ScheduledDelegate pendingBeatmapSwitch; private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction) @@ -352,12 +361,6 @@ namespace osu.Game.Overlays }); } - private void seek(float position) - { - var track = current?.Track; - track?.Seek(track.Length * position); - } - protected override void PopIn() { base.PopIn(); @@ -417,5 +420,49 @@ namespace osu.Game.Overlays sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg4"); } } + + private class ProgressBar : SliderBar + { + public Action OnSeek; + + private Box fill; + + public Color4 FillColour + { + set { fill.Colour = value; } + } + + public double EndTime + { + set { CurrentNumber.MaxValue = value; } + } + + public double Progress + { + set { CurrentNumber.Value = value; } + } + + public ProgressBar() + { + CurrentNumber.MinValue = 0; + CurrentNumber.MaxValue = 1; + RelativeSizeAxes = Axes.X; + + Children = new Drawable[] + { + fill = new Box + { + RelativeSizeAxes = Axes.Y + } + }; + } + + protected override void UpdateValue(float value) + { + fill.Width = value * UsableWidth; + } + + protected override void OnUserChange() => OnSeek?.Invoke(Current); + } } } From 73c004fb71e9334ba6b6512b09098edac2350f8b Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Thu, 22 Jun 2017 17:42:29 +0100 Subject: [PATCH 05/24] Removed DragBar from song progress --- osu.Game/Overlays/DragBar.cs | 110 ------------------- osu.Game/Overlays/MusicController.cs | 6 +- osu.Game/Screens/Play/SongProgress.cs | 13 +-- osu.Game/Screens/Play/SongProgressBar.cs | 128 +++++++++++++++-------- osu.Game/osu.Game.csproj | 3 +- 5 files changed, 97 insertions(+), 163 deletions(-) delete mode 100644 osu.Game/Overlays/DragBar.cs diff --git a/osu.Game/Overlays/DragBar.cs b/osu.Game/Overlays/DragBar.cs deleted file mode 100644 index 07e0c76396..0000000000 --- a/osu.Game/Overlays/DragBar.cs +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Transforms; -using osu.Framework.Input; -using OpenTK; -using osu.Framework.Graphics.Shapes; - -namespace osu.Game.Overlays -{ - public class DragBar : Container - { - protected readonly Container Fill; - - public Action SeekRequested; - - public bool IsSeeking { get; private set; } - - private bool enabled = true; - public bool IsEnabled - { - get { return enabled; } - set - { - enabled = value; - if (!enabled) - Fill.Width = 0; - } - } - - public DragBar() - { - RelativeSizeAxes = Axes.X; - - Children = new Drawable[] - { - Fill = new Container - { - Name = "FillContainer", - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - RelativeSizeAxes = Axes.Both, - Width = 0, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both - } - } - } - }; - } - - public void UpdatePosition(float position) - { - if (IsSeeking || !IsEnabled) return; - - updatePosition(position, false); - } - - private void seek(InputState state) - { - float seekLocation = state.Mouse.Position.X / DrawWidth; - - if (!IsEnabled) return; - - SeekRequested?.Invoke(seekLocation); - updatePosition(seekLocation); - } - - private void updatePosition(float position, bool easing = true) - { - position = MathHelper.Clamp(position, 0, 1); - Fill.TransformTo(() => Fill.Width, position, easing ? 200 : 0, EasingTypes.OutQuint, new TransformSeek()); - } - - protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) - { - seek(state); - return true; - } - - protected override bool OnDrag(InputState state) - { - seek(state); - return true; - } - - protected override bool OnDragStart(InputState state) => IsSeeking = true; - - protected override bool OnDragEnd(InputState state) - { - IsSeeking = false; - return true; - } - - private class TransformSeek : TransformFloat - { - public override void Apply(Drawable d) - { - base.Apply(d); - d.Width = CurrentValue; - } - } - } -} diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 35a683d1d4..8e9ac22925 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -226,7 +226,7 @@ namespace osu.Game.Overlays { var track = current.Track; - progressBar.Progress = track.CurrentTime; + progressBar.CurrentTime = track.CurrentTime; playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o; if (track.HasCompleted && !track.Looping) next(); @@ -437,7 +437,7 @@ namespace osu.Game.Overlays set { CurrentNumber.MaxValue = value; } } - public double Progress + public double CurrentTime { set { CurrentNumber.Value = value; } } @@ -445,7 +445,7 @@ namespace osu.Game.Overlays public ProgressBar() { CurrentNumber.MinValue = 0; - CurrentNumber.MaxValue = 1; + CurrentNumber.MinValue = 1; RelativeSizeAxes = Axes.X; Children = new Drawable[] diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index e5b18292ab..5fc83eddb4 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -50,6 +50,9 @@ namespace osu.Game.Screens.Play info.StartTime = firstHitTime; info.EndTime = lastHitTime; + + bar.StartTime = firstHitTime; + bar.EndTime = lastHitTime; } } @@ -89,10 +92,7 @@ namespace osu.Game.Screens.Play Alpha = 0, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - SeekRequested = delegate (float position) - { - OnSeek?.Invoke(firstHitTime + position * (lastHitTime - firstHitTime)); - }, + OnSeek = position => this.OnSeek?.Invoke(position), }, }; } @@ -144,11 +144,12 @@ namespace osu.Game.Screens.Play if (objects == null) return; - double progress = ((audioClock?.CurrentTime ?? Time.Current) - firstHitTime) / (lastHitTime - firstHitTime); + double position = audioClock?.CurrentTime ?? Time.Current; + double progress = (position - firstHitTime) / (lastHitTime - firstHitTime); if (progress < 1) { - bar.UpdatePosition((float)progress); + bar.CurrentTime = position; graph.Progress = (int)(graph.ColumnCount * progress); } } diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index 730cf471da..84928f437a 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -1,74 +1,118 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using OpenTK; using OpenTK.Graphics; -using osu.Game.Overlays; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.UserInterface; namespace osu.Game.Screens.Play { - public class SongProgressBar : DragBar + public class SongProgressBar : SliderBar { + public Action OnSeek; + + private Box fill; + private Box background; + private Container handleBase; + public Color4 FillColour { - get { return Fill.Colour; } - set { Fill.Colour = value; } + set { fill.Colour = value; } + } + + public double StartTime + { + set { CurrentNumber.MinValue = value; } + } + + public double EndTime + { + set { CurrentNumber.MaxValue = value; } + } + + public double CurrentTime + { + set { CurrentNumber.Value = value; } } public SongProgressBar(float barHeight, float handleBarHeight, Vector2 handleSize) { + CurrentNumber.MinValue = 0; + CurrentNumber.MaxValue = 1; + + RelativeSizeAxes = Axes.X; Height = barHeight + handleBarHeight + handleSize.Y; - Fill.RelativeSizeAxes = Axes.X; - Fill.Height = barHeight; - - Add(new Box + Children = new Drawable[] { - Name = "Background", - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, - Height = barHeight, - Colour = Color4.Black, - Alpha = 0.5f, - Depth = 1 - }); - - Fill.Add(new Container - { - Origin = Anchor.BottomRight, - Anchor = Anchor.BottomRight, - Width = 2, - Height = barHeight + handleBarHeight, - Colour = Color4.White, - Position = new Vector2(2, 0), - Children = new Drawable[] + background = new Box { - new Box + Name = "Background", + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Height = barHeight, + Colour = Color4.Black, + Alpha = 0.5f, + Depth = 1, + }, + fill = new Box + { + Name = "Fill", + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Height = barHeight, + }, + handleBase = new Container + { + Name = "HandleBar container", + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + Width = 2, + Height = barHeight + handleBarHeight, + Colour = Color4.White, + Position = new Vector2(2, 0), + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - }, - new Container - { - Origin = Anchor.BottomCentre, - Anchor = Anchor.TopCentre, - Size = handleSize, - CornerRadius = 5, - Masking = true, - Children = new Drawable[] + new Box { - new Box + Name = "HandleBar box", + RelativeSizeAxes = Axes.Both, + }, + new Container + { + Name = "Handle container", + Origin = Anchor.BottomCentre, + Anchor = Anchor.TopCentre, + Size = handleSize, + CornerRadius = 5, + Masking = true, + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - Colour = Color4.White + new Box + { + Name = "Handle box", + RelativeSizeAxes = Axes.Both, + Colour = Color4.White + } } } } } - }); + }; } + + protected override void UpdateValue(float value) + { + var xFill = value * UsableWidth; + fill.Width = xFill; + handleBase.MoveToX(xFill); + } + + protected override void OnUserChange() => OnSeek?.Invoke(Current); } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 45dc47f842..4646eeb79d 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -214,7 +214,6 @@ - @@ -517,4 +516,4 @@ --> - \ No newline at end of file + From 62aae899fa6333c906d302cf23d115d98a705518 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Thu, 22 Jun 2017 19:03:31 +0100 Subject: [PATCH 06/24] Fixed non-assigned MaxValue --- osu.Game/Overlays/MusicController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 8e9ac22925..aec5e03b8f 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -445,7 +445,7 @@ namespace osu.Game.Overlays public ProgressBar() { CurrentNumber.MinValue = 0; - CurrentNumber.MinValue = 1; + CurrentNumber.MaxValue = 1; RelativeSizeAxes = Axes.X; Children = new Drawable[] From a327f49d68b72c8dd5fe322244c450a3a2721e66 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Fri, 23 Jun 2017 18:24:46 +0100 Subject: [PATCH 07/24] Updating progressBar.EndTime is more thread safe --- osu.Game/Overlays/MusicController.cs | 15 ++++++++++----- osu.Game/Screens/Play/SongProgress.cs | 3 +-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index aec5e03b8f..c9bbb97032 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -293,17 +293,22 @@ namespace osu.Game.Overlays current = beatmapBacking.Value; - updateProgressBar(current?.Track); + updateProgressBarLimit(current?.Track); updateDisplay(beatmapBacking, direction); queuedDirection = null; } - private void updateProgressBar(Track t) + private void updateProgressBarLimit(Track t) { - if (t?.IsLoaded ?? false) - progressBar.EndTime = t.Length; - else if (t != null) + if (t != null) + { t.OnLoaded += loadedTrack => progressBar.EndTime = loadedTrack.Length; + if (t.IsLoaded) + { + progressBar.EndTime = t.Length; + t.OnLoaded = null; + } + } } private ScheduledDelegate pendingBeatmapSwitch; diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 5fc83eddb4..ea91089aa4 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -12,7 +12,6 @@ using System.Linq; using osu.Framework.Timing; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; - namespace osu.Game.Screens.Play { public class SongProgress : OverlayContainer @@ -92,7 +91,7 @@ namespace osu.Game.Screens.Play Alpha = 0, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - OnSeek = position => this.OnSeek?.Invoke(position), + OnSeek = position => OnSeek?.Invoke(position), }, }; } From e16b646014e41262a797a4cdcad17e7d76aea3ab Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Sat, 24 Jun 2017 09:14:55 +0100 Subject: [PATCH 08/24] Add readonly to fill --- osu.Game/Overlays/MusicController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index c9bbb97032..72e2e3a36a 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -430,7 +430,7 @@ namespace osu.Game.Overlays { public Action OnSeek; - private Box fill; + private readonly Box fill; public Color4 FillColour { From a0262e32b1fb2a4fadf96da3c87d158619562f34 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Sat, 24 Jun 2017 09:15:53 +0100 Subject: [PATCH 09/24] CI Fixes --- osu.Game/Screens/Play/SongProgressBar.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index 84928f437a..7fabf2e80e 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -15,9 +15,8 @@ namespace osu.Game.Screens.Play { public Action OnSeek; - private Box fill; - private Box background; - private Container handleBase; + private readonly Box fill; + private readonly Container handleBase; public Color4 FillColour { @@ -49,7 +48,7 @@ namespace osu.Game.Screens.Play Children = new Drawable[] { - background = new Box + new Box { Name = "Background", Anchor = Anchor.BottomLeft, From 82217be9886beff7bd8bf2ae7eb0b5928eb05464 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 18 Jul 2017 15:24:45 +0900 Subject: [PATCH 10/24] Fix dodgy event clearing Also use local ariables where possible. --- osu.Game/Overlays/MusicController.cs | 33 +++++++++++++--------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 2149be09dd..47d305aecd 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Audio.Track; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -280,7 +279,7 @@ namespace osu.Game.Overlays if (current != null) { - bool audioEquals = beatmapBacking.Value?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false; + bool audioEquals = beatmap?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false; if (audioEquals) direction = TransformDirection.None; @@ -293,30 +292,28 @@ namespace osu.Game.Overlays { //figure out the best direction based on order in playlist. var last = playlist.BeatmapSets.TakeWhile(b => b.ID != current.BeatmapSetInfo.ID).Count(); - var next = beatmapBacking.Value == null ? -1 : playlist.BeatmapSets.TakeWhile(b => b.ID != beatmapBacking.Value.BeatmapSetInfo.ID).Count(); + var next = beatmap == null ? -1 : playlist.BeatmapSets.TakeWhile(b => b.ID != beatmap.BeatmapSetInfo.ID).Count(); direction = last > next ? TransformDirection.Prev : TransformDirection.Next; } } - current = beatmapBacking.Value; + current = beatmap; - updateProgressBarLimit(current?.Track); - updateDisplay(beatmapBacking, direction); - queuedDirection = null; - } - - private void updateProgressBarLimit(Track t) - { - if (t != null) + var track = current?.Track; + if (track != null) { - t.OnLoaded += loadedTrack => progressBar.EndTime = loadedTrack.Length; - if (t.IsLoaded) - { - progressBar.EndTime = t.Length; - t.OnLoaded = null; - } + // the track may not be loaded at this point + track.OnLoaded += loadedTrack => Schedule(() => progressBar.EndTime = loadedTrack.Length); + + if (track.IsLoaded) + // but it also may be. + progressBar.EndTime = track.Length; } + + updateDisplay(beatmap, direction); + + queuedDirection = null; } private ScheduledDelegate pendingBeatmapSwitch; From 4b4b03756a1a8ee0b40f4d647b108ae9bcd53cd2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 18 Jul 2017 15:36:05 +0900 Subject: [PATCH 11/24] Don't use dodgy OnLoaded "event" --- osu.Game/Overlays/MusicController.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 47d305aecd..0da425652a 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -229,7 +229,9 @@ namespace osu.Game.Overlays { var track = current.Track; + progressBar.EndTime = track.Length; progressBar.CurrentTime = track.CurrentTime; + playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o; if (track.HasCompleted && !track.Looping) next(); @@ -300,18 +302,9 @@ namespace osu.Game.Overlays current = beatmap; - var track = current?.Track; - if (track != null) - { - // the track may not be loaded at this point - track.OnLoaded += loadedTrack => Schedule(() => progressBar.EndTime = loadedTrack.Length); + progressBar.CurrentTime = 0; - if (track.IsLoaded) - // but it also may be. - progressBar.EndTime = track.Length; - } - - updateDisplay(beatmap, direction); + updateDisplay(current, direction); queuedDirection = null; } From e72c009dd73dd81e5add4c8b5ba6e903e6a406c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 18 Jul 2017 10:53:41 +0300 Subject: [PATCH 12/24] Highlight custom-named users --- osu-framework | 2 +- osu.Game/Overlays/Chat/ChatLine.cs | 50 +++++++++++++++++++----------- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/osu-framework b/osu-framework index 991177da4f..9669c3e067 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 991177da4fbed2dd8260c215f2d341ebc858b03e +Subproject commit 9669c3e06715330e1c8544676caf7fbc0328e92d diff --git a/osu.Game/Overlays/Chat/ChatLine.cs b/osu.Game/Overlays/Chat/ChatLine.cs index 3aaca7593c..d05284774b 100644 --- a/osu.Game/Overlays/Chat/ChatLine.cs +++ b/osu.Game/Overlays/Chat/ChatLine.cs @@ -8,6 +8,8 @@ using osu.Game.Graphics.Sprites; using osu.Game.Online.Chat; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Effects; namespace osu.Game.Overlays.Chat { @@ -53,15 +55,6 @@ namespace osu.Game.Overlays.Chat OsuColour.FromHex("992861"), }; - private Color4 getUsernameColour(Message message) - { - if (!string.IsNullOrEmpty(message.Sender?.Colour)) - return OsuColour.FromHex(message.Sender.Colour); - - //todo: use User instead of Message when user_id is correctly populated. - return username_colours[message.UserId % username_colours.Length]; - } - public const float LEFT_PADDING = message_padding + padding * 2; private const float padding = 15; @@ -77,6 +70,35 @@ namespace osu.Game.Overlays.Chat Padding = new MarginPadding { Left = padding, Right = padding }; + bool hasBackground = !string.IsNullOrEmpty(message.Sender?.Colour); + Drawable username = new OsuSpriteText + { + Origin = Anchor.TopRight, + Anchor = Anchor.TopRight, + Font = @"Exo2.0-BoldItalic", + Text = $@"{Message.Sender.Username}:", + Colour = hasBackground ? Color4.Black : username_colours[message.UserId % username_colours.Length], + TextSize = text_size, + }; + + if (hasBackground) + { + username = username.WithEffect(new EdgeEffect + { + CornerRadius = 4, + Parameters = new EdgeEffectParameters + { + Radius = 1, + Colour = OsuColour.FromHex(message.Sender.Colour), + Type = EdgeEffectType.Shadow, + } + }, d => + { + d.Padding = new MarginPadding { Top = -2 }; + d.Y = 2; + }); + } + Children = new Drawable[] { new Container @@ -94,15 +116,7 @@ namespace osu.Game.Overlays.Chat TextSize = text_size * 0.75f, Alpha = 0.4f, }, - new OsuSpriteText - { - Font = @"Exo2.0-BoldItalic", - Text = $@"{Message.Sender.Username}:", - Colour = getUsernameColour(Message), - TextSize = text_size, - Origin = Anchor.TopRight, - Anchor = Anchor.TopRight, - } + username } }, new Container From 52acd23a5af03b7936e064ce2165d84b2ad9c10a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 18 Jul 2017 10:54:57 +0300 Subject: [PATCH 13/24] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 9669c3e067..2a3b245da9 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 9669c3e06715330e1c8544676caf7fbc0328e92d +Subproject commit 2a3b245da9eff604be09d473203f829690d2808c From 7acff29bd377034481dfa637bcad93ae98d67757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 18 Jul 2017 11:53:56 +0300 Subject: [PATCH 14/24] Fix OsuTooltipContainer.PopIn not overriding PopOut transforms --- osu-framework | 2 +- osu.Game/Graphics/Cursor/OsuTooltipContainer.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 991177da4f..145cee6105 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 991177da4fbed2dd8260c215f2d341ebc858b03e +Subproject commit 145cee6105af742ddfd0c7ef147f72a3fcd8dc63 diff --git a/osu.Game/Graphics/Cursor/OsuTooltipContainer.cs b/osu.Game/Graphics/Cursor/OsuTooltipContainer.cs index 7608a366dc..44d176f4d9 100644 --- a/osu.Game/Graphics/Cursor/OsuTooltipContainer.cs +++ b/osu.Game/Graphics/Cursor/OsuTooltipContainer.cs @@ -83,6 +83,8 @@ namespace osu.Game.Graphics.Cursor protected override void PopIn() { instantMovement |= !IsPresent; + + ClearTransforms(); FadeIn(500, EasingTypes.OutQuint); } From b2dd43075f0fd42b2af71ff5d4ae9fc534fb9e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 18 Jul 2017 11:57:41 +0300 Subject: [PATCH 15/24] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 145cee6105..2a3b245da9 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 145cee6105af742ddfd0c7ef147f72a3fcd8dc63 +Subproject commit 2a3b245da9eff604be09d473203f829690d2808c From e58ea97604b25b169ba655a00e0cd9273cd8d1b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 18 Jul 2017 12:26:05 +0300 Subject: [PATCH 16/24] Improve design as requested --- osu.Game/Overlays/Chat/ChatLine.cs | 44 ++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatLine.cs b/osu.Game/Overlays/Chat/ChatLine.cs index d05284774b..6985781c0d 100644 --- a/osu.Game/Overlays/Chat/ChatLine.cs +++ b/osu.Game/Overlays/Chat/ChatLine.cs @@ -8,8 +8,9 @@ using osu.Game.Graphics.Sprites; using osu.Game.Online.Chat; using OpenTK; using OpenTK.Graphics; -using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Effects; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Allocation; namespace osu.Game.Overlays.Chat { @@ -61,6 +62,8 @@ namespace osu.Game.Overlays.Chat private const float message_padding = 200; private const float text_size = 20; + private Color4 customUsernameColour; + public ChatLine(Message message) { Message = message; @@ -69,33 +72,58 @@ namespace osu.Game.Overlays.Chat AutoSizeAxes = Axes.Y; Padding = new MarginPadding { Left = padding, Right = padding }; + } - bool hasBackground = !string.IsNullOrEmpty(message.Sender?.Colour); + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + customUsernameColour = colours.ChatBlue; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + bool hasBackground = !string.IsNullOrEmpty(Message.Sender?.Colour); Drawable username = new OsuSpriteText { Origin = Anchor.TopRight, Anchor = Anchor.TopRight, Font = @"Exo2.0-BoldItalic", - Text = $@"{Message.Sender.Username}:", - Colour = hasBackground ? Color4.Black : username_colours[message.UserId % username_colours.Length], + Text = $@"{Message.Sender.Username}" + (hasBackground ? "" : ":"), + Colour = hasBackground ? customUsernameColour : username_colours[Message.UserId % username_colours.Length], TextSize = text_size, }; if (hasBackground) { + // Background effect username = username.WithEffect(new EdgeEffect { CornerRadius = 4, Parameters = new EdgeEffectParameters { Radius = 1, - Colour = OsuColour.FromHex(message.Sender.Colour), + Colour = OsuColour.FromHex(Message.Sender.Colour), Type = EdgeEffectType.Shadow, } }, d => { - d.Padding = new MarginPadding { Top = -2 }; - d.Y = 2; + d.Padding = new MarginPadding { Left = 3, Right = 3, Bottom = 1, Top = -3 }; + d.Y = 3; + }) + // Drop shadow effect + .WithEffect(new EdgeEffect + { + CornerRadius = 4, + Parameters = new EdgeEffectParameters + { + Roundness = 1, + Offset = new Vector2(0, 3), + Radius = 3, + Colour = Color4.Black.Opacity(0.3f), + Type = EdgeEffectType.Shadow, + } }); } @@ -104,7 +132,7 @@ namespace osu.Game.Overlays.Chat new Container { Size = new Vector2(message_padding, text_size), - Children = new Drawable[] + Children = new[] { new OsuSpriteText { From fce5a191f10b47666aeb9ce98efd226fd94e6acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 18 Jul 2017 12:26:27 +0300 Subject: [PATCH 17/24] Migrate padding into the scroll content to not cut off effects --- osu.Game/Overlays/Chat/DrawableChannel.cs | 3 +++ osu.Game/Overlays/ChatOverlay.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Chat/DrawableChannel.cs b/osu.Game/Overlays/Chat/DrawableChannel.cs index e51f931959..8a2fa95ed1 100644 --- a/osu.Game/Overlays/Chat/DrawableChannel.cs +++ b/osu.Game/Overlays/Chat/DrawableChannel.cs @@ -29,6 +29,9 @@ namespace osu.Game.Overlays.Chat scroll = new OsuScrollContainer { RelativeSizeAxes = Axes.Both, + // Some chat lines have effects that slightly protrude to the bottom, + // which we do not want to mask away, hence the padding. + Padding = new MarginPadding { Bottom = 5 }, Children = new Drawable[] { flow = new FillFlowContainer diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 700889ed26..1f9f7e57ca 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -111,7 +111,7 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { - Bottom = textbox_height + padding + Bottom = textbox_height }, }, new Container From a225b542d5a36aa6886d5e89fd718f6dd3c3ecb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 18 Jul 2017 12:35:36 +0300 Subject: [PATCH 18/24] Sender is always non-null --- osu.Game/Overlays/Chat/ChatLine.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Chat/ChatLine.cs b/osu.Game/Overlays/Chat/ChatLine.cs index 6985781c0d..198a2a9419 100644 --- a/osu.Game/Overlays/Chat/ChatLine.cs +++ b/osu.Game/Overlays/Chat/ChatLine.cs @@ -84,7 +84,7 @@ namespace osu.Game.Overlays.Chat { base.LoadComplete(); - bool hasBackground = !string.IsNullOrEmpty(Message.Sender?.Colour); + bool hasBackground = !string.IsNullOrEmpty(Message.Sender.Colour); Drawable username = new OsuSpriteText { Origin = Anchor.TopRight, From 5761eb30a04a9fb6095a1b1c936540c3714a8f0d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 18 Jul 2017 16:06:59 +0900 Subject: [PATCH 19/24] Fix nullref error on re-importing a DeletePending beatmap Callback was expecting the beatmap to be populated where it wasn't being. --- osu.Game/Database/BeatmapDatabase.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index efd5631077..1a36e7fa0f 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -178,6 +178,8 @@ namespace osu.Game.Database if (existing != null) { + GetChildren(existing); + if (existing.DeletePending) { existing.DeletePending = false; From f00140f0a45e1bb9fee790c94649388dc265fe24 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 18 Jul 2017 16:11:23 +0900 Subject: [PATCH 20/24] Avoid crashes on attempting to import the same path twice in quick succession --- osu.Game/Database/BeatmapDatabase.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 1a36e7fa0f..43769f67b5 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -144,7 +144,11 @@ namespace osu.Game.Database public void Import(params string[] paths) { foreach (string p in paths) - Import(p); + { + //In case the file was imported twice and deleted after the first time + if (File.Exists(p)) + Import(p); + } } /// From 6f59e5feec4bf12c88c729e2b93d0d9f06a0f2e6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 18 Jul 2017 16:16:01 +0900 Subject: [PATCH 21/24] Add null check on stream --- osu.Game/Beatmaps/IO/OszArchiveReader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/IO/OszArchiveReader.cs b/osu.Game/Beatmaps/IO/OszArchiveReader.cs index eb9e740779..a22a5f4cce 100644 --- a/osu.Game/Beatmaps/IO/OszArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/OszArchiveReader.cs @@ -15,7 +15,7 @@ namespace osu.Game.Beatmaps.IO AddReader((storage, path) => { using (var stream = storage.GetStream(path)) - return ZipFile.IsZipFile(stream, false); + return stream != null && ZipFile.IsZipFile(stream, false); }); OsuLegacyDecoder.Register(); } From 2b1e19814c2b282244526b2943eb28cc859b0035 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 19 Jul 2017 16:07:11 +0900 Subject: [PATCH 22/24] Side flashes should not be affected by parallax --- osu.Game/Screens/Menu/MainMenu.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 5a2e0a7b12..f4cb6dba7b 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -49,10 +49,10 @@ namespace osu.Game.Screens.Menu OnSolo = delegate { Push(consumeSongSelect()); }, OnMulti = delegate { Push(new Lobby()); }, OnExit = delegate { Exit(); }, - }, - new MenuSideFlashes(), + } } - } + }, + new MenuSideFlashes(), }; } From 2a2f4e2a8b8e86ccf671c539690bc9c11c1e3384 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 19 Jul 2017 16:13:01 +0900 Subject: [PATCH 23/24] Ensure side flashes are not visible during moving transitions --- osu.Game/Screens/Menu/MainMenu.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index f4cb6dba7b..d5526532cb 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -28,6 +28,8 @@ namespace osu.Game.Screens.Menu private readonly BackgroundScreenDefault background; private Screen songSelect; + private MenuSideFlashes sideFlashes; + protected override BackgroundScreen CreateBackground() => background; public MainMenu() @@ -52,7 +54,7 @@ namespace osu.Game.Screens.Menu } } }, - new MenuSideFlashes(), + sideFlashes = new MenuSideFlashes(), }; } @@ -112,6 +114,8 @@ namespace osu.Game.Screens.Menu Content.FadeOut(length, EasingTypes.InSine); Content.MoveTo(new Vector2(-800, 0), length, EasingTypes.InSine); + + sideFlashes.FadeOut(length / 4, EasingTypes.OutQuint); } protected override void OnResuming(Screen last) @@ -129,6 +133,8 @@ namespace osu.Game.Screens.Menu Content.FadeIn(length, EasingTypes.OutQuint); Content.MoveTo(new Vector2(0, 0), length, EasingTypes.OutQuint); + + sideFlashes.FadeIn(length / 4, EasingTypes.InQuint); } protected override bool OnExiting(Screen next) From c34856922c40039b2e0e533c05927d20527fcf68 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 19 Jul 2017 16:34:18 +0900 Subject: [PATCH 24/24] Gratify CI --- osu.Game/Screens/Menu/MainMenu.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index d5526532cb..42d435ef88 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -28,7 +28,7 @@ namespace osu.Game.Screens.Menu private readonly BackgroundScreenDefault background; private Screen songSelect; - private MenuSideFlashes sideFlashes; + private readonly MenuSideFlashes sideFlashes; protected override BackgroundScreen CreateBackground() => background;