Rethink selection lists as intmaps

This commit is contained in:
2023-01-15 23:17:47 +00:00
parent 17734738f6
commit 048135c370
17 changed files with 245 additions and 93 deletions
+8 -3
View File
@@ -5,6 +5,7 @@ module Dodge.Update.Input (
doSubInvRegexInput,
) where
import SelectionIntMap
import qualified Data.Map.Strict as M
import Data.Char
import Dodge.Base.You
@@ -45,8 +46,12 @@ 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 . subInvRegexInput .~ False
| otherwise = u & doTextInputOver (uvWorld . hud . hudElement . subInventory . subInvRegex)
= u & uvWorld . hud . hudElement . subInventory . subInvMap . smRegexInput .~ False
| ScancodeBackspace `M.member` pkeys
&& u ^? uvWorld . hud . hudElement . subInventory . subInvMap . smRegex == Just ""
= u & uvWorld . hud . hudElement . subInventory . subInvMap . smRegexInput .~ False
| otherwise = u & doTextInputOver (uvWorld . hud . hudElement . subInventory . subInvMap . smRegex)
& uvWorld . hud . hudElement . subInventory . subInvMap %~ setShownIntMap
where
pkeys = u ^. uvWorld . input . pressedKeys
@@ -89,7 +94,7 @@ 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 . subInvRegexInput) True uv
ScancodeSlash -> set (uvWorld . hud . hudElement . subInventory . subInvMap . smRegexInput) True uv
-- in fact the whole logic should probably be rethought, oh well
_ -> uv
updateKeyInGame uv sc LongPress = case sc of