Add options page scrolling
This commit is contained in:
+15
-6
@@ -5,6 +5,7 @@ import Dodge.Data
|
||||
import Dodge.Debug.Terminal
|
||||
--import Dodge.Menu
|
||||
import Dodge.Menu.PushPop
|
||||
import Dodge.WindowLayout
|
||||
|
||||
import Data.Maybe
|
||||
--import Control.Monad
|
||||
@@ -15,8 +16,8 @@ import qualified Data.Text as T
|
||||
|
||||
handlePressedKeyInMenu :: ScreenLayer -> Scancode -> Universe -> IO (Maybe Universe)
|
||||
handlePressedKeyInMenu mState scode = case mState of
|
||||
OptionScreen { _scOptions = mos, _scDefaultEff = defeff}
|
||||
-> optionListToEffects defeff scode mos
|
||||
OptionScreen { _scOptions = mos, _scDefaultEff = defeff, _scOptionsOffset = offset}
|
||||
-> optionListToEffects defeff scode offset mos
|
||||
DisplayScreen {} -> popScreen
|
||||
ColumnsScreen {} -> popScreen
|
||||
WaitScreen {} -> return . Just
|
||||
@@ -35,12 +36,20 @@ handlePressedKeyInMenu mState scode = case mState of
|
||||
optionListToEffects
|
||||
:: (Universe -> IO (Maybe Universe))
|
||||
-> Scancode
|
||||
-> Int
|
||||
-> [MenuOption]
|
||||
-> Universe -> IO (Maybe Universe)
|
||||
optionListToEffects defaulteff sc
|
||||
= fromMaybe defaulteff
|
||||
. lookup sc
|
||||
. concatMap menuOptionToEffects
|
||||
optionListToEffects defaulteff sc offset mops u = case sc of
|
||||
ScancodeSpace -> return . Just
|
||||
. (menuLayers . ix 0 . scOptionsOffset %~ (f . (+ mlines)))
|
||||
$ u
|
||||
_ -> (fromMaybe defaulteff
|
||||
. lookup sc
|
||||
. concatMap menuOptionToEffects $ mops) u
|
||||
where
|
||||
f x | x > length mops = 0
|
||||
| otherwise = x
|
||||
mlines = availableMenuLines $ _config u
|
||||
|
||||
menuOptionToEffects :: MenuOption -> [(Scancode,Universe -> IO (Maybe Universe))]
|
||||
menuOptionToEffects Toggle {_moKey = k, _moEff = eff} = [(k,eff)]
|
||||
|
||||
Reference in New Issue
Block a user