Code: Select all
diff -Naur src/gui/gui.cpp src/gui/gui.cpp.orig
--- src/gui/gui.cpp.orig 2006-10-29 17:17:41.000000000 -0500
+++ src/gui/gui.cpp 2006-11-09 13:39:18.000000000 -0500
@@ -170,6 +170,7 @@
config.addListener("customcursor", mConfigListener);
mPopup = new PopupMenu();
+ buttonState = 0;
}
Gui::~Gui()
@@ -331,6 +332,40 @@
player_node->setTarget(target);
}
}
+
+ buttonState = button;
+}
+
+void Gui::mouseMotion(int mx, int my) {
+ // Mouse moved on window container (basically, the map)
+
+ // Only detect mouse motion when LEFT is pressed last
+ if (buttonState != gcn::MouseInput::LEFT)
+ return;
+
+ // Check if we are alive and kickin'
+ if (!player_node || player_node->mAction == Being::DEAD)
+ return;
+
+ // Check if we are busy
+ if (current_npc)
+ return;
+
+ int tilex = mx / 32 + camera_x;
+ int tiley = my / 32 + camera_y;
+
+ //Only continue to walk when player has been walking or standing
+ if ((player_node->mAction == Being::WALK || player_node->mAction == Being::STAND) &&
+ engine->getCurrentMap()->getWalk(tilex, tiley))
+ {
+ player_node->setDestination(tilex, tiley);
+ player_node->stopAttack();
+ }
+}
+
+void Gui::mouseRelease(int x, int y, int button)
+{
+ buttonState = 0;
}
void
diff -Naur src/gui/gui.h src/gui/gui.h
--- src/gui/gui.orig 2006-10-29 17:17:41.000000000 -0500
+++ src/gui/gui.h 2006-11-09 13:07:57.000000000 -0500
@@ -81,6 +81,8 @@
*/
void
mousePress(int mx, int my, int button);
+ void mouseMotion(int mx, int my);
+ void mouseRelease(int x, int y, int button);
/**
* Return game font
@@ -122,6 +124,7 @@
PopupMenu *mPopup; /**< Popup window */
bool mPopupActive;
+ int buttonState;
};
extern Gui *gui; /**< The GUI system */