Reorganise/cleanup
This commit is contained in:
+21
-23
@@ -56,7 +56,7 @@ updateUseInputInGame h u = case h of
|
||||
| inTermFocus (_uvWorld u) -> updateKeysInTerminal tmid u
|
||||
| lbinitialpress ->
|
||||
u & uvWorld . cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const True
|
||||
CombineInventory {_ciSections = FilterableSections {_fssSections = sss}}
|
||||
CombineInventory {_ciSections = sss}
|
||||
| inSubInvRegex (u ^. uvWorld) -> u & uvWorld . hud . hudElement . subInventory . ciSections %~ doRegexInput u (-1)
|
||||
| lbinitialpress -> maybeExitCombine $ over uvWorld (tryCombine sss) u
|
||||
-- _ -> case regexFocus w of
|
||||
@@ -73,7 +73,7 @@ updateUseInputInGame h u = case h of
|
||||
|
||||
tryCombine :: SelectionSections CombinableItem -> World -> World
|
||||
tryCombine sss w = fromMaybe w $ do
|
||||
(i,j) <- sss ^? sssSelPos . _Just
|
||||
(i,j) <- sss ^? sssExtra . sssSelPos . _Just
|
||||
CombinableItem is it _ <- sss ^? sssSections . ix i . ssItems . ix j . siPayload
|
||||
return $ createAndSelectItem it $ foldr (rmInvItem 0) w (sort is)
|
||||
|
||||
@@ -106,22 +106,20 @@ backspaceInputted u = case u ^. uvWorld . input . pressedKeys . at ScancodeBacks
|
||||
Just LongPress -> True
|
||||
_ -> False
|
||||
|
||||
doRegexInput :: Universe -> Int -> FilterableSections a -> FilterableSections a
|
||||
doRegexInput u i fss
|
||||
doRegexInput :: Universe -> Int -> SelectionSections a -> SelectionSections a
|
||||
doRegexInput u i sss
|
||||
| backspacetonothing || escapekey = endregex i 0
|
||||
| endkeys || endmouse = endregex (i + 1) (j -1)
|
||||
| otherwise = fss & doTextInputOver' u (fssFilters . ix i . _Just)
|
||||
| otherwise = sss & doTextInputOver' u (sssExtra . sssFilters . ix i . _Just)
|
||||
where
|
||||
endregex a b =
|
||||
fss
|
||||
& fssFilters . ix i .~ Nothing
|
||||
& fssSections
|
||||
%~ ( ssSetCursor (ssLookupDown a b)
|
||||
. (sssSections . ix i . ssItems .~ mempty)
|
||||
)
|
||||
sss
|
||||
& sssExtra . sssFilters . ix i .~ Nothing
|
||||
& sssSections . ix i . ssItems .~ mempty
|
||||
& ssSetCursor (ssLookupDown a b)
|
||||
-- & uvWorld %~ setInvPosFromSS
|
||||
j = fromMaybe 0 $ do
|
||||
itms <- fss ^? fssSections . sssSections . ix (i + 1) . ssItems
|
||||
itms <- sss ^? sssSections . ix (i + 1) . ssItems
|
||||
fst <$> IM.lookupMin itms
|
||||
escapekey = ScancodeEscape `M.lookup` pkeys == Just InitialPress
|
||||
endkeys =
|
||||
@@ -130,7 +128,7 @@ doRegexInput u i fss
|
||||
[ScancodeReturn, ScancodeSlash]
|
||||
endmouse = Just True == (u ^? uvWorld . input . mouseButtons . ix ButtonLeft)
|
||||
backspacetonothing =
|
||||
fss ^? fssFilters . ix i . _Just == Just ""
|
||||
sss ^? sssExtra . sssFilters . ix i . _Just == Just ""
|
||||
&& ScancodeBackspace `M.lookup` pkeys == Just InitialPress
|
||||
pkeys = u ^. uvWorld . input . pressedKeys
|
||||
|
||||
@@ -197,16 +195,16 @@ updateBackspaceRegex w = case di ^? subInventory of
|
||||
_ -> w
|
||||
where
|
||||
secfocus a b = fromMaybe False $ do
|
||||
i <- di ^? diSections . fssSections . sssSelPos . _Just . _1
|
||||
i <- di ^? diSections . sssExtra . sssSelPos . _Just . _1
|
||||
return $ i == a || i == b
|
||||
trybackspace x fss = fromMaybe fss $ do
|
||||
trybackspace x sss = fromMaybe sss $ do
|
||||
-- i <- fss ^? fssSections . sssSelPos . _Just . _1
|
||||
-- guard (i == x || i == x+1)
|
||||
str <- fss ^? fssFilters . ix x . _Just
|
||||
str <- sss ^? sssExtra . sssFilters . ix x . _Just
|
||||
return $ case str of
|
||||
(_ : _) -> fss & fssFilters . ix x . _Just %~ init
|
||||
& fssSections . sssSelPos ?~ (x,0)
|
||||
[] -> fss & fssFilters . ix x .~ Nothing
|
||||
(_ : _) -> sss & sssExtra . sssFilters . ix x . _Just %~ init
|
||||
& sssExtra . sssSelPos ?~ (x,0)
|
||||
[] -> sss & sssExtra . sssFilters . ix x .~ Nothing
|
||||
di = w ^. hud . hudElement
|
||||
|
||||
updateEnterRegex :: World -> World
|
||||
@@ -225,10 +223,10 @@ updateEnterRegex w = case w ^? hud . hudElement . subInventory of
|
||||
where
|
||||
di = w ^. hud . hudElement
|
||||
secfocus a b = fromMaybe False $ do
|
||||
i <- di ^? diSections . fssSections . sssSelPos . _Just . _1
|
||||
i <- di ^? diSections . sssExtra . sssSelPos . _Just . _1
|
||||
return $ i == a || i == b
|
||||
enterregex x fss = fss & fssFilters . ix x %~ f
|
||||
& fssSections . sssSelPos ?~ (x,0)
|
||||
enterregex x sss = sss & sssExtra . sssFilters . ix x %~ f
|
||||
& sssExtra . sssSelPos ?~ (x,0)
|
||||
f Nothing = Just ""
|
||||
f x = x
|
||||
|
||||
@@ -258,7 +256,7 @@ spaceAction w = case w ^?! hud . hudElement of
|
||||
toggleMap :: Universe -> Universe
|
||||
toggleMap u = case u ^?! uvWorld . hud . hudElement of
|
||||
DisplayCarte -> u & uvWorld . hud . hudElement
|
||||
.~ DisplayInventory{_subInventory = NoSubInventory, _diSections = defaultFiltInv}
|
||||
.~ DisplayInventory{_subInventory = NoSubInventory, _diSections = defaultInvSections}
|
||||
_ -> u & uvWorld . hud . hudElement .~ DisplayCarte
|
||||
|
||||
toggleTweakInv :: World -> World
|
||||
|
||||
Reference in New Issue
Block a user