Misc - EventHandler fixed all errors.
This commit is contained in:
parent
e7d592e71a
commit
6f264f5e7b
|
@ -133,7 +133,6 @@ namespace DanBias
|
||||||
|
|
||||||
HRESULT DanBiasGame::Update(float deltaTime)
|
HRESULT DanBiasGame::Update(float deltaTime)
|
||||||
{
|
{
|
||||||
EventHandler::Instance();
|
|
||||||
|
|
||||||
if(m_data->recieverObj->IsConnected())
|
if(m_data->recieverObj->IsConnected())
|
||||||
m_data->recieverObj->Update();
|
m_data->recieverObj->Update();
|
||||||
|
|
|
@ -2,19 +2,25 @@
|
||||||
// Sam Svensson 2013 //
|
// Sam Svensson 2013 //
|
||||||
///////////////////////
|
///////////////////////
|
||||||
|
|
||||||
|
#ifndef MISC_EVENT_BUTTON_H
|
||||||
|
#define MISC_EVENT_BUTTON_H
|
||||||
#include "../../Input/L_inputClass.h"
|
#include "../../Input/L_inputClass.h"
|
||||||
#include <vector>
|
|
||||||
#include "IEventButton.h"
|
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
namespace Event
|
namespace Event
|
||||||
{
|
{
|
||||||
|
template <typename owner>
|
||||||
template <class owner>
|
class EventButton
|
||||||
class EventButton : public IEventButton
|
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
struct ButtonEvent
|
||||||
|
{
|
||||||
|
IEventButton::ButtonState state;
|
||||||
|
EventButton<owner> &sender;
|
||||||
|
owner owner;
|
||||||
|
};
|
||||||
|
|
||||||
struct PrivData
|
struct PrivData
|
||||||
{
|
{
|
||||||
static unsigned int currID;
|
static unsigned int currID;
|
||||||
|
@ -34,7 +40,7 @@ namespace Oyster
|
||||||
|
|
||||||
~EventButton();
|
~EventButton();
|
||||||
|
|
||||||
void checkCollision(InputClass *input);
|
void CheckCollision(InputClass *input);
|
||||||
|
|
||||||
void SetEventFunc(void (*EventFunc)( ButtonEvent e )); //?
|
void SetEventFunc(void (*EventFunc)( ButtonEvent e )); //?
|
||||||
|
|
||||||
|
@ -44,7 +50,7 @@ namespace Oyster
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class owner>
|
template <typename owner>
|
||||||
EventButton<owner>::EventButton()
|
EventButton<owner>::EventButton()
|
||||||
{
|
{
|
||||||
this->privData.ID = privData.currID;
|
this->privData.ID = privData.currID;
|
||||||
|
@ -53,7 +59,7 @@ namespace Oyster
|
||||||
this->privData.EventFunc = NULL;
|
this->privData.EventFunc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class owner>
|
template <typename owner>
|
||||||
EventButton<owner>::EventButton(owner owner)
|
EventButton<owner>::EventButton(owner owner)
|
||||||
{
|
{
|
||||||
this->privData.ID = privData.currID;
|
this->privData.ID = privData.currID;
|
||||||
|
@ -62,7 +68,7 @@ namespace Oyster
|
||||||
this->privData.EventFunc = NULL;
|
this->privData.EventFunc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class owner>
|
template <typename owner>
|
||||||
EventButton<owner>::EventButton(void (*EventFunc)( ButtonEvent e))
|
EventButton<owner>::EventButton(void (*EventFunc)( ButtonEvent e))
|
||||||
{
|
{
|
||||||
this->privData.ID = privData.currID;
|
this->privData.ID = privData.currID;
|
||||||
|
@ -71,7 +77,7 @@ namespace Oyster
|
||||||
this->privData.EventFunc = EventFunc;
|
this->privData.EventFunc = EventFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class owner>
|
template <typename owner>
|
||||||
EventButton<owner>::EventButton(void (*EventFunc)( ButtonEvent e), owner owner)
|
EventButton<owner>::EventButton(void (*EventFunc)( ButtonEvent e), owner owner)
|
||||||
{
|
{
|
||||||
this->privData.ID = privData.currID;
|
this->privData.ID = privData.currID;
|
||||||
|
@ -80,34 +86,36 @@ namespace Oyster
|
||||||
this->privData.EventFunc = EventFunc;
|
this->privData.EventFunc = EventFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class owner>
|
template <typename owner>
|
||||||
EventButton<owner>~EventButton()
|
EventButton<owner>::~EventButton()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class owner>
|
template <typename owner>
|
||||||
void EventButton<owner>::checkCollision(InputClass *input)
|
void EventButton<owner>::CheckCollision(InputClass *input)
|
||||||
{
|
{
|
||||||
//??????????????? TODO: everything
|
//??????????????? TODO: everything
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class owner>
|
template <typename owner>
|
||||||
void EventButton<owner>::SetEventFunc(void (*EventFunc)( ButtonEvent e ))
|
void EventButton<owner>::SetEventFunc(void (*EventFunc)( ButtonEvent e ))
|
||||||
{
|
{
|
||||||
this->privData.EventFunc = EventFunc;
|
this->privData.EventFunc = EventFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class owner>
|
template <typename owner>
|
||||||
unsigned int EventButton<owner>::GetID()
|
unsigned int EventButton<owner>::GetID()
|
||||||
{
|
{
|
||||||
return this->privData.ID;
|
return this->privData.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class owner>
|
template <typename owner>
|
||||||
owner& EventButton<owner>::GetOwner()
|
owner& EventButton<owner>::GetOwner()
|
||||||
{
|
{
|
||||||
return this->privData.owner;
|
return this->privData.owner;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
using namespace Oyster::Event;
|
using namespace Oyster::Event;
|
||||||
|
|
||||||
EventHandler EvtHandler;
|
Oyster::Event::EventHandler EvtHandler;
|
||||||
|
|
||||||
EventHandler& EventHandler::Instance()
|
EventHandler& EventHandler::Instance()
|
||||||
{
|
{
|
||||||
|
@ -32,5 +32,7 @@ void EventHandler::AddCollection(EventButtonCollection& collection)
|
||||||
|
|
||||||
EventButtonCollection& EventHandler::CreateCollection()
|
EventButtonCollection& EventHandler::CreateCollection()
|
||||||
{
|
{
|
||||||
|
EventButtonCollection temp;
|
||||||
|
collections.push_back(&temp);
|
||||||
|
return temp;
|
||||||
}
|
}
|
|
@ -14,6 +14,7 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
class EventHandler
|
class EventHandler
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
EventHandler();
|
EventHandler();
|
||||||
~EventHandler();
|
~EventHandler();
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#ifndef MISC_IEVENT_BUTTON
|
||||||
|
#define MISC_IEVENT_BUTTON
|
||||||
#include "../../Input/L_inputClass.h"
|
#include "../../Input/L_inputClass.h"
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
|
@ -7,7 +9,7 @@ namespace Oyster
|
||||||
class IEventButton
|
class IEventButton
|
||||||
{
|
{
|
||||||
|
|
||||||
private:
|
public:
|
||||||
|
|
||||||
enum ButtonState
|
enum ButtonState
|
||||||
{
|
{
|
||||||
|
@ -17,25 +19,15 @@ namespace Oyster
|
||||||
Button_Smashed,
|
Button_Smashed,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ButtonEvent
|
virtual void CheckCollision(InputClass *input) = 0;
|
||||||
{
|
|
||||||
ButtonState state;
|
|
||||||
IEventButton &sender;
|
|
||||||
|
|
||||||
template<class owner>
|
|
||||||
owner owner;
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual void checkCollision(InputClass *input) = 0;
|
|
||||||
|
|
||||||
|
struct ButtonEvent;
|
||||||
virtual void SetEventFunc(void (*EventFunc)( ButtonEvent e )) = 0;
|
virtual void SetEventFunc(void (*EventFunc)( ButtonEvent e )) = 0;
|
||||||
|
|
||||||
virtual unsigned int GetID() = 0;
|
virtual unsigned int GetID() = 0;
|
||||||
|
|
||||||
template<class owner>
|
|
||||||
virtual owner& GetOwner() = 0;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue