1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 07:32:55 +08:00

Applied suggested changes

This commit is contained in:
EVAST9919 2017-06-05 12:24:28 +03:00
parent 6b9d5afc4b
commit 78500eec21
5 changed files with 19 additions and 41 deletions

View File

@ -171,7 +171,7 @@ namespace osu.Game.Screens.Select
} while (index != startIndex);
}
public void SelectRandom()
public void SelectNextRandom()
{
randomSelectedBeatmaps.Push(selectedGroup);
@ -201,7 +201,7 @@ namespace osu.Game.Screens.Select
selectGroup(group, panel);
}
public void CancelRandom()
public void SelectPreviousRandom()
{
if (!randomSelectedBeatmaps.Any())
return;
@ -210,19 +210,12 @@ namespace osu.Game.Screens.Select
if (!visibleGroups.Any())
return;
// we can avoid selecting deleted beatmaps or beatmaps selected in another gamemode
while (true)
while (randomSelectedBeatmaps.Any())
{
if (!randomSelectedBeatmaps.Any()) break;
if (!visibleGroups.Contains(randomSelectedBeatmaps.FirstOrDefault()))
var group = randomSelectedBeatmaps.Pop();
if (visibleGroups.Contains(group))
{
randomSelectedBeatmaps.Pop();
}
else
{
BeatmapGroup beatmapGroup = randomSelectedBeatmaps.Pop();
selectGroup(beatmapGroup, beatmapGroup.SelectedPanel);
selectGroup(group, group.SelectedPanel);
break;
}
}

View File

@ -38,13 +38,12 @@ 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, bool excludePressWithShift = false, float depth = 0)
public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0)
{
var button = new FooterButton
{
@ -55,7 +54,6 @@ namespace osu.Game.Screens.Select
SelectedColour = colour,
DeselectedColour = colour.Opacity(0.5f),
Hotkey = hotkey,
ExcludePressWithShift = excludePressWithShift,
};
button.Hovered = () => updateModeLight(button);

View File

@ -84,7 +84,6 @@ namespace osu.Game.Screens.Select
public Action Hovered;
public Action HoverLost;
public Key? Hotkey;
public bool ExcludePressWithShift;
protected override bool OnHover(InputState state)
{
@ -125,19 +124,8 @@ namespace osu.Game.Screens.Select
{
if (!args.Repeat && args.Key == Hotkey)
{
if (ExcludePressWithShift)
{
if (!state.Keyboard.ShiftPressed)
{
OnClick(state);
return true;
}
}
else
{
OnClick(state);
return true;
}
OnClick(state);
return true;
}
return base.OnKeyDown(state, args);

View File

@ -42,7 +42,7 @@ namespace osu.Game.Screens.Select
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1, false, float.MaxValue);
Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1, 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);

View File

@ -154,11 +154,11 @@ namespace osu.Game.Screens.Select
}
[BackgroundDependencyLoader(permitNulls: true)]
private void load(BeatmapDatabase beatmaps, AudioManager audio, DialogOverlay dialog, OsuGame osu, OsuColour colours)
private void load(BeatmapDatabase beatmaps, AudioManager audio, DialogOverlay dialog, OsuGame osu, OsuColour colours, UserInputManager input)
{
if (Footer != null)
{
Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2, true);
Footer.AddButton(@"random", colours.Green, () => triggerRandom(input), Key.F2);
Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3);
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, Key.Number4, float.MaxValue);
@ -209,7 +209,13 @@ namespace osu.Game.Screens.Select
OnSelected();
}
public void SelectRandom() => carousel.SelectRandom();
private void triggerRandom(UserInputManager input)
{
if (input.CurrentState.Keyboard.ShiftPressed)
carousel.SelectPreviousRandom();
else
carousel.SelectNextRandom();
}
protected abstract void OnSelected();
@ -381,13 +387,6 @@ 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);