Unify option menu display and effects
This commit is contained in:
+12
-15
@@ -12,8 +12,10 @@ import Dodge.Config.Update
|
||||
import Dodge.Layout
|
||||
import Preload.Update
|
||||
import Dodge.Debug.Terminal
|
||||
import Dodge.Menu
|
||||
|
||||
import Data.Maybe
|
||||
import Data.Foldable
|
||||
--import qualified Data.Set as S
|
||||
import Control.Lens
|
||||
import SDL
|
||||
@@ -47,10 +49,11 @@ handlePressedKeyInMenu mState scode w = case mState of
|
||||
ScancodeO -> pushMenu OptionMenu w
|
||||
ScancodeC -> pushMenu ControlList w
|
||||
_ -> Just w
|
||||
OptionMenu -> case scode of
|
||||
ScancodeV -> pushMenu SoundOptionMenu w
|
||||
ScancodeG -> pushMenu GraphicsOptionMenu w
|
||||
_ -> popMenu w
|
||||
OptionMenu -> optionListToEffects optionsOptions popMenu scode w
|
||||
-- OptionMenu -> case scode of
|
||||
-- ScancodeV -> pushMenu SoundOptionMenu w
|
||||
-- ScancodeG -> pushMenu GraphicsOptionMenu w
|
||||
-- _ -> popMenu w
|
||||
SoundOptionMenu -> case scode of
|
||||
ScancodeY -> Just $ sw & config . volume_master %~ dec
|
||||
ScancodeU -> Just $ sw & config . volume_master %~ inc
|
||||
@@ -66,8 +69,7 @@ handlePressedKeyInMenu mState scode w = case mState of
|
||||
ControlList -> Just $ w & menuLayers %~ tail
|
||||
_ -> Just w
|
||||
where
|
||||
unpause w' = Just . resumeSound $
|
||||
w' {_menuLayers = []}
|
||||
unpause w' = Just . resumeSound $ w' {_menuLayers = []}
|
||||
startLevel = unpause . storeLevel
|
||||
dec x = max 0 (x - 0.1)
|
||||
inc x = min 1 (x + 0.1)
|
||||
@@ -84,16 +86,11 @@ handlePressedKeyInMenu mState scode w = case mState of
|
||||
dropLast (x:xs) = init (x:xs)
|
||||
dropLast _ = []
|
||||
|
||||
-- | hacky
|
||||
scodeToChar :: Scancode -> Char
|
||||
scodeToChar = toEnum . (+ 61) . fromIntegral . toNumber
|
||||
optionListToEffects :: [MenuOption] -> (World -> Maybe World) -> Scancode -> World -> Maybe World
|
||||
optionListToEffects mos eff sc w = case find (\mo -> _moKey mo == sc) mos of
|
||||
Nothing -> eff w
|
||||
Just mo -> _moEffect mo w
|
||||
|
||||
updateFramebufferSize :: World -> World
|
||||
updateFramebufferSize w = w & sideEffects
|
||||
%~ (pdataResizeUpdate (x `div` divRes) (y `div` divRes) x y : )
|
||||
where
|
||||
(x,y) = (round $ getWindowX w, round $ getWindowY w)
|
||||
divRes = w ^. config . resolution_factor
|
||||
|
||||
|
||||
cycleResolution :: (Eq a, Num a, Num p) => a -> p
|
||||
|
||||
Reference in New Issue
Block a user