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