2014-02-11 09:16:01 +01:00
|
|
|
//////////////////////////////////////
|
|
|
|
// Created by Pontus Fransson 2014 //
|
|
|
|
//////////////////////////////////////
|
|
|
|
|
2014-01-31 13:06:11 +01:00
|
|
|
#include "EventButtonCollection.h"
|
2014-02-12 09:08:38 +01:00
|
|
|
#include "EventHandler.h"
|
2014-02-11 09:16:01 +01:00
|
|
|
#include "../../Input/L_inputClass.h"
|
|
|
|
|
2014-01-31 13:06:11 +01:00
|
|
|
using namespace Oyster::Event;
|
|
|
|
|
2014-02-12 09:49:57 +01:00
|
|
|
EventButtonCollection::EventButtonCollection(EventCollectionState state)
|
|
|
|
: collectionState(state)
|
2014-01-31 13:06:11 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
EventButtonCollection::~EventButtonCollection()
|
|
|
|
{
|
2014-02-12 09:08:38 +01:00
|
|
|
for(int i = 0; i < EventHandler::Instance().collections.size(); i++)
|
|
|
|
{
|
|
|
|
if(EventHandler::Instance().collections.at(i) == this)
|
|
|
|
{
|
|
|
|
EventHandler::Instance().collections.erase(EventHandler::Instance().collections.begin() + i);
|
2014-02-12 15:12:01 +01:00
|
|
|
break;
|
2014-02-12 09:08:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-11 09:16:01 +01:00
|
|
|
int size = buttons.size();
|
|
|
|
for(int i = 0; i < size; i++)
|
|
|
|
{
|
|
|
|
delete buttons[i];
|
|
|
|
buttons[i] = NULL;
|
|
|
|
}
|
2014-01-31 13:06:11 +01:00
|
|
|
}
|
|
|
|
|
2014-02-12 15:44:27 +01:00
|
|
|
void EventButtonCollection::Update(MouseInput& input)
|
2014-01-31 13:06:11 +01:00
|
|
|
{
|
2014-01-31 14:16:58 +01:00
|
|
|
if(this->collectionState == EventCollectionState_Enabled)
|
2014-01-31 13:06:11 +01:00
|
|
|
{
|
2014-02-11 09:16:01 +01:00
|
|
|
for(int i = 0; i < (int)buttons.size(); i++)
|
2014-01-31 14:16:58 +01:00
|
|
|
{
|
2014-02-12 15:44:27 +01:00
|
|
|
buttons[i]->Update(input);
|
2014-01-31 14:16:58 +01:00
|
|
|
}
|
2014-01-31 13:06:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-13 15:32:54 +01:00
|
|
|
void EventButtonCollection::RenderTexture()
|
2014-02-11 14:13:35 +01:00
|
|
|
{
|
|
|
|
if(this->collectionState == EventCollectionState_Enabled)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < (int)buttons.size(); i++)
|
|
|
|
{
|
2014-02-13 15:32:54 +01:00
|
|
|
buttons[i]->RenderTexture();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventButtonCollection::RenderText()
|
|
|
|
{
|
|
|
|
if(this->collectionState == EventCollectionState_Enabled)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < (int)buttons.size(); i++)
|
|
|
|
{
|
|
|
|
buttons[i]->RenderText();
|
2014-02-11 14:13:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-31 14:16:58 +01:00
|
|
|
EventCollectionState EventButtonCollection::GetState() const
|
|
|
|
{
|
|
|
|
return collectionState;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventButtonCollection::SetState(const EventCollectionState state)
|
2014-01-31 13:06:11 +01:00
|
|
|
{
|
2014-01-31 14:16:58 +01:00
|
|
|
collectionState = state;
|
|
|
|
}
|
2014-01-31 13:06:11 +01:00
|
|
|
|
2014-01-31 14:16:58 +01:00
|
|
|
void EventButtonCollection::Clear()
|
|
|
|
{
|
2014-02-12 09:49:57 +01:00
|
|
|
int size = buttons.size();
|
|
|
|
for(int i = 0; i < size; i++)
|
|
|
|
{
|
|
|
|
delete buttons[i];
|
|
|
|
buttons[i] = NULL;
|
|
|
|
}
|
2014-01-31 14:16:58 +01:00
|
|
|
buttons.clear();
|
2014-02-12 09:49:57 +01:00
|
|
|
|
2014-01-31 14:16:58 +01:00
|
|
|
collectionState = EventCollectionState_Enabled;
|
2014-01-31 13:06:11 +01:00
|
|
|
}
|