Distinguish between selected item and root-selected item
This commit is contained in:
@@ -25,7 +25,7 @@ import qualified IntMapHelp as IM
|
||||
useItemRightClick :: Creature -> World -> World
|
||||
useItemRightClick cr' w = fromMaybe (f w) $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix (_crID cr')
|
||||
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
itRef <- cr ^? crManipulation . manObject . inInventory . imRootItem
|
||||
it <- invTrees (_crInv cr) ^? ix itRef
|
||||
return $
|
||||
itemEffect cr it w
|
||||
@@ -51,7 +51,7 @@ itemEffect cr it w = case it ^. ldtValue . itUse of
|
||||
AmmoMagUse{} -> w
|
||||
where
|
||||
itm = it ^. ldtValue
|
||||
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||
itRef = cr ^?! crManipulation . manObject . inInventory . imRootItem -- unsafe!! TODO change
|
||||
hammerTest f = case _crHammerPosition cr of
|
||||
HammerUp -> f w & setuhamdown
|
||||
_ -> w & setuhamdown
|
||||
@@ -97,14 +97,16 @@ toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
|
||||
crpoint = cWorld . lWorld . creatures . ix (_crID cr)
|
||||
itmat i = _crInv cr IM.! i
|
||||
itm = itmat itRef
|
||||
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change?
|
||||
itRef = cr ^?! crManipulation . manObject . inInventory . imSelectedItem -- unsafe!! TODO change?
|
||||
onequip itm' = useE ((_eeOnEquip . _equipEffect . _itUse) itm') itm'
|
||||
onremove itm' = useE ((_eeOnRemove . _equipEffect . _itUse) itm') itm'
|
||||
|
||||
-- need to make sure that the root item is not erroneously selected in the
|
||||
-- following
|
||||
useItemLeftClick :: Creature -> World -> World
|
||||
useItemLeftClick cr w = fromMaybe w $ do
|
||||
guard . not $ _crInvLock cr
|
||||
invid <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
invid <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
|
||||
ituse <- cr ^? crInv . ix invid . itUse
|
||||
case ituse of
|
||||
--HeldUse{} -> return $ hammerTest (cWorld . lWorld . creatures . ix (_crID cr) %~ crReloadToggle)
|
||||
|
||||
Reference in New Issue
Block a user