Assorted changes, cleanup menu selection text
This commit is contained in:
@@ -54,9 +54,10 @@ drawOptions u title ops footer = pictures $
|
||||
, drawFooterText cfig red footer
|
||||
] ++
|
||||
zipWith (\s vpos -> placeString (-hw + 50) vpos 0.2 s)
|
||||
(map (menuOptionToString u) ops')
|
||||
(map (menuOptionToString u maxOptionLength) ops')
|
||||
[hh-100,hh-150 ..]
|
||||
where
|
||||
maxOptionLength = 3 + maximum (0 : map (optionValueOffset u) ops')
|
||||
ops' = filter notInvisible ops
|
||||
notInvisible InvisibleToggle {} = False
|
||||
notInvisible _ = True
|
||||
@@ -64,6 +65,11 @@ drawOptions u title ops footer = pictures $
|
||||
hw = halfWidth cfig
|
||||
cfig = _config u
|
||||
|
||||
optionValueOffset :: Universe -> MenuOption -> Int
|
||||
optionValueOffset u mo = case _moString mo u of
|
||||
Left _ -> 0
|
||||
Right (s,_) -> length s
|
||||
|
||||
darkenBackground :: Configuration -> Picture
|
||||
darkenBackground = color (withAlpha 0.5 black) . polygon . screenBox
|
||||
|
||||
@@ -87,9 +93,12 @@ drawFooterText cfig col = color col . placeString (-hw + 30) (-hh+10) 0.1
|
||||
hh = halfHeight cfig
|
||||
hw = halfWidth cfig
|
||||
|
||||
menuOptionToString :: Universe -> MenuOption -> String
|
||||
menuOptionToString w mo = theKeys ++ _moString mo w
|
||||
menuOptionToString :: Universe -> Int -> MenuOption -> String
|
||||
menuOptionToString w padAmount mo = theKeys ++ optionText
|
||||
where
|
||||
optionText = case _moString mo w of
|
||||
Left s -> s
|
||||
Right (s,t) -> rightPad padAmount '.' s ++ t
|
||||
theKeys = case mo of
|
||||
Toggle {_moKey = k} -> stc k : ":"
|
||||
Toggle2 {_moKey1 = k1, _moKey2 = k2} -> stc k1 : '/' : stc k2 : ":"
|
||||
|
||||
Reference in New Issue
Block a user