Reuse combine inventory code

This commit is contained in:
2025-01-06 10:54:24 +00:00
parent ecc9171bb6
commit b59ebaf57d
2 changed files with 12 additions and 3 deletions
-1
View File
@@ -38,7 +38,6 @@ type IMSS a = IntMap (SelectionSection a)
data SelectionWidth
= FixedSelectionWidth Int
-- | UseMaxSelectionItemWidth
| UseItemWidth
data SelectionItem a
+12 -2
View File
@@ -51,7 +51,7 @@ updateCombineSections w cfig =
(const 0)
(w ^? hud . hudElement . subInventory . ciSelection . _Just)
(getAvailableListLines secondColumnParams cfig)
(IM.fromDistinctAscList [(0, sclose), (-1, sfclose)])
(IM.fromDistinctAscList [(-1, sfclose),(0, sclose')])
where
filtcurs = w ^? hud . hudElement . subInventory . ciSelection . _Just . _1 == Just (-1)
(sfclose, sclose) =
@@ -62,6 +62,11 @@ updateCombineSections w cfig =
"COMBINATIONS"
$ w ^? hud . hudElement . subInventory . ciFilter . _Just
invitms = fold $ w ^? cWorld . lWorld . creatures . ix 0 . crInv
sclose'
| null sclose =
IM.singleton 0 $
SelectionInfo ["No possible combinations"] 1 25 False white 0
| otherwise = sclose
regexCombs :: IM.IntMap Item -> SelectionItem CombinableItem -> String -> Bool
regexCombs inv ci = \case
@@ -318,10 +323,15 @@ enterCombineInv :: Configuration -> World -> World
enterCombineInv cfig w =
w & hud . hudElement . subInventory
.~ CombineInventory
{ _ciSections = IM.fromDistinctAscList [(-1, filtsection), (0, combsection)]
{ _ciSections = updateCombineSections w cfig mempty
, _ciSelection = selpos
, _ciFilter = Nothing
}
-- .~ CombineInventory
-- { _ciSections = IM.fromDistinctAscList [(-1, filtsection), (0, combsection)]
-- , _ciSelection = selpos
-- , _ciFilter = Nothing
-- }
& hud . hudElement . diInvFilter
.~ Nothing
where