From c1d8eeb70a63a73739a38e652a2b5462e08588ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Doser?= Date: Wed, 28 Nov 2012 18:39:58 +0100 Subject: Make dragged itemstack following the mouse cursor much smoother by using the cursor coordinates directly, instead of updating them only when a mouse event is seen. --- src/game.cpp | 4 ++-- src/guiFormSpecMenu.cpp | 18 ++++++------------ src/guiFormSpecMenu.h | 3 ++- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 5ce214cb8..edc3ce741 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1513,7 +1513,7 @@ void the_game( <<"Launching inventory"<setFormSpec(meta->getString("formspec"), diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp index 4db020c11..618141d24 100644 --- a/src/guiFormSpecMenu.cpp +++ b/src/guiFormSpecMenu.cpp @@ -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; diff --git a/src/guiFormSpecMenu.h b/src/guiFormSpecMenu.h index 890b54d61..e6a2efe42 100644 --- a/src/guiFormSpecMenu.h +++ b/src/guiFormSpecMenu.h @@ -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 @@ protected: v2s32 spacing; v2s32 imgsize; + irr::IrrlichtDevice* m_device; InventoryManager *m_invmgr; IGameDef *m_gamedef; -- cgit v1.2.3