Allow drag selecting outside of the selection section
Does not yet work outside of any selection section. Need to think about what widths are acceptable to allow for selection.
This commit is contained in:
@@ -5,6 +5,7 @@ module Dodge.Update.Input.InGame (
|
||||
updateMouseInGame,
|
||||
) where
|
||||
|
||||
import Dodge.Data.CardinalPoint
|
||||
import Dodge.Inventory.CheckSlots
|
||||
import Dodge.Base.Collide
|
||||
import Geometry.Vector
|
||||
@@ -103,12 +104,17 @@ updateMouseHeldInGame cfig w = case w ^. input . mouseContext of
|
||||
OverInvDragSelect (Just sstart) _ -> fromMaybe w $ do
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
let msel = inverseSelNumPos cfig invDP sss (w ^. input . mousePos)
|
||||
guard $ Just (fst sstart) == fmap fst msel
|
||||
return $ w & input . mouseContext . mcoSelEnd .~ fmap snd msel
|
||||
return $ case msel of
|
||||
Nothing -> w & input . mouseContext . mcoSelEnd .~ Nothing
|
||||
Just (i,j) | i == fst sstart -> w & input . mouseContext . mcoSelEnd ?~ j
|
||||
| i < fst sstart -> w & input . mouseContext . mcoSelEnd ?~ 0
|
||||
| otherwise -> w & input . mouseContext . mcoSelEnd .~ fmap fst
|
||||
(IM.lookupMax =<< sss ^? ix (fst sstart) . ssItems)
|
||||
OverInvDragSelect Nothing _ -> fromMaybe w $ do
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
ysel <- inverseSelSecYint
|
||||
(posSelSecYint cfig invDP (w ^. input . mousePos . _y)) sss
|
||||
^? nonInf
|
||||
guard (isGroupSelectableSection $ fst ysel)
|
||||
return $ w & input . mouseContext .~ OverInvDragSelect (Just ysel) Nothing
|
||||
OverInvDrag k mmouseover -> doDrag cfig 30 k mmouseover w
|
||||
@@ -204,7 +210,7 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
|
||||
MouseInGame -> fromMaybe (w & input . mouseContext .~ OverInvDragSelect Nothing Nothing) $ do
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
ysel <- inverseSelSecYint
|
||||
(posSelSecYint cfig invDP (w ^. input . mousePos . _y)) sss
|
||||
(posSelSecYint cfig invDP (w ^. input . mousePos . _y)) sss ^? nonInf
|
||||
guard (isGroupSelectableSection $ fst ysel)
|
||||
return $ w & input . mouseContext .~ OverInvDragSelect (Just ysel) Nothing
|
||||
OverInvSelect (-1, _)
|
||||
@@ -314,8 +320,10 @@ shiftInvItems ::
|
||||
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
|
||||
bn = (\v -> inverseSelSecYint (yint + 1) v ^? nonInf)
|
||||
=<< w ^? hud . hudElement . diSections
|
||||
ab = (\v -> inverseSelSecYint (yint - 1) v ^? nonInf)
|
||||
=<< w ^? hud . hudElement . diSections
|
||||
guard $ xk == k || xk + 1 == k || xk -1 == k
|
||||
(maxi, _) <- IS.maxView xs
|
||||
(mini, _) <- IS.minView xs
|
||||
|
||||
Reference in New Issue
Block a user