Ejemplo n.º 1
0
            public void Draw(TextNode n, float lineX)
            {
                node = n;
                pt   = new Vector2(x + offsetX, offsetY);
                for (int i = 0; i < yline; ++i)
                {
                    pt.y += lines[i].y;
                }

                if (maxWidth == 0)
                {
                    return;
                }

                alignedX = AlignedFormatting(n.owner, xFormatting, maxWidth, lines[(int)(yline)].x, 0);
                fHeight  = node.getHeight();

                sb.Remove(0, sb.Length);

                Around around = n.owner.around;

                int   textindex = 0;
                float newx      = 0f;

                for (int k = 0; k < node.d_widthList.Count; ++k)
                {
                    Element e          = node.d_widthList[k];
                    float   totalwidth = e.totalwidth;
                    if ((x + totalwidth) > maxWidth)
                    {
                        if (x != 0f)
                        {
                            DrawCurrent(true, around, lineX);
                        }

                        if (e.widths == null)
                        {
                            if ((x + e.totalwidth > maxWidth))
                            {
                                DrawCurrent(true, around, lineX);
                            }
                            else
                            {
                                x += e.totalwidth;
                                sb.Append(node.d_text[textindex++]);
                            }
                        }
                        else
                        {
                            for (int m = 0; m < e.widths.Count;)
                            {
                                if (x != 0 && x + e.widths[m] > maxWidth)
                                {
                                    DrawCurrent(true, around, lineX);
                                }
                                else
                                {
                                    x += e.widths[m];
                                    sb.Append(node.d_text[textindex++]);
                                    ++m;
                                }
                            }
                        }
                    }
                    else if (!around.isContain(x, pt.y, totalwidth, fHeight, out newx))
                    {
                        DrawCurrent(false, around, lineX);

                        x    = newx;
                        pt.x = newx;
                        --k;
                    }
                    else
                    {
                        int ec = e.count;
                        sb.Append(node.d_text.Substring(textindex, ec));
                        textindex += ec;
                        x         += totalwidth;
                    }
                }

                if (sb.Length != 0)
                {
                    DrawCurrent(false, around, lineX);
                }

                if (node.d_bNewLine == true)
                {
                    yline++;
                    x = lineX;
                }
            }