Refactor updates
This commit is contained in:
@@ -1,24 +1,26 @@
|
||||
module Dodge.Render.InfoBox where
|
||||
module Dodge.Render.InfoBox
|
||||
( renderInfoListAt
|
||||
, renderInfoListsAt
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
import Dodge.Base
|
||||
import Dodge.Data.Universe
|
||||
import Dodge.Data.CamPos
|
||||
import Dodge.Data.Config
|
||||
import Dodge.Render.Connectors
|
||||
import Dodge.Render.List
|
||||
import Geometry
|
||||
import Picture
|
||||
|
||||
renderInfoListAt :: Float -> Float -> Configuration -> World -> (Point2, [String]) -> Picture
|
||||
renderInfoListAt x y cfig w (p, ss) =
|
||||
renderInfoListAt :: Float -> Float -> Configuration -> CamPos -> (Point2, [String]) -> Picture
|
||||
renderInfoListAt x y cfig cam (p, ss) =
|
||||
renderListAt x y cfig (zip ss (repeat white))
|
||||
<> winScale cfig (color white $ lConnect (V2 (x - hw) (hh -25 - y)) (worldPosToScreen cam p))
|
||||
<> listCursorNSW x y cfig 0 white 19 (length ss)
|
||||
where
|
||||
hw = halfWidth cfig
|
||||
hh = halfHeight cfig
|
||||
cam = w ^. cWorld . lWorld . camPos
|
||||
|
||||
renderInfoListsAt :: Float -> Float -> Configuration -> World -> [(Point2, [String])] -> Picture
|
||||
renderInfoListsAt :: Float -> Float -> Configuration -> CamPos -> [(Point2, [String])] -> Picture
|
||||
renderInfoListsAt x y cfig w =
|
||||
fst . foldr f (mempty, 0)
|
||||
where
|
||||
|
||||
@@ -4,7 +4,7 @@ import Data.Foldable
|
||||
import Data.Maybe
|
||||
import Dodge.Base.WinScale
|
||||
import Dodge.Base.Window
|
||||
import Dodge.Data.Universe
|
||||
import Dodge.Data.Config
|
||||
import Geometry
|
||||
import Picture
|
||||
|
||||
@@ -19,7 +19,8 @@ listPicturesAtOff tx ty cfig i = mconcat . zipWith (listTextPictureAt tx ty cfig
|
||||
-- displays a cursor that should match up to list text pictures
|
||||
-- the width of a character appears to be 9(?!)
|
||||
-- this is probably because it is 8 pixels plus one for the border
|
||||
listCursorChooseBorder :: [Bool] -> Float -> Float -> Configuration -> Int -> Color -> Int -> Int -> Picture
|
||||
listCursorChooseBorder ::
|
||||
[Bool] -> Float -> Float -> Configuration -> Int -> Color -> Int -> Int -> Picture
|
||||
listCursorChooseBorder borders xoff yoff cfig yint col cursxsize cursysize =
|
||||
winScale cfig
|
||||
. translate
|
||||
@@ -66,12 +67,11 @@ fillScreenText cfig str =
|
||||
. centerText
|
||||
$ str
|
||||
where
|
||||
wscale = hw*0.02/fromIntegral (length str)
|
||||
hscale = hh*0.01
|
||||
wscale = hw * 0.02 / fromIntegral (length str)
|
||||
hscale = hh * 0.01
|
||||
hw = halfWidth cfig
|
||||
hh = halfHeight cfig
|
||||
|
||||
|
||||
fillWidthText :: Configuration -> String -> Picture
|
||||
fillWidthText cfig str =
|
||||
winScale cfig
|
||||
@@ -79,7 +79,7 @@ fillWidthText cfig str =
|
||||
. centerText
|
||||
$ str
|
||||
where
|
||||
thescale = hw*0.02/fromIntegral (length str)
|
||||
thescale = hw * 0.02 / fromIntegral (length str)
|
||||
hw = halfWidth cfig
|
||||
|
||||
listTextPictureAt :: Float -> Float -> Configuration -> Int -> Picture -> Picture
|
||||
|
||||
@@ -167,7 +167,7 @@ debugDraw' cfig w bl = case bl of
|
||||
Close_shape_culling -> mempty
|
||||
Bound_box_screen -> mempty
|
||||
Show_ms_frame -> mempty
|
||||
View_boundaries -> viewBoundaries w
|
||||
View_boundaries -> viewBoundaries (w ^. cWorld)
|
||||
Show_bound_box -> drawBoundingBox w
|
||||
Show_wall_search_rays -> drawWallSearchRays w
|
||||
Show_dda_test -> drawDDATest w
|
||||
@@ -176,7 +176,7 @@ debugDraw' cfig w bl = case bl of
|
||||
Inspect_wall -> drawInspectWalls w
|
||||
Cr_awareness -> drawCreatureDisplayTexts w
|
||||
Show_sound -> pictures $ M.map (soundPic cfig w) $ _playingSounds w
|
||||
Cr_status -> drawCrInfo cfig w
|
||||
Cr_status -> drawCrInfo cfig (w ^. cWorld . lWorld)
|
||||
Mouse_position -> drawMousePosition cfig w
|
||||
Walls_info -> drawWlIDs cfig w
|
||||
Pathing -> drawPathing cfig w
|
||||
@@ -436,22 +436,23 @@ crDisplayInfo cfig cam cr
|
||||
fpreShow :: (Show a, Functor f) => String -> f a -> f String
|
||||
fpreShow str = fmap (((rightPad 7 '.' str ++ "...") ++) . show)
|
||||
|
||||
drawCrInfo :: Configuration -> World -> Picture
|
||||
drawCrInfo :: Configuration -> LWorld -> Picture
|
||||
drawCrInfo cfig w =
|
||||
setLayer FixedCoordLayer $
|
||||
renderInfoListsAt (2 * hw - 400) 0 cfig w $
|
||||
mapMaybe (crDisplayInfo cfig (w ^. cWorld . lWorld . camPos)) $ IM.elems $ w ^. cWorld . lWorld . creatures
|
||||
renderInfoListsAt (2 * hw - 400) 0 cfig cam $
|
||||
mapMaybe (crDisplayInfo cfig cam) $ IM.elems $ w ^. creatures
|
||||
where
|
||||
cam = w ^. camPos
|
||||
hw = halfWidth cfig
|
||||
|
||||
viewBoundaries :: World -> Picture
|
||||
viewBoundaries :: CWorld -> Picture
|
||||
viewBoundaries w =
|
||||
setLayer DebugLayer $
|
||||
color green (foldMap (polygonWire . _grBound) grs)
|
||||
<> color yellow (foldMap (\q -> line [p, q]) $ farWallPoints p w)
|
||||
where
|
||||
p = _crPos $ you w
|
||||
grs = filter (pointInOrOnPolygon p . _grBound) (_cwgGameRooms $ _cwGen (_cWorld w))
|
||||
p = _crPos $ youc w
|
||||
grs = filter (pointInOrOnPolygon p . _grBound) (_cwgGameRooms $ _cwGen w)
|
||||
|
||||
viewClipBounds :: Configuration -> World -> Picture
|
||||
viewClipBounds cfig w
|
||||
|
||||
Reference in New Issue
Block a user