Continue work on menu screens

This commit is contained in:
2022-11-04 09:14:32 +00:00
parent c263012b61
commit 054405244f
6 changed files with 28 additions and 66 deletions
+19 -12
View File
@@ -9,7 +9,6 @@ module Dodge.Update (updateUniverse) where
import Dodge.Menu.Option
import Dodge.Data.SelectionList
import Dodge.InputFocus
import Dodge.Event.Menu
import Color
import Control.Applicative
import Data.List
@@ -92,16 +91,8 @@ gotoTerminal w = case _uvScreenLayers w of
(InputScreen{} : _) -> w
_ -> w & uvScreenLayers .:~ InputScreen T.empty "Enter command"
optionScreenUpdates :: Universe -> Universe
optionScreenUpdates u = case u ^? uvScreenLayers . _head of
Just (OptionScreen {_scOptions = mos, _scSelPos = mselpos}) ->
mouseClickSelectionList mos mselpos
$ mouseOverSelectionList
(makeOptionsSelectionList mselpos u mos) u
_ -> u
mouseClickSelectionList :: [MenuOption] -> Maybe Int -> Universe -> Universe
mouseClickSelectionList mos mi u = case u ^. uvWorld . input . mouseButtons . at ButtonLeft of
mouseClickOptionsList :: [MenuOption] -> Maybe Int -> Universe -> Universe
mouseClickOptionsList mos mi u = case u ^. uvWorld . input . mouseButtons . at ButtonLeft of
Just False -> fromMaybe u $ do
i <- mi
mo <- mos !? i
@@ -127,7 +118,8 @@ mouseOverSelectionList sl u
updateUseInput :: Universe -> Universe
updateUseInput u = case u ^? uvScreenLayers . _head of
Just (InputScreen thetext _) -> doInputScreenInput thetext u
Just OptionScreen{_scOptions = mos, _scDefaultEff = defeff} -> optionScreenUpdates . menuWheelEvents $ u
Just OptionScreen{_scOptions = mos, _scDefaultEff = defeff, _scOptionFlag = flag, _scSelPos = mselpos}
-> optionScreenUpdate mos defeff flag mselpos u
-- foldl' (\u' scode -> optionListToEffects defeff scode mos u') u (M.keys $ M.filter (== InitialPress) pkeys)
Just ColumnsScreen{} -> u & uvScreenLayers %~ tail
_ -> case u ^? uvWorld . cWorld . lWorld . hud . hudElement . subInventory of
@@ -136,6 +128,21 @@ updateUseInput u = case u ^? uvScreenLayers . _head of
where
pkeys = u ^. uvWorld . input . pressedKeys
optionScreenUpdate :: [MenuOption] -> (Universe -> Universe) -> OptionScreenFlag -> Maybe Int
-> Universe -> Universe
optionScreenUpdate mos defeff _ mselpos u =
optionScreenDefEff defeff
. mouseClickOptionsList mos mselpos
. mouseOverSelectionList
(makeOptionsSelectionList mselpos u mos)
$ menuWheelEvents
u
optionScreenDefEff :: (Universe -> Universe) -> Universe -> Universe
optionScreenDefEff f u = case u ^. uvWorld . input . pressedKeys . at ScancodeEscape of
Just InitialPress -> f u
_ -> u
updateUniverseLast :: Universe -> Universe
updateUniverseLast =
over uvWorld (input . mouseButtons . each .~ True) -- to determine if the mouse button is held