Tweak combine filtering

This commit is contained in:
2023-01-16 00:57:55 +00:00
parent bb72ec9baa
commit 43e3c1fe4c
6 changed files with 35 additions and 12 deletions
+15 -5
View File
@@ -45,14 +45,18 @@ backspaceInputted u = case u ^. uvWorld . input . pressedKeys . at ScancodeBacks
doSubInvRegexInput :: Universe -> Universe
doSubInvRegexInput u
| any ( (== Just InitialPress) . (`M.lookup` pkeys)) [ScancodeReturn,ScancodeEscape,ScancodeSlash]
= u & uvWorld . hud . hudElement . subInventory . subInvMap . smRegexInput .~ False
| ScancodeBackspace `M.member` pkeys
&& u ^? uvWorld . hud . hudElement . subInventory . subInvMap . smRegex == Just ""
| endkeys || backspacetonothing || endmouse
= u & uvWorld . hud . hudElement . subInventory . subInvMap . smRegexInput .~ False
& uvWorld . hud . hudElement . subInventory . subInvMap %~ initialSelPos
| otherwise = u & doTextInputOver (uvWorld . hud . hudElement . subInventory . subInvMap . smRegex)
& 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 . hud . hudElement . subInventory . subInvMap . smRegex == Just ""
&& ScancodeBackspace `M.lookup` pkeys == Just InitialPress
pkeys = u ^. uvWorld . input . pressedKeys
doInputScreenInput :: String -> Universe -> Universe
@@ -94,7 +98,13 @@ updateKeyInGame uv sc InitialPress = case sc of
ScancodeC -> over uvWorld toggleCombineInv uv
-- the following should be put in a more sensible place
--ScancodeSlash -> set (uvWorld . hud . hudElement . subInventory . subInvRegexInput) True uv
ScancodeSlash -> set (uvWorld . hud . hudElement . subInventory . subInvMap . smRegexInput) True uv
ScancodeSlash -> uv
& uvWorld . hud . hudElement . subInventory . subInvMap . smRegexInput .~ True
& uvWorld . hud . hudElement . subInventory . subInvMap . smSelPos ?~ 0
ScancodeBackspace -> uv
& uvWorld . hud . hudElement . subInventory . subInvMap . smRegexInput .~ True
& uvWorld . hud . hudElement . subInventory . subInvMap . smSelPos ?~ 0
-- in fact the whole logic should probably be rethought, oh well
_ -> uv
updateKeyInGame uv sc LongPress = case sc of