From 7dcbefd50fafecdf27f8ab84019bd3515957cb98 Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Fri, 17 Feb 2017 17:41:53 +0100 Subject: [PATCH 01/14] Implemented basic sorting logic --- osu.Game/Screens/Select/CarouselContainer.cs | 38 ++++++++++++++++++++ osu.Game/Screens/Select/FilterControl.cs | 8 ++--- osu.Game/Screens/Select/PlaySongSelect.cs | 2 ++ 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 86cfc897638d..260f2d0998c0 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -184,6 +184,44 @@ public void SelectGroup(BeatmapGroup group, BeatmapPanel panel, bool animated = ScrollTo(selectedY, animated); } + public void Sort(FilterControl.SortMode mode) { + switch (mode) { + case FilterControl.SortMode.Artist: + groups.Sort((x, y) => + { + return string.Compare(x.BeatmapSet.Metadata.Artist, y.BeatmapSet.Metadata.Artist); + }); + break; + case FilterControl.SortMode.Title: + groups.Sort((x, y) => + { + return string.Compare(x.BeatmapSet.Metadata.Title, y.BeatmapSet.Metadata.Title); + }); + break; + case FilterControl.SortMode.Author: + groups.Sort((x, y) => + { + return string.Compare(x.BeatmapSet.Metadata.Author, y.BeatmapSet.Metadata.Author); + }); + break; + case FilterControl.SortMode.Difficulty: + groups.Sort((x, y) => + { + if (x.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty > + y.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty) + return 1; + else if (Equals(x.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty, + y.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty)) + return 0; + else + return -1; + }); + break; + default: + throw new NotImplementedException(); + } + } + private static float offsetX(float dist, float halfHeight) { // The radius of the circle the carousel moves on. diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 975a3f9ca337..e4af7b8d02d3 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -250,9 +250,9 @@ private void load(OsuColour colours) public enum SortMode { - Arist, + Artist, BPM, - Creator, + Author, DateAdded, Difficulty, Length, @@ -263,9 +263,9 @@ public enum SortMode public enum GroupMode { NoGrouping, - Arist, + Artist, BPM, - Creator, + Author, DateAdded, Difficulty, Length, diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index e206c5d5fa95..edd3880a363f 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -174,6 +174,7 @@ private void filterChanged() filterTask = null; var search = filter.Search; BeatmapGroup newSelection = null; + carousel.Sort(filter.Sort); foreach (var beatmapGroup in carousel) { var set = beatmapGroup.BeatmapSet; @@ -373,6 +374,7 @@ private void addBeatmapSets(BaseGame game, CancellationToken token) if (token.IsCancellationRequested) return; addBeatmapSet(beatmapSet, game); } + filterChanged(); } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) From 6b3ecc28b87f58bd4f9ebdff9def1584c5d2719a Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Fri, 17 Feb 2017 23:32:14 +0100 Subject: [PATCH 02/14] Fixed BeatmapPanels disappearing --- osu.Game/Screens/Select/CarouselContainer.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 260f2d0998c0..9ffc5a183a27 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -176,6 +176,7 @@ public void SelectGroup(BeatmapGroup group, BeatmapPanel panel, bool animated = if (SelectedGroup != null && SelectedGroup != group && SelectedGroup.State != BeatmapGroupState.Hidden) SelectedGroup.State = BeatmapGroupState.Collapsed; + group.State = BeatmapGroupState.Expanded; SelectedGroup = group; panel.State = PanelSelectedState.Selected; SelectedPanel = panel; @@ -220,6 +221,20 @@ public void Sort(FilterControl.SortMode mode) { default: throw new NotImplementedException(); } + scrollableContent.Clear(false); + lifetime.Clear(); + foreach (BeatmapGroup group in groups) + { + group.Header.Depth = -scrollableContent.Children.Count(); + scrollableContent.Add(group.Header); + + foreach (BeatmapPanel panel in group.BeatmapPanels) + { + panel.Depth = -scrollableContent.Children.Count(); + scrollableContent.Add(panel); + } + } + SelectGroup(groups.FirstOrDefault(), groups.First().BeatmapPanels.FirstOrDefault()); } private static float offsetX(float dist, float halfHeight) From 1cd93f79b378898feb13ac0142d4be53ff8c5751 Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Sat, 18 Feb 2017 07:59:01 +0100 Subject: [PATCH 03/14] General sorting improvements --- osu.Game/Screens/Select/CarouselContainer.cs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 9ffc5a183a27..a121d4b3ebf1 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -188,26 +188,18 @@ public void SelectGroup(BeatmapGroup group, BeatmapPanel panel, bool animated = public void Sort(FilterControl.SortMode mode) { switch (mode) { case FilterControl.SortMode.Artist: - groups.Sort((x, y) => - { - return string.Compare(x.BeatmapSet.Metadata.Artist, y.BeatmapSet.Metadata.Artist); - }); + groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Artist, y.BeatmapSet.Metadata.Artist)); break; case FilterControl.SortMode.Title: - groups.Sort((x, y) => - { - return string.Compare(x.BeatmapSet.Metadata.Title, y.BeatmapSet.Metadata.Title); - }); + groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Title, y.BeatmapSet.Metadata.Title)); break; case FilterControl.SortMode.Author: - groups.Sort((x, y) => - { - return string.Compare(x.BeatmapSet.Metadata.Author, y.BeatmapSet.Metadata.Author); - }); + groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Author, y.BeatmapSet.Metadata.Author)); break; case FilterControl.SortMode.Difficulty: groups.Sort((x, y) => { + // TODO: replace with star rating once implemented if (x.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty > y.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty) return 1; From 6bbbbd8f969612653666d197d74798e9b3cf3f2a Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Sat, 18 Feb 2017 15:11:40 +0100 Subject: [PATCH 04/14] Implemented sorting in TestCasePlaySong --- .../Tests/TestCasePlaySongSelect.cs | 25 ++++++++++++++++--- osu.Game/Screens/Select/CarouselContainer.cs | 7 +++--- osu.Game/Screens/Select/FilterControl.cs | 10 +++++++- osu.Game/Screens/Select/PlaySongSelect.cs | 6 ++++- 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs index 47fac4d33924..009d7b8830d2 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Collections.Generic; using osu.Desktop.VisualTests.Platform; using osu.Framework.GameModes.Testing; @@ -14,10 +15,17 @@ class TestCasePlaySongSelect : TestCase { private BeatmapDatabase db, oldDb; private TestStorage storage; + private Random rnd = new Random(); + private PlaySongSelect SongSelect = new PlaySongSelect(); public override string Name => @"Song Select"; public override string Description => @"with fake data"; + public Action OnArtist; + public Action OnTitle; + public Action OnAuthor; + public Action OnDifficulty; + public override void Reset() { base.Reset(); @@ -35,6 +43,16 @@ public override void Reset() db.Import(sets); } + OnArtist = () => SongSelect.Filter.Sort = FilterControl.SortMode.Artist; + OnTitle = () => SongSelect.Filter.Sort = FilterControl.SortMode.Title; + OnAuthor = () => SongSelect.Filter.Sort = FilterControl.SortMode.Author; + OnDifficulty = () => SongSelect.Filter.Sort = FilterControl.SortMode.Difficulty; + + AddButton(@"Sort by Artist", OnArtist); + AddButton(@"Sort by Artist", OnTitle); + AddButton(@"Sort by Artist", OnAuthor); + AddButton(@"Sort by Artist", OnDifficulty); + Add(new PlaySongSelect()); } @@ -59,9 +77,10 @@ private BeatmapSetInfo createTestBeatmapSet(int i) Metadata = new BeatmapMetadata { OnlineBeatmapSetID = 1234 + i, - Artist = "MONACA", - Title = "Black Song", - Author = "Some Guy", + // Create random metadata, then we can check if sorting works based on these + Artist = "MONACA " + rnd.Next(0, 9), + Title = "Black Song " + rnd.Next(0, 9), + Author = "Some Guy " + rnd.Next(0, 9), }, Beatmaps = new List(new[] { diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index a121d4b3ebf1..8a346543ba9b 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -199,13 +199,12 @@ public void Sort(FilterControl.SortMode mode) { case FilterControl.SortMode.Difficulty: groups.Sort((x, y) => { - // TODO: replace with star rating once implemented + /*TODO: replace with star rating once implemented + * Assumes BeatmapSets not to be grouped - or to be by difficulty, + * otherwise this sorting makes little sense - or does it? */ if (x.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty > y.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty) return 1; - else if (Equals(x.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty, - y.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty)) - return 0; else return -1; }); diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index e4af7b8d02d3..c660ce48f0cb 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -21,7 +21,15 @@ public class FilterControl : Container public Action FilterChanged; public string Search => searchTextBox.Text; - public SortMode Sort { get; private set; } = SortMode.Title; + private SortMode sort = SortMode.Title; + public SortMode Sort { + get { return sort; } + set { + sort = value; + FilterChanged?.Invoke(); + } + } + public Action Exit; private SearchTextBox searchTextBox; diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index edd3880a363f..82a93c70d2d0 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -54,8 +54,12 @@ public class PlaySongSelect : OsuGameMode private Footer footer; + private FilterControl filter; + public FilterControl Filter { + get; private set; + } + Player player; - FilterControl filter; private void start() { From f48c83b787c040fe28c558f298ac5f058d4dd9d5 Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Sat, 18 Feb 2017 15:56:29 +0100 Subject: [PATCH 05/14] Fix silly sorting mistakes --- .../Tests/TestCasePlaySongSelect.cs | 18 +++++++++--------- osu.Game/Screens/Select/FilterControl.cs | 7 +++++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs index b41d48b99a9a..47fc86ca8429 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs @@ -43,19 +43,19 @@ public override void Reset() db.Import(sets); } - OnArtist = () => SongSelect.Filter.Sort = FilterControl.SortMode.Artist; - OnTitle = () => SongSelect.Filter.Sort = FilterControl.SortMode.Title; - OnAuthor = () => SongSelect.Filter.Sort = FilterControl.SortMode.Author; - OnDifficulty = () => SongSelect.Filter.Sort = FilterControl.SortMode.Difficulty; + OnArtist = () => { SongSelect.Filter.Sort = FilterControl.SortMode.Artist; }; + OnTitle = () => { SongSelect.Filter.Sort = FilterControl.SortMode.Title; }; + OnAuthor = () => { SongSelect.Filter.Sort = FilterControl.SortMode.Author; }; + OnDifficulty = () => { SongSelect.Filter.Sort = FilterControl.SortMode.Difficulty; }; AddButton(@"Sort by Artist", OnArtist); - AddButton(@"Sort by Artist", OnTitle); - AddButton(@"Sort by Artist", OnAuthor); - AddButton(@"Sort by Artist", OnDifficulty); + AddButton(@"Sort by Title", OnTitle); + AddButton(@"Sort by Author", OnAuthor); + AddButton(@"Sort by Difficulty", OnDifficulty); - Add(new PlaySongSelect()); + Add(SongSelect); } - + protected override void Dispose(bool isDisposing) { if (oldDb != null) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index c660ce48f0cb..b2c13a980e24 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -25,8 +25,11 @@ public class FilterControl : Container public SortMode Sort { get { return sort; } set { - sort = value; - FilterChanged?.Invoke(); + if (sort != value) + { + sort = value; + FilterChanged?.Invoke(); + } } } From 21cf96ec1009f2481e8bb7ec0a79a4d8a55fc0e2 Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Sat, 18 Feb 2017 16:23:13 +0100 Subject: [PATCH 06/14] More sorting rookie mistakes --- .../Tests/TestCasePlaySongSelect.cs | 6 +++--- osu.Game/Screens/Select/PlaySongSelect.cs | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs index 47fc86ca8429..e0e5b2cc823b 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs @@ -16,7 +16,7 @@ class TestCasePlaySongSelect : TestCase private BeatmapDatabase db, oldDb; private TestStorage storage; private Random rnd = new Random(); - private PlaySongSelect SongSelect = new PlaySongSelect(); + private PlaySongSelect SongSelect; public override string Name => @"Song Select"; public override string Description => @"with fake data"; @@ -43,6 +43,8 @@ public override void Reset() db.Import(sets); } + + Add(SongSelect = new PlaySongSelect()); OnArtist = () => { SongSelect.Filter.Sort = FilterControl.SortMode.Artist; }; OnTitle = () => { SongSelect.Filter.Sort = FilterControl.SortMode.Title; }; OnAuthor = () => { SongSelect.Filter.Sort = FilterControl.SortMode.Author; }; @@ -52,8 +54,6 @@ public override void Reset() AddButton(@"Sort by Title", OnTitle); AddButton(@"Sort by Author", OnAuthor); AddButton(@"Sort by Difficulty", OnDifficulty); - - Add(SongSelect); } protected override void Dispose(bool isDisposing) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 56d904c155c0..2291daa1c616 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -56,7 +56,15 @@ public class PlaySongSelect : OsuScreen private FilterControl filter; public FilterControl Filter { - get; private set; + get { + return filter; + } + private set { + if (filter != value) { + filter = value; + filterChanged(); + } + } } Player player; From 87ec0e36ea0a07654c9dd9627f411286bbd883fe Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Sat, 18 Feb 2017 16:45:46 +0100 Subject: [PATCH 07/14] Complying with rule "Instance fields (private)" --- .../Tests/TestCasePlaySongSelect.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs index e0e5b2cc823b..52b78267d678 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs @@ -16,7 +16,7 @@ class TestCasePlaySongSelect : TestCase private BeatmapDatabase db, oldDb; private TestStorage storage; private Random rnd = new Random(); - private PlaySongSelect SongSelect; + private PlaySongSelect songSelect; public override string Name => @"Song Select"; public override string Description => @"with fake data"; @@ -44,11 +44,11 @@ public override void Reset() db.Import(sets); } - Add(SongSelect = new PlaySongSelect()); - OnArtist = () => { SongSelect.Filter.Sort = FilterControl.SortMode.Artist; }; - OnTitle = () => { SongSelect.Filter.Sort = FilterControl.SortMode.Title; }; - OnAuthor = () => { SongSelect.Filter.Sort = FilterControl.SortMode.Author; }; - OnDifficulty = () => { SongSelect.Filter.Sort = FilterControl.SortMode.Difficulty; }; + Add(songSelect = new PlaySongSelect()); + OnArtist = () => { songSelect.Filter.Sort = FilterControl.SortMode.Artist; }; + OnTitle = () => { songSelect.Filter.Sort = FilterControl.SortMode.Title; }; + OnAuthor = () => { songSelect.Filter.Sort = FilterControl.SortMode.Author; }; + OnDifficulty = () => { songSelect.Filter.Sort = FilterControl.SortMode.Difficulty; }; AddButton(@"Sort by Artist", OnArtist); AddButton(@"Sort by Title", OnTitle); From a6fbfc8349bf57d31ccd3479f6648f0526110c67 Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Mon, 20 Feb 2017 17:49:02 +0100 Subject: [PATCH 08/14] Using random generator from osu-framework --- osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs index 52b78267d678..9fad8992d2da 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using osu.Desktop.VisualTests.Platform; using osu.Framework.Screens.Testing; +using osu.Framework.MathUtils; using osu.Game.Database; using osu.Game.Modes; using osu.Game.Screens.Select; @@ -15,7 +16,6 @@ class TestCasePlaySongSelect : TestCase { private BeatmapDatabase db, oldDb; private TestStorage storage; - private Random rnd = new Random(); private PlaySongSelect songSelect; public override string Name => @"Song Select"; @@ -78,9 +78,9 @@ private BeatmapSetInfo createTestBeatmapSet(int i) { OnlineBeatmapSetID = 1234 + i, // Create random metadata, then we can check if sorting works based on these - Artist = "MONACA " + rnd.Next(0, 9), - Title = "Black Song " + rnd.Next(0, 9), - Author = "Some Guy " + rnd.Next(0, 9), + Artist = "MONACA " + RNG.Next(0, 9), + Title = "Black Song " + RNG.Next(0, 9), + Author = "Some Guy " + RNG.Next(0, 9), }, Beatmaps = new List(new[] { From 3d19199218b72e70e8e5f4ba94c55031eaf08846 Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Tue, 21 Feb 2017 18:27:39 +0100 Subject: [PATCH 09/14] Fixed for star difficulty --- osu.Game/Screens/Select/CarouselContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 8a346543ba9b..f4d2842638ec 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -202,8 +202,8 @@ public void Sort(FilterControl.SortMode mode) { /*TODO: replace with star rating once implemented * Assumes BeatmapSets not to be grouped - or to be by difficulty, * otherwise this sorting makes little sense - or does it? */ - if (x.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty > - y.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty) + if (x.BeatmapSet.Beatmaps.First().StarDifficulty > + y.BeatmapSet.Beatmaps.First().StarDifficulty) return 1; else return -1; From fbb16295ae4445a941ec508ee70b59ccf627ddfe Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Tue, 21 Feb 2017 18:43:10 +0100 Subject: [PATCH 10/14] Improved delegate syntax --- .../Tests/TestCasePlaySongSelect.cs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs index 9fad8992d2da..6cc2d624027a 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs @@ -21,11 +21,6 @@ class TestCasePlaySongSelect : TestCase public override string Name => @"Song Select"; public override string Description => @"with fake data"; - public Action OnArtist; - public Action OnTitle; - public Action OnAuthor; - public Action OnDifficulty; - public override void Reset() { base.Reset(); @@ -45,15 +40,11 @@ public override void Reset() } Add(songSelect = new PlaySongSelect()); - OnArtist = () => { songSelect.Filter.Sort = FilterControl.SortMode.Artist; }; - OnTitle = () => { songSelect.Filter.Sort = FilterControl.SortMode.Title; }; - OnAuthor = () => { songSelect.Filter.Sort = FilterControl.SortMode.Author; }; - OnDifficulty = () => { songSelect.Filter.Sort = FilterControl.SortMode.Difficulty; }; - AddButton(@"Sort by Artist", OnArtist); - AddButton(@"Sort by Title", OnTitle); - AddButton(@"Sort by Author", OnAuthor); - AddButton(@"Sort by Difficulty", OnDifficulty); + AddButton(@"Sort by Artist", delegate { songSelect.Filter.Sort = FilterControl.SortMode.Artist; }); + AddButton(@"Sort by Title", delegate { songSelect.Filter.Sort = FilterControl.SortMode.Title; }); + AddButton(@"Sort by Author", delegate { songSelect.Filter.Sort = FilterControl.SortMode.Author; }); + AddButton(@"Sort by Difficulty", delegate { songSelect.Filter.Sort = FilterControl.SortMode.Difficulty; }); } protected override void Dispose(bool isDisposing) From 90b0f035ad79cee0fb7edb995e8b37d9317c02bd Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Fri, 24 Feb 2017 17:01:14 +0100 Subject: [PATCH 11/14] Compute average of star ratings --- osu.Game/Screens/Select/CarouselContainer.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 0e540d8868f5..dea9125b7465 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -206,11 +206,20 @@ public void Sort(FilterControl.SortMode mode) { case FilterControl.SortMode.Difficulty: groups.Sort((x, y) => { - /*TODO: replace with star rating once implemented - * Assumes BeatmapSets not to be grouped - or to be by difficulty, - * otherwise this sorting makes little sense - or does it? */ - if (x.BeatmapSet.Beatmaps.First().StarDifficulty > - y.BeatmapSet.Beatmaps.First().StarDifficulty) + float x_average=0, y_average=0; + int counter=0; + foreach (BeatmapInfo set in x.BeatmapSet.Beatmaps) { + x_average += set.StarDifficulty; + counter++; + } + x_average /= counter; + counter = 0; + foreach (BeatmapInfo set in y.BeatmapSet.Beatmaps) { + y_average += set.StarDifficulty; + counter++; + } + y_average /= counter; + if (x_average > y_average) return 1; else return -1; From ace023f0c78a5d1ebe90f46cedd0f799f879635f Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Fri, 24 Feb 2017 17:08:18 +0100 Subject: [PATCH 12/14] Refactor local vars named in a c-like fashion --- osu.Game/Screens/Select/CarouselContainer.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index dea9125b7465..86e00791f6f2 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -206,20 +206,20 @@ public void Sort(FilterControl.SortMode mode) { case FilterControl.SortMode.Difficulty: groups.Sort((x, y) => { - float x_average=0, y_average=0; + float xAverage=0, yAverage=0; int counter=0; foreach (BeatmapInfo set in x.BeatmapSet.Beatmaps) { - x_average += set.StarDifficulty; + xAverage += set.StarDifficulty; counter++; } - x_average /= counter; + xAverage /= counter; counter = 0; foreach (BeatmapInfo set in y.BeatmapSet.Beatmaps) { - y_average += set.StarDifficulty; + yAverage += set.StarDifficulty; counter++; } - y_average /= counter; - if (x_average > y_average) + yAverage /= counter; + if (xAverage > yAverage) return 1; else return -1; From 68a359698d114c8eac351c393ef408001d78140c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 2 Mar 2017 18:35:24 +0900 Subject: [PATCH 13/14] Fix potential nullref caused by test data. --- osu.Game/Database/BeatmapInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Database/BeatmapInfo.cs b/osu.Game/Database/BeatmapInfo.cs index 7a976a1f7a9f..1c2ae2bf78a2 100644 --- a/osu.Game/Database/BeatmapInfo.cs +++ b/osu.Game/Database/BeatmapInfo.cs @@ -88,7 +88,7 @@ public bool Equals(BeatmapInfo other) return ID == other?.ID; } - public bool AudioEquals(BeatmapInfo other) => other != null && + public bool AudioEquals(BeatmapInfo other) => other != null && BeatmapSet != null && other.BeatmapSet != null && BeatmapSet.Path == other.BeatmapSet.Path && (Metadata ?? BeatmapSet.Metadata).AudioFile == (other.Metadata ?? other.BeatmapSet.Metadata).AudioFile; } From 4163569e577f74366c0c53953376f859fa2639e8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 2 Mar 2017 18:45:20 +0900 Subject: [PATCH 14/14] Fix some license headers. --- osu.Game.Modes.Osu/Objects/HitCircle.cs | 1 - osu.Game.Modes.Osu/Objects/SliderTick.cs | 5 ++++- osu.Game.Modes.Osu/Objects/Spinner.cs | 1 - osu.Game.Modes.Osu/OsuScore.cs | 1 - osu.Game/Graphics/UserInterface/FocusedTextBox.cs | 5 ++++- osu.Game/Modes/Objects/HitObjectParser.cs | 1 - osu.Game/Modes/Objects/NullHitObjectParser.cs | 1 - osu.Game/Modes/Score.cs | 1 - osu.Game/Modes/UI/HealthDisplay.cs | 2 +- osu.Game/Online/API/IOnlineComponent.cs | 1 - osu.Game/Users/User.cs | 1 - 11 files changed, 9 insertions(+), 11 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/HitCircle.cs b/osu.Game.Modes.Osu/Objects/HitCircle.cs index 80f9317d9673..2d86f0225fa4 100644 --- a/osu.Game.Modes.Osu/Objects/HitCircle.cs +++ b/osu.Game.Modes.Osu/Objects/HitCircle.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - namespace osu.Game.Modes.Osu.Objects { public class HitCircle : OsuHitObject diff --git a/osu.Game.Modes.Osu/Objects/SliderTick.cs b/osu.Game.Modes.Osu/Objects/SliderTick.cs index d9b8c03c3ce8..4492af86f9a0 100644 --- a/osu.Game.Modes.Osu/Objects/SliderTick.cs +++ b/osu.Game.Modes.Osu/Objects/SliderTick.cs @@ -1,4 +1,7 @@ -namespace osu.Game.Modes.Osu.Objects +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Modes.Osu.Objects { public class SliderTick : OsuHitObject { diff --git a/osu.Game.Modes.Osu/Objects/Spinner.cs b/osu.Game.Modes.Osu/Objects/Spinner.cs index 8a9b5bbbe3db..d55b9eb59c80 100644 --- a/osu.Game.Modes.Osu/Objects/Spinner.cs +++ b/osu.Game.Modes.Osu/Objects/Spinner.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - namespace osu.Game.Modes.Osu.Objects { public class Spinner : OsuHitObject diff --git a/osu.Game.Modes.Osu/OsuScore.cs b/osu.Game.Modes.Osu/OsuScore.cs index ce651e080933..6ea8eff890b1 100644 --- a/osu.Game.Modes.Osu/OsuScore.cs +++ b/osu.Game.Modes.Osu/OsuScore.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - namespace osu.Game.Modes.Osu { class OsuScore : Score diff --git a/osu.Game/Graphics/UserInterface/FocusedTextBox.cs b/osu.Game/Graphics/UserInterface/FocusedTextBox.cs index f657ffe33045..2f53d00c7eff 100644 --- a/osu.Game/Graphics/UserInterface/FocusedTextBox.cs +++ b/osu.Game/Graphics/UserInterface/FocusedTextBox.cs @@ -1,4 +1,7 @@ -using OpenTK.Graphics; +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; using OpenTK.Input; using osu.Framework.Input; using System; diff --git a/osu.Game/Modes/Objects/HitObjectParser.cs b/osu.Game/Modes/Objects/HitObjectParser.cs index 4020c1c0697d..5aa9f085898e 100644 --- a/osu.Game/Modes/Objects/HitObjectParser.cs +++ b/osu.Game/Modes/Objects/HitObjectParser.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - namespace osu.Game.Modes.Objects { public abstract class HitObjectParser diff --git a/osu.Game/Modes/Objects/NullHitObjectParser.cs b/osu.Game/Modes/Objects/NullHitObjectParser.cs index 4f06d5ab2610..fdec98963292 100644 --- a/osu.Game/Modes/Objects/NullHitObjectParser.cs +++ b/osu.Game/Modes/Objects/NullHitObjectParser.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - namespace osu.Game.Modes.Objects { /// diff --git a/osu.Game/Modes/Score.cs b/osu.Game/Modes/Score.cs index df1b65872fe7..8da09cb974cf 100644 --- a/osu.Game/Modes/Score.cs +++ b/osu.Game/Modes/Score.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - namespace osu.Game.Modes { public class Score diff --git a/osu.Game/Modes/UI/HealthDisplay.cs b/osu.Game/Modes/UI/HealthDisplay.cs index 5201a58104e9..c8d45bac36ff 100644 --- a/osu.Game/Modes/UI/HealthDisplay.cs +++ b/osu.Game/Modes/UI/HealthDisplay.cs @@ -1,5 +1,5 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; using osu.Framework.Allocation; diff --git a/osu.Game/Online/API/IOnlineComponent.cs b/osu.Game/Online/API/IOnlineComponent.cs index a4d25613b8cd..d213f5a0fcfa 100644 --- a/osu.Game/Online/API/IOnlineComponent.cs +++ b/osu.Game/Online/API/IOnlineComponent.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - namespace osu.Game.Online.API { public interface IOnlineComponent diff --git a/osu.Game/Users/User.cs b/osu.Game/Users/User.cs index 5928d6106cf4..540bfdbbf987 100644 --- a/osu.Game/Users/User.cs +++ b/osu.Game/Users/User.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - namespace osu.Game.Users { public class User