Add sounds when connecting/disconnecting items
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
|||||||
All good (594 modules, at 18:20:01)
|
All good (594 modules, at 19:11:58)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import Dodge.Data.Material
|
|||||||
|
|
||||||
data SoundOrigin
|
data SoundOrigin
|
||||||
= InventorySound
|
= InventorySound
|
||||||
|
| InventoryConnectSound
|
||||||
| BackgroundSound
|
| BackgroundSound
|
||||||
| OnceSound
|
| OnceSound
|
||||||
| CrSound Int
|
| CrSound Int
|
||||||
|
|||||||
@@ -189,7 +189,8 @@ swapInvItems f i w = fromMaybe w $ do
|
|||||||
Just (0, j) | j == i -> hud . hudElement . diSelection . _Just . _2 .~ k
|
Just (0, j) | j == i -> hud . hudElement . diSelection . _Just . _2 .~ k
|
||||||
_ -> id
|
_ -> id
|
||||||
return $
|
return $
|
||||||
w & checkdisconnect k
|
w
|
||||||
|
& checkconnect k InventorySound disconnectItemS
|
||||||
& cWorld . lWorld . creatures . ix 0 %~ updatecreature k
|
& cWorld . lWorld . creatures . ix 0 %~ updatecreature k
|
||||||
& updateselection
|
& updateselection
|
||||||
& worldEventFlags . at InventoryChange ?~ ()
|
& worldEventFlags . at InventoryChange ?~ ()
|
||||||
@@ -197,14 +198,15 @@ swapInvItems f i w = fromMaybe w $ do
|
|||||||
& setInvPosFromSS
|
& setInvPosFromSS
|
||||||
& cWorld . lWorld %~ crUpdateItemLocations 0 -- the double application is inefficient, but necessary without further changes
|
& cWorld . lWorld %~ crUpdateItemLocations 0 -- the double application is inefficient, but necessary without further changes
|
||||||
-- a rethink is maybe in order
|
-- a rethink is maybe in order
|
||||||
|
& checkconnect k InventoryConnectSound connectItemS
|
||||||
where
|
where
|
||||||
cpos = fromMaybe 0 $ w ^? cWorld . lWorld . creatures . ix 0 . crPos
|
cpos = fromMaybe 0 $ w ^? cWorld . lWorld . creatures . ix 0 . crPos
|
||||||
checkdisconnect k
|
checkconnect k stype s w'
|
||||||
| a || b = soundStart InventorySound cpos disconnectItemS Nothing
|
| p (i+1) || p (i-1)
|
||||||
| otherwise = id
|
|| p (k+1) || p (k-1) = soundStart stype cpos s Nothing w'
|
||||||
|
| otherwise = w'
|
||||||
where
|
where
|
||||||
a = maybe False not $ w ^? cWorld . lWorld . creatures . ix 0 . crInv . ix i . itLocation . ilIsRoot
|
p j = maybe False not $ w' ^? cWorld . lWorld . creatures . ix 0 . crInv . ix j . itLocation . ilIsRoot
|
||||||
b = maybe False not $ w ^? cWorld . lWorld . creatures . ix 0 . crInv . ix k . itLocation . ilIsRoot
|
|
||||||
updatecreature k =
|
updatecreature k =
|
||||||
(crInv %~ IM.safeSwapKeys i k)
|
(crInv %~ IM.safeSwapKeys i k)
|
||||||
. (crManipulation . manObject . imSelectedItem .~ k)
|
. (crManipulation . manObject . imSelectedItem .~ k)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ module Dodge.Inventory.Location (
|
|||||||
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
|
import Data.IntMap.Merge.Strict
|
||||||
import qualified Data.IntSet as IS
|
import qualified Data.IntSet as IS
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Dodge.Base.You
|
import Dodge.Base.You
|
||||||
@@ -13,7 +14,6 @@ import Dodge.Data.Item.Use.Consumption.LoadAction
|
|||||||
import Dodge.Data.World
|
import Dodge.Data.World
|
||||||
import Dodge.Item.Grammar
|
import Dodge.Item.Grammar
|
||||||
import qualified IntMapHelp as IM
|
import qualified IntMapHelp as IM
|
||||||
import Data.IntMap.Merge.Strict
|
|
||||||
import NewInt
|
import NewInt
|
||||||
|
|
||||||
-- assumes all item locations inside the items are correct
|
-- assumes all item locations inside the items are correct
|
||||||
@@ -48,10 +48,13 @@ crUpdateItemLocations crid lw = fromMaybe lw $ do
|
|||||||
crSetRoots :: Int -> LWorld -> LWorld
|
crSetRoots :: Int -> LWorld -> LWorld
|
||||||
crSetRoots cid w = fromMaybe w $ do
|
crSetRoots cid w = fromMaybe w $ do
|
||||||
inv <- w ^? creatures . ix cid . crInv
|
inv <- w ^? creatures . ix cid . crInv
|
||||||
-- invRootTrees inv
|
return $
|
||||||
return $ w & creatures . ix cid . crInv %~ merge dropMissing preserveMissing
|
w & creatures . ix cid . crInv
|
||||||
(zipWithMatched f)
|
%~ merge
|
||||||
(invRootTrees inv)
|
dropMissing
|
||||||
|
preserveMissing
|
||||||
|
(zipWithMatched f)
|
||||||
|
(invRootTrees inv)
|
||||||
where
|
where
|
||||||
f _ _ = itLocation . ilIsRoot .~ True
|
f _ _ = itLocation . ilIsRoot .~ True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user