Distinguish between selected item and root-selected item

This commit is contained in:
2024-09-21 21:59:53 +01:00
parent 2154abfb1d
commit 31b5db6e9e
33 changed files with 313 additions and 281 deletions
+6 -6
View File
@@ -88,26 +88,26 @@ moveZoomCamera cfig theinput cr campos =
where
vfoffset = fromMaybe 0 $ do
guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
i <- cr ^? crManipulation . manObject . inInventory . ispItem
i <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
(cr ^? crInv . ix i . itScope . remotePos)
docamrot = rotateV (campos ^. camRot)
offset = fromMaybe noscopeoffset $ do
guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
i <- cr ^? crManipulation . manObject . inInventory . ispItem
i <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
(fmap docamrot (cr ^? crInv . ix i . itScope . opticPos))
<|> (cr ^? crInv . ix i . itScope . remotePos)
noscopeoffset = docamrot $
((newzoom - newDefaultZoom) / (newDefaultZoom * newzoom)) *.* _mousePos theinput
newzoom = fromMaybe (newDefaultZoom * newItemZoom) $ do
i <- cr ^? crManipulation . manObject . inInventory . ispItem
i <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
(cr ^? crInv . ix i . itScope . opticZoom)
idealDefaultZoom = clipZoom wallZoom
newDefaultZoom = fromMaybe (changeZoom (campos ^. camDefaultZoom) idealDefaultZoom) $ do
i <- cr ^? crManipulation . manObject . inInventory . ispItem
i <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
(cr ^? crInv . ix i . itScope . opticZoom)
idealItemZoom = fromMaybe 1 $ do
guard $ crIsAiming cr
i <- cr ^? crManipulation . manObject . inInventory . ispItem
i <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
zoomFromItem <$> (cr ^? crInv . ix i . itUse . heldAim . aimZoom)
newItemZoom = changeZoom (campos ^. camItemZoom) idealItemZoom
changeZoom curZoom idealZoom
@@ -128,7 +128,7 @@ moveZoomCamera cfig theinput cr campos =
-- is wanted
updateScopeZoom :: World -> World
updateScopeZoom w = fromMaybe w $ do
i <- you w ^? crManipulation . manObject . inInventory . ispItem
i <- you w ^? crManipulation . manObject . inInventory . imSelectedItem
return $ updateScopeZoom' i w
updateScopeZoom' :: Int -> World -> World