GetVisibleColor() публичный Метод

public GetVisibleColor ( ) : Microsoft.Xna.Framework.Color
Результат Microsoft.Xna.Framework.Color
Пример #1
0
        public 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)
        {
            int     num1      = -1;
            Vector2 vec       = new Vector2((float)Main.mouseX, (float)Main.mouseY);
            Vector2 vector2_1 = position;
            Vector2 vector2_2 = vector2_1;
            float   x         = font.MeasureString(" ").X;
            Color   color     = baseColor;
            float   num2      = 0.0f;

            for (int index1 = 0; index1 < snippets.Length; ++index1)
            {
                TextSnippet snippet = snippets[index1];
                snippet.Update();
                if (!ignoreColors)
                {
                    color = snippet.GetVisibleColor();
                }
                float   scale = snippet.Scale;
                Vector2 size;
                if (snippet.UniqueDraw(false, out size, spriteBatch, vector2_1, color, scale))
                {
                    if (vec.Between(vector2_1, vector2_1 + size))
                    {
                        num1 = index1;
                    }
                    vector2_1.X += size.X * baseScale.X * scale;
                    vector2_2.X  = Math.Max(vector2_2.X, vector2_1.X);
                }
                else
                {
                    string[] strArray1 = snippet.Text.Split('\n');
                    foreach (string str in strArray1)
                    {
                        char[] chArray = new char[1] {
                            ' '
                        };
                        string[] strArray2 = str.Split(chArray);
                        for (int index2 = 0; index2 < strArray2.Length; ++index2)
                        {
                            if (index2 != 0)
                            {
                                vector2_1.X += x * baseScale.X * scale;
                            }
                            if ((double)maxWidth > 0.0)
                            {
                                float num3 = font.MeasureString(strArray2[index2]).X *baseScale.X *scale;
                                if ((double)vector2_1.X - (double)position.X + (double)num3 > (double)maxWidth)
                                {
                                    vector2_1.X  = position.X;
                                    vector2_1.Y += (float)font.get_LineSpacing() * num2 * baseScale.Y;
                                    vector2_2.Y  = Math.Max(vector2_2.Y, vector2_1.Y);
                                    num2         = 0.0f;
                                }
                            }
                            if ((double)num2 < (double)scale)
                            {
                                num2 = scale;
                            }
                            DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, font, strArray2[index2], vector2_1, color, rotation, origin, baseScale * snippet.Scale * scale, SpriteEffects.None, 0.0f);
                            Vector2 vector2_3 = font.MeasureString(strArray2[index2]);
                            if (vec.Between(vector2_1, vector2_1 + vector2_3))
                            {
                                num1 = index1;
                            }
                            vector2_1.X += vector2_3.X * baseScale.X * scale;
                            vector2_2.X  = Math.Max(vector2_2.X, vector2_1.X);
                        }
                        if (strArray1.Length > 1)
                        {
                            vector2_1.Y += (float)font.get_LineSpacing() * num2 * baseScale.Y;
                            vector2_1.X  = position.X;
                            vector2_2.Y  = Math.Max(vector2_2.Y, vector2_1.Y);
                            num2         = 0.0f;
                        }
                    }
                }
            }
            hoveredSnippet = num1;
            return(vector2_2);
        }
