diff --git a/src/Dodge/Data/HUD.hs b/src/Dodge/Data/HUD.hs index c8801a542..1ce2417e7 100644 --- a/src/Dodge/Data/HUD.hs +++ b/src/Dodge/Data/HUD.hs @@ -11,6 +11,7 @@ import Dodge.Data.Button import Dodge.Data.FloorItem import Control.Lens import Geometry.Data +import Data.IntMap.Strict (IntMap) data HUDElement = DisplayInventory @@ -23,7 +24,10 @@ data HUDElement data SubInventory = NoSubInventory | ExamineInventory {_subInvMSel :: Maybe Int} - | CombineInventory {_subInvMap :: SelectionIntMap CombinableItem} +-- | CombineInventory {_subInvMap :: SelectionIntMap CombinableItem} + | CombineInventory {_ciCombinations :: IntMap CombinableItem + , _ciSections :: SelectionSections CombinableItem + } | LockedInventory | DisplayTerminal {_termID :: Int} -- deriving (Eq, Ord, Show, Read) --Generic, Flat) diff --git a/src/Dodge/Render/HUD.hs b/src/Dodge/Render/HUD.hs index d429d5a91..fb800373a 100644 --- a/src/Dodge/Render/HUD.hs +++ b/src/Dodge/Render/HUD.hs @@ -68,8 +68,8 @@ invDisplayParams w = Just ExamineInventory{} -> True _ -> False -inventoryDisplay :: SelectionSections () -> World -> Configuration -> Picture -inventoryDisplay sss w cfig = listPicturesAtScaleOff +drawSelectionSections :: SelectionSections () -> ListDisplayParams -> Configuration -> Picture +drawSelectionSections sss ldps cfig = listPicturesAtScaleOff (_ldpVerticalGap ldps) (_ldpScale ldps) (_ldpPosX ldps) @@ -83,8 +83,10 @@ inventoryDisplay sss w cfig = listPicturesAtScaleOff i <- sss ^? sssSelPos . _Just j <- sss ^? sssSections . ix i . ssCursor . _Just . scurSel return $ selSecDrawCursor 15 [North,South,West] cfig ldps sss i j - ldps = invDisplayParams w pics = foldMap _ssShownItems (_sssSections sss) + +inventoryDisplay :: SelectionSections () -> World -> Configuration -> Picture +inventoryDisplay sss w = drawSelectionSections sss (invDisplayParams w) drawSubInventory :: SubInventory -> Configuration -> World -> Picture drawSubInventory subinv cfig w = case subinv of @@ -92,18 +94,18 @@ drawSubInventory subinv cfig w = case subinv of NoSubInventory -> drawNoSubInventory cfig w ExamineInventory mtweaki -> drawExamineInventory cfig mtweaki w DisplayTerminal tid -> displayTerminal tid cfig (w ^. cWorld . lWorld) - CombineInventory sl -> titledSub' cfig "COMBINE" sl - <> combineInventoryExtra sl (_smSelPos sl) cfig w + CombineInventory _ sss -> titledSub' cfig "COMBINE" sss + <> combineInventoryExtra sss cfig w -titledSub :: Configuration -> String -> SelectionList a -> Picture -titledSub cfig subtitle subitems = +titledSub :: Configuration -> String -> SelectionSections a -> Picture +titledSub cfig subtitle sss = invHead cfig subtitle - <> drawSelectionList secondColumnParams cfig subitems + <> drawSelectionList sss secondColumnParams cfig -titledSub' :: Configuration -> String -> SelectionIntMap a -> Picture +titledSub' :: Configuration -> String -> SelectionSections a -> Picture titledSub' cfig subtitle subitems = invHead cfig subtitle - <> drawSelectionMap secondColumnParams cfig subitems + <> drawSelectionSections secondColumnParams cfig subitems drawExamineInventory :: Configuration -> Maybe Int -> World -> Picture drawExamineInventory cfig mtweaki w = @@ -175,28 +177,30 @@ examineInventoryExtra mtweaki mitm cfig = fromMaybe mempty $ do return $ listCursorNSW subInvX 60 cfig tweaki 0 white (length $ showTweak tparam) 15 -- , drawSelectionList thirdColumnParams cfig (thirdColumnPara (itmInfo mitm)) -combineInventoryExtra :: SelectionIntMap CombinableItem -> Maybe Int -> Configuration -> World -> Picture -combineInventoryExtra sm mi cfig w = fromMaybe mempty $ do - i <- mi - let cpos = getIthPos i (sm ^. smShownItems) - col <- sm ^? smShownItems . ix i . siColor - return $ - pictures - [ fromMaybe mempty $ do - strs <- sm ^? smShownItems . ix i . siPayload . ciInfo - return $ listPicturesAtOff (subInvX + 150) 60 cfig cpos $ map (color red . text) strs - , fromMaybe mempty $ do - lnks <- sm ^? smShownItems . ix i . siPayload . ciInvIDs - return $ - lnkMidPosInvSelsCol cfig w cpos col lnks - -- <> foldMap (topCursorTypeWidth listCursorNESW (topInvW + 2) cfig w) lnks - <> foldMap invcursor lnks - <> combineCounts cfig w lnks - ] - where - invcursor i = fromMaybe mempty $ do - sss <- w ^? hud . hudElement . diSections - return $ selSecDrawCursor 17 [North,South,East] cfig (invDisplayParams w) sss 0 i +--combineInventoryExtra :: SelectionIntMap CombinableItem -> Maybe Int -> Configuration -> World -> Picture +combineInventoryExtra :: SelectionSections CombinableItem -> Configuration -> World -> Picture +combineInventoryExtra sss cfig w = mempty +-- fromMaybe mempty $ do +-- i <- mi +-- let cpos = getIthPos i (sm ^. smShownItems) +-- col <- sm ^? smShownItems . ix i . siColor +-- return $ +-- pictures +-- [ fromMaybe mempty $ do +-- strs <- sm ^? smShownItems . ix i . siPayload . ciInfo +-- return $ listPicturesAtOff (subInvX + 150) 60 cfig cpos $ map (color red . text) strs +-- , fromMaybe mempty $ do +-- lnks <- sm ^? smShownItems . ix i . siPayload . ciInvIDs +-- return $ +-- lnkMidPosInvSelsCol cfig w cpos col lnks +-- -- <> foldMap (topCursorTypeWidth listCursorNESW (topInvW + 2) cfig w) lnks +-- <> foldMap invcursor lnks +-- <> combineCounts cfig w lnks +-- ] +-- where +-- invcursor i = fromMaybe mempty $ do +-- sss <- w ^? hud . hudElement . diSections +-- return $ selSecDrawCursor 17 [North,South,East] cfig (invDisplayParams w) sss 0 i secondColumnParams :: ListDisplayParams secondColumnParams =