Cleanup
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
All good (615 modules, at 18:14:34)
|
||||
All good (615 modules, at 18:28:18)
|
||||
|
||||
@@ -28,6 +28,7 @@ import Geometry
|
||||
import LensHelp
|
||||
import SDL
|
||||
|
||||
-- might not need the full universe here
|
||||
updateUseInputInGame :: Universe -> Universe
|
||||
updateUseInputInGame u = case u ^. uvWorld . hud . hudElement of
|
||||
DisplayCarte -> over uvWorld updatePressedButtonsCarte u
|
||||
@@ -40,7 +41,8 @@ updateUseInputInGame u = case u ^. uvWorld . hud . hudElement of
|
||||
u & uvWorld . cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const True
|
||||
CombineInventory{_ciSections = sss}
|
||||
| inSubInvRegex (u ^. uvWorld) ->
|
||||
u & uvWorld . hud . hudElement . subInventory . ciSections %~ doRegexInput u (-1)
|
||||
u & uvWorld . hud . hudElement . subInventory . ciSections
|
||||
%~ doRegexInput (u ^. uvWorld . input) (-1)
|
||||
& uvWorld . worldEventFlags . at CombineInventoryChange ?~ ()
|
||||
| lbinitialpress ->
|
||||
(uvWorld . worldEventFlags . at InventoryChange ?~ ()) . maybeExitCombine $
|
||||
@@ -48,12 +50,12 @@ updateUseInputInGame u = case u ^. uvWorld . hud . hudElement of
|
||||
& uvWorld . worldEventFlags . at CombineInventoryChange ?~ ()
|
||||
_
|
||||
| inInvRegex (u ^. uvWorld) ->
|
||||
u & uvWorld . hud . hudElement . diSections %~ doRegexInput u (-1)
|
||||
u & uvWorld . hud . hudElement . diSections %~ doRegexInput (u ^. uvWorld . input) (-1)
|
||||
& uvWorld . worldEventFlags . at InventoryChange ?~ ()
|
||||
& uvWorld %~ setInvPosFromSS
|
||||
_
|
||||
| inCloseRegex (u ^. uvWorld) ->
|
||||
u & uvWorld . hud . hudElement . diSections %~ doRegexInput u 2
|
||||
u & uvWorld . hud . hudElement . diSections %~ doRegexInput (u ^. uvWorld . input) 2
|
||||
& uvWorld . worldEventFlags . at InventoryChange ?~ ()
|
||||
& uvWorld %~ setInvPosFromSS
|
||||
_ -> M.foldlWithKey' updateKeyInGame u pkeys
|
||||
@@ -89,7 +91,7 @@ updatePressedButtonsCarte' pkeys w
|
||||
|
||||
updateKeysInTerminal :: Int -> Universe -> Universe
|
||||
updateKeysInTerminal tmid u =
|
||||
u & doTextInputOver (uvWorld . cWorld . lWorld . terminals . ix tmid . tmInput . tiText)
|
||||
u & doTextInputOverUniverse (uvWorld . cWorld . lWorld . terminals . ix tmid . tmInput . tiText)
|
||||
& checkEndStatus
|
||||
where
|
||||
pkeys = u ^. uvWorld . input . pressedKeys
|
||||
@@ -130,11 +132,11 @@ updateLongPressInGame uv sc = case sc of
|
||||
ScancodeSpace -> over uvWorld spaceAction uv
|
||||
_ -> uv
|
||||
|
||||
doRegexInput :: Universe -> Int -> SelectionSections a -> SelectionSections a
|
||||
doRegexInput u i sss
|
||||
doRegexInput :: Input -> Int -> SelectionSections a -> SelectionSections a
|
||||
doRegexInput inp i sss
|
||||
| backspacetonothing || escapekey = endregex i 0
|
||||
| endkeys || endmouse = endregex (i + 1) (j -1)
|
||||
| otherwise = sss & doTextInputOver' u (sssExtra . sssFilters . ix i . _Just)
|
||||
| otherwise = sss & doTextInputOver inp (sssExtra . sssFilters . ix i . _Just)
|
||||
where
|
||||
endregex a b =
|
||||
sss
|
||||
@@ -149,11 +151,11 @@ doRegexInput u i sss
|
||||
any
|
||||
((== Just InitialPress) . (`M.lookup` pkeys))
|
||||
[ScancodeReturn, ScancodeSlash]
|
||||
endmouse = (Just 0 ==) $ u ^? uvWorld . input . mouseButtons . ix ButtonLeft
|
||||
endmouse = (Just 0 ==) $ inp ^? mouseButtons . ix ButtonLeft
|
||||
backspacetonothing =
|
||||
sss ^? sssExtra . sssFilters . ix i . _Just == Just ""
|
||||
&& ScancodeBackspace `M.lookup` pkeys == Just InitialPress
|
||||
pkeys = u ^. uvWorld . input . pressedKeys
|
||||
pkeys = inp ^. pressedKeys
|
||||
|
||||
updateBackspaceRegex :: World -> World
|
||||
updateBackspaceRegex w = case di ^? subInventory of
|
||||
|
||||
@@ -24,7 +24,7 @@ updateUseInputOnScreen sl = case sl of
|
||||
|
||||
doInputScreenInput :: String -> Universe -> Universe
|
||||
doInputScreenInput s u =
|
||||
u & doTextInputOver (uvScreenLayers . _head . scInput)
|
||||
u & doTextInputOverUniverse (uvScreenLayers . _head . scInput)
|
||||
& checkEndStatus
|
||||
where
|
||||
ispressed = (`M.member` (u ^. uvWorld . input . pressedKeys))
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
module Dodge.Update.Input.Text (
|
||||
doTextInputOverUniverse,
|
||||
doTextInputOver,
|
||||
doTextInputOver',
|
||||
) where
|
||||
|
||||
import Data.Either
|
||||
--import Data.Char
|
||||
import Data.Char
|
||||
import Dodge.Data.Universe
|
||||
import LensHelp
|
||||
import SDL
|
||||
|
||||
doTextInputOver :: ASetter' Universe String -> Universe -> Universe
|
||||
doTextInputOver p u = doTextInputOver' u p u
|
||||
doTextInputOverUniverse :: ASetter' Universe String -> Universe -> Universe
|
||||
doTextInputOverUniverse p u = doTextInputOver (u ^. uvWorld . input) p u
|
||||
|
||||
doTextInputOver' :: Universe -> ASetter' a String -> a -> a
|
||||
doTextInputOver' u p x =
|
||||
--x & p %~ (++ map toUpper (rights str))
|
||||
x & p %~ (++ rights str)
|
||||
doTextInputOver :: Input -> ASetter' a String -> a -> a
|
||||
doTextInputOver u p x =
|
||||
x & p %~ (++ map toUpper (rights str))
|
||||
--x & p %~ (++ rights str)
|
||||
& checkBackspace
|
||||
where
|
||||
str = u ^. uvWorld . input . textInput
|
||||
str = u ^. textInput
|
||||
checkBackspace
|
||||
| backspaceInputted u = p %~ doBackspace
|
||||
| otherwise = id
|
||||
|
||||
backspaceInputted :: Universe -> Bool
|
||||
backspaceInputted u = case u ^. uvWorld . input . pressedKeys . at ScancodeBackspace of
|
||||
backspaceInputted :: Input -> Bool
|
||||
backspaceInputted u = case u ^. pressedKeys . at ScancodeBackspace of
|
||||
Just InitialPress -> True
|
||||
Just LongPress -> True
|
||||
_ -> False
|
||||
|
||||
Reference in New Issue
Block a user