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 (DisplayTerminal tmid) | inTermFocus (_uvWorld u) -> updateKeysInTerminal tmid u
Just (CombineInventory sm) Just (CombineInventory sm)
| inregex sm -> doSubInvRegexInput u | inregex sm -> doSubInvRegexInput u
_ | inInvRegex (u ^. uvWorld) -> doInvRegexInput u -- _ | inInvRegex (u ^. uvWorld) -> doInvRegexInput u
_ | inCloseRegex (u ^. uvWorld) -> doCloseRegexInput u _ | inInvRegex (u ^. uvWorld) -> doRegexInput (-1) invRegex invRegex u
_ | inCloseRegex (u ^. uvWorld) -> doRegexInput 2 closeRegex closeRegex u
_ -> M.foldlWithKey' updateKeyInGame u pkeys _ -> M.foldlWithKey' updateKeyInGame u pkeys
where where
inregex sm = fromMaybe False $ do inregex sm = fromMaybe False $ do
+16 -43
View File
@@ -3,10 +3,10 @@ module Dodge.Update.Input (
updateKeysInTerminal, updateKeysInTerminal,
doInputScreenInput, doInputScreenInput,
doSubInvRegexInput, doSubInvRegexInput,
doInvRegexInput, doRegexInput,
doCloseRegexInput,
) where ) where
import Data.Monoid (First)
import Dodge.Inventory import Dodge.Inventory
import Data.Maybe import Data.Maybe
import Dodge.DisplayInventory import Dodge.DisplayInventory
@@ -75,59 +75,32 @@ doSubInvRegexInput u
&& ScancodeBackspace `M.lookup` pkeys == Just InitialPress && ScancodeBackspace `M.lookup` pkeys == Just InitialPress
pkeys = u ^. uvWorld . input . pressedKeys pkeys = u ^. uvWorld . input . pressedKeys
doCloseRegexInput :: Universe -> Universe doRegexInput :: Int
doCloseRegexInput u -> ((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 | backspacetonothing
= u = u
& uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . closeRegex .~ Nothing & uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . crregex .~ Nothing
& uvWorld . hud . hudElement . diSections %~ & uvWorld . hud . hudElement . diSections %~
( ssSetCursor (ssLookupGT 0 2) ( ssSetCursor (ssLookupGT i 0)
. (overSection (ssItems . at 2 .~ Nothing)) . (overSection (ssItems . at i .~ Nothing))
) )
& uvWorld %~ setInvPosFromSS & uvWorld %~ setInvPosFromSS
-- & uvWorld . hud . hudElement . diSections %~ setShownIntMap
| endkeys || endmouse = u | 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 | otherwise = u & doTextInputOver
(uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . closeRegex . _Just) (uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . crregex . _Just)
-- & uvWorld . hud . hudElement . subInventory . subInvMap %~ setShownIntMap
where where
endkeys = any endkeys = any
( (== Just InitialPress) . (`M.lookup` pkeys)) ( (== Just InitialPress) . (`M.lookup` pkeys))
[ScancodeReturn,ScancodeEscape,ScancodeSlash] [ScancodeReturn,ScancodeEscape,ScancodeSlash]
endmouse = Just True == (u ^? uvWorld . input . mouseButtons . ix ButtonLeft) endmouse = Just True == (u ^? uvWorld . input . mouseButtons . ix ButtonLeft)
backspacetonothing = u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . closeRegex . _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
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 ""
&& ScancodeBackspace `M.lookup` pkeys == Just InitialPress && ScancodeBackspace `M.lookup` pkeys == Just InitialPress
pkeys = u ^. uvWorld . input . pressedKeys pkeys = u ^. uvWorld . input . pressedKeys