Move inventory filter to different section of selection list

This commit is contained in:
2023-02-17 10:35:59 +00:00
parent 4afc216b25
commit 93dfc2a67c
8 changed files with 111 additions and 102 deletions
+16 -12
View File
@@ -1,9 +1,11 @@
{-# LANGUAGE TupleSections #-}
module Dodge.Inventory (
ssLookupGT,
ssSetCursor,
firstPosSelectionSections,
checkInvSlotsYou,
rmSelectedInvItem,
--invSelPos,
invSelSize,
selNumPos,
selNumTextPos,
@@ -23,6 +25,7 @@ module Dodge.Inventory (
selectedCloseObject,
invDimColor,
trimapAugmentInv,
setInvPosFromSS,
) where
import Dodge.Data.SelectionList
@@ -366,20 +369,13 @@ setInvPosFromSS w = w
i <- sss ^? sssSelPos . _Just
j <- sss ^? sssSections . ix i . ssCursor . _Just . scurSel
case i of
(-1) -> Just $ InInventory SortInventory
0 -> Just $ InInventory (SelItem j NoInvSelAction)
1 -> Just SelNothing
2 -> Just $ SelCloseObject j
_ -> Just SelNothing
_ -> error "selection out of bounds"
--changeAugInvSel :: Int -> World -> World
--changeAugInvSel yi w
-- | yi == 0 = w
-- | otherwise =
-- w & cWorld . lWorld . creatures . ix 0 . crInvSel . isel %~ f
-- where
-- f = fromAugSelPos w . (`mod` (ninv + nclose + 1)) . subtract yi . toAugSelPos w
-- ninv = length (yourInv w)
-- nclose = length (w ^. hud . closeObjects)
-- this should be in a separate module
firstPosSelectionSections :: SelectionSections a -> SelectionSections a
firstPosSelectionSections sss = fromMaybe sss $ do
(i,j,si) <- ssLookupMin sss
@@ -409,6 +405,14 @@ scrollDownSelectionSections sss = fromMaybe (firstPosSelectionSections sss) $ do
return $ sss & sssSelPos ?~ i'
& sssSections . ix i' . ssCursor ?~ SectionCursor j' j' (_siHeight si) (_siColor si)
ssSetCursor :: (SelectionSections a -> Maybe (Int,Int,SelectionItem a))
-> SelectionSections a -> SelectionSections a
ssSetCursor f sss = fromMaybe sss $ do
(i,j,si) <- f sss
return $ sss
& sssSelPos ?~ i
& sssSections . ix i . ssCursor ?~ SectionCursor j j (_siHeight si) (_siColor si)
ssLookupMax :: SelectionSections a -> Maybe (Int,Int,SelectionItem a)
ssLookupMax sss = do
(i,_) <- IM.lookupMax (sss ^. sssSections)