@ -1848,11 +1848,11 @@ void PerformPrimaryAction()
} else if ( IsStashOpen & & GetLeftPanel ( ) . contains ( MousePosition ) ) {
} else if ( IsStashOpen & & GetLeftPanel ( ) . contains ( MousePosition ) ) {
Point stashSlot = ( ActiveStashSlot ! = InvalidStashPoint ) ? ActiveStashSlot : FindClosestStashSlot ( MousePosition ) ;
Point stashSlot = ( ActiveStashSlot ! = InvalidStashPoint ) ? ActiveStashSlot : FindClosestStashSlot ( MousePosition ) ;
const Size cursorSizeInCells = MyPlayer - > HoldItem . isEmpty ( ) ? Size { 1 , 1 } : GetInventorySize ( MyPlayer - > HoldItem ) ;
Size cursorSizeInCells = MyPlayer - > HoldItem . isEmpty ( ) ? Size { 1 , 1 } : GetInventorySize ( MyPlayer - > HoldItem ) ;
// Find any item occupying a slot that is currently under the cursor
// Find any item occupying a slot that is currently under the cursor
StashStruct : : StashCell itemUnderCursor = [ ] ( Point stashSlot , Size cursorSizeInCells ) - > StashStruct : : StashCell {
StashStruct : : StashCell itemUnderCursor = [ ] ( Point stashSlot , Size cursorSizeInCells ) - > StashStruct : : StashCell {
if ( stashSlot ! = InvalidStashPoint )
if ( stashSlot = = InvalidStashPoint )
return StashStruct : : EmptyCell ;
return StashStruct : : EmptyCell ;
for ( Point slotUnderCursor : PointsInRectangle ( Rectangle { stashSlot , cursorSizeInCells } ) ) {
for ( Point slotUnderCursor : PointsInRectangle ( Rectangle { stashSlot , cursorSizeInCells } ) ) {
if ( slotUnderCursor . x > = 10 | | slotUnderCursor . y > = 10 )
if ( slotUnderCursor . x > = 10 | | slotUnderCursor . y > = 10 )
@ -1864,20 +1864,26 @@ void PerformPrimaryAction()
return StashStruct : : EmptyCell ;
return StashStruct : : EmptyCell ;
} ( stashSlot , cursorSizeInCells ) ;
} ( stashSlot , cursorSizeInCells ) ;
// The cursor will need to be shifted to
Point jumpSlot = itemUnderCursor = = StashStruct : : EmptyCell ? stashSlot : FindFirstStashSlotOnItem ( itemUnderCursor ) ;
// this slot if the item is swapped or lifted
Point jumpSlot = FindFirstStashSlotOnItem ( itemUnderCursor ) ;
CheckStashItem ( MousePosition ) ;
CheckStashItem ( MousePosition ) ;
// If we don't find the item in the same position as before,
Point mousePos = GetStashSlotCoord ( jumpSlot ) ;
// it suggests that the item was swapped or lifted
ActiveStashSlot = jumpSlot ;
Point newSlot = FindFirstStashSlotOnItem ( itemUnderCursor ) ;
if ( MyPlayer - > HoldItem . isEmpty ( ) ) {
if ( jumpSlot ! = InvalidStashPoint & & jumpSlot ! = newSlot ) {
// For inventory cut/paste we can combine the cases where we swap or simply paste items. Because stash movement is always cell based (there's no fast
Point mousePos = GetStashSlotCoord ( jumpSlot ) ;
// movement over large items) it looks better if we offset the hand cursor to the bottom right cell of the item we just placed.
mousePos . y - = InventorySlotSizeInPixels . height ;
ActiveStashSlot + = Displacement { cursorSizeInCells - 1 } ; // shift the active stash slot coordinates to account for items larger than 1x1
ActiveStashSlot = jumpSlot ;
// Then we displace the mouse position to the bottom right corner of the item, then shift it back half a cell to center it.
SetCursorPos ( mousePos ) ;
// Could also be written as (cursorSize - 1) * InventorySlotSize + HalfInventorySlotSize, same thing in the end.
mousePos + = Displacement { cursorSizeInCells } * Displacement { InventorySlotSizeInPixels } - Displacement { InventorySlotSizeInPixels } / 2 ;
} else {
// If we've picked up an item then use the same logic as the inventory so that the cursor is offset to the center of where the old item location was
// (in this case jumpSlot was the top left cell of where it used to be in the grid, and we need to update the cursor size since we're now holding the item)
cursorSizeInCells = GetInventorySize ( MyPlayer - > HoldItem ) ;
mousePos . x + = ( ( cursorSizeInCells . width ) * InventorySlotSizeInPixels . width ) / 2 ;
mousePos . y + = ( ( cursorSizeInCells . height ) * InventorySlotSizeInPixels . height ) / 2 ;
}
}
SetCursorPos ( mousePos ) ;
}
}
return ;
return ;
}
}