From 6f264f5e7b8909ce8bb531b83a43039ef442b932 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Fri, 31 Jan 2014 15:38:12 +0100 Subject: [PATCH] Misc - EventHandler fixed all errors. --- Code/Game/DanBiasGame/DanBiasGame_Impl.cpp | 1 - Code/Misc/EventHandler/EventButton.h | 44 +++++++++++++--------- Code/Misc/EventHandler/EventHandler.cpp | 6 ++- Code/Misc/EventHandler/EventHandler.h | 1 + Code/Misc/EventHandler/IEventButton.h | 26 +++++-------- 5 files changed, 40 insertions(+), 38 deletions(-) diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 24c14a0c..ea3a3fc9 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -133,7 +133,6 @@ namespace DanBias HRESULT DanBiasGame::Update(float deltaTime) { - EventHandler::Instance(); if(m_data->recieverObj->IsConnected()) m_data->recieverObj->Update(); diff --git a/Code/Misc/EventHandler/EventButton.h b/Code/Misc/EventHandler/EventButton.h index 01da474c..547cdb47 100644 --- a/Code/Misc/EventHandler/EventButton.h +++ b/Code/Misc/EventHandler/EventButton.h @@ -2,19 +2,25 @@ // Sam Svensson 2013 // /////////////////////// +#ifndef MISC_EVENT_BUTTON_H +#define MISC_EVENT_BUTTON_H #include "../../Input/L_inputClass.h" -#include -#include "IEventButton.h" namespace Oyster { namespace Event { - - template - class EventButton : public IEventButton + template + class EventButton { private: + struct ButtonEvent + { + IEventButton::ButtonState state; + EventButton &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 + template EventButton::EventButton() { this->privData.ID = privData.currID; @@ -53,7 +59,7 @@ namespace Oyster this->privData.EventFunc = NULL; } - template + template EventButton::EventButton(owner owner) { this->privData.ID = privData.currID; @@ -62,7 +68,7 @@ namespace Oyster this->privData.EventFunc = NULL; } - template + template EventButton::EventButton(void (*EventFunc)( ButtonEvent e)) { this->privData.ID = privData.currID; @@ -71,7 +77,7 @@ namespace Oyster this->privData.EventFunc = EventFunc; } - template + template EventButton::EventButton(void (*EventFunc)( ButtonEvent e), owner owner) { this->privData.ID = privData.currID; @@ -80,34 +86,36 @@ 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 + template void EventButton::SetEventFunc(void (*EventFunc)( ButtonEvent e )) { this->privData.EventFunc = EventFunc; } - template + template unsigned int EventButton::GetID() { return this->privData.ID; } - template + template owner& EventButton::GetOwner() { return this->privData.owner; } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Code/Misc/EventHandler/EventHandler.cpp b/Code/Misc/EventHandler/EventHandler.cpp index e064ad41..0d270997 100644 --- a/Code/Misc/EventHandler/EventHandler.cpp +++ b/Code/Misc/EventHandler/EventHandler.cpp @@ -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; } \ No newline at end of file diff --git a/Code/Misc/EventHandler/EventHandler.h b/Code/Misc/EventHandler/EventHandler.h index e19a8149..7fb86b13 100644 --- a/Code/Misc/EventHandler/EventHandler.h +++ b/Code/Misc/EventHandler/EventHandler.h @@ -14,6 +14,7 @@ namespace Oyster { class EventHandler { + public: EventHandler(); ~EventHandler(); diff --git a/Code/Misc/EventHandler/IEventButton.h b/Code/Misc/EventHandler/IEventButton.h index 35a8827c..4b2467c6 100644 --- a/Code/Misc/EventHandler/IEventButton.h +++ b/Code/Misc/EventHandler/IEventButton.h @@ -1,3 +1,5 @@ +#ifndef MISC_IEVENT_BUTTON +#define MISC_IEVENT_BUTTON #include "../../Input/L_inputClass.h" namespace Oyster @@ -6,8 +8,8 @@ namespace Oyster { class IEventButton { - - private: + + public: enum ButtonState { @@ -17,25 +19,15 @@ namespace Oyster Button_Smashed, }; - struct ButtonEvent - { - ButtonState state; - IEventButton &sender; - - template - 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 - virtual owner& GetOwner() = 0; }; } -} \ No newline at end of file +} + +#endif \ No newline at end of file