Cleanup console input slightly

This commit is contained in:
2022-03-20 19:41:40 +00:00
parent ff93d1d041
commit 988a0de578
6 changed files with 39 additions and 41 deletions
+11 -6
View File
@@ -15,7 +15,7 @@ menuScreen w screen = case screen of
(WaitScreen sf _) -> drawOptions w (sf w) [] ""
(InputScreen inputstr help) -> drawOptions w inputstr [] help
(DisplayScreen sd ) -> sd w
(ColumnsScreen title pairs) -> drawTwoColumnsScreen (_config w) title pairs
(ColumnsScreen titf pairs) -> drawTwoColumnsScreen (_config w) (titf w) pairs
--displayStringList :: World -> [String] -> Picture
--displayStringList w ss = pictures
@@ -37,8 +37,7 @@ drawTwoColumnsScreen cfig title lps = pictures
drawTwoColumns :: Configuration -> [(String,String)] -> Picture
drawTwoColumns cfig 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
f y (s1,s2) = placeString (50-hw) y 0.15 $ rightPad ln '.' s1 ++ s2
hh = halfHeight cfig
hw = halfWidth cfig
ln = maximum (map (length . fst) lps) + 3
@@ -61,7 +60,6 @@ drawOptions u title ops footer = pictures $
ops' = filter notInvisible ops
notInvisible InvisibleToggle {} = False
notInvisible _ = True
placeString x y sc t = translate x y $ scale sc sc $ color white $ text t
hh = halfHeight cfig
hw = halfWidth cfig
cfig = _config u
@@ -72,12 +70,19 @@ darkenBackground = color (withAlpha 0.5 black) . polygon . screenBox
drawTitle :: Configuration -> String -> Picture
drawTitle cfig = 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 cfig
hw = halfWidth cfig
placeString
:: Float -- | x distance from center
-> Float -- | y distance from center
-> Float -- | scale
-> String
-> Picture
placeString x y sc = color white . translate x y . scale sc sc . text
drawFooterText :: Configuration -> Color -> String -> Picture
drawFooterText cfig col = translate (-hw + 30) (-hh+10) . scale 0.1 0.1 . color col . text
drawFooterText cfig col = color col . placeString (-hw + 30) (-hh+10) 0.1
where
hh = halfHeight cfig
hw = halfWidth cfig