Distinguish between selected item and root-selected item
This commit is contained in:
+11
-5
@@ -14,6 +14,7 @@ module Dodge.Inventory (
|
||||
module Dodge.Inventory.RBList
|
||||
) where
|
||||
|
||||
import Dodge.Inventory.FindRoot
|
||||
import Dodge.Inventory.RBList
|
||||
import Control.Applicative
|
||||
import Data.Maybe
|
||||
@@ -59,15 +60,16 @@ rmInvItem cid invid w = w
|
||||
& pointcid . crInvHotkeys %~ IM.mapKeys g
|
||||
|
||||
& updateselection
|
||||
& pointcid %~ updateRootItemID
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
where
|
||||
pointcid = cWorld . lWorld . creatures . ix cid
|
||||
|
||||
updateselection
|
||||
| cid == 0 && cr ^? crManipulation . manObject . inInventory . ispItem == Just invid =
|
||||
| cid == 0 && cr ^? crManipulation . manObject . inInventory . imSelectedItem == Just invid =
|
||||
scrollAugInvSel (-1) . scrollAugInvSel 1 . updateInventorySectionItems
|
||||
| otherwise =
|
||||
pointcid . crManipulation . manObject . inInventory . ispItem %~ g
|
||||
pointcid . crManipulation . manObject . inInventory . imSelectedItem %~ g
|
||||
|
||||
cr = w ^?! cWorld . lWorld . creatures . ix cid
|
||||
itm = _crInv cr IM.! invid
|
||||
@@ -158,7 +160,7 @@ rmInvItem cid invid w = w
|
||||
-- | otherwise = x
|
||||
|
||||
rmSelectedInvItem :: Int -> World -> World
|
||||
rmSelectedInvItem cid w = case w ^? cWorld . lWorld . creatures . ix cid . crManipulation . manObject . inInventory . ispItem of
|
||||
rmSelectedInvItem cid w = case w ^? cWorld . lWorld . creatures . ix cid . crManipulation . manObject . inInventory . imSelectedItem of
|
||||
Just i -> rmInvItem cid i w
|
||||
Nothing -> w
|
||||
|
||||
@@ -231,6 +233,7 @@ changeSwapInv f i w = fromMaybe w $ do
|
||||
k <- f i ss
|
||||
return $
|
||||
w & cWorld . lWorld . creatures . ix 0 %~ updatecreature k
|
||||
& cWorld . lWorld . creatures . ix 0 %~ updateRootItemID
|
||||
& hud . hudElement . diSections . sssExtra . sssSelPos . _Just . _2 .~ k
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
where
|
||||
@@ -241,7 +244,7 @@ changeSwapInv f i w = fromMaybe w $ do
|
||||
updatecreature k =
|
||||
(crInv %~ IM.safeSwapKeys i k)
|
||||
-- . (crLeftInvSel . lisMPos . _Just %~ updateLeftInvSel k)
|
||||
. (crManipulation . manObject . inInventory . ispItem .~ k)
|
||||
. (crManipulation . manObject . inInventory . imSelectedItem .~ k)
|
||||
. (crInvEquipped %~ IM.safeSwapKeys i k)
|
||||
. swapSite i k
|
||||
. swapSite k i
|
||||
@@ -280,12 +283,15 @@ setInvPosFromSS w =
|
||||
(i, j) <- sss ^? sssExtra . sssSelPos . _Just
|
||||
case i of
|
||||
(-1) -> Just $ InInventory SortInventory
|
||||
0 -> Just $ InInventory (SelItem j NoInvSelAction)
|
||||
--0 -> Just $ InInventory (SelItem j (getRootItemID i (you w)))
|
||||
0 -> Just $ InInventory (SelectedItem j (getRootItemID j (you w)))
|
||||
1 -> Just SelNothing
|
||||
2 -> Just $ InNearby SortNearby
|
||||
3 -> Just $ InNearby $ SelCloseObject j
|
||||
_ -> error "selection out of bounds"
|
||||
|
||||
|
||||
|
||||
selectedCloseObject :: World -> Maybe (Either FloorItem Button)
|
||||
selectedCloseObject w = do
|
||||
i <-
|
||||
|
||||
Reference in New Issue
Block a user