Commit before restricting menu options

This commit is contained in:
2022-10-30 13:16:59 +00:00
parent 6123795c7a
commit 11e873ea48
4 changed files with 15 additions and 17 deletions
+10 -2
View File
@@ -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