1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 01:27:35 +08:00

Merge branch 'master' into taiko-timingchanges-2

This commit is contained in:
Dean Herbert 2017-08-18 22:44:36 +09:00 committed by GitHub
commit 86d97aa16b
6 changed files with 113 additions and 58 deletions

View File

@ -23,12 +23,12 @@ namespace osu.Game.Rulesets.Catch
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[] public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
{ {
new KeyBinding(Key.Z, CatchAction.MoveLeft), new KeyBinding(InputKey.Z, CatchAction.MoveLeft),
new KeyBinding(Key.Left, CatchAction.MoveLeft), new KeyBinding(InputKey.Left, CatchAction.MoveLeft),
new KeyBinding(Key.X, CatchAction.MoveRight), new KeyBinding(InputKey.X, CatchAction.MoveRight),
new KeyBinding(Key.Right, CatchAction.MoveRight), new KeyBinding(InputKey.Right, CatchAction.MoveRight),
new KeyBinding(Key.LShift, CatchAction.Dash), new KeyBinding(InputKey.Shift, CatchAction.Dash),
new KeyBinding(Key.RShift, CatchAction.Dash), new KeyBinding(InputKey.Shift, CatchAction.Dash),
}; };
public override IEnumerable<Mod> GetModsFor(ModType type) public override IEnumerable<Mod> GetModsFor(ModType type)

View File

