diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-11-17 15:54:20 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-11-17 15:54:20 +0000 |
commit | c2edfcfe9c36fbe58e34b50e4b20a6af8de0b32e (patch) | |
tree | c9fdf062f1b6111868ad0784249e87f1ab21eacd /src/gui/gui.cpp | |
parent | a6b77bc69ba523625bafcb33c4c7f94fdda96af0 (diff) | |
download | mana-c2edfcfe9c36fbe58e34b50e4b20a6af8de0b32e.tar.gz mana-c2edfcfe9c36fbe58e34b50e4b20a6af8de0b32e.tar.bz2 mana-c2edfcfe9c36fbe58e34b50e4b20a6af8de0b32e.tar.xz mana-c2edfcfe9c36fbe58e34b50e4b20a6af8de0b32e.zip |
Added mouse following support.
Diffstat (limited to 'src/gui/gui.cpp')
-rw-r--r-- | src/gui/gui.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index b7f64274..df2bbaf0 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -89,7 +89,9 @@ Gui::Gui(Graphics *graphics): mHostImageLoader(NULL), mMouseCursor(NULL), mCustomCursor(false), - mPopupActive(false) + mPopupActive(false), + mPlayerFollowMouse(false), + mWalkTime(0) { // Set graphics setGraphics(graphics); @@ -205,6 +207,16 @@ Gui::logic() // Work around Guichan bug of only applying focus on mouse or keyboard // events. mFocusHandler->applyChanges(); + + int mouseX, mouseY; + Uint8 button = SDL_GetMouseState(&mouseX, &mouseY); + + if ( mPlayerFollowMouse && button & SDL_BUTTON(1) && + mWalkTime != player_node -> mWalkTime) + { + player_node->setDestination(mouseX / 32 + camera_x, mouseY / 32 + camera_y); + mWalkTime = player_node -> mWalkTime; + } } void @@ -231,6 +243,7 @@ void Gui::mousePress(int mx, int my, int button) { // Mouse pressed on window container (basically, the map) + mPlayerFollowMouse = false; // Are we in-game yet? if (state != GAME_STATE) @@ -316,6 +329,7 @@ Gui::mousePress(int mx, int my, int button) player_node->setDestination(tilex, tiley); player_node->stopAttack(); } + mPlayerFollowMouse = true; } } @@ -334,6 +348,20 @@ Gui::mousePress(int mx, int my, int button) } void +Gui::mouseMotion(int mx, int my) +{ + if (mPlayerFollowMouse && mWalkTime == player_node -> mWalkTime) + player_node->setDestination(mx / 32 + camera_x, my / 32 + camera_y); +} + +void +Gui::mouseRelease(int mx, int my, int button) +{ + mPlayerFollowMouse = false; +} + + +void Gui::setUseCustomCursor(bool customCursor) { if (customCursor != mCustomCursor) |