diff options
author | Ira Rice <irarice@gmail.com> | 2009-02-05 11:44:31 -0700 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-02-05 11:44:31 -0700 |
commit | 34f27b882cf63ca4dfda6079253adb959ebaeadd (patch) | |
tree | 7bdc1e9c41865b9b7ba83296d7d4198655fceb7c /src/game.cpp | |
parent | 620e3d945884f0bfa304092f3924c8b7ea6110d0 (diff) | |
download | mana-34f27b882cf63ca4dfda6079253adb959ebaeadd.tar.gz mana-34f27b882cf63ca4dfda6079253adb959ebaeadd.tar.bz2 mana-34f27b882cf63ca4dfda6079253adb959ebaeadd.tar.xz mana-34f27b882cf63ca4dfda6079253adb959ebaeadd.zip |
Rather than to settle for a broken default (if it's left at space,
then you won't be able to type spaces in the NPC integer or string
dialogs. And no, assigning focus to the ok button doesn't resolve
anything, but makes things worse, as then the user has to click on the
input field to input text, then must click the ok button, as the chat
window already overrode it's confirmation action), this commit allows for
both the chat input and the NPC dialog confirming to share the same key,
but allows for people to change one or the other if they want to. This
will still allow for the player to use the keyboard fully for NPC
dialogs, but allow for people who don't like not being able to use chat
with an NPC dialog open to assign confirmation to another key and get
their way as well.
This is a rather ugly way of resolving both sides of the issue, but it's
the only way to appease both sides. The Aethyra players want things the
way they were, while Bjorn wanted things a different way.
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 91 |
1 files changed, 51 insertions, 40 deletions
diff --git a/src/game.cpp b/src/game.cpp index 3f6de6af..7c038074 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -515,6 +515,57 @@ void Game::handleInput() } } + if (keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT)) + { + // Input chat window + if (!(chatWindow->isInputFocused() || + deathNotice != NULL || + weightNotice != NULL)) + { + // 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")); + else if (!(keyboard.getKeyValue( + KeyboardConfig::KEY_TOGGLE_CHAT) == + keyboard.getKeyValue( + KeyboardConfig::KEY_OK) && + (npcStringDialog->isVisible() || + npcTextDialog->isVisible() || + npcListDialog->isVisible() || + npcIntegerDialog->isVisible()))) + { + chatWindow->requestChatFocus(); + used = true; + } + } + } + + if (keyboard.isKeyActive(keyboard.KEY_OK)) + { + if (!(exitConfirm || helpWindow->isVisible() || + setupWindow->isVisible())) + { + // Submits the text and proceeds to the next dialog + 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")); + } + } + const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); switch (tKey) { @@ -544,45 +595,6 @@ void Game::handleInput() } used = true; break; - - case KeyboardConfig::KEY_TOGGLE_CHAT: - // 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")); - else - { - chatWindow->requestChatFocus(); - used = true; - } - break; - case KeyboardConfig::KEY_OK: - // Submits the text and proceeds to the next dialog - 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")); - break; // Quitting confirmation dialog case KeyboardConfig::KEY_QUIT: if (!exitConfirm) @@ -598,7 +610,6 @@ void Game::handleInput() exitConfirm->action(gcn::ActionEvent(NULL, _("no"))); } break; - default: break; } |