1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 14:13:18 +08:00

Add alternative for random beatmap selection

"Never repeat" will not repeat until all songs have been seen by repeatedly pressing F2/Random button
This commit is contained in:
Patrick Andersson 2017-05-31 18:41:15 +02:00
parent f59edd697c
commit 1dd85b5986
5 changed files with 47 additions and 2 deletions

View File

@ -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,

View File

@ -0,0 +1,15 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// 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
}
}

View File

@ -27,6 +27,11 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
LabelText = "up to",
Bindable = config.GetBindable<double>(OsuSetting.DisplayStarsMaximum)
},
new SettingsEnumDropdown<SelectionRandomType>
{
LabelText = "Random beatmap selection",
Bindable = config.GetBindable<SelectionRandomType>(OsuSetting.SelectionRandomType),
},
};
}

View File

@ -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<BeatmapGroup> groups = new List<BeatmapGroup>();
private Bindable<SelectionRandomType> randomType;
private HashSet<BeatmapGroup> seenGroups = new HashSet<BeatmapGroup>();
private readonly List<Panel> panels = new List<Panel>();
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<BeatmapGroup> 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<SelectionRandomType>(OsuSetting.SelectionRandomType);
}
private void addGroup(BeatmapGroup group)

View File

@ -74,6 +74,7 @@
<Compile Include="Audio\SampleInfoList.cs" />
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
<Compile Include="Beatmaps\DifficultyCalculator.cs" />
<Compile Include="Configuration\SelectionRandomType.cs" />
<Compile Include="Online\API\Requests\PostMessageRequest.cs" />
<Compile Include="Online\Chat\ErrorMessage.cs" />
<Compile Include="Overlays\Chat\ChatTabControl.cs" />