Move inventory filter to different section of selection list
This commit is contained in:
+16
-12
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user