Cleanup
This commit is contained in:
+10
-12
@@ -72,34 +72,31 @@ updateInGameCamera :: Configuration -> World -> World
|
||||
updateInGameCamera cfig w =
|
||||
w
|
||||
& updateBounds cfig
|
||||
& over wCam (setViewDistance cfig)
|
||||
& wCam %~ moveZoomCamera cfig (w ^. input) (you w)
|
||||
& updateScopeZoom
|
||||
& rotateCamera cfig
|
||||
& over wCam (setViewDistance cfig) -- I think this should be updated after the zoom?
|
||||
|
||||
moveZoomCamera :: Configuration -> Input -> Creature -> Camera -> Camera
|
||||
moveZoomCamera cfig theinput cr campos =
|
||||
campos
|
||||
& camCenter .~ newcen
|
||||
& camViewFrom .~ newvf
|
||||
& camCenter .~ _crPos cr +.+ offset
|
||||
& camViewFrom .~ _crPos cr +.+ vfoffset
|
||||
& camZoom .~ newzoom
|
||||
& camDefaultZoom .~ newDefaultZoom
|
||||
& camItemZoom .~ newItemZoom
|
||||
where
|
||||
newvf = _crPos cr +.+ fromMaybe (V2 0 0) vfoffset
|
||||
vfoffset = do
|
||||
vfoffset = fromMaybe 0 $ do
|
||||
guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
(cr ^? crInv . ix i . itScope . remotePos)
|
||||
camrot = campos ^. camRot
|
||||
newcen = _crPos cr +.+ offset
|
||||
docamrot = rotateV (campos ^. camRot)
|
||||
offset = fromMaybe noscopeoffset $ do
|
||||
guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
(fmap (rotateV camrot) (cr ^? crInv . ix i . itScope . opticPos))
|
||||
(fmap docamrot (cr ^? crInv . ix i . itScope . opticPos))
|
||||
<|> (cr ^? crInv . ix i . itScope . remotePos)
|
||||
noscopeoffset =
|
||||
rotateV (campos ^. camRot) $
|
||||
noscopeoffset = docamrot $
|
||||
((newzoom - newDefaultZoom) / (newDefaultZoom * newzoom)) *.* _mousePos theinput
|
||||
newzoom = fromMaybe (newDefaultZoom * newItemZoom) $ do
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
@@ -137,13 +134,12 @@ updateScopeZoom w = fromMaybe w $ do
|
||||
updateScopeZoom' :: Int -> World -> World
|
||||
updateScopeZoom' i w
|
||||
| SDL.ButtonRight `M.member` _mouseButtons (_input w) =
|
||||
w & wppointer %~ doScopeZoom (w ^. input . smoothScrollAmount) mp
|
||||
w & wppointer %~ doScopeZoom (w ^. input . smoothScrollAmount) (w ^. input . mousePos)
|
||||
| otherwise = w & wppointer %~ resetscope
|
||||
where
|
||||
wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix i . itScope
|
||||
resetscope (OpticScope _ _ defz) = OpticScope (V2 0 0) defz defz
|
||||
resetscope otherAtt = otherAtt
|
||||
mp = _mousePos (_input w)
|
||||
|
||||
doScopeZoom :: Int -> Point2 -> Scope -> Scope
|
||||
doScopeZoom scrollamount mp sc = case scrollamount of
|
||||
@@ -249,6 +245,8 @@ findBoundDists cfig w
|
||||
hw = halfWidth cfig
|
||||
hh = halfHeight cfig
|
||||
|
||||
-- this probably doesn't need to be updated every frame,
|
||||
-- though I'm not sure how often it should be updated
|
||||
updateBounds :: Configuration -> World -> World
|
||||
updateBounds cfig w = case (w ^. cWorld . cClock) `mod` 5 of
|
||||
0 -> w
|
||||
|
||||
Reference in New Issue
Block a user