Refactor window size, update selection cursor on new screen
This commit is contained in:
+39
-18
@@ -3,32 +3,36 @@ module Dodge.Render.Picture (
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
import Dodge.Base.WinScale
|
||||
import Data.Maybe
|
||||
import Dodge.Base.Coordinate
|
||||
import Dodge.Base.Window
|
||||
import Dodge.Data.Universe
|
||||
import Dodge.Render.HUD
|
||||
import Dodge.Render.List
|
||||
import Dodge.Render.MenuScreen
|
||||
import Geometry
|
||||
import HelpNum
|
||||
import Picture
|
||||
|
||||
fixedCoordPictures :: Universe -> Picture
|
||||
fixedCoordPictures u = drawMenuOrHUD cfig u
|
||||
<> drawConcurrentMessage u
|
||||
<> customMouseCursor cfig (u ^. uvWorld . input)
|
||||
<> listPicturesAt (halfWidth cfig) 0 cfig (map text (_uvTestString u u))
|
||||
<> displayFrameTicks u
|
||||
fixedCoordPictures u =
|
||||
drawMenuOrHUD cfig u
|
||||
<> drawConcurrentMessage u
|
||||
<> customMouseCursor u
|
||||
<> listPicturesAt (halfWidth cfig) 0 cfig (map text (_uvTestString u u))
|
||||
<> displayFrameTicks u
|
||||
where
|
||||
cfig = _uvConfig u
|
||||
|
||||
displayFrameTicks :: Universe -> Picture
|
||||
displayFrameTicks u = if (debugOn Show_ms_frame $ _uvConfig u) then
|
||||
( setDepth (-1)
|
||||
. translate (-0.5) (-0.8)
|
||||
. scale 0.0005 0.0005
|
||||
displayFrameTicks u =
|
||||
if debugOn Show_ms_frame $ _uvConfig u
|
||||
then
|
||||
setDepth (-1)
|
||||
. translate (-10) (- halfHeight (_uvConfig u) + 6)
|
||||
. scale 0.2 0.2
|
||||
$ fpsText (u ^. uvFrameTicks - u ^. uvLastFrameTicks)
|
||||
)
|
||||
else mempty
|
||||
else mempty
|
||||
|
||||
fpsText :: (Show a, Ord a, Num a) => a -> Picture
|
||||
fpsText x = color col $ text $ "ms/frame " ++ show x
|
||||
@@ -49,7 +53,7 @@ drawConcurrentMessage :: Universe -> Picture
|
||||
drawConcurrentMessage u =
|
||||
stackPicturesAt
|
||||
(halfWidth cfig)
|
||||
(_windowY cfig - 50)
|
||||
(windowYFloat cfig - 50)
|
||||
cfig
|
||||
(map (centerText . f) $ u ^.. uvSideEffects . each)
|
||||
where
|
||||
@@ -57,9 +61,26 @@ drawConcurrentMessage u =
|
||||
f (RunningSideEffect ce) = ce ++ " IN PROGRESS"
|
||||
f x = _ceString x ++ " QUEUED"
|
||||
|
||||
customMouseCursor :: Configuration -> Input -> Picture
|
||||
customMouseCursor cfig inp =
|
||||
winScale cfig
|
||||
. uncurryV translate (_mousePos inp)
|
||||
customMouseCursor :: Universe -> Picture
|
||||
customMouseCursor u =
|
||||
uncurryV translate (u ^. uvWorld . input . mousePos)
|
||||
. color white
|
||||
$ pictures [line [V2 (-5) 0, V2 5 0], line [V2 0 (-5), V2 0 5]]
|
||||
$ mouseCursorType u
|
||||
|
||||
mouseCursorType :: Universe -> Picture
|
||||
mouseCursorType u
|
||||
| null (u ^. uvScreenLayers) = rotate a (drawPlus 5)
|
||||
| otherwise = mousePlus
|
||||
where
|
||||
w = u ^. uvWorld
|
||||
a = fromMaybe 0 $ do
|
||||
cpos <- w ^? cWorld . lWorld . creatures . ix 0 . crPos
|
||||
return . toClosestMultiple (pi / 32) $
|
||||
argV (mouseWorldPos (w ^. input) (w ^. cWorld . cwCamPos) -.- cpos)
|
||||
- w ^. cWorld . cwCamPos . camRot
|
||||
|
||||
mousePlus :: Picture
|
||||
mousePlus = pictures [line [V2 (-5) 0, V2 5 0], line [V2 0 (-5), V2 0 5]]
|
||||
|
||||
drawPlus :: Float -> Picture
|
||||
drawPlus x = pictures [line [V2 (- x) 0, V2 x 0], line [V2 0 (- x), V2 0 x]]
|
||||
|
||||
Reference in New Issue
Block a user