mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 20:07:29 +08:00
Cancel beatmap random selection
This commit is contained in:
parent
900e3ce3e2
commit
a42c67ee97
@ -77,8 +77,9 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
private readonly List<Panel> panels = new List<Panel>();
|
||||
|
||||
private BeatmapGroup selectedGroup;
|
||||
private readonly Stack<BeatmapGroup> randomSelectedBeatmaps = new Stack<BeatmapGroup>();
|
||||
|
||||
private BeatmapGroup selectedGroup;
|
||||
private BeatmapPanel selectedPanel;
|
||||
|
||||
public BeatmapCarousel()
|
||||
@ -172,14 +173,17 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
public void SelectRandom()
|
||||
{
|
||||
IEnumerable<BeatmapGroup> visibleGroups = groups.Where(selectGroup => selectGroup.State != BeatmapGroupState.Hidden);
|
||||
randomSelectedBeatmaps.Push(selectedGroup);
|
||||
|
||||
var visibleGroups = getVisibleGroups();
|
||||
if (!visibleGroups.Any())
|
||||
return;
|
||||
|
||||
BeatmapGroup group;
|
||||
|
||||
if (randomType == SelectionRandomType.RandomPermutation)
|
||||
{
|
||||
IEnumerable<BeatmapGroup> notSeenGroups = visibleGroups.Except(seenGroups);
|
||||
var notSeenGroups = visibleGroups.Except(seenGroups);
|
||||
if (!notSeenGroups.Any())
|
||||
{
|
||||
seenGroups.Clear();
|
||||
@ -197,6 +201,38 @@ namespace osu.Game.Screens.Select
|
||||
selectGroup(group, panel);
|
||||
}
|
||||
|
||||
public void CancelRandom()
|
||||
{
|
||||
if (!randomSelectedBeatmaps.Any())
|
||||
return;
|
||||
|
||||
var visibleGroups = getVisibleGroups();
|
||||
if (!visibleGroups.Any())
|
||||
return;
|
||||
|
||||
// we can avoid selecting deleted beatmaps or beatmaps selected in another gamemode
|
||||
while (true)
|
||||
{
|
||||
if (!randomSelectedBeatmaps.Any()) break;
|
||||
|
||||
if (!visibleGroups.Contains(randomSelectedBeatmaps.FirstOrDefault()))
|
||||
{
|
||||
randomSelectedBeatmaps.Pop();
|
||||
}
|
||||
else
|
||||
{
|
||||
BeatmapGroup beatmapGroup = randomSelectedBeatmaps.Pop();
|
||||
selectGroup(beatmapGroup, beatmapGroup.SelectedPanel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<BeatmapGroup> getVisibleGroups()
|
||||
{
|
||||
return groups.Where(selectGroup => selectGroup.State != BeatmapGroupState.Hidden);
|
||||
}
|
||||
|
||||
private FilterCriteria criteria = new FilterCriteria();
|
||||
|
||||
private ScheduledDelegate filterTask;
|
||||
|
@ -38,12 +38,13 @@ namespace osu.Game.Screens.Select
|
||||
/// <param name="text">Text on the button.</param>
|
||||
/// <param name="colour">Colour of the button.</param>
|
||||
/// <param name="hotkey">Hotkey of the button.</param>
|
||||
/// <param name="excludePressWithShift">Forbid you to use hotkey with shift pressed.</param>
|
||||
/// <param name="action">Action the button does.</param>
|
||||
/// <param name="depth">
|
||||
/// <para>Higher depth to be put on the left, and lower to be put on the right.</para>
|
||||
/// <para>Notice this is different to <see cref="Options.BeatmapOptionsOverlay"/>!</para>
|
||||
/// </param>
|
||||
public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0)
|
||||
public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, bool excludePressWithShift = false, float depth = 0)
|
||||
{
|
||||
var button = new FooterButton
|
||||
{
|
||||
@ -54,6 +55,7 @@ namespace osu.Game.Screens.Select
|
||||
SelectedColour = colour,
|
||||
DeselectedColour = colour.Opacity(0.5f),
|
||||
Hotkey = hotkey,
|
||||
ExcludePressWithShift = excludePressWithShift,
|
||||
};
|
||||
|
||||
button.Hovered = () => updateModeLight(button);
|
||||
|
@ -84,6 +84,7 @@ namespace osu.Game.Screens.Select
|
||||
public Action Hovered;
|
||||
public Action HoverLost;
|
||||
public Key? Hotkey;
|
||||
public bool ExcludePressWithShift;
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
@ -124,8 +125,19 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
if (!args.Repeat && args.Key == Hotkey)
|
||||
{
|
||||
OnClick(state);
|
||||
return true;
|
||||
if (ExcludePressWithShift)
|
||||
{
|
||||
if (!state.Keyboard.ShiftPressed)
|
||||
{
|
||||
OnClick(state);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnClick(state);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Screens.Select
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1, float.MaxValue);
|
||||
Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1, false, float.MaxValue);
|
||||
|
||||
BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1);
|
||||
BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null, Key.Number2);
|
||||
|
@ -158,7 +158,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
if (Footer != null)
|
||||
{
|
||||
Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2);
|
||||
Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2, true);
|
||||
Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3);
|
||||
|
||||
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, Key.Number4, float.MaxValue);
|
||||
@ -381,6 +381,13 @@ namespace osu.Game.Screens.Select
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case Key.F2:
|
||||
if (state.Keyboard.ShiftPressed)
|
||||
{
|
||||
carousel.CancelRandom();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
|
Loading…
Reference in New Issue
Block a user