diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-03-13 14:27:44 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-03-13 14:27:44 +0000 |
commit | 809b072f55b2d419feec8a583f53962f220d4390 (patch) | |
tree | 5a4c4950a85b86c34839093a713a2c86044645c0 | |
parent | cd2c4f5861c89f0925a1a706e38535d6c11cc3a0 (diff) | |
download | mana-809b072f55b2d419feec8a583f53962f220d4390.tar.gz mana-809b072f55b2d419feec8a583f53962f220d4390.tar.bz2 mana-809b072f55b2d419feec8a583f53962f220d4390.tar.xz mana-809b072f55b2d419feec8a583f53962f220d4390.zip |
Fixed problem with mouse walking through GUI.
-rw-r--r-- | src/game.cpp | 8 | ||||
-rw-r--r-- | src/gui/gui.cpp | 17 | ||||
-rw-r--r-- | src/gui/gui.h | 7 | ||||
-rw-r--r-- | src/main.h | 2 |
4 files changed, 23 insertions, 11 deletions
diff --git a/src/game.cpp b/src/game.cpp index 00ad352d..9d55b3e4 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -351,14 +351,6 @@ void do_input() } } } - else if (event.button.button == 1) - { - // Experimental mouse walk support - walk(mx, my, 0); - player_node->setPath(tiledMap->findPath( - player_node->x, player_node->y, - mx, my)); - } } // Push input to GUI when not used diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index cf4c5b36..5c77f317 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -24,6 +24,9 @@ #include "gui.h" #include "window.h" #include "windowcontainer.h" +#include "../engine.h" +#include "../net/protocol.h" +#include "../main.h" // Guichan stuff Gui *gui; @@ -53,6 +56,7 @@ Gui::Gui(Graphics *graphics): guiTop = new WindowContainer(); guiTop->setDimension(gcn::Rectangle(0, 0, screen->w, screen->h)); guiTop->setOpaque(false); + guiTop->addMouseListener(this); Window::setWindowContainer(guiTop); // Create focus handler @@ -165,3 +169,16 @@ void Gui::focusNone() { focusHandler->focusNone(); } + +void Gui::mousePress(int mx, int my, int button) +{ + // Mouse pressed on window container (basically, the map) + int tilex = mx / 32 + camera_x; + int tiley = my / 32 + camera_y; + + // Experimental mouse walk support + walk(mx, my, 0); + player_node->setPath(tiledMap->findPath( + player_node->x, player_node->y, + tilex, tiley)); +} diff --git a/src/gui/gui.h b/src/gui/gui.h index 1c50a2f6..3bcffc5d 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -38,7 +38,7 @@ * * \ingroup GUI */ -class Gui +class Gui : public gcn::MouseListener { public: /** @@ -72,6 +72,11 @@ class Gui */ void draw(); + /** + * Handles mouse press on map. + */ + void mousePress(int mx, int my, int button); + private: gcn::Gui *gui; /**< The GUI system */ #ifdef USE_OPENGL @@ -37,8 +37,6 @@ #include <stdio.h> #include <memory> -#define CORE_VERSION "0.0.9" - #ifdef ERROR #undef ERROR #endif |