Prevent selection of unselectable items when scrolling
This commit is contained in:
@@ -4,7 +4,6 @@ module Dodge.DisplayInventory
|
||||
, defaultSS
|
||||
, defaultFiltSection
|
||||
, defaultDisplaySections
|
||||
-- , updateSections
|
||||
, updateSection
|
||||
) where
|
||||
|
||||
@@ -39,36 +38,32 @@ updateDisplayInventory w cfig sss = case cr ^? crManipulation . manObject of
|
||||
SelNothing -> reverse [filtinv,filtclose,invx ,youx, closex]
|
||||
InNearby SortNearby -> reverse [filtinv,filtclose,closex, invx ,youx]
|
||||
InNearby SelCloseObject {} -> reverse [filtinv,filtclose,closex, invx ,youx]
|
||||
filtinv = (-1,filtinvitems)
|
||||
filtinvitems = case cr ^? crManipulation . invRegex . _Just of
|
||||
Just str -> IM.singleton 0 (SelectionRegex ["INV. FILTER: " ++ str,numfiltitems] 2 True white 0)
|
||||
Nothing -> mempty
|
||||
filtclose = (2,filtcloseitems)
|
||||
filtcloseitems = case cr ^? crManipulation . closeRegex . _Just of
|
||||
Just str -> IM.singleton 0 (SelectionRegex ["NEARBY FILTER: " ++ str,numfiltclose] 2 True white 0)
|
||||
Nothing -> mempty
|
||||
numfiltitems = " " ++ show numfiltitems' ++ " FILTERED"
|
||||
numfiltitems' = length invitems' - length invitems
|
||||
numfiltclose = " " ++ show numfiltclose' ++ " FILTERED"
|
||||
numfiltclose' = length coitems' - length coitems
|
||||
invx = (0, invitems)
|
||||
(filtinv,invx) = filtpair (-1) (crManipulation . invRegex . _Just) invitems' "INV. "
|
||||
(filtclose,closex) = filtpair 2 (crManipulation . closeRegex . _Just) coitems' "NEARBY "
|
||||
youx = (1, youitems)
|
||||
closex = (3, coitems)
|
||||
youitems = IM.singleton 0 $ SelectionItem [thetext] 1 True invDimColor 2 ()
|
||||
thetext = displayFreeSlots nfreeslots
|
||||
availablelines = getAvailableListLines (invDisplayParams w) cfig
|
||||
coitems' = IM.fromDistinctAscList . zip [0..]
|
||||
$ map closeObjectToSelectionItem (w ^. hud . closeObjects)
|
||||
coitems = case cr ^? crManipulation . closeRegex . _Just of
|
||||
Just str -> IM.filter (regexList str . _siPictures) coitems'
|
||||
Nothing -> coitems'
|
||||
invitems' = IM.mapWithKey (invSelectionItem' cr) inv
|
||||
invitems = case cr ^? crManipulation . invRegex . _Just of
|
||||
Just str -> IM.filter (regexList str . _siPictures) invitems'
|
||||
Nothing -> invitems'
|
||||
cr = you w
|
||||
inv = _crInv (you w)
|
||||
nfreeslots = crNumFreeSlots cr
|
||||
filtpair i regpointer itms filtdescription =
|
||||
( ( i, filtsis)
|
||||
, ( i+1, itms')
|
||||
)
|
||||
where
|
||||
mstr = cr ^? regpointer
|
||||
filtsis = fromMaybe mempty $ do
|
||||
str <- mstr
|
||||
return $ IM.singleton 0
|
||||
(SelectionRegex [filtdescription ++ "FILTER: "++str,numfiltitems] 2 True white 0)
|
||||
itms' = fromMaybe itms $ do
|
||||
str <- mstr
|
||||
return $ IM.filter (regexList str . _siPictures) itms
|
||||
numfiltitems = " " ++ show (length itms - length itms') ++ " FILTERED"
|
||||
|
||||
displayFreeSlots :: Int -> String
|
||||
displayFreeSlots x = case x of
|
||||
@@ -76,7 +71,6 @@ displayFreeSlots x = case x of
|
||||
1 -> "1 FREE SLOT"
|
||||
_ -> show x ++ " FREE SLOTS"
|
||||
|
||||
|
||||
updateSectionsPositioning
|
||||
:: SelectionSections a
|
||||
-> Int -> [(Int,IM.IntMap (SelectionItem a))]
|
||||
@@ -96,33 +90,6 @@ updateSectionsPositioning sss allavailablelines ((k,y) : xs)
|
||||
linestaken ss' = max (length $ _ssShownItems ss') (_ssMinSize ss')
|
||||
previoussections = updateSectionsPositioning sss availablelines xs
|
||||
|
||||
--updateSectionsPositioning
|
||||
-- :: SelectionSections a
|
||||
-- -> Int -> (Int, Int) -> [(Int,IM.IntMap (SelectionItem a))]
|
||||
-- -> SelectionSections a
|
||||
--updateSectionsPositioning sss _ _ [] = sss & sssSections .~ mempty
|
||||
--updateSectionsPositioning sss allavailablelines (i,j) ((k,y) : xs)
|
||||
-- = previoussections & sssSections %~ IM.insert k ss
|
||||
-- where
|
||||
-- ss | i == k = updateSection (Just j) y linesleft x
|
||||
-- | otherwise = updateSection Nothing y linesleft x
|
||||
-- x = sss ^?! sssSections . ix k
|
||||
-- availablelines = allavailablelines - _ssMinSize x
|
||||
-- linesleft = allavailablelines - sum (fmap (length . _ssShownItems) $ _sssSections previoussections)
|
||||
-- previoussections = updateSectionsPositioning sss availablelines (i,j) xs
|
||||
|
||||
--updateSections :: Int -> (Int, Int) -> [(Int,(SelectionSection a,IM.IntMap (SelectionItem a)))]
|
||||
-- -> IM.IntMap (SelectionSection a)
|
||||
--updateSections _ _ [] = mempty
|
||||
--updateSections allavailablelines (i,j) ((k,(x,y)):xs) = IM.insert k ss previoussections
|
||||
-- where
|
||||
-- ss | i == k = updateSection y linesleft x
|
||||
-- | otherwise = updateSection y linesleft x
|
||||
-- availablelines = allavailablelines - _ssMinSize x
|
||||
-- linesleft = allavailablelines - sum (fmap (length . _ssShownItems) $ previoussections)
|
||||
-- previoussections = updateSections availablelines (i,j) xs
|
||||
|
||||
|
||||
manObjIndex :: ManipulatedObject -> (Int,Int)
|
||||
manObjIndex mo = case mo of
|
||||
InInventory SortInventory -> (-1, 0)
|
||||
|
||||
Reference in New Issue
Block a user