Cleanup
This commit is contained in:
+16
-43
@@ -3,10 +3,10 @@ module Dodge.Update.Input (
|
||||
updateKeysInTerminal,
|
||||
doInputScreenInput,
|
||||
doSubInvRegexInput,
|
||||
doInvRegexInput,
|
||||
doCloseRegexInput,
|
||||
doRegexInput,
|
||||
) where
|
||||
|
||||
import Data.Monoid (First)
|
||||
import Dodge.Inventory
|
||||
import Data.Maybe
|
||||
import Dodge.DisplayInventory
|
||||
@@ -75,59 +75,32 @@ doSubInvRegexInput u
|
||||
&& ScancodeBackspace `M.lookup` pkeys == Just InitialPress
|
||||
pkeys = u ^. uvWorld . input . pressedKeys
|
||||
|
||||
doCloseRegexInput :: Universe -> Universe
|
||||
doCloseRegexInput u
|
||||
doRegexInput :: Int
|
||||
-> ((Maybe String -> Identity (Maybe String))
|
||||
-> Manipulation -> Identity Manipulation)
|
||||
-> ((Maybe String
|
||||
-> Const (First String) (Maybe String))
|
||||
-> Manipulation -> Const (First String) Manipulation)
|
||||
-> Universe
|
||||
-> Universe
|
||||
doRegexInput i crregex crregex' u
|
||||
| backspacetonothing
|
||||
= u
|
||||
& uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . closeRegex .~ Nothing
|
||||
& uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . crregex .~ Nothing
|
||||
& uvWorld . hud . hudElement . diSections %~
|
||||
( ssSetCursor (ssLookupGT 0 2)
|
||||
. (overSection (ssItems . at 2 .~ Nothing))
|
||||
( ssSetCursor (ssLookupGT i 0)
|
||||
. (overSection (ssItems . at i .~ Nothing))
|
||||
)
|
||||
& uvWorld %~ setInvPosFromSS
|
||||
-- & uvWorld . hud . hudElement . diSections %~ setShownIntMap
|
||||
| endkeys || endmouse = u
|
||||
-- = u & uvWorld . hud . hudElement . diSections %~ initialSelPos
|
||||
-- | otherwise = u & uvWorld . hud . hudElement . diSections %~
|
||||
-- --overSection (doTextInputOver' u (ssRegex . regexString))
|
||||
-- overSection (id)
|
||||
| otherwise = u & doTextInputOver
|
||||
(uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . closeRegex . _Just)
|
||||
-- & uvWorld . hud . hudElement . subInventory . subInvMap %~ setShownIntMap
|
||||
(uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . crregex . _Just)
|
||||
where
|
||||
endkeys = any
|
||||
( (== Just InitialPress) . (`M.lookup` pkeys))
|
||||
[ScancodeReturn,ScancodeEscape,ScancodeSlash]
|
||||
endmouse = Just True == (u ^? uvWorld . input . mouseButtons . ix ButtonLeft)
|
||||
backspacetonothing = u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . closeRegex . _Just == Just ""
|
||||
&& ScancodeBackspace `M.lookup` pkeys == Just InitialPress
|
||||
pkeys = u ^. uvWorld . input . pressedKeys
|
||||
|
||||
doInvRegexInput :: Universe -> Universe
|
||||
doInvRegexInput u
|
||||
| backspacetonothing
|
||||
= u
|
||||
& uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . invRegex .~ Nothing
|
||||
& uvWorld . hud . hudElement . diSections %~
|
||||
( ssSetCursor (ssLookupGT 0 (-1))
|
||||
. (overSection (ssItems . at (-1) .~ Nothing))
|
||||
)
|
||||
& uvWorld %~ setInvPosFromSS
|
||||
-- & uvWorld . hud . hudElement . diSections %~ setShownIntMap
|
||||
| endkeys || endmouse = u
|
||||
-- = u & uvWorld . hud . hudElement . diSections %~ initialSelPos
|
||||
-- | otherwise = u & uvWorld . hud . hudElement . diSections %~
|
||||
-- --overSection (doTextInputOver' u (ssRegex . regexString))
|
||||
-- overSection (id)
|
||||
| otherwise = u & doTextInputOver
|
||||
(uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . invRegex . _Just)
|
||||
-- & uvWorld . hud . hudElement . subInventory . subInvMap %~ setShownIntMap
|
||||
where
|
||||
endkeys = any
|
||||
( (== Just InitialPress) . (`M.lookup` pkeys))
|
||||
[ScancodeReturn,ScancodeEscape,ScancodeSlash]
|
||||
endmouse = Just True == (u ^? uvWorld . input . mouseButtons . ix ButtonLeft)
|
||||
backspacetonothing = u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . invRegex . _Just == Just ""
|
||||
backspacetonothing = u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . crregex' . _Just == Just ""
|
||||
&& ScancodeBackspace `M.lookup` pkeys == Just InitialPress
|
||||
pkeys = u ^. uvWorld . input . pressedKeys
|
||||
|
||||
|
||||
Reference in New Issue
Block a user