Move SSSExtra out of SelectionSections

This commit is contained in:
2024-10-25 21:55:09 +01:00
parent 069392bd33
commit a20fc48eaa
8 changed files with 207 additions and 181 deletions
+37 -37
View File
@@ -5,8 +5,8 @@ module Dodge.InputFocus (
inSubInvRegex,
inputFocus,
inInputFocus,
regexScope,
regexFocus,
-- regexScope,
-- regexFocus,
) where
import Control.Monad
@@ -22,40 +22,40 @@ inTermFocus w = fromMaybe False $ do
connectionstatus <- w ^? cWorld . lWorld . terminals . ix tmid . tmStatus
return $ hasfocus && connectionstatus == TerminalReady
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
--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
--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
@@ -73,7 +73,7 @@ inputFocus w = case w ^? hud . hudElement . subInventory of
Just (2, _) -> di 2
_ -> Nothing
Just CombineInventory{} -> case he ^? subInventory . ciSelection . _Just of
Just (-1, _) -> Just $ hud . hudElement . subInventory . ciSections . sssExtra . sssFilters . ix (-1) . _Just
Just (-1, _) -> Just $ hud . hudElement . subInventory . ciFilters . ix (-1) . _Just
_ -> Nothing
Just DisplayTerminal{_termID = tmid} -> do
hasfocus <- w ^? cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus
@@ -82,7 +82,7 @@ inputFocus w = case w ^? hud . hudElement . subInventory of
return $ cWorld . lWorld . terminals . ix tmid . tmInput . tiText
_ -> Nothing
where
di x = Just $ hud . hudElement . diSections . sssExtra . sssFilters . ix x . _Just
di x = Just $ hud . hudElement . diFilters . ix x . _Just
he = w ^. hud . hudElement
inTopRegex :: Int -> World -> Bool