Start collapsing manipulated item code with selection code

This commit is contained in:
2026-05-14 14:24:57 +01:00
parent 59d128f87a
commit 06b984c2e5
21 changed files with 86 additions and 64 deletions
+16 -10
View File
@@ -6,6 +6,7 @@ module Dodge.Update.Camera (
updateCamera,
) where
import NewInt
import Dodge.Update.Camera.Rotate
import Linear.V3
import Dodge.Creature.Radius
@@ -101,34 +102,39 @@ moveZoomCamera cfig theinput cr w campos =
& camItemZoom .~ newItemZoom
where
mremotepos = do
i <- w^?hud . manObject . imSelectedItem
Sel 0 i <- w^?hud .diSelection._Just
--revise1 i <- cr ^? crManipulation . manObject . imSelectedItem
itid <- cr ^? crInv . ix i
--revise2 i <- w^?hud . manObject . imSelectedItem
itid <- cr ^? crInv . ix (NInt i)
j <- w ^? cWorld . lWorld . items . ix itid . itUse . uaParams . apProjectiles . ix 0
guard $ Just REMOTESCREEN == w ^? cWorld . lWorld . items . ix itid . itType . ibtAttach
w ^? cWorld . lWorld . projectiles . ix j . pjPos . _xy
docamrot = rotateV (campos ^. camRot)
offset = fromMaybe noscopeoffset $ do
guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
i <- w^?hud . manObject . imSelectedItem
itid <- cr ^? crInv . ix i
Sel 0 i <- w^?hud.diSelection._Just
--revise2 i <- w^?hud . manObject . imSelectedItem
itid <- cr ^? crInv . ix (NInt i)
fmap docamrot (w ^? cWorld . lWorld . items . ix itid . itUse . uScope . opticPos)
noscopeoffset =
docamrot $
((newzoom - newDefaultZoom) / (newDefaultZoom * newzoom)) *.* _mousePos theinput
newzoom = fromMaybe (newDefaultZoom * newItemZoom) $ do
i <- w^?hud . manObject . imSelectedItem
itid <- cr ^? crInv . ix i
Sel 0 i <- w^?hud .diSelection._Just
--revise2 i <- w^?hud . manObject . imSelectedItem
itid <- cr ^? crInv . ix (NInt i)
w ^? cWorld . lWorld . items . ix itid . itUse . uScope . opticZoom
idealDefaultZoom = clipZoom wallZoom
newDefaultZoom = fromMaybe (changeZoom (campos ^. camDefaultZoom) idealDefaultZoom) $ do
i <- w^?hud . manObject . imSelectedItem
itid <- cr ^? crInv . ix i
Sel 0 i <- w^?hud .diSelection._Just
--revise2 i <- w^?hud . manObject . imSelectedItem
itid <- cr ^? crInv . ix (NInt i)
w ^? cWorld . lWorld . items . ix itid . itUse . uScope . opticZoom
idealItemZoom = fromMaybe 1 $ do
guard $ crIsAiming cr
i <- w^?hud . manObject . imSelectedItem
itid <- cr ^? crInv . ix i
Sel 0 i <- w^?hud .diSelection._Just
--revise2 i <- w^?hud . manObject . imSelectedItem
itid <- cr ^? crInv . ix (NInt i)
getAimZoom <$> (w ^? cWorld . lWorld . items . ix itid)
newItemZoom = changeZoom (campos ^. camItemZoom) idealItemZoom
changeZoom curZoom idealZoom
+6 -4
View File
@@ -42,15 +42,17 @@ updateBaseWheelEvent yi w
where
bdown b = w & has (input . mouseButtons . ix b)
rbscrollmax = fromMaybe 1 $ do
invid <- w ^? hud . manObject . imSelectedItem
Sel 0 invid <- w ^. hud.diSelection
--revise2 invid <- w ^? hud . manObject . imSelectedItem
--revise1 invid <- you w ^? crManipulation . manObject . imSelectedItem
etype <- you w ^? crInv . ix invid >>= \k -> w ^? cWorld . lWorld . items . ix k >>= equipType
etype <- you w ^? crInv . ix (NInt invid) >>= \k -> w ^? cWorld . lWorld . items . ix k >>= equipType
return . length $ eqTypeToSites etype
selectedItemScroll :: Int -> World -> Maybe World
selectedItemScroll yi w = do
i <- w ^? hud . manObject . imSelectedItem
itm <- you w ^? crInv . ix i >>= \k -> w ^? cWorld . lWorld . items . ix k
Sel 0 i <- w ^.hud.diSelection
--revise2 i <- w ^? hud . manObject . imSelectedItem
itm <- you w ^? crInv . ix (NInt i) >>= \k -> w ^? cWorld . lWorld . items . ix k
return $ itemScroll yi itm w
itemScroll :: Int -> Item -> World -> World