Fix scroll selection of floor items and buttons

This commit is contained in:
2022-12-25 23:37:42 +00:00
parent 2ae7f2bbc1
commit d2141d90ae
13 changed files with 75 additions and 126 deletions
+3 -7
View File
@@ -121,11 +121,7 @@ closeObjectCol e = case e of
Right _ -> yellow
selNumPos :: Int -> World -> Int
selNumPos i w = splitgap + (foldl' (+) 0 . fst $ IM.split i (augmentedInvSizes w))
where
splitgap = 0
-- | i < length (yourInv w) = 0
-- | otherwise = 1
selNumPos i w = sum . fst $ IM.split i (augmentedInvSizes w)
selNumTextPos :: Configuration -> World -> Int -> Point2
selNumTextPos cfig w i = V2 (150 - hw) (hh - (20 * fromIntegral ipos + 20))
@@ -162,7 +158,7 @@ updateTerminal = checkTermDist
checkTermDist :: World -> World
checkTermDist w = case w ^? cWorld . lWorld . hud . hudElement . subInventory . termID of
Just tmid -> fromMaybe (w & cWorld . lWorld . hud . hudElement .~ DisplayInventory NoSubInventory) $ do
Just tmid -> fromMaybe (w & cWorld . lWorld . hud . hudElement . subInventory .~ NoSubInventory) $ do
btid <- w ^? cWorld . lWorld . terminals . ix tmid . tmButtonID
btpos <- w ^? cWorld . lWorld . buttons . ix btid . btPos
if dist btpos (_crPos $ you w) < 40 then Just w else Nothing
@@ -395,4 +391,4 @@ selectedCloseObject w
inv = _crInv cr
selectNthCloseObject :: World -> Int -> Maybe (Int, Either FloorItem Button)
selectNthCloseObject w n = (length (yourInv w) + n,) <$> (_closeObjects (_lWorld (_cWorld w)) !? n)
selectNthCloseObject w n = (length (yourInv w) + n + 1,) <$> (_closeObjects (_lWorld (_cWorld w)) !? n)