From ab714d63dbb5a140e4461e23281b1dfcd2f71c72 Mon Sep 17 00:00:00 2001 From: justin Date: Wed, 10 May 2023 02:47:22 +0100 Subject: [PATCH] Cleanup --- src/Dodge/ListDisplayParams.hs | 2 +- src/Dodge/Menu/Option.hs | 2 +- src/Dodge/Render/HUD.hs | 4 +-- src/Dodge/Render/List.hs | 43 ++++++++++++++--------------- src/Dodge/SelectionSections/Draw.hs | 2 +- 5 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/Dodge/ListDisplayParams.hs b/src/Dodge/ListDisplayParams.hs index c46f21993..b53a8f5e5 100644 --- a/src/Dodge/ListDisplayParams.hs +++ b/src/Dodge/ListDisplayParams.hs @@ -15,7 +15,7 @@ import Control.Lens defaultListDisplayParams :: ListDisplayParams defaultListDisplayParams = ListDisplayParams - { _ldpVerticalGap = 10 + { _ldpVerticalGap = 0 , _ldpScale = 1 , _ldpPosX = 0 , _ldpPosY = 0 diff --git a/src/Dodge/Menu/Option.hs b/src/Dodge/Menu/Option.hs index f5152a30a..585b4f17a 100644 --- a/src/Dodge/Menu/Option.hs +++ b/src/Dodge/Menu/Option.hs @@ -17,7 +17,7 @@ optionListDisplayParams = { _ldpPosX = 50 , _ldpPosY = 50 , _ldpScale = 2 - , _ldpVerticalGap = 30 + , _ldpVerticalGap = 0 , _ldpWidth = FixedSelectionWidth 25 , _ldpCursorSides = [North, South, West] } diff --git a/src/Dodge/Render/HUD.hs b/src/Dodge/Render/HUD.hs index c1644d244..5dce9e6a6 100644 --- a/src/Dodge/Render/HUD.hs +++ b/src/Dodge/Render/HUD.hs @@ -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 extratext str = toTopLeft cfig $ translate 432 0 $ drawListElement 10 1 curpos (text (str ++ deactivatetext)) 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 DoNotMoveEquipment -> mempty PutOnEquipment{} -> @@ -159,7 +159,7 @@ combineInventoryExtra sss cfig w = fromMaybe mempty $ do mconcat [ fromMaybe mempty $ do 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 lnks <- si ^? siPayload . ciInvIDs return $ diff --git a/src/Dodge/Render/List.hs b/src/Dodge/Render/List.hs index 2058f2b98..15ed2d3e1 100644 --- a/src/Dodge/Render/List.hs +++ b/src/Dodge/Render/List.hs @@ -3,11 +3,11 @@ module Dodge.Render.List ( listCursorNSW, drawList, drawSelectionList, - listPicturesScaleOff, + listPicturesYgapScaleYoff, drawListElement, selSecDrawCursor, dShadCol, - listPicturesAtOff, + drawListYoff, stackPicturesAt, toTopLeft, ) where @@ -28,14 +28,13 @@ drawSelectionList :: ListDisplayParams -> Configuration -> SelectionList a -> Pi drawSelectionList ldps cfig sl = toTopLeft cfig - ( ( translate (ldps ^. ldpPosX) (negate $ ldps ^. ldpPosY) $ - listPicturesScaleOff - (_ldpVerticalGap ldps) - (_ldpScale ldps) - 0 - (makeSelectionListPictures sl) - ) - <> drawSelectionCursor ldps sl + ( translate (ldps ^. ldpPosX) (negate $ ldps ^. ldpPosY) $ + listPicturesYgapScaleYoff + (_ldpVerticalGap ldps) + (_ldpScale ldps) + 0 + (makeSelectionListPictures sl) + <> drawSelectionCursor sl ldps ) makeSelectionListPictures :: SelectionList a -> [Picture] @@ -43,15 +42,13 @@ makeSelectionListPictures = concatMap f . getShownItems where f si = map (color (_siColor si) . text) $ _siPictures si -drawCursorAt :: ListDisplayParams -> Maybe Int -> [SelectionItem a] -> Picture -drawCursorAt ldps mi lis = fromMaybe mempty $ do +drawCursorAt :: Maybe Int -> [SelectionItem a] -> ListDisplayParams -> Picture +drawCursorAt mi lis ldps = fromMaybe mempty $ do i <- mi selit <- lis !? i let j = sum . map _siHeight $ take i lis col = _siColor selit return $ - translate (_ldpPosX ldps) - (- _ldpPosY ldps) $ listCursorChooseBorderScale (_ldpVerticalGap ldps) (_ldpScale ldps) @@ -66,8 +63,8 @@ drawCursorAt ldps mi lis = fromMaybe mempty $ do FixedSelectionWidth x -> x _ -> 1 -drawSelectionCursor :: ListDisplayParams -> SelectionList a -> Picture -drawSelectionCursor ldps sl = drawCursorAt ldps (f $ sl ^. slSelPos) (getShownItems sl) +drawSelectionCursor :: SelectionList a -> ListDisplayParams -> Picture +drawSelectionCursor sl = drawCursorAt (f $ sl ^. slSelPos) (getShownItems sl) where -- the following is quite hacky f = case sl ^. slRegex of @@ -75,11 +72,11 @@ drawSelectionCursor ldps sl = drawCursorAt ldps (f $ sl ^. slSelPos) (getShownIt "" | not (sl ^. slRegexInput) -> id _ -> fmap (+ 1) -listPicturesAtOff :: Int -> [Picture] -> Picture -listPicturesAtOff = listPicturesScaleOff 0 1 +drawListYoff :: Int -> [Picture] -> Picture +drawListYoff = listPicturesYgapScaleYoff 0 1 -listPicturesScaleOff :: Float -> Float -> Int -> [Picture] -> Picture -listPicturesScaleOff ygap s i = +listPicturesYgapScaleYoff :: Float -> Float -> Int -> [Picture] -> Picture +listPicturesYgapScaleYoff ygap s i = mconcat . zipWith (drawListElement ygap s) [i ..] @@ -106,7 +103,7 @@ listCursorDisplayParams :: Int -> Picture listCursorDisplayParams ldp borders a b c d = - translate xoff (-yoff) . listCursorChooseBorderScale ygap s borders a b c d + translate xoff (- yoff) . listCursorChooseBorderScale ygap s borders a b c d where ygap = _ldpVerticalGap ldp s = _ldpScale ldp @@ -128,7 +125,7 @@ listCursorChooseBorderScale :: Picture listCursorChooseBorderScale ygap s borders yint xint col cursxsize cursysize = translate - ( (10 * s * (fromIntegral xint ) - 5 * s)) + ((10 * s * (fromIntegral xint) - 5 * s)) (- (ygap + (s * 20 + ygap) * (fromIntegral yint) + 1)) . color col $ chooseCursorBorders (s * wth) (s * hgt) borders @@ -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 -- a list on the screen drawList :: [Picture] -> Picture -drawList = listPicturesScaleOff 0 1 0 +drawList = listPicturesYgapScaleYoff 0 1 0 --TODO put the following functions in an appropriate place diff --git a/src/Dodge/SelectionSections/Draw.hs b/src/Dodge/SelectionSections/Draw.hs index 1fda42d78..b34422b14 100644 --- a/src/Dodge/SelectionSections/Draw.hs +++ b/src/Dodge/SelectionSections/Draw.hs @@ -10,7 +10,7 @@ import Dodge.Data.SelectionList drawSelectionSections :: SelectionSections a -> ListDisplayParams -> Configuration -> Picture drawSelectionSections sss ldps cfig = - toTopLeft cfig ((translate (ldps ^. ldpPosX) (negate $ ldps ^. ldpPosY) $ listPicturesScaleOff + toTopLeft cfig ((translate (ldps ^. ldpPosX) (negate $ ldps ^. ldpPosY) $ listPicturesYgapScaleYoff (_ldpVerticalGap ldps) (_ldpScale ldps) 0