ItemLabel optimization: textBlock is drawn using an offset relative to the position of the item instead of modifying textBlock.Rect each frame (causing the text position/wrapping to be recalculated each frame)

This commit is contained in:
Regalis
2016-04-02 15:54:00 +03:00
parent 5f05db7ca4
commit 2a2ba80f9c
2 changed files with 14 additions and 4 deletions

View File

@@ -62,8 +62,11 @@ namespace Barotrauma.Items.Components
{
base.Draw(spriteBatch, editing);
textBlock.Rect = new Rectangle((int)item.DrawPosition.X - item.Rect.Width/2, -(int)(item.DrawPosition.Y + item.Rect.Height/2), item.Rect.Width, item.Rect.Height);
textBlock.Draw(spriteBatch);
var drawPos = new Vector2(
item.DrawPosition.X - item.Rect.Width/2.0f,
-(item.DrawPosition.Y + item.Rect.Height/2.0f));
textBlock.Draw(spriteBatch, drawPos - textBlock.Rect.Location.ToVector2());
}
}
}