86 lines
1.4 KiB
Plaintext
86 lines
1.4 KiB
Plaintext
#include "cEvent.hpp"
|
|
|
|
/*** Custom Header Files ***/
|
|
#include "../InputEngine/cInput.hpp"
|
|
#include "../MathEngine/iVector/iVector2.hpp"
|
|
#include "../GUIEngine/cGUI.hpp"
|
|
|
|
using EventEngine::cEvent;
|
|
using MathEngine::iVector2;
|
|
|
|
/*static*/ cEvent* cEvent::sp_inst = nullptr;
|
|
|
|
//Private
|
|
cEvent::cEvent()
|
|
{}
|
|
|
|
cEvent::~cEvent()
|
|
{
|
|
CleanUp();
|
|
}
|
|
|
|
//Public
|
|
/*static*/ cEvent& cEvent::Inst()
|
|
{
|
|
if (sp_inst == nullptr)
|
|
sp_inst = new cEvent();
|
|
return *sp_inst;
|
|
}
|
|
|
|
/*static*/ void cEvent::Delete()
|
|
{
|
|
delete sp_inst;
|
|
sp_inst = nullptr;
|
|
}
|
|
|
|
//Functions
|
|
const bool cEvent::Initialize() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
const bool cEvent::Setup()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
void cEvent::CleanUp()
|
|
{
|
|
}
|
|
|
|
/* Checks for Events */
|
|
void cEvent::CheckEvents()
|
|
{
|
|
while ( SDL_PollEvent(&m_event)) {
|
|
iVector2 location = { 0, 0 };
|
|
switch (m_event.type)
|
|
{
|
|
case SDL_KEYUP:
|
|
case SDL_KEYDOWN:
|
|
case SDL_JOYAXISMOTION:
|
|
case SDL_JOYBALLMOTION:
|
|
case SDL_JOYHATMOTION:
|
|
case SDL_JOYBUTTONDOWN:
|
|
case SDL_JOYBUTTONUP:
|
|
InputEngine::cInput::Inst().CheckInputs(m_event);
|
|
break;
|
|
case SDL_MOUSEBUTTONDOWN:
|
|
|
|
SDL_GetMouseState(&location.x, &location.y);
|
|
GUIEngine::cGUI::Inst().Event(location, GUIEngine::cGUI::eGUIEventType::MouseButton1);
|
|
break;
|
|
case SDL_MOUSEBUTTONUP:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///Sets
|
|
|
|
///Gets
|
|
/* Gets return true if Event was initialized */
|
|
const bool cEvent::IsInit() const
|
|
{
|
|
return true;
|
|
} |