mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 11:27:24 +08:00
Apply changes in line with framework input adjustments
This commit is contained in:
parent
de6d1cc647
commit
a78441bc5a
@ -1,6 +1,7 @@
|
|||||||
// 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 System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
@ -9,6 +10,8 @@ namespace osu.Game.Rulesets.Osu
|
|||||||
{
|
{
|
||||||
public class OsuInputManager : RulesetInputManager<OsuAction>
|
public class OsuInputManager : RulesetInputManager<OsuAction>
|
||||||
{
|
{
|
||||||
|
public IEnumerable<OsuAction> PressedActions => KeyBindingContainer.PressedActions;
|
||||||
|
|
||||||
public OsuInputManager(RulesetInfo ruleset) : base(ruleset, 0, SimultaneousBindingMode.Unique)
|
public OsuInputManager(RulesetInfo ruleset) : base(ruleset, 0, SimultaneousBindingMode.Unique)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Input.Bindings
|
|||||||
/// A KeyBindingInputManager with a database backing for custom overrides.
|
/// A KeyBindingInputManager with a database backing for custom overrides.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The type of the custom action.</typeparam>
|
/// <typeparam name="T">The type of the custom action.</typeparam>
|
||||||
public abstract class DatabasedKeyBindingInputManager<T> : KeyBindingInputManager<T>
|
public class DatabasedKeyBindingInputManager<T> : KeyBindingContainer<T>
|
||||||
where T : struct
|
where T : struct
|
||||||
{
|
{
|
||||||
private readonly RulesetInfo ruleset;
|
private readonly RulesetInfo ruleset;
|
||||||
@ -31,7 +31,7 @@ namespace osu.Game.Input.Bindings
|
|||||||
/// <param name="ruleset">A reference to identify the current <see cref="Ruleset"/>. Used to lookup mappings. Null for global mappings.</param>
|
/// <param name="ruleset">A reference to identify the current <see cref="Ruleset"/>. Used to lookup mappings. Null for global mappings.</param>
|
||||||
/// <param name="variant">An optional variant for the specified <see cref="Ruleset"/>. Used when a ruleset has more than one possible keyboard layouts.</param>
|
/// <param name="variant">An optional variant for the specified <see cref="Ruleset"/>. Used when a ruleset has more than one possible keyboard layouts.</param>
|
||||||
/// <param name="simultaneousMode">Specify how to deal with multiple matches of <see cref="KeyCombination"/>s and <see cref="T"/>s.</param>
|
/// <param name="simultaneousMode">Specify how to deal with multiple matches of <see cref="KeyCombination"/>s and <see cref="T"/>s.</param>
|
||||||
protected DatabasedKeyBindingInputManager(RulesetInfo ruleset = null, int? variant = null, SimultaneousBindingMode simultaneousMode = SimultaneousBindingMode.None)
|
public DatabasedKeyBindingInputManager(RulesetInfo ruleset = null, int? variant = null, SimultaneousBindingMode simultaneousMode = SimultaneousBindingMode.None)
|
||||||
: base(simultaneousMode)
|
: base(simultaneousMode)
|
||||||
{
|
{
|
||||||
this.ruleset = ruleset;
|
this.ruleset = ruleset;
|
||||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Input
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Register(KeyBindingInputManager manager) => insertDefaults(manager.DefaultKeyBindings);
|
public void Register(KeyBindingContainer manager) => insertDefaults(manager.DefaultKeyBindings);
|
||||||
|
|
||||||
private void insertDefaults(IEnumerable<KeyBinding> defaults, int? rulesetId = null, int? variant = null)
|
private void insertDefaults(IEnumerable<KeyBinding> defaults, int? rulesetId = null, int? variant = null)
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Overlays.KeyBinding
|
|||||||
public override FontAwesome Icon => FontAwesome.fa_osu_hot;
|
public override FontAwesome Icon => FontAwesome.fa_osu_hot;
|
||||||
public override string Header => "Global";
|
public override string Header => "Global";
|
||||||
|
|
||||||
public GlobalKeyBindingsSection(KeyBindingInputManager manager)
|
public GlobalKeyBindingsSection(KeyBindingContainer manager)
|
||||||
{
|
{
|
||||||
Add(new DefaultBindingsSubsection(manager));
|
Add(new DefaultBindingsSubsection(manager));
|
||||||
}
|
}
|
||||||
@ -21,7 +21,7 @@ namespace osu.Game.Overlays.KeyBinding
|
|||||||
{
|
{
|
||||||
protected override string Header => string.Empty;
|
protected override string Header => string.Empty;
|
||||||
|
|
||||||
public DefaultBindingsSubsection(KeyBindingInputManager manager)
|
public DefaultBindingsSubsection(KeyBindingContainer manager)
|
||||||
: base(null)
|
: base(null)
|
||||||
{
|
{
|
||||||
Defaults = manager.DefaultKeyBindings;
|
Defaults = manager.DefaultKeyBindings;
|
||||||
|
@ -5,6 +5,8 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
@ -16,11 +18,24 @@ using OpenTK.Input;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.UI
|
namespace osu.Game.Rulesets.UI
|
||||||
{
|
{
|
||||||
public abstract class RulesetInputManager<T> : DatabasedKeyBindingInputManager<T>, ICanAttachKeyCounter, IHasReplayHandler
|
public abstract class RulesetInputManager<T> : PassThroughInputManager, ICanAttachKeyCounter, IHasReplayHandler
|
||||||
where T : struct
|
where T : struct
|
||||||
{
|
{
|
||||||
protected RulesetInputManager(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique) : base(ruleset, variant, unique)
|
public class RulesetKeyBindingContainer : DatabasedKeyBindingInputManager<T>
|
||||||
{
|
{
|
||||||
|
public RulesetKeyBindingContainer(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
|
||||||
|
: base(ruleset, variant, unique)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected readonly KeyBindingContainer<T> KeyBindingContainer;
|
||||||
|
|
||||||
|
protected override Container<Drawable> Content => KeyBindingContainer;
|
||||||
|
|
||||||
|
protected RulesetInputManager(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
|
||||||
|
{
|
||||||
|
InternalChild = KeyBindingContainer = new RulesetKeyBindingContainer(ruleset, variant, unique);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Action mapping (for replays)
|
#region Action mapping (for replays)
|
||||||
@ -41,10 +56,10 @@ namespace osu.Game.Rulesets.UI
|
|||||||
List<T> newActions = replayState.PressedActions;
|
List<T> newActions = replayState.PressedActions;
|
||||||
|
|
||||||
foreach (var released in lastPressedActions.Except(newActions))
|
foreach (var released in lastPressedActions.Except(newActions))
|
||||||
PropagateReleased(KeyBindingInputQueue, released);
|
KeyBindingContainer.TriggerReleased(released);
|
||||||
|
|
||||||
foreach (var pressed in newActions.Except(lastPressedActions))
|
foreach (var pressed in newActions.Except(lastPressedActions))
|
||||||
PropagatePressed(KeyBindingInputQueue, pressed);
|
KeyBindingContainer.TriggerPressed(pressed);
|
||||||
|
|
||||||
lastPressedActions = newActions;
|
lastPressedActions = newActions;
|
||||||
}
|
}
|
||||||
@ -203,7 +218,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
Add(receptor);
|
Add(receptor);
|
||||||
keyCounter.SetReceptor(receptor);
|
keyCounter.SetReceptor(receptor);
|
||||||
|
|
||||||
keyCounter.AddRange(DefaultKeyBindings.Select(b => b.GetAction<T>()).Distinct().Select(b => new KeyCounterAction<T>(b)));
|
keyCounter.AddRange(KeyBindingContainer.DefaultKeyBindings.Select(b => b.GetAction<T>()).Distinct().Select(b => new KeyCounterAction<T>(b)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ActionReceptor : KeyCounterCollection.Receptor, IKeyBindingHandler<T>
|
public class ActionReceptor : KeyCounterCollection.Receptor, IKeyBindingHandler<T>
|
||||||
|
Loading…
Reference in New Issue
Block a user