summaryrefslogtreecommitdiff
path: root/src/eventsmanager.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-10-07 18:35:19 +0300
committerAndrei Karas <akaras@inbox.ru>2013-10-07 18:35:19 +0300
commit29cae530ae1796f37fe923fe372c695783b559de (patch)
tree0b02e47dbd52b1fada0b94b2b9956ab0b6308f6c /src/eventsmanager.cpp
parent3eb27b1cb9b1f645ab5bf9d972ce3d73ec743226 (diff)
downloadplus-29cae530ae1796f37fe923fe372c695783b559de.tar.gz
plus-29cae530ae1796f37fe923fe372c695783b559de.tar.bz2
plus-29cae530ae1796f37fe923fe372c695783b559de.tar.xz
plus-29cae530ae1796f37fe923fe372c695783b559de.zip
Move some events code from game into eventsmanager.
Diffstat (limited to 'src/eventsmanager.cpp')
-rw-r--r--src/eventsmanager.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/eventsmanager.cpp b/src/eventsmanager.cpp
index c2b4b4c72..203a7679f 100644
--- a/src/eventsmanager.cpp
+++ b/src/eventsmanager.cpp
@@ -153,6 +153,68 @@ bool EventsManager::handleEvents()
return false;
}
+void EventsManager::handleGameEvents()
+{
+ Game *const game = Game::instance();
+
+ // Events
+ SDL_Event event;
+#ifdef USE_SDL2
+ while (SDL_WaitEventTimeout(&event, 0))
+#else
+ while (SDL_PollEvent(&event))
+#endif
+ {
+ BLOCK_START("Game::handleInput 2")
+ if (mLogInput)
+ logEvent(event);
+
+ if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP)
+ game->updateHistory(event);
+ game->checkKeys();
+
+ if (inputManager.handleEvent(event))
+ {
+ BLOCK_END("Game::handleInput 2")
+ BLOCK_END("Game::handleInput 1")
+ return;
+ }
+
+ switch (event.type)
+ {
+#ifdef USE_SDL2
+ case SDL_WINDOWEVENT:
+ {
+ game->handleSDL2WindowEvent(event);
+ break;
+ }
+#else
+ case SDL_VIDEORESIZE:
+ client->resizeVideo(event.resize.w, event.resize.h);
+ break;
+ // Active event
+ case SDL_ACTIVEEVENT:
+ game->handleActive(event);
+ break;
+#endif
+ // Quit event
+ case SDL_QUIT:
+ client->setState(STATE_EXIT);
+ break;
+#ifdef ANDROID
+#ifndef USE_SDL2
+ case SDL_KEYBOARDSHOW:
+ client->updateScreenKeyboard(event.user.code);
+ break;
+#endif
+#endif
+ default:
+ break;
+ }
+ BLOCK_END("Game::handleInput 2")
+ } // End while
+}
+
void EventsManager::optionChanged(const std::string &name)
{
if (name == "logInput")