From 35fbb7daa975d643ba98a32c5466a9dc93864527 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 7 Sep 2017 21:48:11 -0400 Subject: event order fixes --- build.sh | 14 -------------- include/ui.hpp | 2 -- main.cpp | 12 +++++------- src/ui.cpp | 14 -------------- 4 files changed, 5 insertions(+), 37 deletions(-) delete mode 100755 build.sh diff --git a/build.sh b/build.sh deleted file mode 100755 index b2ddb0a..0000000 --- a/build.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -idate=$(date +"%s" -r .git/index) -odate=$(date +"%s" -r ./.updated) - -if (( $idate > $odate )); then - echo "Project updated, building all..." - make clean - make -j4 - touch ./.updated -else - echo "Up to date, building..." - make -j4 -fi diff --git a/include/ui.hpp b/include/ui.hpp index bfa2fdd..61c06cf 100644 --- a/include/ui.hpp +++ b/include/ui.hpp @@ -130,8 +130,6 @@ namespace ui { */ void takeScreenshot(GLubyte *pixels); - - bool handleGLEvent(SDL_Event& e); } #endif // UI_HPP_ diff --git a/main.cpp b/main.cpp index 51a5776..49d1dd9 100644 --- a/main.cpp +++ b/main.cpp @@ -130,10 +130,10 @@ int main(int argc, char *argv[]) game::time::tick(); } - while (!eventQueue.empty()) { - game::events.emit(eventQueue.back()); - eventQueue.pop_back(); - } + auto clone = eventQueue; + eventQueue.clear(); + for (auto& e : clone) + game::events.emit(e); game::engine.update(game::time::getDeltaTime()); std::this_thread::sleep_for(1ms); @@ -160,10 +160,8 @@ int main(int argc, char *argv[]) Render::render(fps); SDL_Event e; - while (SDL_PollEvent(&e)) { - ui::handleGLEvent(e); + while (SDL_PollEvent(&e)) eventQueue.push_back(e); - } } // on game end, get back together diff --git a/src/ui.cpp b/src/ui.cpp index 4eed4a3..78baa68 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -613,20 +613,6 @@ namespace ui { fclose(bmp); } - - bool handleGLEvent(SDL_Event& e) { - switch (e.type) { - case SDL_MOUSEBUTTONDOWN: - if ((UISystem::isDialog() | pageTexReady) && (e.button.button & SDL_BUTTON_RIGHT)) - UISystem::advanceDialog(); - return true; - break; - default: - break; - } - - return false; - } } using namespace ui; -- cgit v1.2.3