Move configuration from world to universe

This commit is contained in:
2021-11-28 22:30:47 +00:00
parent 45ba120796
commit 8c5777a1af
29 changed files with 343 additions and 300 deletions
+31 -34
View File
@@ -15,47 +15,43 @@ menuScreen w screen = case screen of
-> drawOptions w (titf w) mos
(WaitScreen sf _) -> drawOptions w (sf w) []
(InputScreen s) -> drawOptions w ('>':s) []
(TerminalScreen t xs ) -> displayStringList (_uvWorld w) $ map snd $ filter (( > t) . fst) xs
(DisplayScreen sd ) -> sd w
(ColumnsScreen title pairs) -> drawTwoColumnsScreen (_uvWorld w) title pairs
(ColumnsScreen title pairs) -> drawTwoColumnsScreen (_config w) (_uvWorld w) title pairs
displayStringList :: World -> [String] -> Picture
displayStringList w ss = pictures
( polygon (screenBox w)
: zipWith f ys ss
)
where
hw = halfWidth w
ys = [0,22..]
f y s = translate (10-hw) y . scale 0.15 0.15 $ text s
--displayStringList :: World -> [String] -> Picture
--displayStringList w ss = pictures
-- ( polygon (screenBox w)
-- : zipWith f ys ss
-- )
-- where
-- hw = halfWidth w
-- ys = [0,22..]
-- f y s = translate (10-hw) y . scale 0.15 0.15 $ text s
drawTwoColumnsScreen
:: World
-> String
-> [(String,String)]
-> Picture
drawTwoColumnsScreen w title lps = pictures
[darkenBackground w
,drawTitle w title
,drawTwoColumns w lps
drawTwoColumnsScreen :: Configuration -> World -> String -> [(String,String)] -> Picture
drawTwoColumnsScreen cfig w title lps = pictures
[darkenBackground cfig
,drawTitle cfig w title
,drawTwoColumns cfig w lps
]
drawTwoColumns :: World -> [(String,String)] -> Picture
drawTwoColumns w lps = pictures $ zipWith f [hh-100,hh-130..] lps
drawTwoColumns :: Configuration -> World -> [(String,String)] -> Picture
drawTwoColumns cfig w lps = pictures $ zipWith f [hh-100,hh-130..] lps
where
f y (s1,s2) = translate (50-hw) y $ sc $ rightPad ln '.' s1 ++ s2
sc = scale 0.15 0.15 . color white . text
hh = halfHeight w
hw = halfWidth w
hh = halfHeight cfig
hw = halfWidth cfig
ln = maximum (map (length . fst) lps) + 3
drawOptions :: Universe
drawOptions
:: Universe
-> String -- ^ Title
-> [MenuOption] -- ^ Options
-> Picture
drawOptions w title ops = pictures $
[darkenBackground (_uvWorld w)
,drawTitle (_uvWorld w) title]
[darkenBackground (_config w)
,drawTitle (_config w) (_uvWorld w) title]
++
zipWith (\ s vpos -> placeString (-hw + 50) vpos 0.2 s) (map (menuOptionToString w) ops') [hh-100,hh-150 ..]
where
@@ -63,18 +59,19 @@ 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 (_uvWorld w)
hw = halfWidth (_uvWorld w)
hh = halfHeight cfig
hw = halfWidth cfig
cfig = _config w
darkenBackground :: World -> Picture
darkenBackground :: Configuration -> Picture
darkenBackground = color (withAlpha 0.5 black) . polygon . screenBox
drawTitle :: World -> String -> Picture
drawTitle w = placeString (-hw + 30) (hh - 50) 0.4
drawTitle :: Configuration -> World -> String -> Picture
drawTitle cfig w = placeString (-hw + 30) (hh - 50) 0.4
where
placeString x y sc t = translate x y $ scale sc sc $ color white $ text t
hh = halfHeight w
hw = halfWidth w
hh = halfHeight cfig
hw = halfWidth cfig
menuOptionToString :: Universe -> MenuOption -> String
menuOptionToString w mo = theKeys ++ _moString mo w