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
+1 -1
View File
@@ -1 +1 @@
All good (594 modules, at 17:18:47)
All good (594 modules, at 19:56:08)
+1 -1
View File
@@ -27,7 +27,7 @@ combineList = map f . combineItemListYouX
, _siIsSelectable = True
, _siColor = itemInvColor . pciToCI $ basePCI itm
, _siOffX = 0
, _siPayload = CombinableItem is itm []
, _siPayload = CombinableItem is itm
}
combineItemListYouX :: World -> [([Int], Item)]
-1
View File
@@ -5,6 +5,5 @@ import Dodge.Data.Item
data CombinableItem = CombinableItem
{ _ciInvIDs :: [Int]
, _ciItem :: Item
, _ciInfo :: [String]
}
makeLenses ''CombinableItem
+2 -13
View File
@@ -341,22 +341,11 @@ combineInventoryExtra ::
Picture
combineInventoryExtra sss msel cfig w = fromMaybe mempty $ do
(i, j) <- msel
cpos <- selSecYint i j sss
si <- sss ^? ix i . ssItems . ix j
let col = _siColor si
mconcat
[ do
strs <- si ^? siPayload . ciInfo
return
. translate 160 0
-- it would be better to get the width of the selection list from elsewhere
. translateScreenPos cfig (secondColumnParams ^. ldpPos)
$ drawListYoff cpos $ map (color red . text) strs
, do
lnks <- si ^? siPayload . ciInvIDs
return (lnkMidPosInvSelsCol cfig w j col lnks)
lnks <- si ^? siPayload . ciInvIDs
return (lnkMidPosInvSelsCol cfig w j col lnks)
<> foldMap invcursor lnks
]
where
invcursor i = do
sss' <- w ^? hud . hudElement . diSections
+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)))