Partially working change to selected items

This commit is contained in:
2023-02-07 12:07:13 +00:00
parent 5f7d662454
commit c354949ca9
27 changed files with 386 additions and 288 deletions
+17 -7
View File
@@ -43,7 +43,9 @@ moveZoomCamera cfig theinput cr campos =
& camItemZoom .~ newItemZoom
where
cpos = _crPos cr
mitm = cr ^? crInv . ix (crSel cr)
mitm = do
i <- cr ^? crInvSel . isel . ispItem
cr ^? crInv . ix i
newvf = cpos +.+ fromMaybe (V2 0 0) vfoffset
vfoffset = do
iscam <- mitm ^? _Just . itScope . scopeIsCamera
@@ -83,11 +85,16 @@ moveZoomCamera cfig theinput cr campos =
zoomOutSpeed = 15
updateScopeZoom :: World -> World
updateScopeZoom w
updateScopeZoom w = fromMaybe w $ do
i <- w ^? cWorld . lWorld . creatures . ix 0 . crInvSel . isel . ispItem
return $ updateScopeZoom' i w
updateScopeZoom' :: Int -> World -> World
updateScopeZoom' i w
| SDL.ButtonRight `M.member` _mouseButtons (_input w) = w & wppointer %~ doScopeZoom mp
| otherwise = w & wppointer %~ resetscope
where
wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix (crSel (w ^?! cWorld . lWorld . creatures . ix 0)) . itScope
wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix i . itScope
resetscope (ZoomScope _ _ _ defz bl) = ZoomScope (V2 0 0) 0 defz defz bl
resetscope otherAtt = otherAtt
mp = rotateV (w ^. cWorld . camPos . camRot) $ _mousePos (_input w)
@@ -170,10 +177,13 @@ rotateCameraBy :: Float -> CWorld -> CWorld
rotateCameraBy x w =
w
& camPos . camRot +~ x
& lWorld . creatures . ix 0 . crInv . ix (crSel (w ^?! lWorld . creatures . ix 0))
. itScope
. scopePos
%~ rotateV x
& fromMaybe id (do
i <- w ^? lWorld . creatures . ix 0 . crInvSel . isel . ispItem
return $ lWorld . creatures . ix 0 . crInv . ix i
. itScope
. scopePos
%~ rotateV x
)
rotateCamera :: Configuration -> World -> World
rotateCamera cfig w
+2 -1
View File
@@ -105,11 +105,12 @@ moveTweakSel i w = case yourItem w ^? _Just . itTweaks . tweakParams of
changeTweakParam :: Maybe Int -> Int -> World -> World
changeTweakParam mi i w = fromMaybe w $ do
curpos <- you w ^? crInvSel . isel . ispItem
paramid <- mi
params <- yourItem w ^? _Just . itTweaks . tweakParams . ix paramid
let x = (_tweakVal params + i) `mod` _tweakMax params
return $
w & cWorld . lWorld . creatures . ix 0 . crInv . ix (crSel (you w))
w & cWorld . lWorld . creatures . ix 0 . crInv . ix curpos
%~ ( (itTweaks . tweakParams . ix paramid . tweakVal .~ x)
. doTweak (_tweakType params) x
)