Move towards tweak parameters editing items

This commit is contained in:
2021-11-29 21:58:28 +00:00
parent 4f77a15445
commit 02dc7c29e0
6 changed files with 86 additions and 61 deletions
+11 -8
View File
@@ -114,8 +114,8 @@ wheelEvent y w = case (_carteDisplay w, _inventoryMode w) of
(_, TweakInventory)
| invKeyDown && rbDown -> w & moveYourAmmoSel yi
| invKeyDown -> stopSoundFrom (CrReloadSound 0) $ dirInvPos yi w
| rbDown -> w & moveYourAmmoParam yi
| otherwise -> w & moveYourAmmoSel yi
| rbDown -> w & changeTweakParam yi
| otherwise -> w & moveYourAmmoSel yi
(_, _) -> w
where
yi = round $ signum y
@@ -125,14 +125,17 @@ wheelEvent y w = case (_carteDisplay w, _inventoryMode w) of
invKeyDown = ScancodeCapsLock `S.member` _keys w
moveYourAmmoSel :: Int -> World -> World
moveYourAmmoSel i w = case yourItem w ^? itConsumption . aoType. amPjParams of
moveYourAmmoSel i w = case yourItem w ^? itParams . tweakParams of
Just l -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w))
. itConsumption . aoType. amParamSel %~ (`mod` length l) . subtract i
. itParams . tweakSel %~ (`mod` length l) . subtract i
_ -> w
moveYourAmmoParam :: Int -> World -> World
moveYourAmmoParam i w = case yourItem w ^? itConsumption . aoType. amPjParams . ix paramid . pjMaxParam of
changeTweakParam :: Int -> World -> World
changeTweakParam i w =
case yourItem w ^? itParams . tweakParams . ix paramid . pjMaxParam of
Just n -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w))
. itConsumption . aoType. amPjParams . ix paramid . pjIntParam %~ (`mod` n) . (+ i)
. itParams . tweakParams . ix paramid . curTweak %~ (`mod` n) . (+ i)
_ -> w
where
paramid = _amParamSel $ _aoType $ _itConsumption $ yourItem w
it = yourItem w
theparam = it ^? itParams . tweakParams . ix paramid
paramid = _tweakSel $ _itParams $ yourItem w