This commit is contained in:
2023-02-17 11:53:54 +00:00
parent c0ef36426a
commit 38fdf51517
2 changed files with 19 additions and 45 deletions
+3 -2
View File
@@ -146,8 +146,9 @@ updateUseInput u = case u ^? uvScreenLayers . _head of
Just (DisplayTerminal tmid) | inTermFocus (_uvWorld u) -> updateKeysInTerminal tmid u
Just (CombineInventory sm)
| inregex sm -> doSubInvRegexInput u
_ | inInvRegex (u ^. uvWorld) -> doInvRegexInput u
_ | inCloseRegex (u ^. uvWorld) -> doCloseRegexInput u
-- _ | inInvRegex (u ^. uvWorld) -> doInvRegexInput u
_ | inInvRegex (u ^. uvWorld) -> doRegexInput (-1) invRegex invRegex u
_ | inCloseRegex (u ^. uvWorld) -> doRegexInput 2 closeRegex closeRegex u
_ -> M.foldlWithKey' updateKeyInGame u pkeys
where
inregex sm = fromMaybe False $ do
+16 -43
View File
@@ -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