New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Formspec: Pass the second-touch event as is #13872
Formspec: Pass the second-touch event as is #13872
Conversation
b4617d1
to
a582d7b
Compare
I rebased this PR and added APKs for testing. |
I found the following issue that might be worth having a look into:
Aside from that, the PR works as advised. |
That also happens in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works.
This build solves every issue I have except that (cross)bows still can't be used in mineclone2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rebased a582d7b on top of the latest master branch (4d2227c), together with the latest Irrlicht master branch (minetest/irrlicht@85081d6).
In my tests, this PR didn't work as expected. Here's a video:
recording.android.inventory.fix.review.mp4
-
When I tried to use the "while drag&dropping, tap the screen with another finger to put a single item into the hovered slot" feature, the entire stack was put into the hovered slot, not just a single item.
The feature only worked correctly if the first slot I tried to put an item into was the source slot, or no slot at all (e.g. a border between two slots).
-
Since Inventory mouse shortcut improvements #13146, you can left-drag to distribute an itemstack evenly across multiple slots. If you tap the screen with another finger during this operation, the item counts get confused. The second tap should probably be ignored in this case, as it was before this PR.
Thank you for the test. I must have missed that case. It seems like the problem is much deeper than I though since the inventory PR only considers one pointer. I'm converting this PR as a draft until I found a better solution or another PR fixes the issue better (in that case, I'll close this PR). |
Could you elaborate on this? Since when can't crossbows be used in MCL2? This seems like a different issue. |
This is a known issue, you can't hold the right mouse button on Android, so bows don't work. I'm currently working on different approaches to fix this. |
a582d7b
to
1ff897f
Compare
This PR is ready for review. Android: APK builds EDIT: |
Thank you for the update. I tried splitting stacks, combining them and it works well enough. There is still a difference to the desktop version but I do not know whether that's intentional or not:
|
Thank you for testing. Can you give more concrete example, e.g. the amount of items and slots? EDIT: EDIT (2): That issue also happens in desktop. The table below shows my tests. Numbers of items in a stack that do not fail are omitted. It seems like it happens when
EDIT (3): One of the solution is to add the remainder into the original slot directly. (branch) Example diffdiff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp
index a51a02669..def1c28e5 100644
--- a/src/gui/guiFormSpecMenu.cpp
+++ b/src/gui/guiFormSpecMenu.cpp
@@ -4643,6 +4643,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
// The split amount will always at least one, because the number
// of slots will never be greater than the selected amount
u16 split_amount = m_left_drag_amount / m_left_drag_stacks.size();
+ u16 split_remaining = m_left_drag_amount % m_left_drag_stacks.size();
ItemStack stack_from = m_left_drag_stack;
m_selected_amount = m_left_drag_amount;
@@ -4653,7 +4654,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
if (ds.first == *m_selected_item) {
// Adding to the source stack, just change the selected amount
- m_selected_amount -= split_amount;
+ m_selected_amount -= split_amount + split_remaining;
} else {
// Reset the stack to its original state |
@srifqi I see. Thank you for looking that up. It really does affect desktop as well, thus not of a concern for this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
In addition to what I wrote below: You can trigger broken/inconsistent behavior by doing a second tap while you are "left-dragging to distribute evenly". Here's a video:
Record_2023-11-21-16-48-03_2f92d212d72044a7b2c4130128bd465a.mp4
The second tap should probably be ignored if you are currently "left-dragging to distribute evenly". (Ignore the error messages, I added them for debugging.)
EDIT: I just noticed that I already reported this issue for a previous version of this PR :-D
1ff897f
to
75934d9
Compare
Thank you for testing. The issues should be fixed now.
I must have missed that. Thank you for noticing it (again). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works correctly in the cases I've tested 👍
One remaining question:
The second-touch event is passed to the GUIFormSpecMenu::OnEvent() function as a touch event. There are two types of event for inventory formspec: (1) mouse event and (2) touch event. The touch event is just a modifier of the mouse event.
Co-authored-by: Gregor Parzefall <82708541+grorp@users.noreply.github.com>
75934d9
to
030aa69
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works. Code also looks good. 👍
Thank you.
There's another annoyance which is offtopic for this PR: Since #13146, you can pick up itemstacks of the same type by moving over them while dragging&dropping. I often accidentally pick up the items that I have just put down with a "second touch".
@rubenwardy, any objection? EDIT: https://irc.minetest.net/minetest-dev/2023-11-26#i_6135461 |
The second-touch event is passed to the GUIFormSpecMenu::OnEvent() function as a touch event. There are two types of event for inventory formspec: (1) mouse event and (2) touch event. The touch event is just a modifier of the mouse event. Co-authored-by: Gregor Parzefall <82708541+grorp@users.noreply.github.com>
This reverts commit 53886dc.
This reverts commit 53886dc.
This reverts commit 53886dc.
The second-touch event is passed to the GUIFormSpecMenu::OnEvent() function as a touch event. There are two types of event for inventory formspec: (1) mouse event and (2) touch event. The touch event is just a modifier of the mouse event. Co-authored-by: Gregor Parzefall <82708541+grorp@users.noreply.github.com>
Goal of the PR
This PR tries to restore old touch behaviour on inventory management.
Minetest-Android-split-stack.mp4
Old videos
Minetest-Android-split-stack.mp4
Minetest-Android-split-stack.mp4
How does the PR work?
The current code only convert the second-touch to be a right click event. This would not work for the new inventory management.
This PR passes the second-touch event as a touch event and then uses it as a modifier of the first-touch event.
The current code prohibits multiple button click/press action in a single mouse, but the behaviour is different for touch-screen devices because mouse clicks are simulated from touches. This PR removes that limit only for touch-screen devices.Does it resolve any reported issue?
Yes, this PR tries to fix #13822.
Does this relate to a goal in the roadmap?
Yes, this PR fixes a regression.
To do
This PR is Ready for Review.
How to test
Do as described in the videos above. (... and go wild[!] while testing.)
Simple test
Android: APK builds (old, before grorp's second review)
Older builds