Work towards unifying all in game input

This commit is contained in:
2023-02-21 00:37:26 +00:00
parent 7b9b1d1799
commit dee7472d31
5 changed files with 127 additions and 37 deletions
+10 -13
View File
@@ -59,6 +59,9 @@ updateUseInputInGame h u = case h of
CombineInventory {_ciSections = FilterableSections {_fssSections = sss}}
| inSubInvRegex (u ^. uvWorld) -> u & uvWorld . hud . hudElement . subInventory . ciSections %~ doRegexInput u (-1)
| lbinitialpress -> maybeExitCombine $ over uvWorld (tryCombine sss) u
-- _ -> case regexFocus w of
-- Nothing -> M.foldlWithKey' updateKeyInGame u pkeys
-- Just (filtpoint,selpoint,i) -> u & uvWorld . p %~ doRegexInput
_ | inInvRegex (u ^. uvWorld) -> u & uvWorld . hud . hudElement . diSections %~ doRegexInput u (-1)
_ | inCloseRegex (u ^. uvWorld) -> u & uvWorld . hud . hudElement . diSections %~ doRegexInput u 2
_ -> M.foldlWithKey' updateKeyInGame u pkeys
@@ -82,13 +85,6 @@ maybeExitCombine u
doTextInputOver :: ASetter' Universe String -> Universe -> Universe
doTextInputOver p u = doTextInputOver' u p u
-- u & p %~ (++ map toUpper thetext)
-- & checkBackspace
-- where
-- thetext = u ^. uvWorld . input . textInput
-- checkBackspace
-- | backspaceInputted u = p %~ doBackspace
-- | otherwise = id
doTextInputOver' :: Universe -> ASetter' a String -> a -> a
doTextInputOver' u p x =
@@ -219,21 +215,22 @@ updateEnterRegex w = case w ^? hud . hudElement . subInventory of
| secfocus (-1) 0 ->
w & cWorld . lWorld . creatures . ix 0 . crManipulation . manObject
.~ InInventory SortInventory
& hud . hudElement . diSections . fssFilters . ix (-1) %~ enterregex
& hud . hudElement . diSections %~ enterregex (-1)
Just NoSubInventory
| secfocus 2 3 ->
w & cWorld . lWorld . creatures . ix 0 . crManipulation . manObject .~ InNearby SortNearby
& hud . hudElement . diSections . fssFilters . ix 2 %~ enterregex
Just CombineInventory{} -> w & hud . hudElement . subInventory . ciSections . fssFilters . ix (-1)
%~ enterregex
& hud . hudElement . diSections %~ enterregex 2
Just CombineInventory{} -> w & hud . hudElement . subInventory . ciSections %~ enterregex (-1)
_ -> w
where
di = w ^. hud . hudElement
secfocus a b = fromMaybe False $ do
i <- di ^? diSections . fssSections . sssSelPos . _Just . _1
return $ i == a || i == b
enterregex Nothing = Just ""
enterregex x = x
enterregex x fss = fss & fssFilters . ix x %~ f
& fssSections . sssSelPos ?~ (x,0)
f Nothing = Just ""
f x = x
--overSection :: (SelectionSection a -> SelectionSection a) -> SelectionSections a -> SelectionSections a
--overSection f sss = fromMaybe sss $ do