Cleanup, stop assigning hotkeys to unequipped items
This commit is contained in:
+73
-59
@@ -51,13 +51,21 @@ rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount
|
||||
_ ->
|
||||
w
|
||||
& pointcid %~ crCancelReloading
|
||||
& removeAnySlotEquipment -- the ordering
|
||||
& dounequipfunction -- of these is
|
||||
& pointcid . crInv %~ f -- important
|
||||
& pointcid . crLeftInvSel . lisMPos %~ g'
|
||||
& doanyitemeffect
|
||||
& dounequipfunction --the ordering of these is
|
||||
& pointcid . crInv %~ f -- important
|
||||
-- & pointcid . crLeftInvSel . lisMPos %~ g'
|
||||
|
||||
& removeAnySlotEquipment
|
||||
& pointcid . crEquipment . each %~ g
|
||||
& pointcid . crInvEquipped %~ IM.delete invid
|
||||
& pointcid . crInvEquipped %~ IM.mapKeys g
|
||||
|
||||
& removeanyactivation
|
||||
& pointcid . crHotkeys . each %~ g
|
||||
& pointcid . crInvHotkeys %~ IM.delete invid
|
||||
& pointcid . crInvHotkeys %~ IM.mapKeys g
|
||||
|
||||
& updateselection
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
where
|
||||
@@ -81,6 +89,9 @@ rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount
|
||||
removeAnySlotEquipment = fromMaybe id $ do
|
||||
epos <- w ^? cWorld . lWorld . creatures . ix cid . crInvEquipped . ix invid
|
||||
return $ pointcid . crEquipment . at epos .~ Nothing
|
||||
removeanyactivation = fromMaybe id $ do
|
||||
epos <- w ^? cWorld . lWorld . creatures . ix cid . crInvHotkeys . ix invid
|
||||
return $ pointcid . crHotkeys . at epos .~ Nothing
|
||||
maxk = fmap fst $ IM.lookupMax $ cr ^. crInv
|
||||
f inv =
|
||||
let (xs, ys) = IM.split invid inv
|
||||
@@ -89,11 +100,11 @@ rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount
|
||||
g x
|
||||
| x > invid || Just x == maxk = max 0 $ x - 1
|
||||
| otherwise = x
|
||||
g' Nothing = Nothing
|
||||
g' (Just x)
|
||||
| x == invid = Nothing
|
||||
| x > invid || Just x == maxk = Just $ max 0 $ x - 1
|
||||
| otherwise = Just x
|
||||
-- g' Nothing = Nothing
|
||||
-- g' (Just x)
|
||||
-- | x == invid = Nothing
|
||||
-- | x > invid || Just x == maxk = Just $ max 0 $ x - 1
|
||||
-- | otherwise = Just x
|
||||
|
||||
rmSelectedInvItem :: Int -> World -> World
|
||||
rmSelectedInvItem cid w = case w ^? cWorld . lWorld . creatures . ix cid . crManipulation . manObject . inInventory . ispItem of
|
||||
@@ -131,7 +142,7 @@ updateCloseObjects w =
|
||||
updateRBList :: World -> World
|
||||
updateRBList w
|
||||
| w ^? rbOptions . opItemID == mcurrentitemid =
|
||||
w & setEquipAllocationActivation
|
||||
w & setEquipAllocation
|
||||
| otherwise = fromMaybe (w & rbOptions .~ NoRightButtonOptions) $ do
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
esite <- cr ^? crInv . ix i . itUse . equipEffect . eeSite
|
||||
@@ -146,7 +157,7 @@ updateRBList w
|
||||
, _opAllocateEquipment = DoNotMoveEquipment
|
||||
, _opActivateEquipment = NoChangeActivateEquipment
|
||||
}
|
||||
& setEquipAllocationActivation
|
||||
& setEquipAllocation
|
||||
where
|
||||
mcurrentitemid = do
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
@@ -164,9 +175,6 @@ chooseFreeSite cr = fromMaybe 0 . findIndex hasnoequipment
|
||||
where
|
||||
hasnoequipment ep = isNothing $ cr ^? crEquipment . ix ep
|
||||
|
||||
setEquipAllocationActivation :: World -> World
|
||||
setEquipAllocationActivation = setEquipActivation . setEquipAllocation
|
||||
|
||||
setEquipAllocation :: World -> World
|
||||
setEquipAllocation w = fromMaybe w $ do
|
||||
curpos <- you w ^? crManipulation . manObject . inInventory . ispItem
|
||||
@@ -196,46 +204,46 @@ setEquipAllocation w = fromMaybe w $ do
|
||||
}
|
||||
Nothing -> PutOnEquipment{_allocNewPos = es}
|
||||
|
||||
setEquipActivation :: World -> World
|
||||
setEquipActivation w = case w ^? rbOptions . opAllocateEquipment of
|
||||
Just DoNotMoveEquipment -> w
|
||||
Just RemoveEquipment{} ->
|
||||
case you w ^. crLeftInvSel . lisMPos of
|
||||
Just i
|
||||
| Just i == minvsel ->
|
||||
w & rbOptions . opActivateEquipment
|
||||
.~ DeactivateEquipment
|
||||
{ _deactivateEquipment = i
|
||||
}
|
||||
_ -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||
Just rbos ->
|
||||
case you w ^. crLeftInvSel . lisMPos of
|
||||
Just i | Just i == minvsel -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||
Just i
|
||||
| invselcanactivate ->
|
||||
w & rbOptions . opActivateEquipment
|
||||
.~ ActivateDeactivateEquipment
|
||||
{ _activateEquipment = fromJust minvsel
|
||||
, _deactivateEquipment = i
|
||||
}
|
||||
Just i
|
||||
| Just i == rbos ^? allocRemoveID ->
|
||||
w & rbOptions . opActivateEquipment .~ DeactivateEquipment i
|
||||
Just _ -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||
Nothing
|
||||
| invselcanactivate ->
|
||||
w & rbOptions . opActivateEquipment
|
||||
.~ ActivateEquipment
|
||||
{ _activateEquipment = fromJust minvsel
|
||||
}
|
||||
Nothing -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||
Nothing -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||
where
|
||||
minvsel = cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
cr = you w
|
||||
invselcanactivate = isJust $ do
|
||||
i <- minvsel
|
||||
return $ cr ^? crInv . ix i . itUse . leftUse
|
||||
--setEquipActivation :: World -> World
|
||||
--setEquipActivation w = case w ^? rbOptions . opAllocateEquipment of
|
||||
-- Just DoNotMoveEquipment -> w
|
||||
-- Just RemoveEquipment{} ->
|
||||
-- case you w ^. crLeftInvSel . lisMPos of
|
||||
-- Just i
|
||||
-- | Just i == minvsel ->
|
||||
-- w & rbOptions . opActivateEquipment
|
||||
-- .~ DeactivateEquipment
|
||||
-- { _deactivateEquipment = i
|
||||
-- }
|
||||
-- _ -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||
-- Just rbos ->
|
||||
-- case you w ^. crLeftInvSel . lisMPos of
|
||||
-- Just i | Just i == minvsel -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||
-- Just i
|
||||
-- | invselcanactivate ->
|
||||
-- w & rbOptions . opActivateEquipment
|
||||
-- .~ ActivateDeactivateEquipment
|
||||
-- { _activateEquipment = fromJust minvsel
|
||||
-- , _deactivateEquipment = i
|
||||
-- }
|
||||
-- Just i
|
||||
-- | Just i == rbos ^? allocRemoveID ->
|
||||
-- w & rbOptions . opActivateEquipment .~ DeactivateEquipment i
|
||||
-- Just _ -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||
-- Nothing
|
||||
-- | invselcanactivate ->
|
||||
-- w & rbOptions . opActivateEquipment
|
||||
-- .~ ActivateEquipment
|
||||
-- { _activateEquipment = fromJust minvsel
|
||||
-- }
|
||||
-- Nothing -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||
-- Nothing -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||
-- where
|
||||
-- minvsel = cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
-- cr = you w
|
||||
-- invselcanactivate = isJust $ do
|
||||
-- i <- minvsel
|
||||
-- return $ cr ^? crInv . ix i . itUse . leftUse
|
||||
|
||||
equipSiteToPositions :: EquipSite -> [EquipPosition]
|
||||
equipSiteToPositions es = case es of
|
||||
@@ -288,21 +296,27 @@ changeSwapInv f i w = fromMaybe w $ do
|
||||
& hud . hudElement . diSections . sssExtra . sssSelPos . _Just . _2 .~ k
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
where
|
||||
updateLeftInvSel k li
|
||||
| i == li = k
|
||||
| k == li = i
|
||||
| otherwise = li
|
||||
-- updateLeftInvSel k li
|
||||
-- | i == li = k
|
||||
-- | k == li = i
|
||||
-- | otherwise = li
|
||||
updatecreature k =
|
||||
(crInv %~ IM.safeSwapKeys i k)
|
||||
. (crLeftInvSel . lisMPos . _Just %~ updateLeftInvSel k)
|
||||
-- . (crLeftInvSel . lisMPos . _Just %~ updateLeftInvSel k)
|
||||
. (crManipulation . manObject . inInventory . ispItem .~ k)
|
||||
. (crInvEquipped %~ IM.safeSwapKeys i k)
|
||||
. swapSite i k
|
||||
. swapSite k i
|
||||
. (crInvHotkeys %~ IM.safeSwapKeys i k)
|
||||
. swapSite' i k
|
||||
. swapSite' k i
|
||||
cr = you w
|
||||
swapSite a b = case cr ^? crInvEquipped . ix a of
|
||||
Just epos -> crEquipment . ix epos .~ b
|
||||
Nothing -> id
|
||||
swapSite' a b = case cr ^? crInvHotkeys . ix a of
|
||||
Just epos -> crHotkeys . ix epos .~ b
|
||||
Nothing -> id
|
||||
|
||||
changeSwapWith :: (Int -> IM.IntMap (SelectionItem ()) -> Maybe Int) -> World -> World
|
||||
changeSwapWith f w = case w ^? hud . hudElement . diSections . sssExtra . sssSelPos . _Just of
|
||||
|
||||
Reference in New Issue
Block a user