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:
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user