Fix combinations filter

This commit is contained in:
2023-02-21 11:10:59 +00:00
parent 4904c57972
commit 8b0e1eab81
9 changed files with 211 additions and 227 deletions
+1 -77
View File
@@ -1,17 +1,10 @@
--{-# LANGUAGE TupleSections #-}
module Dodge.Combine (
toggleCombineInv,
enterCombineInv,
combineList,
combineList',
) where
import Dodge.Data.Universe
--import Regex
import Dodge.DisplayInventory
import Dodge.Render.HUD
import Dodge.SelectionList
--import Dodge.Data.Config
--import SelectionIntMap
import Dodge.Data.Combine
import Dodge.Item.Display
import Color
@@ -108,72 +101,3 @@ combineTwoModuleMaps =
fullModuleName :: ItemModuleType -> String
fullModuleName = fromMaybe "EMPTYMODULE" . moduleName
toggleCombineInv :: Universe -> Universe
toggleCombineInv uv = case uv ^? uvWorld . hud . hudElement . subInventory of
Just CombineInventory{} -> uv & uvWorld . hud . hudElement . subInventory .~ NoSubInventory
_ -> uv & uvWorld %~ enterCombineInv (uv ^. uvConfig)
--updateCombineSelections :: World -> Configuration -> SelectionSections CombinableItem
-- -> SelectionSections CombinableItem
--updateCombineSelections w cfig sss = sss & sssSections .~ updateSections availablelines ij [combs,filt]
-- where
-- availablelines = getAvailableListLines secondColumnParams cfig
-- filt = (-1, (filtsec,filtitems))
-- filtsec = fromMaybe defaultFiltSection $ sss ^? sssSections . ix (-1)
-- filtitems = case w ^? hud . hudElement . subInventory . ciRegex . _Just of
-- Just str -> IM.singleton 0 (SelectionRegex ["COMB. FILTER: " ++ str,numfiltitems] 2 True white 0)
-- Nothing -> mempty
-- numfiltitems = " " ++ show numfiltitems' ++ " FILTERED"
-- numfiltitems' = length combitems' - length combitems
-- combs :: (Int , (SelectionSection CombinableItem , IM.IntMap (SelectionItem CombinableItem)))
-- combs = (0, (combsec,combitems))
-- combsec = fromMaybe (defaultSS & ssDescriptor .~ "COMBINATIONS") $ sss ^? sssSections . ix 0
-- combitems' = fromMaybe mempty $ w ^? hud . hudElement . subInventory . ciCombinations
-- combitems = case w ^? hud . hudElement . subInventory . ciRegex . _Just of
-- Just str -> IM.filter (regexList str . _siPictures) combitems'
-- Nothing -> combitems'
-- ij = fromMaybe (0,0) $ do
-- i <- sss ^? sssSelPos . _Just
-- j <- sss ^? sssSections . ix i . ssCursor . _Just . scurSel
-- return (i,j)
enterCombineInv :: Configuration -> World -> World
enterCombineInv cfig w = w & hud . hudElement . subInventory .~ CombineInventory
cm'
sss
--(updateCombineSelections w cfig sss)
where
cm' = IM.fromAscList $ zip [0..] $ combineList' w
cm | null cm' = IM.singleton 0 $ SelectionInfo ["No possible combinations"] 1 False white 0
| otherwise = cm'
sss = SelectionSections
{ _sssSections = IM.fromDistinctAscList [(-1,filtsection),(0,combsection)]
, _sssExtra = SSSExtra
{_sssSelPos = selpos
, _sssFilters=IM.singleton (-1) Nothing
}
}
selpos | null cm' = Nothing
| otherwise = Just (0,0)
availablelines = getAvailableListLines secondColumnParams cfig
filtsection = SelectionSection
{ _ssItems = mempty
, _ssCursor = Nothing
, _ssMinSize = 0
, _ssOffset = 0
, _ssShownItems = mempty
, _ssIndent = 0
, _ssDescriptor = "COMB FILTER"
}
combsection = updateSection cm (Just 0) availablelines combinationssection'
combinationssection' = SelectionSection
{ _ssItems = cm
, _ssCursor = do
(_,si) <- IM.lookupMin cm
return $ SectionCursor 0 (length (_siPictures si)) (_siColor si)
, _ssMinSize = 5
, _ssOffset = 0
, _ssShownItems = mempty
, _ssIndent = 0
, _ssDescriptor = "COMBINATIONS"
}