Allow for scrolling in combine regex

This commit is contained in:
2023-02-13 23:15:34 +00:00
parent 8b39a99194
commit 9dd4c53316
10 changed files with 46 additions and 37 deletions
+9 -8
View File
@@ -47,20 +47,19 @@ backspaceInputted u = case u ^. uvWorld . input . pressedKeys . at ScancodeBacks
doSubInvRegexInput :: Universe -> Universe
doSubInvRegexInput u
| backspacetonothing
= u & uvWorld . hud . hudElement . subInventory . subInvMap . smRegex %~ const NoSMRegex
= u & uvWorld . hud . hudElement . subInventory . subInvMap . smRegex .~ Nothing
& uvWorld . hud . hudElement . subInventory . subInvMap %~ initialSelPos
& uvWorld . hud . hudElement . subInventory . subInvMap %~ setShownIntMap
| endkeys || endmouse
= u & uvWorld . hud . hudElement . subInventory . subInvMap . smRegex . smrInput %~ const False
& uvWorld . hud . hudElement . subInventory . subInvMap %~ initialSelPos
| otherwise = u & doTextInputOver (uvWorld . hud . hudElement . subInventory . subInvMap . smRegex. smrString)
= u & uvWorld . hud . hudElement . subInventory . subInvMap %~ initialSelPos
| otherwise = u & doTextInputOver (uvWorld . hud . hudElement . subInventory . subInvMap . smRegex . _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 . hud . hudElement . subInventory . subInvMap . smRegex . smrString == Just ""
backspacetonothing = u ^? uvWorld . hud . hudElement . subInventory . subInvMap . smRegex . _Just == Just ""
&& ScancodeBackspace `M.lookup` pkeys == Just InitialPress
pkeys = u ^. uvWorld . input . pressedKeys
@@ -106,16 +105,18 @@ updateKeyInGame uv sc InitialPress = case sc of
ScancodeSlash -> uv
& uvWorld . hud . hudElement . subInventory . subInvMap . smRegex %~ enterregex
& uvWorld . hud . hudElement . subInventory . subInvMap . smSelPos ?~ 0
& uvWorld . hud . hudElement . subInventory . subInvMap %~ setShownIntMap
ScancodeBackspace -> uv
& uvWorld . hud . hudElement . subInventory . subInvMap . smRegex %~ enternonzeroregex
& uvWorld . hud . hudElement . subInventory . subInvMap . smSelPos ?~ 0
& uvWorld . hud . hudElement . subInventory . subInvMap %~ setShownIntMap
-- in fact the whole logic should probably be rethought, oh well
_ -> uv
where
enterregex NoSMRegex = SMRegex "" True
enterregex (SMRegex str _) = SMRegex str True
enternonzeroregex (SMRegex (x:xs) _) = SMRegex (init (x:xs)) True
enterregex Nothing = Just ""
enterregex (Just str) = Just str
enternonzeroregex (Just (x:xs)) = Just (init (x:xs))
enternonzeroregex smr = smr
updateKeyInGame uv sc LongPress = case sc of
ScancodeF -> over uvWorld youDropItem uv
+1 -3
View File
@@ -38,12 +38,10 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
| invKeyDown -> stopSoundFrom (CrReloadSound 0) $ changeAugInvSel yi w
| rbDown -> w & changeTweakParam mi yi
| otherwise -> w & moveTweakSel yi
DisplayInventory {_subInventory = CombineInventory sm}
| regexnotinput $ _smRegex sm -> w & moveCombineSel yi
DisplayInventory {_subInventory = CombineInventory {}} -> w & moveCombineSel yi
DisplayInventory {_subInventory = DisplayTerminal tmid} -> terminalWheelEvent yi tmid w
_ -> w
where
regexnotinput smr = not $ smr ^? smrInput == Just True
y = fromIntegral yi
numLocs = (fst . IM.findMax $ (w ^. cWorld . lWorld . seenLocations)) + 1
rbDown = ButtonRight `M.member` _mouseButtons (_input w)
+2 -6
View File
@@ -30,11 +30,8 @@ updateUsingInput w = case w ^. hud . hudElement of
pressedMBEffects :: SubInventory -> M.Map MouseButton Bool -> World -> World
pressedMBEffects subinv pkeys w = case subinv of
NoSubInventory -> pressedMBEffectsNoInventory pkeys w
CombineInventory SelectionIntMap{_smSelPos = mi, _smRegex = smr}
| lbinitialpress && regexnotinput smr -> maybeexitcombine (maybe id doCombine mi w)
CombineInventory SelectionIntMap{}
| lbinitialpress -> w & hud . hudElement . subInventory . subInvMap . smRegex. smrInput
%~ const False
CombineInventory SelectionIntMap{_smSelPos = mi}
| lbinitialpress -> maybeexitcombine (maybe id doCombine mi w)
DisplayTerminal tmid
| lbinitialpress && inTermFocus w ->
doTerminalEffectLB (w ^?! cWorld . lWorld . terminals . ix tmid) w
@@ -42,7 +39,6 @@ pressedMBEffects subinv pkeys w = case subinv of
w & cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const True
_ -> w
where
regexnotinput smr = not $ smr ^? smrInput == Just True
lbinitialpress = pkeys ^? ix ButtonLeft == Just False
maybeexitcombine w'
| ButtonRight `M.member` _mouseButtons (_input w) =