1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 07:43:00 +08:00

MouseCount and KeyBoardCount, input handling.

This commit is contained in:
Huo Yaoyuan 2016-09-23 18:57:19 +08:00
parent e5ef3e1d02
commit 81f269ee69
4 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,30 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Input;
using osu.Framework.Graphics;
using osu.Framework.Input;
namespace osu.Game.Graphics.UserInterface
{
class KeyBoardCount : Count
{
public Key Key { get; }
public KeyBoardCount(string name, Key key) : base(name)
{
Key = key;
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Key == this.Key) IsLit = true;
return base.OnKeyDown(state, args);
}
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args)
{
if (args.Key == this.Key) IsLit = false;
return base.OnKeyUp(state, args);
}
}
}

View File

@ -1,6 +1,7 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Graphics.UserInterface
@ -13,5 +14,7 @@ namespace osu.Game.Graphics.UserInterface
}
public void AddKey(Count key) => base.Add(key);
public override bool Contains(Vector2 screenSpacePos) => true;
}
}

View File

@ -0,0 +1,33 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using OpenTK.Input;
using osu.Framework.Graphics;
using osu.Framework.Input;
namespace osu.Game.Graphics.UserInterface
{
class MouseCount : Count
{
public MouseButton Button { get; }
public MouseCount(string name, MouseButton button) : base(name)
{
Button = button;
}
public override bool Contains(Vector2 screenSpacePos) => true;
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
if (args.Button == this.Button) IsLit = true;
return base.OnMouseDown(state, args);
}
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
if (args.Button == this.Button) IsLit = false;
return base.OnMouseUp(state, args);
}
}
}

View File

@ -54,7 +54,9 @@
<Compile Include="Graphics\Processing\RatioAdjust.cs" />
<Compile Include="Graphics\TextAwesome.cs" />
<Compile Include="Graphics\UserInterface\Counter.cs" />
<Compile Include="Graphics\UserInterface\KeyBoardCount.cs" />
<Compile Include="Graphics\UserInterface\KeyCounter.cs" />
<Compile Include="Graphics\UserInterface\MouseCount.cs" />
<Compile Include="Online\API\APIAccess.cs" />
<Compile Include="Online\API\APIRequest.cs" />
<Compile Include="Online\API\OAuth.cs" />