Remove invTrees function
This commit is contained in:
@@ -40,16 +40,6 @@ useRootItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMaybe w
|
|||||||
where
|
where
|
||||||
fst3 (x,_,_) = x
|
fst3 (x,_,_) = x
|
||||||
|
|
||||||
-- where
|
|
||||||
-- UseHotkey{} -> doequipmentchange
|
|
||||||
-- UseEquip{} -> doequipmentchange
|
|
||||||
-- (UseConsume eff) -> useC eff (_ldtValue itmtree) cr w
|
|
||||||
-- UseCraft{} -> w
|
|
||||||
-- UseAttach{} -> selectUse itmtree cr w
|
|
||||||
-- UseAmmoMag{} -> w
|
|
||||||
-- UseScope{} -> w
|
|
||||||
-- UseBulletMod{} -> w
|
|
||||||
|
|
||||||
toggleEquipmentAt :: Int -> Creature -> World -> World
|
toggleEquipmentAt :: Int -> Creature -> World -> World
|
||||||
toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
|
toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
|
||||||
DoNotMoveEquipment -> w
|
DoNotMoveEquipment -> w
|
||||||
@@ -108,8 +98,7 @@ useItemLeftClick cr w = fromMaybe w $ do
|
|||||||
UseHotkey{} -> return $ doequipmentchange invid
|
UseHotkey{} -> return $ doequipmentchange invid
|
||||||
UseAmmoMag{} -> return w
|
UseAmmoMag{} -> return w
|
||||||
UseAttach{} -> do
|
UseAttach{} -> do
|
||||||
itmtree <- invTrees (_crInv cr) ^? ix invid
|
return $ selectUse itm cr w
|
||||||
return $ selectUse itmtree cr w
|
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
where
|
where
|
||||||
doequipmentchange invid = fromMaybe w $ do
|
doequipmentchange invid = fromMaybe w $ do
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
module Dodge.Item.Grammar (
|
module Dodge.Item.Grammar (
|
||||||
invLDT,
|
invLDT,
|
||||||
invTrees,
|
|
||||||
invAdj,
|
invAdj,
|
||||||
invRootMap,
|
invRootMap,
|
||||||
invRootTrees,
|
invRootTrees,
|
||||||
@@ -9,7 +8,6 @@ module Dodge.Item.Grammar (
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Data.Bifunctor
|
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Dodge.Data.ComposedItem
|
import Dodge.Data.ComposedItem
|
||||||
@@ -205,19 +203,6 @@ invAdj = IM.unions . map g . invLDT
|
|||||||
(error ("invAdj item " ++ show (_itID itm) ++ " location: " ++ show (itm ^? itLocation)))
|
(error ("invAdj item " ++ show (_itID itm) ++ " location: " ++ show (itm ^? itLocation)))
|
||||||
$ itm ^? itLocation . ilInvID
|
$ itm ^? itLocation . ilInvID
|
||||||
|
|
||||||
-- returns an intmap with trees for all items
|
|
||||||
invTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ComposeLinkType Item)
|
|
||||||
invTrees = fmap (first _iatType) . invTrees'
|
|
||||||
|
|
||||||
-- returns an intmap with trees for all items
|
|
||||||
invTrees' :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ItemLink Item)
|
|
||||||
--invTrees' = IM.unions . map (ldtToIM getindex . fmap (^. _1)) . map (fmap (\(x, y, _) -> (x, y))) . invLDT
|
|
||||||
invTrees' = IM.unions . map (ldtToIM getindex . fmap (^. _1)) . invLDT
|
|
||||||
where
|
|
||||||
getindex i =
|
|
||||||
fromMaybe (error "in invTrees try to get non-inventory item tree") $
|
|
||||||
i ^? itLocation . ilInvID
|
|
||||||
|
|
||||||
-- returns an intmap with trees for (only!) root items, indexed by inventory position
|
-- returns an intmap with trees for (only!) root items, indexed by inventory position
|
||||||
invRootTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ItemLink ComposedItem)
|
invRootTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ItemLink ComposedItem)
|
||||||
invRootTrees = IM.fromDistinctAscList . reverse . map getid . invLDT
|
invRootTrees = IM.fromDistinctAscList . reverse . map getid . invLDT
|
||||||
|
|||||||
@@ -4,17 +4,15 @@ import Control.Monad
|
|||||||
import qualified SDL
|
import qualified SDL
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Dodge.Data.ComposedItem
|
|
||||||
import Dodge.Data.DoubleTree
|
|
||||||
import Dodge.Data.World
|
import Dodge.Data.World
|
||||||
import Dodge.Payload
|
import Dodge.Payload
|
||||||
|
|
||||||
selectUse :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
selectUse :: Item -> Creature -> World -> World
|
||||||
selectUse ittree _ w = fromMaybe w $ do
|
selectUse itm _ w = fromMaybe w $ do
|
||||||
lbtime <- w ^? input . mouseButtons . ix SDL.ButtonLeft
|
lbtime <- w ^? input . mouseButtons . ix SDL.ButtonLeft
|
||||||
guard $ lbtime == 0
|
guard $ lbtime == 0
|
||||||
itid <- ittree ^? ldtValue . itID
|
itid <- itm ^? itID
|
||||||
pjid <- ittree ^? ldtValue . itUse . uaParams . apLinkedProjectile . _Just
|
pjid <- itm ^? itUse . uaParams . apLinkedProjectile . _Just
|
||||||
thepj <- w ^? cWorld . lWorld . projectiles . ix pjid
|
thepj <- w ^? cWorld . lWorld . projectiles . ix pjid
|
||||||
return $
|
return $
|
||||||
w
|
w
|
||||||
|
|||||||
Reference in New Issue
Block a user