This commit is contained in:
2024-11-25 23:13:54 +00:00
parent 6aea049b80
commit f91a5cebb5
5 changed files with 98 additions and 218 deletions
+8 -65
View File
@@ -1,11 +1,7 @@
module Dodge.InputFocus (
inInvRegex,
inCloseRegex,
inSubInvRegex,
inputFocus,
inInputFocus,
-- regexScope,
-- regexFocus,
-- inInvRegex,
-- inCloseRegex,
inTextInputFocus,
) where
import Control.Monad
@@ -13,52 +9,17 @@ import Data.Maybe
import Dodge.Data.World
import LensHelp
--regexScope ::
-- (Applicative f) =>
-- World ->
-- Maybe ((SSSExtra -> f SSSExtra) -> HUDElement -> f HUDElement, Int)
--regexScope w = case w ^? hud . hudElement . subInventory of
-- Just NoSubInventory{} -> case he ^? diSelection . _Just of
-- Just (-1, _) -> di (-1)
-- Just (0, _) -> di (-1)
-- Just (2, _) -> di 2
-- Just (3, _) -> di 2
-- _ -> Nothing
-- Just CombineInventory{} ->
-- Just (subInventory . ciSections . sssExtra, -1)
-- _ -> Nothing
-- where
-- di x = Just (diSections . sssExtra, x)
-- he = w ^. hud . hudElement
--regexFocus ::
-- (Applicative f) =>
-- World ->
-- Maybe
-- ((SSSExtra -> f SSSExtra) -> HUDElement -> f HUDElement, Int)
--regexFocus w = case w ^? hud . hudElement . subInventory of
-- Just NoSubInventory{} -> case he ^? diSelection . _Just of
-- Just (-1, _) -> di (-1)
-- Just (2, _) -> di 2
-- _ -> Nothing
-- Just CombineInventory{} ->
-- Just (subInventory . ciSections . sssExtra, -1)
-- _ -> Nothing
-- where
-- di x = Just (diSections . sssExtra, x)
-- he = w ^. hud . hudElement
inInputFocus :: World -> Bool
inInputFocus = isJust . inputFocusI
inTextInputFocus :: World -> Bool
inTextInputFocus = isJust . inputFocusI
inputFocusI :: World -> Maybe ((String -> Identity String) -> World -> Identity World)
inputFocusI = inputFocus
inputFocusI = textInputFocus
inputFocus ::
textInputFocus ::
Applicative f =>
World ->
Maybe ((String -> f String) -> World -> f World)
inputFocus w = case w ^? hud . hudElement . subInventory of
textInputFocus w = case w ^? hud . hudElement . subInventory of
Just NoSubInventory{} -> case he ^? diSelection . _Just . _1 of
Just (-1) -> Just $ hud . hudElement . diInvFilter . _Just
Just 2 -> Just $ hud . hudElement . diCloseFilter . _Just
@@ -74,21 +35,3 @@ inputFocus w = case w ^? hud . hudElement . subInventory of
where
he = w ^. hud . hudElement
inTopRegex :: Int -> World -> Bool
inTopRegex x w = fromMaybe False $ do
i <- w ^? hud . hudElement . diSelection . _Just . _1
return $ i == x
inInvRegex :: World -> Bool
inInvRegex = inTopRegex (-1)
inCloseRegex :: World -> Bool
inCloseRegex = inTopRegex 2
inSubInvRegex :: World -> Bool
inSubInvRegex w = fromMaybe False $ do
i <- w ^? hud . hudElement . subInventory . ciSelection . _Just . _1
return $ i == (-1)
--inputFocus :: World -> Bool
--inputFocus w = inTermFocus w || inSubInvRegex w || inInvRegex w || inCloseRegex w