From 933791ef82d6a4566b15c25cf1db2762f4716a87 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 3 Apr 2012 23:09:23 +0300 Subject: Move some input handling code from game to inputmanager. --- src/game.cpp | 55 ++----------------------------------------------------- 1 file changed, 2 insertions(+), 53 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 5c4785ef0..670188038 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -958,65 +958,14 @@ void Game::handleInput() updateHistory(event); checkKeys(); - if (event.type == SDL_KEYDOWN) - { - if (setupWindow && setupWindow->isVisible() && - keyboard.getNewKeyIndex() > keyboard.KEY_NO_VALUE) - { - keyboard.setNewKey(event); - keyboard.callbackNewKey(); - keyboard.setNewKeyIndex(keyboard.KEY_NO_VALUE); - return; - } - - // send straight to gui for certain windows - if (quitDialog || TextDialog::isActive() || - NpcPostDialog::isActive()) - { - try - { - if (guiInput) - guiInput->pushInput(event); - if (gui) - gui->handleInput(); - } - catch (const gcn::Exception &e) - { - const char* err = e.getMessage().c_str(); - logger->log("Warning: guichan input exception: %s", err); - } - return; - } - } - - try - { - if (guiInput) - guiInput->pushInput(event); - } - catch (const gcn::Exception &e) - { - const char *err = e.getMessage().c_str(); - logger->log("Warning: guichan input exception: %s", err); - } - if (gui) - { - bool res = gui->handleInput(); - if (res && event.type == SDL_KEYDOWN) - return; - } + if (inputManager.handleEvent(event)) + return; if (event.type == SDL_VIDEORESIZE) { // Let the client deal with this one (it'll pass down from there) Client::resize(event.resize.w, event.resize.h); } - // Keyboard events (for discontinuous keys) - else if (event.type == SDL_KEYDOWN) - { - if (inputManager.handleKeyEvent(event)) - return; - } // Active event else if (event.type == SDL_ACTIVEEVENT) { -- cgit v1.2.3-60-g2f50