Assorted changes, cleanup menu selection text

This commit is contained in:
2022-04-25 23:27:39 +01:00
parent 67e6c4a5bd
commit fa8d8b5899
22 changed files with 217 additions and 108 deletions
+12 -3
View File
@@ -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 : ":"
+22 -4
View File
@@ -1,6 +1,7 @@
module Dodge.Render.ShapePicture
( worldSPic
) where
import Dodge.ShortShow
import Dodge.Config.Data
import Dodge.Render.InfoBox
import Dodge.Debug.Picture
@@ -51,11 +52,13 @@ extraPics cfig w = pictures (_decorations w)
<> concatMapPic (dbArg _bmDraw) (_electronBeams $ _beams w)
<> concatMapPic (dbArg _lsPict) (_lightSources w)
<> testPic w
<> _debugPicture w
<> concatMapPic clDraw (_clouds w )
<> concatMapPic ppDraw (_pressPlates w )
<> soundPics cfig w
<> viewBoundaries cfig w
<> viewClipBounds cfig w
<> drawMousePosition cfig w
<> drawPathing cfig w
<> drawCrInfo cfig w
@@ -95,6 +98,19 @@ soundPic cfig w s = fixedSizePicClampArrow 50 50 thePic p cfig w
theScale = 0.15 * f (_soundVolume s * 0.0001)
f x = 1 - 0.5 * (1 - x)
drawMousePosition :: Configuration -> World -> Picture
drawMousePosition cfig w
| not $ _debug_mouse_position cfig = mempty
| otherwise
= setLayer FixedCoordLayer . winScale cfig
. uncurryV translate p
. scale 0.1 0.1
. text
$ shortPoint2 mwp
where
p = worldPosToScreen w mwp
mwp = mouseWorldPos w
drawPathing :: Configuration -> World -> Picture
drawPathing cfig w
| _debug_pathing cfig
@@ -111,9 +127,11 @@ crDisplayInfo cfig w cr
| _crID cr == 0 = Nothing
| crOnScreen = Just (_crPos cr, catMaybes
-- [fmap show $ ap ^? crGoal
-- ,fmap show $ ap ^? crStrategy
[fmap show $ cr ^? crPos
,fmap show $ cr ^? crOldPos
[fmap show $ cr ^? crHP
,fmap show $ ap ^? crStrategy
,fmap show $ cr ^? crPos
,fmap show $ cr ^? crPerception . crAwakeLevel
-- ,fmap show $ cr ^? crOldPos
,fmap show $ ap ^? crAction
,fmap show $ ap ^? crImpulse
]
@@ -126,7 +144,7 @@ crDisplayInfo cfig w cr
drawCrInfo :: Configuration -> World -> Picture
drawCrInfo cfig w
| _debug_cr_status cfig = setLayer FixedCoordLayer
$ renderInfoListsAt (2*hw - 200) 0 cfig w
$ renderInfoListsAt (2*hw - 400) 0 cfig w
$ mapMaybe (crDisplayInfo cfig w) $ IM.elems $ _creatures w
| otherwise = mempty
where