Partially working scrolling below list to floor items

This commit is contained in:
2021-12-01 00:04:54 +00:00
parent 42d7ca3ba8
commit 0ed260c9b7
4 changed files with 99 additions and 56 deletions
+5 -48
View File
@@ -51,37 +51,6 @@ subInventoryDisplay cfig w = case _inventoryMode w of
col = itCol it
cursPos = invSelPos w
--crInvSelSize :: Creature -> Int
--crInvSelSize cr = fromMaybe 1 $ fmap _itInvSize $ _crInv cr IM.!? _crInvSel cr
--crInvSelPos :: Creature -> Int
--crInvSelPos cr = foldl' (+) 0 . fmap _itInvSize . fst $ IM.split (_crInvSel cr) (_crInv cr)
invSelPos :: World -> Int
invSelPos w = splitgap + (foldl' (+) 0 . fst $ IM.split invsel (augmentedInvSizes w))
where
invsel = yourInvSel w
splitgap
| yourInvSel w < length (yourInv w) = 0
| otherwise = 1
augmentedInvSizes :: World -> IM.IntMap Int
augmentedInvSizes w = IM.union (fmap _itInvSize $ yourInv w)
(IM.fromAscList $ zip [length (yourInv w) ..] $ map closeObjectSize $ _closeObjects w)
--augmentedInvSizesWithGap :: World -> IM.IntMap Int
--augmentedInvSizesWithGap w = IM.union (safeUpdateMax (Just . (+1)) $ fmap _itInvSize $ yourInv w)
-- (IM.fromAscList $ zip [length (yourInv w) ..] $ (map closeObjectSize $ _closeObjects w))
--
--safeUpdateMax :: (a -> Maybe a) -> IM.IntMap a -> IM.IntMap a
--safeUpdateMax f m
-- | IM.null m = m
-- | otherwise = IM.updateMax f m
closeObjectSize :: Either FloorItem Button -> Int
closeObjectSize e = case e of
Left flit -> _itInvSize $ _flIt flit
Right bt -> 1
cursorsZ :: Configuration -> Int -> Maybe Item -> Picture
cursorsZ cfig ipos it = case it ^? _Just . itTweaks . tweakSel of
Nothing -> f $ zConnect sp (V2 (155- hw) ( hh - 77.5))
@@ -133,10 +102,14 @@ displayInv :: Int -> Configuration -> World -> Picture
displayInv n cfig w = listTextPicturesAt 0 0 cfig invlist
<> equipcursor
<> selcursor
<> closeobjectcursor
where
selcursor
| IM.null inv && null (_closeObjects w) = mempty
| otherwise = listCursorAt 0 0 cfig curpos white curx cury
closeobjectcursor = case selectedCloseObject w of
Nothing -> mempty
Just (i,_) -> listCursorAt 50 0 cfig (selNumPos i w) blue 15 (invSelSize i w)
inv = _crInv cr
invlist = (concatMap itemToTextPictures $ IM.elems inv)
++ displayFreeSlots ++ concatMap (closeObjectToTextPictures nfreeslots) (_closeObjects w)
@@ -147,11 +120,10 @@ displayInv n cfig w = listTextPicturesAt 0 0 cfig invlist
x -> [color invDimColor . text $ " +" ++ show x ++ " FREE SLOTS"]
curpos = invSelPos w
curx = 10
--cury = crInvSelSize $ you w
cury = fromMaybe 1 $ augmentedInvSizes w IM.!? _crInvSel (you w)
equipcursor = case _crLeftInvSel cr of
Nothing -> mempty
Just invid -> openCursorAt 20 yellow 0 0 invid cfig
Just invid -> openCursorAt 20 yellow 0 0 (selNumPos invid w) cfig
cr = _creatures w IM.! n
invDimColor :: Color
invDimColor = greyN 0.7
@@ -201,21 +173,6 @@ mapWall cfig w wl =
(x,y) = _wlLine wl
c = _wlColor wl
bestCloseObjectIndex :: World -> Maybe Int
bestCloseObjectIndex w = Nothing
selectedCloseObject :: World -> Maybe (Int,Either FloorItem Button)
selectedCloseObject w
| invsel > length inv = Just $ selectNthCloseObject w (invsel - length inv)
| otherwise = fmap (selectNthCloseObject w) $ bestCloseObjectIndex w
where
invsel = _crInvSel cr
cr = you w
inv = _crInv cr
invsize = crInvSize (you w)
selectNthCloseObject :: World -> Int -> (Int,Either FloorItem Button)
selectNthCloseObject w n = undefined
selectedCloseObjectLink :: Configuration -> World -> Picture
selectedCloseObjectLink cfig w = mempty