1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 14:53:21 +08:00

Move PlayerInputManager to own file.

This commit is contained in:
Dean Herbert 2017-01-16 11:40:52 +08:00
parent d17bef12b6
commit 70271fee35
3 changed files with 57 additions and 45 deletions

View File

@ -167,50 +167,5 @@ namespace osu.Game.Screens.Play
{
Background?.FadeTo((100f - dimLevel) / 100, 800);
}
class PlayerInputManager : UserInputManager
{
public PlayerInputManager(BasicGameHost host)
: base(host)
{
}
bool leftViaKeyboard;
bool rightViaKeyboard;
Bindable<bool> mouseDisabled;
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
mouseDisabled = config.GetBindable<bool>(OsuConfig.MouseDisableButtons)
?? new Bindable<bool>(false);
}
protected override void TransformState(InputState state)
{
base.TransformState(state);
if (state.Keyboard != null)
{
leftViaKeyboard = state.Keyboard.Keys.Contains(Key.Z);
rightViaKeyboard = state.Keyboard.Keys.Contains(Key.X);
}
MouseState mouse = (MouseState)state.Mouse;
if (state.Mouse != null)
{
if (mouseDisabled.Value)
{
mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = false;
mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = false;
}
if (leftViaKeyboard)
mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = true;
if (rightViaKeyboard)
mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = true;
}
}
}
}
}

View File

@ -0,0 +1,56 @@
using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Input;
using osu.Framework.Platform;
using osu.Game.Configuration;
using System;
using System.Linq;
namespace osu.Game.Screens.Play
{
class PlayerInputManager : UserInputManager
{
public PlayerInputManager(BasicGameHost host)
: base(host)
{
}
bool leftViaKeyboard;
bool rightViaKeyboard;
Bindable<bool> mouseDisabled;
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
mouseDisabled = config.GetBindable<bool>(OsuConfig.MouseDisableButtons)
?? new Bindable<bool>(false);
}
protected override void TransformState(InputState state)
{
base.TransformState(state);
if (state.Keyboard != null)
{
leftViaKeyboard = state.Keyboard.Keys.Contains(Key.Z);
rightViaKeyboard = state.Keyboard.Keys.Contains(Key.X);
}
var mouse = (Framework.Input.MouseState)state.Mouse;
if (state.Mouse != null)
{
if (mouseDisabled.Value)
{
mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = false;
mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = false;
}
if (leftViaKeyboard)
mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = true;
if (rightViaKeyboard)
mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = true;
}
}
}
}

View File

@ -116,6 +116,7 @@
<Compile Include="Screens\Multiplayer\Lobby.cs" />
<Compile Include="Screens\Multiplayer\Match.cs" />
<Compile Include="Screens\Multiplayer\MatchCreate.cs" />
<Compile Include="Screens\Play\PlayerInputManager.cs" />
<Compile Include="Screens\Select\CarouselContainer.cs" />
<Compile Include="Screens\Select\MatchSongSelect.cs" />
<Compile Include="Screens\OsuGameMode.cs" />