This commit is contained in:
2025-01-04 15:11:37 +00:00
parent 649fc35e32
commit f9eca28b80
+7 -5
View File
@@ -7,6 +7,7 @@ module Dodge.DisplayInventory (
toggleCombineInv, toggleCombineInv,
) where ) where
import Data.IntSet (IntSet)
import Control.Applicative import Control.Applicative
import Control.Lens import Control.Lens
import Control.Monad import Control.Monad
@@ -48,7 +49,7 @@ updateCombineSections w cfig =
updateSectionsPositioning updateSectionsPositioning
(const 5) (const 5)
(const 0) (const 0)
(fmap (\(x, y, _) -> (x, y)) $ w ^? hud . hudElement . subInventory . ciSelection . _Just) (w ^? hud . hudElement . subInventory . ciSelection . _Just)
(getAvailableListLines secondColumnParams cfig) (getAvailableListLines secondColumnParams cfig)
[(0, sclose), (-1, sfclose)] [(0, sclose), (-1, sfclose)]
where where
@@ -138,7 +139,7 @@ updateDisplaySections w cfig =
, interfaces , interfaces
] ]
where where
mselpos = fmap (\(x, y, _) -> (x, y)) $ w ^? hud . hudElement . diSelection . _Just mselpos = w ^? hud . hudElement . diSelection . _Just
invfiltcurs = mselpos ^? _Just . _1 == Just (-1) invfiltcurs = mselpos ^? _Just . _1 == Just (-1)
(sfinv, sinv) = (sfinv, sinv) =
filterSectionsPair invfiltcurs plainRegex invitems "INVENTORY" $ filterSectionsPair invfiltcurs plainRegex invitems "INVENTORY" $
@@ -265,7 +266,7 @@ doSectionSize extraavailable mintaken is sss done = fromMaybe done $ do
updateSectionsPositioning :: updateSectionsPositioning ::
(Int -> Int) -> -- for determining each sections minimum size (Int -> Int) -> -- for determining each sections minimum size
(Int -> Int) -> -- for determining each sections indent (Int -> Int) -> -- for determining each sections indent
Maybe (Int, Int) -> Maybe (Int, Int, IntSet) ->
Int -> Int ->
[(Int, IM.IntMap (SelectionItem a))] -> [(Int, IM.IntMap (SelectionItem a))] ->
IM.IntMap (SelectionSection a) -> IM.IntMap (SelectionSection a) ->
@@ -275,13 +276,14 @@ updateSectionsPositioning f h mselpos allavailablelines lsss sss =
where where
offsets = fmap _ssOffset sss offsets = fmap _ssOffset sss
m k = do m k = do
(k', i) <- mselpos (k', i, _) <- mselpos
guard $ k == k' guard $ k == k'
return i return i
ls = IM.fromList lsss ls = IM.fromList lsss
-- defaults non-existing offsets to 0 -- defaults non-existing offsets to 0
g = merge (mapMissing (const ($ 0))) dropMissing (zipWithMatched (const ($))) g = merge (mapMissing (const ($ 0))) dropMissing (zipWithMatched (const ($)))
lk = maybe [] ((: []) . fst) mselpos --lk = maybe [] ((: []) . fst) mselpos
lk = mselpos ^.. _Just . _1
ssizes = ssizes =
sectionsSizes sectionsSizes
allavailablelines allavailablelines