Commit before restricting menu options
This commit is contained in:
@@ -74,11 +74,6 @@ handlePressedKey _ scode u = case scode of
|
|||||||
_ -> return $ Just u
|
_ -> return $ Just u
|
||||||
_ -> handlePressedKeyInMenu (head $ _uvScreenLayers u) scode u
|
_ -> handlePressedKeyInMenu (head $ _uvScreenLayers u) scode u
|
||||||
|
|
||||||
--doBackspace :: T.Text -> T.Text
|
|
||||||
--doBackspace t = case T.unsnoc t of
|
|
||||||
-- Nothing -> t
|
|
||||||
-- Just (t', _) -> t'
|
|
||||||
|
|
||||||
handlePressedKeyTerminal :: Int -> Scancode -> World -> World
|
handlePressedKeyTerminal :: Int -> Scancode -> World -> World
|
||||||
handlePressedKeyTerminal tmid scode w = case scode of
|
handlePressedKeyTerminal tmid scode w = case scode of
|
||||||
ScancodeEscape -> w & cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const False
|
ScancodeEscape -> w & cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const False
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ module Dodge.Event.Menu (
|
|||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import qualified Data.Text as T
|
|
||||||
import Dodge.Data.Universe
|
import Dodge.Data.Universe
|
||||||
import Dodge.Debug.Terminal
|
|
||||||
import Dodge.Menu.PushPop
|
|
||||||
import Dodge.WindowLayout
|
import Dodge.WindowLayout
|
||||||
import SDL
|
import SDL
|
||||||
|
|
||||||
@@ -16,13 +13,8 @@ handlePressedKeyInMenu mState scode = case mState of
|
|||||||
OptionScreen{_scOptions = mos, _scDefaultEff = defeff} ->
|
OptionScreen{_scOptions = mos, _scDefaultEff = defeff} ->
|
||||||
optionListToEffects defeff scode mos
|
optionListToEffects defeff scode mos
|
||||||
--DisplayScreen{} -> popScreen
|
--DisplayScreen{} -> popScreen
|
||||||
ColumnsScreen{} -> popScreen
|
|
||||||
-- WaitScreen{} -> return . Just
|
-- WaitScreen{} -> return . Just
|
||||||
InputScreen s help -> case scode of
|
_ -> return . Just
|
||||||
ScancodeEscape -> popScreen
|
|
||||||
ScancodeReturn -> popScreen . applyTerminalString (words $ T.unpack s)
|
|
||||||
ScancodeTab -> autoCompleteTerminal (T.unpack s) help
|
|
||||||
_ -> return . Just
|
|
||||||
|
|
||||||
optionListToEffects ::
|
optionListToEffects ::
|
||||||
(Universe -> IO (Maybe Universe)) ->
|
(Universe -> IO (Maybe Universe)) ->
|
||||||
|
|||||||
+4
-1
@@ -76,7 +76,10 @@ updateUniverse u =
|
|||||||
|
|
||||||
updateUseInput :: Universe -> Universe
|
updateUseInput :: Universe -> Universe
|
||||||
updateUseInput u = case u ^? uvScreenLayers . _head of
|
updateUseInput u = case u ^? uvScreenLayers . _head of
|
||||||
Just InputScreen{} -> doInputScreenInput u
|
Just (InputScreen thetext _) -> doInputScreenInput thetext u
|
||||||
|
Just OptionScreen{} --{_scOptions = mos, _scDefaultEff = defeff} -> u
|
||||||
|
-> u
|
||||||
|
Just ColumnsScreen{} -> u & uvScreenLayers %~ tail
|
||||||
_ -> M.foldlWithKey' updateKeyInGame u (u ^. uvWorld . input . pressedKeys)
|
_ -> M.foldlWithKey' updateKeyInGame u (u ^. uvWorld . input . pressedKeys)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ module Dodge.Update.Input
|
|||||||
, doInputScreenInput
|
, doInputScreenInput
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Dodge.Debug.Terminal
|
||||||
import Dodge.WorldPos
|
import Dodge.WorldPos
|
||||||
import Dodge.Button.Event
|
import Dodge.Button.Event
|
||||||
import Dodge.Inventory
|
import Dodge.Inventory
|
||||||
@@ -16,10 +17,12 @@ import Dodge.Data.Universe
|
|||||||
import SDL
|
import SDL
|
||||||
import LensHelp
|
import LensHelp
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
import qualified Data.Map.Strict as M
|
||||||
|
|
||||||
doInputScreenInput :: Universe -> Universe
|
doInputScreenInput :: T.Text -> Universe -> Universe
|
||||||
doInputScreenInput u = u & uvScreenLayers . _head . scInput %~ (`T.append` thetext)
|
doInputScreenInput s u = u & uvScreenLayers . _head . scInput %~ (`T.append` T.toUpper thetext)
|
||||||
& checkBackspace
|
& checkBackspace
|
||||||
|
& checkEndStatus
|
||||||
where
|
where
|
||||||
thetext = u ^. uvWorld . input . textInput
|
thetext = u ^. uvWorld . input . textInput
|
||||||
checkBackspace = case u ^. uvWorld . input . pressedKeys . at ScancodeBackspace of
|
checkBackspace = case u ^. uvWorld . input . pressedKeys . at ScancodeBackspace of
|
||||||
@@ -27,6 +30,11 @@ doInputScreenInput u = u & uvScreenLayers . _head . scInput %~ (`T.append` thete
|
|||||||
Just LongPress -> f
|
Just LongPress -> f
|
||||||
_ -> id
|
_ -> id
|
||||||
f = uvScreenLayers . _head . scInput %~ doBackspace
|
f = uvScreenLayers . _head . scInput %~ doBackspace
|
||||||
|
pkeys = u ^. uvWorld . input . pressedKeys
|
||||||
|
checkEndStatus
|
||||||
|
| ScancodeReturn `M.member` pkeys = (uvScreenLayers %~ tail) . applyTerminalString (words $ T.unpack s)
|
||||||
|
| ScancodeEscape `M.member` pkeys = uvScreenLayers %~ tail
|
||||||
|
| otherwise = id
|
||||||
|
|
||||||
doBackspace :: T.Text -> T.Text
|
doBackspace :: T.Text -> T.Text
|
||||||
doBackspace t = case T.unsnoc t of
|
doBackspace t = case T.unsnoc t of
|
||||||
|
|||||||
Reference in New Issue
Block a user