summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2005-07-23 23:02:47 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2005-07-23 23:02:47 +0000
commit004963a615516d3534a68da90d44443dc765d9d4 (patch)
tree4a37376ad5858a8fe2cc5185dbaf95c5db72b9c8
parentff5d92c8973b89e420cb639bb19f32916187ccaf (diff)
downloadmana-004963a615516d3534a68da90d44443dc765d9d4.tar.gz
mana-004963a615516d3534a68da90d44443dc765d9d4.tar.bz2
mana-004963a615516d3534a68da90d44443dc765d9d4.tar.xz
mana-004963a615516d3534a68da90d44443dc765d9d4.zip
Allowed continous movement when holding down left mouse button
-rw-r--r--ChangeLog3
-rw-r--r--src/gui/gui.cpp40
-rw-r--r--src/gui/gui.h14
3 files changed, 46 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index ce3efd85..755407ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
* src/game.cpp: Made the key-event handler use switches instead of
if-else.
+ * src/gui/gui.cpp:
+ * src/gui/gui.h:
+ Allow continous movement when holding down the left mouse button.
2005-07-23 Björn Steinbrink <B.Steinbrink@gmx.de>
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index cf98dde9..3babd746 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -50,7 +50,9 @@ gcn::ImageFont *speechFont;
Gui::Gui(Graphics *graphics):
mHostImageLoader(NULL),
mMouseCursor(NULL),
- mCustomCursor(false)
+ mCustomCursor(false),
+ mMouseWalk(false),
+ mMouseX(0), mMouseY(0)
{
// Set graphics
guiGraphics = graphics;
@@ -201,6 +203,19 @@ void Gui::logic()
// Work around Guichan bug of only applying focus on mouse or keyboard
// events.
mFocusHandler->applyChanges();
+
+ if (mMouseWalk) {
+ Map *tiledMap = engine->getCurrentMap();
+ int tilex = mMouseX / 32 + camera_x;
+ int tiley = mMouseY / 32 + camera_y;
+
+ if (state == GAME && tiledMap->getWalk(tilex, tiley)) {
+ walk(tilex, tiley, 0);
+ player_node->setDestination(tilex, tiley);
+
+ autoTarget = NULL;
+ }
+ }
}
void Gui::draw()
@@ -225,21 +240,24 @@ void Gui::mousePress(int mx, int my, int button)
{
// Mouse pressed on window container (basically, the map)
- // When conditions for walking are met, set new player destination
+ // When conditions for walking are met, start moving by mouse
if (player_node && player_node->action != DEAD && current_npc == 0 &&
button == gcn::MouseInput::LEFT)
{
- Map *tiledMap = engine->getCurrentMap();
- int tilex = mx / 32 + camera_x;
- int tiley = my / 32 + camera_y;
+ mMouseWalk = true;
+ }
+}
- if (state == GAME && tiledMap->getWalk(tilex, tiley)) {
- walk(tilex, tiley, 0);
- player_node->setDestination(tilex, tiley);
+void Gui::mouseRelease(int x, int y, int button)
+{
+ gcn::MouseListener::mouseRelease(x, y, button);
+ mMouseWalk = false;
+}
- autoTarget = NULL;
- }
- }
+void Gui::mouseMotion(int mx, int my)
+{
+ mMouseX = mx;
+ mMouseY = my;
}
gcn::ImageFont *Gui::getFont()
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 02ea7caa..6264a116 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -76,6 +76,18 @@ class Gui : public gcn::Gui, public gcn::MouseListener, ConfigListener
mousePress(int mx, int my, int button);
/**
+ * Handles mouse releases on map.
+ */
+ void
+ mouseRelease(int mx, int my, int button);
+
+ /**
+ * Handles mouse motion on map.
+ */
+ void
+ mouseMotion(int mx, int my);
+
+ /**
* Return game font
*/
gcn::ImageFont*
@@ -99,6 +111,8 @@ class Gui : public gcn::Gui, public gcn::MouseListener, ConfigListener
gcn::ImageFont *mGuiFont; /**< The global GUI font */
Image *mMouseCursor; /**< Mouse cursor image */
bool mCustomCursor; /**< Show custom cursor */
+ bool mMouseWalk; /**< Move to the mouse cursor */
+ int mMouseX, mMouseY; /**< Mouse coordinates */
};
extern Gui *gui; /**< The GUI system */