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

Revert "Auto assign hotkeys for BeatmapOptionsButton."

This reverts commit beb0a8ff03.
This commit is contained in:
Huo Yaoyuan 2017-03-14 21:13:57 +08:00
parent e1cc74bb40
commit c939897a8a
4 changed files with 20 additions and 23 deletions

View File

@ -3,6 +3,7 @@
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -48,6 +49,8 @@ namespace osu.Game.Screens.Select.Options
set { secondLine.Text = value; }
}
public Key? HotKey;
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
flash.FadeTo(0.1f, 1000, EasingTypes.OutQuint);
@ -69,6 +72,17 @@ namespace osu.Game.Screens.Select.Options
return base.OnClick(state);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (!args.Repeat && args.Key == HotKey)
{
OnClick(state);
return true;
}
return false;
}
public override bool Contains(Vector2 screenSpacePos) => box.Contains(screenSpacePos);
public BeatmapOptionsButton()

View File

@ -12,7 +12,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Input;
using osu.Game.Graphics;
namespace osu.Game.Screens.Select.Options
@ -91,7 +90,7 @@ namespace osu.Game.Screens.Select.Options
/// <para>Lower depth to be put on the left, and higher to be put on the right.</para>
/// <para>Notice this is different to <see cref="Footer"/>!</para>
/// </param>
public void AddButton(string firstLine, string secongLine, FontAwesome icon, Color4 colour, Action action, float depth = 0)
public void AddButton(string firstLine, string secongLine, FontAwesome icon, Color4 colour, Action action, Key? hotkey = null, float depth = 0)
{
buttonsContainer.Add(new BeatmapOptionsButton
{
@ -105,26 +104,10 @@ namespace osu.Game.Screens.Select.Options
Hide();
action?.Invoke();
},
HotKey = hotkey
});
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Repeat) return false;
int index = (int)args.Key - (int)Key.Number1;
if (index >= 0 && index <= 9)
{
// Children of ButtonFlow is reversed. The same reason of depth in AddButton.
var button = buttonsContainer.Children.Reverse().ElementAtOrDefault(index);
if (button != null)
{
button.TriggerClick();
return true;
}
}
return base.OnKeyDown(state, args);
}
private class ButtonFlow : FillFlowContainer<BeatmapOptionsButton>
{
protected override IComparer<Drawable> DepthComparer => new ReverseCreationOrderDepthComparer();

View File

@ -31,9 +31,9 @@ namespace osu.Game.Screens.Select
Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1, float.MaxValue);
BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null);
BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null);
BeatmapOptions.AddButton(@"Edit", @"Beatmap", FontAwesome.fa_pencil, colours.Yellow, null);
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(@"Edit", @"Beatmap", FontAwesome.fa_pencil, colours.Yellow, null, Key.Number3);
}
protected override void OnBeatmapChanged(WorkingBeatmap beatmap)

View File

@ -149,7 +149,7 @@ namespace osu.Game.Screens.Select
Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2);
Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3);
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, float.MaxValue);
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, Key.Number4, float.MaxValue);
if (osu != null)
playMode.BindTo(osu.PlayMode);