2014-02-11 09:16:01 +01:00
|
|
|
//////////////////////////////////////
|
|
|
|
// Created by Pontus Fransson 2014 //
|
|
|
|
//////////////////////////////////////
|
|
|
|
|
2014-01-31 13:06:11 +01:00
|
|
|
#include "EventHandler.h"
|
|
|
|
|
|
|
|
using namespace Oyster::Event;
|
|
|
|
|
2014-01-31 15:38:12 +01:00
|
|
|
Oyster::Event::EventHandler EvtHandler;
|
2014-01-31 13:06:11 +01:00
|
|
|
|
|
|
|
EventHandler& EventHandler::Instance()
|
|
|
|
{
|
|
|
|
return EvtHandler;
|
|
|
|
}
|
|
|
|
|
|
|
|
EventHandler::EventHandler()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
EventHandler::~EventHandler()
|
|
|
|
{
|
2014-02-11 09:16:01 +01:00
|
|
|
int size = collections.size();
|
|
|
|
for(int i = 0; i < size; i++)
|
|
|
|
{
|
|
|
|
delete collections[i];
|
2014-02-12 14:52:31 +01:00
|
|
|
//collections[i] = NULL;
|
2014-02-11 09:16:01 +01:00
|
|
|
}
|
2014-01-31 13:06:11 +01:00
|
|
|
}
|
|
|
|
|
2014-02-12 09:08:38 +01:00
|
|
|
void EventHandler::Clean()
|
|
|
|
{
|
|
|
|
int size = collections.size();
|
|
|
|
for(int i = 0; i < size; i++)
|
|
|
|
{
|
|
|
|
delete collections[i];
|
2014-02-12 14:52:31 +01:00
|
|
|
//collections[i] = NULL;
|
2014-02-12 09:08:38 +01:00
|
|
|
}
|
|
|
|
collections.clear();
|
|
|
|
}
|
|
|
|
|
2014-01-31 13:06:11 +01:00
|
|
|
void EventHandler::Update(InputClass* inputObject)
|
|
|
|
{
|
2014-02-11 09:16:01 +01:00
|
|
|
for(int i = 0; i < (int)collections.size(); i++)
|
2014-01-31 13:06:11 +01:00
|
|
|
{
|
|
|
|
collections.at(i)->Update(inputObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-11 14:13:35 +01:00
|
|
|
void EventHandler::Render()
|
2014-01-31 13:06:11 +01:00
|
|
|
{
|
2014-02-11 14:13:35 +01:00
|
|
|
for(int i = 0; i < (int)collections.size(); i++)
|
|
|
|
{
|
|
|
|
collections.at(i)->Render();
|
|
|
|
}
|
2014-01-31 13:06:11 +01:00
|
|
|
}
|
|
|
|
|
2014-02-11 14:13:35 +01:00
|
|
|
void EventHandler::AddCollection(EventButtonCollection* collection)
|
2014-01-31 13:06:11 +01:00
|
|
|
{
|
2014-02-12 09:49:57 +01:00
|
|
|
for(int i = 0; i < collections.size(); i++)
|
|
|
|
{
|
|
|
|
//Do not add the collection if it's already in the list.
|
|
|
|
if(collections.at(i) == collection)
|
|
|
|
return;
|
|
|
|
}
|
2014-02-11 14:13:35 +01:00
|
|
|
collections.push_back(collection);
|
2014-02-12 09:08:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventHandler::DeleteCollection(EventButtonCollection* collection)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < collections.size(); i++)
|
|
|
|
{
|
|
|
|
if(collections.at(i) == collection)
|
|
|
|
{
|
|
|
|
delete collection;
|
2014-02-12 09:49:57 +01:00
|
|
|
collection = NULL;
|
2014-02-12 09:08:38 +01:00
|
|
|
collections.erase(collections.begin() + i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-01-31 13:06:11 +01:00
|
|
|
}
|