Continuous mouse move patch

Content and general development discussion, including maps, quests, and server code from the development team.
Post Reply
User avatar
Saphy
Novice
Novice
Posts: 371
Joined: 09 Nov 2006, 19:32

Continuous mouse move patch

Post by Saphy » 09 Nov 2006, 19:53

As suggested in the wiki, it would be nice if the character can walk continuously instead of click on area again and again. Thus, I have prepared a patch that implement this UI feature.

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 */
Is there a bugzilla where I can submit this patch instead?
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: 25 Aug 2005, 17:08
Location: Germany

Post by Crush » 09 Nov 2006, 21:29

you can find the patch tracker here:
http://sourceforge.net/tracker/?group_i ... tid=645620

although patchs tend to be ignored when you don't make some promotion for them on #tmwdev.
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
User avatar
Saphy
Novice
Novice
Posts: 371
Joined: 09 Nov 2006, 19:32

Post by Saphy » 09 Nov 2006, 22:38

Well, the patch isn't perfect due to limitation of the design. The mouse must move in order for SDL to detect mouseMotion event, so the character will not continue to move if the mouse stopped moving. Where is #tmvdev?
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: 25 Aug 2005, 17:08
Location: Germany

Post by Crush » 09 Nov 2006, 23:09

#tmwdev is one of our three IRC chat channels. It is the one that is about the code development. For an explanation how to access our IRC channels please read:
http://forums.themanaworld.org/viewtopic.php?t=747
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
Madcap
Novice
Novice
Posts: 156
Joined: 02 Nov 2006, 08:16
Location: Oregon

Post by Madcap » 09 Nov 2006, 23:13

Hey Saphy!

#tmvdev is on IRC.freenode.net. If I wasn't so new at using it, I'd post the exact link. But I think it's in a thread somewhere....maybe job postings?

.....there you go....Crush beat me to it.
User avatar
Saphy
Novice
Novice
Posts: 371
Joined: 09 Nov 2006, 19:32

Post by Saphy » 11 Nov 2006, 08:30

Thanks. I have updated my patch again to reduce CPU usage to absolute minimum and it is now possible to move without mouse moving. It is possible afterall. :D

Here's the new patch:

http://sourceforge.net/tracker/download ... id=1594603
User avatar
Saphy
Novice
Novice
Posts: 371
Joined: 09 Nov 2006, 19:32

Post by Saphy » 12 Nov 2006, 05:24

Patch is now updated so that people with crazy video game with fast CPU will not hog the server.

http://sourceforge.net/tracker/download ... id=1594603
Post Reply