Continue selection refactor

This commit is contained in:
2024-11-20 16:15:51 +00:00
parent 3ecf137801
commit 1f5d034c5f
9 changed files with 159 additions and 114 deletions
+11 -2
View File
@@ -17,6 +17,7 @@ module Dodge.Inventory (
isFilteringInv,
) where
import qualified Data.IntSet as IS
import Control.Monad
import Dodge.Item.Grammar
import Dodge.Data.DoubleTree
@@ -88,7 +89,7 @@ rmInvItem cid invid w =
-- & updateCreatureItemLocations cid
pointcid = cWorld . lWorld . creatures . ix cid
updateselectionextra | cid == 0 = hud . hudElement . diSelectionExtra .~ 0
updateselectionextra | cid == 0 = hud . hudElement . diSelectionExtra .~ mempty
| otherwise = id
updateselection
| cid == 0 && cr ^? crManipulation . manObject . imSelectedItem == Just invid =
@@ -194,7 +195,7 @@ swapInvItems f i w = fromMaybe w $ do
_ -> id
return $
w
-- & checkconnect k InventorySound disconnectItemS
& swapAnyExtraSelection i k
& checkConnection InventorySound disconnectItemS i k
& cWorld . lWorld . creatures . ix 0 %~ updatecreature k
& updateselection
@@ -230,6 +231,14 @@ swapInvItems f i w = fromMaybe w $ do
Just epos -> crHotkeys . ix epos .~ b
Nothing -> id
swapAnyExtraSelection :: Int -> Int -> World -> World
swapAnyExtraSelection i k w = fromMaybe w $ do
is <- w ^? hud . hudElement . diSelectionExtra
let f = if i `IS.member` is then IS.insert k else id
g = if k `IS.member` is then IS.insert i else id
return $ w & hud . hudElement . diSelectionExtra
%~ (f . g . IS.delete i . IS.delete k)
checkConnection :: SoundOrigin -> SoundID -> Int -> Int -> World -> World
checkConnection so s i j w = fromMaybe w $ do
inv <- w ^? cWorld . lWorld . creatures . ix 0 . crInv