[PR #2440] [MERGED] Select a bundle's item with the mouse wheel #4318

Closed
opened 2026-11-03 04:16:18 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2440
Author: @kacpherek
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/27/2026
Merged by: @ludovic111

Base: main ← Head: fix/bundle-selected-item


📝 Commits (2)

  • a08f3eb Select a bundle's item with the mouse wheel
  • 3bb6e40 Clear a bundle's selection when the cursor leaves it on a server's client too

📊 Changes

12 files changed (+262 additions, -15 deletions)

View changed files

📝 crates/horizon-client/src/bundle.rs (+48 -8)
📝 crates/horizon-client/src/game.rs (+12 -0)
➕ crates/horizon-client/src/game/bundles.rs (+103 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+6 -0)
📝 crates/horizon-client/src/game/remote.rs (+4 -2)
📝 crates/horizon-client/src/game/stations.rs (+20 -2)
📝 crates/horizon-client/src/item_data.rs (+17 -0)
📝 crates/horizon-client/src/item_render.rs (+1 -0)
📝 crates/horizon-client/src/lan/containers.rs (+36 -0)
📝 crates/horizon-client/src/lan/menu.rs (+4 -1)
📝 crates/horizon-client/src/menu/bundle.rs (+5 -2)
📝 crates/horizon-protocol/src/packets/play.rs (+6 -0)

📄 Description

What and why

Scrolling the mouse wheel over a bundle in an inventory or container screen did nothing, and taking an item out of a bundle always took the first one. In vanilla the wheel moves a selection through the items the tooltip shows, the selected item is highlighted, and the click that takes an item out of the bundle takes the selected one.

Horizon kept no selected item (the BUNDLE_ITEM_SELECTED packet id was unused and bundle_selected was always -1). Now:

  • A bundle stack carries a runtime-only selected index (StackData::bundle_selected), left out of stack equality, saving and the network, like BundleContents.selectedItem.
  • The wheel over a bundle slot picks the next shown item (ScrollWheelHandler.getNextScrollWheelSelection) and, on a server, sends ServerboundSelectBundleItemPacket. Leaving the slot, closing the screen, a Shift click or a swap clears it.
  • The server (server thread guests included) toggles the selection on the guest's own stack for the inventory menu and chest-like menus. removeOne in both menu engines takes the selected stack and clears the selection; the other clicks that pass a bundle clear it as in overrideOtherStackedOnMe.
  • The tooltip highlights the selected cell, and the item model's bundle/selected_item now gets the index.
  • The tooltip cells now follow 26.3's order (shownItems.size() - slotNumber), so the first item is top left; the highlight needs the right cell.

Not done: the selected item's name tooltip above the grid. On a server the wheel only selects in the inventory and chest-like menus, the ones the server maps slots for.

Vanilla reference

  • BundleMouseActions.onMouseScrolled, onStopHovering, onSlotClicked, toggleSelectedBundleItem
  • ScrollWheelHandler.getNextScrollWheelSelection
  • BundleContents.Mutable.toggleSelectedItem, removeOne
  • BundleItem.overrideOtherStackedOnMe
  • ServerGamePacketListenerImpl.handleBundleItemSelectedPacket, AbstractContainerMenu.setSelectedBundleItemIndex
  • ClientBundleTooltip.extractSlot
  • BundleHasSelectedItem, BundleSelectedItemSpecialRenderer

Self-check

cargo check -p horizon-client passes.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/2440 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/bundle-selected-item` --- ### 📝 Commits (2) - [`a08f3eb`](https://github.com/horizon-rust/horizon/commit/a08f3eb2fa74ccff9d3565b8c0cab520a55276d8) Select a bundle's item with the mouse wheel - [`3bb6e40`](https://github.com/horizon-rust/horizon/commit/3bb6e4030479493f15e366b3ad0081aa178bb7b6) Clear a bundle's selection when the cursor leaves it on a server's client too ### 📊 Changes **12 files changed** (+262 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/bundle.rs` (+48 -8) 📝 `crates/horizon-client/src/game.rs` (+12 -0) ➕ `crates/horizon-client/src/game/bundles.rs` (+103 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+6 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+4 -2) 📝 `crates/horizon-client/src/game/stations.rs` (+20 -2) 📝 `crates/horizon-client/src/item_data.rs` (+17 -0) 📝 `crates/horizon-client/src/item_render.rs` (+1 -0) 📝 `crates/horizon-client/src/lan/containers.rs` (+36 -0) 📝 `crates/horizon-client/src/lan/menu.rs` (+4 -1) 📝 `crates/horizon-client/src/menu/bundle.rs` (+5 -2) 📝 `crates/horizon-protocol/src/packets/play.rs` (+6 -0) </details> ### 📄 Description ## What and why Scrolling the mouse wheel over a bundle in an inventory or container screen did nothing, and taking an item out of a bundle always took the first one. In vanilla the wheel moves a selection through the items the tooltip shows, the selected item is highlighted, and the click that takes an item out of the bundle takes the selected one. Horizon kept no selected item (the `BUNDLE_ITEM_SELECTED` packet id was unused and `bundle_selected` was always -1). Now: - A bundle stack carries a runtime-only selected index (`StackData::bundle_selected`), left out of stack equality, saving and the network, like `BundleContents.selectedItem`. - The wheel over a bundle slot picks the next shown item (`ScrollWheelHandler.getNextScrollWheelSelection`) and, on a server, sends `ServerboundSelectBundleItemPacket`. Leaving the slot, closing the screen, a Shift click or a swap clears it. - The server (server thread guests included) toggles the selection on the guest's own stack for the inventory menu and chest-like menus. `removeOne` in both menu engines takes the selected stack and clears the selection; the other clicks that pass a bundle clear it as in `overrideOtherStackedOnMe`. - The tooltip highlights the selected cell, and the item model's `bundle/selected_item` now gets the index. - The tooltip cells now follow 26.3's order (`shownItems.size() - slotNumber`), so the first item is top left; the highlight needs the right cell. Not done: the selected item's name tooltip above the grid. On a server the wheel only selects in the inventory and chest-like menus, the ones the server maps slots for. ## Vanilla reference - `BundleMouseActions.onMouseScrolled`, `onStopHovering`, `onSlotClicked`, `toggleSelectedBundleItem` - `ScrollWheelHandler.getNextScrollWheelSelection` - `BundleContents.Mutable.toggleSelectedItem`, `removeOne` - `BundleItem.overrideOtherStackedOnMe` - `ServerGamePacketListenerImpl.handleBundleItemSelectedPacket`, `AbstractContainerMenu.setSelectedBundleItemIndex` - `ClientBundleTooltip.extractSlot` - `BundleHasSelectedItem`, `BundleSelectedItemSpecialRenderer` ## Self-check `cargo check -p horizon-client` passes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:16:18 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4318
No description provided.