diff options
author | Ira Rice <irarice@gmail.com> | 2009-01-19 14:06:02 -0700 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-01-19 14:06:02 -0700 |
commit | 73edfce4ce8c12a8ec09a7b5f831698bd64b688b (patch) | |
tree | 4ddd30d9ecf4bec62efc6359eddaa7c7d65d46f7 | |
parent | e4ea98d7256526ec57eba1fdeebfd5828550301f (diff) | |
download | mana-73edfce4ce8c12a8ec09a7b5f831698bd64b688b.tar.gz mana-73edfce4ce8c12a8ec09a7b5f831698bd64b688b.tar.bz2 mana-73edfce4ce8c12a8ec09a7b5f831698bd64b688b.tar.xz mana-73edfce4ce8c12a8ec09a7b5f831698bd64b688b.zip |
Fixed up indentation in game so that the indentation isn't misleading.
Signed-off-by: Ira Rice <irarice@gmail.com>
-rw-r--r-- | src/game.cpp | 502 |
1 files changed, 251 insertions, 251 deletions
diff --git a/src/game.cpp b/src/game.cpp index 51a5d7d9..4c912827 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -553,141 +553,144 @@ void Game::handleInput() } } - // Mode switch to emotes - if (keyboard.isKeyActive(keyboard.KEY_EMOTE)) - { - // Emotions - int emotion = keyboard.getKeyEmoteOffset(event.key.keysym.sym); - if (emotion) + // Mode switch to emotes + if (keyboard.isKeyActive(keyboard.KEY_EMOTE)) { - emoteShortcut->useEmote(emotion); - used = true; - return; - } - } - switch (event.key.keysym.sym) - { - case SDLK_PAGEUP: - if (chatWindow->isVisible()) + // Emotions + int emotion = keyboard.getKeyEmoteOffset(event.key.keysym.sym); + if (emotion) { - chatWindow->scroll(-DEFAULT_CHAT_WINDOW_SCROLL); - used = true; - } - break; - - case SDLK_PAGEDOWN: - if (chatWindow->isVisible()) - { - chatWindow->scroll(DEFAULT_CHAT_WINDOW_SCROLL); + emoteShortcut->useEmote(emotion); used = true; return; } - break; - - case SDLK_F1: - // In-game Help - if (helpWindow->isVisible()) - { - helpWindow->setVisible(false); - } - else - { - helpWindow->loadHelp("index"); - helpWindow->requestMoveToTop(); - } - used = true; - break; + } + switch (event.key.keysym.sym) + { + case SDLK_PAGEUP: + if (chatWindow->isVisible()) + { + chatWindow->scroll(-DEFAULT_CHAT_WINDOW_SCROLL); + used = true; + } + break; - case SDLK_RETURN: - // Input chat window - if (chatWindow->isInputFocused() || - deathNotice != NULL || - weightNotice != NULL) - { + case SDLK_PAGEDOWN: + if (chatWindow->isVisible()) + { + chatWindow->scroll(DEFAULT_CHAT_WINDOW_SCROLL); + used = true; + return; + } break; - } - // Quit by pressing Enter if the exit confirm is there - if (exitConfirm) - { - done = true; - } - // Close the Browser if opened - else if (helpWindow->isVisible()) - { - helpWindow->setVisible(false); - } - // Close the config window, cancelling changes if opened - else if (setupWindow->isVisible()) - { - setupWindow->action(gcn::ActionEvent(NULL, "cancel")); - } - // Submits the text and proceeds to the next dialog - else if (npcStringDialog->isVisible()) - { - npcStringDialog->action(gcn::ActionEvent(NULL, "ok")); - } - // Proceed to the next dialog option, or close the window - else if (npcTextDialog->isVisible()) - { - npcTextDialog->action(gcn::ActionEvent(NULL, "ok")); - } - // Choose the currently highlighted dialogue option - else if (npcListDialog->isVisible()) - { - npcListDialog->action(gcn::ActionEvent(NULL, "ok")); - } - // Submits the text and proceeds to the next dialog - else if (npcIntegerDialog->isVisible()) - { - npcIntegerDialog->action(gcn::ActionEvent(NULL, "ok")); - } - // Else, open the chat edit box - else - { - chatWindow->requestChatFocus(); + case SDLK_F1: + // In-game Help + if (helpWindow->isVisible()) + { + helpWindow->setVisible(false); + } + else + { + helpWindow->loadHelp("index"); + helpWindow->requestMoveToTop(); + } used = true; - } - break; - // Quitting confirmation dialog - case SDLK_ESCAPE: - if (!exitConfirm) { - exitConfirm = new ConfirmDialog( - _("Quit"), _("Are you sure you want to quit?")); - exitConfirm->addActionListener(&exitListener); - exitConfirm->requestMoveToTop(); - } - else - { - exitConfirm->action(gcn::ActionEvent(NULL, _("no"))); - } - break; + break; - default: - break; - } - if (keyboard.isEnabled() && !chatWindow->isInputFocused() - && !npcStringDialog->isInputFocused()) - { - const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); - // Do not activate shortcuts if tradewindow is visible - if (!tradeWindow->isVisible()) + case SDLK_RETURN: + // Input chat window + if (chatWindow->isInputFocused() || + deathNotice != NULL || + weightNotice != NULL) + { + break; + } + + // Quit by pressing Enter if the exit confirm is there + if (exitConfirm) + { + done = true; + } + // Close the Browser if opened + else if (helpWindow->isVisible()) + { + helpWindow->setVisible(false); + } + // Close the config window, cancelling changes if opened + else if (setupWindow->isVisible()) + { + setupWindow->action(gcn::ActionEvent(NULL, "cancel")); + } + // Submits the text and proceeds to the next dialog + else if (npcStringDialog->isVisible()) + { + npcStringDialog->action(gcn::ActionEvent(NULL, "ok")); + } + // Proceed to the next dialog option, or close the window + else if (npcTextDialog->isVisible()) + { + npcTextDialog->action(gcn::ActionEvent(NULL, "ok")); + } + // Choose the currently highlighted dialogue option + else if (npcListDialog->isVisible()) + { + npcListDialog->action(gcn::ActionEvent(NULL, "ok")); + } + // Submits the text and proceeds to the next dialog + else if (npcIntegerDialog->isVisible()) + { + npcIntegerDialog->action(gcn::ActionEvent(NULL, "ok")); + } + // Else, open the chat edit box + else + { + chatWindow->requestChatFocus(); + used = true; + } + break; + // Quitting confirmation dialog + case SDLK_ESCAPE: + if (!exitConfirm) + { + exitConfirm = new ConfirmDialog( _("Quit"), + _("Are you sure you " + "want to quit?")); + exitConfirm->addActionListener(&exitListener); + exitConfirm->requestMoveToTop(); + } + else + { + exitConfirm->action(gcn::ActionEvent(NULL, _("no"))); + } + break; + + default: + break; + } + if (keyboard.isEnabled() && !chatWindow->isInputFocused() + && !npcStringDialog->isInputFocused()) { - // Checks if any item shortcut is pressed. - for (int i = KeyboardConfig::KEY_SHORTCUT_1; - i <= KeyboardConfig::KEY_SHORTCUT_12; - i++) + const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); + // Do not activate shortcuts if tradewindow is visible + if (!tradeWindow->isVisible()) { - if (tKey == i && !used) { - itemShortcut->useItem( - i - KeyboardConfig::KEY_SHORTCUT_1); - break; + // Checks if any item shortcut is pressed. + for (int i = KeyboardConfig::KEY_SHORTCUT_1; + i <= KeyboardConfig::KEY_SHORTCUT_12; + i++) + { + if (tKey == i && !used) + { + itemShortcut->useItem( + i - KeyboardConfig::KEY_SHORTCUT_1); + break; + } } } - } - switch (tKey) { - case KeyboardConfig::KEY_PICKUP: - { + switch (tKey) + { + case KeyboardConfig::KEY_PICKUP: FloorItem *item = floorItemManager->findByCoordinates( player_node->mX, player_node->mY); @@ -714,158 +717,155 @@ void Game::handleInput() 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); - emoteWindow->setVisible(false); - skillDialog->setVisible(false); - setupWindow->setVisible(false); - equipmentWindow->setVisible(false); - helpWindow->setVisible(false); - debugWindow->setVisible(false); - } - break; + 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); + emoteWindow->setVisible(false); + skillDialog->setVisible(false); + setupWindow->setVisible(false); + equipmentWindow->setVisible(false); + helpWindow->setVisible(false); + debugWindow->setVisible(false); + } + break; + case KeyboardConfig::KEY_WINDOW_STATUS: + requestedWindow = statusWindow; + break; + case KeyboardConfig::KEY_WINDOW_INVENTORY: + requestedWindow = inventoryWindow; + break; + case KeyboardConfig::KEY_WINDOW_EQUIPMENT: + requestedWindow = equipmentWindow; + break; + case KeyboardConfig::KEY_WINDOW_SKILL: + requestedWindow = skillDialog; + break; + case KeyboardConfig::KEY_WINDOW_MINIMAP: + minimap->toggle(); + requestedWindow = minimap; + break; + case KeyboardConfig::KEY_WINDOW_CHAT: + requestedWindow = chatWindow; + break; + case KeyboardConfig::KEY_WINDOW_SHORTCUT: + requestedWindow = itemShortcutWindow; + break; + case KeyboardConfig::KEY_WINDOW_SETUP: + requestedWindow = setupWindow; + break; + case KeyboardConfig::KEY_WINDOW_DEBUG: + requestedWindow = debugWindow; + break; + case KeyboardConfig::KEY_WINDOW_EMOTE: + requestedWindow = emoteWindow; + break; + case KeyboardConfig::KEY_WINDOW_EMOTE_SHORTCUT: + requestedWindow = emoteShortcutWindow; + break; + } + } - case KeyboardConfig::KEY_WINDOW_STATUS: - requestedWindow = statusWindow; - break; - case KeyboardConfig::KEY_WINDOW_INVENTORY: - requestedWindow = inventoryWindow; - break; - case KeyboardConfig::KEY_WINDOW_EQUIPMENT: - requestedWindow = equipmentWindow; - break; - case KeyboardConfig::KEY_WINDOW_SKILL: - requestedWindow = skillDialog; - break; - case KeyboardConfig::KEY_WINDOW_MINIMAP: - minimap->toggle(); - requestedWindow = minimap; - break; - case KeyboardConfig::KEY_WINDOW_CHAT: - requestedWindow = chatWindow; - break; - case KeyboardConfig::KEY_WINDOW_SHORTCUT: - requestedWindow = itemShortcutWindow; - break; - case KeyboardConfig::KEY_WINDOW_SETUP: - requestedWindow = setupWindow; - break; - case KeyboardConfig::KEY_WINDOW_DEBUG: - requestedWindow = debugWindow; - break; - case KeyboardConfig::KEY_WINDOW_EMOTE: - requestedWindow = emoteWindow; - break; - case KeyboardConfig::KEY_WINDOW_EMOTE_SHORTCUT: - requestedWindow = emoteShortcutWindow; - break; + if (requestedWindow) + { + requestedWindow->setVisible(!requestedWindow->isVisible()); + if (requestedWindow->isVisible()) + { + requestedWindow->requestMoveToTop(); + } + used = true; } + + } + // Quit event + else if (event.type == SDL_QUIT) + { + done = true; } - if (requestedWindow) + // Push input to GUI when not used + if (!used) { - requestedWindow->setVisible(!requestedWindow->isVisible()); - if (requestedWindow->isVisible()) + try { - requestedWindow->requestMoveToTop(); + guiInput->pushInput(event); + } + catch (gcn::Exception e) + { + const char* err = e.getMessage().c_str(); + logger->log(_("Warning: guichan input exception: %s"), err); } - used = true; } + } // End while - } + // If the user is configuring the keys then don't respond. + if (!keyboard.isEnabled()) + return; - // Quit event - else if (event.type == SDL_QUIT) + // Moving player around + if (player_node->mAction != Being::DEAD && + current_npc == 0 && !chatWindow->isInputFocused()) { - done = true; - } + // Get the state of the keyboard keys + keyboard.refreshActiveKeys(); - // Push input to GUI when not used - if (!used) - { - try + const Uint16 x = player_node->mX; + const Uint16 y = player_node->mY; + unsigned char direction = 0; + + // Translate pressed keys to movement and direction + if (keyboard.isKeyActive(keyboard.KEY_MOVE_UP) || + (joystick && joystick->isUp())) { - guiInput->pushInput(event); + direction |= Being::UP; } - catch (gcn::Exception e) + else if (keyboard.isKeyActive(keyboard.KEY_MOVE_DOWN) || + (joystick && joystick->isDown())) { - const char* err = e.getMessage().c_str(); - logger->log(_("Warning: guichan input exception: %s"), err); + direction |= Being::DOWN; } - } - } // End while - - // If the user is configuring the keys then don't respond. - if (!keyboard.isEnabled()) - return; - // Moving player around - if (player_node->mAction != Being::DEAD && - current_npc == 0 && - !chatWindow->isInputFocused()) - { - // Get the state of the keyboard keys - keyboard.refreshActiveKeys(); - - const Uint16 x = player_node->mX; - const Uint16 y = player_node->mY; - unsigned char direction = 0; - - // Translate pressed keys to movement and direction - if (keyboard.isKeyActive(keyboard.KEY_MOVE_UP) || - (joystick && joystick->isUp())) - { - direction |= Being::UP; - } - else if (keyboard.isKeyActive(keyboard.KEY_MOVE_DOWN) || - (joystick && joystick->isDown())) - { - direction |= Being::DOWN; - } - - if (keyboard.isKeyActive(keyboard.KEY_MOVE_LEFT) || - (joystick && joystick->isLeft())) - { - direction |= Being::LEFT; - } - else if (keyboard.isKeyActive(keyboard.KEY_MOVE_RIGHT) || - (joystick && joystick->isRight())) - { - direction |= Being::RIGHT; - } - - player_node->setWalkingDir(direction); + if (keyboard.isKeyActive(keyboard.KEY_MOVE_LEFT) || + (joystick && joystick->isLeft())) + { + direction |= Being::LEFT; + } + else if (keyboard.isKeyActive(keyboard.KEY_MOVE_RIGHT) || + (joystick && joystick->isRight())) + { + direction |= Being::RIGHT; + } - // Attacking monsters - if (keyboard.isKeyActive(keyboard.KEY_ATTACK) || - (joystick && joystick->buttonPressed(0))) - { - Being *target = beingManager->findNearestLivingBeing(x, y, 20, Being::MONSTER); + player_node->setWalkingDir(direction); - bool newTarget = !keyboard.isKeyActive(keyboard.KEY_TARGET); - // A set target has highest priority - if (newTarget || !player_node->getTarget()) + // Attacking monsters + if (keyboard.isKeyActive(keyboard.KEY_ATTACK) || + (joystick && joystick->buttonPressed(0))) { - Uint16 targetX = x, targetY = y; + Being *target = beingManager->findNearestLivingBeing(x, y, 20, + Being::MONSTER); - switch (player_node->getSpriteDirection()) + bool newTarget = !keyboard.isKeyActive(keyboard.KEY_TARGET); + // A set target has highest priority + if (newTarget || !player_node->getTarget()) { - case DIRECTION_UP : --targetY; break; - case DIRECTION_DOWN : ++targetY; break; - case DIRECTION_LEFT : --targetX; break; - case DIRECTION_RIGHT: ++targetX; break; - default: break; + Uint16 targetX = x, targetY = y; + + switch (player_node->getSpriteDirection()) + { + case DIRECTION_UP : --targetY; break; + case DIRECTION_DOWN : ++targetY; break; + case DIRECTION_LEFT : --targetX; break; + case DIRECTION_RIGHT: ++targetX; break; + default: break; } // Attack priorioty is: Monster, Player, auto target |