2014-01-31 14:29:29 +01:00
|
|
|
///////////////////////
|
|
|
|
// Sam Svensson 2013 //
|
|
|
|
///////////////////////
|
|
|
|
|
2014-01-31 15:38:12 +01:00
|
|
|
#ifndef MISC_EVENT_BUTTON_H
|
|
|
|
#define MISC_EVENT_BUTTON_H
|
2014-01-31 14:29:29 +01:00
|
|
|
#include "../../Input/L_inputClass.h"
|
|
|
|
|
|
|
|
namespace Oyster
|
|
|
|
{
|
|
|
|
namespace Event
|
|
|
|
{
|
2014-01-31 15:38:12 +01:00
|
|
|
template <typename owner>
|
|
|
|
class EventButton
|
2014-01-31 15:06:30 +01:00
|
|
|
{
|
|
|
|
private:
|
2014-01-31 15:38:12 +01:00
|
|
|
struct ButtonEvent
|
|
|
|
{
|
|
|
|
IEventButton::ButtonState state;
|
|
|
|
EventButton<owner> &sender;
|
|
|
|
owner owner;
|
|
|
|
};
|
|
|
|
|
2014-01-31 14:29:29 +01:00
|
|
|
struct PrivData
|
|
|
|
{
|
|
|
|
static unsigned int currID;
|
|
|
|
unsigned int ID;
|
|
|
|
|
2014-01-31 15:06:25 +01:00
|
|
|
owner owner;
|
2014-01-31 14:29:29 +01:00
|
|
|
void (*EventFunc)( ButtonEvent e );
|
|
|
|
};
|
|
|
|
|
|
|
|
PrivData privData;
|
|
|
|
|
|
|
|
public:
|
|
|
|
EventButton();
|
2014-01-31 15:06:25 +01:00
|
|
|
EventButton(owner owner);
|
2014-01-31 14:29:29 +01:00
|
|
|
EventButton(void (*EventFunc)( ButtonEvent e));
|
2014-01-31 15:06:25 +01:00
|
|
|
EventButton(void (*EventFunc)( ButtonEvent e), owner owner);
|
2014-01-31 14:29:29 +01:00
|
|
|
|
|
|
|
~EventButton();
|
|
|
|
|
2014-01-31 15:38:12 +01:00
|
|
|
void CheckCollision(InputClass *input);
|
2014-01-31 14:29:29 +01:00
|
|
|
|
|
|
|
void SetEventFunc(void (*EventFunc)( ButtonEvent e )); //?
|
|
|
|
|
|
|
|
unsigned int GetID();
|
2014-01-31 15:06:25 +01:00
|
|
|
owner& GetOwner();
|
2014-01-31 14:29:29 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-01-31 15:38:12 +01:00
|
|
|
template <typename owner>
|
2014-01-31 15:06:25 +01:00
|
|
|
EventButton<owner>::EventButton()
|
2014-01-31 14:29:29 +01:00
|
|
|
{
|
|
|
|
this->privData.ID = privData.currID;
|
|
|
|
this->privData.currID += 1;
|
|
|
|
this->privData.owner = NULL;
|
|
|
|
this->privData.EventFunc = NULL;
|
|
|
|
}
|
|
|
|
|
2014-01-31 15:38:12 +01:00
|
|
|
template <typename owner>
|
2014-01-31 15:06:25 +01:00
|
|
|
EventButton<owner>::EventButton(owner owner)
|
2014-01-31 14:29:29 +01:00
|
|
|
{
|
|
|
|
this->privData.ID = privData.currID;
|
|
|
|
this->privData.currID += 1;
|
|
|
|
this->privData.owner = owner;
|
|
|
|
this->privData.EventFunc = NULL;
|
|
|
|
}
|
|
|
|
|
2014-01-31 15:38:12 +01:00
|
|
|
template <typename owner>
|
2014-01-31 15:06:25 +01:00
|
|
|
EventButton<owner>::EventButton(void (*EventFunc)( ButtonEvent e))
|
2014-01-31 14:29:29 +01:00
|
|
|
{
|
|
|
|
this->privData.ID = privData.currID;
|
|
|
|
this->privData.currID += 1;
|
|
|
|
this->privData.owner = NULL;
|
|
|
|
this->privData.EventFunc = EventFunc;
|
|
|
|
}
|
|
|
|
|
2014-01-31 15:38:12 +01:00
|
|
|
template <typename owner>
|
2014-01-31 15:06:25 +01:00
|
|
|
EventButton<owner>::EventButton(void (*EventFunc)( ButtonEvent e), owner owner)
|
2014-01-31 14:29:29 +01:00
|
|
|
{
|
|
|
|
this->privData.ID = privData.currID;
|
|
|
|
this->privData.currID += 1;
|
|
|
|
this->privData.owner = owner;
|
|
|
|
this->privData.EventFunc = EventFunc;
|
|
|
|
}
|
|
|
|
|
2014-01-31 15:38:12 +01:00
|
|
|
template <typename owner>
|
|
|
|
EventButton<owner>::~EventButton()
|
2014-01-31 14:29:29 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-01-31 15:38:12 +01:00
|
|
|
template <typename owner>
|
|
|
|
void EventButton<owner>::CheckCollision(InputClass *input)
|
2014-01-31 14:29:29 +01:00
|
|
|
{
|
|
|
|
//??????????????? TODO: everything
|
|
|
|
}
|
|
|
|
|
2014-01-31 15:38:12 +01:00
|
|
|
template <typename owner>
|
2014-01-31 15:06:25 +01:00
|
|
|
void EventButton<owner>::SetEventFunc(void (*EventFunc)( ButtonEvent e ))
|
2014-01-31 14:29:29 +01:00
|
|
|
{
|
|
|
|
this->privData.EventFunc = EventFunc;
|
|
|
|
}
|
|
|
|
|
2014-01-31 15:38:12 +01:00
|
|
|
template <typename owner>
|
2014-01-31 15:06:25 +01:00
|
|
|
unsigned int EventButton<owner>::GetID()
|
2014-01-31 14:29:29 +01:00
|
|
|
{
|
|
|
|
return this->privData.ID;
|
|
|
|
}
|
|
|
|
|
2014-01-31 15:38:12 +01:00
|
|
|
template <typename owner>
|
2014-01-31 15:06:25 +01:00
|
|
|
owner& EventButton<owner>::GetOwner()
|
2014-01-31 14:29:29 +01:00
|
|
|
{
|
|
|
|
return this->privData.owner;
|
|
|
|
}
|
|
|
|
}
|
2014-01-31 15:38:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|