Skip to content

Add drag-and-drop inventory reordering#217

Open
evanofficial wants to merge 1 commit into
DogFingerStudios:masterfrom
evanofficial:feature/inventory-reorder
Open

Add drag-and-drop inventory reordering#217
evanofficial wants to merge 1 commit into
DogFingerStudios:masterfrom
evanofficial:feature/inventory-reorder

Conversation

@evanofficial
Copy link
Copy Markdown
Contributor

Summary

Adds the ability to rearrange inventory items by dragging and dropping them between slots. This implements the reordering requirement from #107.

Changes

CharacterEntity.cs:

  • Added SwapInventorySlots(int slotA, int slotB) — swaps two inventory slots and keeps _equippedItemIndex in sync

InventoryDragHandler.cs (new):

  • Implements IBeginDragHandler, IDragHandler, IEndDragHandler
  • Provides visual feedback during drag (reduced opacity)
  • Detects drop target and triggers slot swap via InventoryUI

InventoryUI.cs:

  • Attaches InventoryDragHandler to each slot during ShowInventory()
  • Added OnSlotSwapRequested() which calls SwapInventorySlots() and refreshes the UI

How it works

  1. Player opens inventory (I key)
  2. Drags an item slot onto another slot
  3. The two slots swap positions in the underlying inventory
  4. Keyboard shortcuts (1-0) now reflect the new order
  5. Equipped item tracking stays correct after reorder

Addresses #107

CLA

  • I agree to the Contributing Agreement in CONTRIBUTING.md

Add the ability to rearrange items in the inventory by dragging
and dropping them between slots. This completes the reordering
requirement from DogFingerStudios#107.

- Add SwapInventorySlots() to CharacterEntity for swapping two
  inventory slots while keeping the equipped item index in sync
- Add InventoryDragHandler component attached at runtime to each
  inventory slot for drag-and-drop interaction
- Add OnSlotSwapRequested() to InventoryUI which performs the
  swap and refreshes the display

Addresses DogFingerStudios#107
@zethon
Copy link
Copy Markdown
Contributor

zethon commented Mar 28, 2026

I merged your other PR. Since this one is a little more involved, I'll give it a closer look tomorrow, perhaps on stream.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants