Misc - EventHandler, EventCollection updated.
This commit is contained in:
parent
d6769ac62f
commit
a864ad81e7
|
@ -3,8 +3,8 @@
|
|||
using namespace Oyster::Event;
|
||||
|
||||
EventButtonCollection::EventButtonCollection()
|
||||
: collectionState(EventCollectionState_Enabled)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
EventButtonCollection::~EventButtonCollection()
|
||||
|
@ -12,14 +12,40 @@ EventButtonCollection::~EventButtonCollection()
|
|||
}
|
||||
|
||||
void EventButtonCollection::Update(InputClass* inputObject)
|
||||
{
|
||||
if(this->collectionState == EventCollectionState_Enabled)
|
||||
{
|
||||
for(int i = 0; i < buttons.size(); i++)
|
||||
{
|
||||
buttons.at(i)->Update(inputObject);
|
||||
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;
|
||||
}
|
|
@ -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;
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue