public void SetText(int index, string text)
        {
            gfx.DeleteTexture(ref Textures[index]);
            DrawTextArgs args = new DrawTextArgs(text, font, true);

            linkData[index] = default(LinkData);
            LinkFlags prevFlags = index > 0 ? linkData[index - 1].flags : 0;

            if (!IDrawer2D.EmptyText(text))
            {
                Texture tex = NextToken(text, 0, ref prevFlags) == -1 ? DrawSimple(ref args) :
                              DrawAdvanced(ref args, index, text);
                game.Drawer2D.ReducePadding(ref tex, Utils.Floor(args.Font.Size), 3);

                tex.X1          = CalcPos(HorizontalAnchor, XOffset, tex.Width, game.Width);
                tex.Y1          = CalcY(index, tex.Height);
                Textures[index] = tex;
                lines[index]    = text;
            }
            else
            {
                int height = PlaceholderHeight[index] ? defaultHeight : 0;
                int y      = CalcY(index, height);
                Textures[index] = new Texture(-1, 0, y, 0, height, 0, 0);
                lines[index]    = null;
            }
            UpdateDimensions();
        }
        public void SetText(int index, string text)
        {
            game.Graphics.DeleteTexture(ref Textures[index]);
            Texture tex;

            if (IDrawer2D.EmptyText(text))
            {
                lines[index] = null;
                tex          = default(Texture);
                tex.Height   = (ushort)(PlaceholderHeight[index] ? defaultHeight : 0);
            }
            else
            {
                lines[index] = text;
                DrawTextArgs args = new DrawTextArgs(text, font, true);

                if (!MightHaveUrls())
                {
                    tex = game.Drawer2D.MakeTextTexture(ref args, 0, 0);
                }
                else
                {
                    tex = DrawAdvanced(ref args, index, text);
                }
                game.Drawer2D.ReducePadding(ref tex, Utils.Floor(args.Font.Size), 3);
            }

            tex.X1          = CalcPos(HorizontalAnchor, XOffset, tex.Width, game.Width);
            tex.Y1          = CalcY(index, tex.Height);
            Textures[index] = tex;
            UpdateDimensions();
        }
Exemple #3
0
        public void SetText(string text)
        {
            game.Graphics.DeleteTexture(ref texture);
            if (IDrawer2D.EmptyText(text))
            {
                texture = default(Texture);
                Width   = 0; Height = defaultHeight;
            }
            else
            {
                DrawTextArgs args = new DrawTextArgs(text, font, true);
                texture = game.Drawer2D.MakeTextTexture(ref args, 0, 0);
                Width   = Math.Max(texture.Width, MinWidth);
                Height  = Math.Max((int)texture.Height, minHeight);

                Reposition();
                texture.X1 = X + (Width / 2 - texture.Width / 2);
                texture.Y1 = Y + (Height / 2 - texture.Height / 2);
            }
        }
        public void SetText(string text)
        {
            game.Graphics.DeleteTexture(ref texture);
            if (IDrawer2D.EmptyText(text))
            {
                texture = new Texture();
                Width   = 0; Height = defaultHeight;
            }
            else
            {
                DrawTextArgs args = new DrawTextArgs(text, font, true);
                texture = game.Drawer2D.MakeTextTexture(ref args, 0, 0);
                if (ReducePadding)
                {
                    game.Drawer2D.ReducePadding(ref texture, Utils.Floor(font.Size), 4);
                }
                Width = texture.Width; Height = texture.Height;

                Reposition();
                texture.X1 = X; texture.Y1 = Y;
            }
        }
        public void SetText(int index, string text)
        {
            gfx.DeleteTexture(ref Textures[index]);
            linkData[index] = default(LinkData);
            Texture tex;

            if (!IDrawer2D.EmptyText(text))
            {
                tex          = MakeTexture(index, text);
                lines[index] = text;
            }
            else
            {
                tex          = new Texture(-1, 0, 0, 0, 0, 0, 0);
                tex.Height   = (ushort)(PlaceholderHeight[index] ? defaultHeight : 0);
                lines[index] = null;
            }

            tex.X1          = CalcPos(HorizontalAnchor, XOffset, tex.Width, game.Width);
            tex.Y1          = CalcY(index, tex.Height);
            Textures[index] = tex;
            UpdateDimensions();
        }