Misc - EventHandler, EventCollection updated.

This commit is contained in:
Pontus Fransson 2014-01-31 14:16:58 +01:00
parent d6769ac62f
commit a864ad81e7
4 changed files with 54 additions and 13 deletions

View File

@ -3,8 +3,8 @@
using namespace Oyster::Event;
EventButtonCollection::EventButtonCollection()
: collectionState(EventCollectionState_Enabled)
{
}
EventButtonCollection::~EventButtonCollection()
@ -13,13 +13,39 @@ EventButtonCollection::~EventButtonCollection()
void EventButtonCollection::Update(InputClass* inputObject)
{
for(int i = 0; i < buttons.size(); i++)
if(this->collectionState == EventCollectionState_Enabled)
{
buttons.at(i)->Update(inputObject);
for(int i = 0; i < buttons.size(); i++)
{
buttons.at(i)->CheckCollision(inputObject);
}
}
}
EventButton* EventButtonCollection::AddButton(EventButton* button)
void EventButtonCollection::AddButton(EventButton& button)
{
buttons.push_back(button);
}
EventButton& EventButtonCollection::CreateButton()
{
EventButton temp;
buttons.push_back(&temp);
return temp;
}
EventCollectionState EventButtonCollection::GetState() const
{
return collectionState;
}
void EventButtonCollection::SetState(const EventCollectionState state)
{
collectionState = state;
}
void EventButtonCollection::Clear()
{
buttons.clear();
collectionState = EventCollectionState_Enabled;
}

View File

@ -11,6 +11,15 @@ namespace Oyster
{
namespace Event
{
enum EventCollectionState
{
EventCollectionState_Disabled,
EventCollectionState_Enabled,
EventCollectionState_Count,
EventCollectionState_Unknown = -1,
};
class EventButtonCollection
{
public:
@ -19,10 +28,18 @@ namespace Oyster
void Update(InputClass* inputObject);
EventButton* AddButton(EventButton* button);
void AddButton(EventButton& button);
EventButton& CreateButton();
EventCollectionState GetState() const;
void SetState(const EventCollectionState state);
//Clear all buttons and reset the state.
void Clear();
private:
std::vector<EventButton*> buttons;
EventCollectionState collectionState;
};
}

View File

@ -11,7 +11,6 @@ EventHandler& EventHandler::Instance()
EventHandler::EventHandler()
{
}
EventHandler::~EventHandler()
@ -26,12 +25,12 @@ void EventHandler::Update(InputClass* inputObject)
}
}
EventButtonCollection* EventHandler::CreateCollection()
{
}
EventButtonCollection* EventHandler::GetCollection(/*ID*/);
void EventHandler::AddCollection(EventButtonCollection& collection)
{
collections.push_back(&collection);
}
EventButtonCollection& EventHandler::CreateCollection()
{
}

View File

@ -21,9 +21,8 @@ namespace Oyster
void Update(InputClass* inputObject);
EventButtonCollection* CreateCollection();
EventButtonCollection* GetCollection(/*ID*/);
void AddCollection(EventButtonCollection& collection);
EventButtonCollection& CreateCollection();
private:
std::vector<EventButtonCollection*> collections;