|
|
|
@@ -1,6 +1,7 @@
|
|
|
|
|
-- {-# OPTIONS_GHC -fno-full-laziness #-}
|
|
|
|
|
--{-# LANGUAGE TupleSections #-}
|
|
|
|
|
{-# LANGUAGE LambdaCase #-}
|
|
|
|
|
--{-# LANGUAGE BangPatterns #-}
|
|
|
|
|
|
|
|
|
|
module Dodge.DisplayInventory (
|
|
|
|
|
updateInventoryPositioning,
|
|
|
|
@@ -8,6 +9,7 @@ module Dodge.DisplayInventory (
|
|
|
|
|
toggleCombineInv,
|
|
|
|
|
) where
|
|
|
|
|
|
|
|
|
|
--import StrictHelp
|
|
|
|
|
import qualified Data.Strict.Tuple as STup
|
|
|
|
|
import Control.Applicative
|
|
|
|
|
import Control.Lens
|
|
|
|
@@ -272,6 +274,7 @@ updateSectionsPositioning f h mselpos allavailablelines lsss sss =
|
|
|
|
|
IM.intersectionWithKey (\k -> updateSection (h k) (m k)) ls ssizes `g` offsets
|
|
|
|
|
where
|
|
|
|
|
offsets = fmap _ssOffset sss
|
|
|
|
|
--offsets = mempty
|
|
|
|
|
m k = do
|
|
|
|
|
(k', i, _) <- mselpos
|
|
|
|
|
guard $ k == k'
|
|
|
|
@@ -296,23 +299,26 @@ updateSection indent mcsel sis availablelines oldoffset =
|
|
|
|
|
, _ssShownItems =
|
|
|
|
|
tweakfirst . tweaklast . map (^. _2) $
|
|
|
|
|
take availablelines shownstrings
|
|
|
|
|
, _ssShownLength = length shownitems
|
|
|
|
|
, _ssIndent = indent
|
|
|
|
|
}
|
|
|
|
|
where
|
|
|
|
|
oldoffsetbounded = max 0 . min oldoffset $ length allstrings - availablelines
|
|
|
|
|
shownitems =
|
|
|
|
|
tweakfirst . tweaklast . map (^. _2) $
|
|
|
|
|
take availablelines shownstrings
|
|
|
|
|
oldoffsetbounded = max 0 . min oldoffset $ aslength - availablelines
|
|
|
|
|
offset = fromMaybe oldoffsetbounded $ do
|
|
|
|
|
csel <- mcsel
|
|
|
|
|
maxcsel <- fst <$> IM.lookupMax sis
|
|
|
|
|
xselsize <- fmap length $ sis ^? ix csel . siPictures
|
|
|
|
|
return $ case sum $ fmap (length . _siPictures) . fst . IM.split csel $ sis of
|
|
|
|
|
pos | pos == 0 || length allstrings <= availablelines -> 0
|
|
|
|
|
pos | pos == 0 || aslength <= availablelines -> 0
|
|
|
|
|
pos | pos - 1 < oldoffset -> pos - 1
|
|
|
|
|
pos | maxcsel == csel -> pos - availablelines + xselsize
|
|
|
|
|
pos | pos + 1 + xselsize - availablelines > oldoffset ->
|
|
|
|
|
pos - availablelines + 1 + xselsize
|
|
|
|
|
-- _ | length allstrings - oldoffset < availablelines ->
|
|
|
|
|
_ | length allstrings - availablelines < oldoffset ->
|
|
|
|
|
length allstrings - availablelines
|
|
|
|
|
_ | aslength - availablelines < oldoffset ->
|
|
|
|
|
aslength - availablelines
|
|
|
|
|
_ -> oldoffsetbounded
|
|
|
|
|
tweakfirst
|
|
|
|
|
| offset > 0 = ix 0 .~ color moreupcolor (text (replicate 15 (toEnum 30)))
|
|
|
|
@@ -324,12 +330,11 @@ updateSection indent mcsel sis availablelines oldoffset =
|
|
|
|
|
.~ color moredowncolor (text . replicate 15 $ toEnum 31)
|
|
|
|
|
| otherwise = id
|
|
|
|
|
moredowncolor = fromMaybe white $ allstrings ^? ix (offset + availablelines - 1) . _1
|
|
|
|
|
allstrings = foldMap listSelectionColorPicture sis
|
|
|
|
|
(allstrings,Sum aslength) = foldMap listSelectionColorPicture sis
|
|
|
|
|
shownstrings = drop offset allstrings
|
|
|
|
|
|
|
|
|
|
listSelectionColorPicture :: SelectionItem a -> [STup.Pair Color Picture]
|
|
|
|
|
--listSelectionColorPicture si = []
|
|
|
|
|
listSelectionColorPicture si = g <$> _siPictures si
|
|
|
|
|
listSelectionColorPicture :: SelectionItem a -> ([STup.Pair Color Picture], Sum Int)
|
|
|
|
|
listSelectionColorPicture si = (g <$> _siPictures si, Sum $ _siHeight si)
|
|
|
|
|
where
|
|
|
|
|
g str =
|
|
|
|
|
_siColor si STup.:!:
|
|
|
|
@@ -370,6 +375,7 @@ enterCombineInv cfig w =
|
|
|
|
|
{ _ssItems = mempty
|
|
|
|
|
, _ssOffset = 0
|
|
|
|
|
, _ssShownItems = mempty
|
|
|
|
|
, _ssShownLength = 0
|
|
|
|
|
, _ssIndent = 0
|
|
|
|
|
}
|
|
|
|
|
combsection =
|
|
|
|
|