Permalink
Browse files

added buttonMap and deactButton

  • Loading branch information...
1 parent d5872fa commit a592990edc85396533815c3c6aefbb4e5e442116 Nik Nyby committed Apr 27, 2010
Showing with 23 additions and 21 deletions.
  1. +7 −20 Bindings.hs
  2. +13 −0 Menu.hs
  3. +3 −1 Render.hs
View
@@ -60,25 +60,7 @@ animatorAction e (MouseButton LeftButton) Down =
-- TODO: just look at this mess!
--
e { sprites = (updateSelected . updateDragged) (sprites e),
- -- TODO: map over MmaMenu?
- vars = (vars e) { menu = MmaMenu {
- playButton = updateButton $ (playButton$menu$vars$e),
-
- sprtWindow = updateWindow $ (sprtWindow$menu$vars$e),
- nextSprtButton = updateButton $ (nextSprtButton$menu$vars$e),
- prevSprtButton = updateButton $ (prevSprtButton$menu$vars$e),
-
- bgWindow = updateWindow $ (bgWindow$menu$vars$e),
- nextBgButton = updateButton $ (nextBgButton$menu$vars$e),
- prevBgButton = updateButton $ (prevBgButton$menu$vars$e),
-
- frameWindow = updateWindow $ (frameWindow$menu$vars$e),
- prevFrameButton = updateButton $ (prevFrameButton$menu$vars$e),
- nextFrameButton = updateButton $ (nextFrameButton$menu$vars$e),
-
- saveButton = updateButton $ (saveButton$menu$vars$e)
- }
- }
+ vars = (vars e) { menu = buttonMap updateButton (menu$vars$e) }
}
where
updateSelected :: [Sprite] -> [Sprite]
@@ -108,11 +90,16 @@ animatorAction e (MouseButton LeftButton) Down =
mp = mousePos $ vars $ e
animatorAction e (MouseButton LeftButton) Up =
- e { sprites = unsticky (sprites e) }
+ e { sprites = unsticky (sprites e),
+ vars = (vars e) { menu = buttonMap deactButton (menu$vars$e) }
+ }
where
unsticky :: [Sprite] -> [Sprite]
unsticky = map (\s -> s {sticky = False})
+ deactButton :: MmaButton -> MmaButton
+ deactButton b = b { buttonState = False }
+
animatorAction e _ _ = e
introAction (Env v s) (MouseButton _) Down =
View
13 Menu.hs
@@ -2,6 +2,7 @@ module Menu (
MmaButton(..),
MmaMenu(..),
MmaWindow(..),
+ buttonMap,
initialMenu,
selectButtonRect,
) where
@@ -53,6 +54,18 @@ initialMenu = MmaMenu {
where
m = mkMenu 640 140 15
+buttonMap :: (MmaButton -> MmaButton) -> MmaMenu -> MmaMenu
+buttonMap f m = m {
+ playButton = f $ playButton m,
+ nextSprtButton = f $ nextSprtButton m,
+ prevSprtButton = f $ prevSprtButton m,
+ nextBgButton = f $ nextBgButton m,
+ prevBgButton = f $ prevBgButton m,
+ nextFrameButton = f $ nextFrameButton m,
+ prevFrameButton = f $ prevFrameButton m,
+ saveButton = f $ saveButton m
+ }
+
-- A list of button x-positions that fit in a window of width wwd. bwd is
-- button width, and sp is space between buttons.
mkMenu :: GLdouble -> GLdouble -> GLdouble -> [GLdouble]
View
@@ -13,8 +13,10 @@ import Util
drawWorld :: Env -> MmaTextures -> IO ()
drawWorld e =
case (mode $ vars $ e) of
- Intro -> drawIntro e
Animator -> drawAnimator e
+ Intro -> drawIntro e
+ Play -> drawAnimator e
+ Record -> drawAnimator e
drawAnimator :: Env -> MmaTextures -> IO ()
drawAnimator e t = do

0 comments on commit a592990

Please sign in to comment.