Fix bugs in equipment allocation using hotkeys
The behaviour is still not perfect, should be able to cycle through all options by pressing one key. There is unnecessary memory of past state going on here
This commit is contained in:
+2
-20
@@ -7,7 +7,6 @@ module Dodge.Inventory (
|
||||
augInvDirectSelect,
|
||||
scrollAugInvSel,
|
||||
crNumFreeSlots,
|
||||
crInvSize,
|
||||
setInvPosFromSS,
|
||||
module Dodge.Inventory.RBList,
|
||||
swapInvItems,
|
||||
@@ -72,10 +71,6 @@ rmInvItem cid invid w =
|
||||
& pointcid . crInv %~ f -- important
|
||||
& removeAnySlotEquipment
|
||||
& pointcid . crEquipment . each %~ g
|
||||
-- & removeanyactivation
|
||||
-- & cWorld . lWorld . hotkeys . each %~ g
|
||||
-- & cWorld . lWorld . imHotkeys %~ IM.delete invid
|
||||
-- & cWorld . lWorld . imHotkeys %~ IM.mapKeys g
|
||||
& updateselection
|
||||
& updateselectionextra
|
||||
& pointcid %~ updateRootItemID
|
||||
@@ -87,7 +82,7 @@ rmInvItem cid invid w =
|
||||
| otherwise = id
|
||||
updateselection
|
||||
| cid == 0 && cr ^? crManipulation . manObject . imSelectedItem == Just invid =
|
||||
scrollAugInvSel (-1) . scrollAugInvSel 1 -- . updateInventorySectionItems
|
||||
scrollAugInvSel (-1) . scrollAugInvSel 1
|
||||
| otherwise =
|
||||
pointcid . crManipulation . manObject . imSelectedItem %~ g
|
||||
cr = w ^?! cWorld . lWorld . creatures . ix cid
|
||||
@@ -102,9 +97,6 @@ rmInvItem cid invid w =
|
||||
epos <- w ^? cWorld . lWorld . creatures . ix cid . crInv . ix invid
|
||||
. itLocation . ilEquipSite . _Just
|
||||
return $ pointcid . crEquipment . at epos .~ Nothing
|
||||
-- removeanyactivation = fromMaybe id $ do
|
||||
-- epos <- w ^? cWorld . lWorld . imHotkeys . ix invid
|
||||
-- return $ cWorld . lWorld . hotkeys . at epos .~ Nothing
|
||||
maxk = fmap fst $ IM.lookupMax $ cr ^. crInv
|
||||
f inv =
|
||||
let (xs, ys) = IM.split invid inv
|
||||
@@ -132,21 +124,12 @@ updateCloseObjects w =
|
||||
isclose pos = dist ypos pos < 40 && hasButtonLOS ypos pos w
|
||||
ypos = _crPos $ you w
|
||||
activeButtons =
|
||||
filter ((/=) BtNoLabel . _btState)
|
||||
filter ((/=) BtInactive . _btState)
|
||||
. IM.elems
|
||||
$ w ^. cWorld . lWorld . buttons
|
||||
|
||||
-- updatecursorposifnecessary =
|
||||
-- case w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . ispCloseObject of
|
||||
-- Just i
|
||||
-- | i >= length newcloseobjects -> scrollAugInvSel 1
|
||||
-- | isNothing (w ^? hud . hudElement . diSections . ix 3 . ssItems . ix i) ->
|
||||
-- scrollAugInvSel (-1)
|
||||
-- _ -> id
|
||||
|
||||
changeSwapSel :: Int -> World -> World
|
||||
changeSwapSel yi w
|
||||
-- | yi == 0 = w
|
||||
| yi >= 0 = foldl' (&) w $ replicate yi (changeSwapWith $ f IM.cycleLT)
|
||||
| otherwise = foldl' (&) w $ replicate (negate yi) (changeSwapWith $ f IM.cycleGT)
|
||||
where
|
||||
@@ -175,7 +158,6 @@ changeSwapOther manlens n f i w = fromMaybe w $ do
|
||||
& hud . hudElement . diSelection . _Just . _2 %~ doswap
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
|
||||
|
||||
swapItemWith ::
|
||||
(Int -> IM.IntMap (SelectionItem ()) -> Maybe Int) ->
|
||||
(Int, Int) ->
|
||||
|
||||
Reference in New Issue
Block a user