Put controls on separate menu screen

This commit is contained in:
2021-04-08 12:34:10 +02:00
parent 28c1f3d23b
commit 7969c3f9e8
3 changed files with 36 additions and 22 deletions
+1
View File
@@ -7,5 +7,6 @@ data MenuLayer
| GameOverMenu | GameOverMenu
| OptionMenu | OptionMenu
| ConfigSaveScreen | ConfigSaveScreen
| ControlList
deriving (Eq,Ord) deriving (Eq,Ord)
+5
View File
@@ -19,6 +19,7 @@ handlePressedKeyInMenu mState scode w = case mState of
LevelMenu _ -> case scode of LevelMenu _ -> case scode of
ScancodeEscape -> Nothing ScancodeEscape -> Nothing
ScancodeO -> goToOptionMenu w ScancodeO -> goToOptionMenu w
ScancodeC -> goToControls w
_ -> startLevel w _ -> startLevel w
PauseMenu -> case scode of PauseMenu -> case scode of
ScancodeEscape -> Nothing ScancodeEscape -> Nothing
@@ -26,6 +27,7 @@ handlePressedKeyInMenu mState scode w = case mState of
ScancodeN -> Just $ putSound $ generateLevel 1 ScancodeN -> Just $ putSound $ generateLevel 1
$ initialWorld {_randGen = _randGen w} $ initialWorld {_randGen = _randGen w}
ScancodeO -> goToOptionMenu w ScancodeO -> goToOptionMenu w
ScancodeC -> goToControls w
_ -> unpause w _ -> unpause w
GameOverMenu -> case scode of GameOverMenu -> case scode of
ScancodeEscape -> Nothing ScancodeEscape -> Nothing
@@ -34,6 +36,7 @@ handlePressedKeyInMenu mState scode w = case mState of
$ initialWorld $ initialWorld
{_randGen = _randGen w} {_randGen = _randGen w}
ScancodeO -> goToOptionMenu w ScancodeO -> goToOptionMenu w
ScancodeC -> goToControls w
_ -> Just w _ -> Just w
OptionMenu -> case scode of OptionMenu -> case scode of
ScancodeY -> Just $ w & config . volume_master %~ dec ScancodeY -> Just $ w & config . volume_master %~ dec
@@ -44,6 +47,7 @@ handlePressedKeyInMenu mState scode w = case mState of
ScancodeM -> Just $ w & config . volume_music %~ inc ScancodeM -> Just $ w & config . volume_music %~ inc
_ -> Just $ w & menuLayers %~ ([ConfigSaveScreen , ConfigSaveScreen] ++) . tail _ -> Just $ w & menuLayers %~ ([ConfigSaveScreen , ConfigSaveScreen] ++) . tail
& configNeedsUpdate .~ False & configNeedsUpdate .~ False
ControlList -> Just $ w & menuLayers %~ tail
_ -> Just w _ -> Just w
where where
unpause w' = Just . resumeSound $ unpause w' = Just . resumeSound $
@@ -54,6 +58,7 @@ handlePressedKeyInMenu mState scode w = case mState of
inc x = min 1 (x + 0.1) inc x = min 1 (x + 0.1)
goToOptionMenu w = Just $ w & menuLayers %~ (OptionMenu :) goToOptionMenu w = Just $ w & menuLayers %~ (OptionMenu :)
& configNeedsUpdate .~ True & configNeedsUpdate .~ True
goToControls w = Just $ w & menuLayers %~ (ControlList :)
storeLevel :: World -> World storeLevel :: World -> World
storeLevel w = case _storedLevel w of storeLevel w = case _storedLevel w of
+30 -22
View File
@@ -14,7 +14,6 @@ menuScreen w = case _menuLayers w of
(LevelMenu x:_) -> pictures (LevelMenu x:_) -> pictures
[color (withAlpha 0.5 black) $ polygon $ screenBox w [color (withAlpha 0.5 black) $ polygon $ screenBox w
,tst (-100) 100 0.4 ("LEVEL "++show x) ,tst (-100) 100 0.4 ("LEVEL "++show x)
,controlsList
] ]
(PauseMenu:_) -> pictures (PauseMenu:_) -> pictures
[color (withAlpha 0.5 black) $ polygon $ screenBox w [color (withAlpha 0.5 black) $ polygon $ screenBox w
@@ -22,7 +21,7 @@ menuScreen w = case _menuLayers w of
,tst (-100) 50 0.2 "n - new level" ,tst (-100) 50 0.2 "n - new level"
,tst (-100) 0 0.2 "r - restart" ,tst (-100) 0 0.2 "r - restart"
,tst (-100) (-50) 0.2 "o - options" ,tst (-100) (-50) 0.2 "o - options"
, controlsList ,tst (-100) (-100) 0.2 "c - controls"
] ]
(GameOverMenu:_) -> pictures (GameOverMenu:_) -> pictures
[color (withAlpha 0.5 black) $ polygon $ screenBox w [color (withAlpha 0.5 black) $ polygon $ screenBox w
@@ -30,7 +29,7 @@ menuScreen w = case _menuLayers w of
,tst (-100) 50 0.2 "n - new level" ,tst (-100) 50 0.2 "n - new level"
,tst (-100) 0 0.2 "r - restart" ,tst (-100) 0 0.2 "r - restart"
,tst (-100) (-50) 0.2 "o - options" ,tst (-100) (-50) 0.2 "o - options"
,controlsList ,tst (-100) (-100) 0.2 "c - controls"
] ]
(OptionMenu : _) -> pictures (OptionMenu : _) -> pictures
[color (withAlpha 0.5 black) $ polygon $ screenBox w [color (withAlpha 0.5 black) $ polygon $ screenBox w
@@ -38,8 +37,19 @@ menuScreen w = case _menuLayers w of
,tst (-180) 50 0.2 $ "y - master volume + u : " ++ mavol ,tst (-180) 50 0.2 $ "y - master volume + u : " ++ mavol
,tst (-180) 0 0.2 $ "h - sound volume + j : " ++ snvol ,tst (-180) 0 0.2 $ "h - sound volume + j : " ++ snvol
,tst (-180) (-50) 0.2 $ "n - music volume + m : " ++ muvol ,tst (-180) (-50) 0.2 $ "n - music volume + m : " ++ muvol
]
(ControlList : _) -> pictures
[color (withAlpha 0.5 black) $ polygon $ screenBox w
,tst (-100) 100 0.4 "CONTROLS"
,controlsList ,controlsList
] ]
(ConfigSaveScreen : _) -> pictures
[color (withAlpha 0.5 black) $ polygon $ screenBox w
,tst (-100) 100 0.4 "OPTIONS"
,tst (-180) 50 0.2 $ "y - master volume + u : " ++ mavol
,tst (-180) 0 0.2 $ "h - sound volume + j : " ++ snvol
,tst (-180) (-50) 0.2 $ "n - music volume + m : " ++ muvol
]
_ -> blank _ -> blank
where where
tst x y sc t = translate x y $ scale sc sc $ color white $ text t tst x y sc t = translate x y $ scale sc sc $ color white $ text t
@@ -48,25 +58,23 @@ menuScreen w = case _menuLayers w of
muvol = f $ _volume_music $ _config w muvol = f $ _volume_music $ _config w
f x = show $ round $ 10 * x f x = show $ round $ 10 * x
controlsList = pictures [tst (-250) (-130) 0.15 "controls:" controlsList = pictures $ concat $ zipWith butAndEff
,tst (-150) (-130) 0.15 "wasd" [("wasd", "movement")
,tst 0 (-130) 0.15 "movement" ,("[rmb]", "aim")
,tst (-150) (-160) 0.15 "[rmb]" ,("[rmb+lmb]", "shoot or use item")
,tst 0 (-160) 0.15 "aim" ,("[wheelscroll]" , "select item" )
,tst (-150) (-190) 0.15 "[rmb+lmb]" ,("[space]" , "pickup item" )
,tst 0 (-190) 0.15 "shoot or use item" ,("m" , "display map" )
,tst (-150) (-220) 0.15 "[wheelscroll]" ,("f" , "drop item" )
,tst 0 (-220) 0.15 "select item" ,("c[esc]" , "pause" )
,tst (-150) (-250) 0.15 "[space]" ,("qe" , "rotate camera")
,tst 0 (-250) 0.15 "pickup item" ]
,tst (-150) (-280) 0.15 "f" [60,30..]
,tst 0 (-280) 0.15 "drop item" where
,tst (-150) (-310) 0.15 "cp[esc]" butAndEff (btext,etext) y =
,tst 0 (-310) 0.15 "pause" [translate (-250) y $ scale 0.15 0.15 $ color white $ text btext
,tst (-150) (-340) 0.15 "qe[lmb]" ,translate 0 y $ scale 0.15 0.15 $ color white $ text etext
,tst 0 (-340) 0.15 "rotate camera" ]
]
where tst x y sc t = translate x y $ scale sc sc $ color white $ text t
screenBox w = [ (halfWidth w, halfHeight w) screenBox w = [ (halfWidth w, halfHeight w)
, (-halfWidth w, halfHeight w) , (-halfWidth w, halfHeight w)