Add options page scrolling

This commit is contained in:
2022-06-25 09:28:45 +01:00
parent 3c2df2542a
commit dd0afc6166
12 changed files with 74 additions and 44 deletions
+19 -7
View File
@@ -3,19 +3,21 @@ module Dodge.Render.MenuScreen
( menuScreen
) where
import Dodge.Data
import Dodge.WindowLayout
import Dodge.Base.Window
import Picture
import Dodge.Menu
import Padding
import Geometry
import qualified Data.Text as T
menuScreen :: Universe -> ScreenLayer -> Picture
menuScreen w screen = case screen of
OptionScreen {_scTitle = titf, _scOptions = mos}
-> drawOptions w (titf w) mos "Use keys to navigate the menu"
(WaitScreen sf _) -> drawOptions w (sf w) [] ""
(InputScreen inputstr help) -> drawOptions w ('>':T.unpack inputstr) [] help
OptionScreen {_scTitle = titf, _scOptions = mos, _scOptionsOffset = off}
-> drawOptions w (titf w) mos off "Use keys to navigate the menu"
(WaitScreen sf _) -> drawOptions w (sf w) [] 0 ""
(InputScreen inputstr help) -> drawOptions w ('>':T.unpack inputstr) [] 0 help
(DisplayScreen sd ) -> sd w
(ColumnsScreen titf pairs) -> drawTwoColumnsScreen (_config w) (titf w) pairs
@@ -48,19 +50,29 @@ drawOptions
:: Universe
-> String -- ^ Title
-> [MenuOption] -- ^ Options
-> Int -- ^ Options offset
-> String -- ^ Help Text
-> Picture
drawOptions u title ops footer = pictures $
drawOptions u title ops off footer = pictures $
[ darkenBackground cfig
, drawTitle cfig title
, drawFooterText cfig red footer
] ++
zipWith (\s vpos -> placeString (-hw + 50) vpos 0.2 s)
(map (menuOptionToString u maxOptionLength) ops')
(ops'')
[hh-100,hh-150 ..]
-- ++ [color yellow $ concat [line [V2 (negate hw) (hh-y), V2 hw (hh-y)] |
-- y <- map (+75) [0,50..hh*2]]
-- ]
where
maxOptionLength = 3 + maximum (0 : map (optionValueOffset u) ops')
ops' = filter notInvisible ops
ops' = case availableMenuLines cfig of
x | x < length ops -> take (availableMenuLines cfig) (drop off visibleops)
_ -> visibleops
ops'' = case availableMenuLines cfig of
x | x < length ops -> map (menuOptionToString u maxOptionLength) ops' ++ ["SPACE: MORE OPTIONS"]
_ -> map (menuOptionToString u maxOptionLength) ops'
visibleops = filter notInvisible ops
notInvisible InvisibleToggle {} = False
notInvisible _ = True
hh = halfHeight cfig