diff --git a/src/Dodge/Data/Input.hs b/src/Dodge/Data/Input.hs index dc8650afb..7cfebdd27 100644 --- a/src/Dodge/Data/Input.hs +++ b/src/Dodge/Data/Input.hs @@ -17,8 +17,7 @@ data MouseContext | MouseInGame | MouseMenu {_mcoMenuClick :: Maybe Int} | OverInvDrag {_mcoDragSection :: Int } --- | OverInvDrag {_mcoDragSection :: Int , _mcoMaybeSelect :: Maybe (Int,Int) } - | OverInvDragSelect { _mcoSecSelStart :: XInfinity (Int,Int) } --, _mcoSelEnd :: Maybe (XInfinity (Int,Int)) } + | OverInvDragSelect { _mcoSecSelStart :: XInfinity (Int,Int) } | OverInvSelect { _mcoInvSelect :: (Int,Int)} | OverCombFiltInv { _mcoInvFilt :: (Int,Int)} | OverCombSelect { _mcoCombSelect :: (Int,Int)} diff --git a/src/Dodge/Inventory.hs b/src/Dodge/Inventory.hs index b43f74e2a..9310e93c8 100644 --- a/src/Dodge/Inventory.hs +++ b/src/Dodge/Inventory.hs @@ -233,7 +233,7 @@ changeSwapOther n f i w = fromMaybe w $ do | otherwise = j return $ w - & swapAnyExtraSelection 3 i k + & hud . diSections . ix 3 . ssSet %~ swapInIntSet i k & hud . closeItems %~ swapIndices i k & hud . diSelection . _Just . slInt %~ doswap & worldEventFlags . at InventoryChange ?~ () diff --git a/src/Dodge/Inventory/Swap.hs b/src/Dodge/Inventory/Swap.hs index ab6a3cb3c..f6dfe3f92 100644 --- a/src/Dodge/Inventory/Swap.hs +++ b/src/Dodge/Inventory/Swap.hs @@ -1,6 +1,6 @@ module Dodge.Inventory.Swap ( swapInvItems, - swapAnyExtraSelection + swapInIntSet, ) where import Linear @@ -34,7 +34,7 @@ swapInvItems f i w = fromMaybe w $ do _ -> id return $ w - & swapAnyExtraSelection 0 i k + & hud . diSections . ix 0 . ssSet %~ swapInIntSet i k & checkConnection InventorySound disconnectItemS i k & cWorld . lWorld . creatures . ix 0 %~ updatecreature k & updateselection @@ -54,22 +54,11 @@ swapInvItems f i w = fromMaybe w $ do Just epos -> crEquipment . ix epos .~ NInt b Nothing -> id -swapAnyExtraSelection :: Int -> Int -> Int -> World -> World -swapAnyExtraSelection seci i k w = w - & hud . diSections . ix seci . ssSet %~ f - where - f is +swapInIntSet :: Int -> Int -> IS.IntSet -> IS.IntSet +swapInIntSet i k is | i `IS.member` is && not (k `IS.member` is) = IS.insert k $ IS.delete i is | k `IS.member` is && not (i `IS.member` is) = IS.insert i $ IS.delete k is | otherwise = is - --- fromMaybe w $ do --- is <- w ^? hud . diSelection . _Just . slSet --- let f = if i `IS.member` is then IS.insert k else id --- g = if k `IS.member` is then IS.insert i else id --- return $ --- w & hud . diSelection . _Just . slSet --- %~ (f . g . IS.delete i . IS.delete k) checkConnection :: SoundOrigin -> SoundID -> Int -> Int -> World -> World checkConnection so s i j w = fromMaybe w $ do diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index da6789198..23672cbf3 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -450,7 +450,6 @@ updateMouseContextGame cfig u = \case return $ OverInvSelect selpos overcomb = do sss <- w ^? hud . subInventory . ciSections --- Sel xl xr _ <- w ^? hud . subInventory . ciSelection . _Just Sel xl xr <- w ^? hud . subInventory . ciSelection . _Just let msel = (xl, xr) let mpossel = inverseSelNumPos cfig secondColumnLDP (w ^. input . mousePos) sss ^? _Just . nonInf diff --git a/src/Dodge/Update/Input/InGame.hs b/src/Dodge/Update/Input/InGame.hs index 59d8e25aa..57375bc6d 100644 --- a/src/Dodge/Update/Input/InGame.hs +++ b/src/Dodge/Update/Input/InGame.hs @@ -72,10 +72,8 @@ updateUseInputInGame u = updateFunctionKeys $ case u ^. uvWorld . hud . subInven & filterlens .~ filts' docombineregexinput sss msel ci = fromMaybe ci $ do filts <- ci ^? ciFilter - --let (sss', msel', filts') = doRegexInput (u ^. uvWorld . input) (-1) sss msel filts let ( msel', filts') = doRegexInput (u ^. uvWorld . input) (-1) sss msel filts return $ ci --- & ciSections .~ sss' & ciSelection .~ msel' & ciFilter .~ filts' @@ -219,6 +217,9 @@ mouseInvPos u = inverseSelNumPos updateMouseClickInGame :: Universe -> Universe updateMouseClickInGame u = case w ^. input . mouseContext of MouseInGame -> u & uvWorld . input . mouseContext .~ OverInvDragSelect (mouseInvHeight u) + OverInvSelect x + | ScancodeLShift `M.member` (w ^. input . pressedKeys) -> + u & uvWorld . input . mouseContext .~ OverInvDragSelect (NonInf x) OverInvSelect (-1, _) | selsec == Just (-1) -> u @@ -233,9 +234,6 @@ updateMouseClickInGame u = case w ^. input . mouseContext of k <- w ^? hud . closeButtons . ix j but <- w ^? cWorld . lWorld . buttons . ix k return $ u & uvWorld %~ doButtonEvent (but ^. btEvent) but - OverInvSelect x - | ScancodeLShift `M.member` (w ^. input . pressedKeys) -> - u & uvWorld . input . mouseContext .~ OverInvDragSelect (NonInf x) OverInvSelect x -> u & uvWorld %~ startDrag x OverTerminal tmid TerminalTextInput{} -> u & uvWorld %~ terminalReturnEffect tmid OverTerminal tmid TerminalPressTo{} -> u & uvWorld %~ continueTerminal tmid @@ -460,14 +458,12 @@ doRegexInput inp i sss msel filts | backspacetonothing || escapekey = endregex i 0 | endkeys = endregex (i + 1) (j - 1) | otherwise = - (-- sss , - msel + ( msel , filts & doTextInputOver inp _Just ) where endregex a b = - (-- sss , - msel & ssSetCursor (ssLookupDown a b) sss + ( msel & ssSetCursor (ssLookupDown a b) sss , Nothing ) j = fromMaybe 0 $ do