diff --git a/Code/Misc/EventHandler/EventButton.cpp b/Code/Misc/EventHandler/EventButton.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/Code/Misc/EventHandler/EventButton.h b/Code/Misc/EventHandler/EventButton.h index e69de29b..189102cc 100644 --- a/Code/Misc/EventHandler/EventButton.h +++ b/Code/Misc/EventHandler/EventButton.h @@ -0,0 +1,126 @@ +/////////////////////// +// Sam Svensson 2013 // +/////////////////////// + +#include "../../Input/L_inputClass.h" +#include + +namespace Oyster +{ + namespace Event + { + + template + class EventButton + { + private: + enum ButtonState + { + Button_Clicked, + Button_Hover, + Button_Hold, + Button_Smashed, + }; + struct ButtonEvent + { + ButtonState state; + EventButton &sender; + T owner; + }; + + struct PrivData + { + static unsigned int currID; + unsigned int ID; + + T owner; + void (*EventFunc)( ButtonEvent e ); + }; + + PrivData privData; + + public: + EventButton(); + EventButton(T owner); + EventButton(void (*EventFunc)( ButtonEvent e)); + EventButton(void (*EventFunc)( ButtonEvent e), T owner); + + ~EventButton(); + + void checkCollision(InputClass *input); + + void SetEventFunc(void (*EventFunc)( ButtonEvent e )); //? + + unsigned int GetID(); + T& GetOwner(); + + }; + + + template + EventButton::EventButton() + { + this->privData.ID = privData.currID; + this->privData.currID += 1; + this->privData.owner = NULL; + this->privData.EventFunc = NULL; + } + + template + EventButton::EventButton(T 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), T 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 + } + + template + void EventButton::SetEventFunc(void (*EventFunc)( ButtonEvent e )) + { + this->privData.EventFunc = EventFunc; + } + + template + unsigned int EventButton::GetID() + { + return this->privData.ID; + } + + template + T& EventButton::GetOwner() + { + return this->privData.owner; + } + } +} \ No newline at end of file