/////////////////////// // Sam Svensson 2013 // /////////////////////// #ifndef MISC_EVENT_BUTTON_H #define MISC_EVENT_BUTTON_H #include "../../Input/L_inputClass.h" namespace Oyster { namespace Event { template class EventButton { public: struct ButtonEvent { IEventButton::ButtonState state; EventButton &sender; owner owner; }; struct PrivData { static unsigned int currID; unsigned int ID; owner owner; void (*EventFunc)( ButtonEvent e ); }; PrivData privData; public: EventButton(); EventButton(owner owner); EventButton(void (*EventFunc)( ButtonEvent e)); EventButton(void (*EventFunc)( ButtonEvent e), owner owner); ~EventButton(); void CheckCollision(InputClass *input); void SendEvent(IEventButton::ButtonState state); void SetEventFunc(void (*EventFunc)( ButtonEvent e )); //? unsigned int GetID(); }; template unsigned int EventButton::PrivData::currID = 0; template EventButton::EventButton() { this->privData.ID = privData.currID; this->privData.currID += 1; //this->privData.owner = NULL; this->privData.EventFunc = NULL; } template EventButton::EventButton(owner owner) { this->privData.ID = privData.currID; this->privData.currID += 1; this->privData.owner = owner; this->privData.EventFunc = NULL; } template EventButton::EventButton(void (*EventFunc)( ButtonEvent e)) { this->privData.ID = privData.currID; this->privData.currID += 1; //this->privData.owner = NULL; this->privData.EventFunc = EventFunc; } template EventButton::EventButton(void (*EventFunc)( ButtonEvent e), owner owner) { this->privData.ID = privData.currID; this->privData.currID += 1; this->privData.owner = owner; this->privData.EventFunc = EventFunc; } template EventButton::~EventButton() { } template void EventButton::CheckCollision(InputClass *input) { //??????????????? TODO: everything SendEvent(Button_Smashed); } template void EventButton::SendEvent(IEventButton::ButtonState state) { ButtonEvent event; event.state = state; event.sender = this; event.owner = privData.owner; privData.EventFunc(event); } template void EventButton::SetEventFunc(void (*EventFunc)( ButtonEvent e )) { this->privData.EventFunc = EventFunc; } template unsigned int EventButton::GetID() { return this->privData.ID; } } } #endif