summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-03 01:29:22 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-03 01:29:22 +0300
commit5e4a1bf239d76a5525a4409dc7a2094fbffe0eb3 (patch)
tree2563cd7dd22fb1370b0311e9b7b45b8657f9ecdf /src/game.cpp
parenta56d6c4d316551940982d622e9b0e3b0f1ad1863 (diff)
downloadplus-5e4a1bf239d76a5525a4409dc7a2094fbffe0eb3.tar.gz
plus-5e4a1bf239d76a5525a4409dc7a2094fbffe0eb3.tar.bz2
plus-5e4a1bf239d76a5525a4409dc7a2094fbffe0eb3.tar.xz
plus-5e4a1bf239d76a5525a4409dc7a2094fbffe0eb3.zip
Put gui input logic before most game input logic.
This solving game and gui shortcuts conflicts.
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp54
1 files changed, 29 insertions, 25 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 143751731..5c4785ef0 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -955,18 +955,10 @@ void Game::handleInput()
SDL_Event event;
while (SDL_PollEvent(&event))
{
- bool used = false;
-
updateHistory(event);
checkKeys();
- 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 (event.type == SDL_KEYDOWN)
{
if (setupWindow && setupWindow->isVisible() &&
keyboard.getNewKeyIndex() > keyboard.KEY_NO_VALUE)
@@ -985,6 +977,8 @@ void Game::handleInput()
{
if (guiInput)
guiInput->pushInput(event);
+ if (gui)
+ gui->handleInput();
}
catch (const gcn::Exception &e)
{
@@ -993,7 +987,33 @@ void Game::handleInput()
}
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 (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;
}
@@ -1007,22 +1027,6 @@ void Game::handleInput()
{
Client::setState(STATE_EXIT);
}
-
- // Push input to GUI when not used
- if (!used)
- {
- 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);
- }
- }
-
} // End while
// If the user is configuring the keys then don't respond.