summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan-Fabian Humann <malastare@gmx.net>2005-03-14 12:50:00 +0000
committerJan-Fabian Humann <malastare@gmx.net>2005-03-14 12:50:00 +0000
commit020ae4ba6537fdce87209f07ea21cc002aaa52ba (patch)
tree6d17dec981f0c2b2ef60a35652cb931d63c32022 /src
parentbb5886f5351a148b5443adaee0a64ca6e81ee0b9 (diff)
downloadmana-020ae4ba6537fdce87209f07ea21cc002aaa52ba.tar.gz
mana-020ae4ba6537fdce87209f07ea21cc002aaa52ba.tar.bz2
mana-020ae4ba6537fdce87209f07ea21cc002aaa52ba.tar.xz
mana-020ae4ba6537fdce87209f07ea21cc002aaa52ba.zip
Fixed handling of get item button and made chatWindow (de)focus on ENTER - You can now only use the get item button when chat window isn't focused
Diffstat (limited to 'src')
-rw-r--r--src/engine.cpp4
-rw-r--r--src/game.cpp91
-rw-r--r--src/gui/chat.cpp10
-rw-r--r--src/gui/chat.h8
4 files changed, 70 insertions, 43 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index 0359e19f..1a60e6c3 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -184,8 +184,8 @@ Engine::Engine()
screen->w - 5 - chargeDialog->getWidth(),
screen->h - chargeDialog->getHeight() - 15);
- // Give focus to chat window
- chatWindow->requestFocus();
+ // Do not focus any text field
+ gui->focusNone();
// Load the sprite sets
ResourceManager *resman = ResourceManager::getInstance();
diff --git a/src/game.cpp b/src/game.cpp
index c9d611bf..77bb83c3 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -175,6 +175,15 @@ void do_input()
{
SDL_keysym keysym = event.key.keysym;
+ if (keysym.sym == SDLK_RETURN)
+ {
+ if (!chatWindow->isFocused())
+ {
+ chatWindow->requestFocus();
+ used = true;
+ }
+ }
+
if ((keysym.sym == SDLK_F5) && action_time)
{
if (player_node->action == STAND)
@@ -250,47 +259,50 @@ void do_input()
if (keysym.sym == SDLK_g)
{
// Get the item code
-
- int id = 0;
- id = find_floor_item_by_cor(player_node->x, player_node->y);
- if (id != 0)
+ if (!chatWindow->isFocused())
{
- WFIFOW(0) = net_w_value(0x009f);
- WFIFOL(2) = net_l_value(id);
- WFIFOSET(6);
- }
- else {
- switch (player_node->direction) {
- case NORTH:
- id = find_floor_item_by_cor(player_node->x, player_node->y-1);
- break;
- case SOUTH:
- id = find_floor_item_by_cor(player_node->x, player_node->y+1);
- break;
- case WEST:
- id = find_floor_item_by_cor(player_node->x-1, player_node->y);
- break;
- case EAST:
- id = find_floor_item_by_cor(player_node->x+1, player_node->y);
- break;
- case NW:
- id = find_floor_item_by_cor(player_node->x-1, player_node->y-1);
- break;
- case NE:
- id = find_floor_item_by_cor(player_node->x+1, player_node->y-1);
- break;
- case SW:
- id = find_floor_item_by_cor(player_node->x-1, player_node->y+1);
- break;
- case SE:
- id = find_floor_item_by_cor(player_node->x+1, player_node->y+1);
- break;
- default:
- break;
+ used = true;
+ int id = 0;
+ id = find_floor_item_by_cor(player_node->x, player_node->y);
+ if (id != 0)
+ {
+ WFIFOW(0) = net_w_value(0x009f);
+ WFIFOL(2) = net_l_value(id);
+ WFIFOSET(6);
+ }
+ else {
+ switch (player_node->direction) {
+ case NORTH:
+ id = find_floor_item_by_cor(player_node->x, player_node->y-1);
+ break;
+ case SOUTH:
+ id = find_floor_item_by_cor(player_node->x, player_node->y+1);
+ break;
+ case WEST:
+ id = find_floor_item_by_cor(player_node->x-1, player_node->y);
+ break;
+ case EAST:
+ id = find_floor_item_by_cor(player_node->x+1, player_node->y);
+ break;
+ case NW:
+ id = find_floor_item_by_cor(player_node->x-1, player_node->y-1);
+ break;
+ case NE:
+ id = find_floor_item_by_cor(player_node->x+1, player_node->y-1);
+ break;
+ case SW:
+ id = find_floor_item_by_cor(player_node->x-1, player_node->y+1);
+ break;
+ case SE:
+ id = find_floor_item_by_cor(player_node->x+1, player_node->y+1);
+ break;
+ default:
+ break;
+ }
+ WFIFOW(0) = net_w_value(0x009f);
+ WFIFOL(2) = net_l_value(id);
+ WFIFOSET(6);
}
- WFIFOW(0) = net_w_value(0x009f);
- WFIFOL(2) = net_l_value(id);
- WFIFOSET(6);
}
}
@@ -415,6 +427,7 @@ void do_input()
player_node->direction = WEST;
}
else player_node->direction = WEST;
+
}
else if (keys[SDLK_RIGHT] || keys[SDLK_KP6])
{
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 253fb3f4..45c87ee8 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -188,6 +188,8 @@ void ChatWindow::action(const std::string& eventId)
chat_send(char_info[0].name, message.c_str());
chatInput->setText("");
}
+ gui->focusNone();
+
}
}
@@ -197,6 +199,11 @@ void ChatWindow::requestFocus()
chatInput->requestFocus();
}
+bool ChatWindow::isFocused()
+{
+ return chatInput->hasFocus();
+}
+
char *ChatWindow::chat_send(std::string nick, std::string msg)
{
short packid = 0x008c;
@@ -339,4 +346,5 @@ std::string ChatWindow::cut_string(std::string& value, unsigned int maximumLengt
}
return std::string("");
-} \ No newline at end of file
+}
+
diff --git a/src/gui/chat.h b/src/gui/chat.h
index db2d9843..ad3d5e39 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -136,7 +136,12 @@ class ChatWindow : public Window, public gcn::ActionListener {
* Request focus.
*/
void requestFocus();
-
+
+ /**
+ * Checks wether ChatWindow is Focused or not
+ */
+ bool isFocused();
+
/*
* Determines wether to send a command or an ordinary message, then
* contructs packets & sends them
@@ -196,3 +201,4 @@ class ChatWindow : public Window, public gcn::ActionListener {
};
#endif
+