Fix cursor positioning in selection sections

This commit is contained in:
2023-05-19 16:07:11 +01:00
parent 5604d7f1e3
commit 448669cd83
3 changed files with 9 additions and 6 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ module Dodge.Combine (
combineList', combineList',
) where ) where
import Dodge.Item.SlotsTaken
import Dodge.Data.Universe import Dodge.Data.Universe
import Dodge.Data.Combine import Dodge.Data.Combine
import Dodge.Item.Display import Dodge.Item.Display
@@ -54,7 +55,7 @@ combineList' = map f . combineListInfo
where where
f (is,(strs,itm)) = SelectionItem f (is,(strs,itm)) = SelectionItem
{ _siPictures = basicItemDisplay itm { _siPictures = basicItemDisplay itm
, _siHeight = length (basicItemDisplay itm) , _siHeight = itSlotsTaken itm
, _siIsSelectable = True , _siIsSelectable = True
, _siColor = _itInvColor itm , _siColor = _itInvColor itm
, _siOffX = 0 , _siOffX = 0
+4 -3
View File
@@ -195,10 +195,11 @@ updateSection sis mcsel availablelines ss =
scurs = do scurs = do
csel <- mcsel csel <- mcsel
(_, si) <- IM.lookupGE csel sis -- this is not right? (_, 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 csize = length $ _siPictures si
ccolor = _siColor si ccolor = _siColor si
return $ SectionCursor (cpos - offset) csize ccolor return $ SectionCursor (cpos - offset) csize ccolor
--return $ SectionCursor (cpos - offset) 1 ccolor
nocursoroffset = nocursoroffset =
if length allstrings - oldoffset <= availablelines if length allstrings - oldoffset <= availablelines
then max 0 (length allstrings - availablelines) then max 0 (length allstrings - availablelines)
@@ -245,7 +246,7 @@ updateSection sis mcsel availablelines ss =
allstrings = IM.elems $ overlapSelectionItems $ IM.elems sis allstrings = IM.elems $ overlapSelectionItems $ IM.elems sis
shownstrings = drop offset allstrings shownstrings = drop offset allstrings
--h (col, str) = color col . text $ theindent ++ str --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) ' ' theindent = replicate (_ssIndent ss) ' '
--xtra str = color white . text $ theindent ++ str ++ " MORE " ++ _ssDescriptor ss --xtra str = color white . text $ theindent ++ str ++ " MORE " ++ _ssDescriptor ss
g si = map (_siColor si,) $ _siPictures si g si = map (_siColor si,) $ _siPictures si
@@ -305,7 +306,7 @@ enterCombineInv cfig w =
{ _ssItems = cm { _ssItems = cm
, _ssCursor = do , _ssCursor = do
(_, si) <- IM.lookupMin cm (_, si) <- IM.lookupMin cm
return $ SectionCursor 0 (length (_siPictures si)) (_siColor si) return $ SectionCursor 0 (_siHeight si) (_siColor si)
, _ssMinSize = 5 , _ssMinSize = 5
, _ssOffset = 0 , _ssOffset = 0
, _ssShownItems = mempty , _ssShownItems = mempty
+3 -2
View File
@@ -86,7 +86,8 @@ stackPicturesAtOff i = mconcat . zipWith (drawListElement 10 1 0) [i, i -1 ..]
selSecDrawCursor :: Int -> ListDisplayParams -> SelectionSections a -> Picture selSecDrawCursor :: Int -> ListDisplayParams -> SelectionSections a -> Picture
selSecDrawCursor xsize ldp sss = fromMaybe mempty $ do selSecDrawCursor xsize ldp sss = fromMaybe mempty $ do
(i, j) <- sss ^? sssExtra . sssSelPos . _Just (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 xint <- sss ^? sssSections . ix i . ssIndent
si <- sss ^? sssSections . ix i . ssItems . ix j si <- sss ^? sssSections . ix i . ssItems . ix j
return $ return $
@@ -98,7 +99,7 @@ selSecDrawCursor xsize ldp sss = fromMaybe mempty $ do
xint xint
(_siColor si) (_siColor si)
xsize xsize
(length $ _siPictures si) (_siHeight si)
-- displays a cursor that should match up to list text pictures -- displays a cursor that should match up to list text pictures
listCursorChooseBorderScale :: listCursorChooseBorderScale ::