From 489ff21e12b06905a55a97a5995dc940fc09caf6 Mon Sep 17 00:00:00 2001 From: justin Date: Mon, 4 Nov 2024 19:45:12 +0000 Subject: [PATCH] Remove inventory selection on item drop/pickup --- ghcidOutput | 2 +- src/Dodge/DisplayInventory.hs | 24 ++++++++---------------- src/Dodge/Inventory.hs | 4 +++- src/Dodge/Inventory/Add.hs | 3 +++ src/Dodge/Render/HUD.hs | 2 +- src/Dodge/SelectionSections.hs | 2 +- 6 files changed, 17 insertions(+), 20 deletions(-) diff --git a/ghcidOutput b/ghcidOutput index b8fe98076..bea2fd497 100644 --- a/ghcidOutput +++ b/ghcidOutput @@ -1 +1 @@ -All good (594 modules, at 19:29:05) +All good (594 modules, at 19:44:39) diff --git a/src/Dodge/DisplayInventory.hs b/src/Dodge/DisplayInventory.hs index 3b99141c6..5335ac3b2 100644 --- a/src/Dodge/DisplayInventory.hs +++ b/src/Dodge/DisplayInventory.hs @@ -243,32 +243,24 @@ updateSection sis mcsel availablelines ss = si <- sis ^? ix csel let xselsize = length $ _siPictures si return $ case sum $ fmap (length . _siPictures) . fst . IM.split csel $ sis of - pos - | pos == 0 || length allstrings <= availablelines -> - 0 - pos - | pos - 1 < oldoffset -> - pos - 1 - pos - | maxcsel == csel -> - pos - availablelines + xselsize - pos - | pos + 1 + xselsize - availablelines > oldoffset -> + pos | pos == 0 || length allstrings <= availablelines -> 0 + pos | pos - 1 < oldoffset -> pos - 1 + pos | maxcsel == csel -> pos - availablelines + xselsize + pos | pos + 1 + xselsize - availablelines > oldoffset -> pos - availablelines + 1 + xselsize - _ - | length allstrings - oldoffset < availablelines -> + _ | length allstrings - oldoffset < availablelines -> length allstrings - availablelines _ -> oldoffset tweakfirst (x : xs) | offset > 0 = - (color moreupcolor $ text (theindent ++ replicate 15 (toEnum 30))) : + color moreupcolor (text (theindent ++ replicate 15 (toEnum 30))) : xs - | otherwise = (x : xs) + | otherwise = x : xs tweakfirst [] = [] moreupcolor = fromMaybe white $ allstrings ^? ix offset . _1 shownitems | length shownstrings > availablelines = - (map h $ take (availablelines - 1) shownstrings) + map h (take (availablelines - 1) shownstrings) ++ [color moredowncolor . text $ theindent ++ replicate 15 (toEnum 31)] | otherwise = map h shownstrings moredowncolor = fromMaybe white $ allstrings ^? ix (offset + availablelines - 1) . _1 diff --git a/src/Dodge/Inventory.hs b/src/Dodge/Inventory.hs index 63c9f896b..8b7e497e2 100644 --- a/src/Dodge/Inventory.hs +++ b/src/Dodge/Inventory.hs @@ -76,13 +76,15 @@ rmInvItem cid invid w = & pointcid . crInvHotkeys %~ IM.delete invid & pointcid . crInvHotkeys %~ IM.mapKeys g & updateselection + & updateselectionextra & pointcid %~ updateRootItemID & worldEventFlags . at InventoryChange ?~ () where -- & updateCreatureItemLocations cid pointcid = cWorld . lWorld . creatures . ix cid - + updateselectionextra | cid == 0 = hud . hudElement . diSelectionExtra .~ 0 + | otherwise = id updateselection | cid == 0 && cr ^? crManipulation . manObject . imSelectedItem == Just invid = scrollAugInvSel (-1) . scrollAugInvSel 1 -- . updateInventorySectionItems diff --git a/src/Dodge/Inventory/Add.hs b/src/Dodge/Inventory/Add.hs index eb3ea1161..03b004bd5 100644 --- a/src/Dodge/Inventory/Add.hs +++ b/src/Dodge/Inventory/Add.hs @@ -42,9 +42,12 @@ tryPutItemInInv cid flit w = case maybeInvSlot of -- second for the root/selected item bools & cWorld . lWorld %~ crUpdateItemLocations cid & setInvPosFromSS + & updateselectionextra & cWorld . lWorld %~ crUpdateItemLocations cid ) where + updateselectionextra | cid == 0 = hud . hudElement . diSelectionExtra .~ 0 + | otherwise = id it = _flIt flit maybeInvSlot = checkInvSlotsYou it w -- not sure if the following is necessary diff --git a/src/Dodge/Render/HUD.hs b/src/Dodge/Render/HUD.hs index 7083ee6d7..5303a6742 100644 --- a/src/Dodge/Render/HUD.hs +++ b/src/Dodge/Render/HUD.hs @@ -74,7 +74,7 @@ drawInventory sss w cfig = curs = invCursorParams w iextra = fromMaybe mempty $ do inv <- w ^? cWorld . lWorld . creatures . ix 0 . crInv - guard =<< fmap (not . isFilteringInv) (w ^? hud . hudElement . diSections) + guard . not . isFilteringInv =<< (w ^? hud . hudElement . diSections) return . inventoryExtra sss cfig w $ invAdj inv drawRootCursor :: World diff --git a/src/Dodge/SelectionSections.hs b/src/Dodge/SelectionSections.hs index 4c0dc7fcb..912d9c9cd 100644 --- a/src/Dodge/SelectionSections.hs +++ b/src/Dodge/SelectionSections.hs @@ -41,7 +41,7 @@ nextInSectionSS :: IM.IntMap (SelectionSection a) -> Maybe (Int, Int) -> Maybe (Int, Int) -nextInSectionSS sss = ssScrollUsing ssLookupNextMax sss +nextInSectionSS = ssScrollUsing ssLookupNextMax --setFirstPosSelectionSections :: SelectionSections a -> SelectionSections a --setFirstPosSelectionSections sss = fromMaybe sss $ do