From 448669cd83a44495a44ca18b57353b68557200f1 Mon Sep 17 00:00:00 2001 From: justin Date: Fri, 19 May 2023 16:07:11 +0100 Subject: [PATCH] Fix cursor positioning in selection sections --- src/Dodge/Combine.hs | 3 ++- src/Dodge/DisplayInventory.hs | 7 ++++--- src/Dodge/Render/List.hs | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Dodge/Combine.hs b/src/Dodge/Combine.hs index 884239c19..538aea655 100644 --- a/src/Dodge/Combine.hs +++ b/src/Dodge/Combine.hs @@ -4,6 +4,7 @@ module Dodge.Combine ( combineList', ) where +import Dodge.Item.SlotsTaken import Dodge.Data.Universe import Dodge.Data.Combine import Dodge.Item.Display @@ -54,7 +55,7 @@ combineList' = map f . combineListInfo where f (is,(strs,itm)) = SelectionItem { _siPictures = basicItemDisplay itm - , _siHeight = length (basicItemDisplay itm) + , _siHeight = itSlotsTaken itm , _siIsSelectable = True , _siColor = _itInvColor itm , _siOffX = 0 diff --git a/src/Dodge/DisplayInventory.hs b/src/Dodge/DisplayInventory.hs index 49b07cd86..3e7eed0a2 100644 --- a/src/Dodge/DisplayInventory.hs +++ b/src/Dodge/DisplayInventory.hs @@ -195,10 +195,11 @@ updateSection sis mcsel availablelines ss = scurs = do csel <- mcsel (_, si) <- IM.lookupGE csel sis -- this is not right? - let cpos = sum (fmap (length . _siPictures) . fst . IM.split csel $ sis) + let cpos = sum (fmap ( _siHeight) . fst . IM.split csel $ sis) csize = length $ _siPictures si ccolor = _siColor si return $ SectionCursor (cpos - offset) csize ccolor + --return $ SectionCursor (cpos - offset) 1 ccolor nocursoroffset = if length allstrings - oldoffset <= availablelines then max 0 (length allstrings - availablelines) @@ -245,7 +246,7 @@ updateSection sis mcsel availablelines ss = allstrings = IM.elems $ overlapSelectionItems $ IM.elems sis shownstrings = drop offset allstrings --h (col, str) = color col . text $ theindent ++ str - h (col, str) = translate (fromIntegral (_ssIndent ss) * 10) 0 str + h (col, str) = translate (fromIntegral (_ssIndent ss) * 100) 0 str theindent = replicate (_ssIndent ss) ' ' --xtra str = color white . text $ theindent ++ str ++ " MORE " ++ _ssDescriptor ss g si = map (_siColor si,) $ _siPictures si @@ -305,7 +306,7 @@ enterCombineInv cfig w = { _ssItems = cm , _ssCursor = do (_, si) <- IM.lookupMin cm - return $ SectionCursor 0 (length (_siPictures si)) (_siColor si) + return $ SectionCursor 0 (_siHeight si) (_siColor si) , _ssMinSize = 5 , _ssOffset = 0 , _ssShownItems = mempty diff --git a/src/Dodge/Render/List.hs b/src/Dodge/Render/List.hs index 93431e757..61944f851 100644 --- a/src/Dodge/Render/List.hs +++ b/src/Dodge/Render/List.hs @@ -86,7 +86,8 @@ stackPicturesAtOff i = mconcat . zipWith (drawListElement 10 1 0) [i, i -1 ..] selSecDrawCursor :: Int -> ListDisplayParams -> SelectionSections a -> Picture selSecDrawCursor xsize ldp sss = fromMaybe mempty $ do (i, j) <- sss ^? sssExtra . sssSelPos . _Just - yint <- selSecYint i j sss + --yint <- selSecYint i j sss + yint <- sss ^? sssSections . ix i . ssCursor . _Just . scurPos xint <- sss ^? sssSections . ix i . ssIndent si <- sss ^? sssSections . ix i . ssItems . ix j return $ @@ -98,7 +99,7 @@ selSecDrawCursor xsize ldp sss = fromMaybe mempty $ do xint (_siColor si) xsize - (length $ _siPictures si) + (_siHeight si) -- displays a cursor that should match up to list text pictures listCursorChooseBorderScale ::