diff --git a/src/Dodge/Update/Camera.hs b/src/Dodge/Update/Camera.hs index 84941b8cd..8ec692a84 100644 --- a/src/Dodge/Update/Camera.hs +++ b/src/Dodge/Update/Camera.hs @@ -5,6 +5,7 @@ module Dodge.Update.Camera ( updateCamera, ) where +import Dodge.HeldScroll import Bound import Control.Applicative import Control.Monad @@ -76,7 +77,7 @@ updateInGameCamera cfig w = & updateBounds cfig & over wCam (setViewDistance cfig) & wCam %~ moveZoomCamera cfig (w ^. input) (you w) --- & updateScopeZoom + & updateScopeZoom & rotateCamera cfig moveZoomCamera :: Configuration -> Input -> Creature -> Camera -> Camera @@ -102,6 +103,7 @@ moveZoomCamera cfig theinput cr campos = (cr ^? crInv . ix (i - 1) . itUse . attachParams . scrollAttachParams . opticPos) <|> (mitm ^? _Just . itScope . remotePos) newcen = cpos +.+ fromMaybe (V2 0 0) mscopeoffset +.+ offset +-- newcen = cpos +.+ fromMaybe offset mscopeoffset -- +.+ offset offset = rotateV (campos ^. camRot) $ ((newzoom - newDefaultZoom) / (newDefaultZoom * newzoom)) *.* _mousePos theinput @@ -112,9 +114,12 @@ moveZoomCamera cfig theinput cr campos = ---- Just zs@ZoomScope{} -> _scopeZoom zs -- _ -> newDefaultZoom * newItemZoom idealDefaultZoom = clipZoom wallZoom - newDefaultZoom = case mitm ^? _Just . itScope of --- Just zs@ZoomScope{} -> _scopeZoom zs - _ -> changeZoom (campos ^. camDefaultZoom) idealDefaultZoom +-- newDefaultZoom = case mitm ^? _Just . itScope of +---- Just zs@ZoomScope{} -> _scopeZoom zs +-- _ -> changeZoom (campos ^. camDefaultZoom) idealDefaultZoom + newDefaultZoom = fromMaybe (changeZoom (campos ^. camDefaultZoom) idealDefaultZoom) $ do + i <- cr ^? crManipulation . manObject . inInventory . ispItem + (cr ^? crInv . ix (i - 1) . itUse . attachParams . scrollAttachParams . opticZoom) idealItemZoom = fromMaybe 1 $ do guard $ crIsAiming cr zoomFromItem <$> (mitm ^? _Just . itUse . heldAim . aimZoom) @@ -136,6 +141,9 @@ moveZoomCamera cfig theinput cr campos = updateScopeZoom :: World -> World updateScopeZoom w = fromMaybe w $ do i <- w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . inInventory . ispItem + itm <- _crInv (you w) IM.!? i + atparams <- you w ^? crInv . ix (i - 1) . itUse . attachParams . scrollAttachParams + guard (canHeldScrollAttach itm atparams) return $ updateScopeZoom' i w updateScopeZoom' :: Int -> World -> World