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