mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Add global actions; improve default assignment
This commit is contained in:
parent
bd84e507de
commit
34b12fbfa4
@ -11,16 +11,17 @@ namespace osu.Game.Rulesets.Catch
|
||||
{
|
||||
public CatchInputManager(RulesetInfo ruleset) : base(ruleset)
|
||||
{
|
||||
Mappings = new Dictionary<Key, CatchAction>
|
||||
{
|
||||
{ Key.Z, CatchAction.MoveLeft },
|
||||
{ Key.Left, CatchAction.MoveLeft },
|
||||
{ Key.X, CatchAction.MoveRight },
|
||||
{ Key.Right, CatchAction.MoveRight },
|
||||
{ Key.LShift, CatchAction.Dash },
|
||||
{ Key.RShift, CatchAction.Dash },
|
||||
};
|
||||
}
|
||||
|
||||
protected override IDictionary<Key, CatchAction> CreateDefaultMappings() => new Dictionary<Key, CatchAction>
|
||||
{
|
||||
{ Key.Z, CatchAction.MoveLeft },
|
||||
{ Key.Left, CatchAction.MoveLeft },
|
||||
{ Key.X, CatchAction.MoveRight },
|
||||
{ Key.Right, CatchAction.MoveRight },
|
||||
{ Key.LShift, CatchAction.Dash },
|
||||
{ Key.RShift, CatchAction.Dash },
|
||||
};
|
||||
}
|
||||
|
||||
public enum CatchAction
|
||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Input
|
||||
/// Maps custom action data of type <see cref="T"/> and stores to <see cref="InputState.Data"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the custom action.</typeparam>
|
||||
public class ActionMappingInputManager<T> : PassThroughInputManager
|
||||
public abstract class ActionMappingInputManager<T> : PassThroughInputManager
|
||||
where T : struct
|
||||
{
|
||||
private readonly RulesetInfo ruleset;
|
||||
@ -30,9 +30,13 @@ namespace osu.Game.Input
|
||||
{
|
||||
this.ruleset = ruleset;
|
||||
this.variant = variant;
|
||||
|
||||
Mappings = CreateDefaultMappings();
|
||||
}
|
||||
|
||||
protected IDictionary<Key, T> Mappings { get; set; }
|
||||
protected IDictionary<Key, T> Mappings { get; private set; }
|
||||
|
||||
protected abstract IDictionary<Key, T> CreateDefaultMappings();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(BindingStore bindings)
|
||||
|
18
osu.Game/Input/GlobalActionMappingInputManager.cs
Normal file
18
osu.Game/Input/GlobalActionMappingInputManager.cs
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Input;
|
||||
using OpenTK.Input;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game
|
||||
{
|
||||
public class GlobalActionMappingInputManager : ActionMappingInputManager<OsuAction>
|
||||
{
|
||||
protected override IDictionary<Key, OsuAction> CreateDefaultMappings() => new Dictionary<Key, OsuAction>()
|
||||
{
|
||||
{ Key.F8, OsuAction.ToggleChat },
|
||||
{ Key.F9, OsuAction.ToggleSocial },
|
||||
};
|
||||
}
|
||||
}
|
12
osu.Game/Input/OsuAction.cs
Normal file
12
osu.Game/Input/OsuAction.cs
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
|
||||
namespace osu.Game
|
||||
{
|
||||
public enum OsuAction
|
||||
{
|
||||
ToggleChat,
|
||||
ToggleSocial
|
||||
}
|
||||
}
|
@ -256,22 +256,17 @@ namespace osu.Game
|
||||
{
|
||||
if (args.Repeat || intro == null) return false;
|
||||
|
||||
switch (args.Key)
|
||||
if (state.Data is OsuAction)
|
||||
{
|
||||
case Key.F8:
|
||||
chat.ToggleVisibility();
|
||||
return true;
|
||||
case Key.F9:
|
||||
social.ToggleVisibility();
|
||||
return true;
|
||||
case Key.PageUp:
|
||||
case Key.PageDown:
|
||||
var swClock = (Clock as ThrottledFrameClock)?.Source as StopwatchClock;
|
||||
if (swClock == null) return false;
|
||||
|
||||
swClock.Rate *= args.Key == Key.PageUp ? 1.1f : 0.9f;
|
||||
Logger.Log($@"Adjusting game clock to {swClock.Rate}", LoggingTarget.Debug);
|
||||
return true;
|
||||
switch ((OsuAction)state.Data)
|
||||
{
|
||||
case OsuAction.ToggleChat:
|
||||
chat.ToggleVisibility();
|
||||
return true;
|
||||
case OsuAction.ToggleSocial:
|
||||
social.ToggleVisibility();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (state.Keyboard.ControlPressed)
|
||||
|
@ -187,13 +187,14 @@ namespace osu.Game
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Cursor = new MenuCursor(),
|
||||
new OsuTooltipContainer(Cursor)
|
||||
new GlobalActionMappingInputManager
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = content = new OsuContextMenuContainer
|
||||
Child = new OsuTooltipContainer(Cursor)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
Child = content = new OsuContextMenuContainer { RelativeSizeAxes = Axes.Both },
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -94,6 +94,8 @@
|
||||
<Compile Include="Graphics\UserInterface\OsuContextMenuItem.cs" />
|
||||
<Compile Include="Input\Binding.cs" />
|
||||
<Compile Include="Input\BindingStore.cs" />
|
||||
<Compile Include="Input\OsuAction.cs" />
|
||||
<Compile Include="Input\GlobalActionMappingInputManager.cs" />
|
||||
<Compile Include="IO\FileStore.cs" />
|
||||
<Compile Include="IO\FileInfo.cs" />
|
||||
<Compile Include="Online\API\Requests\GetUsersRequest.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user