This commit is contained in:
2025-09-19 20:39:17 +01:00
parent d4f2cdd3fd
commit b837e6a798
9 changed files with 268 additions and 345 deletions
+9 -15
View File
@@ -11,29 +11,23 @@ import Dodge.Render.List
import Dodge.ScreenPos
import Picture
drawMenuScreen :: Config -> Maybe Int -> ScreenLayer -> Picture
drawMenuScreen cf mi = \case
OptionScreen{_scTitle = s, _scSelectionList = l} -> drawOptions cf s mi l
InputScreen inputstr -> drawInputMenu cf ('>' : inputstr)
drawMenuScreen :: Maybe Int -> ScreenLayer -> Config -> Picture
drawMenuScreen mi = \case
OptionScreen{_scTitle = s, _scSelectionList = l} -> drawOptions s mi l
InputScreen inputstr -> drawInputMenu ('>' : inputstr)
drawInputMenu :: Config -> String -> Picture
drawInputMenu cf s = darkenBackground cf <> drawTitle cf s
drawInputMenu :: String -> Config -> Picture
drawInputMenu s cf = darkenBackground cf <> drawTitle cf s
drawOptions :: Config -> String -> Maybe Int -> [SelectionItem a] -> Picture
drawOptions cf title msel sl =
drawOptions :: String -> Maybe Int -> [SelectionItem a] -> Config -> Picture
drawOptions title msel sl cf =
darkenBackground cf
<> drawTitle cf title
<> drawSelectionList menuLDP cf sl
<> translateScreenPos
cf
(menuLDP ^. ldpPos)
( drawCursorAt
msel
sl
menuLDP
50
(BoundaryCursor [North, South])
)
(drawCursorAt msel sl menuLDP 50 (BoundaryCursor [North, South]))
darkenBackground :: Config -> Picture
darkenBackground = color (withAlpha 0.5 black) . polygon . reverse . screenBox
+36 -44
View File
@@ -1,7 +1,6 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Render.Picture (
fixedCoordPictures,
) where
module Dodge.Render.Picture (fixedCoordPictures) where
import Control.Lens
import Data.Maybe
@@ -62,18 +61,18 @@ fpsText x = color col . text $ "ms/frame " ++ show x
| otherwise = red
drawMenuOrHUD :: Config -> Universe -> Picture
drawMenuOrHUD cfig u = case u ^. uvScreenLayers of
drawMenuOrHUD cf u = case u ^. uvScreenLayers of
[] -> drawHUD (u ^. uvConfig) (u ^. uvWorld)
(x : _) -> drawMenuScreen cfig (u ^? uvWorld . input . mouseContext . mcoMenuClick) x
(x : _) -> drawMenuScreen (u ^? uvWorld . input . mouseContext . mcoMenuClick) x cf
drawConcurrentMessage :: Universe -> Picture
drawConcurrentMessage u =
translate 0 (50 - halfHeight cfig)
translate 0 (50 - halfHeight cf)
. stackPicturesAt
. map (centerText . f)
$ u ^.. uvSideEffects . each
where
cfig = _uvConfig u
cf = _uvConfig u
f (RunningSideEffect ce) = ce ++ " IN PROGRESS"
f x = _ceString x ++ " QUEUED"
@@ -131,43 +130,32 @@ drawCursorByTerminalStatus = \case
_ -> drawEmptySet 5
drawQuitTerminal :: Float -> Picture
drawQuitTerminal x = fold
[ line [V2 x x, V2 (- x) (- x)]
, line [V2 x (-x), V2 (- x) x]
, polygonWire (square x)
]
drawQuitTerminal x =
line [V2 x x, V2 (- x) (- x)]
<> line [V2 x (- x), V2 (- x) x]
<> polygonWire (square x)
drawEmptySet :: Float -> Picture
drawEmptySet x =
fold
[ line [V2 x x, V2 (- x) (- x)]
, circle x
]
drawEmptySet x = line [V2 x x, V2 (- x) (- x)] <> circle x
drawReturn :: Float -> Picture
drawReturn x =
fold
[ line [V2 0 0, V2 y y]
, line [V2 0 0, V2 y (- y)]
, line [V2 0 0, V2 (2 * y) 0]
, line [V2 (2 * y) 0, V2 (2 * y) (2 * x)]
]
line [V2 0 0, V2 y y]
<> line [V2 0 0, V2 y (- y)]
<> line [V2 0 0, V2 (2 * y) 0]
<> line [V2 (2 * y) 0, V2 (2 * y) (2 * x)]
where
y = 0.7 * x
--drawReturn = scale 0.1 0.1 . translate (-50) (-100) $ text [toEnum 153]
drawPlus :: Float -> Picture
drawPlus x = fold [line [V2 (- x) 0, V2 x 0], line [V2 0 (- x), V2 0 x]]
drawMenuClick :: Float -> Picture
drawMenuClick z =
fold
[ line [V2 y 0, V2 x 0]
, line [V2 ny 0, V2 nx 0]
, line [V2 0 ny, V2 0 nx]
, line [V2 0 y, V2 0 x]
]
line [V2 y 0, V2 x 0]
<> line [V2 ny 0, V2 nx 0]
<> line [V2 0 ny, V2 0 nx]
<> line [V2 0 y, V2 0 x]
where
x = 0.5 * z
y = x + z
@@ -176,12 +164,10 @@ drawMenuClick z =
drawMenuCursor :: Float -> Picture
drawMenuCursor z =
fold
[ line [V2 y 0, V2 x 0]
, line [V2 ny 0, V2 nx 0]
, line [V2 0 ny, V2 0 nx]
, line [V2 0 y, V2 0 x]
]
line [V2 y 0, V2 x 0]
<> line [V2 ny 0, V2 nx 0]
<> line [V2 0 ny, V2 0 nx]
<> line [V2 0 y, V2 0 x]
where
x = z
y = x + z
@@ -278,12 +264,10 @@ drawCombFilter x =
drawGapPlus :: Float -> Picture
drawGapPlus x =
fold
[ line [V2 (-1.5 * x) 0, V2 (-0.5 * x) 0]
, line [V2 (0.5 * x) 0, V2 (1.5 * x) 0]
, line [V2 (0.5 * x) (- x), V2 (0.5 * x) x]
, line [V2 (-0.5 * x) (- x), V2 (-0.5 * x) x]
]
line [V2 (-1.5 * x) 0, V2 (-0.5 * x) 0]
<> line [V2 (0.5 * x) 0, V2 (1.5 * x) 0]
<> line [V2 (0.5 * x) (- x), V2 (0.5 * x) x]
<> line [V2 (-0.5 * x) (- x), V2 (-0.5 * x) x]
aimDelaySweep :: Universe -> Picture
aimDelaySweep u = fold $ do
@@ -297,7 +281,15 @@ drawAimSweep cr w = fold $ do
a <- safeArgV (mwp -.- p)
return $
uncurryV translate (worldPosToScreen campos p) $
arcFull (a - rot) 10 white (a + diffAngles cdir a - rot) 1 white (5 + dist mwp p * campos ^. camZoom) white
arcFull
(a - rot)
10
white
(a + diffAngles cdir a - rot)
1
white
(5 + dist mwp p * campos ^. camZoom)
white
where
cdir = _crDir cr
rot = campos ^. camRot