This commit is contained in:
2024-11-24 22:36:00 +00:00
parent 82c53fc8e3
commit 7d2a4bf439
2 changed files with 54 additions and 30 deletions
+1 -1
View File
@@ -1 +1 @@
All good (593 modules, at 22:07:48) All good (593 modules, at 22:35:05)
+43 -19
View File
@@ -86,8 +86,6 @@ rmInvItem cid invid w =
& pointcid %~ updateRootItemID & pointcid %~ updateRootItemID
& worldEventFlags . at InventoryChange ?~ () & worldEventFlags . at InventoryChange ?~ ()
where where
-- & updateCreatureItemLocations cid
pointcid = cWorld . lWorld . creatures . ix cid pointcid = cWorld . lWorld . creatures . ix cid
updateselectionextra updateselectionextra
| cid == 0 = hud . hudElement . diSelectionExtra .~ mempty | cid == 0 = hud . hudElement . diSelectionExtra .~ mempty
@@ -95,10 +93,8 @@ rmInvItem cid invid w =
updateselection updateselection
| cid == 0 && cr ^? crManipulation . manObject . imSelectedItem == Just invid = | cid == 0 && cr ^? crManipulation . manObject . imSelectedItem == Just invid =
scrollAugInvSel (-1) . scrollAugInvSel 1 -- . updateInventorySectionItems scrollAugInvSel (-1) . scrollAugInvSel 1 -- . updateInventorySectionItems
-- id -- . updateInventorySectionItems
| otherwise = | otherwise =
pointcid . crManipulation . manObject . imSelectedItem %~ g pointcid . crManipulation . manObject . imSelectedItem %~ g
cr = w ^?! cWorld . lWorld . creatures . ix cid cr = w ^?! cWorld . lWorld . creatures . ix cid
itm = _crInv cr IM.! invid itm = _crInv cr IM.! invid
dounequipfunction = fromMaybe id $ do dounequipfunction = fromMaybe id $ do
@@ -132,8 +128,9 @@ updateCloseObjects w =
g oldbts = intersect oldbts cbts `union` cbts g oldbts = intersect oldbts cbts `union` cbts
f olditems = intersect olditems citems `union` citems f olditems = intersect olditems citems `union` citems
cbts = fmap _btID $ filter (isclose . _btPos) activeButtons cbts = fmap _btID $ filter (isclose . _btPos) activeButtons
citems = fmap _flItID . citems =
filter (isclose . _flItPos) fmap _flItID
. filter (isclose . _flItPos)
. IM.elems . IM.elems
$ w ^. cWorld . lWorld . floorItems . unNIntMap $ w ^. cWorld . lWorld . floorItems . unNIntMap
isclose pos = dist ypos pos < 40 && hasButtonLOS ypos pos w isclose pos = dist ypos pos < 40 && hasButtonLOS ypos pos w
@@ -142,6 +139,7 @@ updateCloseObjects w =
filter ((/=) BtNoLabel . _btState) filter ((/=) BtNoLabel . _btState)
. IM.elems . IM.elems
$ w ^. cWorld . lWorld . buttons $ w ^. cWorld . lWorld . buttons
-- updatecursorposifnecessary = -- updatecursorposifnecessary =
-- case w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . ispCloseObject of -- case w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . ispCloseObject of
-- Just i -- Just i
@@ -152,36 +150,60 @@ updateCloseObjects w =
changeSwapSel :: Int -> World -> World changeSwapSel :: Int -> World -> World
changeSwapSel yi w changeSwapSel yi w
| yi == 0 = w -- | yi == 0 = w
| yi > 0 = foldl' (&) w $ replicate yi (changeSwapWith $ f IM.cycleLT) | yi >= 0 = foldl' (&) w $ replicate yi (changeSwapWith $ f IM.cycleLT)
| otherwise = foldl' (&) w $ replicate (negate yi) (changeSwapWith $ f IM.cycleGT) | otherwise = foldl' (&) w $ replicate (negate yi) (changeSwapWith $ f IM.cycleGT)
where where
f g i m = fst <$> g i m f g i m = fst <$> g i m
changeSwapClose :: --changeSwapClose ::
-- (Int -> IM.IntMap (SelectionItem ()) -> Maybe Int) ->
-- Int ->
-- World ->
-- World
--changeSwapClose f i w = fromMaybe w $ do
-- ss <- w ^? hud . hudElement . diSections . ix 3 . ssItems
-- k <- f i ss
-- let doswap j
-- | j == i = k
-- | j == k = i
-- | otherwise = j
-- return $
-- w
-- & swapAnyExtraSelection i k
-- & cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . ispCloseItem
-- %~ doswap
-- & hud . closeItems %~ swapIndices i k
-- & hud . hudElement . diSelection . _Just . _2 %~ doswap
-- & worldEventFlags . at InventoryChange ?~ ()
--changeSwapClose' ::
-- (Int -> IM.IntMap (SelectionItem ()) -> Maybe Int) ->
-- Int ->
-- World ->
-- World
changeSwapOther ::
((Int -> Identity Int) -> ManipulatedObject -> Identity ManipulatedObject) ->
Int ->
(Int -> IM.IntMap (SelectionItem ()) -> Maybe Int) -> (Int -> IM.IntMap (SelectionItem ()) -> Maybe Int) ->
Int -> Int ->
World -> World ->
World World
changeSwapClose f i w = fromMaybe w $ do changeSwapOther manlens n f i w = fromMaybe w $ do
ss <- w ^? hud . hudElement . diSections . ix 3 . ssItems ss <- w ^? hud . hudElement . diSections . ix n . ssItems
k <- f i ss k <- f i ss
let doswap j let doswap j
| j == i = k | j == i = k
| j == k = i | j == k = i
| otherwise = j | otherwise = j
-- updateselection = case w ^? hud . hudElement . diSelection . _Just of
-- Just (0, j) | j == k -> hud . hudElement . diSelection . _Just . _2 .~ i
-- Just (0, j) | j == i -> hud . hudElement . diSelection . _Just . _2 .~ k
-- _ -> id
return $ return $
w w
& swapAnyExtraSelection i k & swapAnyExtraSelection i k
& cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . ispCloseItem & cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . manlens
%~ doswap %~ doswap
& hud . closeItems %~ swapIndices i k & hud . closeItems %~ swapIndices i k
& hud . hudElement . diSelection . _Just . _2 %~ doswap & hud . hudElement . diSelection . _Just . _2 %~ doswap
-- & updateselection
& worldEventFlags . at InventoryChange ?~ () & worldEventFlags . at InventoryChange ?~ ()
-- can be specialised for when we know that item i is selected -- can be specialised for when we know that item i is selected
@@ -269,13 +291,15 @@ swapItemWith ::
World World
swapItemWith f (j, i) w = case j of swapItemWith f (j, i) w = case j of
0 -> w & swapInvItems f i 0 -> w & swapInvItems f i
3 -> w & changeSwapClose f i 3 -> w & changeSwapOther ispCloseItem 3 f i
5 -> w & changeSwapOther ispCloseButton 5 f i
_ -> w _ -> w
changeSwapWith :: (Int -> IM.IntMap (SelectionItem ()) -> Maybe Int) -> World -> World changeSwapWith :: (Int -> IM.IntMap (SelectionItem ()) -> Maybe Int) -> World -> World
changeSwapWith f w = case w ^? hud . hudElement . diSelection . _Just of changeSwapWith f w = case w ^? hud . hudElement . diSelection . _Just of
Just (0, i) -> w & swapInvItems f i Just (0, i) -> w & swapInvItems f i
Just (3, i) -> w & changeSwapClose f i Just (3, i) -> w & changeSwapOther ispCloseItem 3 f i
Just (5, i) -> w & changeSwapOther ispCloseButton 5 f i
_ -> w _ -> w
augInvDirectSelect :: (Int, Int) -> World -> World augInvDirectSelect :: (Int, Int) -> World -> World