diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-01 18:18:24 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-01 18:18:24 +0000 |
commit | 84a403f0a0590ebc11f66955e864c12886da5815 (patch) | |
tree | 628d49ac79ea159ba0109eb8817cfd9144dbab13 /src | |
parent | e02192d7d1a34088d66072a60cf3ed57d638a695 (diff) | |
download | mana-84a403f0a0590ebc11f66955e864c12886da5815.tar.gz mana-84a403f0a0590ebc11f66955e864c12886da5815.tar.bz2 mana-84a403f0a0590ebc11f66955e864c12886da5815.tar.xz mana-84a403f0a0590ebc11f66955e864c12886da5815.zip |
Chat input now hides when not focussed, and doesn't allow player be controlled
by keyboard when it is.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/game.cpp | 10 | ||||
-rw-r--r-- | src/gui/chat.cpp | 8 | ||||
-rw-r--r-- | src/gui/chat.h | 4 | ||||
-rw-r--r-- | src/gui/chatinput.cpp | 35 | ||||
-rw-r--r-- | src/gui/chatinput.h | 47 |
6 files changed, 97 insertions, 9 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 69a24f1c..47bb0cb5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,6 +15,8 @@ tmw_SOURCES = graphic/spriteset.cpp \ gui/char_select.h \ gui/chat.cpp \ gui/chat.h \ + gui/chatinput.cpp \ + gui/chatinput.h \ gui/checkbox.cpp \ gui/checkbox.h \ gui/confirm_dialog.cpp \ diff --git a/src/game.cpp b/src/game.cpp index 8e0168b2..51a0a0c7 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -206,7 +206,7 @@ void do_input() { if (!chatWindow->isFocused()) { - chatWindow->requestFocus(); + chatWindow->requestChatFocus(); used = true; } } @@ -287,7 +287,7 @@ void do_input() state = EXIT; } - if (keysym.sym == SDLK_g) + if (keysym.sym == SDLK_g && !chatWindow->isFocused()) { // Get the item code if (!chatWindow->isFocused()) @@ -405,7 +405,8 @@ void do_input() int yDirection = 0; int Direction = DIR_NONE; - if (player_node->action != DEAD && current_npc == 0) + if (player_node->action != DEAD && current_npc == 0 && + !chatWindow->isFocused()) { int x = player_node->x; int y = player_node->y; @@ -1368,14 +1369,13 @@ void do_parse() inventoryWindow->items->setEquipped( equipmentWindow->equipments[position - 1].inventoryIndex, false); - inventoryWindow->items->setEquipped(RFIFOW(2), true); equipmentWindow->addEquipment(position - 1, inventoryWindow->items->getId(RFIFOW(2))); equipmentWindow->equipments[position - 1].inventoryIndex = RFIFOW(2); - + // Trick to use the proper graphic until I find // the right packet switch (inventoryWindow->items->getId(RFIFOW(2))) { diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 380d9d13..40a44b13 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -24,6 +24,7 @@ #include "chat.h" #include "textfield.h" #include "textbox.h" +#include "chatinput.h" #include "../graphics.h" #include "../main.h" #include <iostream> @@ -37,7 +38,7 @@ ChatWindow::ChatWindow(const char *logfile, int item_num): setContentSize(600, 100); textOutput = new TextBox(); - chatInput = new TextField(); + chatInput = new ChatInput(); textOutput->setEditable(false); scrollArea = new ScrollArea(textOutput); scrollArea->setDimension(gcn::Rectangle( @@ -228,13 +229,16 @@ void ChatWindow::action(const std::string& eventId) chatInput->setText(""); } + // Remove focus and hide input gui->focusNone(); + chatInput->setVisible(false); } } -void ChatWindow::requestFocus() +void ChatWindow::requestChatFocus() { // Give focus to the chat input + chatInput->setVisible(true); chatInput->requestFocus(); } diff --git a/src/gui/chat.h b/src/gui/chat.h index 4b0946f9..1c3fc007 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -138,9 +138,9 @@ class ChatWindow : public Window, public gcn::ActionListener, void action(const std::string &actionId); /** - * Request focus. + * Request focus for typing chat message. */ - void requestFocus(); + void requestChatFocus(); /** * Checks whether ChatWindow is Focused or not. diff --git a/src/gui/chatinput.cpp b/src/gui/chatinput.cpp new file mode 100644 index 00000000..55417ac8 --- /dev/null +++ b/src/gui/chatinput.cpp @@ -0,0 +1,35 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#include "chatinput.h" + +ChatInput::ChatInput() +{ + setVisible(false); +} + +void ChatInput::lostFocus() +{ + // TODO: Never mind this, it'll probably work in next Guichan version. + //setVisible(false); +} diff --git a/src/gui/chatinput.h b/src/gui/chatinput.h new file mode 100644 index 00000000..9f543e24 --- /dev/null +++ b/src/gui/chatinput.h @@ -0,0 +1,47 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#ifndef _TMW_CHATINPUT_H +#define _TMW_CHATINPUT_H + +#include "textfield.h" + +/** + * The chat input hides when it loses focus. It is also invisible by default. + */ +class ChatInput : public TextField +{ + public: + /** + * Constructor. + */ + ChatInput(); + + /** + * Called if the chat input loses focus. It will set itself to + * invisible as result. + */ + void lostFocus(); +}; + +#endif |