Added Event types

This commit is contained in:
Simon Lübeß
2020-11-08 18:20:50 +01:00
parent 6de44d40b3
commit 30c898185d
4 changed files with 331 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
using System;
namespace GlitchyEngine.Events
{
public abstract class KeyEvent : Event
{
protected int32 _keyCode;
[Inline]
public int32 KeyCode => _keyCode;
public override EventCategory Category => .Input | .Keyboard
protected this(int32 keyCode)
{
_keyCode = keyCode;
}
}
public class KeyPressedEvent : KeyEvent, IEvent
{
private int32 _repeatCount;
public int32 RepeatCount => _repeatCount;
public override EventType EventType => .KeyPressed;
public static EventType StaticType => .KeyPressed;
public override StringView Name => "KeyPressed";
public this(int32 keyCode, int32 repeatCount) : base(keyCode)
{
_repeatCount = repeatCount;
}
public override void ToString(String strBuffer)
{
strBuffer.AppendF("KeyPressedEvent: {} ({} repeats)", _keyCode, _repeatCount);
}
}
public class KeyReleasedEvent : KeyEvent, IEvent
{
public override EventType EventType => .KeyReleased;
public static EventType StaticType => .KeyReleased;
public override StringView Name => "KeyReleased";
public this(int32 keyCode) : base(keyCode) { }
public override void ToString(String strBuffer)
{
strBuffer.AppendF("KeyReleasedEvent: {}", _keyCode);
}
}
}