summaryrefslogtreecommitdiffstats
path: root/src/control/RPGEdit.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/control/RPGEdit.hpp')
-rw-r--r--src/control/RPGEdit.hpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/control/RPGEdit.hpp b/src/control/RPGEdit.hpp
index f045265..8b5e697 100644
--- a/src/control/RPGEdit.hpp
+++ b/src/control/RPGEdit.hpp
@@ -30,8 +30,10 @@
#include "InputHandler.hpp"
#include "MapContext.hpp"
+#include <condition_variable>
#include <memory>
#include <mutex>
+#include <thread>
namespace RPGEdit {
@@ -40,6 +42,8 @@ namespace Control {
class RPGEdit {
private:
+ TimeProvider timeProvider;
+
EventBus eventBus;
InputHandler inputHandler;
ImageLoader tileLoader;
@@ -49,11 +53,20 @@ private:
std::shared_ptr<View::Window> window;
std::shared_ptr<View::MapView> mapView;
- std::mutex modelLock;
+ std::thread eventThread;
+ std::mutex modelMutex;
+ std::condition_variable modelCond;
+ uint64_t handledTime = std::numeric_limits<uint64_t>::max();
+
+ void enqueueNow(const EventBus::Event &event) {
+ eventBus.enqueue(event, timeProvider.now());
+ }
- bool systemIter(unsigned ticks);
+ bool handleSystemEvent(const SDL_Event &event);
void systemLoop();
+ void eventLoop();
+
public:
void run();
};