diff --git a/Code/Misc/EventHandler/EventButton.h b/Code/Misc/EventHandler/EventButton.h index 189102cc..e4ba0a4d 100644 --- a/Code/Misc/EventHandler/EventButton.h +++ b/Code/Misc/EventHandler/EventButton.h @@ -4,36 +4,23 @@ #include "../../Input/L_inputClass.h" #include +#include "IEventButton.h" namespace Oyster { namespace Event { - - template - class EventButton + template + class EventButton : public IEventButton { 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; + owner owner; void (*EventFunc)( ButtonEvent e ); }; @@ -41,9 +28,9 @@ namespace Oyster public: EventButton(); - EventButton(T owner); + EventButton(owner owner); EventButton(void (*EventFunc)( ButtonEvent e)); - EventButton(void (*EventFunc)( ButtonEvent e), T owner); + EventButton(void (*EventFunc)( ButtonEvent e), owner owner); ~EventButton(); @@ -52,13 +39,13 @@ namespace Oyster void SetEventFunc(void (*EventFunc)( ButtonEvent e )); //? unsigned int GetID(); - T& GetOwner(); + owner& GetOwner(); }; - template - EventButton::EventButton() + template + EventButton::EventButton() { this->privData.ID = privData.currID; this->privData.currID += 1; @@ -66,8 +53,8 @@ namespace Oyster this->privData.EventFunc = NULL; } - template - EventButton::EventButton(T owner) + template + EventButton::EventButton(owner owner) { this->privData.ID = privData.currID; this->privData.currID += 1; @@ -75,8 +62,8 @@ namespace Oyster this->privData.EventFunc = NULL; } - template - EventButton::EventButton(void (*EventFunc)( ButtonEvent e)) + template + EventButton::EventButton(void (*EventFunc)( ButtonEvent e)) { this->privData.ID = privData.currID; this->privData.currID += 1; @@ -84,8 +71,8 @@ namespace Oyster this->privData.EventFunc = EventFunc; } - template - EventButton::EventButton(void (*EventFunc)( ButtonEvent e), T owner) + template + EventButton::EventButton(void (*EventFunc)( ButtonEvent e), owner owner) { this->privData.ID = privData.currID; this->privData.currID += 1; @@ -93,32 +80,32 @@ namespace Oyster this->privData.EventFunc = EventFunc; } - template - EventButton~EventButton() + template + EventButton~EventButton() { } - template - void EventButton::checkCollision(InputClass *input) + template + void EventButton::checkCollision(InputClass *input) { //??????????????? TODO: everything } - template - void EventButton::SetEventFunc(void (*EventFunc)( ButtonEvent e )) + template + void EventButton::SetEventFunc(void (*EventFunc)( ButtonEvent e )) { this->privData.EventFunc = EventFunc; } - template - unsigned int EventButton::GetID() + template + unsigned int EventButton::GetID() { return this->privData.ID; } - template - T& EventButton::GetOwner() + template + owner& EventButton::GetOwner() { return this->privData.owner; } diff --git a/Code/Misc/EventHandler/IEventButton.h b/Code/Misc/EventHandler/IEventButton.h new file mode 100644 index 00000000..35a8827c --- /dev/null +++ b/Code/Misc/EventHandler/IEventButton.h @@ -0,0 +1,41 @@ +#include "../../Input/L_inputClass.h" + +namespace Oyster +{ + namespace Event + { + class IEventButton + { + + private: + + enum ButtonState + { + Button_Clicked, + Button_Hover, + Button_Hold, + Button_Smashed, + }; + + struct ButtonEvent + { + ButtonState state; + IEventButton &sender; + + template + owner owner; + }; + + public: + virtual void checkCollision(InputClass *input) = 0; + + virtual void SetEventFunc(void (*EventFunc)( ButtonEvent e )) = 0; + + virtual unsigned int GetID() = 0; + + template + virtual owner& GetOwner() = 0; + + }; + } +} \ No newline at end of file diff --git a/Code/Misc/Misc.vcxproj b/Code/Misc/Misc.vcxproj index 52b7c96c..2d2d35f4 100644 --- a/Code/Misc/Misc.vcxproj +++ b/Code/Misc/Misc.vcxproj @@ -167,6 +167,7 @@ + diff --git a/Code/Misc/Misc.vcxproj.filters b/Code/Misc/Misc.vcxproj.filters index d4874b4c..7bc3ffc9 100644 --- a/Code/Misc/Misc.vcxproj.filters +++ b/Code/Misc/Misc.vcxproj.filters @@ -134,5 +134,8 @@ Header Files + + Header Files + \ No newline at end of file