Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ DrawSelf()

override void Terraria.GameContent.UI.Elements.UIText.DrawSelf ( SpriteBatch spriteBatch)
inlineprotectedvirtual

Reimplemented from Terraria.UI.UIElement.

Definition at line 124 of file UIText.cs.

125 {
126 base.DrawSelf(spriteBatch);
128 CalculatedStyle innerDimensions = GetInnerDimensions();
129 Vector2 position = innerDimensions.Position();
130 if (_isLarge)
131 {
132 position.Y -= 10f * _textScale;
133 }
134 else
135 {
136 position.Y -= 2f * _textScale;
137 }
138 position.X += (innerDimensions.Width - _textSize.X) * TextOriginX;
139 position.Y += (innerDimensions.Height - _textSize.Y) * TextOriginY;
140 float num = _textScale;
141 if (DynamicallyScaleDownToWidth && _textSize.X > innerDimensions.Width)
142 {
143 num *= innerDimensions.Width / _textSize.X;
144 }
145 DynamicSpriteFont value = (_isLarge ? FontAssets.DeathText : FontAssets.MouseText).Value;
146 Vector2 vector = value.MeasureString(_visibleText);
147 Color baseColor = _shadowColor * ((float)(int)_color.A / 255f);
148 Vector2 origin = new Vector2(0f, 0f) * vector;
149 Vector2 baseScale = new Vector2(num);
150 TextSnippet[] snippets = ChatManager.ParseMessage(_visibleText, _color).ToArray();
152 ChatManager.DrawColorCodedStringShadow(spriteBatch, value, snippets, position, baseColor, 0f, origin, baseScale, -1f, 1.5f);
153 ChatManager.DrawColorCodedString(spriteBatch, value, snippets, position, Color.White, 0f, origin, baseScale, out var _, -1f);
154 }
static void DrawColorCodedStringShadow(SpriteBatch spriteBatch, DynamicSpriteFont font, TextSnippet[] snippets, Vector2 position, Color baseColor, float rotation, Vector2 origin, Vector2 baseScale, float maxWidth=-1f, float spread=2f)
static Vector2 DrawColorCodedString(SpriteBatch spriteBatch, DynamicSpriteFont font, TextSnippet[] snippets, Vector2 position, Color baseColor, float rotation, Vector2 origin, Vector2 baseScale, out int hoveredSnippet, float maxWidth, bool ignoreColors=false)
static void ConvertNormalSnippets(TextSnippet[] snippets)
static List< TextSnippet > ParseMessage(string text, Color baseColor)
CalculatedStyle GetInnerDimensions()
Definition UIElement.cs:377

References Terraria.GameContent.UI.Elements.UIText._color, Terraria.GameContent.UI.Elements.UIText._isLarge, Terraria.GameContent.UI.Elements.UIText._shadowColor, Terraria.GameContent.UI.Elements.UIText._textScale, Terraria.GameContent.UI.Elements.UIText._textSize, Terraria.GameContent.UI.Elements.UIText._visibleText, Terraria.UI.Chat.ChatManager.ConvertNormalSnippets(), Terraria.UI.Chat.ChatManager.DrawColorCodedString(), Terraria.UI.Chat.ChatManager.DrawColorCodedStringShadow(), Terraria.GameContent.UI.Elements.UIText.DynamicallyScaleDownToWidth, Terraria.UI.UIElement.GetInnerDimensions(), Terraria.GameContent.FontAssets.MouseText, Terraria.UI.Chat.ChatManager.ParseMessage(), Terraria.UI.CalculatedStyle.Position(), Terraria.GameContent.UI.Elements.UIText.TextOriginX, Terraria.GameContent.UI.Elements.UIText.TextOriginY, System.value, Microsoft.Xna.Framework.Graphics.Vector2, Terraria.GameContent.UI.Elements.UIText.VerifyTextState(), Microsoft.Xna.Framework.Color.White, Terraria.UI.CalculatedStyle.Width, Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.