{-# LANGUAGE LambdaCase #-} module Dodge.Render.MenuScreen (drawMenuScreen) where import Control.Lens import Dodge.Base.Window import Dodge.Data.CardinalPoint import Dodge.Data.ScreenPos import Dodge.Data.SelectionList import Dodge.Data.Universe import Dodge.ListDisplayParams import Dodge.Render.List import Dodge.ScreenPos import Geometry.Polygon import Linear 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.5 0.7) (V2 (-300) (10 * fromIntegral (length s)))) (drawList $ map text s) 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 (BoundCurs [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