Cleanup item swapping
This commit is contained in:
@@ -17,8 +17,7 @@ data MouseContext
|
|||||||
| MouseInGame
|
| MouseInGame
|
||||||
| MouseMenu {_mcoMenuClick :: Maybe Int}
|
| MouseMenu {_mcoMenuClick :: Maybe Int}
|
||||||
| OverInvDrag {_mcoDragSection :: Int }
|
| OverInvDrag {_mcoDragSection :: Int }
|
||||||
-- | OverInvDrag {_mcoDragSection :: Int , _mcoMaybeSelect :: Maybe (Int,Int) }
|
| OverInvDragSelect { _mcoSecSelStart :: XInfinity (Int,Int) }
|
||||||
| OverInvDragSelect { _mcoSecSelStart :: XInfinity (Int,Int) } --, _mcoSelEnd :: Maybe (XInfinity (Int,Int)) }
|
|
||||||
| OverInvSelect { _mcoInvSelect :: (Int,Int)}
|
| OverInvSelect { _mcoInvSelect :: (Int,Int)}
|
||||||
| OverCombFiltInv { _mcoInvFilt :: (Int,Int)}
|
| OverCombFiltInv { _mcoInvFilt :: (Int,Int)}
|
||||||
| OverCombSelect { _mcoCombSelect :: (Int,Int)}
|
| OverCombSelect { _mcoCombSelect :: (Int,Int)}
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ changeSwapOther n f i w = fromMaybe w $ do
|
|||||||
| otherwise = j
|
| otherwise = j
|
||||||
return $
|
return $
|
||||||
w
|
w
|
||||||
& swapAnyExtraSelection 3 i k
|
& hud . diSections . ix 3 . ssSet %~ swapInIntSet i k
|
||||||
& hud . closeItems %~ swapIndices i k
|
& hud . closeItems %~ swapIndices i k
|
||||||
& hud . diSelection . _Just . slInt %~ doswap
|
& hud . diSelection . _Just . slInt %~ doswap
|
||||||
& worldEventFlags . at InventoryChange ?~ ()
|
& worldEventFlags . at InventoryChange ?~ ()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module Dodge.Inventory.Swap (
|
module Dodge.Inventory.Swap (
|
||||||
swapInvItems,
|
swapInvItems,
|
||||||
swapAnyExtraSelection
|
swapInIntSet,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Linear
|
import Linear
|
||||||
@@ -34,7 +34,7 @@ swapInvItems f i w = fromMaybe w $ do
|
|||||||
_ -> id
|
_ -> id
|
||||||
return $
|
return $
|
||||||
w
|
w
|
||||||
& swapAnyExtraSelection 0 i k
|
& hud . diSections . ix 0 . ssSet %~ swapInIntSet i k
|
||||||
& checkConnection InventorySound disconnectItemS i k
|
& checkConnection InventorySound disconnectItemS i k
|
||||||
& cWorld . lWorld . creatures . ix 0 %~ updatecreature k
|
& cWorld . lWorld . creatures . ix 0 %~ updatecreature k
|
||||||
& updateselection
|
& updateselection
|
||||||
@@ -54,22 +54,11 @@ swapInvItems f i w = fromMaybe w $ do
|
|||||||
Just epos -> crEquipment . ix epos .~ NInt b
|
Just epos -> crEquipment . ix epos .~ NInt b
|
||||||
Nothing -> id
|
Nothing -> id
|
||||||
|
|
||||||
swapAnyExtraSelection :: Int -> Int -> Int -> World -> World
|
swapInIntSet :: Int -> Int -> IS.IntSet -> IS.IntSet
|
||||||
swapAnyExtraSelection seci i k w = w
|
swapInIntSet i k is
|
||||||
& hud . diSections . ix seci . ssSet %~ f
|
|
||||||
where
|
|
||||||
f is
|
|
||||||
| i `IS.member` is && not (k `IS.member` is) = IS.insert k $ IS.delete i 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
|
| k `IS.member` is && not (i `IS.member` is) = IS.insert i $ IS.delete k is
|
||||||
| otherwise = 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 :: SoundOrigin -> SoundID -> Int -> Int -> World -> World
|
||||||
checkConnection so s i j w = fromMaybe w $ do
|
checkConnection so s i j w = fromMaybe w $ do
|
||||||
|
|||||||
@@ -450,7 +450,6 @@ updateMouseContextGame cfig u = \case
|
|||||||
return $ OverInvSelect selpos
|
return $ OverInvSelect selpos
|
||||||
overcomb = do
|
overcomb = do
|
||||||
sss <- w ^? hud . subInventory . ciSections
|
sss <- w ^? hud . subInventory . ciSections
|
||||||
-- Sel xl xr _ <- w ^? hud . subInventory . ciSelection . _Just
|
|
||||||
Sel xl xr <- w ^? hud . subInventory . ciSelection . _Just
|
Sel xl xr <- w ^? hud . subInventory . ciSelection . _Just
|
||||||
let msel = (xl, xr)
|
let msel = (xl, xr)
|
||||||
let mpossel = inverseSelNumPos cfig secondColumnLDP (w ^. input . mousePos) sss ^? _Just . nonInf
|
let mpossel = inverseSelNumPos cfig secondColumnLDP (w ^. input . mousePos) sss ^? _Just . nonInf
|
||||||
|
|||||||
@@ -72,10 +72,8 @@ updateUseInputInGame u = updateFunctionKeys $ case u ^. uvWorld . hud . subInven
|
|||||||
& filterlens .~ filts'
|
& filterlens .~ filts'
|
||||||
docombineregexinput sss msel ci = fromMaybe ci $ do
|
docombineregexinput sss msel ci = fromMaybe ci $ do
|
||||||
filts <- ci ^? ciFilter
|
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
|
let ( msel', filts') = doRegexInput (u ^. uvWorld . input) (-1) sss msel filts
|
||||||
return $ ci
|
return $ ci
|
||||||
-- & ciSections .~ sss'
|
|
||||||
& ciSelection .~ msel'
|
& ciSelection .~ msel'
|
||||||
& ciFilter .~ filts'
|
& ciFilter .~ filts'
|
||||||
|
|
||||||
@@ -219,6 +217,9 @@ mouseInvPos u = inverseSelNumPos
|
|||||||
updateMouseClickInGame :: Universe -> Universe
|
updateMouseClickInGame :: Universe -> Universe
|
||||||
updateMouseClickInGame u = case w ^. input . mouseContext of
|
updateMouseClickInGame u = case w ^. input . mouseContext of
|
||||||
MouseInGame -> u & uvWorld . input . mouseContext .~ OverInvDragSelect (mouseInvHeight u)
|
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, _)
|
OverInvSelect (-1, _)
|
||||||
| selsec == Just (-1) ->
|
| selsec == Just (-1) ->
|
||||||
u
|
u
|
||||||
@@ -233,9 +234,6 @@ updateMouseClickInGame u = case w ^. input . mouseContext of
|
|||||||
k <- w ^? hud . closeButtons . ix j
|
k <- w ^? hud . closeButtons . ix j
|
||||||
but <- w ^? cWorld . lWorld . buttons . ix k
|
but <- w ^? cWorld . lWorld . buttons . ix k
|
||||||
return $ u & uvWorld %~ doButtonEvent (but ^. btEvent) but
|
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
|
OverInvSelect x -> u & uvWorld %~ startDrag x
|
||||||
OverTerminal tmid TerminalTextInput{} -> u & uvWorld %~ terminalReturnEffect tmid
|
OverTerminal tmid TerminalTextInput{} -> u & uvWorld %~ terminalReturnEffect tmid
|
||||||
OverTerminal tmid TerminalPressTo{} -> u & uvWorld %~ continueTerminal tmid
|
OverTerminal tmid TerminalPressTo{} -> u & uvWorld %~ continueTerminal tmid
|
||||||
@@ -460,14 +458,12 @@ doRegexInput inp i sss msel filts
|
|||||||
| backspacetonothing || escapekey = endregex i 0
|
| backspacetonothing || escapekey = endregex i 0
|
||||||
| endkeys = endregex (i + 1) (j - 1)
|
| endkeys = endregex (i + 1) (j - 1)
|
||||||
| otherwise =
|
| otherwise =
|
||||||
(-- sss ,
|
( msel
|
||||||
msel
|
|
||||||
, filts & doTextInputOver inp _Just
|
, filts & doTextInputOver inp _Just
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
endregex a b =
|
endregex a b =
|
||||||
(-- sss ,
|
( msel & ssSetCursor (ssLookupDown a b) sss
|
||||||
msel & ssSetCursor (ssLookupDown a b) sss
|
|
||||||
, Nothing
|
, Nothing
|
||||||
)
|
)
|
||||||
j = fromMaybe 0 $ do
|
j = fromMaybe 0 $ do
|
||||||
|
|||||||
Reference in New Issue
Block a user