Continue inventory tweak

This commit is contained in:
2023-02-16 17:07:59 +00:00
parent 934dd64704
commit 4afc216b25
28 changed files with 106 additions and 94 deletions
+15 -15
View File
@@ -60,7 +60,7 @@ rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount
& pointcid . crInv %~ f
& pointcid %~ crCancelReloading
-- & pointcid . crInvSel . iselPos %~ g THIS NEEDS CHECKING
& pointcid . crManipulation . isel . ispItem %~ g
& pointcid . crManipulation . manObject . inInventory . ispItem %~ g
& pointcid . crLeftInvSel . lisMPos %~ g'
& removeAnySlotEquipment
& dounequipfunction
@@ -98,7 +98,7 @@ rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount
| otherwise = Just x
rmSelectedInvItem :: Int -> World -> World
rmSelectedInvItem cid w = case w ^? cWorld . lWorld . creatures . ix cid . crManipulation . isel . ispItem of
rmSelectedInvItem cid w = case w ^? cWorld . lWorld . creatures . ix cid . crManipulation . manObject . inInventory . ispItem of
Just i -> rmInvItem cid i w
Nothing -> w
@@ -172,7 +172,7 @@ updateCloseObjects w =
where
newcloseobjects = unionBy closeObjEq oldCloseFiltered currentClose
updatecursorposifnecessary
= case w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . isel . ispCloseObject of
= case w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject. ispCloseObject of
Just i | i >= length newcloseobjects -> changeAugInvSel 1
_ -> id
filt = filter $ \obj -> dist ypos (closeObjPos obj) < 40 && hasButtonLOS ypos (closeObjPos obj) w
@@ -193,7 +193,7 @@ updateRBList w
| w ^? rbOptions . opItemID == mcurrentitemid =
w & setEquipAllocation & setEquipActivation
| otherwise = fromMaybe (w & rbOptions .~ NoRightButtonOptions) $ do
i <- cr ^? crManipulation . isel . ispItem
i <- cr ^? crManipulation . manObject . inInventory . ispItem
esite <- cr ^? crInv . ix i . itUse . equipEffect . eeSite
itid <- mcurrentitemid
return $
@@ -210,14 +210,14 @@ updateRBList w
& setEquipActivation
where
mcurrentitemid = do
i <- cr ^? crManipulation . isel . ispItem
i <- cr ^? crManipulation . manObject . inInventory . ispItem
cr ^? crInv . ix i . itID
--curinvid = crSel cr
cr = you w
chooseEquipmentPosition :: Creature -> [EquipPosition] -> Int
chooseEquipmentPosition cr eps = fromMaybe (chooseFreeSite cr eps) $ do
i <- cr ^? crManipulation . isel . ispItem
i <- cr ^? crManipulation . manObject . inInventory . ispItem
ep <- cr ^? crInvEquipped . ix i
elemIndex ep eps
@@ -228,7 +228,7 @@ chooseFreeSite cr = fromMaybe 0 . findIndex hasnoequipment
setEquipAllocation :: World -> World
setEquipAllocation w = fromMaybe w $ do
curpos <- you w ^? crManipulation . isel . ispItem
curpos <- you w ^? crManipulation . manObject . inInventory . ispItem
return $ case _rbOptions w of
EquipOptions{_opEquip = es, _opSel = i} ->
case you w ^? crInvEquipped . ix curpos of
@@ -302,7 +302,7 @@ setEquipActivation w = case w ^? rbOptions . opAllocateEquipment of
Nothing -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
where
--invsel = crSel (you w)
minvsel = cr ^? crManipulation . isel . ispItem
minvsel = cr ^? crManipulation . manObject . inInventory . ispItem
cr = you w
invselcanactivate = isJust $ do
i <- minvsel
@@ -323,10 +323,10 @@ closeObjScrollDir x
| otherwise = id
changeSwapInvSel :: Int -> World -> World
changeSwapInvSel k w = case you w ^? crManipulation . isel of
Just (SelItem i _) -> w & cWorld . lWorld . creatures . ix 0 %~ updatecreature i
changeSwapInvSel k w = case you w ^? crManipulation . manObject of
Just (InInventory (SelItem i _)) -> w & cWorld . lWorld . creatures . ix 0 %~ updatecreature i
Just (SelCloseObject i) -> w
& cWorld . lWorld . creatures . ix 0 . crManipulation . isel . ispCloseObject
& cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . ispCloseObject
.~ ((i - k) `mod` numCO)
& hud . closeObjects %~ swapIndices i ((i - k) `mod` numCO)
_ -> w
@@ -334,7 +334,7 @@ changeSwapInvSel k w = case you w ^? crManipulation . isel of
updatecreature i =
(crInv %~ IM.safeSwapKeys (i `mod` n) (swapi i))
. (crLeftInvSel . lisMPos . _Just %~ updateLeftInvSel i)
. (crManipulation . isel . ispItem %~ (`mod` n) . subtract k)
. (crManipulation . manObject . inInventory . ispItem %~ (`mod` n) . subtract k)
. (crInvEquipped %~ IM.safeSwapKeys i (swapi i))
. swapSite i (swapi i)
. swapSite (swapi i) i
@@ -359,14 +359,14 @@ changeAugInvSel yi w
setInvPosFromSS :: World -> World
setInvPosFromSS w = w
& cWorld . lWorld . creatures . ix 0 . crManipulation . isel .~ thesel
& cWorld . lWorld . creatures . ix 0 . crManipulation . manObject .~ thesel
where
thesel = fromMaybe SelNothing $ do
sss <- w ^? hud . hudElement . diSections
i <- sss ^? sssSelPos . _Just
j <- sss ^? sssSections . ix i . ssCursor . _Just . scurSel
case i of
0 -> Just $ SelItem j NoInvSelAction
0 -> Just $ InInventory (SelItem j NoInvSelAction)
2 -> Just $ SelCloseObject j
_ -> Just SelNothing
@@ -493,7 +493,7 @@ bestCloseObjectIndex w = findIndex f $ w ^. hud . closeObjects
ycr = you w
selectedCloseObject :: World -> Maybe (Int, Either FloorItem Button)
selectedCloseObject w = case you w ^? crManipulation . isel . ispCloseObject of
selectedCloseObject w = case you w ^? crManipulation . manObject . ispCloseObject of
Just i -> selectNthCloseObject w i
Nothing -> selectNthCloseObject w =<< bestCloseObjectIndex w