From 0f59645e171413b017b3a0fc3bc6a5afd00c85a0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 31 May 2017 15:51:21 +0900 Subject: [PATCH 1/5] Increase timeout in TestImportOverIPC Has been failing CI randomly, so let's increase the timeout a bit. --- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 0e456941a1..7fb01cedc0 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -56,7 +56,7 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.IsTrue(File.Exists(temp)); var importer = new BeatmapIPCChannel(client); - if (!importer.ImportAsync(temp).Wait(5000)) + if (!importer.ImportAsync(temp).Wait(10000)) Assert.Fail(@"IPC took too long to send"); ensureLoaded(host); From 1dd85b598612e6487ac3edec0a72a52a1bcafb1b Mon Sep 17 00:00:00 2001 From: Patrick Andersson Date: Wed, 31 May 2017 18:41:15 +0200 Subject: [PATCH 2/5] Add alternative for random beatmap selection "Never repeat" will not repeat until all songs have been seen by repeatedly pressing F2/Random button --- osu.Game/Configuration/OsuConfigManager.cs | 3 +++ osu.Game/Configuration/SelectionRandomType.cs | 15 +++++++++++ .../Sections/Gameplay/SongSelectSettings.cs | 5 ++++ osu.Game/Screens/Select/BeatmapCarousel.cs | 25 +++++++++++++++++-- osu.Game/osu.Game.csproj | 1 + 5 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 osu.Game/Configuration/SelectionRandomType.cs diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 8f177d6b56..6ec827e881 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -20,6 +20,8 @@ namespace osu.Game.Configuration Set(OsuSetting.DisplayStarsMinimum, 0.0, 0, 10); Set(OsuSetting.DisplayStarsMaximum, 10.0, 0, 10); + Set(OsuSetting.SelectionRandomType, SelectionRandomType.Random); + Set(OsuSetting.ChatDisplayHeight, ChatOverlay.DEFAULT_HEIGHT, 0.2, 1); // Online settings @@ -102,6 +104,7 @@ namespace osu.Game.Configuration SaveUsername, DisplayStarsMinimum, DisplayStarsMaximum, + SelectionRandomType, SnakingInSliders, SnakingOutSliders, ShowFpsDisplay, diff --git a/osu.Game/Configuration/SelectionRandomType.cs b/osu.Game/Configuration/SelectionRandomType.cs new file mode 100644 index 0000000000..a2cd3ba7e8 --- /dev/null +++ b/osu.Game/Configuration/SelectionRandomType.cs @@ -0,0 +1,15 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.ComponentModel; + +namespace osu.Game.Configuration +{ + public enum SelectionRandomType + { + [Description("Random")] + Random, + [Description("Never repeat")] + RandomPermutation + } +} diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs index 7626911627..62801b2ef6 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs @@ -27,6 +27,11 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay LabelText = "up to", Bindable = config.GetBindable(OsuSetting.DisplayStarsMaximum) }, + new SettingsEnumDropdown + { + LabelText = "Random beatmap selection", + Bindable = config.GetBindable(OsuSetting.SelectionRandomType), + }, }; } diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 130642b9c7..33aca5a96b 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -9,6 +9,7 @@ using System; using System.Collections.Generic; using System.Linq; using osu.Game.Beatmaps.Drawables; +using osu.Game.Configuration; using osu.Framework.Input; using OpenTK.Input; using System.Collections; @@ -17,6 +18,7 @@ using System.Diagnostics; using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Threading; +using osu.Framework.Configuration; namespace osu.Game.Screens.Select { @@ -70,6 +72,9 @@ namespace osu.Game.Screens.Select private readonly List groups = new List(); + private Bindable randomType; + private HashSet seenGroups = new HashSet(); + private readonly List panels = new List(); private BeatmapGroup selectedGroup; @@ -171,7 +176,22 @@ namespace osu.Game.Screens.Select if (visibleGroups.Count < 1) return; - BeatmapGroup group = visibleGroups[RNG.Next(visibleGroups.Count)]; + BeatmapGroup group; + if (randomType == SelectionRandomType.RandomPermutation) + { + List notSeenGroups = visibleGroups.Except(seenGroups).ToList(); + if (!notSeenGroups.Any()) + { + seenGroups.Clear(); + notSeenGroups = visibleGroups; + } + + group = notSeenGroups[RNG.Next(notSeenGroups.Count())]; + seenGroups.Add(group); + } + else + group = visibleGroups[RNG.Next(visibleGroups.Count)]; + BeatmapPanel panel = group.BeatmapPanels[RNG.Next(group.BeatmapPanels.Count)]; selectGroup(group, panel); @@ -239,9 +259,10 @@ namespace osu.Game.Screens.Select } [BackgroundDependencyLoader(permitNulls: true)] - private void load(BeatmapDatabase database) + private void load(BeatmapDatabase database, OsuConfigManager config) { this.database = database; + randomType = config.GetBindable(OsuSetting.SelectionRandomType); } private void addGroup(BeatmapGroup group) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 0ec0624978..b58e2f8c41 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -74,6 +74,7 @@ + From 9592e9778bea75cfad8865d2ee969f83bc115191 Mon Sep 17 00:00:00 2001 From: Patrick Andersson Date: Wed, 31 May 2017 20:31:05 +0200 Subject: [PATCH 3/5] Trim whitespace --- osu.Game/Screens/Select/BeatmapCarousel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 33aca5a96b..2c7fde968e 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -181,7 +181,7 @@ namespace osu.Game.Screens.Select { List notSeenGroups = visibleGroups.Except(seenGroups).ToList(); if (!notSeenGroups.Any()) - { + { seenGroups.Clear(); notSeenGroups = visibleGroups; } From a3945bb11d289709088a3f78fe07bd809167eb51 Mon Sep 17 00:00:00 2001 From: Patrick Andersson Date: Wed, 31 May 2017 22:04:29 +0200 Subject: [PATCH 4/5] Added suggestions by code inspector --- osu.Game/Screens/Select/BeatmapCarousel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 2c7fde968e..7db9803804 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -73,7 +73,7 @@ namespace osu.Game.Screens.Select private readonly List groups = new List(); private Bindable randomType; - private HashSet seenGroups = new HashSet(); + private readonly HashSet seenGroups = new HashSet(); private readonly List panels = new List(); @@ -186,7 +186,7 @@ namespace osu.Game.Screens.Select notSeenGroups = visibleGroups; } - group = notSeenGroups[RNG.Next(notSeenGroups.Count())]; + group = notSeenGroups[RNG.Next(notSeenGroups.Count)]; seenGroups.Add(group); } else From 94294e4b45edf63be1884b7b86ed02a9038625bf Mon Sep 17 00:00:00 2001 From: Patrick Andersson Date: Thu, 1 Jun 2017 08:54:48 +0200 Subject: [PATCH 5/5] Changed default selection type and added suggestions from PR feedback --- osu.Game/Configuration/OsuConfigManager.cs | 2 +- osu.Game/Configuration/SelectionRandomType.cs | 8 ++++---- osu.Game/Screens/Select/BeatmapCarousel.cs | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 6ec827e881..8b2a06ad0b 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -20,7 +20,7 @@ namespace osu.Game.Configuration Set(OsuSetting.DisplayStarsMinimum, 0.0, 0, 10); Set(OsuSetting.DisplayStarsMaximum, 10.0, 0, 10); - Set(OsuSetting.SelectionRandomType, SelectionRandomType.Random); + Set(OsuSetting.SelectionRandomType, SelectionRandomType.RandomPermutation); Set(OsuSetting.ChatDisplayHeight, ChatOverlay.DEFAULT_HEIGHT, 0.2, 1); diff --git a/osu.Game/Configuration/SelectionRandomType.cs b/osu.Game/Configuration/SelectionRandomType.cs index a2cd3ba7e8..298ee71e36 100644 --- a/osu.Game/Configuration/SelectionRandomType.cs +++ b/osu.Game/Configuration/SelectionRandomType.cs @@ -7,9 +7,9 @@ namespace osu.Game.Configuration { public enum SelectionRandomType { - [Description("Random")] - Random, [Description("Never repeat")] - RandomPermutation + RandomPermutation, + [Description("Random")] + Random } -} +} \ No newline at end of file diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 7db9803804..26820fc388 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -73,7 +73,7 @@ namespace osu.Game.Screens.Select private readonly List groups = new List(); private Bindable randomType; - private readonly HashSet seenGroups = new HashSet(); + private readonly List seenGroups = new List(); private readonly List panels = new List(); @@ -172,25 +172,25 @@ namespace osu.Game.Screens.Select public void SelectRandom() { - List visibleGroups = groups.Where(selectGroup => selectGroup.State != BeatmapGroupState.Hidden).ToList(); - if (visibleGroups.Count < 1) + IEnumerable visibleGroups = groups.Where(selectGroup => selectGroup.State != BeatmapGroupState.Hidden); + if (!visibleGroups.Any()) return; BeatmapGroup group; if (randomType == SelectionRandomType.RandomPermutation) { - List notSeenGroups = visibleGroups.Except(seenGroups).ToList(); + IEnumerable notSeenGroups = visibleGroups.Except(seenGroups); if (!notSeenGroups.Any()) { seenGroups.Clear(); notSeenGroups = visibleGroups; } - group = notSeenGroups[RNG.Next(notSeenGroups.Count)]; + group = notSeenGroups.ElementAt(RNG.Next(notSeenGroups.Count())); seenGroups.Add(group); } else - group = visibleGroups[RNG.Next(visibleGroups.Count)]; + group = visibleGroups.ElementAt(RNG.Next(visibleGroups.Count())); BeatmapPanel panel = group.BeatmapPanels[RNG.Next(group.BeatmapPanels.Count)];