Move combine list over to SelectionSections -- more todo
This commit is contained in:
+60
-14
@@ -5,11 +5,17 @@ module Dodge.Combine (
|
||||
combineList,
|
||||
) where
|
||||
|
||||
import SelectionIntMap
|
||||
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
|
||||
import Dodge.Data.SelectionList
|
||||
--import Dodge.Data.SelectionList
|
||||
import qualified Data.IntSet as IS
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
@@ -20,7 +26,7 @@ import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
import Dodge.Base.You
|
||||
import Dodge.Combine.Trie
|
||||
import Dodge.Data.World
|
||||
--import Dodge.Data.World
|
||||
import Dodge.Item.Amount
|
||||
import Dodge.Module
|
||||
import qualified IntMapHelp as IM
|
||||
@@ -103,17 +109,57 @@ combineTwoModuleMaps =
|
||||
fullModuleName :: ItemModuleType -> String
|
||||
fullModuleName = fromMaybe "EMPTYMODULE" . moduleName
|
||||
|
||||
toggleCombineInv :: World -> World
|
||||
toggleCombineInv w = case w ^? hud . hudElement . subInventory of
|
||||
Just CombineInventory{} -> w & hud . hudElement . subInventory .~ NoSubInventory
|
||||
_ -> w & enterCombineInv
|
||||
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)
|
||||
|
||||
enterCombineInv :: World -> World
|
||||
enterCombineInv w = w & hud . hudElement . subInventory .~ CombineInventory sm
|
||||
updateCombineSelections :: World -> Configuration -> SelectionSections CombinableItem
|
||||
-> SelectionSections CombinableItem
|
||||
updateCombineSelections w cfig sss = sss & sssSections .~ updateSections availablelines ij [filt,combs]
|
||||
where
|
||||
sm = initialSelPos $ SelectionIntMap
|
||||
{ _smItems = combineList w
|
||||
, _smSelPos = Nothing
|
||||
, _smRegex = Nothing
|
||||
, _smShownItems = IM.fromAscList $ zip [0..] (combineList w)
|
||||
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
|
||||
Nothing
|
||||
sss
|
||||
--(updateCombineSelections w cfig sss)
|
||||
where
|
||||
cm = IM.fromAscList $ zip [0..] $ combineList w
|
||||
sss = SelectionSections
|
||||
{ _sssSections = IM.singleton 0 combsection
|
||||
, _sssSelPos = Just 0
|
||||
}
|
||||
availablelines = getAvailableListLines secondColumnParams cfig
|
||||
combsection = updateSection (Just 0) cm availablelines combinationssection'
|
||||
combinationssection' = SelectionSection
|
||||
{ _ssItems = cm
|
||||
, _ssCursor = do
|
||||
(i,si) <- IM.lookupMin cm
|
||||
return $ SectionCursor i 0 (length (_siPictures si)) (_siColor si)
|
||||
, _ssMinSize = 5
|
||||
, _ssOffset = 0
|
||||
, _ssShownItems = mempty
|
||||
, _ssIndent = 0
|
||||
, _ssDescriptor = "COMBINATIONS"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user