This commit is contained in:
2025-09-19 19:56:12 +01:00
parent 2d856ddf9e
commit d4f2cdd3fd
20 changed files with 282 additions and 351 deletions
+15 -46
View File
@@ -1,7 +1,5 @@
{- The menu picture. -}
module Dodge.Render.MenuScreen (
drawMenuScreen,
) where
{-# LANGUAGE LambdaCase #-}
module Dodge.Render.MenuScreen (drawMenuScreen) where
import Control.Lens
import Dodge.Base.Window
@@ -14,32 +12,20 @@ import Dodge.ScreenPos
import Picture
drawMenuScreen :: Config -> Maybe Int -> ScreenLayer -> Picture
drawMenuScreen cfig spos screen = case screen of
OptionScreen{_scTitle = titf, _scSelectionList = slist} ->
drawOptions cfig titf spos slist
InputScreen inputstr help -> drawInputMenu cfig ('>' : inputstr) help
drawMenuScreen cf mi = \case
OptionScreen{_scTitle = s, _scSelectionList = l} -> drawOptions cf s mi l
InputScreen inputstr -> drawInputMenu cf ('>' : inputstr)
drawInputMenu ::
Config ->
-- | Title
String ->
-- | Help Text
String ->
Picture
drawInputMenu cfig title footer =
fold
[ darkenBackground cfig
, drawTitle cfig title
, drawFooterText cfig red footer
]
drawInputMenu :: Config -> String -> Picture
drawInputMenu cf s = darkenBackground cf <> drawTitle cf s
drawOptions :: Config -> String -> Maybe Int -> [SelectionItem a] -> Picture
drawOptions cfig title msel sl =
darkenBackground cfig
<> drawTitle cfig title
<> drawSelectionList menuLDP cfig sl
drawOptions cf title msel sl =
darkenBackground cf
<> drawTitle cf title
<> drawSelectionList menuLDP cf sl
<> translateScreenPos
cfig
cf
(menuLDP ^. ldpPos)
( drawCursorAt
msel
@@ -53,24 +39,7 @@ darkenBackground :: Config -> Picture
darkenBackground = color (withAlpha 0.5 black) . polygon . reverse . screenBox
drawTitle :: Config -> String -> Picture
drawTitle cfig = translate (- hw) (hh -80) . scale 0.4 0.4 . text
drawTitle cf = translate (- hw) (hh -80) . 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 :: Config -> Color -> String -> Picture
drawFooterText cfig col = color col . placeString (- hw + 30) (- hh + 10) 0.1
where
hh = halfHeight cfig
hw = halfWidth cfig
hh = halfHeight cf
hw = halfWidth cf