Various performance improvements
This commit is contained in:
+13
-9
@@ -34,7 +34,8 @@ hudDrawings w = pictures
|
||||
|
||||
|
||||
drawInventory :: World -> Picture
|
||||
drawInventory w = displayInv 0 w `appendPic` subInventoryDisplay w
|
||||
drawInventory w = subInventoryDisplay w
|
||||
`appendPic` displayInv 0 w
|
||||
|
||||
subInventoryDisplay :: World -> Picture
|
||||
subInventoryDisplay w = case _inventoryMode w of
|
||||
@@ -104,7 +105,7 @@ invHead :: World -> String -> Picture
|
||||
invHead w s = winScale w . translate (-130) (halfHeight w - 40) . dShadCol white . scale 0.4 0.4 $ text s
|
||||
|
||||
renderItemMapAt :: Float -> Float -> World -> IM.IntMap Item -> Picture
|
||||
--{-# INLINE renderItemMapAt #-}
|
||||
{-# INLINE renderItemMapAt #-}
|
||||
renderItemMapAt tx ty w = concatMapPic (uncurry $ listItemAt tx ty w) . IM.toList
|
||||
|
||||
displayInv :: Int -> World -> Picture
|
||||
@@ -187,19 +188,22 @@ listItemAt
|
||||
-> Int -- ^ y offset (discrete)
|
||||
-> Item -- ^ The item
|
||||
-> Picture
|
||||
--{-# INLINE listItemAt #-}
|
||||
listItemAt xoff yoff w yint item
|
||||
{-# INLINE listItemAt #-}
|
||||
listItemAt xoff yoff w yint
|
||||
= winScale w
|
||||
. translate (xoff + 15 - hw) (yoff + hh - (20 * (fromIntegral yint+1)))
|
||||
. scale 0.1 0.1
|
||||
. dShadCol col
|
||||
$ text s
|
||||
. itemText
|
||||
where
|
||||
hw = halfWidth w
|
||||
hh = halfHeight w
|
||||
(s,col) = case item of
|
||||
NoItem -> ("----", greyN 0.5)
|
||||
_ -> (_itInvDisplay item item , _itInvColor item)
|
||||
|
||||
itemText :: Item -> Picture
|
||||
{-# INLINE itemText #-}
|
||||
--itemText NoItem = dShadCol (greyN 0.5) $ text "----"
|
||||
--itemText it = dShadCol (_itInvColor it) $ text (_itInvDisplay it it)
|
||||
itemText NoItem = text "----"
|
||||
itemText it = color (_itInvColor it) $ text (_itInvDisplay it it)
|
||||
|
||||
openCursorAt
|
||||
:: Float -- ^ Width
|
||||
|
||||
@@ -32,7 +32,6 @@ worldPictures w = pictures
|
||||
,concatMapPic (dbArg _ptDraw) $ _particles w
|
||||
,testPic w
|
||||
,concatMapPic (_spPicture . floorItemSPic) $ _floorItems w
|
||||
,concatMapPic (crDraw w) $ _creatures w
|
||||
,concatMapPic clDraw $ _clouds w
|
||||
,concatMapPic ppDraw $ _pressPlates w
|
||||
,concatMapPic btDraw $ _buttons w
|
||||
@@ -149,8 +148,9 @@ wallShadowsToDraw w
|
||||
-- cannot only test if walls are on screen, but also if they are on the cone
|
||||
-- towards the center of sight
|
||||
lineOnScreenCone :: World -> Point2 -> Point2 -> Bool
|
||||
lineOnScreenCone w p1 p2 = errorPointInPolygon 8 p1 sp || errorPointInPolygon 9 p2 sp
|
||||
|| any (isJust . uncurry (intersectSegSeg p1 p2)) sps
|
||||
lineOnScreenCone w p1 p2 = pointInPolygon p1 sp
|
||||
|| pointInPolygon p2 sp
|
||||
|| any (isJust . uncurry (intersectSegSeg p1 p2)) sps
|
||||
where
|
||||
sp' = screenPolygon w
|
||||
vp = _cameraViewFrom w
|
||||
@@ -160,8 +160,9 @@ lineOnScreenCone w p1 p2 = errorPointInPolygon 8 p1 sp || errorPointInPolygon 9
|
||||
|
||||
|
||||
lineOnScreen :: World -> Point2 -> Point2 -> Bool
|
||||
lineOnScreen w p1 p2 = errorPointInPolygon 8 p1 sp || errorPointInPolygon 9 p2 sp
|
||||
|| any (isJust . uncurry (intersectSegSeg p1 p2)) sps
|
||||
lineOnScreen w p1 p2 = pointInPolygon p1 sp
|
||||
|| pointInPolygon p2 sp
|
||||
|| any (isJust . uncurry (intersectSegSeg p1 p2)) sps
|
||||
where
|
||||
sp = screenPolygon w
|
||||
sps = zip sp (tail sp ++ [head sp])
|
||||
|
||||
Reference in New Issue
Block a user