Allow selection of noncontiguous items using shift
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
|||||||
All good (594 modules, at 17:16:08)
|
All good (594 modules, at 18:13:44)
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import qualified IntMapHelp as IM
|
|||||||
import Dodge.Data.World
|
import Dodge.Data.World
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
|
|
||||||
-- can be specialised for when we know that item i is selected
|
|
||||||
swapInvItems ::
|
swapInvItems ::
|
||||||
(Int -> IM.IntMap (SelectionItem ()) -> Maybe Int) ->
|
(Int -> IM.IntMap (SelectionItem ()) -> Maybe Int) ->
|
||||||
Int ->
|
Int ->
|
||||||
|
|||||||
@@ -139,16 +139,22 @@ updateMouseReleaseInGame w = case w ^. input . mouseContext of
|
|||||||
OverInvDrag k mpos _ _ ->
|
OverInvDrag k mpos _ _ ->
|
||||||
input . mouseContext .~ MouseInGame $
|
input . mouseContext .~ MouseInGame $
|
||||||
fromMaybe w $ tryDropSelected mpos w <|> tryPickupSelected k mpos w
|
fromMaybe w $ tryDropSelected mpos w <|> tryPickupSelected k mpos w
|
||||||
|
OverInvDragSelect ssel mesel | ScancodeLShift `M.member` (w ^. input . pressedKeys)
|
||||||
|
-> w & input . mouseContext .~ MouseInGame
|
||||||
|
& hud . hudElement . diSelection . _Just . _3 %~ getuniques
|
||||||
|
(maybe mempty (h ssel) (mesel ^? _Just . _2))
|
||||||
|
-- note this assumes that mesel isn't outside the first
|
||||||
|
-- selection, this should perhaps just be made impossible by
|
||||||
|
-- removing the first part of the tuple
|
||||||
OverInvDragSelect _ Nothing ->
|
OverInvDragSelect _ Nothing ->
|
||||||
w & input . mouseContext .~ MouseInGame
|
w & input . mouseContext .~ MouseInGame
|
||||||
& hud . hudElement . diSelection . _Just . _3 %~ const mempty
|
& hud . hudElement . diSelection . _Just . _3 %~ const mempty
|
||||||
OverInvDragSelect ssel (Just esel) ->
|
OverInvDragSelect ssel (Just esel) ->
|
||||||
w & input . mouseContext .~ MouseInGame
|
w & input . mouseContext .~ MouseInGame
|
||||||
-- & hud . hudElement . diSelectionExtra
|
|
||||||
-- .~ h ssel (snd esel) -- IM.keysSet [min (snd ssel) (snd esel) + 1 .. max (snd ssel) (snd esel)]
|
|
||||||
& augInvDirectSelect (f (min ssel esel) (h ssel (snd esel)))
|
& augInvDirectSelect (f (min ssel esel) (h ssel (snd esel)))
|
||||||
_ -> w
|
_ -> w
|
||||||
where
|
where
|
||||||
|
getuniques x y = IS.union x y IS.\\ IS.intersection x y
|
||||||
f (x,y) z = (x,y,z)
|
f (x,y) z = (x,y,z)
|
||||||
h (k,i) j = fold $ do
|
h (k,i) j = fold $ do
|
||||||
sss <- w ^? hud . hudElement . diSections . ix k . ssItems
|
sss <- w ^? hud . hudElement . diSections . ix k . ssItems
|
||||||
@@ -164,6 +170,8 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
|
|||||||
return $
|
return $
|
||||||
w & input . mouseContext
|
w & input . mouseContext
|
||||||
.~ OverInvDragSelect ysel Nothing
|
.~ OverInvDragSelect ysel Nothing
|
||||||
|
OverInvSelect x | ScancodeLShift `M.member` (w ^. input . pressedKeys )
|
||||||
|
-> w & input . mouseContext .~ OverInvDragSelect x (Just x)
|
||||||
OverInvSelect x -> startDrag x cfig w
|
OverInvSelect x -> startDrag x cfig w
|
||||||
OverTerminalReturn tmid -> terminalReturnEffect tmid w
|
OverTerminalReturn tmid -> terminalReturnEffect tmid w
|
||||||
OverTerminalEscape ->
|
OverTerminalEscape ->
|
||||||
|
|||||||
Reference in New Issue
Block a user