Reorganise update-input-gamestate structure
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
module Dodge.Update.Input.Text (
|
||||
doTextInputOver,
|
||||
doTextInputOver',
|
||||
) where
|
||||
|
||||
import Data.Char
|
||||
import Dodge.Data.Universe
|
||||
import LensHelp
|
||||
import SDL
|
||||
|
||||
doTextInputOver :: ASetter' Universe String -> Universe -> Universe
|
||||
doTextInputOver p u = doTextInputOver' u p u
|
||||
|
||||
doTextInputOver' :: Universe -> ASetter' a String -> a -> a
|
||||
doTextInputOver' u p x =
|
||||
x & p %~ (++ map toUpper str)
|
||||
& checkBackspace
|
||||
where
|
||||
str = u ^. uvWorld . input . textInput
|
||||
checkBackspace
|
||||
| backspaceInputted u = p %~ doBackspace
|
||||
| otherwise = id
|
||||
|
||||
backspaceInputted :: Universe -> Bool
|
||||
backspaceInputted u = case u ^. uvWorld . input . pressedKeys . at ScancodeBackspace of
|
||||
Just InitialPress -> True
|
||||
Just LongPress -> True
|
||||
_ -> False
|
||||
|
||||
doBackspace :: String -> String
|
||||
doBackspace [] = []
|
||||
doBackspace s = init s
|
||||
Reference in New Issue
Block a user