Files
loop/src/Dodge/Render/MenuScreen.hs
T
2022-12-28 01:12:10 +00:00

74 lines
1.9 KiB
Haskell

{- The menu picture. -}
module Dodge.Render.MenuScreen (
drawMenuScreen,
) where
import Dodge.Base.WinScale
import Dodge.Data.SelectionList
import Dodge.Render.List
import qualified Data.Text as T
import Dodge.Base.Window
import Dodge.Data.Universe
import Picture
drawMenuScreen :: Configuration -> ScreenLayer -> Picture
drawMenuScreen cfig screen = case screen of
OptionScreen{_scTitle = titf, _scSelectionList = selpos, _scListDisplayParams = ldps} ->
drawOptions ldps cfig titf selpos
InputScreen inputstr help -> drawInputMenu cfig ('>' : T.unpack inputstr) help
drawInputMenu ::
Configuration ->
-- | Title
String ->
-- | Help Text
String ->
Picture
drawInputMenu cfig title footer =
pictures
[ darkenBackground cfig
, drawTitle cfig title
, drawFooterText cfig red footer
]
drawOptions ::
ListDisplayParams ->
Configuration ->
-- | Title
String ->
-- | Select position
SelectionList a ->
Picture
drawOptions ldps cfig title sl =
pictures
[ darkenBackground cfig
, drawTitle cfig title
, drawSelectionList ldps cfig sl
]
darkenBackground :: Configuration -> Picture
darkenBackground cfig = winScale cfig . color (withAlpha 0.5 black) . polygon . reverse . screenBox $ cfig
drawTitle :: Configuration -> String -> Picture
drawTitle cfig = winScale cfig . translate (30 - hw) (hh-50) . scale 0.4 0.4 . text
where
hh = halfHeight cfig
hw = halfWidth cfig
placeString ::
-- | x distance from center
Float ->
-- | y distance from center
Float ->
-- | scale
Float ->
String ->
Picture
placeString x y sc = color white . translate x y . scale sc sc . text
drawFooterText :: Configuration -> Color -> String -> Picture
drawFooterText cfig col = color col . placeString (- hw + 30) (- hh + 10) 0.1
where
hh = halfHeight cfig
hw = halfWidth cfig