Inventory: allow selection and dropping by dragging while filtering

This commit is contained in:
2024-11-20 19:58:24 +00:00
parent b750fe4186
commit efef41c9e1
5 changed files with 13 additions and 18 deletions
+9 -2
View File
@@ -3,6 +3,7 @@ module Dodge.Update.Input.InGame (
updateMouseInGame,
) where
import Data.Foldable
import Control.Applicative
import Control.Monad
import qualified Data.IntMap.Strict as IM
@@ -127,9 +128,15 @@ updateMouseReleaseInGame w = case w ^. input . mouseContext of
OverInvDragSelect ssel (Just esel) ->
w & input . mouseContext .~ MouseInGame
& hud . hudElement . diSelectionExtra
.~ IS.fromAscList [min (snd ssel) (snd esel) + 1 .. max (snd ssel) (snd esel)]
.~ h (snd ssel) (snd esel)-- IM.keysSet [min (snd ssel) (snd esel) + 1 .. max (snd ssel) (snd esel)]
& augInvDirectSelect (min ssel esel)
_ -> w
where
h i j = fold $ do
sss <- w ^? hud . hudElement . diSections . ix 0 . ssItems
let (_,xss) = IM.split ((min i j)-1) sss
(yss,_) = IM.split ((max i j)+1) xss
return . IM.keysSet $ yss
updateMouseClickInGame :: Configuration -> World -> World
updateMouseClickInGame cfig w = case w ^. input . mouseContext of
@@ -483,7 +490,7 @@ tryCombine ::
World
tryCombine (i, j) w = fromMaybe w $ do
sss <- w ^? hud . hudElement . subInventory . ciSections
CombinableItem is it _ <- sss ^? ix i . ssItems . ix j . siPayload
CombinableItem is it <- sss ^? ix i . ssItems . ix j . siPayload
p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos
return $
snd (createItemYou it (foldr (destroyInvItem 0) w (sort is)))