Remove cursor type from ListDisplayParams

This commit is contained in:
2024-10-25 17:41:37 +01:00
parent bd505b072a
commit 6424899afd
7 changed files with 252 additions and 208 deletions
+12 -5
View File
@@ -58,7 +58,8 @@ drawHP cfig =
drawInventory :: SelectionSections () -> World -> Configuration -> Picture
drawInventory sss w cfig =
drawSelectionSections sss (w ^? hud . hudElement . diSelection . _Just) ldp cfig
drawSelectionSections sss ldp cfig
<> drawSSCursor sss (w ^? hud . hudElement . diSelection . _Just) ldp curs cfig
<> iextra
<> translateScreenPos
cfig
@@ -68,6 +69,7 @@ drawInventory sss w cfig =
<> drawDISelections' w cfig
where
ldp = invDisplayParams w
curs = invCursorParams w
iextra = fromMaybe mempty $ do
inv <- w ^? cWorld . lWorld . creatures . ix 0 . crInv
let x = case invAdj inv of
@@ -80,7 +82,9 @@ drawDIMouseOver w = fromMaybe mempty $ do
(_, i) <- w ^? hud . hudElement . subInventory . nsMouseOver . _Just
sss <- w ^? hud . hudElement . diSections
let idp = invDisplayParams w
return . color (withAlpha 0.5 white) $ selSecDrawCursorAt (0, i) 10 idp sss
return . color (withAlpha 0.5 white) $ selSecDrawCursorAt (0, i) 10 idp curs sss
where
curs = CursorDisplay [North,South]
getMouseInvSel :: World -> Maybe ((Int, Int), (Int, Int))
getMouseInvSel w = case w ^? hud . hudElement . subInventory . nsSelected of
@@ -122,9 +126,11 @@ drawSubInventory subinv cfig w = case subinv of
drawCombineInventory :: Configuration -> SelectionSections CombinableItem -> World -> Picture
drawCombineInventory cfig sss w =
invHead cfig "COMBINE"
<> drawSelectionSections sss msel secondColumnParams cfig
<> drawSelectionSections sss secondColumnParams cfig
<> drawSSCursor sss msel secondColumnParams curs cfig
<> combineInventoryExtra sss msel cfig w
where
curs = CursorDisplay [North,South,West]
msel = w ^? hud . hudElement . subInventory . ciSelection . _Just
drawExamineInventory :: Configuration -> World -> Picture
@@ -273,10 +279,11 @@ combineInventoryExtra sss msel cfig w = fromMaybe mempty $ do
where
invcursor i = do
sss' <- w ^? hud . hudElement . diSections
let idp = invDisplayParams w & ldpCursorSides .~ [North, South, East, West]
let idp = invDisplayParams w
return $
translateScreenPos cfig (idp ^. ldpPos) $
selSecDrawCursor 17 idp sss' (Just (0, i))
selSecDrawCursor 17 idp (CursorDisplay [North, South, East, West])
sss' (Just (0, i))
displayTerminal :: Int -> Configuration -> LWorld -> Picture
displayTerminal tid cfig w = fromMaybe mempty $ do
+25 -11
View File
@@ -36,9 +36,12 @@ drawSelectionList ldps cfig sl =
(_ldpScale ldps)
0
(makeSelectionListPictures sl)
<> drawSelectionCursor sl ldps
<> drawSelectionCursor sl ldps (CursorDisplay [North,West,South])
drawSelectionCursor :: SelectionList a -> ListDisplayParams -> Picture
drawSelectionCursor :: SelectionList a
-> ListDisplayParams
-> CursorDisplay
-> Picture
drawSelectionCursor sl = drawCursorAt (f $ sl ^. slSelPos) (getShownItems sl)
where
-- the following is quite hacky
@@ -53,15 +56,18 @@ makeSelectionListPictures = concatMap f . getShownItems
f si = map (color (_siColor si) . text) $ _siPictures si
--f si = map ((flip inverseText) ((_siColor si))) $ _siPictures si
drawCursorAt :: Maybe Int -> [SelectionItem a] -> ListDisplayParams -> Picture
drawCursorAt mi lis ldps = fromMaybe mempty $ do
drawCursorAt :: Maybe Int -> [SelectionItem a]
-> ListDisplayParams
-> CursorDisplay
-> Picture
drawCursorAt mi lis ldps curs = fromMaybe mempty $ do
i <- mi
selit <- lis !? i
return $
listCursorChooseBorderScale
(_ldpVerticalGap ldps)
(_ldpScale ldps)
(ldps ^. ldpCursorSides)
(curs ^. cursSides)
(sum . map _siHeight $ take i lis)
(_siOffX selit)
(_siColor selit)
@@ -85,8 +91,14 @@ stackPicturesAt = stackPicturesAtOff 0
stackPicturesAtOff :: Int -> [Picture] -> Picture
stackPicturesAtOff i = mconcat . zipWith (drawListElement 10 1 0) [i, i -1 ..]
selSecDrawCursorAt :: (Int,Int) -> Int -> ListDisplayParams -> SelectionSections a -> Picture
selSecDrawCursorAt (i,j) xsize ldp sss = fromMaybe mempty $ do
selSecDrawCursorAt
:: (Int,Int)
-> Int
-> ListDisplayParams
-> CursorDisplay
-> SelectionSections a
-> Picture
selSecDrawCursorAt (i,j) xsize ldp curs sss = fromMaybe mempty $ do
yint <- selSecYint i j sss
xint <- sss ^? sssSections . ix i . ssIndent
si <- sss ^? sssSections . ix i . ssItems . ix j
@@ -94,17 +106,19 @@ selSecDrawCursorAt (i,j) xsize ldp sss = fromMaybe mempty $ do
listCursorChooseBorderScale
(ldp ^. ldpVerticalGap)
(ldp ^. ldpScale)
(ldp ^. ldpCursorSides)
(curs ^. cursSides)
yint
(xint + _siOffX si)
(_siColor si)
xsize
(_siHeight si)
selSecDrawCursor :: Int -> ListDisplayParams -> SelectionSections a ->
selSecDrawCursor :: Int -> ListDisplayParams
-> CursorDisplay
-> SelectionSections a ->
Maybe (Int,Int) -> Picture
selSecDrawCursor xsize ldp sss msel = maybe mempty
(\x -> selSecDrawCursorAt x xsize ldp sss)
selSecDrawCursor xsize ldp curs sss msel = maybe mempty
(\x -> selSecDrawCursorAt x xsize ldp curs sss)
msel
-- displays a cursor that should match up to list text pictures