This commit is contained in:
2024-11-25 16:30:38 +00:00
parent 32f0d287e8
commit 83bcf3c0f7
4 changed files with 12 additions and 12 deletions
+7 -6
View File
@@ -121,14 +121,15 @@ tryPickupSelected k mpos w = do
let nfreeslots = crNumFreeSlots cr
xs <- w ^? hud . hudElement . diSelectionExtra
let itmstopickup = mapMaybe g $ IS.toList xs
let slotsneeded = alaf Sum foldMap (_itInvSize . _flIt) $ itmstopickup
let slotsneeded = alaf Sum foldMap (_itInvSize . _flIt) itmstopickup
guard $ nfreeslots >= slotsneeded
return $ case mpos of
Nothing -> foldl' (flip $ pickUpItem 0) w itmstopickup
& hud . hudElement . diSelectionExtra .~ mempty
Just (_,j) -> foldr (pickUpItemAt j 0) w itmstopickup
& hud . hudElement . diSelection ?~ (0,j)
& hud . hudElement . diSelectionExtra .~ IS.fromDistinctAscList [j..j+IS.size xs-1]
& hud . hudElement . diSelectionExtra
.~ IS.fromDistinctAscList [j..j+IS.size xs-1]
where
g i = do
NInt j <- w ^? hud . closeItems . ix i
@@ -440,11 +441,11 @@ updateBackspaceRegex w = case di ^? subInventory of
updateEnterRegex :: World -> World
updateEnterRegex w = case w ^? hud . hudElement . subInventory of
Just NoSubInventory{}
| secfocus (-1) 0 ->
| secfocus [-1,0,1] ->
w & hud . hudElement . diSelection ?~ (-1, 0)
& hud . hudElement . diInvFilter %~ enterregex
Just NoSubInventory{}
| secfocus 2 3 ->
| secfocus [2,3] ->
w & hud . hudElement . diSelection ?~ (2, 0)
& hud . hudElement . diCloseFilter %~ enterregex
Just CombineInventory{} ->
@@ -453,9 +454,9 @@ updateEnterRegex w = case w ^? hud . hudElement . subInventory of
_ -> w
where
di = w ^. hud . hudElement
secfocus a b = fromMaybe False $ do
secfocus xs = fromMaybe False $ do
i <- di ^? diSelection . _Just . _1
return $ i == a || i == b
return $ i `elem` xs
enterregex = (<|> Just "")
pauseGame :: Universe -> Universe