Remove explicit scancode from menu items

This commit is contained in:
2022-11-04 08:42:30 +00:00
parent 6e7cd14f49
commit c263012b61
11 changed files with 81 additions and 85 deletions
+2 -1
View File
@@ -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
View File
@@ -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)]