Refactor event handling. Allow mouse movement in menus

This commit is contained in:
2021-04-07 21:59:44 +02:00
parent d42cb89dd2
commit 294f2509d0
12 changed files with 319 additions and 317 deletions
+9 -1
View File
@@ -5,7 +5,6 @@ import Dodge.Data
import Dodge.Base
import Dodge.CreatureAction
import Dodge.Update.UsingInput
import Dodge.Event
import Dodge.CreatureState
import Dodge.LoadConfig
@@ -90,3 +89,12 @@ wasdComp ks w = f $ foldr ( (+.+) . wasdM w ) (0,0) ks
where f (0,0) = ((0,0), Nothing)
f p = (errorNormalizeV 46 p, Just $ argV p)
mouseActionsCr :: S.Set SDL.MouseButton -> Creature -> Creature
mouseActionsCr keys cr
| rbPressed
= set ( crState . stance . posture) Aiming cr
| otherwise
= set ( crState . stance . posture) AtEase cr
where lbPressed = SDL.ButtonLeft `S.member` keys
rbPressed = SDL.ButtonRight `S.member` keys