Skip to content
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

Inventory: Add remaining items into the source slot directly #14021

Merged
merged 1 commit into from
Dec 3, 2023

Conversation

srifqi
Copy link
Member

@srifqi srifqi commented Nov 20, 2023

Goal of the PR
This PR tries to fix remaining items hanging to the pointer when splitting a stack evenly (click/tap + drag) in some cases.

How does the PR work?
This PR adds the remaining items into the source slot directly.

Currently, it only adds the result of division. This works when the original/source slot is not selected because the remaining items will be left there, but does not work when the original slot is selected (not empty).

Does it resolve any reported issue?
Yes, reported in PR 13872 by SmallJoker.

Does this relate to a goal in the roadmap?
Yes, this PR fixes a UI/UX issue.

To do

This PR is Ready for Review.

How to test

  1. Play in a world/server.
  2. Open an inventory menu.
  3. Single-click or single-tap a stack with n items.
  4. Mouse-down or tap-and-hold the original/source slot.
  5. Drag until visiting k slots.
  6. Mouse-up or release-tap.
  7. There should be no items left at the pointer.
  8. Redo step 3–6, except start dragging not from the original slot, but still visiting the original slot. There should be no items left at the pointer.
  9. Redo step 8, but not visiting the original slot. The remaining items should be put back in the original slot.

The table below lists some n and k values that this PR fixes. The formula is

  1. n is odd and k is 2 or
  2. n is odd and k is ceil(n / 2).
n k
3 2
5 2 or 3
7 2 or 4
9 2 or 5
11 2 or 6
13 2 or 7
15 2 or 8
17 2 or 9
19 2 or 10

Copy link
Member

@grorp grorp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that both the current behavior (leaving leftover items selected) and the new behavior introduced by this PR (putting leftover items into the source slot) are valid.

However, I think that the current behavior is more useful. It gives you the freedom to decide what happens to the items remaining after an even distribution, and it makes it obvious that there is a remainder.

If the behavior is currently inconsistent, we of course have to fix that, regardless of which behavior we choose.

@srifqi
Copy link
Member Author

srifqi commented Nov 22, 2023

If the behavior is currently inconsistent, we of course have to fix that, regardless of which behavior we choose.

The remaining items are put back into the original/source slot, except in some cases (described in the first post).

Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the click -> drag -> click -> drop mechanism for entire stacks, the second click now also drops the wielded item stack, which is exactly what I'd expect.
Thank you for this change

@srifqi srifqi merged commit 047520d into minetest:master Dec 3, 2023
13 checks passed
@srifqi srifqi deleted the fix_split_stack_1 branch December 8, 2023 15:00
cx384 pushed a commit to cx384/minetest that referenced this pull request Dec 9, 2023
…t#14021)

Remaining items are added into the source slot directly when left-dragging over the source slot.
kawogi pushed a commit to kawogi/minetest that referenced this pull request Dec 19, 2023
…t#14021)

Remaining items are added into the source slot directly when left-dragging over the source slot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants