]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Make dragged itemstack following the mouse cursor much smoother
authorJürgen Doser <jurgen.doser@gmail.com>
Wed, 28 Nov 2012 17:39:58 +0000 (18:39 +0100)
committerPerttu Ahola <celeron55@gmail.com>
Fri, 30 Nov 2012 20:07:30 +0000 (22:07 +0200)
by using the cursor coordinates directly, instead of updating them only when a mouse event is seen.

src/game.cpp
src/guiFormSpecMenu.cpp
src/guiFormSpecMenu.h

index 5ce214cb8d3150c253c63c1be99d028654667f10..edc3ce7417027b26a67a00ff120b5c2bc5273d5b 100644 (file)
@@ -1513,7 +1513,7 @@ void the_game(
                                        <<"Launching inventory"<<std::endl;
                        
                        GUIFormSpecMenu *menu =
-                               new GUIFormSpecMenu(guienv, guiroot, -1,
+                               new GUIFormSpecMenu(device, guiroot, -1,
                                        &g_menumgr,
                                        &client, gamedef);
 
@@ -2296,7 +2296,7 @@ void the_game(
                                        /* Create menu */
 
                                        GUIFormSpecMenu *menu =
-                                               new GUIFormSpecMenu(guienv, guiroot, -1,
+                                               new GUIFormSpecMenu(device, guiroot, -1,
                                                        &g_menumgr,
                                                        &client, gamedef);
                                        menu->setFormSpec(meta->getString("formspec"),
index 4db020c11fd88ebfc53148edf90e8b4b6d73ac34..618141d24dff16f652ba15c670efd900f19f4b0a 100644 (file)
@@ -125,13 +125,14 @@ void drawItemStack(video::IVideoDriver *driver,
        GUIFormSpecMenu
 */
 
-GUIFormSpecMenu::GUIFormSpecMenu(gui::IGUIEnvironment* env,
+GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,
                gui::IGUIElement* parent, s32 id,
                IMenuManager *menumgr,
                InventoryManager *invmgr,
                IGameDef *gamedef
 ):
-       GUIModalMenu(env, parent, id, menumgr),
+       GUIModalMenu(dev->getGUIEnvironment(), parent, id, menumgr),
+       m_device(dev),
        m_invmgr(invmgr),
        m_gamedef(gamedef),
        m_form_src(NULL),
@@ -698,6 +699,8 @@ void GUIFormSpecMenu::drawMenu()
                }
        }
 
+       m_pointer = m_device->getCursorControl()->getPosition();
+
        updateSelectedItem();
 
        gui::IGUISkin* skin = Environment->getSkin();
@@ -937,24 +940,15 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
                        return true;
                }
        }
-       if(event.EventType==EET_MOUSE_INPUT_EVENT
-                       && event.MouseInput.Event == EMIE_MOUSE_MOVED)
-       {
-               // Mouse moved
-               m_pointer = v2s32(event.MouseInput.X, event.MouseInput.Y);
-       }
        if(event.EventType==EET_MOUSE_INPUT_EVENT
                        && event.MouseInput.Event != EMIE_MOUSE_MOVED)
        {
                // Mouse event other than movement
 
-               v2s32 p(event.MouseInput.X, event.MouseInput.Y);
-               m_pointer = p;
-
                // Get selected item and hovered/clicked item (s)
 
                updateSelectedItem();
-               ItemSpec s = getItemAtPos(p);
+               ItemSpec s = getItemAtPos(m_pointer);
 
                Inventory *inv_selected = NULL;
                Inventory *inv_s = NULL;
index 890b54d61bae710cf3dc49a083850351dd4b142b..e6a2efe42413d900e274052a58b0cd1d60d69e42 100644 (file)
@@ -144,7 +144,7 @@ class GUIFormSpecMenu : public GUIModalMenu
        };
 
 public:
-       GUIFormSpecMenu(gui::IGUIEnvironment* env,
+       GUIFormSpecMenu(irr::IrrlichtDevice* dev,
                        gui::IGUIElement* parent, s32 id,
                        IMenuManager *menumgr,
                        InventoryManager *invmgr,
@@ -197,6 +197,7 @@ class GUIFormSpecMenu : public GUIModalMenu
        v2s32 spacing;
        v2s32 imgsize;
        
+       irr::IrrlichtDevice* m_device;
        InventoryManager *m_invmgr;
        IGameDef *m_gamedef;