Move action and hotkey specification local

This commit is contained in:
Dean Herbert 2019-05-08 19:29:43 +09:00
parent c91b9c6032
commit 6dea16f365
5 changed files with 15 additions and 13 deletions

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
using osuTK.Input;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -34,22 +33,19 @@ namespace osu.Game.Screens.Select
/// <param name="button">THe button to be added.</param> /// <param name="button">THe button to be added.</param>
/// <param name="overlay">The <see cref="OverlayContainer"/> to be toggled by this button.</param> /// <param name="overlay">The <see cref="OverlayContainer"/> to be toggled by this button.</param>
/// <param name="hotkey">Hotkey of the button.</param> public void AddButton(FooterButton button, OverlayContainer overlay)
public void AddButton(FooterButton button, OverlayContainer overlay, Key? hotkey = null)
{ {
overlays.Add(overlay); overlays.Add(overlay);
AddButton(button, () => showOverlay(overlay), hotkey); button.Action = () => showOverlay(overlay);
AddButton(button);
} }
/// <param name="button">Button to be added.</param> /// <param name="button">Button to be added.</param>
/// <param name="action">Action the button does.</param> public void AddButton(FooterButton button)
/// <param name="hotkey">Hotkey of the button.</param>
public void AddButton(FooterButton button, Action action, Key? hotkey = null)
{ {
button.Hotkey = hotkey;
button.Hovered = updateModeLight; button.Hovered = updateModeLight;
button.HoverLost = updateModeLight; button.HoverLost = updateModeLight;
button.Action = action;
buttons.Add(button); buttons.Add(button);
} }

View File

@ -11,6 +11,7 @@ using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Game.Graphics; using osu.Game.Graphics;
using osuTK; using osuTK;
using osuTK.Input;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
@ -43,6 +44,7 @@ namespace osu.Game.Screens.Select
SelectedColour = colours.Yellow; SelectedColour = colours.Yellow;
DeselectedColour = SelectedColour.Opacity(0.5f); DeselectedColour = SelectedColour.Opacity(0.5f);
Text = @"mods"; Text = @"mods";
Hotkey = Key.F1;
} }
private class FooterModDisplay : ModDisplay private class FooterModDisplay : ModDisplay

View File

@ -1,6 +1,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Game.Graphics; using osu.Game.Graphics;
using osuTK.Input;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
@ -12,6 +13,7 @@ namespace osu.Game.Screens.Select
SelectedColour = colours.Blue; SelectedColour = colours.Blue;
DeselectedColour = SelectedColour.Opacity(0.5f); DeselectedColour = SelectedColour.Opacity(0.5f);
Text = @"options"; Text = @"options";
Hotkey = Key.F3;
} }
} }
} }

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osuTK.Input;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
@ -33,6 +34,7 @@ namespace osu.Game.Screens.Select
SelectedColour = colours.Green; SelectedColour = colours.Green;
DeselectedColour = SelectedColour.Opacity(0.5f); DeselectedColour = SelectedColour.Opacity(0.5f);
Text = @"random"; Text = @"random";
Hotkey = Key.F2;
} }
protected override bool OnKeyDown(KeyDownEvent e) protected override bool OnKeyDown(KeyDownEvent e)

View File

@ -223,9 +223,9 @@ namespace osu.Game.Screens.Select
if (Footer != null) if (Footer != null)
{ {
Footer.AddButton(new FooterButtonMods(mods), ModSelect, Key.F1); Footer.AddButton(new FooterButtonMods(mods), ModSelect);
Footer.AddButton(new FooterButtonRandom(), triggerRandom, Key.F2); Footer.AddButton(new FooterButtonRandom { Action = triggerRandom });
Footer.AddButton(new FooterButtonOptions(), BeatmapOptions, Key.F3); Footer.AddButton(new FooterButtonOptions(), BeatmapOptions);
BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue); BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue);
BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.Regular.TimesCircle, colours.Purple, null, Key.Number1); BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.Regular.TimesCircle, colours.Purple, null, Key.Number1);