Simplify inventory display
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
-- {-# OPTIONS_GHC -fno-full-laziness #-}
|
-- {-# OPTIONS_GHC -fno-full-laziness #-}
|
||||||
--{-# LANGUAGE TupleSections #-}
|
--{-# LANGUAGE TupleSections #-}
|
||||||
{-# LANGUAGE LambdaCase #-}
|
{-# LANGUAGE LambdaCase #-}
|
||||||
{-# LANGUAGE BangPatterns #-}
|
--{-# LANGUAGE BangPatterns #-}
|
||||||
|
|
||||||
module Dodge.DisplayInventory (
|
module Dodge.DisplayInventory (
|
||||||
updateInventoryPositioning,
|
updateInventoryPositioning,
|
||||||
@@ -9,9 +9,9 @@ module Dodge.DisplayInventory (
|
|||||||
toggleCombineInv,
|
toggleCombineInv,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import StrictHelp
|
--import StrictHelp
|
||||||
import Dodge.Item.Display
|
import Dodge.Item.Display
|
||||||
import qualified Data.Strict.Tuple as STup
|
--import qualified Data.Strict.Tuple as STup
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
@@ -294,8 +294,8 @@ updateSection indent mcsel sis availablelines oldoffset =
|
|||||||
}
|
}
|
||||||
where
|
where
|
||||||
shownitems =
|
shownitems =
|
||||||
tweakfirst . tweaklast . map (^. _2) $
|
-- tweakfirst . tweaklast . map (^. _2) $ take availablelines shownstrings
|
||||||
take availablelines shownstrings
|
tweakfirst . tweaklast $ take availablelines shownstrings
|
||||||
oldoffsetbounded = max 0 . min oldoffset $ aslength - availablelines
|
oldoffsetbounded = max 0 . min oldoffset $ aslength - availablelines
|
||||||
offset = fromMaybe oldoffsetbounded $ do
|
offset = fromMaybe oldoffsetbounded $ do
|
||||||
csel <- mcsel
|
csel <- mcsel
|
||||||
@@ -312,25 +312,33 @@ updateSection indent mcsel sis availablelines oldoffset =
|
|||||||
aslength - availablelines
|
aslength - availablelines
|
||||||
_ -> oldoffsetbounded
|
_ -> oldoffsetbounded
|
||||||
tweakfirst
|
tweakfirst
|
||||||
| offset > 0 = ix 0 .~ color moreupcolor (text (replicate 15 (toEnum 30)))
|
-- | offset > 0 = ix 0 .~ color moreupcolor (text (replicate 15 (toEnum 30)))
|
||||||
|
| offset > 0 = ix 0 .~ color white (text (replicate 15 (toEnum 30)))
|
||||||
| otherwise = id
|
| otherwise = id
|
||||||
moreupcolor = fromMaybe white $ allstrings ^? ix offset . _1
|
-- moreupcolor = fromMaybe white $ allstrings ^? ix offset . _1
|
||||||
tweaklast
|
tweaklast
|
||||||
| length shownstrings > availablelines =
|
| length shownstrings > availablelines =
|
||||||
ix (availablelines - 1)
|
ix (availablelines - 1)
|
||||||
.~ color moredowncolor (text . replicate 15 $ toEnum 31)
|
.~ color white (text . replicate 15 $ toEnum 31)
|
||||||
|
-- .~ color moredowncolor (text . replicate 15 $ toEnum 31)
|
||||||
| otherwise = id
|
| otherwise = id
|
||||||
moredowncolor = fromMaybe white $ allstrings ^? ix (offset + availablelines - 1) . _1
|
-- moredowncolor = fromMaybe white $ allstrings ^? ix (offset + availablelines - 1) . _1
|
||||||
(allstrings,Sum aslength) = foldMap listSelectionColorPicture sis
|
(allstrings,Sum aslength) = foldMap listSelectionColorPicture sis
|
||||||
shownstrings = drop offset allstrings
|
shownstrings = drop offset allstrings
|
||||||
|
|
||||||
listSelectionColorPicture :: SelectionItem a -> ([STup.Pair Color Picture], Sum Int)
|
listSelectionColorPicture :: SelectionItem a -> ([Picture], Sum Int)
|
||||||
listSelectionColorPicture si = (g <$> _siPictures si, Sum $ _siHeight si)
|
listSelectionColorPicture si = (g <$> _siPictures si, Sum $ _siHeight si)
|
||||||
where
|
where
|
||||||
g !str =
|
g = translate lindent 0 . color (_siColor si) . text
|
||||||
_siColor si STup.:!:
|
|
||||||
translate lindent 0 (color (_siColor si) $ text str)
|
|
||||||
lindent = 100 * fromIntegral (_siOffX si)
|
lindent = 100 * fromIntegral (_siOffX si)
|
||||||
|
--listSelectionColorPicture :: SelectionItem a -> ([(Color,Picture)], Sum Int)
|
||||||
|
--listSelectionColorPicture si = (g <$> _siPictures si, Sum $ _siHeight si)
|
||||||
|
-- where
|
||||||
|
-- g str = (
|
||||||
|
-- _siColor si
|
||||||
|
-- , translate lindent 0 (color (_siColor si) $ text str)
|
||||||
|
-- )
|
||||||
|
-- lindent = 100 * fromIntegral (_siOffX si)
|
||||||
|
|
||||||
regexList :: String -> [String] -> Bool
|
regexList :: String -> [String] -> Bool
|
||||||
regexList x = any (List.isInfixOf x)
|
regexList x = any (List.isInfixOf x)
|
||||||
|
|||||||
Reference in New Issue
Block a user