diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-01-30 23:59:09 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-01-30 23:59:09 +0300 |
commit | cc87cce57186c59fdf49a9f46d216063757638ec (patch) | |
tree | 6499daff872f9464c53a390bb6bd0543d4639226 /src | |
parent | 0fc75f671dace65f1ed8d5b6a66b17b9ab15a9c2 (diff) | |
download | mv-cc87cce57186c59fdf49a9f46d216063757638ec.tar.gz mv-cc87cce57186c59fdf49a9f46d216063757638ec.tar.bz2 mv-cc87cce57186c59fdf49a9f46d216063757638ec.tar.xz mv-cc87cce57186c59fdf49a9f46d216063757638ec.zip |
Rename isKeyActive to isActionActive om keyboard config class.
Diffstat (limited to 'src')
-rw-r--r-- | src/game.cpp | 111 | ||||
-rw-r--r-- | src/gui/chatwindow.cpp | 8 | ||||
-rw-r--r-- | src/gui/inventorywindow.cpp | 6 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 8 | ||||
-rw-r--r-- | src/keyboardconfig.cpp | 2 | ||||
-rw-r--r-- | src/keyboardconfig.h | 2 |
6 files changed, 69 insertions, 68 deletions
diff --git a/src/game.cpp b/src/game.cpp index fcec7731b..0d5c1113e 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -726,10 +726,10 @@ bool Game::handleOutfitsKeys(SDL_Event &event, bool &used) { bool wearOutfit = false; bool copyOutfit = false; - if (keyboard.isKeyActive(keyboard.KEY_WEAR_OUTFIT)) + if (keyboard.isActionActive(keyboard.KEY_WEAR_OUTFIT)) wearOutfit = true; - if (keyboard.isKeyActive(keyboard.KEY_COPY_OUTFIT)) + if (keyboard.isActionActive(keyboard.KEY_COPY_OUTFIT)) copyOutfit = true; if (wearOutfit || copyOutfit) @@ -746,15 +746,15 @@ bool Game::handleOutfitsKeys(SDL_Event &event, bool &used) } else { - if (keyboard.isKeyActive(keyboard.KEY_MOVE_RIGHT)) + if (keyboard.isActionActive(keyboard.KEY_MOVE_RIGHT)) outfitWindow->wearNextOutfit(); - else if (keyboard.isKeyActive(keyboard.KEY_MOVE_LEFT)) + else if (keyboard.isActionActive(keyboard.KEY_MOVE_LEFT)) outfitWindow->wearPreviousOutfit(); } setValidSpeed(); return true; } - else if (keyboard.isKeyActive(keyboard.KEY_MOVE_TO_POINT)) + else if (keyboard.isActionActive(keyboard.KEY_MOVE_TO_POINT)) { int num = outfitWindow->keyToNumber( event.key.keysym.sym); @@ -775,7 +775,7 @@ bool Game::handleSwitchKeys(SDL_Event &event, bool &used) && !player_node->getAway()) { NpcDialog *dialog = NpcDialog::getActive(); - if (keyboard.isKeyActive(keyboard.KEY_OK) + if (keyboard.isActionActive(keyboard.KEY_OK) && (!dialog || !dialog->isTextInputFocused())) { // Close the Browser if opened @@ -792,7 +792,7 @@ bool Game::handleSwitchKeys(SDL_Event &event, bool &used) dialog->action(gcn::ActionEvent(nullptr, "ok")); } } - if (chatWindow && keyboard.isKeyActive( + if (chatWindow && keyboard.isActionActive( keyboard.KEY_TOGGLE_CHAT)) { if (!InventoryWindow::isAnyInputFocused()) @@ -803,9 +803,9 @@ bool Game::handleSwitchKeys(SDL_Event &event, bool &used) } if (dialog) { - if (keyboard.isKeyActive(keyboard.KEY_MOVE_UP)) + if (keyboard.isActionActive(keyboard.KEY_MOVE_UP)) dialog->move(1); - else if (keyboard.isKeyActive(keyboard.KEY_MOVE_DOWN)) + else if (keyboard.isActionActive(keyboard.KEY_MOVE_DOWN)) dialog->move(-1); } } @@ -815,27 +815,27 @@ bool Game::handleSwitchKeys(SDL_Event &event, bool &used) !InventoryWindow::isAnyInputFocused()) || (event.key.keysym.mod & KMOD_ALT))) { - if (keyboard.isKeyActive(keyboard.KEY_PREV_CHAT_TAB)) + if (keyboard.isActionActive(keyboard.KEY_PREV_CHAT_TAB)) { chatWindow->prevTab(); return true; } - else if (keyboard.isKeyActive(keyboard.KEY_NEXT_CHAT_TAB)) + else if (keyboard.isActionActive(keyboard.KEY_NEXT_CHAT_TAB)) { chatWindow->nextTab(); return true; } - else if (keyboard.isKeyActive(keyboard.KEY_PREV_SOCIAL_TAB)) + else if (keyboard.isActionActive(keyboard.KEY_PREV_SOCIAL_TAB)) { socialWindow->prevTab(); return true; } - else if (keyboard.isKeyActive(keyboard.KEY_NEXT_SOCIAL_TAB)) + else if (keyboard.isActionActive(keyboard.KEY_NEXT_SOCIAL_TAB)) { socialWindow->nextTab(); return true; } - else if (keyboard.isKeyActive(keyboard.KEY_CLOSE_CHAT_TAB)) + else if (keyboard.isActionActive(keyboard.KEY_CLOSE_CHAT_TAB)) { chatWindow->closeTab(); return true; @@ -965,9 +965,9 @@ bool Game::handleSwitchKeys(SDL_Event &event, bool &used) case KeyboardConfig::KEY_MOVE_TO_TARGET: if (player_node) { - if (!keyboard.isKeyActive( + if (!keyboard.isActionActive( keyboard.KEY_TARGET_ATTACK) - && !keyboard.isKeyActive(keyboard.KEY_ATTACK)) + && !keyboard.isActionActive(keyboard.KEY_ATTACK)) { player_node->moveToTarget(); } @@ -977,9 +977,9 @@ bool Game::handleSwitchKeys(SDL_Event &event, bool &used) case KeyboardConfig::KEY_MOVE_TO_HOME: if (player_node) { - if (!keyboard.isKeyActive( + if (!keyboard.isActionActive( keyboard.KEY_TARGET_ATTACK) - && !keyboard.isKeyActive(keyboard.KEY_ATTACK)) + && !keyboard.isActionActive(keyboard.KEY_ATTACK)) { player_node->moveToHome(); } @@ -1102,8 +1102,8 @@ bool Game::handleSwitchKeys(SDL_Event &event, bool &used) if (!NpcDialog::isAnyInputFocused() && !InventoryWindow::isAnyInputFocused() - && !keyboard.isKeyActive(keyboard.KEY_TARGET) - && !keyboard.isKeyActive(keyboard.KEY_UNTARGET)) + && !keyboard.isActionActive(keyboard.KEY_TARGET) + && !keyboard.isActionActive(keyboard.KEY_UNTARGET)) { if (setupWindow && setupWindow->isVisible()) { @@ -1149,7 +1149,7 @@ bool Game::handleSwitchKeys(SDL_Event &event, bool &used) // Player sit action if (player_node) { - if (keyboard.isKeyActive(keyboard.KEY_EMOTE)) + if (keyboard.isActionActive(keyboard.KEY_EMOTE)) player_node->updateSit(); else player_node->toggleSit(); @@ -1322,8 +1322,8 @@ void Game::handleMoveAndAttack(SDL_Event &event, bool wasDown) // Ignore input if either "ignore" key is pressed // Stops the character moving about if the user's window manager // uses "ignore+arrow key" to switch virtual desktops. - if (keyboard.isKeyActive(keyboard.KEY_IGNORE_INPUT_1) || - keyboard.isKeyActive(keyboard.KEY_IGNORE_INPUT_2)) + if (keyboard.isActionActive(keyboard.KEY_IGNORE_INPUT_1) || + keyboard.isActionActive(keyboard.KEY_IGNORE_INPUT_2)) { return; } @@ -1331,14 +1331,14 @@ void Game::handleMoveAndAttack(SDL_Event &event, bool wasDown) unsigned char direction = 0; // Translate pressed keys to movement and direction - if (keyboard.isKeyActive(keyboard.KEY_MOVE_UP) || + if (keyboard.isActionActive(keyboard.KEY_MOVE_UP) || (joystick && joystick->isUp())) { direction |= Being::UP; setValidSpeed(); player_node->cancelFollow(); } - else if (keyboard.isKeyActive(keyboard.KEY_MOVE_DOWN) || + else if (keyboard.isActionActive(keyboard.KEY_MOVE_DOWN) || (joystick && joystick->isDown())) { direction |= Being::DOWN; @@ -1346,23 +1346,23 @@ void Game::handleMoveAndAttack(SDL_Event &event, bool wasDown) player_node->cancelFollow(); } - if (keyboard.isKeyActive(keyboard.KEY_MOVE_LEFT) || + if (keyboard.isActionActive(keyboard.KEY_MOVE_LEFT) || (joystick && joystick->isLeft())) { direction |= Being::LEFT; setValidSpeed(); player_node->cancelFollow(); } - else if (keyboard.isKeyActive(keyboard.KEY_MOVE_RIGHT) || + else if (keyboard.isActionActive(keyboard.KEY_MOVE_RIGHT) || (joystick && joystick->isRight())) { direction |= Being::RIGHT; setValidSpeed(); player_node->cancelFollow(); } - else if (!keyboard.isKeyActive(keyboard.KEY_EMOTE)) + else if (!keyboard.isActionActive(keyboard.KEY_EMOTE)) { - if (keyboard.isKeyActive(keyboard.KEY_DIRECT_UP)) + if (keyboard.isActionActive(keyboard.KEY_DIRECT_UP)) { if (player_node->getDirection() != Being::UP) { @@ -1373,7 +1373,7 @@ void Game::handleMoveAndAttack(SDL_Event &event, bool wasDown) } } } - else if (keyboard.isKeyActive(keyboard.KEY_DIRECT_DOWN)) + else if (keyboard.isActionActive(keyboard.KEY_DIRECT_DOWN)) { if (player_node->getDirection() != Being::DOWN) { @@ -1384,7 +1384,7 @@ void Game::handleMoveAndAttack(SDL_Event &event, bool wasDown) } } } - else if (keyboard.isKeyActive(keyboard.KEY_DIRECT_LEFT)) + else if (keyboard.isActionActive(keyboard.KEY_DIRECT_LEFT)) { if (player_node->getDirection() != Being::LEFT) { @@ -1395,7 +1395,7 @@ void Game::handleMoveAndAttack(SDL_Event &event, bool wasDown) } } } - else if (keyboard.isKeyActive(keyboard.KEY_DIRECT_RIGHT)) + else if (keyboard.isActionActive(keyboard.KEY_DIRECT_RIGHT)) { if (player_node->getDirection() != Being::RIGHT) { @@ -1408,7 +1408,7 @@ void Game::handleMoveAndAttack(SDL_Event &event, bool wasDown) } } - if (keyboard.isKeyActive(keyboard.KEY_EMOTE) && direction != 0) + if (keyboard.isActionActive(keyboard.KEY_EMOTE) && direction != 0) { if (player_node->getDirection() != direction) { @@ -1452,18 +1452,19 @@ void Game::handleMoveAndAttack(SDL_Event &event, bool wasDown) || joyAttack) && mValidSpeed) { // Attacking monsters - if (keyboard.isKeyActive(keyboard.KEY_ATTACK)) + if (keyboard.isActionActive(keyboard.KEY_ATTACK)) { if (player_node->getTarget()) player_node->attack(player_node->getTarget(), true); } - if ((keyboard.isKeyActive(keyboard.KEY_TARGET_ATTACK) || joyAttack) - && !keyboard.isKeyActive(keyboard.KEY_MOVE_TO_TARGET)) + if ((keyboard.isActionActive(keyboard.KEY_TARGET_ATTACK) + || joyAttack) + && !keyboard.isActionActive(keyboard.KEY_MOVE_TO_TARGET)) { Being *target = nullptr; - bool newTarget = !keyboard.isKeyActive(keyboard.KEY_TARGET); + bool newTarget = !keyboard.isActionActive(keyboard.KEY_TARGET); // A set target has highest priority if (!player_node->getTarget()) { @@ -1480,27 +1481,27 @@ void Game::handleMoveAndAttack(SDL_Event &event, bool wasDown) } } - if (!keyboard.isKeyActive(keyboard.KEY_EMOTE)) + if (!keyboard.isActionActive(keyboard.KEY_EMOTE)) { // Target the nearest player/monster/npc - if ((keyboard.isKeyActive(keyboard.KEY_TARGET_PLAYER) || - keyboard.isKeyActive(keyboard.KEY_TARGET_CLOSEST) || - keyboard.isKeyActive(keyboard.KEY_TARGET_NPC) || + if ((keyboard.isActionActive(keyboard.KEY_TARGET_PLAYER) || + keyboard.isActionActive(keyboard.KEY_TARGET_CLOSEST) || + keyboard.isActionActive(keyboard.KEY_TARGET_NPC) || (joystick && joystick->buttonPressed(3))) && - !keyboard.isKeyActive(keyboard.KEY_TARGET) && - !keyboard.isKeyActive(keyboard.KEY_UNTARGET)) + !keyboard.isActionActive(keyboard.KEY_TARGET) && + !keyboard.isActionActive(keyboard.KEY_UNTARGET)) { ActorSprite::Type currentTarget = ActorSprite::UNKNOWN; - if (keyboard.isKeyActive(keyboard.KEY_TARGET_CLOSEST) || + if (keyboard.isActionActive(keyboard.KEY_TARGET_CLOSEST) || (joystick && joystick->buttonPressed(3))) { currentTarget = ActorSprite::MONSTER; } - else if (keyboard.isKeyActive(keyboard.KEY_TARGET_PLAYER)) + else if (keyboard.isActionActive(keyboard.KEY_TARGET_PLAYER)) { currentTarget = ActorSprite::PLAYER; } - else if (keyboard.isKeyActive(keyboard.KEY_TARGET_NPC)) + else if (keyboard.isActionActive(keyboard.KEY_TARGET_NPC)) { currentTarget = ActorSprite::NPC; } @@ -1524,7 +1525,7 @@ void Game::handleMoveAndAttack(SDL_Event &event, bool wasDown) // Talk to the nearest NPC if 't' pressed if (wasDown && keyboard.getKeyIndex(event.key.keysym.sym) == KeyboardConfig::KEY_TALK && - !keyboard.isKeyActive(keyboard.KEY_EMOTE)) + !keyboard.isActionActive(keyboard.KEY_EMOTE)) { Being *target = player_node->getTarget(); @@ -1538,15 +1539,15 @@ void Game::handleMoveAndAttack(SDL_Event &event, bool wasDown) } // Stop attacking if the right key is pressed - if (!keyboard.isKeyActive(keyboard.KEY_ATTACK) - && !keyboard.isKeyActive(keyboard.KEY_EMOTE)) + if (!keyboard.isActionActive(keyboard.KEY_ATTACK) + && !keyboard.isActionActive(keyboard.KEY_EMOTE)) { - if (keyboard.isKeyActive(keyboard.KEY_TARGET) + if (keyboard.isActionActive(keyboard.KEY_TARGET) || (joystick && joystick->buttonPressed(4))) { player_node->stopAttack(); } - else if (keyboard.isKeyActive(keyboard.KEY_UNTARGET)) + else if (keyboard.isActionActive(keyboard.KEY_UNTARGET)) { player_node->untarget(); } @@ -1671,7 +1672,7 @@ void Game::handleInput() } if (chatWindow && !chatWindow->isInputFocused() - && keyboard.isKeyActive(keyboard.KEY_RIGHT_CLICK)) + && keyboard.isActionActive(keyboard.KEY_RIGHT_CLICK)) { int mouseX, mouseY; SDL_GetMouseState(&mouseX, &mouseY); @@ -1684,7 +1685,7 @@ void Game::handleInput() } // Mode switch to emotes - if (keyboard.isKeyActive(keyboard.KEY_EMOTE)) + if (keyboard.isActionActive(keyboard.KEY_EMOTE)) { // Emotions int emotion = keyboard.getKeyEmoteOffset(event.key.keysym.sym); @@ -1738,8 +1739,8 @@ void Game::handleInput() return; // If pressed outfits keys, stop processing keys. - if (keyboard.isKeyActive(keyboard.KEY_WEAR_OUTFIT) - || keyboard.isKeyActive(keyboard.KEY_COPY_OUTFIT) + if (keyboard.isActionActive(keyboard.KEY_WEAR_OUTFIT) + || keyboard.isActionActive(keyboard.KEY_COPY_OUTFIT) || (setupWindow && setupWindow->isVisible())) { return; diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 899bbdc36..3d52e28f4 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -764,18 +764,18 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event) mCurHist = mHistory.end(); mChatInput->setText(""); } - else if (keyboard.isKeyActive(keyboard.KEY_AUTOCOMPLETE_CHAT) && + else if (keyboard.isActionActive(keyboard.KEY_AUTOCOMPLETE_CHAT) && mChatInput->getText() != "") { autoComplete(); return; } - else if (keyboard.isKeyActive(keyboard.KEY_DEACTIVATE_CHAT) && + else if (keyboard.isActionActive(keyboard.KEY_DEACTIVATE_CHAT) && mChatInput->isVisible()) { mChatInput->processVisible(false); } - else if (keyboard.isKeyActive(keyboard.KEY_CHAT_PREV_HISTORY) && + else if (keyboard.isActionActive(keyboard.KEY_CHAT_PREV_HISTORY) && mChatInput->isVisible()) { ChatTab *tab = getFocused(); @@ -807,7 +807,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event) mChatInput->getText().length())); } } - else if (keyboard.isKeyActive(keyboard.KEY_CHAT_NEXT_HISTORY) && + else if (keyboard.isActionActive(keyboard.KEY_CHAT_NEXT_HISTORY) && mChatInput->isVisible()) { ChatTab *tab = getFocused(); diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 4a54f5fb2..23f1e6fcf 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -346,7 +346,7 @@ void InventoryWindow::action(const gcn::ActionEvent &event) } else { - if (keyboard.isKeyActive(keyboard.KEY_MOD)) + if (keyboard.isActionActive(keyboard.KEY_MOD)) { Net::getInventoryHandler()->dropItem( item, item->getQuantity()); @@ -386,11 +386,11 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) { Window::mouseClicked(event); - const bool mod = (isStorageActive() && keyboard.isKeyActive( + const bool mod = (isStorageActive() && keyboard.isActionActive( keyboard.KEY_MOD)); const bool mod2 = (tradeWindow && tradeWindow->isVisible() - && keyboard.isKeyActive(keyboard.KEY_MOD)); + && keyboard.isActionActive(keyboard.KEY_MOD)); if (!mod && !mod2 && event.getButton() == gcn::MouseEvent::RIGHT) { diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index f4c6c315f..7ff2c8850 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -497,16 +497,16 @@ void Viewport::mousePressed(gcn::MouseEvent &event) } } else if (player_node->withinAttackRange(mHoverBeing) || - keyboard.isKeyActive(keyboard.KEY_ATTACK)) + keyboard.isActionActive(keyboard.KEY_ATTACK)) { if (player_node != mHoverBeing) { player_node->attack(mHoverBeing, - !keyboard.isKeyActive(keyboard.KEY_TARGET)); + !keyboard.isActionActive(keyboard.KEY_TARGET)); return; } } - else if (!keyboard.isKeyActive(keyboard.KEY_ATTACK)) + else if (!keyboard.isActionActive(keyboard.KEY_ATTACK)) { if (player_node != mHoverBeing) { @@ -522,7 +522,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) player_node->pickUp(mHoverItem); } // Just walk around - else if (!keyboard.isKeyActive(keyboard.KEY_ATTACK)) + else if (!keyboard.isActionActive(keyboard.KEY_ATTACK)) { player_node->stopAttack(); player_node->cancelFollow(); diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index 0079ee2ee..49dd56b91 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -468,7 +468,7 @@ int KeyboardConfig::getKeyEmoteOffset(int keyValue) const return 0; } -bool KeyboardConfig::isKeyActive(int index) const +bool KeyboardConfig::isActionActive(int index) const { if (!mActiveKeys) return false; diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h index 45c5ba65f..33ce6ea49 100644 --- a/src/keyboardconfig.h +++ b/src/keyboardconfig.h @@ -136,7 +136,7 @@ class KeyboardConfig /** * Checks if the key is active, by providing the key function index. */ - bool isKeyActive(int index) const; + bool isActionActive(int index) const; /** * Takes a snapshot of all the active keys. |