2017-04-04 09:49:18 +08:00
|
|
|
#pragma once
|
|
|
|
#include "MiniEngine.h"
|
2017-04-04 21:56:19 +08:00
|
|
|
|
2017-04-25 10:15:12 +08:00
|
|
|
namespace MiniEngine
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace EventSystem
|
|
|
|
{
|
|
|
|
|
2017-04-04 21:56:19 +08:00
|
|
|
class EventBase
|
|
|
|
{
|
2017-04-06 21:53:53 +08:00
|
|
|
public:
|
|
|
|
EventBase()=default;
|
|
|
|
EventBase(SDL_Event);
|
2017-04-04 21:56:19 +08:00
|
|
|
protected:
|
|
|
|
SDL_Event e;
|
2017-04-05 08:34:01 +08:00
|
|
|
virtual void update(const EventBase&);
|
|
|
|
friend class EventHandlerBase;
|
2017-04-04 21:56:19 +08:00
|
|
|
};
|
|
|
|
|
2017-04-05 08:34:01 +08:00
|
|
|
class MouseMotionEvent : public EventBase
|
2017-04-04 21:56:19 +08:00
|
|
|
{
|
|
|
|
public:
|
2017-04-05 08:34:01 +08:00
|
|
|
int x,y;
|
|
|
|
void update(const EventBase&);
|
|
|
|
};
|
|
|
|
|
2017-04-05 12:20:13 +08:00
|
|
|
enum class MouseButton { Left, Middle, Right, X1, X2 };
|
|
|
|
|
2017-04-05 08:34:01 +08:00
|
|
|
class MouseButtonEvent : public EventBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int x,y;
|
2017-04-05 12:20:13 +08:00
|
|
|
MouseButton button;
|
2017-04-05 08:34:01 +08:00
|
|
|
void update(const EventBase&);
|
|
|
|
};
|
|
|
|
|
2017-04-25 12:09:35 +08:00
|
|
|
class KeyEvent : public EventBase
|
2017-04-25 10:18:26 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
int key;
|
|
|
|
void update(const EventBase&);
|
|
|
|
};
|
|
|
|
|
2017-04-05 08:34:01 +08:00
|
|
|
class EventHandlerBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual bool event(const EventBase&);
|
|
|
|
protected:
|
|
|
|
virtual bool onMouseDown(const MouseButtonEvent&);
|
|
|
|
virtual bool onMouseUp(const MouseButtonEvent&);
|
2017-04-05 12:20:13 +08:00
|
|
|
virtual bool onMouseMotion(const MouseMotionEvent&);
|
2017-04-25 10:18:26 +08:00
|
|
|
virtual bool onKeyDown(const KeyEvent&);
|
|
|
|
virtual bool onKeyUp(const KeyEvent&);
|
2017-04-04 21:56:19 +08:00
|
|
|
};
|
2017-04-25 10:15:12 +08:00
|
|
|
|
|
|
|
}/// End of namespace MiniEngine::EventSystem
|
|
|
|
|
|
|
|
}/// End of namespace MiniEngine
|