From 32f0d287e83954657036df3bd1819101b0441b68 Mon Sep 17 00:00:00 2001 From: justin Date: Mon, 25 Nov 2024 15:47:32 +0000 Subject: [PATCH] Space only picks up filtered close items --- ghcidOutput | 2 +- src/Dodge/Creature/Action.hs | 6 +++++- src/Dodge/FloorItem.hs | 4 +++- src/Dodge/Update/Input/InGame.hs | 10 ++++++---- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ghcidOutput b/ghcidOutput index 469709bcd..ebca0b22c 100644 --- a/ghcidOutput +++ b/ghcidOutput @@ -1 +1 @@ -All good (594 modules, at 15:18:36) +All good (594 modules, at 15:45:51) diff --git a/src/Dodge/Creature/Action.hs b/src/Dodge/Creature/Action.hs index 2042cb5e8..014214e44 100644 --- a/src/Dodge/Creature/Action.hs +++ b/src/Dodge/Creature/Action.hs @@ -176,11 +176,15 @@ dropExcept cr invid w = -- why not a cid (Int)? dropItem :: Creature -> Int -> World -> World dropItem cr invid = - rmInvItem (_crID cr) invid + maybeshiftseldown + . rmInvItem (_crID cr) invid . copyItemToFloor (_crPos cr) itm -- . mayberemoveequip . soundStart (CrSound (_crID cr)) (_crPos cr) whiteNoiseFadeOutS Nothing where itm = fromMaybe (error "dropItem cannot find item") $ cr ^? crInv . ix invid + maybeshiftseldown w = fromMaybe w $ do + 3 <- w ^? hud . hudElement . diSelection . _Just . _1 + return $ w & hud . hudElement . diSelection . _Just . _2 +~ 1 -- | Get your creature to drop the item under the cursor. youDropItem :: World -> World diff --git a/src/Dodge/FloorItem.hs b/src/Dodge/FloorItem.hs index 734c599a6..ca4a6e452 100644 --- a/src/Dodge/FloorItem.hs +++ b/src/Dodge/FloorItem.hs @@ -24,7 +24,9 @@ copyItemToFloorID pos it w = w' & cWorld . lWorld . floorItems . unNIntMap %~ IM.insert flid theflit & cWorld . lWorld . itemLocations %~ IM.insert (_unNInt $ _itID it) (OnFloor $ NInt flid) - & hud . closeItems %~ (NInt flid:) + & hud . closeItems %~ (NInt flid:) +-- & hud . hudElement . diSections . ix 3 . ssOffset .~ 0 + -- ensures dropped item is at the top of the close item selection list where (p', w') = findWallFreeDropPoint (_dimRad $ _itDimension it) pos w rot = fst . randomR (- pi, pi) $ _randGen w diff --git a/src/Dodge/Update/Input/InGame.hs b/src/Dodge/Update/Input/InGame.hs index f55afee61..55ed11011 100644 --- a/src/Dodge/Update/Input/InGame.hs +++ b/src/Dodge/Update/Input/InGame.hs @@ -100,7 +100,7 @@ updateMouseHeldInGame cfig w = case w ^. input . mouseContext of is <- w ^? hud . hudElement . diSelectionExtra return $ if concurrentIS is then shiftInvItems k x ab bn is ss w - else collectInvItems is w + else collectInvItems k is w _ -> w where ldp = invDisplayParams w @@ -231,8 +231,9 @@ concurrentIS = go . IS.minView (j, js) <- IS.minView is return $ i + 1 == j && go (Just (j, js)) -collectInvItems :: IS.IntSet -> World -> World -collectInvItems is w = fromMaybe w $ do +collectInvItems :: Int -> IS.IntSet -> World -> World +collectInvItems secid is w = fromMaybe w $ do + guard $ secid == 0 (j, js) <- IS.minView is return $ h j js w where @@ -494,7 +495,8 @@ selCloseObj w = selobj <|> firstcitem <|> firstcbut fmap Right $ w ^? cWorld . lWorld . buttons . ix k _ -> Nothing firstcitem = do - NInt k <- w ^? hud . closeItems . ix 0 + k' <- (w ^? hud . hudElement . diSections . ix 3 . ssItems) >>= (fmap fst . IM.lookupMin) + NInt k <- w ^? hud . closeItems . ix k' fmap Left $ w ^? cWorld . lWorld . floorItems . unNIntMap . ix k firstcbut = do k <- w ^? hud . closeButtons . ix 0