40 lines
1.3 KiB
Haskell
40 lines
1.3 KiB
Haskell
{-# LANGUAGE LambdaCase #-}
|
|
module Dodge.Render.MenuScreen (drawMenuScreen) where
|
|
|
|
import Control.Lens
|
|
import Dodge.Base.Window
|
|
import Dodge.Data.CardinalPoint
|
|
import Dodge.Data.SelectionList
|
|
import Dodge.Data.Universe
|
|
import Dodge.ListDisplayParams
|
|
import Dodge.Render.List
|
|
import Dodge.ScreenPos
|
|
import Picture
|
|
|
|
drawMenuScreen :: Maybe Int -> ScreenLayer -> Config -> Picture
|
|
drawMenuScreen mi = \case
|
|
OptionScreen{_scTitle = s, _scSelectionList = l} -> drawOptions s mi l
|
|
InputScreen inputstr -> drawInputMenu ('>' : inputstr)
|
|
|
|
drawInputMenu :: String -> Config -> Picture
|
|
drawInputMenu s cf = darkenBackground cf <> drawTitle cf s
|
|
|
|
drawOptions :: String -> Maybe Int -> [SelectionItem a] -> Config -> Picture
|
|
drawOptions title msel sl cf =
|
|
darkenBackground cf
|
|
<> drawTitle cf title
|
|
<> drawSelectionList menuLDP cf sl
|
|
<> translateScreenPos
|
|
cf
|
|
(menuLDP ^. ldpPos)
|
|
(drawCursorAt msel sl menuLDP 50 (BoundaryCursor [North, South]))
|
|
|
|
darkenBackground :: Config -> Picture
|
|
darkenBackground = color (withAlpha 0.5 black) . polygon . reverse . screenBox
|
|
|
|
drawTitle :: Config -> String -> Picture
|
|
drawTitle cf = translate (- hw) (hh -80) . scale 0.4 0.4 . text
|
|
where
|
|
hh = halfHeight cf
|
|
hw = halfWidth cf
|