mirror of
https://github.com/ppy/osu
synced 2025-02-15 17:47:28 +00:00
MouseCount and KeyBoardCount, input handling.
This commit is contained in:
parent
e5ef3e1d02
commit
81f269ee69
30
osu.Game/Graphics/UserInterface/KeyBoardCount.cs
Normal file
30
osu.Game/Graphics/UserInterface/KeyBoardCount.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
//Copyright (c) 2007-2016 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 OpenTK;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
@ -13,5 +14,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void AddKey(Count key) => base.Add(key);
|
public void AddKey(Count key) => base.Add(key);
|
||||||
|
|
||||||
|
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
33
osu.Game/Graphics/UserInterface/MouseCount.cs
Normal file
33
osu.Game/Graphics/UserInterface/MouseCount.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -54,7 +54,9 @@
|
|||||||
<Compile Include="Graphics\Processing\RatioAdjust.cs" />
|
<Compile Include="Graphics\Processing\RatioAdjust.cs" />
|
||||||
<Compile Include="Graphics\TextAwesome.cs" />
|
<Compile Include="Graphics\TextAwesome.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\Counter.cs" />
|
<Compile Include="Graphics\UserInterface\Counter.cs" />
|
||||||
|
<Compile Include="Graphics\UserInterface\KeyBoardCount.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\KeyCounter.cs" />
|
<Compile Include="Graphics\UserInterface\KeyCounter.cs" />
|
||||||
|
<Compile Include="Graphics\UserInterface\MouseCount.cs" />
|
||||||
<Compile Include="Online\API\APIAccess.cs" />
|
<Compile Include="Online\API\APIAccess.cs" />
|
||||||
<Compile Include="Online\API\APIRequest.cs" />
|
<Compile Include="Online\API\APIRequest.cs" />
|
||||||
<Compile Include="Online\API\OAuth.cs" />
|
<Compile Include="Online\API\OAuth.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user