{- The menu picture. -} module Dodge.Render.MenuScreen ( menuScreen ) where import Dodge.Data.Menu --import Dodge.Config.Update import Dodge.Config.Data --import Dodge.Base (halfWidth,halfHeight) import Picture import Geometry menuScreen :: Configuration -> Float -- Half width of screen -> Float -- Half height of screen -> [MenuLayer] -> Picture menuScreen cfig hw hh mLays = case mLays of (LevelMenu x:_) -> optionsList hw hh ("LEVEL"++show x) [] (PauseMenu:_) -> optionsList hw hh "PAUSED" ["N - NEW LEVEL" ,"R - RESTART" ,"O - OPTIONS" ,"C - CONTROLS" ] (GameOverMenu:_) -> optionsList hw hh "GAME OVER" ["N - NEW LEVEL" ,"R - RESTART" ,"O - OPTIONS" ,"C - CONTROLS" ] (OptionMenu : _) -> optionsList hw hh "OPTIONS" ["V - VOLUME" ,"G - GRAPHICS" ] (SoundOptionMenu : _) -> optionsList hw hh "OPTIONS:VOLUME" ["Y - MASTER VOLUME + U : " ++ mavol ,"H - SOUND VOLUME + J : " ++ snvol ,"N - MUSIC VOLUME + M : " ++ muvol ] (GraphicsOptionMenu : _) -> optionsList hw hh "OPTIONS:GRAPHICS" ["W - WALL TEXTURES:" ++ show (_wall_textured cfig) ,"S - SHADOW RESOLUTION:" ++ showShadRes (_shadow_resolution cfig) ] (ControlList : _) -> pictures [color (withAlpha 0.5 black) $ polygon $ screenBox hw hh ,tst (-100) 100 0.4 "CONTROLS" ,controlsList ] (WaitMessage s _ : _) -> optionsList hw hh s [] (Terminal s : _) -> optionsList hw hh "SCANCODE INPUT" ['>':s ++ "_"] (TerminalMessage t xs : _) -> displayStringList hw hh $ map snd $ filter (( > t) . fst) xs _ -> blank where tst x y sc t = translate x y $ scale sc sc $ color white $ text t mavol = f $ _volume_master cfig snvol = f $ _volume_sound cfig muvol = f $ _volume_music cfig f x = show (round $ 10 * x :: Int) showShadRes i = "1/"++ show i displayStringList :: Float -> Float -> [String] -> Picture displayStringList hw hh ss = pictures ( polygon (rectNSEW hh (-hh) hw (-hw)) : zipWith f ys ss ) where ys = [0,22..] f y s = translate (10-hw) y . scale 0.15 0.15 $ text s optionsList :: Float -- ^ Half screen width -> Float -- ^ Half screen height -> String -- ^ Title -> [String] -- ^ Options -> Picture optionsList hw hh tit ops = pictures $ [color (withAlpha 0.5 black) $ polygon $ screenBox hw hh ,placeString (-hw + 30) (hh - 50) 0.4 tit] ++ zipWith (\ s vpos -> placeString (-hw + 50) vpos 0.2 s) ops [hh-100,hh-150 ..] where placeString x y sc t = translate x y $ scale sc sc $ color white $ text t 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") ] [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 ] screenBox :: Float -- ^ Half screen width -> Float -- ^ Half screen height -> [(Float,Float)] screenBox halfW halfH = [ (halfW, halfH) , (-halfW, halfH) , (-halfW,-halfH) , ( halfW,-halfH) ]