Add strict tuples

This commit is contained in:
2025-01-04 15:56:40 +00:00
parent b5ffeae538
commit 31a74b9ac0
+8 -14
View File
@@ -8,6 +8,7 @@ module Dodge.DisplayInventory (
toggleCombineInv,
) where
import qualified Data.Strict.Tuple as STup
import Control.Applicative
import Control.Lens
import Control.Monad
@@ -90,10 +91,9 @@ updateInventoryPositioning u =
%~ checkInventorySelectionExists
checkInventorySelectionExists :: World -> World
checkInventorySelectionExists w =
case w ^? hud . hudElement . diSections . ix i . ssItems . ix j of
Nothing -> scrollAugNextInSection w
_ -> w
checkInventorySelectionExists w
| isJust $ w ^? hud . hudElement . diSections . ix i . ssItems . ix j = w
| otherwise = scrollAugNextInSection w
where
(i, j, _) = fromMaybe (1, -1, mempty) $ w ^? hud . hudElement . diSelection . _Just
@@ -279,14 +279,8 @@ updateSectionsPositioning f h mselpos allavailablelines lsss sss =
ls = IM.fromList lsss
-- defaults non-existing offsets to 0
g = merge (mapMissing (const ($ 0))) dropMissing (zipWithMatched (const ($)))
--lk = maybe [] ((: []) . fst) mselpos
lk = mselpos ^.. _Just . _1
ssizes =
sectionsSizes
allavailablelines
f
lk
$ sectionsDesiredLines ls
ssizes = sectionsSizes allavailablelines f lk $ sectionsDesiredLines ls
updateSection ::
Int ->
@@ -300,7 +294,7 @@ updateSection indent mcsel sis availablelines oldoffset =
{ _ssItems = sis
, _ssOffset = offset
, _ssShownItems =
tweakfirst . tweaklast . map snd $
tweakfirst . tweaklast . map (^. _2) $
take availablelines shownstrings
, _ssIndent = indent
}
@@ -335,10 +329,10 @@ updateSection indent mcsel sis availablelines oldoffset =
allstrings = foldMap listSelectionColorPicture sis
shownstrings = drop offset allstrings
listSelectionColorPicture :: SelectionItem a -> [(Color, Picture)]
listSelectionColorPicture :: SelectionItem a -> [STup.Pair Color Picture]
listSelectionColorPicture si = g <$> _siPictures si
where
g str = (_siColor si, translate lindent 0 . color (_siColor si) $ text str)
g str = _siColor si STup.:!: translate lindent 0 (color (_siColor si) $ text str)
lindent = 100 * fromIntegral (_siOffX si)
regexList :: String -> [String] -> Bool