Work on cursor for lists
This commit is contained in:
@@ -16,7 +16,7 @@ data ListDisplayParams = ListDisplayParams
|
|||||||
, _ldpPosY :: Float
|
, _ldpPosY :: Float
|
||||||
, _ldpScale :: Float
|
, _ldpScale :: Float
|
||||||
, _ldpVerticalGap :: Float
|
, _ldpVerticalGap :: Float
|
||||||
, _ldpCursorType :: CursorType
|
, _ldpCursorSides :: [CardinalPoint]
|
||||||
, _ldpWidth :: SelectionWidth
|
, _ldpWidth :: SelectionWidth
|
||||||
-- , _ldpSizeRestriction :: SelectionSizeRestriction
|
-- , _ldpSizeRestriction :: SelectionSizeRestriction
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ debugDraw :: Configuration -> World -> Picture
|
|||||||
debugDraw cfig w
|
debugDraw cfig w
|
||||||
| Enable_debug `S.member` _debug_booleans cfig =
|
| Enable_debug `S.member` _debug_booleans cfig =
|
||||||
pic
|
pic
|
||||||
<> setLayer FixedCoordLayer (toTopLeft cfig (translate (0.5 * halfWidth cfig) 0 $ listPicturesAt $ map text ts))
|
<> setLayer FixedCoordLayer (toTopLeft cfig (translate (0.5 * halfWidth cfig) 0 $ drawList $ map text ts))
|
||||||
| otherwise = mempty
|
| otherwise = mempty
|
||||||
where
|
where
|
||||||
pic = foldMap (debugDraw' cfig w) (_debug_booleans cfig)
|
pic = foldMap (debugDraw' cfig w) (_debug_booleans cfig)
|
||||||
|
|||||||
@@ -19,14 +19,14 @@ defaultListDisplayParams =
|
|||||||
, _ldpScale = 1
|
, _ldpScale = 1
|
||||||
, _ldpPosX = 0
|
, _ldpPosX = 0
|
||||||
, _ldpPosY = 0
|
, _ldpPosY = 0
|
||||||
, _ldpCursorType = NoCursor
|
, _ldpCursorSides = mempty
|
||||||
, _ldpWidth = FixedSelectionWidth 15
|
, _ldpWidth = FixedSelectionWidth 15
|
||||||
}
|
}
|
||||||
|
|
||||||
invDisplayParams :: World -> ListDisplayParams
|
invDisplayParams :: World -> ListDisplayParams
|
||||||
invDisplayParams w =
|
invDisplayParams w =
|
||||||
defaultListDisplayParams
|
defaultListDisplayParams
|
||||||
& ldpCursorType .~ BorderCursor selcursortype
|
& ldpCursorSides .~ selcursortype
|
||||||
& ldpWidth .~ FixedSelectionWidth (determineInvSelCursorWidth w)
|
& ldpWidth .~ FixedSelectionWidth (determineInvSelCursorWidth w)
|
||||||
where
|
where
|
||||||
selcursortype
|
selcursortype
|
||||||
@@ -41,7 +41,7 @@ secondColumnParams =
|
|||||||
defaultListDisplayParams
|
defaultListDisplayParams
|
||||||
& ldpPosX .~ subInvX
|
& ldpPosX .~ subInvX
|
||||||
& ldpPosY .~ 60
|
& ldpPosY .~ 60
|
||||||
& ldpCursorType .~ BorderCursor [North, South, West]
|
& ldpCursorSides .~ [North, South, West]
|
||||||
|
|
||||||
subInvX :: Float
|
subInvX :: Float
|
||||||
subInvX = 9 * fromIntegral topInvW + 50
|
subInvX = 9 * fromIntegral topInvW + 50
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ import Text.Read
|
|||||||
|
|
||||||
splashMenu :: Universe -> ScreenLayer
|
splashMenu :: Universe -> ScreenLayer
|
||||||
splashMenu u =
|
splashMenu u =
|
||||||
initializeOptionMenu "AMNESIS" splashMenuOptions NoPositionedMenuOption u
|
initializeOptionMenu "GAME TITLE" splashMenuOptions NoPositionedMenuOption u
|
||||||
& scOptionFlag .~ SplashOptions
|
& scOptionFlag .~ SplashOptions
|
||||||
|
|
||||||
splashMenuOptions :: [MenuOption]
|
splashMenuOptions :: [MenuOption]
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ optionListDisplayParams =
|
|||||||
, _ldpScale = 2
|
, _ldpScale = 2
|
||||||
, _ldpVerticalGap = 30
|
, _ldpVerticalGap = 30
|
||||||
, _ldpWidth = FixedSelectionWidth 25
|
, _ldpWidth = FixedSelectionWidth 25
|
||||||
, _ldpCursorType = BorderCursor [North, South, West]
|
, _ldpCursorSides = [North, South, West]
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeOptionMenu :: String -> [MenuOption] -> PositionedMenuOption -> Universe -> ScreenLayer
|
initializeOptionMenu :: String -> [MenuOption] -> PositionedMenuOption -> Universe -> ScreenLayer
|
||||||
|
|||||||
@@ -119,8 +119,8 @@ drawRBOptions cfig w = fromMaybe mempty $ do
|
|||||||
sss <- w ^? hud . hudElement . diSections
|
sss <- w ^? hud . hudElement . diSections
|
||||||
(i', j) <- sss ^? sssExtra . sssSelPos . _Just
|
(i', j) <- sss ^? sssExtra . sssSelPos . _Just
|
||||||
curpos <- selSecSelPos i' j sss
|
curpos <- selSecSelPos i' j sss
|
||||||
let midtext str = toTopLeft cfig $ translate 252 0 $ listTextPictureAtScale 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 $ listTextPictureAtScale 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 $ listPicturesAtOff (curpos - i) (map (text . eqPosText) es))
|
||||||
<> case ae of
|
<> case ae of
|
||||||
|
|||||||
+34
-23
@@ -1,10 +1,10 @@
|
|||||||
module Dodge.Render.List (
|
module Dodge.Render.List (
|
||||||
renderListAt,
|
renderListAt,
|
||||||
listCursorNSW,
|
listCursorNSW,
|
||||||
listPicturesAt,
|
drawList,
|
||||||
drawSelectionList,
|
drawSelectionList,
|
||||||
listPicturesAtScaleOff,
|
listPicturesAtScaleOff,
|
||||||
listTextPictureAtScale,
|
drawListElement,
|
||||||
selSecDrawCursor,
|
selSecDrawCursor,
|
||||||
dShadCol,
|
dShadCol,
|
||||||
listPicturesAtOff,
|
listPicturesAtOff,
|
||||||
@@ -26,13 +26,16 @@ import Picture
|
|||||||
|
|
||||||
drawSelectionList :: ListDisplayParams -> Configuration -> SelectionList a -> Picture
|
drawSelectionList :: ListDisplayParams -> Configuration -> SelectionList a -> Picture
|
||||||
drawSelectionList ldps cfig sl =
|
drawSelectionList ldps cfig sl =
|
||||||
toTopLeft cfig ((translate (ldps ^. ldpPosX) (negate $ ldps ^. ldpPosY) $ listPicturesAtScaleOff
|
toTopLeft
|
||||||
(_ldpVerticalGap ldps)
|
cfig
|
||||||
(_ldpScale ldps)
|
( ( translate (ldps ^. ldpPosX) (negate $ ldps ^. ldpPosY) $
|
||||||
0
|
listPicturesAtScaleOff
|
||||||
(makeSelectionListPictures sl)
|
(_ldpVerticalGap ldps)
|
||||||
)
|
(_ldpScale ldps)
|
||||||
<> drawSelectionCursor ldps sl
|
0
|
||||||
|
(makeSelectionListPictures sl)
|
||||||
|
)
|
||||||
|
<> drawSelectionCursor ldps sl
|
||||||
)
|
)
|
||||||
|
|
||||||
makeSelectionListPictures :: SelectionList a -> [Picture]
|
makeSelectionListPictures :: SelectionList a -> [Picture]
|
||||||
@@ -44,12 +47,20 @@ drawCursorAt :: ListDisplayParams -> Maybe Int -> [SelectionItem a] -> Picture
|
|||||||
drawCursorAt ldps mi lis = fromMaybe mempty $ do
|
drawCursorAt ldps mi lis = fromMaybe mempty $ do
|
||||||
i <- mi
|
i <- mi
|
||||||
selit <- lis !? i
|
selit <- lis !? i
|
||||||
f <- case _ldpCursorType ldps of
|
|
||||||
BorderCursor cps -> Just $ listCursorChooseBorderScale (_ldpVerticalGap ldps) (_ldpScale ldps) cps
|
|
||||||
NoCursor -> Nothing
|
|
||||||
let j = sum . map _siHeight $ take i lis
|
let j = sum . map _siHeight $ take i lis
|
||||||
col = _siColor selit
|
col = _siColor selit
|
||||||
return $ f (_ldpPosX ldps + (9 * fromIntegral (_siOffX selit))) (_ldpPosY ldps) j 0 col wdth (_siHeight selit)
|
return $
|
||||||
|
listCursorChooseBorderScale
|
||||||
|
(_ldpVerticalGap ldps)
|
||||||
|
(_ldpScale ldps)
|
||||||
|
(ldps ^. ldpCursorSides)
|
||||||
|
(_ldpPosX ldps + (9 * fromIntegral (_siOffX selit)))
|
||||||
|
(_ldpPosY ldps)
|
||||||
|
j
|
||||||
|
0
|
||||||
|
col
|
||||||
|
wdth
|
||||||
|
(_siHeight selit)
|
||||||
where
|
where
|
||||||
wdth = case _ldpWidth ldps of
|
wdth = case _ldpWidth ldps of
|
||||||
FixedSelectionWidth x -> x
|
FixedSelectionWidth x -> x
|
||||||
@@ -65,18 +76,18 @@ drawSelectionCursor ldps sl = drawCursorAt ldps (f $ sl ^. slSelPos) (getShownIt
|
|||||||
_ -> fmap (+ 1)
|
_ -> fmap (+ 1)
|
||||||
|
|
||||||
listPicturesAtOff :: Int -> [Picture] -> Picture
|
listPicturesAtOff :: Int -> [Picture] -> Picture
|
||||||
listPicturesAtOff i = mconcat . zipWith (listTextPictureAtScale 10 1) [i ..]
|
listPicturesAtOff = listPicturesAtScaleOff 10 1
|
||||||
|
|
||||||
listPicturesAtScaleOff :: Float -> Float -> Int -> [Picture] -> Picture
|
listPicturesAtScaleOff :: Float -> Float -> Int -> [Picture] -> Picture
|
||||||
listPicturesAtScaleOff ygap s i =
|
listPicturesAtScaleOff ygap s i =
|
||||||
mconcat
|
mconcat
|
||||||
. zipWith (listTextPictureAtScale ygap s) [i ..]
|
. zipWith (drawListElement ygap s) [i ..]
|
||||||
|
|
||||||
stackPicturesAt :: [Picture] -> Picture
|
stackPicturesAt :: [Picture] -> Picture
|
||||||
stackPicturesAt = stackPicturesAtOff 0
|
stackPicturesAt = stackPicturesAtOff 0
|
||||||
|
|
||||||
stackPicturesAtOff :: Int -> [Picture] -> Picture
|
stackPicturesAtOff :: Int -> [Picture] -> Picture
|
||||||
stackPicturesAtOff i = mconcat . zipWith (listTextPictureAtScale 10 1) [i, i -1 ..]
|
stackPicturesAtOff i = mconcat . zipWith (drawListElement 10 1) [i, i -1 ..]
|
||||||
|
|
||||||
selSecDrawCursor :: Int -> [CardinalPoint] -> ListDisplayParams -> SelectionSections a -> Int -> Int -> Picture
|
selSecDrawCursor :: Int -> [CardinalPoint] -> ListDisplayParams -> SelectionSections a -> Int -> Int -> Picture
|
||||||
selSecDrawCursor xsize borders ldp sss i j = fromMaybe mempty $ do
|
selSecDrawCursor xsize borders ldp sss i j = fromMaybe mempty $ do
|
||||||
@@ -120,7 +131,7 @@ listCursorChooseBorderScale ::
|
|||||||
listCursorChooseBorderScale ygap s borders xoff yoff yint xint col cursxsize cursysize =
|
listCursorChooseBorderScale ygap s borders xoff yoff yint xint col cursxsize cursysize =
|
||||||
translate
|
translate
|
||||||
(xoff + (10 * s * (fromIntegral xint -1)))
|
(xoff + (10 * s * (fromIntegral xint -1)))
|
||||||
( - (yoff + (s * 10 + ygap) * (fromIntegral yint + 1)))
|
(- (yoff + (s * 10 + ygap) * (fromIntegral yint + 1)))
|
||||||
. color col
|
. color col
|
||||||
$ chooseCursorBorders (s * wth) (s * hgt) borders
|
$ chooseCursorBorders (s * wth) (s * hgt) borders
|
||||||
where
|
where
|
||||||
@@ -165,18 +176,18 @@ listCursorNSW = listCursorChooseBorder [North, South, West]
|
|||||||
-- thescale = hw * 0.02 / fromIntegral (length str)
|
-- thescale = hw * 0.02 / fromIntegral (length str)
|
||||||
-- hw = halfWidth cfig
|
-- hw = halfWidth cfig
|
||||||
|
|
||||||
listTextPictureAtScale :: Float -> Float -> Int -> Picture -> Picture
|
drawListElement :: Float -> Float -> Int -> Picture -> Picture
|
||||||
listTextPictureAtScale ygap s yint =
|
drawListElement ygap s yint =
|
||||||
translate 0 (negate ((s * 10 + ygap) * (fromIntegral yint + 1)))
|
translate 0 (negate ((s * 10 + ygap) * (fromIntegral yint + 1)))
|
||||||
. scale (s * 0.1) (s * 0.1)
|
. scale (s * 0.1) (s * 0.1)
|
||||||
|
|
||||||
renderListAt :: Float -> Float -> [(String, Color)] -> Picture
|
renderListAt :: Float -> Float -> [(String, Color)] -> Picture
|
||||||
renderListAt tx ty = translate tx (-ty) . listPicturesAt . map (\(str, col) -> color col $ text str)
|
renderListAt tx ty = translate tx (- ty) . drawList . map (\(str, col) -> color col $ text str)
|
||||||
|
|
||||||
-- 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
|
||||||
listPicturesAt :: [Picture] -> Picture
|
drawList :: [Picture] -> Picture
|
||||||
listPicturesAt = listPicturesAtScaleOff 10 1 0
|
drawList = listPicturesAtScaleOff 10 1 0
|
||||||
|
|
||||||
--TODO put the following functions in an appropriate place
|
--TODO put the following functions in an appropriate place
|
||||||
|
|
||||||
@@ -186,7 +197,7 @@ dShadCol :: Color -> Picture -> Picture
|
|||||||
dShadCol c p = color black (translate 1.2 (-1.2) p) <> color c p
|
dShadCol c p = color black (translate 1.2 (-1.2) p) <> color c p
|
||||||
|
|
||||||
toTopLeft :: Configuration -> Picture -> Picture
|
toTopLeft :: Configuration -> Picture -> Picture
|
||||||
toTopLeft cfig = translate (-hw) (hh)
|
toTopLeft cfig = translate (- hw) (hh)
|
||||||
where
|
where
|
||||||
hw = halfWidth cfig
|
hw = halfWidth cfig
|
||||||
hh = halfHeight cfig
|
hh = halfHeight cfig
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ module Dodge.Render.MenuScreen (
|
|||||||
drawMenuScreen,
|
drawMenuScreen,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Dodge.Data.SelectionList
|
|
||||||
import Dodge.Render.List
|
|
||||||
import Dodge.Base.Window
|
import Dodge.Base.Window
|
||||||
|
import Dodge.Data.SelectionList
|
||||||
import Dodge.Data.Universe
|
import Dodge.Data.Universe
|
||||||
|
import Dodge.Render.List
|
||||||
import Picture
|
import Picture
|
||||||
|
|
||||||
drawMenuScreen :: Configuration -> ScreenLayer -> Picture
|
drawMenuScreen :: Configuration -> ScreenLayer -> Picture
|
||||||
@@ -38,17 +38,15 @@ drawOptions ::
|
|||||||
SelectionList a ->
|
SelectionList a ->
|
||||||
Picture
|
Picture
|
||||||
drawOptions ldps cfig title sl =
|
drawOptions ldps cfig title sl =
|
||||||
pictures
|
darkenBackground cfig
|
||||||
[ darkenBackground cfig
|
<> drawTitle cfig title
|
||||||
, drawTitle cfig title
|
<> drawSelectionList ldps cfig sl
|
||||||
, drawSelectionList ldps cfig sl
|
|
||||||
]
|
|
||||||
|
|
||||||
darkenBackground :: Configuration -> Picture
|
darkenBackground :: Configuration -> Picture
|
||||||
darkenBackground = color (withAlpha 0.5 black) . polygon . reverse . screenBox
|
darkenBackground = color (withAlpha 0.5 black) . polygon . reverse . screenBox
|
||||||
|
|
||||||
drawTitle :: Configuration -> String -> Picture
|
drawTitle :: Configuration -> String -> Picture
|
||||||
drawTitle cfig = translate (30 - hw) (hh-50) . scale 0.4 0.4 . text
|
drawTitle cfig = translate (- hw) (hh -80) . scale 0.4 0.4 . text
|
||||||
where
|
where
|
||||||
hh = halfHeight cfig
|
hh = halfHeight cfig
|
||||||
hw = halfWidth cfig
|
hw = halfWidth cfig
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ fixedCoordPictures u =
|
|||||||
drawMenuOrHUD cfig u
|
drawMenuOrHUD cfig u
|
||||||
<> drawConcurrentMessage u
|
<> drawConcurrentMessage u
|
||||||
<> customMouseCursor u
|
<> customMouseCursor u
|
||||||
<> toTopLeft cfig (translate (halfWidth cfig) 0 $ listPicturesAt (map text (_uvTestString u u)))
|
<> toTopLeft cfig (translate (halfWidth cfig) 0 $ drawList (map text (_uvTestString u u)))
|
||||||
<> displayFrameTicks u
|
<> displayFrameTicks u
|
||||||
where
|
where
|
||||||
cfig = _uvConfig u
|
cfig = _uvConfig u
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ extraPics cfig u =
|
|||||||
<> foldMap (`_debugPic` u) (_uvDebug u)
|
<> foldMap (`_debugPic` u) (_uvDebug u)
|
||||||
<> setLayer FixedCoordLayer
|
<> setLayer FixedCoordLayer
|
||||||
(toTopLeft cfig . translate (1.3* halfWidth cfig) 0
|
(toTopLeft cfig . translate (1.3* halfWidth cfig) 0
|
||||||
. listPicturesAt
|
. drawList
|
||||||
. take 50 . drop (u ^. uvDebugMessageOffset)
|
. take 50 . drop (u ^. uvDebugMessageOffset)
|
||||||
. map text $ foldMap (`_debugMessage` u) (_uvDebug u))
|
. map text $ foldMap (`_debugMessage` u) (_uvDebug u))
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import Picture.Base
|
|||||||
import Dodge.Data.CardinalPoint
|
import Dodge.Data.CardinalPoint
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Picture.Data
|
|
||||||
import Dodge.Data.Config
|
import Dodge.Data.Config
|
||||||
import Dodge.Render.List
|
import Dodge.Render.List
|
||||||
import Dodge.Data.SelectionList
|
import Dodge.Data.SelectionList
|
||||||
|
|||||||
Reference in New Issue
Block a user