mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Merge branch 'master' into fix-tablet-aspect-ratio-values
This commit is contained in:
@ -3,6 +3,8 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Localisation;
|
||||
@ -13,6 +15,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
protected override LocalisableString Header => BindingSettingsStrings.ShortcutAndGameplayBindings;
|
||||
|
||||
public override IEnumerable<LocalisableString> FilterTerms => base.FilterTerms.Concat(new LocalisableString[] { "keybindings" });
|
||||
|
||||
public BindingSettings(KeyBindingPanel keyConfig)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
|
@ -33,6 +33,11 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
public class KeyBindingRow : Container, IFilterable
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked when the binding of this row is updated with a change being written.
|
||||
/// </summary>
|
||||
public Action<KeyBindingRow> BindingUpdated { get; set; }
|
||||
|
||||
private readonly object action;
|
||||
private readonly IEnumerable<RealmKeyBinding> bindings;
|
||||
|
||||
@ -153,7 +158,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
Spacing = new Vector2(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new CancelButton { Action = finalise },
|
||||
new CancelButton { Action = () => finalise(false) },
|
||||
new ClearButton { Action = clear },
|
||||
},
|
||||
},
|
||||
@ -226,7 +231,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
}
|
||||
}
|
||||
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState));
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState), KeyCombination.FromMouseButton(e.Button));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -240,7 +245,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
}
|
||||
|
||||
if (bindTarget.IsHovered)
|
||||
finalise();
|
||||
finalise(false);
|
||||
// prevent updating bind target before clear button's action
|
||||
else if (!cancelAndClearButtons.Any(b => b.IsHovered))
|
||||
updateBindTarget();
|
||||
@ -252,7 +257,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
if (bindTarget.IsHovered)
|
||||
{
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState, e.ScrollDelta));
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState, e.ScrollDelta), KeyCombination.FromScrollDelta(e.ScrollDelta).First());
|
||||
finalise();
|
||||
return true;
|
||||
}
|
||||
@ -263,10 +268,10 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
if (!HasFocus)
|
||||
if (!HasFocus || e.Repeat)
|
||||
return false;
|
||||
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState));
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState), KeyCombination.FromKey(e.Key));
|
||||
if (!isModifier(e.Key)) finalise();
|
||||
|
||||
return true;
|
||||
@ -288,7 +293,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
if (!HasFocus)
|
||||
return false;
|
||||
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState));
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState), KeyCombination.FromJoystickButton(e.Button));
|
||||
finalise();
|
||||
|
||||
return true;
|
||||
@ -310,7 +315,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
if (!HasFocus)
|
||||
return false;
|
||||
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState));
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState), KeyCombination.FromMidiKey(e.Key));
|
||||
finalise();
|
||||
|
||||
return true;
|
||||
@ -332,7 +337,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
if (!HasFocus)
|
||||
return false;
|
||||
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState));
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState), KeyCombination.FromTabletAuxiliaryButton(e.Button));
|
||||
finalise();
|
||||
|
||||
return true;
|
||||
@ -354,7 +359,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
if (!HasFocus)
|
||||
return false;
|
||||
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState));
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState), KeyCombination.FromTabletPenButton(e.Button));
|
||||
finalise();
|
||||
|
||||
return true;
|
||||
@ -377,10 +382,10 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
return;
|
||||
|
||||
bindTarget.UpdateKeyCombination(InputKey.None);
|
||||
finalise();
|
||||
finalise(false);
|
||||
}
|
||||
|
||||
private void finalise()
|
||||
private void finalise(bool hasChanged = true)
|
||||
{
|
||||
if (bindTarget != null)
|
||||
{
|
||||
@ -393,6 +398,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
// schedule to ensure we don't instantly get focus back on next OnMouseClick (see AcceptFocus impl.)
|
||||
bindTarget = null;
|
||||
if (hasChanged)
|
||||
BindingUpdated?.Invoke(this);
|
||||
});
|
||||
}
|
||||
|
||||
@ -417,7 +424,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
|
||||
protected override void OnFocusLost(FocusLostEvent e)
|
||||
{
|
||||
finalise();
|
||||
finalise(false);
|
||||
base.OnFocusLost(e);
|
||||
}
|
||||
|
||||
@ -563,6 +570,14 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update from a key combination, only allowing a single non-modifier key to be specified.
|
||||
/// </summary>
|
||||
/// <param name="fullState">A <see cref="KeyCombination"/> generated from the full input state.</param>
|
||||
/// <param name="triggerKey">The key which triggered this update, and should be used as the binding.</param>
|
||||
public void UpdateKeyCombination(KeyCombination fullState, InputKey triggerKey) =>
|
||||
UpdateKeyCombination(new KeyCombination(fullState.Keys.Where(KeyCombination.IsModifierKey).Append(triggerKey)));
|
||||
|
||||
public void UpdateKeyCombination(KeyCombination newCombination)
|
||||
{
|
||||
if (KeyBinding.RulesetName != null && !RealmKeyBindingStore.CheckValidForGameplay(newCombination))
|
||||
|
@ -19,6 +19,12 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
public abstract class KeyBindingsSubsection : SettingsSubsection
|
||||
{
|
||||
/// <summary>
|
||||
/// After a successful binding, automatically select the next binding row to make quickly
|
||||
/// binding a large set of keys easier on the user.
|
||||
/// </summary>
|
||||
protected virtual bool AutoAdvanceTarget => false;
|
||||
|
||||
protected IEnumerable<Framework.Input.Bindings.KeyBinding> Defaults;
|
||||
|
||||
public RulesetInfo Ruleset { get; protected set; }
|
||||
@ -49,7 +55,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
Add(new KeyBindingRow(defaultGroup.Key, bindings.Where(b => b.ActionInt.Equals(intKey)).ToList())
|
||||
{
|
||||
AllowMainMouseButtons = Ruleset != null,
|
||||
Defaults = defaultGroup.Select(d => d.KeyCombination)
|
||||
Defaults = defaultGroup.Select(d => d.KeyCombination),
|
||||
BindingUpdated = onBindingUpdated
|
||||
});
|
||||
}
|
||||
|
||||
@ -58,6 +65,16 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
Action = () => Children.OfType<KeyBindingRow>().ForEach(k => k.RestoreDefaults())
|
||||
});
|
||||
}
|
||||
|
||||
private void onBindingUpdated(KeyBindingRow sender)
|
||||
{
|
||||
if (AutoAdvanceTarget)
|
||||
{
|
||||
var next = Children.SkipWhile(c => c != sender).Skip(1).FirstOrDefault();
|
||||
if (next != null)
|
||||
GetContainingInputManager().ChangeFocus(next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ResetButton : DangerousSettingsButton
|
||||
|
@ -110,9 +110,10 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows || RuntimeInfo.OS == RuntimeInfo.Platform.Linux)
|
||||
{
|
||||
t.NewLine();
|
||||
var formattedSource = MessageFormatter.FormatText(localisation.GetLocalisedBindableString(TabletSettingsStrings.NoTabletDetectedDescription(RuntimeInfo.OS == RuntimeInfo.Platform.Windows
|
||||
? @"https://opentabletdriver.net/Wiki/FAQ/Windows"
|
||||
: @"https://opentabletdriver.net/Wiki/FAQ/Linux")).Value);
|
||||
var formattedSource = MessageFormatter.FormatText(localisation.GetLocalisedBindableString(TabletSettingsStrings.NoTabletDetectedDescription(
|
||||
RuntimeInfo.OS == RuntimeInfo.Platform.Windows
|
||||
? @"https://opentabletdriver.net/Wiki/FAQ/Windows"
|
||||
: @"https://opentabletdriver.net/Wiki/FAQ/Linux")).Value);
|
||||
t.AddLinks(formattedSource.Text, formattedSource.Links);
|
||||
}
|
||||
}),
|
||||
@ -273,6 +274,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
sizeY.Default = sizeY.MaxValue = tab.Size.Y;
|
||||
|
||||
areaSize.Default = new Vector2(sizeX.Default, sizeY.Default);
|
||||
areaOffset.Default = new Vector2(offsetX.Default, offsetY.Default);
|
||||
}), true);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
public class VariantBindingsSubsection : KeyBindingsSubsection
|
||||
{
|
||||
protected override bool AutoAdvanceTarget => true;
|
||||
|
||||
protected override LocalisableString Header { get; }
|
||||
|
||||
public VariantBindingsSubsection(RulesetInfo ruleset, int variant)
|
||||
|
Reference in New Issue
Block a user