1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 16:12:57 +08:00

Merge branch 'master' into fix-menu-cursor-animation

This commit is contained in:
Dean Herbert 2018-07-06 17:46:29 +09:00 committed by GitHub
commit c4952569cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 47 additions and 33 deletions

4
.vscode/launch.json vendored
View File

@ -41,7 +41,7 @@
"request": "launch",
"program": "dotnet",
"args": [
"${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp2.1/osu!.dll",
"${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp2.1/osu!.dll"
],
"cwd": "${workspaceRoot}",
"preLaunchTask": "Build osu! (Debug)",
@ -58,7 +58,7 @@
"request": "launch",
"program": "dotnet",
"args": [
"${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp2.1/osu!.dll",
"${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp2.1/osu!.dll"
],
"cwd": "${workspaceRoot}",
"preLaunchTask": "Build osu! (Release)",

View File

@ -67,7 +67,7 @@ namespace osu.Game.Graphics.Containers
return base.OnClick(state);
}
public bool OnPressed(GlobalAction action)
public virtual bool OnPressed(GlobalAction action)
{
if (action == GlobalAction.Back)
{

View File

@ -39,7 +39,10 @@ namespace osu.Game.Input.Bindings
new KeyBinding(InputKey.F4, GlobalAction.ToggleMute),
new KeyBinding(InputKey.Escape, GlobalAction.Back),
new KeyBinding(InputKey.MouseButton1, GlobalAction.Back)
new KeyBinding(InputKey.MouseButton1, GlobalAction.Back),
new KeyBinding(InputKey.Space, GlobalAction.Select),
new KeyBinding(InputKey.Enter, GlobalAction.Select),
};
public IEnumerable<KeyBinding> InGameKeyBindings => new[]
@ -86,7 +89,7 @@ namespace osu.Game.Input.Bindings
[Description("Toggle gameplay mouse buttons")]
ToggleGameplayMouseButtons,
[Description("Go back")]
[Description("Back")]
Back,
[Description("Increase scroll speed")]
@ -94,5 +97,8 @@ namespace osu.Game.Input.Bindings
[Description("Decrease scroll speed")]
DecreaseScrollSpeed,
[Description("Select")]
Select,
}
}

View File

@ -13,6 +13,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Input.Bindings;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
@ -192,16 +193,22 @@ namespace osu.Game.Overlays.Dialog
};
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
public override bool OnPressed(GlobalAction action)
{
if (args.Repeat) return false;
if (args.Key == Key.Enter || args.Key == Key.KeypadEnter)
switch (action)
{
case GlobalAction.Select:
Buttons.OfType<PopupDialogOkButton>().FirstOrDefault()?.TriggerOnClick();
return true;
}
return base.OnPressed(action);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Repeat) return false;
// press button at number if 1-9 on number row or keypad are pressed
var k = args.Key;
if (k >= Key.Number1 && k <= Key.Number9)

View File

@ -11,7 +11,6 @@ using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Threading;
using osu.Game.Graphics;
@ -139,26 +138,15 @@ namespace osu.Game.Screens.Menu
sampleBack = audio.Sample.Get(@"Menu/button-back-select");
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Repeat) return false;
switch (args.Key)
{
case Key.Space:
logo?.TriggerOnClick(state);
return true;
}
return false;
}
public bool OnPressed(GlobalAction action)
{
switch (action)
{
case GlobalAction.Back:
return goBack();
case GlobalAction.Select:
logo?.TriggerOnClick();
return true;
default:
return false;
}

View File

@ -101,7 +101,7 @@ namespace osu.Game.Screens
sampleExit = audio.Sample.Get(@"UI/screen-back");
}
public bool OnPressed(GlobalAction action)
public virtual bool OnPressed(GlobalAction action)
{
if (!IsCurrentScreen) return false;

View File

@ -17,6 +17,7 @@ using osu.Framework.Threading;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
using osu.Game.Rulesets;
using osu.Game.Screens.Backgrounds;
@ -67,6 +68,7 @@ namespace osu.Game.Screens.Select
protected new readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
=> dependencies = new DependencyContainer(base.CreateLocalDependencies(parent));
@ -464,7 +466,8 @@ namespace osu.Game.Screens.Select
private void carouselBeatmapsLoaded()
{
if (!Beatmap.IsDefault && Beatmap.Value.BeatmapSetInfo?.DeletePending == false && Beatmap.Value.BeatmapSetInfo?.Protected == false && Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false))
if (!Beatmap.IsDefault && Beatmap.Value.BeatmapSetInfo?.DeletePending == false && Beatmap.Value.BeatmapSetInfo?.Protected == false
&& Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false))
return;
if (Carousel.SelectedBeatmapSet == null && !Carousel.SelectNextRandom())
@ -481,16 +484,26 @@ namespace osu.Game.Screens.Select
dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap));
}
public override bool OnPressed(GlobalAction action)
{
if (!IsCurrentScreen) return false;
switch (action)
{
case GlobalAction.Select:
FinaliseSelection();
return true;
}
return base.OnPressed(action);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Repeat) return false;
switch (args.Key)
{
case Key.KeypadEnter:
case Key.Enter:
FinaliseSelection();
return true;
case Key.Delete:
if (state.Keyboard.ShiftPressed)
{