This commit is contained in:
2023-05-10 02:47:22 +01:00
parent 12aa1361eb
commit ab714d63db
5 changed files with 25 additions and 28 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ import Control.Lens
defaultListDisplayParams :: ListDisplayParams defaultListDisplayParams :: ListDisplayParams
defaultListDisplayParams = defaultListDisplayParams =
ListDisplayParams ListDisplayParams
{ _ldpVerticalGap = 10 { _ldpVerticalGap = 0
, _ldpScale = 1 , _ldpScale = 1
, _ldpPosX = 0 , _ldpPosX = 0
, _ldpPosY = 0 , _ldpPosY = 0
+1 -1
View File
@@ -17,7 +17,7 @@ optionListDisplayParams =
{ _ldpPosX = 50 { _ldpPosX = 50
, _ldpPosY = 50 , _ldpPosY = 50
, _ldpScale = 2 , _ldpScale = 2
, _ldpVerticalGap = 30 , _ldpVerticalGap = 0
, _ldpWidth = FixedSelectionWidth 25 , _ldpWidth = FixedSelectionWidth 25
, _ldpCursorSides = [North, South, West] , _ldpCursorSides = [North, South, West]
} }
+2 -2
View File
@@ -122,7 +122,7 @@ drawRBOptions cfig w = fromMaybe mempty $ do
let midtext str = toTopLeft cfig $ translate 252 0 $ drawListElement 10 1 curpos (text str) let midtext str = toTopLeft cfig $ translate 252 0 $ drawListElement 10 1 curpos (text str)
let extratext str = toTopLeft cfig $ translate 432 0 $ drawListElement 10 1 curpos (text (str ++ deactivatetext)) let extratext str = toTopLeft cfig $ translate 432 0 $ drawListElement 10 1 curpos (text (str ++ deactivatetext))
return $ return $
toTopLeft cfig (translate 342 0 $ listPicturesAtOff (curpos - i) (map (text . eqPosText) es)) toTopLeft cfig (translate 342 0 $ drawListYoff (curpos - i) (map (text . eqPosText) es))
<> case ae of <> case ae of
DoNotMoveEquipment -> mempty DoNotMoveEquipment -> mempty
PutOnEquipment{} -> PutOnEquipment{} ->
@@ -159,7 +159,7 @@ combineInventoryExtra sss cfig w = fromMaybe mempty $ do
mconcat mconcat
[ fromMaybe mempty $ do [ fromMaybe mempty $ do
strs <- si ^? siPayload . ciInfo strs <- si ^? siPayload . ciInfo
return $ toTopLeft cfig (translate (subInvX + 150) 60 $ listPicturesAtOff cpos $ map (color red . text) strs) return $ toTopLeft cfig (translate (subInvX + 150) 60 $ drawListYoff cpos $ map (color red . text) strs)
, fromMaybe mempty $ do , fromMaybe mempty $ do
lnks <- si ^? siPayload . ciInvIDs lnks <- si ^? siPayload . ciInvIDs
return $ return $
+14 -17
View File
@@ -3,11 +3,11 @@ module Dodge.Render.List (
listCursorNSW, listCursorNSW,
drawList, drawList,
drawSelectionList, drawSelectionList,
listPicturesScaleOff, listPicturesYgapScaleYoff,
drawListElement, drawListElement,
selSecDrawCursor, selSecDrawCursor,
dShadCol, dShadCol,
listPicturesAtOff, drawListYoff,
stackPicturesAt, stackPicturesAt,
toTopLeft, toTopLeft,
) where ) where
@@ -28,14 +28,13 @@ drawSelectionList :: ListDisplayParams -> Configuration -> SelectionList a -> Pi
drawSelectionList ldps cfig sl = drawSelectionList ldps cfig sl =
toTopLeft toTopLeft
cfig cfig
( ( translate (ldps ^. ldpPosX) (negate $ ldps ^. ldpPosY) $ ( translate (ldps ^. ldpPosX) (negate $ ldps ^. ldpPosY) $
listPicturesScaleOff listPicturesYgapScaleYoff
(_ldpVerticalGap ldps) (_ldpVerticalGap ldps)
(_ldpScale ldps) (_ldpScale ldps)
0 0
(makeSelectionListPictures sl) (makeSelectionListPictures sl)
) <> drawSelectionCursor sl ldps
<> drawSelectionCursor ldps sl
) )
makeSelectionListPictures :: SelectionList a -> [Picture] makeSelectionListPictures :: SelectionList a -> [Picture]
@@ -43,15 +42,13 @@ makeSelectionListPictures = concatMap f . getShownItems
where where
f si = map (color (_siColor si) . text) $ _siPictures si f si = map (color (_siColor si) . text) $ _siPictures si
drawCursorAt :: ListDisplayParams -> Maybe Int -> [SelectionItem a] -> Picture drawCursorAt :: Maybe Int -> [SelectionItem a] -> ListDisplayParams -> Picture
drawCursorAt ldps mi lis = fromMaybe mempty $ do drawCursorAt mi lis ldps = fromMaybe mempty $ do
i <- mi i <- mi
selit <- lis !? i selit <- lis !? i
let j = sum . map _siHeight $ take i lis let j = sum . map _siHeight $ take i lis
col = _siColor selit col = _siColor selit
return $ return $
translate (_ldpPosX ldps)
(- _ldpPosY ldps) $
listCursorChooseBorderScale listCursorChooseBorderScale
(_ldpVerticalGap ldps) (_ldpVerticalGap ldps)
(_ldpScale ldps) (_ldpScale ldps)
@@ -66,8 +63,8 @@ drawCursorAt ldps mi lis = fromMaybe mempty $ do
FixedSelectionWidth x -> x FixedSelectionWidth x -> x
_ -> 1 _ -> 1
drawSelectionCursor :: ListDisplayParams -> SelectionList a -> Picture drawSelectionCursor :: SelectionList a -> ListDisplayParams -> Picture
drawSelectionCursor ldps sl = drawCursorAt ldps (f $ sl ^. slSelPos) (getShownItems sl) drawSelectionCursor sl = drawCursorAt (f $ sl ^. slSelPos) (getShownItems sl)
where where
-- the following is quite hacky -- the following is quite hacky
f = case sl ^. slRegex of f = case sl ^. slRegex of
@@ -75,11 +72,11 @@ drawSelectionCursor ldps sl = drawCursorAt ldps (f $ sl ^. slSelPos) (getShownIt
"" | not (sl ^. slRegexInput) -> id "" | not (sl ^. slRegexInput) -> id
_ -> fmap (+ 1) _ -> fmap (+ 1)
listPicturesAtOff :: Int -> [Picture] -> Picture drawListYoff :: Int -> [Picture] -> Picture
listPicturesAtOff = listPicturesScaleOff 0 1 drawListYoff = listPicturesYgapScaleYoff 0 1
listPicturesScaleOff :: Float -> Float -> Int -> [Picture] -> Picture listPicturesYgapScaleYoff :: Float -> Float -> Int -> [Picture] -> Picture
listPicturesScaleOff ygap s i = listPicturesYgapScaleYoff ygap s i =
mconcat mconcat
. zipWith (drawListElement ygap s) [i ..] . zipWith (drawListElement ygap s) [i ..]
@@ -185,7 +182,7 @@ renderListAt tx ty = translate tx (- ty) . drawList . map (\(str, col) -> color
-- given a list of pictures that are each the size of a "text" call, displays them as -- given a list of pictures that are each the size of a "text" call, displays them as
-- a list on the screen -- a list on the screen
drawList :: [Picture] -> Picture drawList :: [Picture] -> Picture
drawList = listPicturesScaleOff 0 1 0 drawList = listPicturesYgapScaleYoff 0 1 0
--TODO put the following functions in an appropriate place --TODO put the following functions in an appropriate place
+1 -1
View File
@@ -10,7 +10,7 @@ import Dodge.Data.SelectionList
drawSelectionSections :: SelectionSections a -> ListDisplayParams -> Configuration -> Picture drawSelectionSections :: SelectionSections a -> ListDisplayParams -> Configuration -> Picture
drawSelectionSections sss ldps cfig = drawSelectionSections sss ldps cfig =
toTopLeft cfig ((translate (ldps ^. ldpPosX) (negate $ ldps ^. ldpPosY) $ listPicturesScaleOff toTopLeft cfig ((translate (ldps ^. ldpPosX) (negate $ ldps ^. ldpPosY) $ listPicturesYgapScaleYoff
(_ldpVerticalGap ldps) (_ldpVerticalGap ldps)
(_ldpScale ldps) (_ldpScale ldps)
0 0