Refactor, try to limit dependencies

This commit is contained in:
2022-07-28 00:59:56 +01:00
parent 8aa5c17ab9
commit 160560af5f
418 changed files with 15104 additions and 13342 deletions
+37 -32
View File
@@ -1,13 +1,13 @@
module Dodge.Targeting.Draw where
import Dodge.Data
import Dodge.Base
import Picture
import Geometry.Vector
import Geometry.Data
import LensHelp
import ShortShow
import Data.Maybe
import Dodge.Base
import Dodge.Data.Universe
import Geometry.Data
import Geometry.Vector
import LensHelp
import Picture
import ShortShow
drawTargeting :: TargetDraw -> Item -> Creature -> Configuration -> World -> Picture
drawTargeting td = case td of
@@ -26,50 +26,55 @@ targetDistanceDraw itm _ cfig w = fromMaybe mempty $ do
mwp = mouseWorldPos w
p2 = worldPosToScreen w mwp
thecol = if dist p mwp > 100 then red else white
return $ winScale cfig
$ setLayer FixedCoordLayer
$ color thecol
$ line [p1, p2]
<> transMidLine p1 p2 (scale 0.1 0.1 . text . shortShow $ dist p mwp)
return $
winScale cfig $
setLayer FixedCoordLayer $
color thecol $
line [p1, p2]
<> transMidLine p1 p2 (scale 0.1 0.1 . text . shortShow $ dist p mwp)
targetDraw :: (Item -> Picture) -> Item -> Creature -> Configuration -> World -> Picture
targetDraw f it _ cfig w = fromMaybe mempty $ do
p <- it ^? itTargeting . tgPos . _Just
return $ winScale cfig
$ setLayer FixedCoordLayer
$ color white
$ uncurryV translate (worldPosToScreen w p)
$ f it
return $
winScale cfig $
setLayer FixedCoordLayer $
color white $
uncurryV translate (worldPosToScreen w p) $
f it
activeTargetCursorPic :: Picture
activeTargetCursorPic = pictures
[rotate a $ line [V2 15 0,V2 10 0] <> targCorner | a <- [0,0.5*pi,pi,1.5*pi]]
activeTargetCursorPic =
pictures
[rotate a $ line [V2 15 0, V2 10 0] <> targCorner | a <- [0, 0.5 * pi, pi, 1.5 * pi]]
transMidLine :: Point2 -> Point2 -> Picture -> Picture
transMidLine p1 p2 = translate 20 (f p1 p2) . uncurryV translate (0.5 *.* (p1 +.+ p2))
where
f (V2 x y) (V2 x' y')
| y > y' && x > x' = max (-10) (x'-x)
| y > y' && x < x' = min 10 (x'-x)
| x > x' = min 10 (x-x')
| otherwise = max (-10) (x-x')
f (V2 x y) (V2 x' y')
| y > y' && x > x' = max (-10) (x' - x)
| y > y' && x < x' = min 10 (x' - x)
| x > x' = min 10 (x - x')
| otherwise = max (-10) (x - x')
targetRBCreatureDraw :: Item -> Creature -> Configuration -> World -> Picture
targetRBCreatureDraw = targetDraw thepic
where
thepic it | _tgActive $ _itTargeting it = activeTargetCursorPic
thepic it
| _tgActive $ _itTargeting it = activeTargetCursorPic
| otherwise = targetCursorPic
targCorner :: Picture
targCorner = pictures
[line [V2 x x, V2 x (x-y)]
,line [V2 x x, V2 (x-y) x]
]
targCorner =
pictures
[ line [V2 x x, V2 x (x - y)]
, line [V2 x x, V2 (x - y) x]
]
where
x = 10
y = 5
targetCursorPic :: Picture
targetCursorPic = pictures
[rotate a targCorner | a <- [0,0.5*pi,pi,1.5*pi]]
targetCursorPic =
pictures
[rotate a targCorner | a <- [0, 0.5 * pi, pi, 1.5 * pi]]