Move scroll smoothing to central location
This commit is contained in:
@@ -128,31 +128,25 @@ updateScopeZoom w = fromMaybe w $ do
|
||||
|
||||
updateScopeZoom' :: Int -> World -> World
|
||||
updateScopeZoom' i w
|
||||
| SDL.ButtonRight `M.member` _mouseButtons (_input w) = w & wppointer %~ doScopeZoom mp
|
||||
| SDL.ButtonRight `M.member` _mouseButtons (_input w)
|
||||
= w & wppointer %~ doScopeZoom (w ^. input . smoothScrollAmount) mp
|
||||
| otherwise = w & wppointer %~ resetscope
|
||||
where
|
||||
wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix i . itScope
|
||||
resetscope (ZoomScope _ _ _ defz bl) = ZoomScope (V2 0 0) 0 defz defz bl
|
||||
resetscope (ZoomScope _ _ defz bl) = ZoomScope (V2 0 0) defz defz bl
|
||||
resetscope otherAtt = otherAtt
|
||||
mp = rotateV (w ^. wCam . camRot) $ _mousePos (_input w)
|
||||
|
||||
doScopeZoom :: Point2 -> Scope -> Scope
|
||||
doScopeZoom mp sc = case sc ^? scopeZoomChange of
|
||||
Just x
|
||||
doScopeZoom :: Int -> Point2 -> Scope -> Scope
|
||||
doScopeZoom scrollamount mp sc = case scrollamount of
|
||||
x
|
||||
| x > 10 -> (zoomInLongGun mp . zoomInLongGun mp . zoomInLongGun mp) $ sc
|
||||
& scopeZoomChange -~ 2
|
||||
| x > 5 -> (zoomInLongGun mp . zoomInLongGun mp) $ sc
|
||||
& scopeZoomChange -~ 1
|
||||
| x > 0 -> zoomInLongGun mp $ sc
|
||||
& scopeZoomChange -~ 1
|
||||
| x < -10 -> (zoomOutLongGun . zoomOutLongGun . zoomOutLongGun) $ sc
|
||||
& scopeZoomChange +~ 2
|
||||
| x < -5 -> (zoomOutLongGun . zoomOutLongGun) $ sc
|
||||
& scopeZoomChange +~ 1
|
||||
| x < 0 -> zoomOutLongGun $ sc
|
||||
& scopeZoomChange +~ 1
|
||||
| otherwise -> sc
|
||||
_ -> sc
|
||||
|
||||
zoomSpeed :: Float
|
||||
zoomSpeed = 39 / 40
|
||||
@@ -163,7 +157,7 @@ zoomInLongGun mousep sc
|
||||
sc
|
||||
& scopePos .+.+~ (1 - zoomSpeed) / newzoom *.* mousep
|
||||
& scopeZoom %~ (/ zoomSpeed)
|
||||
| otherwise = sc & scopeZoomChange .~ 0
|
||||
| otherwise = sc
|
||||
where
|
||||
Just currentZoom = sc ^? scopeZoom
|
||||
newzoom = (sc ^?! scopeZoom) / zoomSpeed
|
||||
@@ -175,7 +169,7 @@ zoomOutLongGun sc
|
||||
& scopePos %~ (\p -> p +.+ (zoomSpeed-1) / currentzoom *.* p)
|
||||
-- & scopePos .*.*~ 1 - ((newzoom * 2) ** zoomSpeed)
|
||||
& scopeZoom *~ zoomSpeed
|
||||
| otherwise = sc & scopeZoomChange .~ 0
|
||||
| otherwise = sc
|
||||
& scopePos .~ V2 0 0
|
||||
where
|
||||
Just currentzoom = sc ^? scopeZoom
|
||||
|
||||
Reference in New Issue
Block a user