mirror of
https://github.com/osukey/osukey.git
synced 2025-05-02 12:17:27 +09: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 readonly List<Panel> panels = new List<Panel>();
|
||||||
|
|
||||||
private BeatmapGroup selectedGroup;
|
private readonly Stack<BeatmapGroup> randomSelectedBeatmaps = new Stack<BeatmapGroup>();
|
||||||
|
|
||||||
|
private BeatmapGroup selectedGroup;
|
||||||
private BeatmapPanel selectedPanel;
|
private BeatmapPanel selectedPanel;
|
||||||
|
|
||||||
public BeatmapCarousel()
|
public BeatmapCarousel()
|
||||||
@ -172,14 +173,17 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
public void SelectRandom()
|
public void SelectRandom()
|
||||||
{
|
{
|
||||||
IEnumerable<BeatmapGroup> visibleGroups = groups.Where(selectGroup => selectGroup.State != BeatmapGroupState.Hidden);
|
randomSelectedBeatmaps.Push(selectedGroup);
|
||||||
|
|
||||||
|
var visibleGroups = getVisibleGroups();
|
||||||
if (!visibleGroups.Any())
|
if (!visibleGroups.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BeatmapGroup group;
|
BeatmapGroup group;
|
||||||
|
|
||||||
if (randomType == SelectionRandomType.RandomPermutation)
|
if (randomType == SelectionRandomType.RandomPermutation)
|
||||||
{
|
{
|
||||||
IEnumerable<BeatmapGroup> notSeenGroups = visibleGroups.Except(seenGroups);
|
var notSeenGroups = visibleGroups.Except(seenGroups);
|
||||||
if (!notSeenGroups.Any())
|
if (!notSeenGroups.Any())
|
||||||
{
|
{
|
||||||
seenGroups.Clear();
|
seenGroups.Clear();
|
||||||
@ -197,6 +201,38 @@ namespace osu.Game.Screens.Select
|
|||||||
selectGroup(group, panel);
|
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 FilterCriteria criteria = new FilterCriteria();
|
||||||
|
|
||||||
private ScheduledDelegate filterTask;
|
private ScheduledDelegate filterTask;
|
||||||
|
@ -38,12 +38,13 @@ namespace osu.Game.Screens.Select
|
|||||||
/// <param name="text">Text on the button.</param>
|
/// <param name="text">Text on the button.</param>
|
||||||
/// <param name="colour">Colour of the button.</param>
|
/// <param name="colour">Colour of the button.</param>
|
||||||
/// <param name="hotkey">Hotkey 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="action">Action the button does.</param>
|
||||||
/// <param name="depth">
|
/// <param name="depth">
|
||||||
/// <para>Higher depth to be put on the left, and lower to be put on the right.</para>
|
/// <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>
|
/// <para>Notice this is different to <see cref="Options.BeatmapOptionsOverlay"/>!</para>
|
||||||
/// </param>
|
/// </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
|
var button = new FooterButton
|
||||||
{
|
{
|
||||||
@ -54,6 +55,7 @@ namespace osu.Game.Screens.Select
|
|||||||
SelectedColour = colour,
|
SelectedColour = colour,
|
||||||
DeselectedColour = colour.Opacity(0.5f),
|
DeselectedColour = colour.Opacity(0.5f),
|
||||||
Hotkey = hotkey,
|
Hotkey = hotkey,
|
||||||
|
ExcludePressWithShift = excludePressWithShift,
|
||||||
};
|
};
|
||||||
|
|
||||||
button.Hovered = () => updateModeLight(button);
|
button.Hovered = () => updateModeLight(button);
|
||||||
|
@ -84,6 +84,7 @@ namespace osu.Game.Screens.Select
|
|||||||
public Action Hovered;
|
public Action Hovered;
|
||||||
public Action HoverLost;
|
public Action HoverLost;
|
||||||
public Key? Hotkey;
|
public Key? Hotkey;
|
||||||
|
public bool ExcludePressWithShift;
|
||||||
|
|
||||||
protected override bool OnHover(InputState state)
|
protected override bool OnHover(InputState state)
|
||||||
{
|
{
|
||||||
@ -124,8 +125,19 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
if (!args.Repeat && args.Key == Hotkey)
|
if (!args.Repeat && args.Key == Hotkey)
|
||||||
{
|
{
|
||||||
OnClick(state);
|
if (ExcludePressWithShift)
|
||||||
return true;
|
{
|
||||||
|
if (!state.Keyboard.ShiftPressed)
|
||||||
|
{
|
||||||
|
OnClick(state);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OnClick(state);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.OnKeyDown(state, args);
|
return base.OnKeyDown(state, args);
|
||||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Screens.Select
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
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(@"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);
|
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)
|
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);
|
Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3);
|
||||||
|
|
||||||
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, Key.Number4, float.MaxValue);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Key.F2:
|
||||||
|
if (state.Keyboard.ShiftPressed)
|
||||||
|
{
|
||||||
|
carousel.CancelRandom();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.OnKeyDown(state, args);
|
return base.OnKeyDown(state, args);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user