Various performance improvements

This commit is contained in:
2021-09-23 15:27:37 +01:00
parent 7b6904b51f
commit 85edd98d62
17 changed files with 137 additions and 81 deletions
+13 -9
View File
@@ -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