Warp mouse after unpausing, with (undesired) one frame gap
This commit is contained in:
+13
-1
@@ -4,6 +4,8 @@ module Dodge.Menu (
|
||||
splashMenu,
|
||||
) where
|
||||
|
||||
import Dodge.Base.Coordinate
|
||||
import Geometry
|
||||
import Control.Monad
|
||||
import qualified Data.Aeson.Encode.Pretty as AEP
|
||||
import Data.ByteString.Lazy.Char8 (unpack)
|
||||
@@ -23,6 +25,7 @@ import Padding
|
||||
import Preload.Update
|
||||
import System.Clipboard
|
||||
import Text.Read
|
||||
import qualified SDL as SDL
|
||||
|
||||
splashMenu :: Universe -> ScreenLayer
|
||||
splashMenu u =
|
||||
@@ -190,7 +193,16 @@ gameOverMenu u =
|
||||
--charToScode = Scancode . fromIntegral . (\x -> x - 61) . fromEnum
|
||||
|
||||
unpause :: Universe -> Universe
|
||||
unpause = resumeSound . set uvScreenLayers []
|
||||
unpause u' = resumeSound . set uvScreenLayers []
|
||||
$ over uvIOEffects (\f u -> SDL.warpMouse SDL.WarpCurrentFocus (SDL.P (SDL.V2 x' y')) >> f u)
|
||||
u'
|
||||
where
|
||||
cfig = u' ^. uvConfig
|
||||
x' = round $ x + 0.5 * windowXFloat cfig
|
||||
y' = round $ 0.5 * windowYFloat cfig - y
|
||||
V2 x y = worldPosToScreen (u' ^. uvWorld . wCam)
|
||||
(u' ^. uvWorld . cWorld . lWorld . lAimPos)
|
||||
|
||||
|
||||
-- note that this won't update after it is first loaded
|
||||
displayConfig :: Universe -> ScreenLayer
|
||||
|
||||
Reference in New Issue
Block a user