Move menu layers outside of world

This commit is contained in:
2021-11-28 14:26:15 +00:00
parent 574f195b21
commit 462100703c
13 changed files with 132 additions and 124 deletions
+9 -13
View File
@@ -9,18 +9,15 @@ import Picture
import Dodge.Menu
import Padding
menuScreen
:: World
-> ScreenLayer
-> Picture
menuScreen :: Universe -> ScreenLayer -> Picture
menuScreen w screen = case screen of
OptionScreen {_scTitle = titf, _scOptions = mos}
-> drawOptions w (titf w) mos
(WaitScreen sf _) -> drawOptions w (sf w) []
(InputScreen s) -> drawOptions w ('>':s) []
(TerminalScreen t xs ) -> displayStringList w $ map snd $ filter (( > t) . fst) xs
(TerminalScreen t xs ) -> displayStringList (_uvWorld w) $ map snd $ filter (( > t) . fst) xs
(DisplayScreen sd ) -> sd w
(ColumnsScreen title pairs) -> drawTwoColumnsScreen w title pairs
(ColumnsScreen title pairs) -> drawTwoColumnsScreen (_uvWorld w) title pairs
displayStringList :: World -> [String] -> Picture
displayStringList w ss = pictures
@@ -52,14 +49,13 @@ drawTwoColumns w lps = pictures $ zipWith f [hh-100,hh-130..] lps
hw = halfWidth w
ln = maximum (map (length . fst) lps) + 3
drawOptions
:: World
drawOptions :: Universe
-> String -- ^ Title
-> [MenuOption] -- ^ Options
-> Picture
drawOptions w title ops = pictures $
[darkenBackground w
,drawTitle w title]
[darkenBackground (_uvWorld w)
,drawTitle (_uvWorld w) title]
++
zipWith (\ s vpos -> placeString (-hw + 50) vpos 0.2 s) (map (menuOptionToString w) ops') [hh-100,hh-150 ..]
where
@@ -67,8 +63,8 @@ drawOptions w title ops = pictures $
notInvisible InvisibleToggle {} = False
notInvisible _ = True
placeString x y sc t = translate x y $ scale sc sc $ color white $ text t
hh = halfHeight w
hw = halfWidth w
hh = halfHeight (_uvWorld w)
hw = halfWidth (_uvWorld w)
darkenBackground :: World -> Picture
darkenBackground = color (withAlpha 0.5 black) . polygon . screenBox
@@ -80,7 +76,7 @@ drawTitle w = placeString (-hw + 30) (hh - 50) 0.4
hh = halfHeight w
hw = halfWidth w
menuOptionToString :: World -> MenuOption -> String
menuOptionToString :: Universe -> MenuOption -> String
menuOptionToString w mo = theKeys ++ _moString mo w
where
theKeys :: String