Allow to filter combinations based on used items
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
|
||||
module Dodge.DisplayInventory (
|
||||
updateDisplayInventory,
|
||||
defaultSS,
|
||||
defaultFiltSection,
|
||||
-- , defaultDisplaySections
|
||||
updateSection,
|
||||
enterCombineInv,
|
||||
toggleCombineInv,
|
||||
updatePositionHUD,
|
||||
@@ -20,7 +15,6 @@ import Dodge.Combine
|
||||
import Dodge.Data.Config
|
||||
import Dodge.Data.SelectionList
|
||||
import Dodge.Data.Universe
|
||||
import Dodge.Default.World
|
||||
import Dodge.Inventory.CheckSlots
|
||||
import Dodge.Inventory.Color
|
||||
import Dodge.Inventory.SelectionList
|
||||
@@ -57,7 +51,9 @@ updateCombineInventory w cfig sss =
|
||||
allcombs = IM.fromAscList $ zip [0 ..] $ combineList' w
|
||||
filtcombs = fromMaybe allcombs $ do
|
||||
str <- mstr
|
||||
return $ IM.filter (regexList str . _siPictures) allcombs
|
||||
invitms <- w ^? hud . hudElement . diSections . sssSections . ix 0 . ssItems
|
||||
--return $ IM.filter (regexList str . _siPictures) allcombs
|
||||
return $ regexCombs invitms str allcombs
|
||||
showncombs
|
||||
| null filtcombs = IM.singleton 0 $ SelectionInfo ["No possible combinations"] 1 False white 0
|
||||
| otherwise = filtcombs
|
||||
@@ -70,6 +66,18 @@ updateCombineInventory w cfig sss =
|
||||
mstr = w ^? hud . hudElement . subInventory . ciSections . sssExtra . sssFilters . ix (-1) . _Just
|
||||
numfiltitems = " " ++ show (length allcombs - length filtcombs) ++ " FILTERED"
|
||||
|
||||
regexCombs :: IM.IntMap (SelectionItem ()) -> String
|
||||
-> IM.IntMap (SelectionItem CombinableItem)
|
||||
-> IM.IntMap (SelectionItem CombinableItem)
|
||||
regexCombs inv str = case str of
|
||||
'<':str' -> IM.filter (f str')
|
||||
_ -> IM.filter (regexList str . _siPictures)
|
||||
where
|
||||
f str' si = any (g str') (_ciInvIDs $ _siPayload si)
|
||||
g str' i = fromMaybe False $ do
|
||||
si' <- inv ^? ix i
|
||||
return $ regexList str' $ _siPictures si'
|
||||
|
||||
updateDisplayInventory :: World -> Configuration -> SelectionSections () -> SelectionSections ()
|
||||
updateDisplayInventory w cfig sss =
|
||||
sss & sssSections
|
||||
|
||||
@@ -121,7 +121,6 @@ doRegexInput u i sss
|
||||
& sssExtra . sssFilters . ix i .~ Nothing
|
||||
& sssSections . ix i . ssItems .~ mempty
|
||||
& ssSetCursor (ssLookupDown a b)
|
||||
-- & uvWorld %~ setInvPosFromSS
|
||||
j = fromMaybe 0 $ do
|
||||
itms <- sss ^? sssSections . ix (i + 1) . ssItems
|
||||
fst <$> IM.lookupMin itms
|
||||
|
||||
Reference in New Issue
Block a user