Work on terminal text display
This commit is contained in:
@@ -44,7 +44,6 @@ drawFlamelet size pt =
|
|||||||
time = _ebTimer pt
|
time = _ebTimer pt
|
||||||
piu =
|
piu =
|
||||||
translate3 sp
|
translate3 sp
|
||||||
-- setDepth (z + 5)
|
|
||||||
-- . uncurryV translate sp
|
-- . uncurryV translate sp
|
||||||
. color
|
. color
|
||||||
( mixColors
|
( mixColors
|
||||||
@@ -61,8 +60,6 @@ drawFlamelet size pt =
|
|||||||
$ reverse (rectNSWE siz2 (- siz2) (- siz2) siz2)
|
$ reverse (rectNSWE siz2 (- siz2) (- siz2) siz2)
|
||||||
pi2 =
|
pi2 =
|
||||||
translate3 sp
|
translate3 sp
|
||||||
--setDepth (z + 5)
|
|
||||||
-- . uncurryV translate sp
|
|
||||||
. color
|
. color
|
||||||
( mixColors
|
( mixColors
|
||||||
(fromIntegral (max 0 (time -2)))
|
(fromIntegral (max 0 (time -2)))
|
||||||
@@ -79,8 +76,6 @@ drawFlamelet size pt =
|
|||||||
$ rectNSWE siz2 (- siz2) (- siz2) siz2
|
$ rectNSWE siz2 (- siz2) (- siz2) siz2
|
||||||
pic =
|
pic =
|
||||||
translate3 sp
|
translate3 sp
|
||||||
--setDepth (z + 2)
|
|
||||||
-- . uncurryV translate sp
|
|
||||||
. color
|
. color
|
||||||
( mixColors
|
( mixColors
|
||||||
(fromIntegral (max 0 (time -2)))
|
(fromIntegral (max 0 (time -2)))
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import Dodge.Data.World
|
|||||||
import Linear
|
import Linear
|
||||||
import SDL (MouseButton (..))
|
import SDL (MouseButton (..))
|
||||||
|
|
||||||
defaultListDisplayParams :: ListDisplayParams
|
defaultLDP :: ListDisplayParams
|
||||||
defaultListDisplayParams =
|
defaultLDP =
|
||||||
ListDisplayParams
|
ListDisplayParams
|
||||||
{ _ldpVerticalGap = 0
|
{ _ldpVerticalGap = 0
|
||||||
, _ldpScale = 1
|
, _ldpScale = 1
|
||||||
@@ -30,7 +30,8 @@ defaultListDisplayParams =
|
|||||||
}
|
}
|
||||||
|
|
||||||
invDP :: ListDisplayParams
|
invDP :: ListDisplayParams
|
||||||
invDP = defaultListDisplayParams & ldpPos . spPixelOff .~ V2 6 0
|
--invDP = defaultLDP & ldpPos . spPixelOff .~ V2 6 0
|
||||||
|
invDP = defaultLDP & ldpPos . spPixelOff .~ V2 16 (-20)
|
||||||
|
|
||||||
invCursorParams :: World -> CursorDisplay
|
invCursorParams :: World -> CursorDisplay
|
||||||
invCursorParams w = BoundaryCursor $ case w ^? hud . subInventory of
|
invCursorParams w = BoundaryCursor $ case w ^? hud . subInventory of
|
||||||
@@ -40,10 +41,7 @@ invCursorParams w = BoundaryCursor $ case w ^? hud . subInventory of
|
|||||||
_ -> [North, South, West]
|
_ -> [North, South, West]
|
||||||
|
|
||||||
secondColumnLDP :: ListDisplayParams
|
secondColumnLDP :: ListDisplayParams
|
||||||
--secondColumnLDP = defaultListDisplayParams & ldpPos . spPixelOff .~ V2 subInvX (-20)
|
secondColumnLDP = defaultLDP & ldpPos . spPixelOff .~ V2 subInvX (-20)
|
||||||
secondColumnLDP = defaultListDisplayParams
|
|
||||||
& ldpPos . spPixelOff .~ V2 subInvX (-16)
|
|
||||||
& ldpBorder ?~ (49, 16)
|
|
||||||
|
|
||||||
subInvX :: Float
|
subInvX :: Float
|
||||||
subInvX = 10 * fromIntegral topInvW + 170
|
subInvX = 10 * fromIntegral topInvW + 170
|
||||||
@@ -52,8 +50,4 @@ topInvW :: Int
|
|||||||
topInvW = 15
|
topInvW = 15
|
||||||
|
|
||||||
menuLDP :: ListDisplayParams
|
menuLDP :: ListDisplayParams
|
||||||
menuLDP =
|
menuLDP = defaultLDP & ldpPos . spPixelOff .~ V2 11 (-70) & ldpScale .~ 2
|
||||||
defaultListDisplayParams
|
|
||||||
& ldpPos . spPixelOff .~ V2 11 (-70)
|
|
||||||
& ldpScale .~ 2
|
|
||||||
& ldpVerticalGap .~ 0
|
|
||||||
|
|||||||
@@ -358,7 +358,8 @@ combineInventoryExtra sss msel cfig w = fold $ do
|
|||||||
(Just (0, i))
|
(Just (0, i))
|
||||||
|
|
||||||
drawTerminalDisplay :: LWorld -> Config -> Terminal -> Picture
|
drawTerminalDisplay :: LWorld -> Config -> Terminal -> Picture
|
||||||
drawTerminalDisplay lw cfig tm = drawSelectionList secondColumnLDP cfig f
|
drawTerminalDisplay lw cfig tm
|
||||||
|
= drawSelectionList (secondColumnLDP & ldpBorder ?~ (49, 16)) cfig f
|
||||||
where
|
where
|
||||||
-- <> invHead cfig ("TERMINAL-" ++ show tid)
|
-- <> invHead cfig ("TERMINAL-" ++ show tid)
|
||||||
-- <> color
|
-- <> color
|
||||||
|
|||||||
+31
-26
@@ -36,14 +36,18 @@ import Picture
|
|||||||
drawSelectionList :: ListDisplayParams -> Config -> [SelectionItem a] -> Picture
|
drawSelectionList :: ListDisplayParams -> Config -> [SelectionItem a] -> Picture
|
||||||
drawSelectionList ldps cfig sl =
|
drawSelectionList ldps cfig sl =
|
||||||
translateScreenPos cfig (ldps ^. ldpPos) $
|
translateScreenPos cfig (ldps ^. ldpPos) $
|
||||||
drawListYgapScaleYoff
|
drawListYgapScaleYoff ygap sf 0 (makeSelectionListPictures sl)
|
||||||
(ldps ^. ldpVerticalGap)
|
<> foldMap (g . f) (ldps ^. ldpBorder)
|
||||||
(ldps ^. ldpScale)
|
|
||||||
0
|
|
||||||
(makeSelectionListPictures sl)
|
|
||||||
<> foldMap (color white . polygonWire . f) (ldps ^. ldpBorder)
|
|
||||||
where
|
where
|
||||||
f (x,y) = rectNSWE 5 (negate $ 20 * fromIntegral y + 5) (-5) (10 * fromIntegral x)
|
g xs = color white (polygonWire xs) <> setDepth 0.5 (polygon xs)
|
||||||
|
ygap = ldps ^. ldpVerticalGap
|
||||||
|
sf = ldps ^. ldpScale
|
||||||
|
f (x, y) =
|
||||||
|
rectNSWE
|
||||||
|
5
|
||||||
|
(negate $ (20 * sf + ygap) * fromIntegral y + 5)
|
||||||
|
(-5)
|
||||||
|
(10 * sf * fromIntegral x)
|
||||||
|
|
||||||
drawTitleBackground :: Config -> Picture
|
drawTitleBackground :: Config -> Picture
|
||||||
drawTitleBackground cfig =
|
drawTitleBackground cfig =
|
||||||
@@ -63,7 +67,7 @@ drawSelectionListBackground ldp cfig l =
|
|||||||
. reverse
|
. reverse
|
||||||
$ rectNSWE 5 s (-5) e
|
$ rectNSWE 5 s (-5) e
|
||||||
where
|
where
|
||||||
s = - (5 + fromIntegral l * (20 * ldp ^. ldpScale + ldp ^. ldpVerticalGap))
|
s = -(5 + fromIntegral l * (20 * ldp ^. ldpScale + ldp ^. ldpVerticalGap))
|
||||||
e = 555 -- HACK isOverTerminalScreen
|
e = 555 -- HACK isOverTerminalScreen
|
||||||
|
|
||||||
makeSelectionListPictures :: [SelectionItem a] -> [Picture]
|
makeSelectionListPictures :: [SelectionItem a] -> [Picture]
|
||||||
@@ -103,7 +107,7 @@ stackPicturesAt :: [Picture] -> Picture
|
|||||||
stackPicturesAt = stackPicturesAtOff 0
|
stackPicturesAt = stackPicturesAtOff 0
|
||||||
|
|
||||||
stackPicturesAtOff :: Int -> [Picture] -> Picture
|
stackPicturesAtOff :: Int -> [Picture] -> Picture
|
||||||
stackPicturesAtOff i = mconcat . zipWith (drawListElement 10 1 0) [i, i -1 ..]
|
stackPicturesAtOff i = mconcat . zipWith (drawListElement 10 1 0) [i, i - 1 ..]
|
||||||
|
|
||||||
selSecDrawCursorAt ::
|
selSecDrawCursorAt ::
|
||||||
ListDisplayParams ->
|
ListDisplayParams ->
|
||||||
@@ -148,7 +152,7 @@ listCursorChooseBorderScale ::
|
|||||||
listCursorChooseBorderScale ygap s curs yint xint col cursxsize cursysize =
|
listCursorChooseBorderScale ygap s curs yint xint col cursxsize cursysize =
|
||||||
translate
|
translate
|
||||||
((10 * fromIntegral xint - 5) * s)
|
((10 * fromIntegral xint - 5) * s)
|
||||||
(- (ygap + (s * 20 + ygap) * fromIntegral yint))
|
(-(ygap + (s * 20 + ygap) * fromIntegral yint))
|
||||||
. color col
|
. color col
|
||||||
$ chooseCursorBorders (s * wth) (s * hgt) curs
|
$ chooseCursorBorders (s * wth) (s * hgt) curs
|
||||||
where
|
where
|
||||||
@@ -167,8 +171,8 @@ chooseCursorBorders w h = \case
|
|||||||
toLine South = [V2 w h', V2 0 h']
|
toLine South = [V2 w h', V2 0 h']
|
||||||
toLine West = [V2 0 h', V2 0 0]
|
toLine West = [V2 0 h', V2 0 0]
|
||||||
|
|
||||||
--fillScreenText :: Config -> String -> Picture
|
-- fillScreenText :: Config -> String -> Picture
|
||||||
--fillScreenText cfig str =
|
-- fillScreenText cfig str =
|
||||||
-- scale wscale hscale
|
-- scale wscale hscale
|
||||||
-- . centerText
|
-- . centerText
|
||||||
-- $ str
|
-- $ str
|
||||||
@@ -178,8 +182,8 @@ chooseCursorBorders w h = \case
|
|||||||
-- hw = halfWidth cfig
|
-- hw = halfWidth cfig
|
||||||
-- hh = halfHeight cfig
|
-- hh = halfHeight cfig
|
||||||
|
|
||||||
--fillWidthText :: Config -> String -> Picture
|
-- fillWidthText :: Config -> String -> Picture
|
||||||
--fillWidthText cfig str =
|
-- fillWidthText cfig str =
|
||||||
-- scale thescale thescale
|
-- scale thescale thescale
|
||||||
-- . centerText
|
-- . centerText
|
||||||
-- $ str
|
-- $ str
|
||||||
@@ -193,12 +197,13 @@ drawListElement ygap s xint yint =
|
|||||||
. 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)
|
renderListAt tx ty =
|
||||||
. drawList
|
translate tx (-ty)
|
||||||
. map (\(str, col) -> color col $ text str)
|
. drawList
|
||||||
|
. map (\(str, col) -> color col $ text str)
|
||||||
|
|
||||||
--inverseText :: String -> Color -> Picture
|
-- inverseText :: String -> Color -> Picture
|
||||||
--inverseText str col =
|
-- inverseText str col =
|
||||||
-- translate3 (V3 0 0 (0.5))
|
-- translate3 (V3 0 0 (0.5))
|
||||||
-- (color (V4 0 1 0 0.1) ( text str))
|
-- (color (V4 0 1 0 0.1) ( text str))
|
||||||
-- <>
|
-- <>
|
||||||
@@ -212,14 +217,14 @@ renderListAt tx ty = translate tx (- ty)
|
|||||||
drawList :: [Picture] -> Picture
|
drawList :: [Picture] -> Picture
|
||||||
drawList = drawListYgapScaleYoff 0 1 0
|
drawList = drawListYgapScaleYoff 0 1 0
|
||||||
|
|
||||||
drawLabelledList :: [(String,[String])] -> Picture
|
drawLabelledList :: [(String, [String])] -> Picture
|
||||||
drawLabelledList ((s,ss):xs)
|
drawLabelledList ((s, ss) : xs) =
|
||||||
= translate (-10) 0 (drawListYgapScaleYoff 0 1 0 [ textJustifyRight s])
|
translate (-10) 0 (drawListYgapScaleYoff 0 1 0 [textJustifyRight s])
|
||||||
<> drawListYgapScaleYoff 0 1 0 (text <$> ss)
|
<> drawListYgapScaleYoff 0 1 0 (text <$> ss)
|
||||||
<> translate 0 (negate $ fromIntegral (max 1 $ length ss) * 20) (drawLabelledList xs)
|
<> translate 0 (negate $ fromIntegral (max 1 $ length ss) * 20) (drawLabelledList xs)
|
||||||
drawLabelledList [] = mempty
|
drawLabelledList [] = mempty
|
||||||
|
|
||||||
--TODO put the following functions in an appropriate place
|
-- TODO put the following functions in an appropriate place
|
||||||
|
|
||||||
-- | Colour picture and add black drop shadow.
|
-- | Colour picture and add black drop shadow.
|
||||||
dShadCol :: Color -> Picture -> Picture
|
dShadCol :: Color -> Picture -> Picture
|
||||||
@@ -227,4 +232,4 @@ 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 :: Config -> Picture -> Picture
|
toTopLeft :: Config -> Picture -> Picture
|
||||||
toTopLeft cfig = translate (- halfWidth cfig) (halfHeight cfig)
|
toTopLeft cfig = translate (-halfWidth cfig) (halfHeight cfig)
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ drawMouseCursor :: Universe -> Picture
|
|||||||
drawMouseCursor u =
|
drawMouseCursor u =
|
||||||
uncurryV translate (u ^. uvWorld . input . mousePos)
|
uncurryV translate (u ^. uvWorld . input . mousePos)
|
||||||
. color white
|
. color white
|
||||||
. setDepth 1
|
. setDepth (-1)
|
||||||
$ mouseCursorType u
|
$ mouseCursorType u
|
||||||
|
|
||||||
mouseCursorType :: Universe -> Picture
|
mouseCursorType :: Universe -> Picture
|
||||||
|
|||||||
Reference in New Issue
Block a user