Cleanup
This commit is contained in:
+6
-12
@@ -39,12 +39,6 @@ import Control.Lens
|
||||
import qualified Data.Set as S
|
||||
import SDL
|
||||
|
||||
|
||||
--handleEvent :: Event -> Universe -> Maybe Universe
|
||||
--handleEvent e uv = case handleEvent' e (_uvWorld uv) of
|
||||
-- Nothing -> Nothing
|
||||
-- Just w -> Just $ uv & uvWorld .~ w
|
||||
|
||||
handleEvent :: Event -> Universe -> IO (Maybe Universe)
|
||||
handleEvent e = case eventPayload e of
|
||||
KeyboardEvent kev -> handleKeyboardEvent kev
|
||||
@@ -64,18 +58,18 @@ handleMouseMotionEvent mmev u = Just $ u & uvWorld . mousePos .~ V2
|
||||
P (V2 x y) = mouseMotionEventPos mmev
|
||||
|
||||
handleMouseButtonEvent :: MouseButtonEventData -> Universe -> Maybe Universe
|
||||
handleMouseButtonEvent mbev u = case mouseButtonEventMotion mbev of
|
||||
Released -> Just $ u & updateButtons S.delete
|
||||
Pressed -> handlePressedMouseButton thebutton $ u & updateButtons S.insert
|
||||
handleMouseButtonEvent mbev = case mouseButtonEventMotion mbev of
|
||||
Released -> Just . updateButtons S.delete
|
||||
Pressed -> handlePressedMouseButton thebutton . updateButtons S.insert
|
||||
where
|
||||
thebutton = mouseButtonEventButton mbev
|
||||
updateButtons f = uvWorld . mouseButtons %~ f thebutton
|
||||
|
||||
{- | Sets window position in config. -}
|
||||
handleWindowMoveEvent :: WindowMovedEventData -> Universe -> Maybe Universe
|
||||
handleWindowMoveEvent mev u = Just $ u
|
||||
& config . windowPosX .~ fromIntegral x
|
||||
& config . windowPosY .~ fromIntegral y
|
||||
handleWindowMoveEvent mev = Just
|
||||
. (config . windowPosX .~ fromIntegral x)
|
||||
. (config . windowPosY .~ fromIntegral y)
|
||||
where
|
||||
P (V2 x y) = windowMovedEventPosition mev
|
||||
|
||||
|
||||
Reference in New Issue
Block a user