Files
loop/src/Dodge/Render/MenuScreen.hs
T

52 lines
1.7 KiB
Haskell

{-# LANGUAGE LambdaCase #-}
module Dodge.Render.MenuScreen (drawMenuScreen) where
import Geometry.Polygon
import Linear
import Dodge.Data.ScreenPos
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)
LoadingScreen ss t -> drawLoadingScreen ss t
drawLoadingScreen :: [String] -> BlockStatus -> Config -> Picture
drawLoadingScreen s _ cfig =
polygon (rectWH (fromIntegral (cfig ^.windowX)) (fromIntegral (cfig ^. windowY))) <>
translateScreenPos cfig
(ScreenPos (V2 0 0.2) (V2 (-300) (10 * fromIntegral (length s))))
(drawList $ map text s -- <> [text $ show t])
)
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