From 608de9f2ed954fbf7bebcd80b1c1247173140bc1 Mon Sep 17 00:00:00 2001 From: justin Date: Mon, 6 Apr 2026 18:18:41 +0100 Subject: [PATCH] Tweak drag pickup/drop --- src/Dodge/Update/Input/InGame.hs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Dodge/Update/Input/InGame.hs b/src/Dodge/Update/Input/InGame.hs index 13c116b0d..1bad81eb7 100644 --- a/src/Dodge/Update/Input/InGame.hs +++ b/src/Dodge/Update/Input/InGame.hs @@ -155,9 +155,11 @@ tryDropSelected mpos w = do guard $ maybe True (\(i, _) -> i == 3) mpos cr <- w ^? cWorld . lWorld . creatures . ix 0 0 <- w ^? hud . diSelection . _Just . slSec + j <- w ^? hud . diSelection . _Just . slInt xs <- selectionSet w + let xmin = IS.findMin xs return - . (hud . diSelection ?~ Sel 3 0 (IS.fromDistinctAscList [0..IS.size xs - 1])) + . (hud . diSelection ?~ Sel 3 (j-xmin) (IS.fromDistinctAscList [0..IS.size xs - 1])) . foldl' (flip $ dropItem cr) w . IS.toDescList $ xs selectionSet :: World -> Maybe IS.IntSet @@ -172,17 +174,20 @@ tryPickupSelected k mpos w = do guard $ maybe True (\(i, _) -> i == 0 || i == 1) mpos cr <- w ^? cWorld . lWorld . creatures . ix 0 xs <- selectionSet w + sli <- w ^? hud . diSelection . _Just . slInt + let xmin = IS.findMin xs + joff = sli - xmin 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 ispickup & newdisel j xs - _ -> foldl' (flip $ pickUpItem 0) w ispickup & newdisel (length (cr ^. crInv)) xs + Just (0, j) -> foldr (pickUpItemAt j 0) w ispickup & newdisel j joff xs + _ -> foldl' (flip $ pickUpItem 0) w ispickup & newdisel (length (cr ^. crInv)) joff xs where - newdisel j xs = - hud . diSelection ?~ Sel 0 j (IS.fromDistinctAscList [j .. j + IS.size xs -1]) + newdisel j joff xs = + hud . diSelection ?~ Sel 0 (j+joff) (IS.fromDistinctAscList [j .. j + IS.size xs -1]) g i = do NInt j <- w ^? hud . closeItems . ix i w ^? cWorld . lWorld . items . ix j