Work on mouse selection in options menu

This commit is contained in:
2023-05-10 10:02:37 +01:00
parent ab714d63db
commit cc42a5e124
10 changed files with 130 additions and 88 deletions
+4 -1
View File
@@ -3,6 +3,7 @@ module Dodge.Render.HUD (
drawHUD,
) where
import Dodge.ScreenPos
import Control.Lens
import Control.Monad
import qualified Data.Map.Strict as M
@@ -170,7 +171,9 @@ combineInventoryExtra sss cfig w = fromMaybe mempty $ do
where
invcursor i = fromMaybe mempty $ do
sss' <- w ^? hud . hudElement . diSections
return $ toTopLeft cfig $ selSecDrawCursor 17 [North, South, East] (invDisplayParams w) sss' 0 i
let idp = invDisplayParams w
return $ translateScreenPos cfig (idp ^. ldpPos)
$ selSecDrawCursor 17 [North, South, East] idp sss' 0 i
displayTerminal :: Int -> Configuration -> LWorld -> Picture
displayTerminal tid cfig w = fromMaybe mempty $ do
+5 -9
View File
@@ -12,6 +12,7 @@ module Dodge.Render.List (
toTopLeft,
) where
import Dodge.ScreenPos
import Data.Maybe
import Dodge.Base.Window
import Dodge.Data.CardinalPoint
@@ -26,16 +27,15 @@ import Picture
drawSelectionList :: ListDisplayParams -> Configuration -> SelectionList a -> Picture
drawSelectionList ldps cfig sl =
toTopLeft
translateScreenPos
cfig
( translate (ldps ^. ldpPosX) (negate $ ldps ^. ldpPosY) $
(ldps ^. ldpPos) $
listPicturesYgapScaleYoff
(_ldpVerticalGap ldps)
(_ldpScale ldps)
0
(makeSelectionListPictures sl)
<> drawSelectionCursor sl ldps
)
makeSelectionListPictures :: SelectionList a -> [Picture]
makeSelectionListPictures = concatMap f . getShownItems
@@ -76,9 +76,7 @@ drawListYoff :: Int -> [Picture] -> Picture
drawListYoff = listPicturesYgapScaleYoff 0 1
listPicturesYgapScaleYoff :: Float -> Float -> Int -> [Picture] -> Picture
listPicturesYgapScaleYoff ygap s i =
mconcat
. zipWith (drawListElement ygap s) [i ..]
listPicturesYgapScaleYoff ygap s i = mconcat . zipWith (drawListElement ygap s) [i ..]
stackPicturesAt :: [Picture] -> Picture
stackPicturesAt = stackPicturesAtOff 0
@@ -103,12 +101,10 @@ listCursorDisplayParams ::
Int ->
Picture
listCursorDisplayParams ldp borders a b c d =
translate xoff (- yoff) . listCursorChooseBorderScale ygap s borders a b c d
listCursorChooseBorderScale ygap s borders a b c d
where
ygap = _ldpVerticalGap ldp
s = _ldpScale ldp
xoff = _ldpPosX ldp
yoff = _ldpPosY ldp
-- displays a cursor that should match up to list text pictures
-- the width of a character appears to be 9(?!)