Esempio n. 1
0
        public Bounds2 DrawTextDebug(string str, Vector2 bottom_left_start_pos, float char_height, bool draw = true, SpriteRenderer.ISpriteShader shader = null)
        {
            if (null == shader)
            {
                shader = this.m_default_font_shader;
            }
            float   num     = char_height / (float)EmbeddedDebugFontData.CharSizei.Y;
            Vector2 vector  = new Vector2(-1f, 1f);
            Vector2 vector2 = vector * num;
            TRS     tRS     = default(TRS);

            tRS.R = Math._10;
            tRS.S = EmbeddedDebugFontData.CharSizef * num;
            tRS.T = bottom_left_start_pos;
            Vector2 max = bottom_left_start_pos;
            float   x   = tRS.T.X;

            if (draw)
            {
                this.DefaultFontShader.SetUVTransform(ref Math.UV_TransformFlipV);
                this.BeginSprites(this.m_embedded_font_texture_info, this.DefaultFontShader, str.Length);
            }
            for (int i = 0; i < str.Length; i++)
            {
                if (str[i] == '\n')
                {
                    tRS.T  -= new Vector2(0f, tRS.S.Y + vector2.Y);
                    tRS.T.X = x;
                }
                else
                {
                    if (draw)
                    {
                        int num2 = (int)(str[i] - ' ');
                        if (num2 < 0 || num2 >= EmbeddedDebugFontData.NumChars)
                        {
                            num2 = 31;
                        }
                        this.AddSprite(ref tRS, new Vector2i(num2, 0));
                    }
                    tRS.T += new Vector2(tRS.S.X + vector2.X, 0f);
                    max.X  = FMath.Max(tRS.T.X, max.X);
                    max.Y  = FMath.Min(tRS.T.Y, max.Y);
                }
            }
            if (draw)
            {
                this.EndSprites();
            }
            return(Bounds2.SafeBounds(bottom_left_start_pos + new Vector2(0f, tRS.S.Y), max));
        }
Esempio n. 2
0
        public Bounds2 DrawTextWithFontMap(string str, Vector2 bottom_left_start_pos, float char_height, bool draw, FontMap fontmap, SpriteRenderer.ISpriteShader shader)
        {
            float   num     = char_height / fontmap.CharPixelHeight;
            Vector2 vector  = new Vector2(1f, 1f);
            Vector2 vector2 = vector * num;
            Vector2 vector3 = bottom_left_start_pos;
            Vector2 max     = bottom_left_start_pos;
            float   x       = bottom_left_start_pos.X;

            if (draw)
            {
                shader.SetUVTransform(ref Math.UV_TransformFlipV);
                this.BeginSprites(new TextureInfo(fontmap.Texture), shader, str.Length);
            }
            for (int i = 0; i < str.Length; i++)
            {
                FontMap.CharData charData;
                if (str[i] == '\n')
                {
                    vector3  -= new Vector2(0f, char_height + vector2.Y);
                    vector3.X = x;
                }
                else if (fontmap.TryGetCharData(str[i], out charData))
                {
                    Vector2 vector4 = charData.PixelSize * num;
                    if (draw)
                    {
                        this.AddSprite(vector3, new Vector2(vector4.X, 0f), charData.UV);
                    }
                    vector3 += new Vector2(vector4.X + vector2.X, 0f);
                    max.X    = FMath.Max(vector3.X, max.X);
                    max.Y    = FMath.Min(vector3.Y, max.Y);
                }
            }
            if (draw)
            {
                this.EndSprites();
            }
            return(Bounds2.SafeBounds(bottom_left_start_pos + new Vector2(0f, char_height), max));
        }