Continue reload refactor
This commit is contained in:
+16
-14
@@ -55,7 +55,7 @@ rmInvItem :: Int -- ^ Creature id
|
||||
rmInvItem cid invid w = case w ^? creatures . ix cid . crInv . ix invid . itConsumption . icAmount of
|
||||
Just x | x > 1 -> w & creatures . ix cid . crInv . ix invid . itConsumption . icAmount %~ subtract 1
|
||||
_ -> w & creatures . ix cid . crInv %~ f
|
||||
& creatures . ix cid . crInvSel %~ g
|
||||
& creatures . ix cid . crInvSel . iselPos %~ g
|
||||
& creatures . ix cid . crLeftInvSel %~ g'
|
||||
& removeAnySlotEquipment
|
||||
& dounequipfunction
|
||||
@@ -87,7 +87,7 @@ rmInvItem cid invid w = case w ^? creatures . ix cid . crInv . ix invid . itCons
|
||||
| otherwise = Just x
|
||||
|
||||
rmSelectedInvItem :: Int -> World -> World
|
||||
rmSelectedInvItem cid w = rmInvItem cid (_crInvSel (_creatures w IM.! cid)) w
|
||||
rmSelectedInvItem cid w = rmInvItem cid (crSel (_creatures w IM.! cid)) w
|
||||
|
||||
augmentedInvSizes :: World -> IM.IntMap Int
|
||||
augmentedInvSizes = bimapAugmentInv itSlotsTaken closeObjectSize
|
||||
@@ -160,7 +160,7 @@ checkTermDist w = case w ^? hud . hudElement . subInventory . termID of
|
||||
updateCloseObjects :: World -> World
|
||||
updateCloseObjects w = w
|
||||
& closeObjects .~ unionBy closeObjEq oldCloseFiltered currentClose
|
||||
& creatures . ix (_yourID w) . crInvSel %~ updateinvsel
|
||||
& creatures . ix (_yourID w) . crInvSel . iselPos %~ updateinvsel
|
||||
where
|
||||
updateinvsel curinvsel
|
||||
| length (augmentedInvSizes w) <= curinvsel = max 0 $ length (augmentedInvSizes w) - 1
|
||||
@@ -192,12 +192,12 @@ updateRBList w
|
||||
Nothing -> w & rbOptions .~ NoRightButtonOptions
|
||||
-- | otherwise = w & rbOptions .~ NoRightButtonOptions
|
||||
where
|
||||
curinvid = _crInvSel cr
|
||||
curinvid = crSel cr
|
||||
cr = you w
|
||||
|
||||
chooseEquipmentPosition :: Creature -> [EquipPosition] -> Int
|
||||
chooseEquipmentPosition cr eps = fromMaybe (chooseFreeSite cr eps) $ do
|
||||
ep <- cr ^? crInvEquipped . ix (_crInvSel cr)
|
||||
ep <- cr ^? crInvEquipped . ix (crSel cr)
|
||||
elemIndex ep eps
|
||||
|
||||
chooseFreeSite :: Creature -> [EquipPosition] -> Int
|
||||
@@ -208,7 +208,7 @@ chooseFreeSite cr = fromMaybe 0 . findIndex hasnoequipment
|
||||
setEquipAllocation :: World -> World
|
||||
setEquipAllocation w = case _rbOptions w of
|
||||
EquipOptions {_opEquip = es,_opSel=i} ->
|
||||
case you w ^? crInvEquipped . ix (_crInvSel (you w)) of
|
||||
case you w ^? crInvEquipped . ix (crSel (you w)) of
|
||||
Just epos | es !! i == epos
|
||||
-> w & rbOptions . opAllocateEquipment .~ RemoveEquipment
|
||||
{_allocOldPos = epos}
|
||||
@@ -254,7 +254,7 @@ setEquipActivation w = case w ^? rbOptions . opAllocateEquipment of
|
||||
Nothing -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||
Nothing -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||
where
|
||||
invsel = _crInvSel (you w)
|
||||
invsel = crSel (you w)
|
||||
invselcanactivate = isJust (you w ^? crInv . ix invsel . itUse . lUse)
|
||||
|
||||
equipSiteToPositions :: EquipSite -> [EquipPosition]
|
||||
@@ -276,8 +276,10 @@ closeObjScrollDir x
|
||||
changeInvSel :: Int -> World -> World
|
||||
changeInvSel i w
|
||||
| n == 0 = w
|
||||
| yourInvSel w < n = w & creatures . ix (_yourID w) . crInvSel %~ (`mod` n) . subtract i
|
||||
| otherwise = w & creatures . ix (_yourID w) . crInvSel %~ ((+n) . (`mod` numCO) . subtract (i+n))
|
||||
| yourInvSel w < n = w & creatures . ix (_yourID w) . crInvSel . iselPos %~ (`mod` n) . subtract i
|
||||
& creatures . ix (_yourID w) . crInvSel . iselAction .~ NoInvSelAction
|
||||
| otherwise = w & creatures . ix (_yourID w) . crInvSel . iselPos %~ ((+n) . (`mod` numCO) . subtract (i+n))
|
||||
& creatures . ix (_yourID w) . crInvSel . iselAction .~ NoInvSelAction
|
||||
-- arguably this should jump the invpos into the inventory proper
|
||||
where
|
||||
n = length $ _crInv $ _creatures w IM.! _yourID w
|
||||
@@ -288,12 +290,12 @@ changeSwapInvSel k w
|
||||
| n == 0 = w
|
||||
| yourInvSel w < n = w
|
||||
& creatures . ix (_yourID w) %~ updatecreature
|
||||
| otherwise = w & creatures . ix (_yourID w) . crInvSel .~ ico'
|
||||
| otherwise = w & creatures . ix (_yourID w) . crInvSel . iselPos .~ ico'
|
||||
& closeObjects %~ swapIndices (i - n) (ico' - n)
|
||||
where
|
||||
updatecreature = ( crInv %~ IM.safeSwapKeys (i `mod` n) swapi )
|
||||
. (crLeftInvSel . _Just %~ updateLeftInvSel)
|
||||
. (crInvSel %~ (`mod` n) . subtract k)
|
||||
. (crInvSel . iselPos %~ (`mod` n) . subtract k)
|
||||
. (crInvEquipped %~ IM.safeSwapKeys i swapi)
|
||||
. swapSite i swapi
|
||||
. swapSite swapi i
|
||||
@@ -305,7 +307,7 @@ changeSwapInvSel k w
|
||||
updateLeftInvSel li | i == li = swapi
|
||||
| swapi == li = i
|
||||
| otherwise = li
|
||||
i = _crInvSel cr
|
||||
i = crSel cr
|
||||
ico' = ( (i - (k+n)) `mod` numCO ) + n
|
||||
n = length $ _crInv cr
|
||||
numCO = length $ _closeObjects w
|
||||
@@ -313,7 +315,7 @@ changeSwapInvSel k w
|
||||
changeAugInvSel :: Int -> World -> World
|
||||
changeAugInvSel i w
|
||||
| n == 0 = w
|
||||
| otherwise = w & creatures . ix (_yourID w) . crInvSel %~ (`mod` n) . subtract i
|
||||
| otherwise = w & creatures . ix (_yourID w) . crInvSel . iselPos %~ (`mod` n) . subtract i
|
||||
where
|
||||
n = length (yourInv w) + length (_closeObjects w)
|
||||
|
||||
@@ -329,7 +331,7 @@ selectedCloseObject w
|
||||
| invsel >= length inv = selectNthCloseObject w (invsel - length inv)
|
||||
| otherwise = selectNthCloseObject w =<< bestCloseObjectIndex w
|
||||
where
|
||||
invsel = _crInvSel cr
|
||||
invsel = crSel cr
|
||||
cr = you w
|
||||
inv = _crInv cr
|
||||
|
||||
|
||||
Reference in New Issue
Block a user