Move selection list offset into option screen data structure

This commit is contained in:
2022-12-22 10:27:01 +00:00
parent 91d65094c9
commit a8fa1e9949
7 changed files with 14 additions and 11 deletions
+9 -4
View File
@@ -1,11 +1,17 @@
module Dodge.SelectionList where
--import Color
import Dodge.Data.SelectionList
import Dodge.Data.Universe
import LensHelp
import Data.Maybe
setShownSelectionItems :: SelectionList -> SelectionList
setShownSelectionItems sl = case sl ^? slSizeRestriction of
setShownSelectionItems :: ScreenLayer -> ScreenLayer
setShownSelectionItems sl = fromMaybe sl $ do
offset <- sl ^? scOffset
return $ sl & scSelectionList %~ setShownSelectionItems' offset
setShownSelectionItems' :: Int -> SelectionList -> SelectionList
setShownSelectionItems' offset sl = case sl ^? slSizeRestriction of
Just (SelectionSizeRestriction maxlines _ botit _)
| length allitems > maxlines ->
sl & slShownItems .~ take (maxlines - 2) (drop offset allitems) -- ++ repeat dummyitem))
@@ -13,5 +19,4 @@ setShownSelectionItems sl = case sl ^? slSizeRestriction of
_ -> sl & slShownItems .~ allitems
where
-- dummyitem = (SelectionItem [] 1 False 0 white 0, DummySelectionItem)
offset = sl ^. slOffset
allitems = zipWith (\x y -> (x,ListedSelectionItem y)) (sl ^. slItems) [0..]