Work on tweak datatypes

This commit is contained in:
2021-11-29 23:05:51 +00:00
parent 02dc7c29e0
commit e75cbdf6cb
5 changed files with 32 additions and 45 deletions
+10 -10
View File
@@ -112,10 +112,10 @@ wheelEvent y w = case (_carteDisplay w, _inventoryMode w) of
| invKeyDown -> swapInvDir yi $ stopSoundFrom (CrReloadSound 0) $ dirInvPos yi w
| otherwise -> stopSoundFrom (CrReloadSound 0) $ dirInvPos yi w
(_, TweakInventory)
| invKeyDown && rbDown -> w & moveYourAmmoSel yi
| invKeyDown && rbDown -> w & moveTweakSel yi
| invKeyDown -> stopSoundFrom (CrReloadSound 0) $ dirInvPos yi w
| rbDown -> w & changeTweakParam yi
| otherwise -> w & moveYourAmmoSel yi
| otherwise -> w & moveTweakSel yi
(_, _) -> w
where
yi = round $ signum y
@@ -124,18 +124,18 @@ wheelEvent y w = case (_carteDisplay w, _inventoryMode w) of
lbDown = ButtonLeft `S.member` _mouseButtons w
invKeyDown = ScancodeCapsLock `S.member` _keys w
moveYourAmmoSel :: Int -> World -> World
moveYourAmmoSel i w = case yourItem w ^? itParams . tweakParams of
moveTweakSel :: Int -> World -> World
moveTweakSel i w = case yourItem w ^? itParams . tweakParams of
Just l -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w))
. itParams . tweakSel %~ (`mod` length l) . subtract i
_ -> w
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))
. itParams . tweakParams . ix paramid . curTweak %~ (`mod` n) . (+ i)
_ -> w
changeTweakParam i w = w
& creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w)) %~
( (itParams . tweakParams . ix paramid . curTweak .~ x)
. _doTweak params x)
where
it = yourItem w
theparam = it ^? itParams . tweakParams . ix paramid
params = _tweakParams (_itParams it) IM.! paramid
x = (_curTweak params + i) `mod` _maxTweak params
paramid = _tweakSel $ _itParams $ yourItem w