Tweak scrolling, particularly zooming

This commit is contained in:
2023-01-07 19:50:44 +00:00
parent 6b259fa200
commit d4122b2d6f
7 changed files with 42 additions and 37 deletions
+11 -13
View File
@@ -84,16 +84,12 @@ moveZoomCamera cfig theinput cr campos =
updateScopeZoom :: World -> World
updateScopeZoom w
| SDL.ButtonRight `M.member` _mouseButtons (_input w) = over wppointer (doScopeZoom mp) w
| otherwise =
w
& cWorld . lWorld . creatures . ix 0 . crInv . ix (crSel (w ^?! cWorld . lWorld . creatures . ix 0))
. itScope
%~ updateScope
| 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
updateScope (ZoomScope _ _ _ defz bl) = ZoomScope (V2 0 0) 0 defz defz bl
updateScope otherAtt = otherAtt
resetscope (ZoomScope _ _ _ defz bl) = ZoomScope (V2 0 0) 0 defz defz bl
resetscope otherAtt = otherAtt
mp = rotateV (w ^. cWorld . camPos . camRot) $ _mousePos (_input w)
doScopeZoom :: Point2 -> Scope -> Scope
@@ -117,23 +113,25 @@ zoomInLongGun mousep sc
sc
& scopePos .+.+~ (1 - zoomSpeed) / newzoom *.* mousep
& scopeZoom %~ (/ zoomSpeed)
& decreaseScopeZoomChange
& scopeZoomChange -~ 1
| otherwise = sc & scopeZoomChange .~ 0
where
decreaseScopeZoomChange = scopeZoomChange -~ 1
Just currentZoom = sc ^? scopeZoom
newzoom = (sc ^?! scopeZoom) / zoomSpeed
zoomOutLongGun :: Scope -> Scope
zoomOutLongGun sc
| currentZoom > 0.5 =
| currentzoom > 0.5 =
sc
-- & scopePos .+.+~ ((1*zoomSpeed-1)) / currentZoom *.* mousep
& scopePos %~ (\p -> p +.+ (zoomSpeed-1) / currentzoom *.* p)
-- & scopePos .*.*~ 1 - ((newzoom * 2) ** zoomSpeed)
& scopeZoom *~ zoomSpeed
& scopeZoomChange +~ 1
| otherwise = sc & scopeZoomChange .~ 0
& scopePos .~ V2 0 0
where
Just currentZoom = sc ^? scopeZoom
Just currentzoom = sc ^? scopeZoom
--newzoom = (sc ^?! scopeZoom) / zoomSpeed
ifConfigWallRotate :: Configuration -> World -> World
ifConfigWallRotate cfig w