Prevent dragging items down from cycling to top
This commit is contained in:
+14
-14
@@ -355,29 +355,29 @@ shiftInvItems ::
|
|||||||
SelectionSections a ->
|
SelectionSections a ->
|
||||||
World ->
|
World ->
|
||||||
World
|
World
|
||||||
shiftInvItems topsel cfig mpos ldp sss w = case inverseSelBoundaryUp cfig ldp sss mpos of
|
shiftInvItems topsel cfig mpos ldp sss w = fromMaybe w $ do
|
||||||
Just p | p < topsel -> shiftInvItemsUp topsel w
|
x <- w ^? hud . hudElement . diSelectionExtra
|
||||||
_ -> fromMaybe w $ do
|
return $ case inverseSelBoundaryUp cfig ldp sss mpos of
|
||||||
x <- w ^? hud . hudElement . diSelectionExtra
|
Just p | p < topsel -> shiftInvItemsUp topsel x w
|
||||||
return $ case inverseSelBoundaryDown cfig ldp sss mpos of
|
_ -> case inverseSelBoundaryDown cfig ldp sss mpos of
|
||||||
Just p | p > (topsel & _2 +~ x) -> shiftInvItemsDown topsel x w
|
Just p | p > (topsel & _2 +~ x) -> shiftInvItemsDown topsel x w
|
||||||
_ -> w
|
_ -> w
|
||||||
where
|
where
|
||||||
mysel = inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
|
mysel = inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
|
||||||
|
|
||||||
shiftInvItemsUp :: (Int, Int) -> World -> World
|
shiftInvItemsUp :: (Int, Int) -> Int -> World -> World
|
||||||
shiftInvItemsUp (_, i) w = fromMaybe w $ do
|
shiftInvItemsUp (_, i) x w = foldl' f w [i .. i + x]
|
||||||
x <- w ^? hud . hudElement . diSelectionExtra
|
|
||||||
return $ foldl' f w [i .. i + x]
|
|
||||||
where
|
where
|
||||||
f w' i' = swapInvItems g i' w'
|
f w' i' = swapInvItems g i' w'
|
||||||
g i' m = fmap fst $ IM.cycleLT i' m
|
g i' m = fmap fst $ IM.lookupLT i' m
|
||||||
|
|
||||||
shiftInvItemsDown :: (Int, Int) -> Int -> World -> World
|
shiftInvItemsDown :: (Int, Int) -> Int -> World -> World
|
||||||
shiftInvItemsDown (_, i) x w = foldl' f w $ reverse [i .. i + x]
|
shiftInvItemsDown (_, i) x w = fromMaybe w $ do
|
||||||
|
guard $ isJust $ w ^? hud . hudElement . diSections . sssSections . ix 0 . ssItems . ix (i + x + 1)
|
||||||
|
return $ foldl' f w $ reverse [i .. i + x]
|
||||||
where
|
where
|
||||||
f w' i' = swapInvItems g i' w'
|
f w' i' = swapInvItems g i' w'
|
||||||
g i' m = fmap fst $ IM.cycleGT i' m
|
g i' m = fmap fst $ IM.lookupGT i' m
|
||||||
|
|
||||||
--shiftInvItemsUp :: (Int, Int) -> (Int, Int) -> Maybe (Int, Int) -> World -> World
|
--shiftInvItemsUp :: (Int, Int) -> (Int, Int) -> Maybe (Int, Int) -> World -> World
|
||||||
--shiftInvItemsUp (_, i) (_, j) Just{} w =
|
--shiftInvItemsUp (_, i) (_, j) Just{} w =
|
||||||
|
|||||||
Reference in New Issue
Block a user