Continuous mouse move patch

Content and general development discussion, including quest scripts and server code. TMW Classic is a project comprising the Legacy tmwAthena server & the designated improved engine server based on evolHercules.


Forum rules

This forum houses many years of development, tracing back to some of the earliest posts that exist on the board.

Its current use is for the continued development of the server and game it has always served: TMW Classic.

Post Reply
User avatar
Saphy
Warrior
Warrior
Posts: 371
Joined: 09 Nov 2006, 18:32

Continuous mouse move patch

Post by Saphy »

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, 16:08
Location: Germany

Post by Crush »

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
Warrior
Warrior
Posts: 371
Joined: 09 Nov 2006, 18:32

Post by Saphy »

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, 16:08
Location: Germany

Post by Crush »

#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, 07:16
Location: Oregon

Post by Madcap »

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
Warrior
Warrior
Posts: 371
Joined: 09 Nov 2006, 18:32

Post by Saphy »

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
Warrior
Warrior
Posts: 371
Joined: 09 Nov 2006, 18:32

Post by Saphy »

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