diff --git a/src/Dodge/Data/Item/Scope.hs b/src/Dodge/Data/Item/Scope.hs index c7f829f87..9bcc2756f 100644 --- a/src/Dodge/Data/Item/Scope.hs +++ b/src/Dodge/Data/Item/Scope.hs @@ -22,7 +22,7 @@ data Scope | ZoomScope { -- | a camera offset _scopePos :: Point2 - , _scopeZoomChange :: Int +-- , _scopeZoomChange :: Int , _scopeZoom :: Float , _scopeDefaultZoom :: Float , -- | if the camera offset is also the center of vision diff --git a/src/Dodge/HeldScroll.hs b/src/Dodge/HeldScroll.hs index d6a76cf6e..bd21fd4ad 100644 --- a/src/Dodge/HeldScroll.hs +++ b/src/Dodge/HeldScroll.hs @@ -7,7 +7,6 @@ import Control.Lens hiding ((<|), (|>)) import Data.Sequence import Dodge.Data.Creature import Dodge.Data.World -import Dodge.Item.Weapon.ZoomScope import Data.Maybe --import LensHelp hiding ((|>), (<|)) -- should be able to just import data.item @@ -15,7 +14,7 @@ import Data.Maybe doHeldScroll :: HeldScroll -> Float -> Creature -> World -> World doHeldScroll hs = case hs of HeldScrollDoNothing -> const . const id - HeldScrollZoom -> overYourItem (const . setZoomScopeChange) + HeldScrollZoom -> const . const id HeldScrollCharMode{} -> overYourItem $ \x _ -> itUse . heldScroll . hsCharMode %~ cycleSignum x where overYourItem f x cr w = fromMaybe w $ do diff --git a/src/Dodge/Item/Held/Rod.hs b/src/Dodge/Item/Held/Rod.hs index df8ec0ca7..f440c4c7e 100644 --- a/src/Dodge/Item/Held/Rod.hs +++ b/src/Dodge/Item/Held/Rod.hs @@ -71,7 +71,7 @@ sniperRifle = & itParams . gunBarrels .~ SingleBarrel 0 & itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 0.5, _izMin = 0.5,_izFac = 1} & itUse . heldScroll .~ HeldScrollZoom -- zoomLongGun - & itScope .~ ZoomScope (V2 0 0) 0 1 0.5 False + & itScope .~ ZoomScope (V2 0 0) 1 0.5 False & itUse . useTargeting ?~ TargetLaser machineGun :: Item diff --git a/src/Dodge/Item/Held/Utility.hs b/src/Dodge/Item/Held/Utility.hs index cec0a2726..b44a3332b 100644 --- a/src/Dodge/Item/Held/Utility.hs +++ b/src/Dodge/Item/Held/Utility.hs @@ -32,7 +32,7 @@ latchkey _ = binoculars :: Item binoculars = defaultHeldItem - & itScope .~ ZoomScope (V2 0 0) 0 1 0.5 False + & itScope .~ ZoomScope (V2 0 0) 1 0.5 False & itType . iyBase .~ HELD BINOCULARS & itUse . heldAim . aimHandlePos .~ 5 & itUse . heldAim . aimMuzPos .~ 10 diff --git a/src/Dodge/Item/Weapon/ZoomScope.hs b/src/Dodge/Item/Weapon/ZoomScope.hs deleted file mode 100644 index ee37fee8e..000000000 --- a/src/Dodge/Item/Weapon/ZoomScope.hs +++ /dev/null @@ -1,19 +0,0 @@ -module Dodge.Item.Weapon.ZoomScope where - -import Dodge.Data.Item -import LensHelp --- should be possible without the creature - -setZoomScopeChange :: Float -> Item -> Item -setZoomScopeChange x - | x > 0 = itScope . scopeZoomChange %~ (max 0 . (+ xi)) - | x < 0 = itScope . scopeZoomChange %~ (min 0 . (+ xi)) - | otherwise = id - where - xi | x > 2 = 20 - | x > 1 = 10 - | x > 0 = 1 - | x < -2 = - 20 - | x < -1 = - 10 - | x < -0 = - 1 - | otherwise = 0 diff --git a/src/Dodge/Update/Camera.hs b/src/Dodge/Update/Camera.hs index a86822e81..8881580b3 100644 --- a/src/Dodge/Update/Camera.hs +++ b/src/Dodge/Update/Camera.hs @@ -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