Пример #2
0
        // Token: 0x06000C5B RID: 3163 RVA: 0x003D8C40 File Offset: 0x003D6E40
        public 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)
        {
            int     num     = -1;
            Vector2 vec     = new Vector2((float)Main.mouseX, (float)Main.mouseY);
            Vector2 vector  = position;
            Vector2 vector2 = vector;
            float   x       = font.MeasureString(" ").X;
            Color   color   = baseColor;
            float   num2    = 0f;

            for (int i = 0; i < snippets.Length; i++)
            {
                TextSnippet textSnippet = snippets[i];
                textSnippet.Update();
                if (!ignoreColors)
                {
                    color = textSnippet.GetVisibleColor();
                }
                float   scale = textSnippet.Scale;
                Vector2 vector3;
                if (textSnippet.UniqueDraw(false, out vector3, spriteBatch, vector, color, scale))
                {
                    if (vec.Between(vector, vector + vector3))
                    {
                        num = i;
                    }
                    vector.X += vector3.X * baseScale.X * scale;
                    vector2.X = Math.Max(vector2.X, vector.X);
                }
                else
                {
                    string[] array = textSnippet.Text.Split(new char[]
                    {
                        '\n'
                    });
                    string[] array2 = array;
                    for (int j = 0; j < array2.Length; j++)
                    {
                        string[] array3 = array2[j].Split(new char[]
                        {
                            ' '
                        });
                        for (int k = 0; k < array3.Length; k++)
                        {
                            if (k != 0)
                            {
                                vector.X += x * baseScale.X * scale;
                            }
                            if (maxWidth > 0f)
                            {
                                float num3 = font.MeasureString(array3[k]).X *baseScale.X *scale;
                                if (vector.X - position.X + num3 > maxWidth)
                                {
                                    vector.X  = position.X;
                                    vector.Y += (float)font.LineSpacing * num2 * baseScale.Y;
                                    vector2.Y = Math.Max(vector2.Y, vector.Y);
                                    num2      = 0f;
                                }
                            }
                            if (num2 < scale)
                            {
                                num2 = scale;
                            }
                            spriteBatch.DrawString(font, array3[k], vector, color, rotation, origin, baseScale * textSnippet.Scale * scale, SpriteEffects.None, 0f);
                            Vector2 vector4 = font.MeasureString(array3[k]);
                            if (vec.Between(vector, vector + vector4))
                            {
                                num = i;
                            }
                            vector.X += vector4.X * baseScale.X * scale;
                            vector2.X = Math.Max(vector2.X, vector.X);
                        }
                        if (array.Length > 1)
                        {
                            vector.Y += (float)font.LineSpacing * num2 * baseScale.Y;
                            vector.X  = position.X;
                            vector2.Y = Math.Max(vector2.Y, vector.Y);
                            num2      = 0f;
                        }
                    }
                }
            }
            hoveredSnippet = num;
            return(vector2);
        }
Пример #3
0
        public static Vector2 DrawColorCodedString(SpriteBatch spriteBatch, SpriteFont font, TextSnippet[] snippets, Vector2 position, Color baseColor, float rotation, Vector2 origin, Vector2 baseScale, out int hoveredSnippet, float maxWidth, bool ignoreColors = false)
        {
            int     num    = -1;
            Vector2 vec    = new Vector2(Main.mouseX, Main.mouseY);
            Vector2 vector = position;
            Vector2 result = vector;
            float   x      = font.MeasureString(" ").X;
            Color   color  = baseColor;
            float   num2   = 1f;
            float   num3   = 0f;

            for (int i = 0; i < snippets.Length; i++)
            {
                TextSnippet textSnippet = snippets[i];
                textSnippet.Update();
                if (!ignoreColors)
                {
                    color = textSnippet.GetVisibleColor();
                }
                num2 = textSnippet.Scale;
                Vector2 size;
                if (textSnippet.UniqueDraw(false, out size, spriteBatch, vector, color, num2))
                {
                    if (vec.Between(vector, vector + size))
                    {
                        num = i;
                    }
                    vector.X += size.X * baseScale.X * num2;
                    result.X  = Math.Max(result.X, vector.X);
                    continue;
                }
                string[] array  = textSnippet.Text.Split('\n');
                string[] array2 = array;
                foreach (string text in array2)
                {
                    string[] array3 = text.Split(' ');
                    for (int k = 0; k < array3.Length; k++)
                    {
                        if (k != 0)
                        {
                            vector.X += x * baseScale.X * num2;
                        }
                        if (maxWidth > 0f)
                        {
                            float num4 = font.MeasureString(array3[k]).X *baseScale.X *num2;
                            if (vector.X - position.X + num4 > maxWidth)
                            {
                                vector.X  = position.X;
                                vector.Y += (float)font.LineSpacing * num3 * baseScale.Y;
                                result.Y  = Math.Max(result.Y, vector.Y);
                                num3      = 0f;
                            }
                        }
                        if (num3 < num2)
                        {
                            num3 = num2;
                        }
                        spriteBatch.DrawString(font, array3[k], vector, color, rotation, origin, baseScale * textSnippet.Scale * num2, SpriteEffects.None, 0f);
                        Vector2 value = font.MeasureString(array3[k]);
                        if (vec.Between(vector, vector + value))
                        {
                            num = i;
                        }
                        vector.X += value.X * baseScale.X * num2;
                        result.X  = Math.Max(result.X, vector.X);
                    }
                    if (array.Length > 1)
                    {
                        vector.Y += (float)font.LineSpacing * num3 * baseScale.Y;
                        vector.X  = position.X;
                        result.Y  = Math.Max(result.Y, vector.Y);
                        num3      = 0f;
                    }
                }
            }
            hoveredSnippet = num;
            return(result);
        }
