1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 16:52:55 +08:00

Merge pull request #888 from Drenata/random-selection-alternatives

Add alternative for random beatmap selection
This commit is contained in:
Dean Herbert 2017-06-01 18:04:31 +09:00 committed by GitHub
commit 900e3ce3e2
5 changed files with 49 additions and 4 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.RandomPermutation);
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("Never repeat")]
RandomPermutation,
[Description("Random")]
Random
}
}

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 readonly List<BeatmapGroup> seenGroups = new List<BeatmapGroup>();
private readonly List<Panel> panels = new List<Panel>();
private BeatmapGroup selectedGroup;
@ -167,11 +172,26 @@ namespace osu.Game.Screens.Select
public void SelectRandom()
{
List<BeatmapGroup> visibleGroups = groups.Where(selectGroup => selectGroup.State != BeatmapGroupState.Hidden).ToList();
if (visibleGroups.Count < 1)
IEnumerable<BeatmapGroup> visibleGroups = groups.Where(selectGroup => selectGroup.State != BeatmapGroupState.Hidden);
if (!visibleGroups.Any())
return;
BeatmapGroup group = visibleGroups[RNG.Next(visibleGroups.Count)];
BeatmapGroup group;
if (randomType == SelectionRandomType.RandomPermutation)
{
IEnumerable<BeatmapGroup> notSeenGroups = visibleGroups.Except(seenGroups);
if (!notSeenGroups.Any())
{
seenGroups.Clear();
notSeenGroups = visibleGroups;
}
group = notSeenGroups.ElementAt(RNG.Next(notSeenGroups.Count()));
seenGroups.Add(group);
}
else
group = visibleGroups.ElementAt(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" />