Display basic tree of attachments in inventory

This commit is contained in:
2024-09-13 16:19:17 +01:00
parent bd681a577c
commit fb104a1719
3 changed files with 39 additions and 27 deletions
+14 -4
View File
@@ -62,7 +62,7 @@ drawInventory sss w cfig = drawSelectionSections sss (invDisplayParams w) cfig
where
iextra = fromMaybe mempty $ do
inv <- w ^? cWorld . lWorld . creatures . ix 0 . crInv
return $ inventoryExtra cfig (invAdj inv) (fmap (^._2) $ invIndentIM inv)
return $ inventoryExtra sss cfig w (invAdj inv)
drawSubInventory :: SubInventory -> Configuration -> World -> Picture
drawSubInventory subinv cfig w = case subinv of
@@ -183,8 +183,16 @@ examineInventoryExtra mtweaki cfig = fromMaybe mempty $ do
translate subInvX (-71) $
listCursorChooseBorderScale 0 1 [North, South, West] tweaki 0 white 10 1
inventoryExtra :: Configuration -> IM.IntMap ([Int],[Int]) -> IM.IntMap Int -> Picture
inventoryExtra = undefined
inventoryExtra :: SelectionSections () -> Configuration -> World -> IM.IntMap ([Int],[Int]) -> Picture
inventoryExtra sss cfig w is = translate (negate 5) 0 $ IM.foldMapWithKey (inventoryExtraH sss cfig w) $ fmap (\(a,b) -> a<>b) is
inventoryExtraH :: SelectionSections () -> Configuration -> World -> Int -> [Int] -> Picture
inventoryExtraH sss cfig w i is = fromMaybe mempty $ do
p <- snum i
let ps = mapMaybe snum is
return $ color white $ lConnectMulti ps p
where
snum = selNumPos cfig (invDisplayParams w) sss 0
combineInventoryExtra :: SelectionSections CombinableItem -> Configuration -> World -> Picture
combineInventoryExtra sss cfig w = fromMaybe mempty $ do
@@ -355,9 +363,11 @@ selNumPos ::
selNumPos cfig ldp sss i j = do
ipos <- selSecYint i j sss
size <- selSecSelSize i j sss
indent <- sss ^? sssSections . ix i . ssItems . ix j . siOffX
return $
screenPosAbs cfig (ldp ^. ldpPos)
+ V2 0 (negate (20 * s + ygap) * (fromIntegral ipos + fromIntegral size * 0.5))
+ V2 (10 * s * fromIntegral indent)
(negate (20 * s + ygap) * (fromIntegral ipos + fromIntegral size * 0.5))
where
s = _ldpScale ldp
ygap = _ldpVerticalGap ldp