From 7175a96249010b8f3dced36b13a849bcb4a234a1 Mon Sep 17 00:00:00 2001 From: justin Date: Sun, 5 Jan 2025 17:40:50 +0000 Subject: [PATCH] Simplify inventory display --- src/Dodge/DisplayInventory.hs | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/Dodge/DisplayInventory.hs b/src/Dodge/DisplayInventory.hs index 07fce4544..041f5a1b6 100644 --- a/src/Dodge/DisplayInventory.hs +++ b/src/Dodge/DisplayInventory.hs @@ -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)