Refactor control list display

This commit is contained in:
2021-09-13 01:39:53 +01:00
parent d11d19c9e8
commit b27c174d93
6 changed files with 79 additions and 52 deletions
+36 -43
View File
@@ -1,4 +1,10 @@
module Dodge.Menu
( scodeToChar
, popScreen
, pushScreen
, pauseMenu
, gameOverMenu
)
where
import Dodge.Data
import Dodge.Save
@@ -12,7 +18,7 @@ import Dodge.Initialisation
import Preload.Update
import Dodge.Base.Window
import Dodge.SoundLogic
import Picture
--import Picture
import Control.Lens
optionMenu :: ScreenLayer
@@ -28,12 +34,12 @@ optionsOptions =
, Toggle ScancodeG (pushScreen graphicsMenu) (const "GRAPHICS")
, Toggle ScancodeP (pushScreen gameplayOptionsMenu) (const "GAMEPLAY")
]
levelMenuOptions :: [MenuOption]
levelMenuOptions =
[ InvisibleToggle ScancodeEscape (const Nothing)
, InvisibleToggle ScancodeO (pushScreen optionMenu)
, InvisibleToggle ScancodeC (pushScreen displayControls)
]
--levelMenuOptions :: [MenuOption]
--levelMenuOptions =
-- [ InvisibleToggle ScancodeEscape (const Nothing)
-- , InvisibleToggle ScancodeO (pushScreen optionMenu)
-- , InvisibleToggle ScancodeC (pushScreen displayControls)
-- ]
gameplayOptionsMenu :: ScreenLayer
gameplayOptionsMenu = OptionScreen
{ _scTitle = const "OPTIONS:GAMEPLAY"
@@ -151,8 +157,8 @@ startNewGame w = Just $ w
scodeToChar :: Scancode -> Char
scodeToChar = toEnum . (+ 61) . fromIntegral . toNumber
charToScode :: Char -> Scancode
charToScode = Scancode . fromIntegral . (\x -> x - 61) . fromEnum
--charToScode :: Char -> Scancode
--charToScode = Scancode . fromIntegral . (\x -> x - 61) . fromEnum
updateFramebufferSize :: World -> World
updateFramebufferSize w = w & sideEffects %~ up
@@ -164,43 +170,30 @@ updateFramebufferSize w = w & sideEffects %~ up
pdata <- pdataResizeUpdate (x `div` divRes) (y `div` divRes) x y (_preloadData w')
f $ w' & preloadData .~ pdata
levelMenu :: Int -> ScreenLayer
levelMenu x = OptionScreen
{ _scTitle = const $ "LEVEL "++ show x
, _scOptions = levelMenuOptions
, _scDefaultEff = unpause . storeLevel
, _scOptionFlag = NormalOptions
}
--levelMenu :: Int -> ScreenLayer
--levelMenu x = OptionScreen
-- { _scTitle = const $ "LEVEL "++ show x
-- , _scOptions = levelMenuOptions
-- , _scDefaultEff = unpause . storeLevel
-- , _scOptionFlag = NormalOptions
-- }
unpause :: World -> Maybe World
unpause w = Just . resumeSound $ w {_menuLayers = []}
displayControls :: ScreenLayer
displayControls = DisplayScreen
{_scDisplay = \w -> pictures
[color (withAlpha 0.5 black) $ polygon $ screenBox w
,tst (-100) 100 0.4 "CONTROLS"
,controlsList
]
}
where
tst x y sc t = translate x y $ scale sc sc $ color white $ text t
displayControls = ColumnsScreen "CONTROLS" listControls
controlsList :: Picture
controlsList = pictures $ concat $ zipWith butAndEff
[("wasd", "movement")
,("[rmb]", "aim")
,("[rmb+lmb]", "shoot or use item")
,("[wheelscroll]" , "select item" )
,("[space]" , "pickup item" )
,("m" , "display map" )
,("f" , "drop item" )
,("c[esc]" , "pause" )
,("qe" , "rotate camera")
listControls :: [(String,String)]
listControls =
[("wasd", "MOVEMENT")
,("[rmb]", "AIM")
,("[rmb+lmb]", "SHOOT OR USE ITEM")
,("[wheelscroll]" , "SELECT ITEM" )
,("[space]" , "PICKUP ITEM" )
,("m" , "DISPLAY MAP" )
,("f" , "DROP ITEM" )
,("c[esc]" , "PAUSE" )
,("qe" , "ROTATE CAMERA")
,("F5" , "QUICKSAVE")
,("F9" , "QUICKLOAD")
]
[60,30..]
where
butAndEff (btext,etext) y =
[translate (-250) y $ scale 0.15 0.15 $ color white $ text btext
,translate 0 y $ scale 0.15 0.15 $ color white $ text etext
]