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

◆ DrawColorCodedString() [1/2]

static Vector2 Terraria.UI.Chat.ChatManager.DrawColorCodedString ( SpriteBatch spriteBatch,
DynamicSpriteFont font,
string text,
Vector2 position,
Color baseColor,
float rotation,
Vector2 origin,
Vector2 baseScale,
float maxWidth = -1f,
bool ignoreColors = false )
inlinestatic

Definition at line 305 of file ChatManager.cs.

306 {
307 Vector2 vector = position;
308 Vector2 result = vector;
309 string[] array = text.Split('\n');
310 float x = font.MeasureString(" ").X;
311 Color color = baseColor;
312 float num = 1f;
313 float num2 = 0f;
314 string[] array2 = array;
315 for (int i = 0; i < array2.Length; i++)
316 {
317 string[] array3 = array2[i].Split(':');
318 foreach (string text2 in array3)
319 {
320 if (text2.StartsWith("sss"))
321 {
322 if (text2.StartsWith("sss1"))
323 {
324 if (!ignoreColors)
325 {
326 color = Color.Red;
327 }
328 }
329 else if (text2.StartsWith("sss2"))
330 {
331 if (!ignoreColors)
332 {
333 color = Color.Blue;
334 }
335 }
336 else if (text2.StartsWith("sssr") && !ignoreColors)
337 {
338 color = Color.White;
339 }
340 continue;
341 }
342 string[] array4 = text2.Split(' ');
343 for (int k = 0; k < array4.Length; k++)
344 {
345 if (k != 0)
346 {
347 vector.X += x * baseScale.X * num;
348 }
349 if (maxWidth > 0f)
350 {
351 float num3 = font.MeasureString(array4[k]).X * baseScale.X * num;
352 if (vector.X - position.X + num3 > maxWidth)
353 {
354 vector.X = position.X;
355 vector.Y += (float)font.LineSpacing * num2 * baseScale.Y;
356 result.Y = Math.Max(result.Y, vector.Y);
357 num2 = 0f;
358 }
359 }
360 if (num2 < num)
361 {
362 num2 = num;
363 }
364 DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, font, array4[k], vector, color, rotation, origin, baseScale * num, SpriteEffects.None, 0f);
365 vector.X += font.MeasureString(array4[k]).X * baseScale.X * num;
366 result.X = Math.Max(result.X, vector.X);
367 }
368 }
369 vector.X = position.X;
370 vector.Y += (float)font.LineSpacing * num2 * baseScale.Y;
371 result.Y = Math.Max(result.Y, vector.Y);
372 num2 = 0f;
373 }
374 return result;
375 }
static void DrawString(this SpriteBatch spriteBatch, DynamicSpriteFont spriteFont, string text, Vector2 position, Color color)
static byte Max(byte val1, byte val2)
Definition Math.cs:738

References System.array, Microsoft.Xna.Framework.Color.Blue, ReLogic.Graphics.DynamicSpriteFontExtensionMethods.DrawString(), System.Text.RegularExpressions.i, System.Math.Max(), Microsoft.Xna.Framework.Color.Red, System.text, Microsoft.Xna.Framework.Color.White, Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.