diff options
author | Ira Rice <irarice@gmail.com> | 2008-11-06 02:56:09 +0000 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2008-11-06 02:56:09 +0000 |
commit | cb81caa6ddbe1861d7b276d48f337dd8841d68c1 (patch) | |
tree | 9f69ddadd5e3e82215065b6377559e85ad19c959 /src/game.cpp | |
parent | 762c754670c1accb294a9d5c34dfbb32e9cfe960 (diff) | |
download | mana-cb81caa6ddbe1861d7b276d48f337dd8841d68c1.tar.gz mana-cb81caa6ddbe1861d7b276d48f337dd8841d68c1.tar.bz2 mana-cb81caa6ddbe1861d7b276d48f337dd8841d68c1.tar.xz mana-cb81caa6ddbe1861d7b276d48f337dd8841d68c1.zip |
Don't allow players to use items through item shortcuts while trading.
Patch done by Peavey on TMW.
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 152 |
1 files changed, 78 insertions, 74 deletions
diff --git a/src/game.cpp b/src/game.cpp index 10a66ce1..eb200f4a 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -672,97 +672,101 @@ void Game::handleInput() if (keyboard.isEnabled() && !chatWindow->isInputFocused()) { const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); - // Checks if any item shortcut is pressed. - for (int i = KeyboardConfig::KEY_SHORTCUT_0; - i <= KeyboardConfig::KEY_SHORTCUT_9; - i++) - { - if (tKey == i && !used) { - itemShortcut->useItem(i - KeyboardConfig::KEY_SHORTCUT_0); - break; - } - } - switch (tKey) { - case KeyboardConfig::KEY_PICKUP: + + // Do not activate shortcuts if tradewindow is visible + if (!tradeWindow->isVisible()) { - FloorItem *item = floorItemManager->findByCoordinates( - player_node->mX, player_node->mY); - - // If none below the player, try the tile in front - // of the player - if (!item) { - Uint16 x = player_node->mX; - Uint16 y = player_node->mY; - switch (player_node->getSpriteDirection()) - { - case DIRECTION_UP : --y; break; - case DIRECTION_DOWN : ++y; break; - case DIRECTION_LEFT : --x; break; - case DIRECTION_RIGHT: ++x; break; - default: break; + // Checks if any item shortcut is pressed. + for (int i = KeyboardConfig::KEY_SHORTCUT_0; + i <= KeyboardConfig::KEY_SHORTCUT_9; + i++) + { + if (tKey == i && !used) { + itemShortcut->useItem(i - KeyboardConfig::KEY_SHORTCUT_0); + break; } - item = floorItemManager->findByCoordinates(x, y); } - - if (item) - player_node->pickUp(item); - - used = true; } - break; - case KeyboardConfig::KEY_SIT: - // Player sit action - player_node->toggleSit(); - used = true; - break; - case KeyboardConfig::KEY_HIDE_WINDOWS: - // Hide certain windows - if (!chatWindow->isInputFocused()) + switch (tKey) { + case KeyboardConfig::KEY_PICKUP: { - statusWindow->setVisible(false); - inventoryWindow->setVisible(false); - skillDialog->setVisible(false); - setupWindow->setVisible(false); - equipmentWindow->setVisible(false); - helpWindow->setVisible(false); - debugWindow->setVisible(false); + FloorItem *item = floorItemManager->findByCoordinates( + player_node->mX, player_node->mY); + + // If none below the player, try the tile in front + // of the player + if (!item) { + Uint16 x = player_node->mX; + Uint16 y = player_node->mY; + switch (player_node->getSpriteDirection()) + { + case DIRECTION_UP : --y; break; + case DIRECTION_DOWN : ++y; break; + case DIRECTION_LEFT : --x; break; + case DIRECTION_RIGHT: ++x; break; + default: break; + } + item = floorItemManager->findByCoordinates(x, y); + } + + if (item) + player_node->pickUp(item); + + used = true; } break; + case KeyboardConfig::KEY_SIT: + // Player sit action + player_node->toggleSit(); + used = true; + break; + case KeyboardConfig::KEY_HIDE_WINDOWS: + // Hide certain windows + if (!chatWindow->isInputFocused()) + { + statusWindow->setVisible(false); + inventoryWindow->setVisible(false); + skillDialog->setVisible(false); + setupWindow->setVisible(false); + equipmentWindow->setVisible(false); + helpWindow->setVisible(false); + debugWindow->setVisible(false); + } + break; + } } - } - if (requestedWindow) - { - requestedWindow->setVisible(!requestedWindow->isVisible()); - if (requestedWindow->isVisible()) + if (requestedWindow) { - requestedWindow->requestMoveToTop(); + requestedWindow->setVisible(!requestedWindow->isVisible()); + if (requestedWindow->isVisible()) + { + requestedWindow->requestMoveToTop(); + } + used = true; } - used = true; - } - - } - // Quit event - else if (event.type == SDL_QUIT) - { - done = true; - } + } - // Push input to GUI when not used - if (!used) - { - try + // Quit event + else if (event.type == SDL_QUIT) { - guiInput->pushInput(event); + done = true; } - catch (gcn::Exception e) + + // Push input to GUI when not used + if (!used) { - const char* err = e.getMessage().c_str(); - logger->log("Warning: guichan input exception: %s", err); + try + { + guiInput->pushInput(event); + } + catch (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. if (!keyboard.isEnabled()) |