summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-02-28 10:49:55 -0700
committerJared Adams <jaxad0127@gmail.com>2009-02-28 10:49:55 -0700
commita65570a60c1d2f58d2f3fe01a4a54cd08a90d932 (patch)
tree91d5e6026b2e23c907b227af06ae3923677eca80 /src
parent49665def0ef539fc8c24cb66817fbf7e0408a1a4 (diff)
downloadmana-a65570a60c1d2f58d2f3fe01a4a54cd08a90d932.tar.gz
mana-a65570a60c1d2f58d2f3fe01a4a54cd08a90d932.tar.bz2
mana-a65570a60c1d2f58d2f3fe01a4a54cd08a90d932.tar.xz
mana-a65570a60c1d2f58d2f3fe01a4a54cd08a90d932.zip
Allow chatting while talking to NPCs
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp40
-rw-r--r--src/gui/chat.cpp7
-rw-r--r--src/gui/chat.h5
3 files changed, 22 insertions, 30 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 6bff0025..d6445ecc 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -513,58 +513,42 @@ void Game::handleInput()
}
}
- if (keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT) ||
- keyboard.isKeyActive(keyboard.KEY_OK))
- {
- // Input chat window
- if (!(chatWindow->isInputFocused() ||
- deathNotice ||
- weightNotice))
+ if (!(chatWindow->isInputFocused() || deathNotice || weightNotice))
+ if (keyboard.isKeyActive(keyboard.KEY_OK))
{
- // Quit by pressing Enter if the exit confirm is there
if (exitConfirm &&
keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT))
done = true;
// Close the Browser if opened
else if (helpWindow->isVisible() &&
- keyboard.isKeyActive(keyboard.KEY_OK))
+ keyboard.isKeyActive(keyboard.KEY_OK))
helpWindow->setVisible(false);
// Close the config window, cancelling changes if opened
else if (setupWindow->isVisible() &&
- keyboard.isKeyActive(keyboard.KEY_OK))
+ keyboard.isKeyActive(keyboard.KEY_OK))
setupWindow->action(gcn::ActionEvent(NULL, "cancel"));
// Submits the text and proceeds to the next dialog
else if (npcStringDialog->isVisible() &&
- keyboard.isKeyActive(keyboard.KEY_OK))
+ keyboard.isKeyActive(keyboard.KEY_OK))
npcStringDialog->action(gcn::ActionEvent(NULL, "ok"));
// Proceed to the next dialog option, or close the window
else if (npcTextDialog->isVisible() &&
- keyboard.isKeyActive(keyboard.KEY_OK))
+ keyboard.isKeyActive(keyboard.KEY_OK))
npcTextDialog->action(gcn::ActionEvent(NULL, "ok"));
// Choose the currently highlighted dialogue option
else if (npcListDialog->isVisible() &&
- keyboard.isKeyActive(keyboard.KEY_OK))
+ keyboard.isKeyActive(keyboard.KEY_OK))
npcListDialog->action(gcn::ActionEvent(NULL, "ok"));
// Submits the text and proceeds to the next dialog
else if (npcIntegerDialog->isVisible() &&
- keyboard.isKeyActive(keyboard.KEY_OK))
+ keyboard.isKeyActive(keyboard.KEY_OK))
npcIntegerDialog->action(gcn::ActionEvent(NULL, "ok"));
- else if (!(keyboard.getKeyValue(
- KeyboardConfig::KEY_TOGGLE_CHAT) ==
- keyboard.getKeyValue(
- KeyboardConfig::KEY_OK) &&
- (helpWindow->isVisible() ||
- setupWindow->isVisible() ||
- npcStringDialog->isVisible() ||
- npcTextDialog->isVisible() ||
- npcListDialog->isVisible() ||
- npcIntegerDialog->isVisible())))
- {
- chatWindow->requestChatFocus();
+ }
+ if (keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT))
+ {
+ if (chatWindow->requestChatFocus())
used = true;
- }
}
- }
const int tKey = keyboard.getKeyIndex(event.key.keysym.sym);
switch (tKey)
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index ac13355c..20d0213b 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -284,7 +284,7 @@ void ChatWindow::action(const gcn::ActionEvent &event)
}
}
-void ChatWindow::requestChatFocus()
+bool ChatWindow::requestChatFocus()
{
// Make sure chatWindow is visible
if (!isVisible())
@@ -299,9 +299,14 @@ void ChatWindow::requestChatFocus()
mTmpVisible = true;
}
+ // Don't do anything else if the input is already visible and has focus
+ if (mChatInput->isVisible() && mChatInput->isFocused())
+ return false;
+
// Give focus to the chat input
mChatInput->setVisible(true);
mChatInput->requestFocus();
+ return true;
}
bool ChatWindow::isInputFocused()
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 2fadb014..6002fed3 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -138,8 +138,11 @@ class ChatWindow : public Window, public gcn::ActionListener,
/**
* Request focus for typing chat message.
+ *
+ * \returns true if the input was shown
+ * false otherwise
*/
- void requestChatFocus();
+ bool requestChatFocus();
/**
* Checks whether ChatWindow is Focused or not.