Start implementing attachable scroll items
This commit is contained in:
+20
-21
@@ -93,23 +93,21 @@ moveZoomCamera cfig theinput cr campos =
|
||||
cr ^? crInv . ix i
|
||||
newvf = cpos +.+ fromMaybe (V2 0 0) vfoffset
|
||||
vfoffset = do
|
||||
iscam <- mitm ^? _Just . itScope . scopeIsCamera
|
||||
guard iscam
|
||||
guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
|
||||
mitm ^? _Just . itScope . scopePos
|
||||
mitm ^? _Just . itScope . remotePos
|
||||
mscopeoffset = do
|
||||
guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
|
||||
mitm ^? _Just . itScope . scopePos
|
||||
mitm ^? _Just . itScope . remotePos
|
||||
newcen = cpos +.+ fromMaybe (V2 0 0) mscopeoffset +.+ offset
|
||||
offset =
|
||||
rotateV (campos ^. camRot) $
|
||||
((newzoom - newDefaultZoom) / (newDefaultZoom * newzoom)) *.* _mousePos theinput
|
||||
newzoom = case mitm ^? _Just . itScope of
|
||||
Just zs@ZoomScope{} -> _scopeZoom zs
|
||||
-- Just zs@ZoomScope{} -> _scopeZoom zs
|
||||
_ -> newDefaultZoom * newItemZoom
|
||||
idealDefaultZoom = clipZoom wallZoom
|
||||
newDefaultZoom = case mitm ^? _Just . itScope of
|
||||
Just zs@ZoomScope{} -> _scopeZoom zs
|
||||
-- Just zs@ZoomScope{} -> _scopeZoom zs
|
||||
_ -> changeZoom (campos ^. camDefaultZoom) idealDefaultZoom
|
||||
idealItemZoom = fromMaybe 1 $ do
|
||||
guard $ crIsAiming cr
|
||||
@@ -140,13 +138,12 @@ updateScopeZoom' i 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) defz defz bl
|
||||
resetscope (ZoomScope _ _ defz) = ZoomScope (V2 0 0) defz defz
|
||||
wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix (i - 1) . itUse . attachParams . scrollAttachParams
|
||||
resetscope (ZoomScrollParams _ _ defz) = ZoomScrollParams (V2 0 0) defz defz
|
||||
resetscope otherAtt = otherAtt
|
||||
mp = rotateV (w ^. wCam . camRot) $ _mousePos (_input w)
|
||||
|
||||
doScopeZoom :: Int -> Point2 -> Scope -> Scope
|
||||
doScopeZoom :: Int -> Point2 -> ScrollAttachParams -> ScrollAttachParams
|
||||
doScopeZoom scrollamount mp sc = case scrollamount of
|
||||
x
|
||||
| x > 10 -> (zoomInLongGun mp . zoomInLongGun mp . zoomInLongGun mp) sc
|
||||
@@ -160,21 +157,21 @@ doScopeZoom scrollamount mp sc = case scrollamount of
|
||||
zoomSpeed :: Float
|
||||
zoomSpeed = 39 / 40
|
||||
|
||||
zoomInLongGun :: Point2 -> Scope -> Scope
|
||||
zoomInLongGun :: Point2 -> ScrollAttachParams -> ScrollAttachParams
|
||||
zoomInLongGun mousep sc = fromMaybe sc $ do
|
||||
curzoom <- sc ^? scopeZoom
|
||||
curzoom <- sc ^? opticZoom
|
||||
guard $ curzoom < 8
|
||||
return $
|
||||
sc & scopePos .+.+~ (1 - zoomSpeed) * zoomSpeed / curzoom *.* mousep
|
||||
& scopeZoom %~ (/ zoomSpeed)
|
||||
sc & opticPos .+.+~ (1 - zoomSpeed) * zoomSpeed / curzoom *.* mousep
|
||||
& opticZoom %~ (/ zoomSpeed)
|
||||
|
||||
zoomOutLongGun :: Scope -> Scope
|
||||
zoomOutLongGun :: ScrollAttachParams -> ScrollAttachParams
|
||||
zoomOutLongGun sc = fromMaybe sc $ do
|
||||
curzoom <- sc ^? scopeZoom
|
||||
curzoom <- sc ^? opticZoom
|
||||
guard $ curzoom > 0.5
|
||||
return $
|
||||
sc & scopePos %~ (\p -> p +.+ (zoomSpeed - 1) / curzoom *.* p)
|
||||
& scopeZoom *~ zoomSpeed
|
||||
sc & opticPos %~ (\p -> p +.+ (zoomSpeed - 1) / curzoom *.* p)
|
||||
& opticZoom *~ zoomSpeed
|
||||
|
||||
ifConfigWallRotate :: Configuration -> World -> World
|
||||
ifConfigWallRotate cfig w
|
||||
@@ -213,9 +210,11 @@ rotateCameraBy x w =
|
||||
rotateanyscope = fromMaybe id $ do
|
||||
i <- w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . inInventory . ispItem
|
||||
return $
|
||||
lWorld . creatures . ix 0 . crInv . ix i
|
||||
. itScope
|
||||
. scopePos
|
||||
lWorld . creatures . ix 0 . crInv . ix (i - 1)
|
||||
. itUse
|
||||
. attachParams
|
||||
. scrollAttachParams
|
||||
. opticPos
|
||||
%~ rotateV x
|
||||
|
||||
rotateCamera :: Configuration -> World -> World
|
||||
|
||||
@@ -26,10 +26,14 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
|
||||
-- functions that modify the inventory should be centralised so that
|
||||
-- this lock can be sensibly applied, perhaps
|
||||
| w ^?! cWorld . lWorld . creatures . ix 0 . crInvLock -> w
|
||||
| rbDown -> case (yourItem w ^? _Just . itUse . heldScroll, _rbOptions w) of
|
||||
(_, EquipOptions{}) -> w & rbOptions . opSel %~ scrollRBOption yi rbscrollmax
|
||||
(Nothing, _) -> closeObjScrollDir y w
|
||||
(Just f, _) -> doHeldScroll f y (you w) w
|
||||
-- | rbDown -> case (yourItem w ^? _Just . itUse . heldScroll, _rbOptions w) of
|
||||
-- (_, EquipOptions{}) -> w & rbOptions . opSel %~ scrollRBOption yi rbscrollmax
|
||||
-- (Nothing, _) -> closeObjScrollDir y w
|
||||
-- (Just f, _) -> doHeldScroll f y (you w) w
|
||||
| rbDown -> case (yourScrollAttachment w, _rbOptions w) of
|
||||
(_,EquipOptions{}) -> w & rbOptions . opSel %~ scrollRBOption yi rbscrollmax
|
||||
(Nothing, _) -> w -- closeObjScrollDir y w
|
||||
(Just (invid,hs), _) -> doHeldScroll invid hs y w
|
||||
| lbDown -> w & wCam . camZoom +~ y
|
||||
| invKeyDown -> changeSwapSel yi w
|
||||
| otherwise -> stopSoundFrom (CrReloadSound 0) $ scrollAugInvSel yi w
|
||||
|
||||
Reference in New Issue
Block a user