merge total remake

This commit is contained in:
Eduardo Bart
2011-08-13 23:09:11 -03:00
parent 0af7856475
commit 55862b07ad
253 changed files with 6777 additions and 8463 deletions

View File

@@ -0,0 +1,38 @@
#ifndef EVENTDISPATCHER_H
#define EVENTDISPATCHER_H
#include <global.h>
struct ScheduledEvent {
ScheduledEvent(int ticks, const SimpleCallback& callback) : ticks(ticks), callback(callback) { }
bool operator<(const ScheduledEvent& other) const { return ticks > other.ticks; }
int ticks;
SimpleCallback callback;
};
class EventDispatcher
{
public:
/// Initialize dispatcher
void init();
/// Cleanup scheduled events
void terminate();
/// Execute scheduled events
void poll();
/// Add an event
void addEvent(const SimpleCallback& callback, bool pushFront = false);
/// Schedule an event
void scheduleEvent(const SimpleCallback& callback, int delay);
private:
std::list<SimpleCallback> m_eventList;
std::priority_queue<ScheduledEvent> m_scheduledEventList;
};
extern EventDispatcher g_dispatcher;
#endif