Commit before removing "above/below" checks on inventory dragging
I don't think these actually do anything EDIT: they are actually necessary
This commit is contained in:
@@ -19,10 +19,9 @@ data MouseContext
|
||||
| MouseMenuCursor
|
||||
| OverInvDrag {_mcoDragSection :: Int
|
||||
, _mcoMaybeSelect :: Maybe (Int,Int)
|
||||
, _mcoAboveSelect :: Maybe (Int,Int)
|
||||
, _mcoBelowSelect :: Maybe (Int,Int)
|
||||
-- , _mcoAboveSelect :: Maybe (Int,Int)
|
||||
-- , _mcoBelowSelect :: Maybe (Int,Int)
|
||||
}
|
||||
-- | OverInvDragSelect { _mcoSecSelStart :: (Int,Int), _mcoSelEnd :: Maybe Int }
|
||||
| OverInvDragSelect { _mcoSecSelStart :: Maybe (Int,Int), _mcoSelEnd :: Maybe Int }
|
||||
| OverInvSelect { _mcoInvSelect :: (Int,Int)}
|
||||
| OverCombFiltInv { _mcoInvFilt :: (Int,Int)}
|
||||
|
||||
@@ -91,15 +91,15 @@ mouseCursorType u = case u ^. uvWorld . input . mouseContext of
|
||||
MouseMenuClick{} -> drawMenuClick 5
|
||||
MouseMenuCursor -> drawMenuCursor 5
|
||||
MouseInGame -> drawPlus 5
|
||||
OverInvDrag 0 (Just (3, _)) _ _ -> drawDragDrop 5
|
||||
OverInvDrag 0 Nothing _ _ -> drawDragDrop 5
|
||||
OverInvDrag 0 (Just (0, _)) _ _ -> drawDrag 5
|
||||
OverInvDrag 0 _ _ _ -> drawEmptySet 5
|
||||
OverInvDrag 3 (Just (3, _)) _ _ -> drawDrag 5
|
||||
OverInvDrag 3 (Just (0, _)) _ _ -> drawDragPickup 5
|
||||
OverInvDrag 3 (Just (1, _)) _ _ -> drawDragPickup 5
|
||||
OverInvDrag 3 Nothing _ _ -> drawDragPickup 5
|
||||
OverInvDrag 3 _ _ _ -> drawEmptySet 5
|
||||
OverInvDrag 0 (Just (3, _)) -> drawDragDrop 5
|
||||
OverInvDrag 0 Nothing -> drawDragDrop 5
|
||||
OverInvDrag 0 (Just (0, _)) -> drawDrag 5
|
||||
OverInvDrag 0 _ -> drawEmptySet 5
|
||||
OverInvDrag 3 (Just (3, _)) -> drawDrag 5
|
||||
OverInvDrag 3 (Just (0, _)) -> drawDragPickup 5
|
||||
OverInvDrag 3 (Just (1, _)) -> drawDragPickup 5
|
||||
OverInvDrag 3 Nothing -> drawDragPickup 5
|
||||
OverInvDrag 3 _ -> drawEmptySet 5
|
||||
OverInvDrag{} -> drawEmptySet 5
|
||||
OverInvDragSelect{} -> drawDragSelect 5
|
||||
OverInvSelect (-1, _) | selsec == Just (-1) -> drawJumpDown 5
|
||||
|
||||
+3
-9
@@ -346,7 +346,7 @@ updateMouseContext cfig u = case u ^? uvScreenLayers . ix 0 of
|
||||
|
||||
updateMouseContextGame :: Configuration -> Universe -> Universe
|
||||
updateMouseContextGame cfig u = case u ^. uvWorld . input . mouseContext of
|
||||
OverInvDrag i _ _ _ -> u & uvWorld . input . mouseContext .~ invdrag i
|
||||
OverInvDrag i _ -> u & uvWorld . input . mouseContext .~ invdrag i
|
||||
OverInvDragSelect{} -> u
|
||||
_ ->
|
||||
u & uvWorld . input . mouseContext
|
||||
@@ -359,19 +359,13 @@ updateMouseContextGame cfig u = case u ^. uvWorld . input . mouseContext of
|
||||
guard $ t1 > t2
|
||||
return MouseGameRotate
|
||||
aimcontext
|
||||
-- | Just t1 <- w ^. input . mouseButtons . at ButtonLeft
|
||||
-- , Just t2 <- w ^. input . mouseButtons . at ButtonRight
|
||||
-- , t1 > t2 = MouseGameRotate
|
||||
| ButtonRight `M.member` (w ^. input . mouseButtons) = MouseAiming
|
||||
| otherwise = MouseInGame
|
||||
mpos = w ^. input . mousePos
|
||||
invdrag i' = fromMaybe (OverInvDrag i' Nothing Nothing Nothing) $ do
|
||||
invdrag i' = fromMaybe (OverInvDrag i' Nothing) $ do
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
let yint = posSelSecYint cfig invDP (mpos ^. _y)
|
||||
(i, j) <- inverseSelNumPos cfig invDP sss mpos
|
||||
let above = inverseSelSecYint (yint - 1) sss
|
||||
bneath = inverseSelSecYint (yint + 1) sss
|
||||
return $ OverInvDrag i' (Just (i, j)) above bneath
|
||||
return $ OverInvDrag i' (Just (i, j))
|
||||
overinv = do
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
selpos@(i, j) <- inverseSelNumPos cfig invDP sss mpos
|
||||
|
||||
@@ -111,19 +111,18 @@ updateMouseHeldInGame cfig w = case w ^. input . mouseContext of
|
||||
(posSelSecYint cfig invDP (w ^. input . mousePos . _y)) sss
|
||||
guard (isGroupSelectableSection $ fst ysel)
|
||||
return $ w & input . mouseContext .~ OverInvDragSelect (Just ysel) Nothing
|
||||
OverInvDrag k mmouseover ab bn -> doDrag 30 k mmouseover ab bn w
|
||||
OverInvDrag k mmouseover -> doDrag cfig 30 k mmouseover w
|
||||
_ -> w
|
||||
|
||||
doDrag :: Int -> Int -> Maybe (Int, Int) -> Maybe (Int, Int) -> Maybe (Int, Int) -> World -> World
|
||||
--doDrag 0 _ _ _ _ w = w
|
||||
doDrag n k mmouseover ab bn w = fromMaybe w $ do
|
||||
doDrag :: Configuration -> Int -> Int -> Maybe (Int, Int) -> World -> World
|
||||
doDrag cfig n k mmouseover w = fromMaybe w $ do
|
||||
guard (n /= 0) -- > 0 ?
|
||||
ss <- w ^? hud . hudElement . diSections . ix k . ssItems
|
||||
x <- mmouseover
|
||||
is <- w ^? hud . hudElement . diSelection . _Just . _3
|
||||
return $
|
||||
if concurrentIS is
|
||||
then shiftInvItems n k x ab bn is ss w
|
||||
then shiftInvItems cfig n k x is ss w
|
||||
else collectInvItems k is w
|
||||
|
||||
tryDropSelected :: Maybe (Int, Int) -> World -> Maybe World
|
||||
@@ -160,7 +159,7 @@ tryPickupSelected k mpos w = do
|
||||
|
||||
updateMouseReleaseInGame :: World -> World
|
||||
updateMouseReleaseInGame w = case w ^. input . mouseContext of
|
||||
OverInvDrag k mpos _ _ ->
|
||||
OverInvDrag k mpos ->
|
||||
input . mouseContext .~ MouseInGame $
|
||||
fromMaybe w $ tryDropSelected mpos w <|> tryPickupSelected k mpos w
|
||||
OverInvDragSelect (Just ssel) mesel
|
||||
@@ -222,7 +221,7 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
|
||||
| ScancodeLShift `M.member` (w ^. input . pressedKeys)
|
||||
&& isGroupSelectableSection (fst x) ->
|
||||
w & input . mouseContext .~ OverInvDragSelect (Just x) (Just $ snd x)
|
||||
OverInvSelect x -> startDrag x cfig w
|
||||
OverInvSelect x -> startDrag x w
|
||||
OverTerminal tmid TerminalTextInput{} -> terminalReturnEffect tmid w
|
||||
OverTerminal tmid TerminalPressTo{} -> continueTerminal tmid w
|
||||
OutsideTerminal -> w & hud . hudElement . subInventory .~ NoSubInventory
|
||||
@@ -277,16 +276,13 @@ endCombineRegex w = fromMaybe id $ do
|
||||
return (k -1)
|
||||
return $ ssSetCursor (ssLookupDown 0 j) sss
|
||||
|
||||
startDrag :: (Int, Int) -> Configuration -> World -> World
|
||||
startDrag (a, b) cfig w = setcontext
|
||||
startDrag :: (Int, Int) -> World -> World
|
||||
startDrag (a, b) w = setcontext
|
||||
$ case w ^? hud . hudElement . diSelection . _Just of
|
||||
Just (i,_,xs) | i == a && b `IS.member` xs -> w
|
||||
_ -> invSetSelection (a, b, IS.singleton b) w
|
||||
where
|
||||
setcontext = input . mouseContext .~ OverInvDrag a (Just (a, b)) above bneath
|
||||
above = inverseSelSecYint (yint - 1) =<< w ^? hud . hudElement . diSections
|
||||
bneath = inverseSelSecYint (yint + 1) =<< w ^? hud . hudElement . diSections
|
||||
yint = posSelSecYint cfig invDP (w ^. input . mousePos . _y)
|
||||
setcontext = input . mouseContext .~ OverInvDrag a (Just (a, b))
|
||||
|
||||
concurrentIS :: IS.IntSet -> Bool
|
||||
concurrentIS = go . IS.minView
|
||||
@@ -307,17 +303,19 @@ collectInvItems secid is w = fromMaybe w $ do
|
||||
return . h (j + 1) ks $ swapInvItems (\_ _ -> Just (j + 1)) k w'
|
||||
|
||||
shiftInvItems ::
|
||||
Configuration ->
|
||||
Int -> -- recurse limit
|
||||
Int -> -- section where drag started
|
||||
(Int, Int) -> -- selection item mouse is over
|
||||
Maybe (Int, Int) -> -- selection item "above" mouse position (can be same as over)
|
||||
Maybe (Int, Int) -> -- selection item "below" mouse position (can be same as over)
|
||||
IS.IntSet ->
|
||||
IM.IntMap (SelectionItem a) ->
|
||||
World ->
|
||||
World
|
||||
shiftInvItems n k x ab bn xs ss w = setSelWhileDragging . fromMaybe w $ do
|
||||
shiftInvItems cfig n k x xs ss w = setSelWhileDragging . fromMaybe w $ do
|
||||
let xk = fst x
|
||||
let yint = posSelSecYint cfig invDP (w ^. input . mousePos . _y)
|
||||
bn = inverseSelSecYint (yint + 1) =<< w ^? hud . hudElement . diSections
|
||||
ab = inverseSelSecYint (yint - 1) =<< w ^? hud . hudElement . diSections
|
||||
guard $ xk == k || xk + 1 == k || xk -1 == k
|
||||
(maxi, _) <- IS.maxView xs
|
||||
(mini, _) <- IS.minView xs
|
||||
@@ -325,11 +323,11 @@ shiftInvItems n k x ab bn xs ss w = setSelWhileDragging . fromMaybe w $ do
|
||||
_ | x < (k, mini) -> do
|
||||
guard $ not . null . fst $ IM.split mini ss
|
||||
guard $ Just (k, mini -1) /= ab
|
||||
return . doDrag (n -1) k (Just x) ab bn $ shiftInvItemsUp k xs w
|
||||
return . doDrag cfig (n -1) k (Just x) $ shiftInvItemsUp k xs w
|
||||
_ | x > (k, maxi) -> do
|
||||
guard $ not . null . snd $ IM.split maxi ss
|
||||
guard $ Just (k, maxi + 1) /= bn
|
||||
return . doDrag (n -1) k (Just x) ab bn $ shiftInvItemsDown k xs w
|
||||
return . doDrag cfig (n -1) k (Just x) $ shiftInvItemsDown k xs w
|
||||
_ -> Nothing
|
||||
|
||||
setSelWhileDragging :: World -> World
|
||||
|
||||
Reference in New Issue
Block a user