Remove inventory selection on item drop/pickup

This commit is contained in:
2024-11-04 19:45:12 +00:00
parent 3f9b31a838
commit 489ff21e12
6 changed files with 17 additions and 20 deletions
+1 -1
View File
@@ -1 +1 @@
All good (594 modules, at 19:29:05) All good (594 modules, at 19:44:39)
+8 -16
View File
@@ -243,32 +243,24 @@ updateSection sis mcsel availablelines ss =
si <- sis ^? ix csel si <- sis ^? ix csel
let xselsize = length $ _siPictures si let xselsize = length $ _siPictures si
return $ case sum $ fmap (length . _siPictures) . fst . IM.split csel $ sis of return $ case sum $ fmap (length . _siPictures) . fst . IM.split csel $ sis of
pos pos | pos == 0 || length allstrings <= availablelines -> 0
| pos == 0 || length allstrings <= availablelines -> pos | pos - 1 < oldoffset -> pos - 1
0 pos | maxcsel == csel -> pos - availablelines + xselsize
pos pos | pos + 1 + xselsize - availablelines > oldoffset ->
| pos - 1 < oldoffset ->
pos - 1
pos
| maxcsel == csel ->
pos - availablelines + xselsize
pos
| pos + 1 + xselsize - availablelines > oldoffset ->
pos - availablelines + 1 + xselsize pos - availablelines + 1 + xselsize
_ _ | length allstrings - oldoffset < availablelines ->
| length allstrings - oldoffset < availablelines ->
length allstrings - availablelines length allstrings - availablelines
_ -> oldoffset _ -> oldoffset
tweakfirst (x : xs) tweakfirst (x : xs)
| offset > 0 = | offset > 0 =
(color moreupcolor $ text (theindent ++ replicate 15 (toEnum 30))) : color moreupcolor (text (theindent ++ replicate 15 (toEnum 30))) :
xs xs
| otherwise = (x : xs) | otherwise = x : xs
tweakfirst [] = [] tweakfirst [] = []
moreupcolor = fromMaybe white $ allstrings ^? ix offset . _1 moreupcolor = fromMaybe white $ allstrings ^? ix offset . _1
shownitems shownitems
| length shownstrings > availablelines = | length shownstrings > availablelines =
(map h $ take (availablelines - 1) shownstrings) map h (take (availablelines - 1) shownstrings)
++ [color moredowncolor . text $ theindent ++ replicate 15 (toEnum 31)] ++ [color moredowncolor . text $ theindent ++ replicate 15 (toEnum 31)]
| otherwise = map h shownstrings | otherwise = map h shownstrings
moredowncolor = fromMaybe white $ allstrings ^? ix (offset + availablelines - 1) . _1 moredowncolor = fromMaybe white $ allstrings ^? ix (offset + availablelines - 1) . _1
+3 -1
View File
@@ -76,13 +76,15 @@ rmInvItem cid invid w =
& pointcid . crInvHotkeys %~ IM.delete invid & pointcid . crInvHotkeys %~ IM.delete invid
& pointcid . crInvHotkeys %~ IM.mapKeys g & pointcid . crInvHotkeys %~ IM.mapKeys g
& updateselection & updateselection
& updateselectionextra
& pointcid %~ updateRootItemID & pointcid %~ updateRootItemID
& worldEventFlags . at InventoryChange ?~ () & worldEventFlags . at InventoryChange ?~ ()
where where
-- & updateCreatureItemLocations cid -- & updateCreatureItemLocations cid
pointcid = cWorld . lWorld . creatures . ix cid pointcid = cWorld . lWorld . creatures . ix cid
updateselectionextra | cid == 0 = hud . hudElement . diSelectionExtra .~ 0
| otherwise = id
updateselection updateselection
| cid == 0 && cr ^? crManipulation . manObject . imSelectedItem == Just invid = | cid == 0 && cr ^? crManipulation . manObject . imSelectedItem == Just invid =
scrollAugInvSel (-1) . scrollAugInvSel 1 -- . updateInventorySectionItems scrollAugInvSel (-1) . scrollAugInvSel 1 -- . updateInventorySectionItems
+3
View File
@@ -42,9 +42,12 @@ tryPutItemInInv cid flit w = case maybeInvSlot of
-- second for the root/selected item bools -- second for the root/selected item bools
& cWorld . lWorld %~ crUpdateItemLocations cid & cWorld . lWorld %~ crUpdateItemLocations cid
& setInvPosFromSS & setInvPosFromSS
& updateselectionextra
& cWorld . lWorld %~ crUpdateItemLocations cid & cWorld . lWorld %~ crUpdateItemLocations cid
) )
where where
updateselectionextra | cid == 0 = hud . hudElement . diSelectionExtra .~ 0
| otherwise = id
it = _flIt flit it = _flIt flit
maybeInvSlot = checkInvSlotsYou it w maybeInvSlot = checkInvSlotsYou it w
-- not sure if the following is necessary -- not sure if the following is necessary
+1 -1
View File
@@ -74,7 +74,7 @@ drawInventory sss w cfig =
curs = invCursorParams w curs = invCursorParams w
iextra = fromMaybe mempty $ do iextra = fromMaybe mempty $ do
inv <- w ^? cWorld . lWorld . creatures . ix 0 . crInv 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 return . inventoryExtra sss cfig w $ invAdj inv
drawRootCursor :: World drawRootCursor :: World
+1 -1
View File
@@ -41,7 +41,7 @@ nextInSectionSS ::
IM.IntMap (SelectionSection a) -> IM.IntMap (SelectionSection a) ->
Maybe (Int, Int) -> Maybe (Int, Int) ->
Maybe (Int, Int) Maybe (Int, Int)
nextInSectionSS sss = ssScrollUsing ssLookupNextMax sss nextInSectionSS = ssScrollUsing ssLookupNextMax
--setFirstPosSelectionSections :: SelectionSections a -> SelectionSections a --setFirstPosSelectionSections :: SelectionSections a -> SelectionSections a
--setFirstPosSelectionSections sss = fromMaybe sss $ do --setFirstPosSelectionSections sss = fromMaybe sss $ do