Distinguish between selected item and root-selected item
This commit is contained in:
@@ -4,6 +4,8 @@ module Dodge.Inventory.Add (
|
||||
createAndSelectItem,
|
||||
) where
|
||||
|
||||
import Dodge.Inventory.FindRoot
|
||||
--import Dodge.Item.Grammar
|
||||
import Control.Lens
|
||||
import Data.Maybe
|
||||
import Dodge.Base.You
|
||||
@@ -47,7 +49,7 @@ createAndSelectItem itm w = case createPutItem itm w of
|
||||
w'
|
||||
& hud . hudElement . diSections . sssExtra . sssSelPos ?~ (0, i)
|
||||
& cWorld . lWorld . creatures . ix 0 . crManipulation . manObject
|
||||
.~ InInventory (SelItem i NoInvSelAction)
|
||||
.~ InInventory (SelectedItem i (getRootItemID i (you w)))
|
||||
(Nothing, w') -> w'
|
||||
|
||||
createPutItem :: Item -> World -> (Maybe Int, World)
|
||||
|
||||
@@ -20,7 +20,7 @@ updateRBList w
|
||||
| otherwise = case w ^. rbOptions of
|
||||
EquipOptions{} -> w
|
||||
_ -> fromMaybe (w & rbOptions .~ NoRightButtonOptions) $ do
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
i <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
|
||||
esite <- cr ^? crInv . ix i . itUse . equipEffect . eeSite
|
||||
return $
|
||||
w
|
||||
@@ -35,7 +35,7 @@ updateRBList w
|
||||
-- find a free equipment slot
|
||||
chooseEquipmentPosition :: Creature -> [EquipPosition] -> Int
|
||||
chooseEquipmentPosition cr eps = fromMaybe (chooseFreeSite cr eps) $ do
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
i <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
|
||||
ep <- cr ^? crInvEquipped . ix i
|
||||
elemIndex ep eps
|
||||
|
||||
@@ -46,7 +46,7 @@ chooseFreeSite cr = fromMaybe 0 . findIndex hasnoequipment
|
||||
|
||||
getEquipmentAllocation :: World -> EquipmentAllocation
|
||||
getEquipmentAllocation w = fromMaybe DoNotMoveEquipment $ do
|
||||
curpos <- you w ^? crManipulation . manObject . inInventory . ispItem
|
||||
curpos <- you w ^? crManipulation . manObject . inInventory . imSelectedItem
|
||||
esite <- you w ^? crInv . ix curpos . itUse . equipEffect . eeSite
|
||||
i <- w ^? rbOptions . opSel
|
||||
<|> Just (chooseEquipmentPosition (you w) (equipSiteToPositions esite))
|
||||
|
||||
Reference in New Issue
Block a user