diff --git a/Subsurface/Source/GUI/GUITextBlock.cs b/Subsurface/Source/GUI/GUITextBlock.cs index c04912ad3..4b4dda5dc 100644 --- a/Subsurface/Source/GUI/GUITextBlock.cs +++ b/Subsurface/Source/GUI/GUITextBlock.cs @@ -231,6 +231,11 @@ namespace Barotrauma } public override void Draw(SpriteBatch spriteBatch) + { + Draw(spriteBatch, Vector2.Zero); + } + + public void Draw(SpriteBatch spriteBatch, Vector2 offset) { if (!Visible) return; @@ -238,6 +243,9 @@ namespace Barotrauma if (state == ComponentState.Hover) currColor = hoverColor; if (state == ComponentState.Selected) currColor = selectedColor; + Rectangle drawRect = rect; + if (offset != Vector2.Zero) drawRect.Location += offset.ToPoint(); + if (currColor.A * currColor.A > 0.0f) GUI.DrawRectangle(spriteBatch, rect, currColor * (currColor.A / 255.0f), true); base.Draw(spriteBatch); @@ -248,7 +256,7 @@ namespace Barotrauma { spriteBatch.DrawString(Font, text, - new Vector2(rect.X, rect.Y) + textPos, + new Vector2(rect.X, rect.Y) + textPos + offset, textColor * (textColor.A / 255.0f), 0.0f, origin, 1.0f, SpriteEffects.None, textDepth); @@ -257,7 +265,6 @@ namespace Barotrauma DrawChildren(spriteBatch); if (OutlineColor.A * currColor.A > 0.0f) GUI.DrawRectangle(spriteBatch, rect, OutlineColor * (currColor.A / 255.0f), false); - } } } diff --git a/Subsurface/Source/Items/Components/ItemLabel.cs b/Subsurface/Source/Items/Components/ItemLabel.cs index c9e51fe14..7837ad5c0 100644 --- a/Subsurface/Source/Items/Components/ItemLabel.cs +++ b/Subsurface/Source/Items/Components/ItemLabel.cs @@ -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()); } } } \ No newline at end of file