Major item refactor, still broken
This commit is contained in:
@@ -95,28 +95,33 @@ moveZoomCamera cfig theinput cr w campos =
|
||||
where
|
||||
mremotepos = do
|
||||
i <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
j <- cr ^? crInv . ix i . itUse . uaParams . apProjectiles . ix 0
|
||||
guard $ Just REMOTESCREEN == cr ^? crInv . ix i . itType . ibtAttach
|
||||
itid <- cr ^? crInv . ix 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 <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
fmap docamrot (cr ^? crInv . ix i . itUse . uScope . opticPos)
|
||||
itid <- cr ^? crInv . ix 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 <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
cr ^? crInv . ix i . itUse . uScope . opticZoom
|
||||
itid <- cr ^? crInv . ix i
|
||||
w ^? cWorld . lWorld . items . ix itid . itUse . uScope . opticZoom
|
||||
idealDefaultZoom = clipZoom wallZoom
|
||||
newDefaultZoom = fromMaybe (changeZoom (campos ^. camDefaultZoom) idealDefaultZoom) $ do
|
||||
i <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
cr ^? crInv . ix i . itUse . uScope . opticZoom
|
||||
itid <- cr ^? crInv . ix i
|
||||
w ^? cWorld . lWorld . items . ix itid . itUse . uScope . opticZoom
|
||||
idealItemZoom = fromMaybe 1 $ do
|
||||
guard $ crIsAiming cr
|
||||
i <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
getAimZoom <$> (cr ^? crInv . ix i)
|
||||
itid <- cr ^? crInv . ix i
|
||||
getAimZoom <$> (w ^? cWorld . lWorld . items . ix itid)
|
||||
newItemZoom = changeZoom (campos ^. camItemZoom) idealItemZoom
|
||||
changeZoom curZoom idealZoom
|
||||
| curZoom > idealZoom + 0.01 = ((zoomOutSpeed -1) * curZoom + idealZoom) / zoomOutSpeed
|
||||
|
||||
@@ -131,7 +131,7 @@ tryPickupSelected k mpos w = do
|
||||
guard $ k == 3
|
||||
guard $ maybe True (\(i, _) -> i == 0 || i == 1) mpos
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
let nfreeslots = crNumFreeSlots cr
|
||||
let nfreeslots = crNumFreeSlots (w ^. cWorld . lWorld . items) cr
|
||||
xs <- w ^? hud . hudElement . diSelection . _Just . _3
|
||||
let itmstopickup = mapMaybe g $ IS.toList xs
|
||||
let slotsneeded = alaf Sum foldMap itInvHeight itmstopickup
|
||||
@@ -238,6 +238,7 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
|
||||
str <-
|
||||
fmap (take 5) $
|
||||
w ^? cWorld . lWorld . creatures . ix 0 . crInv . ix j
|
||||
>>= \k -> w ^? cWorld . lWorld . items . ix k
|
||||
>>= (listToMaybe . basicItemDisplay)
|
||||
return . (worldEventFlags . at CombineInventoryChange ?~ ()) $
|
||||
case w ^? hud . hudElement . subInventory . ciFilter . _Just of
|
||||
@@ -541,7 +542,7 @@ tryCombine (i, j) w = fromMaybe w $ do
|
||||
CombinableItem is it <- sss ^? ix i . ssItems . ix j . siPayload . _Just
|
||||
p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos
|
||||
return $
|
||||
snd (createItemYou it (foldr (destroyInvItem 0) w (sort is)))
|
||||
(createItemYou it (foldr (destroyInvItem 0) w (sort is)))
|
||||
& soundStart InventorySound p wrench1S Nothing
|
||||
& hud . hudElement . diSelection . _Just . _3 .~ mempty
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ module Dodge.Update.Scroll (
|
||||
updateWheelEvent,
|
||||
) where
|
||||
|
||||
import NewInt
|
||||
import Control.Applicative
|
||||
import qualified Data.ListTrie.Patricia.Map.Enum as PTE
|
||||
import Dodge.Data.Terminal.Status
|
||||
@@ -44,13 +45,13 @@ updateBaseWheelEvent yi w
|
||||
bdown b = w & has (input . mouseButtons . ix b)
|
||||
rbscrollmax = fromMaybe 1 $ do
|
||||
invid <- you w ^? crManipulation . manObject . imSelectedItem
|
||||
esite <- you w ^? crInv . ix invid >>= equipType -- . itUse . uequipEffect . eeType
|
||||
esite <- you w ^? crInv . ix invid >>= \k -> w ^? cWorld . lWorld . items . ix k >>= equipType -- . itUse . uequipEffect . eeType
|
||||
return . length $ eqSiteToPositions esite
|
||||
|
||||
selectedItemScroll :: Int -> World -> Maybe World
|
||||
selectedItemScroll yi w = do
|
||||
i <- you w ^? crManipulation . manObject . imSelectedItem
|
||||
itm <- you w ^? crInv . ix i
|
||||
itm <- you w ^? crInv . ix i >>= \k -> w ^? cWorld . lWorld . items . ix k
|
||||
return $ itemScroll yi i itm w
|
||||
|
||||
itemScroll :: Int -> Int -> Item -> World -> World
|
||||
@@ -69,7 +70,8 @@ itemScroll yi invid itm w
|
||||
%~ ((`mod` y) . (+ yi))
|
||||
| otherwise = w
|
||||
where
|
||||
itmlens = cWorld . lWorld . creatures . ix 0 . crInv . ix invid
|
||||
--itmlens = cWorld . lWorld . creatures . ix 0 . crInv . ix invid
|
||||
itmlens = cWorld . lWorld . items . ix (itm ^. itID . unNInt)
|
||||
|
||||
-- note that your _crInvLock does not apply to this TODO check that this is what
|
||||
-- is wanted
|
||||
@@ -82,7 +84,8 @@ updateScopeZoom i w
|
||||
w & wppointer %~ doScopeZoom (w ^. input . smoothScrollAmount) (w ^. input . mousePos)
|
||||
| otherwise = w & wppointer %~ resetscope
|
||||
where
|
||||
wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix i . itUse . uScope
|
||||
itid = w ^?! cWorld . lWorld . creatures . ix 0 . crInv . ix i
|
||||
wppointer = cWorld . lWorld . items . ix itid . itUse . uScope
|
||||
resetscope (OpticScope _ _ defz) = OpticScope (V2 0 0) defz defz
|
||||
|
||||
doScopeZoom :: Int -> Point2 -> Scope -> Scope
|
||||
|
||||
Reference in New Issue
Block a user