@ -27,10 +27,10 @@ namespace osu.Game.Rulesets.Osu
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[] public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
{ {
new KeyBinding(Key.Z, OsuAction.LeftButton), new KeyBinding(InputKey.Z, OsuAction.LeftButton),
new KeyBinding(Key.X, OsuAction.RightButton), new KeyBinding(InputKey.X, OsuAction.RightButton),
new KeyBinding(Key.LastKey + 1, OsuAction.LeftButton), new KeyBinding(InputKey.LastKey + 1, OsuAction.LeftButton),
new KeyBinding(Key.LastKey + 2, OsuAction.RightButton), new KeyBinding(InputKey.LastKey + 2, OsuAction.RightButton),
}; };
public override IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new[] public override IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new[]

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Input;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
@ -22,16 +21,16 @@ namespace osu.Game.Input.Bindings
public override IEnumerable<KeyBinding> DefaultKeyBindings => new[] public override IEnumerable<KeyBinding> DefaultKeyBindings => new[]
{ {
new KeyBinding(Key.F8, GlobalAction.ToggleChat), new KeyBinding(InputKey.F8, GlobalAction.ToggleChat),
new KeyBinding(Key.F9, GlobalAction.ToggleSocial), new KeyBinding(InputKey.F9, GlobalAction.ToggleSocial),
new KeyBinding(new[] { Key.LControl, Key.LAlt, Key.R }, GlobalAction.ResetInputSettings), new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.R }, GlobalAction.ResetInputSettings),
new KeyBinding(new[] { Key.LControl, Key.T }, GlobalAction.ToggleToolbar), new KeyBinding(new[] { InputKey.Control, InputKey.T }, GlobalAction.ToggleToolbar),
new KeyBinding(new[] { Key.LControl, Key.O }, GlobalAction.ToggleSettings), new KeyBinding(new[] { InputKey.Control, InputKey.O }, GlobalAction.ToggleSettings),
new KeyBinding(new[] { Key.LControl, Key.D }, GlobalAction.ToggleDirect), new KeyBinding(new[] { InputKey.Control, InputKey.D }, GlobalAction.ToggleDirect),
}; };
protected override IEnumerable<Drawable> GetKeyboardInputQueue() => protected override IEnumerable<Drawable> KeyBindingInputQueue =>
handler == null ? base.GetKeyboardInputQueue() : new[] { handler }.Concat(base.GetKeyboardInputQueue()); handler == null ? base.KeyBindingInputQueue : new[] { handler }.Concat(base.KeyBindingInputQueue);
} }
public enum GlobalAction public enum GlobalAction

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Input; using osu.Game.Input;
@ -123,46 +124,74 @@ namespace osu.Game.Overlays.KeyBinding
base.OnHoverLost(state); base.OnHoverLost(state);
} }
public override bool AcceptsFocus => true; public override bool AcceptsFocus => bindTarget == null;
private KeyButton bindTarget; private KeyButton bindTarget;
protected override void OnFocus(InputState state) public bool AllowMainMouseButtons;
{
AutoSizeDuration = 500;
AutoSizeEasing = Easing.OutQuint;
pressAKey.FadeIn(300, Easing.OutQuint);
pressAKey.Padding = new MarginPadding();
base.OnFocus(state);
}
private bool isModifier(Key k) => k < Key.F1; private bool isModifier(Key k) => k < Key.F1;
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) protected override bool OnClick(InputState state) => true;
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{ {
switch (args.Key) if (HasFocus)
{ {
case Key.Escape: if (bindTarget.IsHovered)
GetContainingInputManager().ChangeFocus(null); {
if (!AllowMainMouseButtons)
{
switch (args.Button)
{
case MouseButton.Left:
case MouseButton.Right:
return true; return true;
case Key.Delete: }
bindTarget.UpdateKeyCombination(Key.Unknown); }
store.Update(bindTarget.KeyBinding);
GetContainingInputManager().ChangeFocus(null); bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(state));
return true;
}
}
return base.OnMouseDown(state, args);
}
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
if (HasFocus && !state.Mouse.Buttons.Any())
{
if (bindTarget.IsHovered)
finalise();
else
updateBindTarget();
return true; return true;
} }
if (HasFocus) return base.OnMouseUp(state, args);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{ {
bindTarget.UpdateKeyCombination(state.Keyboard.Keys.ToArray()); if (!HasFocus)
if (!isModifier(args.Key)) return false;
switch (args.Key)
{
case Key.Escape:
finalise();
return true;
case Key.Delete:
bindTarget.UpdateKeyCombination(InputKey.None);
finalise(); finalise();
return true; return true;
} }
return base.OnKeyDown(state, args); bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(state));
if (!isModifier(args.Key)) finalise();
return true;
} }
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) protected override bool OnKeyUp(InputState state, KeyUpEventArgs args)
@ -177,28 +206,49 @@ namespace osu.Game.Overlays.KeyBinding
} }
private void finalise() private void finalise()
{
if (bindTarget != null)
{ {
store.Update(bindTarget.KeyBinding); store.Update(bindTarget.KeyBinding);
bindTarget.IsBinding = false;
Schedule(() =>
{
// schedule to ensure we don't instantly get focus back on next OnMouseClick (see AcceptFocus impl.)
bindTarget = null;
});
}
if (HasFocus)
GetContainingInputManager().ChangeFocus(null); GetContainingInputManager().ChangeFocus(null);
pressAKey.FadeOut(300, Easing.OutQuint);
pressAKey.Padding = new MarginPadding { Bottom = -pressAKey.DrawHeight };
}
protected override void OnFocus(InputState state)
{
AutoSizeDuration = 500;
AutoSizeEasing = Easing.OutQuint;
pressAKey.FadeIn(300, Easing.OutQuint);
pressAKey.Padding = new MarginPadding();
updateBindTarget();
base.OnFocus(state);
} }
protected override void OnFocusLost(InputState state) protected override void OnFocusLost(InputState state)
{ {
bindTarget.IsBinding = false; finalise();
bindTarget = null;
pressAKey.FadeOut(300, Easing.OutQuint);
pressAKey.Padding = new MarginPadding { Bottom = -pressAKey.DrawHeight };
base.OnFocusLost(state); base.OnFocusLost(state);
} }
protected override bool OnClick(InputState state) private void updateBindTarget()
{ {
if (bindTarget != null) bindTarget.IsBinding = false; if (bindTarget != null) bindTarget.IsBinding = false;
bindTarget = buttons.FirstOrDefault(b => b.IsHovered) ?? buttons.FirstOrDefault(); bindTarget = buttons.FirstOrDefault(b => b.IsHovered) ?? buttons.FirstOrDefault();
if (bindTarget != null) bindTarget.IsBinding = true; if (bindTarget != null) bindTarget.IsBinding = true;
return bindTarget != null;
} }
private class KeyButton : Container private class KeyButton : Container
@ -296,7 +346,7 @@ namespace osu.Game.Overlays.KeyBinding
} }
} }
public void UpdateKeyCombination(params Key[] newCombination) public void UpdateKeyCombination(KeyCombination newCombination)
{ {
KeyBinding.KeyCombination = newCombination; KeyBinding.KeyCombination = newCombination;
Text.Text = KeyBinding.KeyCombination.ReadableString(); Text.Text = KeyBinding.KeyCombination.ReadableString();

View File

@ -40,7 +40,10 @@ namespace osu.Game.Overlays.KeyBinding
foreach (Enum v in Enum.GetValues(enumType)) foreach (Enum v in Enum.GetValues(enumType))
// one row per valid action. // one row per valid action.
Add(new KeyBindingRow(v, bindings.Where(b => b.Action.Equals((int)(object)v)))); Add(new KeyBindingRow(v, bindings.Where(b => b.Action.Equals((int)(object)v)))
{
AllowMainMouseButtons = Ruleset != null
});
} }
} }
} }

View File

@ -370,6 +370,9 @@ namespace osu.Game.Screens.Select
if (!track.IsRunning) if (!track.IsRunning)
{ {
// Ensure the track is added to the TrackManager, since it is removed after the player finishes the map.
// Using AddItemToList rather than AddItem so that it doesn't attempt to register adjustment dependencies more than once.
Game.Audio.Track.AddItemToList(track);
if (preview) track.Seek(Beatmap.Value.Metadata.PreviewTime); if (preview) track.Seek(Beatmap.Value.Metadata.PreviewTime);
track.Start(); track.Start();
} }