Work on selections when picking up/droping items

This commit is contained in:
2026-05-14 11:40:58 +01:00
parent 44ecaf409e
commit ab393febcb
7 changed files with 155 additions and 112 deletions
+7 -13
View File
@@ -154,7 +154,6 @@ tryDropSelected mpos w = do
let xmin = IS.findMin xs
return
. (hud . diSelection ?~ Sel 3 (j - xmin))
. (hud . diSections . ix 3 . ssSet .~ IS.fromDistinctAscList [0 .. IS.size xs - 1])
. foldl' (flip $ dropItem cr) w
. IS.toDescList
$ xs
@@ -181,18 +180,17 @@ tryPickupSelected k mpos w = do
let xmin = IS.findMin xs
joff = sli - xmin
let nfreeslots = crNumFreeSlots (w ^. cWorld . lWorld . items) cr
itmstopickup = mapMaybe g $ IS.toList xs
is = IS.toList xs
itmstopickup = mapMaybe g is
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 joff xs
_ -> foldl' (flip $ pickUpItem 0) w ispickup & newdisel (length (cr ^. crInv)) joff xs
Just (0, j) -> foldr (pickUpItemAt j 0) w (zip is ispickup) & newdisel j joff
_ -> foldl' (flip $ pickUpItem 0) w (zip is ispickup) & newdisel (length (cr ^. crInv)) joff
where
newdisel j joff xs =
-- hud . diSelection ?~ Sel 0 (j+joff) (IS.fromDistinctAscList [j .. j + IS.size xs -1])
newdisel j joff =
(hud . diSelection ?~ Sel 0 (j + joff))
. (hud . diSections . ix 0 . ssSet .~ IS.fromDistinctAscList [j .. j + IS.size xs - 1])
g i = do
NInt j <- w ^? hud . closeItems . ix i
w ^? cWorld . lWorld . items . ix j
@@ -549,12 +547,8 @@ updateEnterRegex w = case w ^? hud . subInventory of
| secfocus [2, 3] ->
-- w & hud . diSelection ?~ Sel 2 0 mempty
w
& hud
. diSelection
?~ Sel 2 0
& hud
. diCloseFilter
%~ enterregex
& hud . diSelection ?~ Sel 2 0
& hud . diCloseFilter %~ enterregex
Just CombineInventory{} ->
w
& hud