Cleanup
This commit is contained in:
@@ -21,7 +21,7 @@ import qualified SDL
|
||||
-- | The AI equivalent for your control.
|
||||
yourControl :: Creature -> World -> World
|
||||
yourControl _ w
|
||||
| inInputFocus w = w
|
||||
| inTextInputFocus w = w
|
||||
| not intopinv =
|
||||
w & cWorld . lWorld . creatures . ix 0 %~ wasdWithAiming w
|
||||
| otherwise =
|
||||
|
||||
+8
-65
@@ -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
|
||||
|
||||
@@ -206,7 +206,7 @@ rotateCamera cfig w
|
||||
| keydown SDL.ScancodeE = rotateCameraBy (-0.025) w
|
||||
| otherwise = ifConfigWallRotate cfig (w ^. input . mouseButtons) w
|
||||
where
|
||||
keydown scode = scode `M.member` _pressedKeys (_input w) && not (inInputFocus w)
|
||||
keydown scode = scode `M.member` _pressedKeys (_input w) && not (inTextInputFocus w)
|
||||
|
||||
zoomFromItem :: ItZoom -> Float
|
||||
zoomFromItem ItZoom{_izMax = zMax, _izMin = zMin, _izFac = zFac} =
|
||||
|
||||
@@ -21,7 +21,6 @@ import Dodge.Data.Combine
|
||||
import Dodge.Data.Universe
|
||||
import Dodge.DisplayInventory
|
||||
import Dodge.Event.Test
|
||||
import Dodge.InputFocus
|
||||
import Dodge.Inventory
|
||||
import Dodge.Inventory.Add
|
||||
import Dodge.ListDisplayParams
|
||||
@@ -39,22 +38,19 @@ import SDL
|
||||
updateUseInputInGame :: Universe -> Universe
|
||||
updateUseInputInGame u = updateFunctionKeys $ case u ^. uvWorld . hud . hudElement of
|
||||
DisplayCarte -> over uvWorld updatePressedButtonsCarte u
|
||||
DisplayInventory{_subInventory = si} -> case si of
|
||||
DisplayInventory{_subInventory = si, _diSelection = disel} -> case si of
|
||||
DisplayTerminal tmid -> updateKeysInTerminal tmid u
|
||||
CombineInventory{_ciSections = sss, _ciSelection = msel}
|
||||
| inSubInvRegex (u ^. uvWorld) ->
|
||||
CombineInventory{_ciSections = sss, _ciSelection = msel@(Just ((-1),_,_))} ->
|
||||
u
|
||||
& uvWorld . hud . hudElement . subInventory
|
||||
%~ docombineregexinput sss msel
|
||||
& uvWorld . worldEventFlags . at CombineInventoryChange ?~ ()
|
||||
_
|
||||
| inInvRegex (u ^. uvWorld) ->
|
||||
_ | disel ^? _Just . _1 == Just (-1) ->
|
||||
u & uvWorld . hud . hudElement
|
||||
%~ dodisplayregexinput diInvFilter diInvFilter (-1)
|
||||
& uvWorld . worldEventFlags . at InventoryChange ?~ ()
|
||||
& uvWorld %~ setInvPosFromSS
|
||||
_
|
||||
| inCloseRegex (u ^. uvWorld) ->
|
||||
_ | disel ^? _Just . _1 == Just 2 ->
|
||||
u & uvWorld . hud . hudElement
|
||||
%~ dodisplayregexinput diCloseFilter diCloseFilter 2
|
||||
& uvWorld . worldEventFlags . at InventoryChange ?~ ()
|
||||
|
||||
Reference in New Issue
Block a user