mirror of https://github.com/minetest/minetest.git
m_rmouse_auto_place for RMB dragging removed
MMB dragging implemented in GUIFormSpecMenu::OnEvent
This commit is contained in:
parent
e201620ee1
commit
684ba6e25a
|
@ -124,7 +124,6 @@ GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,
|
|||
m_tooltip_element(NULL),
|
||||
m_hovered_time(0),
|
||||
m_old_tooltip_id(-1),
|
||||
m_rmouse_auto_place(false),
|
||||
m_allowclose(true),
|
||||
m_lock(false),
|
||||
m_form_src(fsrc),
|
||||
|
@ -3063,14 +3062,16 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||
}
|
||||
|
||||
/* Mouse event other than movement, or crossing the border of inventory
|
||||
field while holding right mouse button
|
||||
field while holding a mouse button
|
||||
*/
|
||||
if (event.EventType == EET_MOUSE_INPUT_EVENT &&
|
||||
(event.MouseInput.Event != EMIE_MOUSE_MOVED ||
|
||||
(event.MouseInput.Event == EMIE_MOUSE_MOVED &&
|
||||
event.MouseInput.isRightPressed() &&
|
||||
event.MouseInput.ButtonStates != 0 &&
|
||||
getItemAtPos(m_pointer).i != getItemAtPos(m_old_pointer).i))) {
|
||||
|
||||
|
||||
|
||||
|
||||
// Get selected item and hovered/clicked item (s)
|
||||
|
||||
m_old_tooltip_id = -1;
|
||||
|
@ -3141,8 +3142,25 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||
else if(event.MouseInput.Event == EMIE_MMOUSE_LEFT_UP)
|
||||
{ button = 2; updown = 1; }
|
||||
else if(event.MouseInput.Event == EMIE_MOUSE_MOVED)
|
||||
{ updown = -1;}
|
||||
|
||||
{updown = -1;
|
||||
switch (event.MouseInput.ButtonStates) {
|
||||
case EMBSM_LEFT:
|
||||
button = 0;
|
||||
break;
|
||||
case EMBSM_RIGHT:
|
||||
button = 1;
|
||||
break;
|
||||
case EMBSM_MIDDLE:
|
||||
button = 2;
|
||||
break;
|
||||
default: // Other/multiple MB
|
||||
updown = 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// std::cout << "updown (" << updown <<") button (" << button << ")" << std::endl;
|
||||
|
||||
// Set this number to a positive value to generate a move action
|
||||
// from m_selected_item to s.
|
||||
u32 move_amount = 0;
|
||||
|
@ -3179,7 +3197,6 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||
m_selected_amount = s_count;
|
||||
|
||||
m_selected_dragging = true;
|
||||
m_rmouse_auto_place = false;
|
||||
}
|
||||
}
|
||||
else { // m_selected_item != NULL
|
||||
|
@ -3232,20 +3249,15 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||
}
|
||||
|
||||
m_selected_dragging = false;
|
||||
// Keep count of how many times right mouse button has been
|
||||
// clicked. One click is drag without dropping. Click + release
|
||||
// + click changes to drop one item when moved mode
|
||||
if(button == 1 && m_selected_item != NULL)
|
||||
m_rmouse_auto_place = !m_rmouse_auto_place;
|
||||
}
|
||||
else if(updown == -1) {
|
||||
// Mouse has been moved and rmb is down and mouse pointer just
|
||||
// entered a new inventory field (checked in the entry-if, this
|
||||
// is the only action here that is generated by mouse movement)
|
||||
if(m_selected_item != NULL && s.isValid()){
|
||||
// Move 1 item
|
||||
// TODO: middle mouse to move 10 items might be handy
|
||||
if (m_rmouse_auto_place) {
|
||||
if(button == 1 || button == 2) {
|
||||
// Move 1 item
|
||||
|
||||
// Only move an item if the destination slot is empty
|
||||
// or contains the same item type as what is going to be
|
||||
// moved
|
||||
|
@ -3254,8 +3266,12 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||
assert(list_from && list_to);
|
||||
ItemStack stack_from = list_from->getItem(m_selected_item->i);
|
||||
ItemStack stack_to = list_to->getItem(s.i);
|
||||
if (stack_to.empty() || stack_to.name == stack_from.name)
|
||||
move_amount = 1;
|
||||
if (stack_to.empty() || stack_to.name == stack_from.name) {
|
||||
if(button == 1)
|
||||
move_amount = 1;
|
||||
else
|
||||
move_amount = MYMIN(m_selected_amount, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue