Work on inventory management

This commit is contained in:
2021-11-30 20:11:03 +00:00
parent 3754627e0d
commit 42d7ca3ba8
8 changed files with 154 additions and 85 deletions
+7 -6
View File
@@ -25,6 +25,7 @@ import Dodge.Inventory
--import Preload.Update
import qualified IntMapHelp as IM
import Data.Maybe
import Control.Lens
--import Data.Maybe
--import Data.Char
@@ -105,15 +106,15 @@ wheelEvent y w = case (_carteDisplay w, _inventoryMode w) of
| rbDown -> w & carteZoom %~ min 0.75 . max 0.05 . ((1+y*0.1) * )
| otherwise -> w & selLocation %~ (`mod` numLocs) . (+ yi)
(_, TopInventory)
| rbDown -> case yourItem w ^? itScroll of
| rbDown -> case yourItem w ^? _Just . itScroll of
Nothing -> closeObjScrollDir y w
Just f -> w & creatures . ix 0 . crInv . ix (_crInvSel $ you w) %~ f y (you w)
| lbDown -> w & cameraZoom +~ y
| invKeyDown -> swapInvDir yi $ stopSoundFrom (CrReloadSound 0) $ dirInvPos yi w
| otherwise -> stopSoundFrom (CrReloadSound 0) $ dirInvPos yi w
| invKeyDown -> swapInvDir yi $ stopSoundFrom (CrReloadSound 0) $ changeInvPos yi w
| otherwise -> stopSoundFrom (CrReloadSound 0) $ changeInvCloseObjectsPos yi w
(_, TweakInventory)
| invKeyDown && rbDown -> w & moveTweakSel yi
| invKeyDown -> stopSoundFrom (CrReloadSound 0) $ dirInvPos yi w
| invKeyDown -> stopSoundFrom (CrReloadSound 0) $ changeInvPos yi w
| rbDown -> w & changeTweakParam yi
| otherwise -> w & moveTweakSel yi
(_, _) -> w
@@ -125,7 +126,7 @@ wheelEvent y w = case (_carteDisplay w, _inventoryMode w) of
invKeyDown = ScancodeCapsLock `S.member` _keys w
moveTweakSel :: Int -> World -> World
moveTweakSel i w = case yourItem w ^? itTweaks . tweakParams of
moveTweakSel i w = case yourItem w ^? _Just . itTweaks . tweakParams of
Just l -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w))
. itTweaks . tweakSel %~ (`mod` length l) . subtract i
_ -> w
@@ -135,7 +136,7 @@ changeTweakParam i w = w
( (itTweaks . tweakParams . ix paramid . curTweak .~ x)
. _doTweak params x)
where
tweaks = _itTweaks $ yourItem w
tweaks = _itTweaks . fromJust $ yourItem w
params = _tweakParams tweaks IM.! paramid
x = (_curTweak params + i) `mod` _maxTweak params
paramid = _tweakSel tweaks