Fix bugs in drag pickup when releasing mouse outside of inventory list
This commit is contained in:
@@ -132,23 +132,22 @@ tryPickupSelected k mpos w = do
|
||||
guard $ k == 3
|
||||
guard $ maybe True (\(i, _) -> i == 0 || i == 1) mpos
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
let nfreeslots = crNumFreeSlots (w ^. cWorld . lWorld . items) cr
|
||||
xs <- w ^? hud . hudElement . diSelection . _Just . _3
|
||||
let itmstopickup = mapMaybe g $ IS.toList xs
|
||||
let slotsneeded = alaf Sum foldMap itInvHeight itmstopickup
|
||||
let nfreeslots = crNumFreeSlots (w ^. cWorld . lWorld . items) cr
|
||||
itmstopickup = mapMaybe g $ IS.toList xs
|
||||
slotsneeded = alaf Sum foldMap itInvHeight itmstopickup
|
||||
ispickup = map (_unNInt . _itID) itmstopickup
|
||||
guard $ nfreeslots >= slotsneeded
|
||||
return $ case mpos of
|
||||
Just (0, j) ->
|
||||
foldr (pickUpItemAt j 0) w (map (_unNInt . _itID) itmstopickup)
|
||||
& hud . hudElement . diSelection
|
||||
?~ ( 0
|
||||
, j
|
||||
, IS.fromDistinctAscList [j .. j + IS.size xs -1]
|
||||
)
|
||||
foldr (pickUpItemAt j 0) w ispickup
|
||||
& newdisel j xs
|
||||
_ ->
|
||||
foldl' (flip $ pickUpItem 0) w (IS.toList xs)
|
||||
& hud . hudElement . diSelection . _Just . _3 %~ const mempty
|
||||
foldl' (flip $ pickUpItem 0) w ispickup
|
||||
& newdisel (length (cr ^. crInv)) xs
|
||||
where
|
||||
newdisel j xs = hud . hudElement . diSelection ?~
|
||||
(0 , j , IS.fromDistinctAscList [j .. j + IS.size xs -1])
|
||||
g i = do
|
||||
NInt j <- w ^? hud . closeItems . ix i
|
||||
w ^? cWorld . lWorld . items . ix j
|
||||
|
||||
Reference in New Issue
Block a user