Remove SelectionSections

This commit is contained in:
2024-10-25 22:19:04 +01:00
parent a20fc48eaa
commit d93c548d3c
15 changed files with 202 additions and 195 deletions
+21 -16
View File
@@ -36,10 +36,13 @@ updateCombinePositioning u =
u & uvWorld . hud . hudElement . subInventory . ciSections
%~ updateCombineSections (_uvWorld u) (_uvConfig u)
updateCombineSections :: World -> Configuration -> SelectionSections CombinableItem -> SelectionSections CombinableItem
updateCombineSections ::
World ->
Configuration ->
IM.IntMap (SelectionSection CombinableItem) ->
IM.IntMap (SelectionSection CombinableItem)
updateCombineSections w cfig =
sssSections
%~ updateSectionsPositioning
updateSectionsPositioning
mselpos
availablelines
[(0, showncombs), (-1, filtinv)]
@@ -49,11 +52,12 @@ updateCombineSections w cfig =
allcombs = IM.fromDistinctAscList $ zip [0 ..] $ combineList w
filtcombs = fromMaybe allcombs $ do
str <- mstr
invitms <- w ^? hud . hudElement . diSections . sssSections . ix 0 . ssItems
invitms <- w ^? hud . hudElement . diSections . ix 0 . ssItems
return $ IM.filter (flip (andOrRegex $ regexCombs invitms) str) allcombs
showncombs
| null filtcombs = IM.singleton 0
$ SelectionInfo ["No possible combinations"] 1 False white 0
| null filtcombs =
IM.singleton 0 $
SelectionInfo ["No possible combinations"] 1 False white 0
| otherwise = filtcombs
filtinv = fromMaybe mempty $ do
str <- mstr
@@ -90,14 +94,14 @@ updateInventoryPositioning u =
updateDisplaySections ::
World ->
Configuration ->
SelectionSections () ->
SelectionSections ()
IM.IntMap (SelectionSection ()) ->
IM.IntMap (SelectionSection ())
updateDisplaySections w cfig sss =
sss & sssSections
%~ updateSectionsPositioning
updateSectionsPositioning
mselpos
availablelines
addorder
sss
where
mselpos = w ^? hud . hudElement . diSelection . _Just
addorder = case mselpos of
@@ -246,17 +250,18 @@ listSelectionColorPicture = foldMap f
g str = (_siColor si, translate indent 0 . color (_siColor si) $ text str)
enterCombineInv :: Configuration -> World -> World
enterCombineInv cfig w = w & hud . hudElement . subInventory .~ CombineInventory sss selpos
(IM.singleton (-1) Nothing)
enterCombineInv cfig w =
w & hud . hudElement . subInventory
.~ CombineInventory
sss
selpos
(IM.singleton (-1) Nothing)
where
cm' = IM.fromDistinctAscList . 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)]
}
sss = IM.fromDistinctAscList [(-1, filtsection), (0, combsection)]
selpos
| null cm' = Nothing
| otherwise = Just (0, 0)