Allow more drag selection to work

This commit is contained in:
2025-08-25 13:30:04 +01:00
parent a2c32907f0
commit 58c645041f
5 changed files with 72 additions and 57 deletions
+3
View File
@@ -23,3 +23,6 @@ data CardinalCover
| NSE
| NSW
| NS
data AboveBelow = Above | Below
deriving (Eq, Ord, Show, Bounded, Enum)
+2 -1
View File
@@ -22,7 +22,8 @@ data MouseContext
, _mcoAboveSelect :: Maybe (Int,Int)
, _mcoBelowSelect :: Maybe (Int,Int)
}
| OverInvDragSelect { _mcoSecSelStart :: (Int,Int), _mcoSelEnd :: Maybe Int }
-- | OverInvDragSelect { _mcoSecSelStart :: (Int,Int), _mcoSelEnd :: Maybe Int }
| OverInvDragSelect { _mcoSecSelStart :: Maybe (Int,Int), _mcoSelEnd :: Maybe Int }
| OverInvSelect { _mcoInvSelect :: (Int,Int)}
| OverCombFiltInv { _mcoInvFilt :: (Int,Int)}
| OverCombSelect { _mcoCombSelect :: (Int,Int)}
+1 -2
View File
@@ -148,8 +148,7 @@ drawDragSelected cfig w = do
drawDragSelecting :: Configuration -> World -> Maybe Picture
drawDragSelecting cfig w = do
OverInvDragSelect (i, j) mselend <- w ^? input . mouseContext
b <- mselend
OverInvDragSelect (Just (i, j)) (Just b) <- w ^? input . mouseContext
sss <- w ^? hud . hudElement . diSections
let f x = selSecDrawCursorAt invDP BackdropCursor sss (i, x)
return . translateScreenPos cfig (invDP ^. ldpPos)
+16 -7
View File
@@ -100,11 +100,17 @@ updateMouseHeldInGame :: Configuration -> World -> World
updateMouseHeldInGame cfig w = case w ^. input . mouseContext of
OverInvDragSelect {} | ButtonRight `M.member` (w ^. input . mouseButtons)
-> w & input . mouseContext .~ MouseGameRotate
OverInvDragSelect sstart _ -> fromMaybe w $ do
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 || isNothing msel
guard $ Just (fst sstart) == fmap fst msel
return $ w & input . mouseContext . mcoSelEnd .~ fmap snd msel
OverInvDragSelect Nothing _ -> fromMaybe w $ do
sss <- w ^? hud . hudElement . diSections
ysel <- inverseSelSecYint
(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
_ -> w
@@ -157,7 +163,7 @@ updateMouseReleaseInGame w = case w ^. input . mouseContext of
OverInvDrag k mpos _ _ ->
input . mouseContext .~ MouseInGame $
fromMaybe w $ tryDropSelected mpos w <|> tryPickupSelected k mpos w
OverInvDragSelect ssel mesel
OverInvDragSelect (Just ssel) mesel
| ScancodeLShift `M.member` (w ^. input . pressedKeys) ->
w & input . mouseContext .~ MouseInGame
& hud . hudElement . diSelection . _Just . _3
@@ -172,9 +178,12 @@ updateMouseReleaseInGame w = case w ^. input . mouseContext of
OverInvDragSelect _ Nothing ->
w & input . mouseContext .~ MouseInGame
& hud . hudElement . diSelection . _Just . _3 %~ const mempty
OverInvDragSelect ssel (Just esel) ->
OverInvDragSelect (Just ssel) (Just esel) ->
w & input . mouseContext .~ MouseInGame
& invSetSelection (f (fst ssel, esel) (h ssel esel))
OverInvDragSelect Nothing _ ->
w & input . mouseContext .~ MouseInGame
& hud . hudElement . diSelection . _Just . _3 %~ const mempty
_ -> w
where
getuniques x y = IS.union x y IS.\\ IS.intersection x y
@@ -193,12 +202,12 @@ isGroupSelectableSection = \case
updateMouseClickInGame :: Configuration -> World -> World
updateMouseClickInGame cfig w = case w ^. input . mouseContext of
MouseInGame -> fromMaybe w $ do
MouseInGame -> fromMaybe (w & input . mouseContext .~ OverInvDragSelect Nothing Nothing) $ do
sss <- w ^? hud . hudElement . diSections
ysel <- inverseSelSecYint
(posSelSecYint cfig invDP (w ^. input . mousePos . _y)) sss
guard (isGroupSelectableSection $ fst ysel)
return $ w & input . mouseContext .~ OverInvDragSelect ysel Nothing
return $ w & input . mouseContext .~ OverInvDragSelect (Just ysel) Nothing
OverInvSelect (-1, _)
| selsec == Just (-1) ->
w
@@ -212,7 +221,7 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
OverInvSelect x
| ScancodeLShift `M.member` (w ^. input . pressedKeys)
&& isGroupSelectableSection (fst x) ->
w & input . mouseContext .~ OverInvDragSelect x (Just $ snd x)
w & input . mouseContext .~ OverInvDragSelect (Just x) (Just $ snd x)
OverInvSelect x -> startDrag x cfig w
OverTerminal tmid TerminalTextInput{} -> terminalReturnEffect tmid w
OverTerminal tmid TerminalPressTo{} -> continueTerminal tmid w