Implement filter on nearby objects

This commit is contained in:
2023-02-17 11:19:07 +00:00
parent 93dfc2a67c
commit c0ef36426a
8 changed files with 103 additions and 18 deletions
+21 -7
View File
@@ -23,21 +23,25 @@ import Dodge.Data.World
updateDisplayInventory :: World -> Configuration -> SelectionSections () -> SelectionSections ()
updateDisplayInventory w cfig sss = case cr ^? crManipulation . manObject of
Just (InInventory SortInventory) -> sss
{ _sssSections = updateSections availablelines ((-1),0) [filtinv,invx ,youx, closex]
{ _sssSections = updateSections availablelines ((-1),0) [filtinv,filtclose,invx ,youx, closex]
, _sssSelPos = Just (-1)
}
Just (InInventory (SelItem i _)) -> sss
{ _sssSections = updateSections availablelines (0,i) [filtinv,invx ,youx, closex]
{ _sssSections = updateSections availablelines (0,i) [filtinv,filtclose,invx ,youx, closex]
, _sssSelPos = Just 0
}
Just SelNothing -> sss
{ _sssSections = updateSections availablelines (1,0) [filtinv,invx ,youx, closex]
{ _sssSections = updateSections availablelines (1,0) [filtinv,filtclose,invx ,youx, closex]
, _sssSelPos = Just 1
}
Just (SelCloseObject i) -> sss
{ _sssSections = updateSections availablelines (2,i) [filtinv,closex, invx ,youx]
Just (InNearby SortNearby) -> sss
{ _sssSections = updateSections availablelines (2,0) [filtinv,filtclose,closex, invx ,youx]
, _sssSelPos = Just 2
}
Just (InNearby (SelCloseObject i)) -> sss
{ _sssSections = updateSections availablelines (3,i) [filtinv,filtclose,closex, invx ,youx]
, _sssSelPos = Just 3
}
_ -> error "error when getting cr inv sel"
where
filtinv = (-1,(filtinvsec,filtinvitems))
@@ -45,18 +49,28 @@ updateDisplayInventory w cfig sss = case cr ^? crManipulation . manObject of
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,(filtclosesec,filtcloseitems))
filtclosesec = fromMaybe defaultFiltSection $ sss ^? sssSections . ix 2
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,(invsec, invitems))
youx = (1,(yousec, youitems))
closex = (2,(cosec, coitems))
closex = (3,(cosec, coitems))
youitems = IM.singleton 0 $ SelectionItem [thetext] 1 True invDimColor 2 ()
thetext = displayFreeSlots nfreeslots
availablelines = getAvailableListLines (invDisplayParams w) cfig
cosec = fromMaybe defaultCOSection $ sss ^? sssSections . ix 2
invsec = fromMaybe defaultInvSection $ sss ^? sssSections . ix 0
coitems = IM.fromDistinctAscList . zip [0..]
coitems' = IM.fromDistinctAscList . zip [0..]
$ map (closeObjectToSelectionItem nfreeslots) (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'