Move selection list offset into option screen data structure
This commit is contained in:
@@ -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..]
|
||||
|
||||
Reference in New Issue
Block a user