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