From 809b072f55b2d419feec8a583f53962f220d4390 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 13 Mar 2005 14:27:44 +0000 Subject: Fixed problem with mouse walking through GUI. --- src/gui/gui.cpp | 17 +++++++++++++++++ src/gui/gui.h | 7 ++++++- 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src/gui') 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 -- cgit v1.2.3-70-g09d2