Remove explicit scancode from menu items
This commit is contained in:
@@ -31,10 +31,11 @@ handleKeyboardEvent kev = case keyboardEventKeyMotion kev of
|
||||
|
||||
handleMouseMotionEvent :: MouseMotionEventData -> Configuration -> Input -> Input
|
||||
handleMouseMotionEvent mmev cfig =
|
||||
mousePos
|
||||
(mousePos
|
||||
.~ V2
|
||||
(fromIntegral x - 0.5 * _windowX cfig)
|
||||
(0.5 * _windowY cfig - fromIntegral y)
|
||||
) . (mouseMoving .~ True)
|
||||
where
|
||||
P (V2 x y) = mouseMotionEventPos mmev
|
||||
|
||||
|
||||
+23
-33
@@ -1,5 +1,5 @@
|
||||
module Dodge.Event.Menu (
|
||||
optionListToEffects,
|
||||
--optionListToEffects,
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
@@ -8,36 +8,26 @@ import Dodge.Data.Universe
|
||||
import Dodge.WindowLayout
|
||||
import SDL
|
||||
|
||||
optionListToEffects ::
|
||||
(Universe -> Universe) ->
|
||||
Scancode ->
|
||||
[MenuOption] ->
|
||||
Universe ->
|
||||
Universe
|
||||
optionListToEffects defaulteff sc mops u = case sc of
|
||||
ScancodeSpace ->
|
||||
(uvScreenLayers . ix 0 . scOptionsOffset %~ (f . (+ mlines)))
|
||||
u
|
||||
_ ->
|
||||
( fromMaybe defaulteff
|
||||
. lookup sc
|
||||
. concatMap menuOptionToEffects
|
||||
$ mops
|
||||
)
|
||||
u
|
||||
where
|
||||
f x
|
||||
| x > length mops = 0
|
||||
| otherwise = x
|
||||
mlines = availableMenuLines $ _uvConfig u
|
||||
--optionListToEffects ::
|
||||
-- (Universe -> Universe) ->
|
||||
-- Scancode ->
|
||||
-- [MenuOption] ->
|
||||
-- Universe ->
|
||||
-- Universe
|
||||
--optionListToEffects defaulteff sc mops u = case sc of
|
||||
-- ScancodeSpace ->
|
||||
-- (uvScreenLayers . ix 0 . scOptionsOffset %~ (f . (+ mlines)))
|
||||
-- u
|
||||
-- _ ->
|
||||
-- ( fromMaybe defaulteff
|
||||
-- . lookup sc
|
||||
-- . concatMap menuOptionToEffects
|
||||
-- $ mops
|
||||
-- )
|
||||
-- u
|
||||
-- where
|
||||
-- f x
|
||||
-- | x > length mops = 0
|
||||
-- | otherwise = x
|
||||
-- mlines = availableMenuLines $ _uvConfig u
|
||||
|
||||
menuOptionToEffects :: MenuOption -> [(Scancode, Universe -> Universe)]
|
||||
menuOptionToEffects Toggle{_moKey = k, _moEff = eff} = [(k, eff)]
|
||||
menuOptionToEffects InvisibleToggle{_moKey = k, _moEff = eff} = [(k, eff)]
|
||||
menuOptionToEffects
|
||||
Toggle2
|
||||
{ _moKey1 = k1
|
||||
, _moEff1 = eff1
|
||||
, _moKey2 = k2
|
||||
, _moEff2 = eff2
|
||||
} = [(k1, eff1), (k2, eff2)]
|
||||
|
||||
Reference in New Issue
Block a user