Move optic zoom scrolling to item scrolling function
Zoom scrolling behaviour has slightly changed, I'm not sure how I want it to work yet though
This commit is contained in:
@@ -64,15 +64,16 @@ translateFloatingCameraKeys theinput = (camCenter -~ thetran) . (camViewFrom -~
|
||||
zoomFloatingCamera :: Input -> Camera -> Camera
|
||||
zoomFloatingCamera theinput
|
||||
| ButtonRight `M.member` (theinput ^. mouseButtons) =
|
||||
camZoom *~ (zoomSpeed ^^ negate (getSmoothScrollValue theinput))
|
||||
camZoom *~ (39/40 ^^ negate (getSmoothScrollValue theinput))
|
||||
| otherwise = id
|
||||
-- the 39/40 is taken from zoomSpeed
|
||||
|
||||
updateInGameCamera :: Configuration -> World -> World
|
||||
updateInGameCamera cfig w =
|
||||
w
|
||||
& updateBounds cfig
|
||||
& wCam %~ moveZoomCamera cfig (w ^. input) (you w) w
|
||||
& updateScopeZoom
|
||||
-- & updateScopeZoom
|
||||
& rotateCamera cfig
|
||||
& over wCam (setViewDistance cfig) -- I think this should be updated after the zoom?
|
||||
|
||||
@@ -128,52 +129,6 @@ moveZoomCamera cfig theinput cr w campos =
|
||||
viewDistanceFromItems :: Creature -> Float
|
||||
viewDistanceFromItems _ = 1
|
||||
|
||||
-- note that your _crInvLock does not apply to this TODO check that this is what
|
||||
-- is wanted
|
||||
updateScopeZoom :: World -> World
|
||||
updateScopeZoom w = fromMaybe w $ do
|
||||
i <- you w ^? crManipulation . manObject . imSelectedItem
|
||||
return $ updateScopeZoom' i w
|
||||
|
||||
updateScopeZoom' :: Int -> World -> World
|
||||
updateScopeZoom' i w
|
||||
| SDL.ButtonRight `M.member` _mouseButtons (_input w) =
|
||||
w & wppointer %~ doScopeZoom (w ^. input . smoothScrollAmount) (w ^. input . mousePos)
|
||||
| otherwise = w & wppointer %~ resetscope
|
||||
where
|
||||
wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix i . itUse . uScope
|
||||
resetscope (OpticScope _ _ defz) = OpticScope (V2 0 0) defz defz
|
||||
|
||||
doScopeZoom :: Int -> Point2 -> Scope -> Scope
|
||||
doScopeZoom scrollamount mp sc = case scrollamount of
|
||||
x
|
||||
| x > 10 -> (zoomInLongGun mp . zoomInLongGun mp . zoomInLongGun mp) sc
|
||||
| x > 5 -> (zoomInLongGun mp . zoomInLongGun mp) sc
|
||||
| x > 0 -> zoomInLongGun mp sc
|
||||
| x < -10 -> (zoomOutLongGun . zoomOutLongGun . zoomOutLongGun) sc
|
||||
| x < -5 -> (zoomOutLongGun . zoomOutLongGun) sc
|
||||
| x < 0 -> zoomOutLongGun sc
|
||||
| otherwise -> sc
|
||||
|
||||
zoomSpeed :: Float
|
||||
zoomSpeed = 39 / 40
|
||||
|
||||
zoomInLongGun :: Point2 -> Scope -> Scope
|
||||
zoomInLongGun mousep sc = fromMaybe sc $ do
|
||||
curzoom <- sc ^? opticZoom
|
||||
guard $ curzoom < 8
|
||||
return $
|
||||
sc & opticPos .+.+~ (1 - zoomSpeed) * zoomSpeed / curzoom *.* mousep
|
||||
& opticZoom %~ (/ zoomSpeed)
|
||||
|
||||
zoomOutLongGun :: Scope -> Scope
|
||||
zoomOutLongGun sc = fromMaybe sc $ do
|
||||
curzoom <- sc ^? opticZoom
|
||||
guard $ curzoom > 0.5
|
||||
return $
|
||||
sc & opticPos %~ (\p -> p +.+ (zoomSpeed - 1) / curzoom *.* p)
|
||||
& opticZoom *~ zoomSpeed
|
||||
|
||||
ifConfigWallRotate :: Configuration -> M.Map MouseButton Int -> World -> World
|
||||
ifConfigWallRotate cfig mbs
|
||||
| _gameplay_rotate_to_wall cfig && not (SDL.ButtonRight `M.member` mbs) =
|
||||
|
||||
Reference in New Issue
Block a user