Пример #4
0
        public 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)
        {
            int     num1 = -1;
            Vector2 vec;

            // ISSUE: explicit reference operation
            ((Vector2)@vec).\u002Ector((float)Main.mouseX, (float)Main.mouseY);
            Vector2 vector2_1 = position;
            Vector2 vector2_2 = vector2_1;
            float   x         = (float)font.MeasureString(" ").X;
            Color   color     = baseColor;
            float   num2      = 0.0f;

            for (int index1 = 0; index1 < snippets.Length; ++index1)
            {
                TextSnippet snippet = snippets[index1];
                snippet.Update();
                if (!ignoreColors)
                {
                    color = snippet.GetVisibleColor();
                }
                float   scale = snippet.Scale;
                Vector2 size;
                if (snippet.UniqueDraw(false, out size, spriteBatch, vector2_1, color, scale))
                {
                    if (vec.Between(vector2_1, Vector2.op_Addition(vector2_1, size)))
                    {
                        num1 = index1;
                    }
                    // ISSUE: explicit reference operation
                    // ISSUE: variable of a reference type
                    Vector2& local = @vector2_1;
                    // ISSUE: explicit reference operation
                    double num3 = (^ local).X + size.X * baseScale.X * (double)scale;
                    // ISSUE: explicit reference operation
                    (^ local).X = (__Null)num3;
                    vector2_2.X = (__Null)(double)Math.Max((float)vector2_2.X, (float)vector2_1.X);
                }
                else
                {
                    string[] strArray1 = snippet.Text.Split('\n');
                    foreach (string str in strArray1)
                    {
                        char[] chArray = new char[1] {
                            ' '
                        };
                        string[] strArray2 = str.Split(chArray);
                        for (int index2 = 0; index2 < strArray2.Length; ++index2)
                        {
                            if (index2 != 0)
                            {
                                // ISSUE: explicit reference operation
                                // ISSUE: variable of a reference type
                                Vector2& local = @vector2_1;
                                // ISSUE: explicit reference operation
                                double num3 = (^ local).X + (double)x * baseScale.X * (double)scale;
                                // ISSUE: explicit reference operation
                                (^ local).X = (__Null)num3;
                            }
                            if ((double)maxWidth > 0.0)
                            {
                                float num3 = (float)(font.MeasureString(strArray2[index2]).X *baseScale.X) * scale;
                                if (vector2_1.X - position.X + (double)num3 > (double)maxWidth)
                                {
                                    vector2_1.X = position.X;
                                    // ISSUE: explicit reference operation
                                    // ISSUE: variable of a reference type
                                    Vector2& local = @vector2_1;
                                    // ISSUE: explicit reference operation
                                    double num4 = (^ local).Y + (double)font.get_LineSpacing() * (double)num2 * baseScale.Y;
                                    // ISSUE: explicit reference operation
                                    (^ local).Y = (__Null)num4;
                                    vector2_2.Y = (__Null)(double)Math.Max((float)vector2_2.Y, (float)vector2_1.Y);
                                    num2        = 0.0f;
                                }
                            }
                            if ((double)num2 < (double)scale)
                            {
                                num2 = scale;
                            }
                            DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, font, strArray2[index2], vector2_1, color, rotation, origin, Vector2.op_Multiply(Vector2.op_Multiply(baseScale, snippet.Scale), scale), (SpriteEffects)0, 0.0f);
                            Vector2 vector2_3 = font.MeasureString(strArray2[index2]);
                            if (vec.Between(vector2_1, Vector2.op_Addition(vector2_1, vector2_3)))
                            {
                                num1 = index1;
                            }
                            // ISSUE: explicit reference operation
                            // ISSUE: variable of a reference type
                            Vector2& local1 = @vector2_1;
                            // ISSUE: explicit reference operation
                            double num5 = (^ local1).X + vector2_3.X * baseScale.X * (double)scale;
                            // ISSUE: explicit reference operation
                            (^ local1).X = (__Null)num5;
                            vector2_2.X  = (__Null)(double)Math.Max((float)vector2_2.X, (float)vector2_1.X);
                        }
                        if (strArray1.Length > 1)
                        {
                            // ISSUE: explicit reference operation
                            // ISSUE: variable of a reference type
                            Vector2& local = @vector2_1;
                            // ISSUE: explicit reference operation
                            double num3 = (^ local).Y + (double)font.get_LineSpacing() * (double)num2 * baseScale.Y;
                            // ISSUE: explicit reference operation
                            (^ local).Y = (__Null)num3;
                            vector2_1.X = position.X;
                            vector2_2.Y = (__Null)(double)Math.Max((float)vector2_2.Y, (float)vector2_1.Y);
                            num2        = 0.0f;
                        }
                    }
                }
            }
            hoveredSnippet = num1;
            return(vector2_2);
        }