Add count of used items to combinations

This commit is contained in:
2022-02-17 10:05:04 +00:00
parent 6573b3346e
commit bae0e1f0b7
3 changed files with 37 additions and 10 deletions
+3
View File
@@ -50,6 +50,9 @@ invertListInv = IM.foldrWithKey
(\k it -> ((_itType it, k, itStackAmount it) :) )
[]
-- gives a list of indices-item pairs.
-- Note that within the pair, indices can be repeated if two or more of an item
-- are needed
combineItemListYou :: World -> [([Int],Item)]
combineItemListYou = concatMap lookupItems . invertListInvMult . yourInv
+10
View File
@@ -1,5 +1,6 @@
module Dodge.Render.Connectors
( zConnect
, zConnectCol
, bConnect
, lConnect
) where
@@ -13,6 +14,15 @@ zConnect (V2 x y) (V2 a b) = line $ map toV2
,(0.5 * (x+a), b)
,(a, b)
]
zConnectCol :: Point2 -> Point2 -> Color -> Color -> Color -> Color -> Picture
zConnectCol (V2 x y) (V2 a b) c1 c2 c3 c4 = lineCol $ zip
( map toV2
[(x,y)
,(0.5 * (x+a), y)
,(0.5 * (x+a), b)
,(a, b)
]
) [c1,c2,c3,c4]
bConnect :: Point2 -> Point2 -> Picture
bConnect (V2 x y) (V2 z w) = pictures
+24 -10
View File
@@ -101,9 +101,11 @@ subInventoryDisplay cfig w = case _inventoryMode w of
, fromMaybe mempty $ do
i <- mi
cpos <- combinePoss w !? i
lnks <- combineListLnks w !? i
return $ (lnkMidPosInvSels cfig w) cpos (snd lnks)
<> foldMap (cursorAtInvSel listCursorNESW cfig w) (snd lnks)
col <- (combineItemListYou w !? i) <&> _itInvColor . snd
lnks <- map fst (combineItemListYou w) !? i
return $ lnkMidPosInvSelsCol cfig w cpos col lnks
<> foldMap (cursorAtInvSel listCursorNESW cfig w) lnks
<> combineCounts cfig w lnks
]
InspectInventory -> invHead cfig "INSPECT"
where
@@ -138,10 +140,25 @@ lnkMidInvSel cfig w lefti midi = winScale cfig
hw = halfWidth cfig
lnkMidPosInvSels :: Configuration -> World -> Int -> [Int] -> Picture
lnkMidPosInvSels cfig w i = winScale cfig
. color white
. concatMap (zConnect rp . selNumMidHeight cfig w)
--lnkMidPosInvSels :: Configuration -> World -> Int -> [Int] -> Picture
--lnkMidPosInvSels cfig w i = winScale cfig
-- . color white
-- . concatMap (zConnect rp . selNumMidHeight cfig w)
-- where
---- lp ipos = V2 (150 - hw) ( hh - (20 * fromIntegral ipos + 17.5))
-- rp = V2 (190 - hw) ( hh - (20 * fromIntegral i + 77.5))
-- hh = halfHeight cfig
-- hw = halfWidth cfig
combineCounts :: Configuration -> World -> [Int] -> Picture
combineCounts cfig w = winScale cfig . foldMap f . group
where
f (i:is) = uncurryV translate (V2 10 5 +.+ selNumMidHeight cfig w i) . scale 0.1 0.1 . text . show $ length is + 1
f _ = mempty
lnkMidPosInvSelsCol :: Configuration -> World -> Int -> Color -> [Int] -> Picture
lnkMidPosInvSelsCol cfig w i col = winScale cfig
. concatMap (\j -> zConnectCol rp (selNumMidHeight cfig w j) col white white (selNumCol j w))
where
-- lp ipos = V2 (150 - hw) ( hh - (20 * fromIntegral ipos + 17.5))
rp = V2 (190 - hw) ( hh - (20 * fromIntegral i + 77.5))
@@ -161,9 +178,6 @@ combineListStringPictures w = case concatMap (itemText . snd) . combineItemListY
[] -> [text "NO POSSIBLE COMBINATIONS"]
xs -> xs
combineListLnks :: World -> [(Int,[Int])]
combineListLnks = zip [0..] . map fst . combineItemListYou
ammoTweakStrings :: Maybe Item -> [String]
ammoTweakStrings it = case it ^? _Just . itTweaks . tweakParams of
Just l -> map tweakString $ IM.elems l