mirror of
https://github.com/ppy/osu.git
synced 2024-11-12 01:07:25 +08:00
Merge branch 'master' into taiko-timingchanges-2
This commit is contained in:
commit
86d97aa16b
@ -23,12 +23,12 @@ namespace osu.Game.Rulesets.Catch
|
||||
|
||||
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
|
||||
{
|
||||
new KeyBinding(Key.Z, CatchAction.MoveLeft),
|
||||
new KeyBinding(Key.Left, CatchAction.MoveLeft),
|
||||
new KeyBinding(Key.X, CatchAction.MoveRight),
|
||||
new KeyBinding(Key.Right, CatchAction.MoveRight),
|
||||
new KeyBinding(Key.LShift, CatchAction.Dash),
|
||||
new KeyBinding(Key.RShift, CatchAction.Dash),
|
||||
new KeyBinding(InputKey.Z, CatchAction.MoveLeft),
|
||||
new KeyBinding(InputKey.Left, CatchAction.MoveLeft),
|
||||
new KeyBinding(InputKey.X, CatchAction.MoveRight),
|
||||
new KeyBinding(InputKey.Right, CatchAction.MoveRight),
|
||||
new KeyBinding(InputKey.Shift, CatchAction.Dash),
|
||||
new KeyBinding(InputKey.Shift, CatchAction.Dash),
|
||||
};
|
||||
|
||||
public override IEnumerable<Mod> GetModsFor(ModType type)
|
||||
|
@ -27,10 +27,10 @@ namespace osu.Game.Rulesets.Osu
|
||||
|
||||
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
|
||||
{
|
||||
new KeyBinding(Key.Z, OsuAction.LeftButton),
|
||||
new KeyBinding(Key.X, OsuAction.RightButton),
|
||||
new KeyBinding(Key.LastKey + 1, OsuAction.LeftButton),
|
||||
new KeyBinding(Key.LastKey + 2, OsuAction.RightButton),
|
||||
new KeyBinding(InputKey.Z, OsuAction.LeftButton),
|
||||
new KeyBinding(InputKey.X, OsuAction.RightButton),
|
||||
new KeyBinding(InputKey.LastKey + 1, OsuAction.LeftButton),
|
||||
new KeyBinding(InputKey.LastKey + 2, OsuAction.RightButton),
|
||||
};
|
||||
|
||||
public override IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new[]
|
||||
|
@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK.Input;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
@ -22,16 +21,16 @@ namespace osu.Game.Input.Bindings
|
||||
|
||||
public override IEnumerable<KeyBinding> DefaultKeyBindings => new[]
|
||||
{
|
||||
new KeyBinding(Key.F8, GlobalAction.ToggleChat),
|
||||
new KeyBinding(Key.F9, GlobalAction.ToggleSocial),
|
||||
new KeyBinding(new[] { Key.LControl, Key.LAlt, Key.R }, GlobalAction.ResetInputSettings),
|
||||
new KeyBinding(new[] { Key.LControl, Key.T }, GlobalAction.ToggleToolbar),
|
||||
new KeyBinding(new[] { Key.LControl, Key.O }, GlobalAction.ToggleSettings),
|
||||
new KeyBinding(new[] { Key.LControl, Key.D }, GlobalAction.ToggleDirect),
|
||||
new KeyBinding(InputKey.F8, GlobalAction.ToggleChat),
|
||||
new KeyBinding(InputKey.F9, GlobalAction.ToggleSocial),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.R }, GlobalAction.ResetInputSettings),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.T }, GlobalAction.ToggleToolbar),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.O }, GlobalAction.ToggleSettings),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.D }, GlobalAction.ToggleDirect),
|
||||
};
|
||||
|
||||
protected override IEnumerable<Drawable> GetKeyboardInputQueue() =>
|
||||
handler == null ? base.GetKeyboardInputQueue() : new[] { handler }.Concat(base.GetKeyboardInputQueue());
|
||||
protected override IEnumerable<Drawable> KeyBindingInputQueue =>
|
||||
handler == null ? base.KeyBindingInputQueue : new[] { handler }.Concat(base.KeyBindingInputQueue);
|
||||
}
|
||||
|
||||
public enum GlobalAction
|
||||
|
@ -11,6 +11,7 @@ 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.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Input;
|
||||
@ -123,46 +124,74 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
|
||||
public override bool AcceptsFocus => true;
|
||||
public override bool AcceptsFocus => bindTarget == null;
|
||||
|
||||
private KeyButton bindTarget;
|
||||
|
||||
protected override void OnFocus(InputState state)
|
||||
{
|
||||
AutoSizeDuration = 500;
|
||||
AutoSizeEasing = Easing.OutQuint;
|
||||
|
||||
pressAKey.FadeIn(300, Easing.OutQuint);
|
||||
pressAKey.Padding = new MarginPadding();
|
||||
|
||||
base.OnFocus(state);
|
||||
}
|
||||
public bool AllowMainMouseButtons;
|
||||
|
||||
private bool isModifier(Key k) => k < Key.F1;
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
switch (args.Key)
|
||||
{
|
||||
case Key.Escape:
|
||||
GetContainingInputManager().ChangeFocus(null);
|
||||
return true;
|
||||
case Key.Delete:
|
||||
bindTarget.UpdateKeyCombination(Key.Unknown);
|
||||
store.Update(bindTarget.KeyBinding);
|
||||
GetContainingInputManager().ChangeFocus(null);
|
||||
return true;
|
||||
}
|
||||
protected override bool OnClick(InputState state) => true;
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
if (HasFocus)
|
||||
{
|
||||
bindTarget.UpdateKeyCombination(state.Keyboard.Keys.ToArray());
|
||||
if (!isModifier(args.Key))
|
||||
if (bindTarget.IsHovered)
|
||||
{
|
||||
if (!AllowMainMouseButtons)
|
||||
{
|
||||
switch (args.Button)
|
||||
{
|
||||
case MouseButton.Left:
|
||||
case MouseButton.Right:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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 base.OnKeyDown(state, args);
|
||||
return base.OnMouseUp(state, args);
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
if (!HasFocus)
|
||||
return false;
|
||||
|
||||
switch (args.Key)
|
||||
{
|
||||
case Key.Escape:
|
||||
finalise();
|
||||
return true;
|
||||
case Key.Delete:
|
||||
bindTarget.UpdateKeyCombination(InputKey.None);
|
||||
finalise();
|
||||
return true;
|
||||
}
|
||||
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(state));
|
||||
if (!isModifier(args.Key)) finalise();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args)
|
||||
@ -178,27 +207,48 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
|
||||
private void finalise()
|
||||
{
|
||||
store.Update(bindTarget.KeyBinding);
|
||||
GetContainingInputManager().ChangeFocus(null);
|
||||
if (bindTarget != null)
|
||||
{
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
bindTarget.IsBinding = false;
|
||||
bindTarget = null;
|
||||
|
||||
pressAKey.FadeOut(300, Easing.OutQuint);
|
||||
pressAKey.Padding = new MarginPadding { Bottom = -pressAKey.DrawHeight };
|
||||
finalise();
|
||||
base.OnFocusLost(state);
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
private void updateBindTarget()
|
||||
{
|
||||
if (bindTarget != null) bindTarget.IsBinding = false;
|
||||
bindTarget = buttons.FirstOrDefault(b => b.IsHovered) ?? buttons.FirstOrDefault();
|
||||
if (bindTarget != null) bindTarget.IsBinding = true;
|
||||
|
||||
return bindTarget != null;
|
||||
}
|
||||
|
||||
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;
|
||||
Text.Text = KeyBinding.KeyCombination.ReadableString();
|
||||
|
@ -40,7 +40,10 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
|
||||
foreach (Enum v in Enum.GetValues(enumType))
|
||||
// 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
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -370,6 +370,9 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
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);
|
||||
track.Start();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user